diff --git a/src/libs/pdflib/bind/Makefile b/src/libs/pdflib/bind/Makefile new file mode 100644 index 0000000000..16c7664b26 --- /dev/null +++ b/src/libs/pdflib/bind/Makefile @@ -0,0 +1,8 @@ +# PDFlib bindings Makefile +# $Id: Makefile,v 1.1 2004/10/06 17:46:38 laplace Exp $ + +include ../config/mkcommon.inc + +SUB_DIRS = $(BINDTARGETS) + +include ../config/mksubdirs.inc diff --git a/src/libs/pdflib/bind/pdflib/c/Makefile b/src/libs/pdflib/bind/pdflib/c/Makefile new file mode 100644 index 0000000000..85d7e9fe52 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/Makefile @@ -0,0 +1,86 @@ +# Makefile for PDFlib C samples, C language binding +# $Id: Makefile,v 1.1 2004/10/06 17:46:38 laplace Exp $ + +top_builddir = ../../.. + +include $(top_builddir)/config/mkcommon.inc + +DEPLIBS = $(PDFLIBLINK) +LIBS = $(DEPLIBS) $(EXTERNALLIBS) +INCLUDES = $(PDFLIBINC) $(PDCORELIBINC) +FLAGS = $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) + +# the following is platform-specific +DLLIB = -ldl + +# ------------------------------ + +SRC = \ + $(srcdir)/chartab.c \ + $(srcdir)/hello.c \ + $(srcdir)/hellodl.c \ + $(srcdir)/image.c \ + $(srcdir)/pdfclock.c \ + $(srcdir)/invoice.c \ + $(srcdir)/businesscard.c \ + $(srcdir)/quickreference.c \ + $(srcdir)/smoketest.c \ + $(srcdir)/smoketestdl.c + +PROGS = \ + hello$(EXE) \ + image$(EXE) \ + pdfclock$(EXE) \ + chartab$(EXE) \ + invoice$(EXE) \ + businesscard$(EXE) \ + quickreference$(EXE) + +include $(top_builddir)/config/mkprogs.inc + +test:: $(PROGS) + -./hello + -./image + -./pdfclock + -./chartab + -./invoice + -./businesscard + -./quickreference + +smoke:: test smoketest$(EXE) + -./smoketest + +clean:: + $(RM) chartab.pdf hello.pdf image.pdf pdfclock.pdf invoice.pdf + $(RM) smoketest$(EXE) smoketestdl$(EXE) smoke_c_?.pdf smoke_cdl_?.pdf + $(RM) hellodl hellodl.pdf businesscard.pdf quickreference.pdf + +hello$(EXE): hello.c $(DEPLIBS) + $(PROGS_BUILD) + +image$(EXE): image.c $(DEPLIBS) + $(PROGS_BUILD) + +pdfclock$(EXE): pdfclock.c $(DEPLIBS) + $(PROGS_BUILD) + +chartab$(EXE): chartab.c $(DEPLIBS) + $(PROGS_BUILD) + +invoice$(EXE): invoice.c $(DEPLIBS) + $(PROGS_BUILD) + +businesscard$(EXE): businesscard.c $(DEPLIBS) + $(PROGS_BUILD) + +quickreference$(EXE): quickreference.c $(DEPLIBS) + $(PROGS_BUILD) + +smoketest$(EXE): smoketest.c $(DEPLIBS) + $(PROGS_BUILD) + +smoketestdl$(EXE): smoketestdl.c pdflibdl.c $(DEPLIBS) $(DLLIB) pdflibdl.h + $(PROGS_BUILD) pdflibdl.c $(DLLIB) + +hellodl$(EXE): hellodl.c pdflibdl.c $(DEPLIBS) $(DLLIB) pdflibdl.h + $(PROGS_BUILD) pdflibdl.c $(DLLIB) diff --git a/src/libs/pdflib/bind/pdflib/c/businesscard.c b/src/libs/pdflib/bind/pdflib/c/businesscard.c new file mode 100644 index 0000000000..46b101929e --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/businesscard.c @@ -0,0 +1,109 @@ +/* $Id: businesscard.c,v 1.1 2004/10/06 17:46:38 laplace Exp $ + * PDFlib client: block processing example in C + * + */ + +#include +#include + +#include "pdflib.h" + +int +main(void) +{ + PDF *p; + int i, blockcontainer, page; + char *infile = "boilerplate.pdf"; + + /* + * This is where font/image/PDF input files live. Adjust as necessary. + * + * Note that this directory must also contain the LuciduxSans font outline + * and metrics files. + */ + char *searchpath = "../data"; + + typedef struct { char *name; char *value; } blockdata; + + blockdata data[] = { + { "name", "Victor Kraxi" }, + { "business.title", "Chief Paper Officer" }, + { "business.address.line1", "17, Aviation Road" }, + { "business.address.city", "Paperfield" }, + { "business.telephone.voice","phone +1 234 567-89" }, + { "business.telephone.fax", "fax +1 234 567-98" }, + { "business.email", "victor@kraxi.com" }, + { "business.homepage", "www.kraxi.com" }, + }; + +#define BLOCKCOUNT (sizeof(data)/sizeof(data[0])) + + /* create a new PDFlib object */ + if ((p = PDF_new()) == (PDF *) 0) + { + printf("Couldn't create PDFlib object (out of memory)!\n"); + return(2); + } + + PDF_TRY(p) { + /* Set the search path for fonts and PDF files */ + + /* open new PDF file */ + if (PDF_open_file(p, "businesscard.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + PDF_set_parameter(p, "SearchPath", searchpath); + + /* This line is required to avoid problems on Japanese systems */ + PDF_set_parameter(p, "hypertextencoding", "host"); + + PDF_set_info(p, "Creator", "businesscard.c"); + PDF_set_info(p, "Author", "Thomas Merz"); + PDF_set_info(p, "Title","PDFlib block processing sample (C)"); + + blockcontainer = PDF_open_pdi(p, infile, "", 0); + if (blockcontainer == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + page = PDF_open_pdi_page(p, blockcontainer, 1, ""); + if (page == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + PDF_begin_page(p, 20, 20); /* dummy page size */ + + /* This will adjust the page size to the block container's size. */ + PDF_fit_pdi_page(p, page, 0, 0, "adjustpage"); + + /* Fill all text blocks with dynamic data */ + for (i = 0; i < (int) BLOCKCOUNT; i++) { + if (PDF_fill_textblock(p, page, data[i].name, data[i].value, 0, + "embedding encoding=host") == -1) { + printf("Warning: %s\n", PDF_get_errmsg(p)); + } + } + + PDF_end_page(p); /* close page */ + PDF_close_pdi_page(p, page); + + PDF_close(p); /* close PDF document */ + PDF_close_pdi(p, blockcontainer); + } + + PDF_CATCH(p) { + printf("PDFlib exception occurred in businesscard sample:\n"); + printf("[%d] %s: %s\n", + PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p)); + PDF_delete(p); + return(2); + } + + PDF_delete(p); /* delete the PDFlib object */ + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/c/businesscard.dsp b/src/libs/pdflib/bind/pdflib/c/businesscard.dsp new file mode 100644 index 0000000000..c7a7f7db22 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/businesscard.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="businesscard" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=businesscard - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "businesscard.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "businesscard.mak" CFG="businesscard - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "businesscard - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "businesscard - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "businesscard - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /out:"businesscard.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "businesscard - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PDFLIB_STATIC" /D "_MT" /FR /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /machine:I386 /out:"businesscard.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "businesscard - Win32 Release" +# Name "businesscard - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\businesscard.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/c/chartab.c b/src/libs/pdflib/bind/pdflib/c/chartab.c new file mode 100644 index 0000000000..f612de19cd --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/chartab.c @@ -0,0 +1,129 @@ +/* $Id: chartab.c,v 1.1 2004/10/06 17:46:38 laplace Exp $ + * PDFlib client: character table in C + * + */ + +#include +#include + +#include "pdflib.h" + +int +main(void) +{ + /* change these as required */ + const char *fontname = "LuciduxSans-Oblique"; + + /* This is where font/image/PDF input files live. Adjust as necessary. */ + char *searchpath = "../data"; + + /* list of encodings to use */ + const char *encodings[] = { "iso8859-1", "iso8859-2", "iso8859-15" }; + + /* whether or not to embed the font */ + int embed = 1; + +#define ENCODINGS ((int) ((sizeof(encodings)/sizeof(encodings[0])))) + + char buf[256]; + float x, y; + PDF *p; + int row, col, font, page; + +#define FONTSIZE ((float) 16) +#define TOP ((float) 700) +#define LEFT ((float) 50) +#define YINCR 2*FONTSIZE +#define XINCR 2*FONTSIZE + + /* create a new PDFlib object */ + if ((p = PDF_new()) == (PDF *) 0) + { + printf("Couldn't create PDFlib object (out of memory)!\n"); + return(2); + } + + PDF_TRY(p) + { + /* open new PDF file */ + if (PDF_open_file(p, "chartab.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + PDF_set_parameter(p, "openaction", "fitpage"); + PDF_set_parameter(p, "fontwarning", "true"); + + PDF_set_parameter(p, "SearchPath", searchpath); + + /* This line is required to avoid problems on Japanese systems */ + PDF_set_parameter(p, "hypertextencoding", "host"); + + PDF_set_info(p, "Creator", "chartab.c"); + PDF_set_info(p, "Author", "Thomas Merz"); + PDF_set_info(p, "Title", "Character table (C)"); + + /* loop over all encodings */ + for (page = 0; page < ENCODINGS; page++) + { + PDF_begin_page(p, a4_width, a4_height); /* start a new page */ + + /* print the heading and generate the bookmark */ + /* Change "host" encoding to "winansi" or whatever you need! */ + font = PDF_load_font(p, "Helvetica", 0, "host", ""); + PDF_setfont(p, font, FONTSIZE); + sprintf(buf, "%s (%s) %sembedded", + fontname, encodings[page], embed ? "" : "not "); + + PDF_show_xy(p, buf, LEFT - XINCR, TOP + 3 * YINCR); + PDF_add_bookmark(p, buf, 0, 0); + + /* print the row and column captions */ + PDF_setfont(p, font, 2 * FONTSIZE/3); + + for (row = 0; row < 16; row++) + { + sprintf(buf, "x%X", row); + PDF_show_xy(p, buf, LEFT + row*XINCR, TOP + YINCR); + + sprintf(buf, "%Xx", row); + PDF_show_xy(p, buf, LEFT - XINCR, TOP - row * YINCR); + } + + /* print the character table */ + font = PDF_load_font(p, fontname, 0, encodings[page], + embed ? "embedding": ""); + PDF_setfont(p, font, FONTSIZE); + + y = TOP; + x = LEFT; + + for (row = 0; row < 16; row++) + { + for (col = 0; col < 16; col++) { + sprintf(buf, "%c", 16*row + col); + PDF_show_xy(p, buf, x, y); + x += XINCR; + } + x = LEFT; + y -= YINCR; + } + + PDF_end_page(p); /* close page */ + } + + PDF_close(p); /* close PDF document */ + } + PDF_CATCH(p) + { + printf("PDFlib exception occurred in chartab sample:\n"); + printf("[%d] %s: %s\n", + PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p)); + PDF_delete(p); + return(2); + } + + PDF_delete(p); /* delete the PDFlib object */ + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/c/chartab.dsp b/src/libs/pdflib/bind/pdflib/c/chartab.dsp new file mode 100644 index 0000000000..c59f7b4cee --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/chartab.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="chartab" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=chartab - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "chartab.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "chartab.mak" CFG="chartab - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "chartab - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "chartab - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "chartab - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /out:"chartab.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "chartab - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PDFLIB_STATIC" /D "_MT" /FR /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /machine:I386 /out:"chartab.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "chartab - Win32 Release" +# Name "chartab - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\chartab.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/c/examples_c.dsw b/src/libs/pdflib/bind/pdflib/c/examples_c.dsw new file mode 100644 index 0000000000..c1f4135f53 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/examples_c.dsw @@ -0,0 +1,101 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "businesscard"=".\businesscard.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "chartab"=".\chartab.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "hello"=".\hello.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "image"=".\image.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "invoice"=".\invoice.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "pdfclock"=".\pdfclock.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "quickreference"=".\quickreference.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/libs/pdflib/bind/pdflib/c/hello.c b/src/libs/pdflib/bind/pdflib/c/hello.c new file mode 100644 index 0000000000..8e0b39cfeb --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/hello.c @@ -0,0 +1,63 @@ +/* $Id: hello.c,v 1.1 2004/10/06 17:46:38 laplace Exp $ + * PDFlib client: hello example in C + * + */ + +#include +#include + +#include "pdflib.h" + +int +main(void) +{ + PDF *p; + int font; + + /* create a new PDFlib object */ + if ((p = PDF_new()) == (PDF *) 0) + { + printf("Couldn't create PDFlib object (out of memory)!\n"); + return(2); + } + + PDF_TRY(p) { + /* open new PDF file */ + if (PDF_open_file(p, "hello.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + /* This line is required to avoid problems on Japanese systems */ + PDF_set_parameter(p, "hypertextencoding", "host"); + + PDF_set_info(p, "Creator", "hello.c"); + PDF_set_info(p, "Author", "Thomas Merz"); + PDF_set_info(p, "Title", "Hello, world (C)!"); + + PDF_begin_page(p, a4_width, a4_height); /* start a new page */ + + /* Change "host" encoding to "winansi" or whatever you need! */ + font = PDF_load_font(p, "Helvetica-Bold", 0, "host", ""); + + PDF_setfont(p, font, 24); + PDF_set_text_pos(p, 50, 700); + PDF_show(p, "Hello, world!"); + PDF_continue_text(p, "(says C)"); + PDF_end_page(p); /* close page */ + + PDF_close(p); /* close PDF document */ + } + + PDF_CATCH(p) { + printf("PDFlib exception occurred in hello sample:\n"); + printf("[%d] %s: %s\n", + PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p)); + PDF_delete(p); + return(2); + } + + PDF_delete(p); /* delete the PDFlib object */ + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/c/hello.dsp b/src/libs/pdflib/bind/pdflib/c/hello.dsp new file mode 100644 index 0000000000..5f203c38f7 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/hello.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="hello" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=hello - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "hello.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "hello.mak" CFG="hello - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "hello - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "hello - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "hello - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /out:"hello.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "hello - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PDFLIB_STATIC" /D "_MT" /FR /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /machine:I386 /out:"hello.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "hello - Win32 Release" +# Name "hello - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\hello.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/c/hellodl.c b/src/libs/pdflib/bind/pdflib/c/hellodl.c new file mode 100644 index 0000000000..d468a10540 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/hellodl.c @@ -0,0 +1,66 @@ +/* $Id: hellodl.c,v 1.1 2004/10/06 17:46:38 laplace Exp $ + * PDFlib client: hello example in C with dynamic DLL loading + * + */ + +#include +#include + +#include "pdflibdl.h" + +int +main(void) +{ + PDF *p; + int font; + PDFlib_api *PDFlib; + + /* load the PDFlib dynamic library and create a new PDFlib object*/ + if ((PDFlib = PDF_new_dl(&p)) == (PDFlib_api *) NULL) + { + printf("Couldn't create PDFlib object (DLL not found?)\n"); + return(2); + } + + PDF_TRY_DL(PDFlib, p) { + /* open new PDF file */ + if (PDFlib->PDF_open_file(p, "hellodl.pdf") == -1) { + printf("Error: %s\n", PDFlib->PDF_get_errmsg(p)); + return(2); + } + + /* This line is required to avoid problems on Japanese systems */ + PDFlib->PDF_set_parameter(p, "hypertextencoding", "host"); + + PDFlib->PDF_set_info(p, "Creator", "hello.c"); + PDFlib->PDF_set_info(p, "Author", "Thomas Merz"); + PDFlib->PDF_set_info(p, "Title", "Hello, world (C DLL)!"); + + PDFlib->PDF_begin_page(p, a4_width, a4_height); /* start a new page */ + + /* Change "host" encoding to "winansi" or whatever you need! */ + font = PDFlib->PDF_load_font(p, "Helvetica-Bold", 0, "host", ""); + + PDFlib->PDF_setfont(p, font, 24); + PDFlib->PDF_set_text_pos(p, 50, 700); + PDFlib->PDF_show(p, "Hello, world!"); + PDFlib->PDF_continue_text(p, "(says C DLL)"); + PDFlib->PDF_end_page(p); /* close page */ + + PDFlib->PDF_close(p); /* close PDF document */ + } + + PDF_CATCH_DL(PDFlib, p) { + printf("PDFlib exception occurred in hellodl sample:\n"); + printf("[%d] %s: %s\n", + PDFlib->PDF_get_errnum(p), PDFlib->PDF_get_apiname(p), + PDFlib->PDF_get_errmsg(p)); + PDF_delete_dl(PDFlib, p); + return(2); + } + + /* delete the PDFlib object and unload the library */ + PDF_delete_dl(PDFlib, p); + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/c/image.c b/src/libs/pdflib/bind/pdflib/c/image.c new file mode 100644 index 0000000000..8085a5a3d5 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/image.c @@ -0,0 +1,71 @@ +/* $Id: image.c,v 1.1 2004/10/06 17:46:38 laplace Exp $ + * PDFlib client: image example in C + * + */ + +#include +#include + +#include "pdflib.h" + +int +main(void) +{ + PDF *p; + int image; + char *imagefile = "nesrin.jpg"; + + /* This is where font/image/PDF input files live. Adjust as necessary. */ + char *searchpath = "../data"; + + /* create a new PDFlib object */ + if ((p = PDF_new()) == (PDF *) 0) + { + printf("Couldn't create PDFlib object (out of memory)!\n"); + return(2); + } + + PDF_TRY(p){ + /* open new PDF file */ + if (PDF_open_file(p, "image.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + PDF_set_parameter(p, "SearchPath", searchpath); + + /* This line is required to avoid problems on Japanese systems */ + PDF_set_parameter(p, "hypertextencoding", "host"); + + PDF_set_info(p, "Creator", "image.c"); + PDF_set_info(p, "Author", "Thomas Merz"); + PDF_set_info(p, "Title", "image sample (C)"); + + image = PDF_load_image(p, "auto", imagefile, 0, ""); + + if (image == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(3); + } + + /* dummy page size, will be adjusted by PDF_fit_image() */ + PDF_begin_page(p, 10, 10); + PDF_fit_image(p, image, (float) 0.0, (float) 0.0, "adjustpage"); + PDF_close_image(p, image); + PDF_end_page(p); /* close page */ + + PDF_close(p); /* close PDF document */ + } + + PDF_CATCH(p) { + printf("PDFlib exception occurred in image sample:\n"); + printf("[%d] %s: %s\n", + PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p)); + PDF_delete(p); + return(2); + } + + PDF_delete(p); /* delete the PDFlib object */ + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/c/image.dsp b/src/libs/pdflib/bind/pdflib/c/image.dsp new file mode 100644 index 0000000000..31ad143c2d --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/image.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="image" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=image - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "image.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "image.mak" CFG="image - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "image - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "image - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "image - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /out:"image.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "image - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PDFLIB_STATIC" /D "_MT" /FR /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /machine:I386 /out:"image.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "image - Win32 Release" +# Name "image - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\image.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/c/invoice.c b/src/libs/pdflib/bind/pdflib/c/invoice.c new file mode 100644 index 0000000000..ad075d9a38 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/invoice.c @@ -0,0 +1,196 @@ +/* $Id: invoice.c,v 1.1 2004/10/06 17:46:38 laplace Exp $ + * + * PDFlib/PDI client: invoice generation demo + */ + +#include +#include +#include + +#include "pdflib.h" + +int +main(void) +{ + PDF * p; + int i, form, page, regularfont, boldfont; + char * infile = "stationery.pdf"; + + /* This is where font/image/PDF input files live. Adjust as necessary. */ + char *searchpath = "../data"; + + const float col1 = 55; + const float col2 = 100; + const float col3 = 330; + const float col4 = 430; + const float col5 = 530; + time_t timer; + struct tm ltime; + float fontsize = 12, leading, y; + float sum, total; + float pagewidth = 595, pageheight = 842; + char buf[128]; + char *closingtext = + "30 days warranty starting at the day of sale. " + "This warranty covers defects in workmanship only. " + "Kraxi Systems, Inc. will, at its option, repair or replace the " + "product under the warranty. This warranty is not transferable. " + "No returns or exchanges will be accepted for wet products."; + + typedef struct { char *name; float price; int quantity; } articledata; + + articledata data[] = { + { "Super Kite", 20, 2}, + { "Turbo Flyer", 40, 5}, + { "Giga Trash", 180, 1}, + { "Bare Bone Kit", 50, 3}, + { "Nitty Gritty", 20, 10}, + { "Pretty Dark Flyer", 75, 1}, + { "Free Gift", 0, 1}, + }; + +#define ARTICLECOUNT (sizeof(data)/sizeof(data[0])) + + static const char *months[] = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; + + /* create a new PDFlib object */ + if ((p = PDF_new()) == (PDF *) 0) + { + printf("Couldn't create PDFlib object (out of memory)!\n"); + return(2); + } + + PDF_TRY(p) { + /* open new PDF file */ + if (PDF_open_file(p, "invoice.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + PDF_set_parameter(p, "SearchPath", searchpath); + + /* This line is required to avoid problems on Japanese systems */ + PDF_set_parameter(p, "hypertextencoding", "host"); + + PDF_set_info(p, "Creator", "invoice.c"); + PDF_set_info(p, "Author", "Thomas Merz"); + PDF_set_info(p, "Title", "PDFlib invoice generation demo (C)"); + + form = PDF_open_pdi(p, infile, "", 0); + if (form == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + page = PDF_open_pdi_page(p, form, 1, ""); + if (page == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + boldfont = PDF_load_font(p, "Helvetica-Bold", 0, "host", ""); + regularfont = PDF_load_font(p, "Helvetica", 0, "host", ""); + leading = fontsize + 2; + + /* Establish coordinates with the origin in the upper left corner. */ + PDF_set_parameter(p, "topdown", "true"); + + PDF_begin_page(p, pagewidth, pageheight); /* A4 page */ + + PDF_fit_pdi_page(p, page, 0, pageheight, ""); + PDF_close_pdi_page(p, page); + + PDF_setfont(p, regularfont, fontsize); + + /* Print the address */ + y = 170; + PDF_set_value(p, "leading", leading); + + PDF_show_xy(p, "John Q. Doe", col1, y); + PDF_continue_text(p, "255 Customer Lane"); + PDF_continue_text(p, "Suite B"); + PDF_continue_text(p, "12345 User Town"); + PDF_continue_text(p, "Everland"); + + /* Print the header and date */ + + PDF_setfont(p, boldfont, fontsize); + y = 300; + PDF_show_xy(p, "INVOICE", col1, y); + + time(&timer); + ltime = *localtime(&timer); + sprintf(buf, "%s %d, %d", + months[ltime.tm_mon], ltime.tm_mday, ltime.tm_year + 1900); + PDF_fit_textline(p, buf, 0, col5, y, "position {100 0}"); + + /* Print the invoice header line */ + PDF_setfont(p, boldfont, fontsize); + + /* "position {0 0}" is left-aligned, "position {100 0}" right-aligned */ + y = 370; + PDF_fit_textline(p, "ITEM", 0, col1, y, "position {0 0}"); + PDF_fit_textline(p, "DESCRIPTION", 0, col2, y, "position {0 0}"); + PDF_fit_textline(p, "QUANTITY", 0, col3, y, "position {100 0}"); + PDF_fit_textline(p, "PRICE", 0, col4, y, "position {100 0}"); + PDF_fit_textline(p, "AMOUNT", 0, col5, y, "position {100 0}"); + + /* Print the article list */ + + PDF_setfont(p, regularfont, fontsize); + y += 2*leading; + total = 0; + + for (i = 0; i < (int) ARTICLECOUNT; i++) { + sprintf(buf, "%d", i+1); + PDF_show_xy(p, buf, col1, y); + + PDF_show_xy(p, data[i].name, col2, y); + + sprintf(buf, "%d", data[i].quantity); + PDF_fit_textline(p, buf, 0, col3, y, "position {100 0}"); + + sprintf(buf, "%.2f", data[i].price); + PDF_fit_textline(p, buf, 0, col4, y, "position {100 0}"); + + sum = data[i].price * data[i].quantity; + sprintf(buf, "%.2f", sum); + PDF_fit_textline(p, buf, 0, col5, y, "position {100 0}"); + + y += leading; + total += sum; + } + + y += leading; + PDF_setfont(p, boldfont, fontsize); + sprintf(buf, "%.2f", total); + PDF_fit_textline(p, buf, 0, col5, y, "position {100 0}"); + + /* Print the closing text */ + + y += 5*leading; + PDF_setfont(p, regularfont, fontsize); + PDF_set_value(p, "leading", leading); + PDF_show_boxed(p, closingtext, + col1, y + 4*leading, col5-col1, 4*leading, "justify", ""); + + PDF_end_page(p); + PDF_close(p); + PDF_close_pdi(p, form); + } + + PDF_CATCH(p) { + printf("PDFlib exception occurred in invoice sample:\n"); + printf("[%d] %s: %s\n", + PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p)); + PDF_delete(p); + return(2); + } + + PDF_delete(p); + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/c/invoice.dsp b/src/libs/pdflib/bind/pdflib/c/invoice.dsp new file mode 100644 index 0000000000..51513f7d35 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/invoice.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="invoice" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=invoice - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "invoice.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "invoice.mak" CFG="invoice - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "invoice - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "invoice - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "invoice - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /out:"invoice.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "invoice - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PDFLIB_STATIC" /D "_MT" /FR /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /machine:I386 /out:"invoice.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "invoice - Win32 Release" +# Name "invoice - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\invoice.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/c/pdfclock.c b/src/libs/pdflib/bind/pdflib/c/pdfclock.c new file mode 100644 index 0000000000..10e223e187 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/pdfclock.c @@ -0,0 +1,131 @@ +/* $Id: pdfclock.c,v 1.1 2004/10/06 17:46:38 laplace Exp $ + * A little PDFlib application to draw an analog clock. + * + */ + +#include +#include +#include + +#include "pdflib.h" + +#define RADIUS 200.0f +#define MARGIN 20.0f + +int +main(void) +{ + PDF *p; + float alpha; + time_t timer; + struct tm ltime; + + /* create a new PDFlib object */ + if ((p = PDF_new()) == (PDF *) 0) + { + printf("Couldn't create PDFlib object (out of memory)!\n"); + return(2); + } + + PDF_TRY(p) { + /* open new PDF file */ + if (PDF_open_file(p, "pdfclock.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + /* This line is required to avoid problems on Japanese systems */ + PDF_set_parameter(p, "hypertextencoding", "host"); + + PDF_set_info(p, "Creator", "pdfclock.c"); + PDF_set_info(p, "Author", "Thomas Merz"); + PDF_set_info(p, "Title", "PDF clock (C)"); + + PDF_begin_page(p, (float) (2 * (RADIUS + MARGIN)), + (float) (2 * (RADIUS + MARGIN))); + + PDF_translate(p, RADIUS + MARGIN, RADIUS + MARGIN); + PDF_setcolor(p, "fillstroke", "rgb", 0, 0, 1, 0); + PDF_save(p); + + /* minute strokes */ + PDF_setlinewidth(p, 2); + for (alpha = 0; alpha < 360; alpha += 6) + { + PDF_rotate(p, 6); + PDF_moveto(p, RADIUS, 0); + PDF_lineto(p, (float) (RADIUS-MARGIN/3), 0); + PDF_stroke(p); + } + + PDF_restore(p); + PDF_save(p); + + /* 5 minute strokes */ + PDF_setlinewidth(p, 3); + for (alpha = 0; alpha < 360; alpha += 30) + { + PDF_rotate(p, 30); + PDF_moveto(p, RADIUS, 0); + PDF_lineto(p, RADIUS-MARGIN, 0); + PDF_stroke(p); + } + + time(&timer); + ltime = *localtime(&timer); + + /* draw hour hand */ + PDF_save(p); + PDF_rotate(p, + (float)(-((ltime.tm_min/60.0) + ltime.tm_hour - 3.0) * 30.0)); + PDF_moveto(p, -RADIUS/10, -RADIUS/20); + PDF_lineto(p, RADIUS/2, 0); + PDF_lineto(p, -RADIUS/10, RADIUS/20); + PDF_closepath(p); + PDF_fill(p); + PDF_restore(p); + + /* draw minute hand */ + PDF_save(p); + PDF_rotate(p, + (float) (-((ltime.tm_sec/60.0) + ltime.tm_min - 15.0) * 6.0)); + PDF_moveto(p, -RADIUS/10, -RADIUS/20); + PDF_lineto(p, RADIUS * 0.8f, 0); + PDF_lineto(p, -RADIUS/10, RADIUS/20); + PDF_closepath(p); + PDF_fill(p); + PDF_restore(p); + + /* draw second hand */ + PDF_setcolor(p, "fillstroke", "rgb", 1, 0, 0, 0); + PDF_setlinewidth(p, 2); + PDF_save(p); + PDF_rotate(p, (float) -((ltime.tm_sec - 15.0) * 6.0)); + PDF_moveto(p, -RADIUS/5, 0); + PDF_lineto(p, RADIUS, 0); + PDF_stroke(p); + PDF_restore(p); + + /* draw little circle at center */ + PDF_circle(p, 0, 0, (float) RADIUS/30); + PDF_fill(p); + + PDF_restore(p); + + PDF_end_page(p); + + PDF_close(p); + } + + PDF_CATCH(p) { + printf("PDFlib exception occurred in pdfclock sample:\n"); + printf("[%d] %s: %s\n", + PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p)); + PDF_delete(p); + return(2); + } + + PDF_delete(p); /* delete the PDFlib object */ + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/c/pdfclock.dsp b/src/libs/pdflib/bind/pdflib/c/pdfclock.dsp new file mode 100644 index 0000000000..903e2df14a --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/pdfclock.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="pdfclock" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=pdfclock - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pdfclock.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pdfclock.mak" CFG="pdfclock - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pdfclock - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "pdfclock - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pdfclock - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /out:"pdfclock.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "pdfclock - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PDFLIB_STATIC" /D "_MT" /FR /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /machine:I386 /out:"pdfclock.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "pdfclock - Win32 Release" +# Name "pdfclock - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdfclock.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/c/pdflibdl.c b/src/libs/pdflib/bind/pdflib/c/pdflibdl.c new file mode 100644 index 0000000000..f04276a276 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/pdflibdl.c @@ -0,0 +1,532 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdflibdl.c,v 1.1 2004/10/06 17:46:38 laplace Exp $ + * + * C wrapper code for dynamically loading the PDFlib DLL at runtime. + * + * This module is not supported on all platforms. + * + */ + +#include + +#include "pdflibdl.h" + +/* enable this to avoid error messages */ +//#define PDF_SILENT + +/* ---------------------------------- WIN32 ----------------------------- */ + +#ifdef WIN32 + +#define WIN32_LEAN_AND_MEAN +#include +#include +#undef WIN32_LEAN_AND_MEAN + +#define PDF_DLLNAME "pdflib.dll" + +static void * +pdf_dlopen(const char *filename) +{ + return (void *) LoadLibrary(filename); +} + +static void * +pdf_dlsym(void *handle, const char *funcname) +{ + return (void *) GetProcAddress((HINSTANCE) handle, funcname); +} + +static void +pdf_dlclose(void *handle) +{ + (void) FreeLibrary((HINSTANCE) handle); +} + +/* ---------------------------------- MVS ----------------------------- */ + +#elif defined(__MVS__) + +#include +#include + +#define PDF_DLLNAME "PDFLIB" + +static void * +pdf_dlopen(const char *filename) +{ + return dllload(filename); +} + +static void * +pdf_dlsym(void *handle, const char *funcname) +{ + return dllqueryfn((dllhandle *) handle, funcname); +} + +static void pdf_dlclose(void *handle) +{ + (void) dllfree((dllhandle *) handle); +} + +/* ---------------------------------- Linux ----------------------------- */ + +#elif defined(linux) + +#include + +#define PDF_DLLNAME "libpdf.so" + +static void * +pdf_dlopen(const char *filename) +{ + return dlopen(filename, RTLD_LAZY); +} + +static void * +pdf_dlsym(void *handle, const char *funcname) +{ + return dlsym(handle, funcname); +} + +static void pdf_dlclose(void *handle) +{ + (void) dlclose(handle); +} + +/* ---------------------------------- Mac OS X ----------------------------- */ + +#elif defined(__ppc__) && defined(__APPLE__) + +#define PDF_DLLNAME "libpdf.dylib" + +/* + * The dl code for Mac OS X has been butchered from dlcompat, + * see http://www.opendarwin.org/projects/dlcompat + * It contained the copyright notice below. + */ + +/* +Copyright (c) 2002 Peter O'Gorman + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include +#include + +#if defined (__GNUC__) && __GNUC__ > 3 +#define dl_restrict __restrict +#else +#define dl_restrict +#endif +/* + * Structure filled in by dladdr(). + */ + +typedef struct dl_info { + const char *dli_fname; /* Pathname of shared object */ + void *dli_fbase; /* Base address of shared object */ + const char *dli_sname; /* Name of nearest symbol */ + void *dli_saddr; /* Address of nearest symbol */ +} Dl_info; + +#define RTLD_LAZY 0x1 +#define RTLD_NOW 0x2 +#define RTLD_LOCAL 0x4 +#define RTLD_GLOBAL 0x8 +#define RTLD_NOLOAD 0x10 +#define RTLD_NODELETE 0x80 + +/* + * Special handle arguments for dlsym(). + */ +#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ +#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ + +static void *dlsymIntern(void *handle, const char *symbol); + +void *pdf_dlopen(const char *path) +{ + int mode = RTLD_LAZY; + void *module = 0; + NSObjectFileImage ofi = 0; + NSObjectFileImageReturnCode ofirc; + static int (*make_private_module_public) (NSModule module) = 0; + unsigned int flags = + NSLINKMODULE_OPTION_RETURN_ON_ERROR | NSLINKMODULE_OPTION_PRIVATE; + +/* If we got no path, the app wants the global namespace, use -1 as the marker + in this case */ + if (!path) + return (void *)-1; + + /* Create the object file image, works for things linked with the + -bundle arg to ld */ + ofirc = NSCreateObjectFileImageFromFile(path, &ofi); + switch (ofirc) + { + case NSObjectFileImageSuccess: + /* It was okay, so use NSLinkModule to link in the image */ + if (!(mode & RTLD_LAZY)) flags += NSLINKMODULE_OPTION_BINDNOW; + module = NSLinkModule(ofi, path,flags); + /* Don't forget to destroy the object file image, unless you like leaks */ + NSDestroyObjectFileImage(ofi); + /* If the mode was global, then change the module, this avoids + multiply defined symbol errors to first load private then make + global. Silly, isn't it. */ + if ((mode & RTLD_GLOBAL)) + { + if (!make_private_module_public) + { + _dyld_func_lookup("__dyld_NSMakePrivateModulePublic", + (unsigned long *)&make_private_module_public); + } + make_private_module_public(module); + } + break; + case NSObjectFileImageInappropriateFile: +/* It may have been a dynamic library rather than a bundle, try to load it */ + module = + (void *)NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR); + break; + case NSObjectFileImageFailure: + /* + error(0,"Object file setup failure : \"%s\"", path); + */ + return 0; + case NSObjectFileImageArch: + /* + error(0,"No object for this architecture : \"%s\"", path); + */ + return 0; + case NSObjectFileImageFormat: + /* + error(0,"Bad object file format : \"%s\"", path); + */ + return 0; + case NSObjectFileImageAccess: + /* + error(0,"Can't read object file : \"%s\"", path); + */ + return 0; + } + if (!module) + /* + error(0, "Can not open \"%s\"", path); + */ + ; + + return module; +} + +/* dlsymIntern is used by dlsym to find the symbol */ +void *dlsymIntern(void *handle, const char *symbol) +{ + NSSymbol *nssym = 0; + /* If the handle is -1, if is the app global context */ + if (handle == (void *)-1) + { + /* Global context, use NSLookupAndBindSymbol */ + if (NSIsSymbolNameDefined(symbol)) + { + nssym = NSLookupAndBindSymbol(symbol); + } + + } + /* Now see if the handle is a struch mach_header* or not, use + NSLookupSymbol in image for libraries, and NSLookupSymbolInModule + for bundles */ + else + { + /* Check for both possible magic numbers depending on x86/ppc byte order */ + if ((((struct mach_header *)handle)->magic == MH_MAGIC) || + (((struct mach_header *)handle)->magic == MH_CIGAM)) + { + if (NSIsSymbolNameDefinedInImage((struct mach_header *)handle, symbol)) + { + nssym = NSLookupSymbolInImage((struct mach_header *)handle, + symbol, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND + | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + } + + } + else + { + nssym = NSLookupSymbolInModule(handle, symbol); + } + } + if (!nssym) + { + /* + error(0, "Symbol \"%s\" Not found", symbol); + */ + return NULL; + } + return NSAddressOfSymbol(nssym); +} + +int pdf_dlclose(void *handle) +{ + if ((((struct mach_header *)handle)->magic == MH_MAGIC) || + (((struct mach_header *)handle)->magic == MH_CIGAM)) + { + /* + error(-1, "Can't remove dynamic libraries on darwin"); + */ + return 0; + } + if (!NSUnLinkModule(handle, 0)) + { + /* + error(0, "unable to unlink module %s", NSNameOfModule(handle)); + */ + return 1; + } + return 0; +} + +/* dlsym, prepend the underscore and call dlsymIntern */ +void *pdf_dlsym(void *handle, const char *symbol) +{ + static char undersym[257]; /* Saves calls to malloc(3) */ + int sym_len = strlen(symbol); + void *value = NULL; + char *malloc_sym = NULL; + + if (sym_len < 256) + { + snprintf(undersym, 256, "_%s", symbol); + value = dlsymIntern(handle, undersym); + } + else + { + malloc_sym = malloc(sym_len + 2); + if (malloc_sym) + { + sprintf(malloc_sym, "_%s", symbol); + value = dlsymIntern(handle, malloc_sym); + free(malloc_sym); + } + else + { + /* + error(-1, "Unable to allocate memory"); + */ + } + } + return value; +} + +/* ---------------------------------- AS/400 ----------------------------- */ + +#elif defined __ILEC400__ + +#include + +#include +#include +#include +#include "mgosifc.h" + +#define PDF_DLLNAME "PDFLIB" + +static void * +pdf_dlopen(const char *filename) +{ + char libName[11], objName[11], *s; + HMODULE handle; + _SYSPTR pSrvPgm; + Qle_ABP_Info_t actInfo; + int actInfoLen; + Qus_EC_t errCode; + + memset(libName, '\0', sizeof(libName)); + if ((s = strchr(filename, '/')) == NULL) { + s = filename; + } else { + memcpy(libName, filename, s - filename); + if (!strcmp(libName, "*LIBL")) + libName[0] = '\0'; + s += 1; + } + strcpy(objName, s); + + /* Get system pointer to service program */ + pSrvPgm = rslvsp(WLI_SRVPGM, objName, libName, _AUTH_NONE); + + /* Activate Bound Program */ + handle = malloc(sizeof(int)); + actInfoLen = sizeof(actInfo); + errCode.Bytes_Provided = sizeof(errCode); + QleActBndPgm(&pSrvPgm, handle, &actInfo, &actInfoLen, &errCode); + + if (errCode.Bytes_Available > 0) + return NULL; + + return (void *) handle; +} + +static void * +pdf_dlsym(void *handle, const char *funcname) +{ + int expID; + int expNameLen; + void *ret; + int expType; + Qus_EC_t errCode; + + expID = 0; + expNameLen = strlen(funcname); + errCode.Bytes_Provided = sizeof(errCode); + QleGetExp((HMODULE) handle, + &expID, &expNameLen, funcname, &ret, &expType, &errCode); + + if (errCode.Bytes_Available > 0) + return NULL; + + return ret; +} + +static void pdf_dlclose(void *handle) +{ + free((HMODULE) handle); +} + +/* ---------------------------------- unknown ----------------------------- */ + +#else + +#error No DLL loading code for this platform available! + +#endif + +/* ---------------------------------- generic ----------------------------- */ + +static void +pdf_dlerror(const char *msg) +{ +#ifndef PDF_SILENT + fprintf(stderr, msg); +#endif +} + +/* Load the PDFlib DLL and fetch the API structure */ + +PDFLIB_API PDFlib_api * PDFLIB_CALL +PDF_new_dl(PDF **pp) +{ + PDFlib_api *PDFlib, *(PDFLIB_CALL *get_api)(void); + char buf[256]; + void *handle; + PDF *p; + + /* load the PDFLIB DLL... */ + handle = pdf_dlopen(PDF_DLLNAME); + + if (!handle) + { + pdf_dlerror("Error: couldn't load PDFlib DLL\n"); + return NULL; + } + + /* ...and fetch function pointers */ + get_api = (PDFlib_api *(PDFLIB_CALL *)(void)) + pdf_dlsym(handle, "PDF_get_api"); + + if (get_api == NULL) + { + pdf_dlerror( + "Error: couldn't find function PDF_get_api in PDFlib DLL\n"); + pdf_dlclose(handle); + return NULL; + } + + /* Fetch the API structure and boot the library. */ + PDFlib = (*get_api)(); + + /* + * Check the version number of the loaded DLL against that of + * the included header file to avoid version mismatch. + */ + + if (PDFlib->sizeof_PDFlib_api != sizeof(PDFlib_api) || + PDFlib->major != PDFLIB_MAJORVERSION || + PDFlib->minor != PDFLIB_MINORVERSION) { + sprintf(buf, + "Error: loaded wrong version of PDFlib DLL\n" + "Expected version %d.%d (API size %d), loaded %d.%d (API size %d)\n", + PDFLIB_MAJORVERSION, PDFLIB_MINORVERSION, sizeof(PDFlib_api), + PDFlib->major, PDFlib->minor, PDFlib->sizeof_PDFlib_api); + pdf_dlerror(buf); + pdf_dlclose(handle); + return NULL; + } + + /* Boot the library. */ + PDFlib->PDF_boot(); + + /* + * Create a new PDFlib object; use PDF_new2() so that we can store + * the DLL handle within PDFlib and later retrieve it. + */ + if ((p = PDFlib->PDF_new2(NULL, NULL, NULL, NULL, handle)) == (PDF *) NULL) + { + pdf_dlerror("Couldn't create PDFlib object (out of memory)!\n"); + return NULL; + } + + /* Make the PDF * available to the client and return */ + *pp = p; + return PDFlib; +} + +/* delete the PDFlib object and unload the previously loaded PDFlib DLL */ + +PDFLIB_API void PDFLIB_CALL +PDF_delete_dl(PDFlib_api *PDFlib, PDF *p) +{ + void *handle; + + if (!PDFlib || !p) + return; + + /* fetch the DLL handle (previously stored in PDFlib) */ + handle = PDFlib->PDF_get_opaque(p); + + if (!handle) + return; + + PDFlib->PDF_delete(p); + PDFlib->PDF_shutdown(); + + pdf_dlclose(handle); +} diff --git a/src/libs/pdflib/bind/pdflib/c/pdflibdl.h b/src/libs/pdflib/bind/pdflib/c/pdflibdl.h new file mode 100644 index 0000000000..6d95014d5e --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/pdflibdl.h @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdflibdl.h,v 1.1 2004/10/06 17:46:39 laplace Exp $ + * + * Function prototypes for dynamically loading the PDFlib DLL at runtime + * + */ + +#ifdef __cplusplus +#define PDF PDF_c +#endif + +#include "pdflib.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Notes for using the PDFlib DLL loading mechanism: + * + * - PDF_TRY_DL()/PDF_CATCH_DL() must be used instead of the standard + * exception handling macros. + * - PDF_new_dl() must be used instead of PDF_boot() and PDF_new()/PDF_new2(). + * - PDF_delete_dl() must be used instead of PDF_delete() and PDF_shutdown(). + * - PDF_get_opaque() must not be used. + */ + +/* Load the PDFlib DLL, and fetch pointers to all exported functions. */ +PDFLIB_API PDFlib_api * PDFLIB_CALL +PDF_new_dl(PDF **pp); + +/* Unload the previously loaded PDFlib DLL (also calls PDF_shutdown()) */ +PDFLIB_API void PDFLIB_CALL +PDF_delete_dl(PDFlib_api *PDFlib, PDF *p); + + +#define PDF_TRY_DL(PDFlib, p) \ + if (p) { if (setjmp(PDFlib->pdf_jbuf(p)->jbuf) == 0) + +/* Inform the exception machinery that a PDF_TRY() will be left without + entering the corresponding PDF_CATCH( ) clause. */ +#define PDF_EXIT_TRY_DL(PDFlib, p) PDFlib->pdf_exit_try(p) + +/* Catch an exception; must always be paired with PDF_TRY(). */ +#define PDF_CATCH_DL(PDFlib, p) } if (PDFlib->pdf_catch(p)) + +/* Re-throw an exception to another handler. */ +#define PDF_RETHROW_DL(PDFlib, p) PDFlib->pdf_rethrow(p) + +#ifdef __cplusplus +} /* extern "C" */ +#endif diff --git a/src/libs/pdflib/bind/pdflib/c/quickreference.c b/src/libs/pdflib/bind/pdflib/c/quickreference.c new file mode 100644 index 0000000000..3492e2e05c --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/quickreference.c @@ -0,0 +1,112 @@ +/* $Id: quickreference.c,v 1.1 2004/10/06 17:46:39 laplace Exp $ + * + * PDFlib/PDI client: mini imposition demo + */ +#include +#include + +#include "pdflib.h" + +int +main(void) +{ + PDF *p; + int manual, page; + int font, row, col; + const int maxrow = 2; + const int maxcol = 2; + char optlist[128]; + int startpage = 1, endpage = 4; + const float width = 500, height = 770; + int pageno; + const char *infile = "reference.pdf"; + + /* This is where font/image/PDF input files live. Adjust as necessary. */ + char *searchpath = "../data"; + + /* create a new PDFlib object */ + if ((p = PDF_new()) == (PDF *) 0) + { + printf("Couldn't create PDFlib object (out of memory)!\n"); + return(2); + } + + PDF_TRY(p) { + /* open new PDF file */ + if (PDF_open_file(p, "quickreference.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + PDF_set_parameter(p, "SearchPath", searchpath); + + /* This line is required to avoid problems on Japanese systems */ + PDF_set_parameter(p, "hypertextencoding", "host"); + + PDF_set_info(p, "Creator", "quickreference.c"); + PDF_set_info(p, "Author", "Thomas Merz"); + PDF_set_info(p, "Title", "mini imposition demo (C)"); + + manual = PDF_open_pdi(p, infile, "", 0); + if (manual == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + row = 0; + col = 0; + + PDF_set_parameter(p, "topdown", "true"); + + for (pageno = startpage; pageno <= endpage; pageno++) { + if (row == 0 && col == 0) { + PDF_begin_page(p, width, height); + font = PDF_load_font(p, "Helvetica-Bold", 0, "host", ""); + PDF_setfont(p, font, 18); + PDF_set_text_pos(p, 24, 24); + PDF_show(p, "PDFlib Quick Reference"); + } + + page = PDF_open_pdi_page(p, manual, pageno, ""); + + if (page == -1) { + printf("Error: %s\n", PDF_get_errmsg(p)); + return(2); + } + + sprintf(optlist, "scale %f", (float) 1/maxrow); + PDF_fit_pdi_page(p, page, + width/maxcol*col, (row + 1) * height/maxrow, optlist); + PDF_close_pdi_page(p, page); + + col++; + if (col == maxcol) { + col = 0; + row++; + } + if (row == maxrow) { + row = 0; + PDF_end_page(p); + } + } + + /* finish the last partial page */ + if (row != 0 || col != 0) + PDF_end_page(p); + + PDF_close(p); + PDF_close_pdi(p, manual); + } + + PDF_CATCH(p) { + printf("PDFlib exception occurred in quickreference sample:\n"); + printf("[%d] %s: %s\n", + PDF_get_errnum(p), PDF_get_apiname(p), PDF_get_errmsg(p)); + PDF_delete(p); + return(2); + } + + PDF_delete(p); + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/c/quickreference.dsp b/src/libs/pdflib/bind/pdflib/c/quickreference.dsp new file mode 100644 index 0000000000..0b5585ad7a --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/quickreference.dsp @@ -0,0 +1,107 @@ +# Microsoft Developer Studio Project File - Name="quickreference" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=quickreference - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "quickreference.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "quickreference.mak" CFG="quickreference - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "quickreference - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "quickreference - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "quickreference - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /out:"quickreference.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /pdb:none /machine:I386 /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "quickreference - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PDFLIB_STATIC" /D "_MT" /FR /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /machine:I386 /out:"quickreference.exe" /pdbtype:sept /libpath:"..\..\..\libs\pdflib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "quickreference - Win32 Release" +# Name "quickreference - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\quickreference.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/c/readme.txt b/src/libs/pdflib/bind/pdflib/c/readme.txt new file mode 100644 index 0000000000..900cf07a3f --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/c/readme.txt @@ -0,0 +1,3 @@ +Notes on the PDFlib C binding: + +(none) diff --git a/src/libs/pdflib/bind/pdflib/c/samples.mcp b/src/libs/pdflib/bind/pdflib/c/samples.mcp new file mode 100644 index 0000000000..3668ec4ad9 Binary files /dev/null and b/src/libs/pdflib/bind/pdflib/c/samples.mcp differ diff --git a/src/libs/pdflib/bind/pdflib/cpp/Makefile b/src/libs/pdflib/bind/pdflib/cpp/Makefile new file mode 100644 index 0000000000..f2a3a0448c --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/Makefile @@ -0,0 +1,81 @@ +# Makefile for PDFlib, C++ language binding +# $Id: Makefile,v 1.1 2004/10/06 17:46:40 laplace Exp $ + +top_builddir = ../../.. + +include $(top_builddir)/config/mkcommon.inc + +DEPLIBS = $(PDFLIBLINK) pdflib$(LO) +LIBS = $(DEPLIBS) $(STDCPP) $(EXTERNALLIBS) +INCLUDES = $(PDFLIBINC) +CXXFLAGS = $(CFLAGS) +FLAGS = $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) + +# -------------------------------------------------------------------------- + +SRC = \ + $(srcdir)/pdflib.cpp \ + $(srcdir)/hello.cpp \ + $(srcdir)/image.cpp \ + $(srcdir)/pdfclock.cpp \ + $(srcdir)/chartab.cpp \ + $(srcdir)/invoice.cpp \ + $(srcdir)/businesscard.cpp \ + $(srcdir)/quickreference.cpp \ + $(srcdir)/smoketest.cpp + +PROGS = \ + hello$(EXE) \ + image$(EXE) \ + pdfclock$(EXE) \ + chartab$(EXE) \ + invoice$(EXE) \ + businesscard$(EXE) \ + quickreference$(EXE) + +include $(top_builddir)/config/mkprogs.inc + + +test:: $(PROGS) + -./hello + -./image + -./pdfclock + -./chartab + -./invoice + -./businesscard + -./quickreference + +smoke:: test smoketest$(EXE) + -./smoketest + +clean:: + $(RM) smoketest$(EXE) smoke_cpp_?.pdf + $(RM) hello.pdf image.pdf pdfclock.pdf chartab.pdf invoice.pdf + $(RM) businesscard.pdf quickreference.pdf + +hello$(EXE): hello.cpp $(DEPLIBS) + $(CXXPROGS_BUILD) + +image$(EXE): image.cpp $(DEPLIBS) + $(CXXPROGS_BUILD) + +pdfclock$(EXE): pdfclock.cpp $(DEPLIBS) + $(CXXPROGS_BUILD) + +chartab$(EXE): chartab.cpp $(DEPLIBS) + $(CXXPROGS_BUILD) + +invoice$(EXE): invoice.cpp $(DEPLIBS) + $(CXXPROGS_BUILD) + +businesscard$(EXE): businesscard.cpp $(DEPLIBS) + $(CXXPROGS_BUILD) + +quickreference$(EXE): quickreference.cpp $(DEPLIBS) + $(CXXPROGS_BUILD) + +smoketest$(EXE): smoketest.cpp $(DEPLIBS) + $(CXXPROGS_BUILD) + +pdflib$(LO): ./pdflib.cpp pdflib.hpp ../../../libs/pdflib/pdflib.h + $(LIBTOOL_CC) $(CXX) -c $(CXXFLAGS) pdflib.cpp diff --git a/src/libs/pdflib/bind/pdflib/cpp/businesscard.cpp b/src/libs/pdflib/bind/pdflib/cpp/businesscard.cpp new file mode 100644 index 0000000000..70596bdbf8 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/businesscard.cpp @@ -0,0 +1,96 @@ +// $Id: businesscard.cpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// PDFlib client: hello example in C++ +// +// + +#include + +#include "pdflib.hpp" + +int +main(void) +{ + try { + PDFlib p; // the PDFlib object + int i, blockcontainer, page; + const string infile = "boilerplate.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary. + * + * Note that this directory must also contain the LuciduxSans font + * outline and metrics files. + */ + const string searchpath = "../data"; + struct blockdata { + blockdata(string n, string v): name(n), value(v){} + string name; + string value; + }; + + blockdata data[] = { + blockdata("name", "Victor Kraxi"), + blockdata("business.title", "Chief Paper Officer"), + blockdata("business.address.line1", "17, Aviation Road"), + blockdata("business.address.city", "Paperfield"), + blockdata("business.telephone.voice","phone +1 234 567-89"), + blockdata("business.telephone.fax", "fax +1 234 567-98"), + blockdata("business.email", "victor@kraxi.com"), + blockdata("business.homepage", "www.kraxi.com"), + }; + +#define BLOCKCOUNT (sizeof(data)/sizeof(data[0])) + + // open new PDF file + if (p.open_file("businesscard.pdf") == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + return(2); + } + + p.set_parameter("SearchPath", searchpath); + + // This line is required to avoid problems on Japanese systems + p.set_parameter("hypertextencoding", "host"); + + p.set_info("Creator", "businesscard.cpp"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title","PDFlib block processing sample (C++)"); + + blockcontainer = p.open_pdi(infile, "", 0); + if (blockcontainer == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + return(2); + } + + page = p.open_pdi_page(blockcontainer, 1, ""); + if (page == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + return(2); + } + + p.begin_page(20, 20); // dummy page size + + // This will adjust the page size to the block container's size. + p.fit_pdi_page(page, 0, 0, "adjustpage"); + + // Fill all text blocks with dynamic data + for (i = 0; i < (int) BLOCKCOUNT; i++) { + if (p.fill_textblock(page, data[i].name, data[i].value, + "embedding encoding=host") == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + } + } + + p.end_page(); // close page + p.close_pdi_page(page); + + p.close(); // close PDF document + p.close_pdi(blockcontainer); + } + catch (PDFlib::Exception &ex) { + cerr << "PDFlib exception occurred in businesscard sample: " << endl; + cerr << "[" << ex.get_errnum() << "] " << ex.get_apiname() + << ": " << ex.get_errmsg() << endl; + return 99; + } + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/cpp/businesscard.dsp b/src/libs/pdflib/bind/pdflib/cpp/businesscard.dsp new file mode 100644 index 0000000000..da3689507e --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/businesscard.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="businesscard" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=businesscard - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "businesscard.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "businesscard.mak" CFG="businesscard - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "businesscard - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "businesscard - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "businesscard - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:5.0 /subsystem:console /debug /machine:I386 /out:"pdfclock.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /machine:I386 /out:"release\businesscard.exe" /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" + +!ELSEIF "$(CFG)" == "businesscard - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /machine:I386 /out:"businesscard.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /map + +!ENDIF + +# Begin Target + +# Name "businesscard - Win32 Release" +# Name "businesscard - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib.cpp +# End Source File +# Begin Source File + +SOURCE=.\businesscard.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pdflib.hpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/cpp/chartab.cpp b/src/libs/pdflib/bind/pdflib/cpp/chartab.cpp new file mode 100644 index 0000000000..e04a946c35 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/chartab.cpp @@ -0,0 +1,120 @@ +// $Id: chartab.cpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// PDFlib client: chartab example in C++ +// +// + +#include + +#include "pdflib.hpp" + +int +main(void) +{ + /* change these as required */ + const char *fontname = "LuciduxSans-Oblique"; + + /* This is where font/image/PDF input files live. Adjust as necessary. */ + char *searchpath = "../data"; + + /* list of encodings to use */ + const char *encodings[] = { "iso8859-1", "iso8859-2", "iso8859-15" }; + + /* whether or not to embed the font */ + int embed = 1; + + + char buf[256]; + float x, y; + int row, col, font, page; + + static const int ENCODINGS = 3; + static const float FONTSIZE = 16; + static const float TOP = 700; + static const float LEFT = 50; + static const float YINCR = 2*FONTSIZE; + static const float XINCR = 2*FONTSIZE; + + try { + /* create a new PDFlib object */ + PDFlib p; // the PDFlib object + + /* open new PDF file */ + if (p.open_file("chartab.pdf") == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + return(2); + } + + p.set_parameter("openaction", "fitpage"); + p.set_parameter("fontwarning", "true"); + + p.set_parameter("SearchPath", searchpath); + + // This line is required to avoid problems on Japanese systems + p.set_parameter("hypertextencoding", "host"); + + p.set_info("Creator", "chartab.c"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "Character table (C++)"); + + /* loop over all encodings */ + for (page = 0; page < ENCODINGS; page++) + { + p.begin_page(a4_width, a4_height); /* start a new page */ + + /* print the heading and generate the bookmark */ + // Change "host" encoding to "winansi" or whatever you need! + font = p.load_font("Helvetica", "host", ""); + p.setfont(font, FONTSIZE); + sprintf(buf, "%s (%s) %sembedded", + fontname, encodings[page], embed ? "" : "not "); + + p.show_xy(buf, LEFT - XINCR, TOP + 3 * YINCR); + p.add_bookmark(buf, 0, 0); + + /* print the row and column captions */ + p.setfont(font, 2 * FONTSIZE/3); + + for (row = 0; row < 16; row++) + { + sprintf(buf, "x%X", row); + p.show_xy(buf, LEFT + row*XINCR, TOP + YINCR); + + sprintf(buf, "%Xx", row); + p.show_xy(buf, LEFT - XINCR, TOP - row * YINCR); + } + + /* print the character table */ + font = p.load_font(fontname, encodings[page], + embed ? "embedding": ""); + p.setfont(font, FONTSIZE); + + y = TOP; + x = LEFT; + + for (row = 0; row < 16; row++) + { + for (col = 0; col < 16; col++) { + sprintf(buf, "%c", 16*row + col); + p.show_xy(buf, x, y); + x += XINCR; + } + x = LEFT; + y -= YINCR; + } + + p.end_page(); /* close page */ + } + + p.close(); /* close PDF document */ + + + } + catch (PDFlib::Exception &ex) { + cerr << "PDFlib exception occurred in chartab sample: " << endl; + cerr << "[" << ex.get_errnum() << "] " << ex.get_apiname() + << ": " << ex.get_errmsg() << endl; + return 2; + } + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/cpp/chartab.dsp b/src/libs/pdflib/bind/pdflib/cpp/chartab.dsp new file mode 100644 index 0000000000..24bf46a40e --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/chartab.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="chartab" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=chartab - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "chartab.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "chartab.mak" CFG="chartab - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "chartab - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "chartab - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "chartab - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:5.0 /subsystem:console /debug /machine:I386 /out:"pdfclock.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /machine:I386 /out:"release\chartab.exe" /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" + +!ELSEIF "$(CFG)" == "chartab - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /machine:I386 /out:"chartab.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /map + +!ENDIF + +# Begin Target + +# Name "chartab - Win32 Release" +# Name "chartab - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\chartab.cpp +# End Source File +# Begin Source File + +SOURCE=.\pdflib.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pdflib.hpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/cpp/examples_cpp.dsw b/src/libs/pdflib/bind/pdflib/cpp/examples_cpp.dsw new file mode 100644 index 0000000000..c1f4135f53 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/examples_cpp.dsw @@ -0,0 +1,101 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "businesscard"=".\businesscard.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "chartab"=".\chartab.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "hello"=".\hello.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "image"=".\image.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "invoice"=".\invoice.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "pdfclock"=".\pdfclock.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "quickreference"=".\quickreference.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/libs/pdflib/bind/pdflib/cpp/hello.cpp b/src/libs/pdflib/bind/pdflib/cpp/hello.cpp new file mode 100644 index 0000000000..d540d67b2c --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/hello.cpp @@ -0,0 +1,51 @@ +// $Id: hello.cpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// PDFlib client: hello example in C++ +// +// + +#include + +#include "pdflib.hpp" + +int +main(void) +{ + try { + int font; + PDFlib p; // the PDFlib object + + // open new PDF file + if (p.open_file("hello.pdf") == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + return 2; + } + + // This line is required to avoid problems on Japanese systems + p.set_parameter("hypertextencoding", "host"); + + p.set_info("Creator", "hello.cpp"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "Hello, world (C++)!"); + + // start a new page + p.begin_page((float) a4_width, (float) a4_height); + + // Change "host" encoding to "winansi" or whatever you need! + font = p.load_font("Helvetica-Bold", "host", ""); + + p.setfont(font, 24); + p.set_text_pos(50, 700); + p.show("Hello, world!"); + p.continue_text("(says C++)"); + p.end_page(); // close page + p.close(); // close PDF document + } + catch (PDFlib::Exception &ex) { + cerr << "PDFlib exception occurred in hello sample: " << endl; + cerr << "[" << ex.get_errnum() << "] " << ex.get_apiname() + << ": " << ex.get_errmsg() << endl; + return 2; + } + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/cpp/hello.dsp b/src/libs/pdflib/bind/pdflib/cpp/hello.dsp new file mode 100644 index 0000000000..c931f96e0f --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/hello.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="hello" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=hello - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "hello.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "hello.mak" CFG="hello - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "hello - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "hello - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "hello - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:5.0 /subsystem:console /debug /machine:I386 /out:"pdfclock.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /machine:I386 /out:"release\hello.exe" /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" + +!ELSEIF "$(CFG)" == "hello - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /machine:I386 /out:"hello.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /map + +!ENDIF + +# Begin Target + +# Name "hello - Win32 Release" +# Name "hello - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib.cpp +# End Source File +# Begin Source File + +SOURCE=.\hello.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pdflib.hpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/cpp/image.cpp b/src/libs/pdflib/bind/pdflib/cpp/image.cpp new file mode 100644 index 0000000000..3104f0ca0c --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/image.cpp @@ -0,0 +1,60 @@ +// $Id: image.cpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// PDFlib client: image example in C++ +// +// + +#include + +#include "pdflib.hpp" + +int +main(void) +{ + try { + PDFlib *p; // pointer to the PDFlib class + int image; + char *imagefile = (char *) "nesrin.jpg"; + // This is where font/image/PDF input files live. Adjust as necessary. + char *searchpath = (char *) "../data"; + + p = new PDFlib(); + + // Open new PDF file + if (p->open_file("image.pdf") == -1) { + cerr << "Error: " << p->get_errmsg() << endl; + return 2; + } + + p->set_parameter("SearchPath", searchpath); + + // This line is required to avoid problems on Japanese systems + p->set_parameter("hypertextencoding", "host"); + + p->set_info("Creator", "image.cpp"); + p->set_info("Author", "Thomas Merz"); + p->set_info("Title", "image sample (C++)!"); + + image = p->load_image("auto", imagefile, ""); + + if (image == -1) { + cerr << "Error: " << p->get_errmsg() << endl; + exit(3); + } + + // dummy page size, will be adjusted by PDF_fit_image() + p->begin_page(10, 10); + p->fit_image(image, (float) 0.0,(float) 0.0, "adjustpage"); + p->close_image(image); + p->end_page(); // close page + + p->close(); // close PDF document + } + catch (PDFlib::Exception &ex) { + cerr << "PDFlib exception occurred in hello sample: " << endl; + cerr << "[" << ex.get_errnum() << "] " << ex.get_apiname() + << ": " << ex.get_errmsg() << endl; + return 2; + } + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/cpp/image.dsp b/src/libs/pdflib/bind/pdflib/cpp/image.dsp new file mode 100644 index 0000000000..abd4b0c849 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/image.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="image" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=image - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "image.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "image.mak" CFG="image - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "image - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "image - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "image - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /out:"pdfclock.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /machine:I386 /out:"release\image.exe" /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" + +!ELSEIF "$(CFG)" == "image - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /machine:I386 /out:"hello.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /map + +!ENDIF + +# Begin Target + +# Name "image - Win32 Release" +# Name "image - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib.cpp +# End Source File +# Begin Source File + +SOURCE=.\image.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pdflib.hpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/cpp/invoice.cpp b/src/libs/pdflib/bind/pdflib/cpp/invoice.cpp new file mode 100644 index 0000000000..455d372125 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/invoice.cpp @@ -0,0 +1,194 @@ +// $Id: invoice.cpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// PDFlib client: invoice example in C++ +// +// + +#include + +#include + +#if !defined(WIN32) && !defined(MAC) +#include +#endif + +#include "pdflib.hpp" + +int +main(void) +{ + try { + int i, form, page, regularfont, boldfont; + string infile = "stationery.pdf"; + // This is where font/image/PDF input files live. Adjust as necessary. + string searchpath = "../data"; + const float col1 = 55; + const float col2 = 100; + const float col3 = 330; + const float col4 = 430; + const float col5 = 530; + time_t timer; + struct tm ltime; + float fontsize = 12, leading, y; + float sum, total; + float pagewidth = 595, pageheight = 842; + char buf[128]; + PDFlib p; + string closingtext = + "30 days warranty starting at the day of sale. " + "This warranty covers defects in workmanship only. " + "Kraxi Systems, Inc. will, at its option, repair or replace the " + "product under the warranty. This warranty is not transferable. " + "No returns or exchanges will be accepted for wet products."; + + struct articledata { + articledata(string n, float pr, int q): + name(n), price(pr), quantity(q){} + string name; + float price; + int quantity; + }; + + articledata data[] = { + articledata("Super Kite", 20, 2), + articledata("Turbo Flyer", 40, 5), + articledata("Giga Trash", 180, 1), + articledata("Bare Bone Kit", 50, 3), + articledata("Nitty Gritty", 20, 10), + articledata("Pretty Dark Flyer", 75, 1), + articledata("Free Gift", 0, 1), + }; + +#define ARTICLECOUNT (sizeof(data)/sizeof(data[0])) + + static const string months[] = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; + + + // open new PDF file + if (p.open_file("invoice.pdf") == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + return(2); + } + + p.set_parameter("SearchPath", searchpath); + + // This line is required to avoid problems on Japanese systems + p.set_parameter("hypertextencoding", "host"); + + p.set_info("Creator", "invoice.cpp"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "PDFlib invoice generation demo (C++)"); + + form = p.open_pdi(infile, "", 0); + if (form == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + return(2); + } + + page = p.open_pdi_page(form, 1, ""); + if (page == -1) { + cerr << "Error: " << p.get_errmsg() << endl; + return(2); + } + + boldfont = p.load_font("Helvetica-Bold", "host", ""); + regularfont = p.load_font("Helvetica", "host", ""); + leading = fontsize + 2; + + // Establish coordinates with the origin in the upper left corner. + p.set_parameter("topdown", "true"); + + p.begin_page(pagewidth, pageheight); // A4 page + + p.fit_pdi_page(page, 0, pageheight, ""); + p.close_pdi_page(page); + + p.setfont(regularfont, 12); + + // Print the address + y = 170; + p.set_value("leading", leading); + + p.show_xy("John Q. Doe", col1, y); + p.continue_text("255 Customer Lane"); + p.continue_text("Suite B"); + p.continue_text("12345 User Town"); + p.continue_text("Everland"); + + // Print the header and date + + p.setfont(boldfont, 12); + y = 300; + p.show_xy("INVOICE", col1, y); + + time(&timer); + ltime = *localtime(&timer); + sprintf(buf, "%s %d, %d", months[ltime.tm_mon].c_str(), + ltime.tm_mday, ltime.tm_year + 1900); + p.fit_textline(buf, col5, y, "position {100 0}"); + + // Print the invoice header line + p.setfont(boldfont, 12); + + // "position {0 0}" is left-aligned, "position {100 0}" right-aligned + y = 370; + p.fit_textline("ITEM", col1, y, "position {0 0}"); + p.fit_textline("DESCRIPTION", col2, y, "position {0 0}"); + p.fit_textline("QUANTITY", col3, y, "position {100 0}"); + p.fit_textline("PRICE", col4, y, "position {100 0}"); + p.fit_textline("AMOUNT", col5, y, "position {100 0}"); + + // Print the article list + + p.setfont(regularfont, 12); + y += 2*leading; + total = 0; + + for (i = 0; i < (int)ARTICLECOUNT; i++) { + sprintf(buf, "%d", i+1); + p.show_xy(buf, col1, y); + + p.show_xy(data[i].name, col2, y); + + sprintf(buf, "%d", data[i].quantity); + p.fit_textline(buf, col3, y, "position {100 0}"); + + sprintf(buf, "%.2f", data[i].price); + p.fit_textline(buf, col4, y, "position {100 0}"); + + sum = data[i].price * data[i].quantity; + sprintf(buf, "%.2f", sum); + p.fit_textline(buf, col5, y, "position {100 0}"); + + y += leading; + total += sum; + } + + y += leading; + p.setfont(boldfont, 12); + sprintf(buf, "%.2f", total); + p.fit_textline(buf, col5, y, "position {100 0}"); + + // Print the closing text + + y += 5*leading; + p.setfont(regularfont, 12); + p.set_value("leading", leading); + p.show_boxed(closingtext, + col1, y + 4*leading, col5-col1, 4*leading, "justify", ""); + + p.end_page(); + p.close(); + p.close_pdi(form); + } + catch (PDFlib::Exception &ex) { + cerr << "PDFlib exception occurred in invoice sample: " << endl; + cerr << "[" << ex.get_errnum() << "] " << ex.get_apiname() + << ": " << ex.get_errmsg() << endl; + return 2; + } + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/cpp/invoice.dsp b/src/libs/pdflib/bind/pdflib/cpp/invoice.dsp new file mode 100644 index 0000000000..54493b426f --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/invoice.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="invoice" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=invoice - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "invoice.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "invoice.mak" CFG="invoice - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "invoice - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "invoice - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "invoice - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:5.0 /subsystem:console /debug /machine:I386 /out:"pdfclock.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /machine:I386 /out:"release\invoice.exe" /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" + +!ELSEIF "$(CFG)" == "invoice - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /machine:I386 /out:"invoice.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:5.0 /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /map + +!ENDIF + +# Begin Target + +# Name "invoice - Win32 Release" +# Name "invoice - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib.cpp +# End Source File +# Begin Source File + +SOURCE=.\invoice.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pdflib.hpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/cpp/pdfclock.cpp b/src/libs/pdflib/bind/pdflib/cpp/pdfclock.cpp new file mode 100644 index 0000000000..533dd75305 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/pdfclock.cpp @@ -0,0 +1,126 @@ +// $Id: pdfclock.cpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// A little PDFlib application to draw an analog clock. +// +// + +#include + +#include + +#if !defined(WIN32) && !defined(MAC) +#include +#endif + +#include "pdflib.hpp" + +#define RADIUS 200.0f +#define MARGIN 20.0f + +int +main() +{ + try { + PDFlib *p; + float alpha; + time_t timer; + struct tm ltime; + + // Create a new PDFlib object + p = new PDFlib(); + + // Open new PDF file + if (p->open_file("pdfclock.pdf") == -1) { + cerr << "Error: " << p->get_errmsg() << endl; + return 2; + } + + // This line is required to avoid problems on Japanese systems + p->set_parameter("hypertextencoding", "host"); + + p->set_info("Creator", "pdfclock.cpp"); + p->set_info("Author", "Thomas Merz"); + p->set_info("Title", "PDF clock (C++)"); + + p->begin_page((unsigned int) (2 * (RADIUS + MARGIN)), + (unsigned int) (2 * (RADIUS + MARGIN))); + + p->translate(RADIUS + MARGIN, RADIUS + MARGIN); + p->setcolor("fillstroke", "rgb", 0, 0, 1, 0); + p->save(); + + // minute strokes + p->setlinewidth(2); + for (alpha = 0; alpha < 360; alpha += 6) + { + p->rotate(6); + p->moveto(RADIUS, 0); + p->lineto((float) (RADIUS-MARGIN/3), 0); + p->stroke(); + } + + p->restore(); + p->save(); + + // 5 minute strokes + p->setlinewidth(3); + for (alpha = 0; alpha < 360; alpha += 30) + { + p->rotate(30); + p->moveto(RADIUS, 0); + p->lineto(RADIUS-MARGIN, 0); + p->stroke(); + } + + time(&timer); + ltime = *localtime(&timer); + + // draw hour hand + p->save(); + p->rotate( + (float)(-((ltime.tm_min/60) + ltime.tm_hour - 3.0) * 30)); + p->moveto(-RADIUS/10, -RADIUS/20); + p->lineto(RADIUS/2, 0); + p->lineto(-RADIUS/10, RADIUS/20); + p->closepath(); + p->fill(); + p->restore(); + + // draw minute hand + p->save(); + p->rotate((float) (-((ltime.tm_sec/60.0) + ltime.tm_min - 15.0) * 6.0)); + p->moveto(-RADIUS/10, -RADIUS/20); + p->lineto(RADIUS * 0.8, 0); + p->lineto(-RADIUS/10, RADIUS/20); + p->closepath(); + p->fill(); + p->restore(); + + // draw second hand + p->setcolor("fillstroke", "rgb", 1, 0, 0, 0); + p->setlinewidth(2); + p->save(); + p->rotate((float) -((ltime.tm_sec - 15) * 6)); + p->moveto(-RADIUS/5, 0); + p->lineto(RADIUS, 0); + p->stroke(); + p->restore(); + + // draw little circle at center + p->circle(0, 0, (float) RADIUS/30); + p->fill(); + + p->restore(); + + p->end_page(); + + p->close(); + } + catch (PDFlib::Exception &ex) { + cerr << "PDFlib exception occurred in pdfclock sample: " << endl; + cerr << "[" << ex.get_errnum() << "] " << ex.get_apiname() + << ": " << ex.get_errmsg() << endl; + return 2; + } + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/cpp/pdfclock.dsp b/src/libs/pdflib/bind/pdflib/cpp/pdfclock.dsp new file mode 100644 index 0000000000..1458230b62 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/pdfclock.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="pdfclock" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=pdfclock - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pdfclock.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pdfclock.mak" CFG="pdfclock - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pdfclock - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "pdfclock - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pdfclock - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /out:"pdfclock.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /machine:I386 /out:"release\pdfclock.exe"/libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" + +!ELSEIF "$(CFG)" == "pdfclock - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /machine:I386 /out:"hello.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /map + +!ENDIF + +# Begin Target + +# Name "pdfclock - Win32 Release" +# Name "pdfclock - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib.cpp +# End Source File +# Begin Source File + +SOURCE=.\pdfclock.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pdflib.hpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/cpp/pdflib.cpp b/src/libs/pdflib/bind/pdflib/cpp/pdflib.cpp new file mode 100644 index 0000000000..7902dd1cf6 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/pdflib.cpp @@ -0,0 +1,1299 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +// $Id: pdflib.cpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// +// in sync with pdflib.h 1.151.2.22 +// +// Implementation of C++ wrapper for PDFlib +// +// + +#include "pdflib.hpp" + +#define CHAR(s) (s).c_str() +#define LEN(s) (s).size() + + +#ifdef PDF_THROWS_CPP_EXCEPTIONS + +PDFlib::Exception::Exception(string errmsg, int errnum, string apiname, void *opaque) +: m_errmsg(errmsg), + m_errnum(errnum), + m_apiname(apiname), + m_opaque(opaque) +{ } + +string PDFlib::Exception::get_errmsg() { return m_errmsg; } +string PDFlib::Exception::get_message() { return m_errmsg; } +int PDFlib::Exception::get_errnum() { return m_errnum; } +string PDFlib::Exception::get_apiname() { return m_apiname; } +const void * PDFlib::Exception::get_opaque() { return m_opaque; } + +#define PDFCPP_TRY PDF_TRY(p) +#define PDFCPP_CATCH \ +PDF_CATCH(p) {\ + throw Exception(PDF_get_errmsg(p), PDF_get_errnum(p),\ + PDF_get_apiname(p), PDF_get_opaque(p));\ +} +#else + +#define PDFCPP_TRY +#define PDFCPP_CATCH + +#endif // PDF_THROWS_CPP_EXCEPTIONS + + +#ifdef PDF_THROWS_CPP_EXCEPTIONS +PDFlib::PDFlib( + errorproc_t errorproc, + allocproc_t allocproc, + reallocproc_t reallocproc, + freeproc_t freeproc, + void *opaque) PDF_THROWS(PDFlib::Exception) +{ + m_PDFlib_api = ::PDF_get_api(); + + if (m_PDFlib_api->sizeof_PDFlib_api != sizeof(PDFlib_api) || + m_PDFlib_api->major != PDFLIB_MAJORVERSION || + m_PDFlib_api->minor != PDFLIB_MINORVERSION) { + throw Exception("loaded wrong version of PDFlib library", 0, + "pdflib.cpp", opaque); + } + + m_PDFlib_api->PDF_boot(); + + p = m_PDFlib_api->PDF_new2(NULL, allocproc, reallocproc, freeproc, opaque); + +/* + * errorproc is ignored here to be compatible with old applications + * that were not compiled with PDF_THROWS_CPP_EXCEPTIONS + */ + (void) errorproc; + + if (p == (PDF *)0) { + throw Exception("No memory for PDFlib object", 0, "pdflib.cpp", opaque); + } + + PDFCPP_TRY + { + PDF_set_parameter(p, "binding", "C++"); + } + PDFCPP_CATCH; +} + +PDFlib::PDFlib( + allocproc_t allocproc, + reallocproc_t reallocproc, + freeproc_t freeproc, + void *opaque) PDF_THROWS(PDFlib::Exception) +{ + m_PDFlib_api = ::PDF_get_api(); + + if (m_PDFlib_api->sizeof_PDFlib_api != sizeof(PDFlib_api) || + m_PDFlib_api->major != PDFLIB_MAJORVERSION || + m_PDFlib_api->minor != PDFLIB_MINORVERSION) { + throw Exception("loaded wrong version of PDFlib library", 0, + "pdflib.cpp", opaque); + } + + m_PDFlib_api->PDF_boot(); + + p = m_PDFlib_api->PDF_new2(NULL, allocproc, reallocproc, freeproc, opaque); + + if (p == (PDF *)0) { + throw Exception("No memory for PDFlib object", 0, "pdflib.cpp", opaque); + } + + PDFCPP_TRY + { + PDF_set_parameter(p, "binding", "C++"); + } + PDFCPP_CATCH; +} + +#else // ! PDF_THROWS_CPP_EXCEPTIONS + +PDFlib::PDFlib( + errorproc_t errorproc, + allocproc_t allocproc, + reallocproc_t reallocproc, + freeproc_t freeproc, + void *opaque) +{ + PDF_boot(); + m_PDFlib_api = ::PDF_get_api(); + + p = m_PDFlib_api->PDF_new2(errorproc, allocproc, reallocproc, freeproc, opaque); + + PDF_set_parameter(p, "binding", "C++"); +} + +#endif // ! PDF_THROWS_CPP_EXCEPTIONS + + +PDFlib::~PDFlib() PDF_THROWS_NOTHING +{ + m_PDFlib_api->PDF_delete(p); + m_PDFlib_api->PDF_shutdown(); +} + +/* p_annots.c */ +void +PDFlib::add_launchlink(float llx, float lly, float urx, float ury, + string filename) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_add_launchlink(p, llx, lly, urx, ury, CHAR(filename)); + PDFCPP_CATCH; +} + +void +PDFlib::add_locallink(float llx, float lly, float urx, float ury, int page, + string optlist) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_add_locallink(p, llx, lly, urx, ury, page, CHAR(optlist)); + PDFCPP_CATCH; +} + +void +PDFlib::add_note(float llx, float lly, float urx, float ury, string contents, + string title, string icon, bool p_open) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_add_note(p, llx, lly, urx, ury, CHAR(contents), + CHAR(title), CHAR(icon), p_open); + PDFCPP_CATCH; +} + +void +PDFlib::add_pdflink(float llx, float lly, float urx, float ury, + string filename, int page, string optlist) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY + { + m_PDFlib_api->PDF_add_pdflink(p, llx, lly, urx, ury, CHAR(filename), + page, CHAR(optlist)); + } + PDFCPP_CATCH; +} + +void +PDFlib::add_weblink(float llx, float lly, float urx, float ury, + string url) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_add_weblink(p, llx, lly, urx, ury, CHAR(url)); + PDFCPP_CATCH; +} + +void +PDFlib::attach_file(float llx, float lly, float urx, float ury, + string filename, string description, string author, + string mimetype, string icon) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY + { + m_PDFlib_api->PDF_attach_file2(p, llx, lly, urx, ury, CHAR(filename), 0, + CHAR(description), (int) LEN(description), CHAR(author), + (int) LEN(author), CHAR(mimetype), CHAR(icon)); + } + PDFCPP_CATCH; +} + +void +PDFlib::set_border_color(float red, float green, float blue) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_set_border_color(p, red, green, blue); + PDFCPP_CATCH; +} + +void +PDFlib::set_border_dash(float b, float w) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_set_border_dash(p, b, w); + PDFCPP_CATCH; +} + +void +PDFlib::set_border_style(string style, float width) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_set_border_style(p, CHAR(style), width); + PDFCPP_CATCH; +} + +/* p_basic.c */ + +void +PDFlib::begin_page(float width, float height) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_begin_page(p, width, height); + PDFCPP_CATCH; +} + +void +PDFlib::close() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_close(p); + PDFCPP_CATCH; +} + +void +PDFlib::end_page() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_end_page(p); + PDFCPP_CATCH; +} + +string +PDFlib::get_apiname() PDF_THROWS(PDFlib::Exception) +{ + const char *retval = NULL; + + PDFCPP_TRY + { + retval = m_PDFlib_api->PDF_get_apiname(p); + } + PDFCPP_CATCH; + + if (retval) + return retval; + else + return ""; +} + +const char * +PDFlib::get_buffer(long *size) PDF_THROWS(PDFlib::Exception) +{ + const char * retval = NULL; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_get_buffer(p, size); + PDFCPP_CATCH; + + return retval; +} + +string +PDFlib::get_errmsg() PDF_THROWS(PDFlib::Exception) +{ + const char *retval = NULL; + + PDFCPP_TRY + { + retval = m_PDFlib_api->PDF_get_errmsg(p); + } + PDFCPP_CATCH; + + if (retval) + return retval; + else + return ""; +} + +int +PDFlib::get_errnum() PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_get_errnum(p); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::get_majorversion() PDF_THROWS_NOTHING +{ + return (int) m_PDFlib_api->PDF_get_value(NULL, "major", 0); +} + +int +PDFlib::get_minorversion() PDF_THROWS_NOTHING +{ + return (int) m_PDFlib_api->PDF_get_value(NULL, "minor", 0); +} + +void * +PDFlib::get_opaque() PDF_THROWS(PDFlib::Exception) +{ + void * retval = NULL; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_get_opaque(p); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::open(string filename) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_open_file(p, CHAR(filename)); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::open(FILE *fp) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_open_fp(p, fp); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::open(writeproc_t writeproc) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_open_mem(p, writeproc); + PDFCPP_CATCH; +} + +int +PDFlib::open_file(string filename) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_open_file(p, CHAR(filename)); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::open_fp(FILE *fp) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_open_fp(p, fp); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::open_mem(writeproc_t writeproc) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_open_mem(p, writeproc); + PDFCPP_CATCH; +} + +/* p_block.c */ +int +PDFlib::fill_imageblock(int page, string blockname, int image, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_fill_imageblock(p, page, CHAR(blockname), + image, CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::fill_pdfblock(int page, string blockname, int contents, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_fill_pdfblock(p, page, CHAR(blockname), + contents, CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::fill_textblock(int page, string blockname, string text, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_fill_textblock(p, page, CHAR(blockname), + CHAR(text), (int) LEN(text), CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +/* p_color.c */ + +int +PDFlib::makespotcolor(string spotname, int reserved) PDF_THROWS(PDFlib::Exception) +{ + (void) reserved; + + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_makespotcolor(p, CHAR(spotname), (int) LEN(spotname)); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::setcolor(string fstype, string colorspace, + float c1, float c2, float c3, float c4) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY + m_PDFlib_api->PDF_setcolor(p, CHAR(fstype), CHAR(colorspace), c1, c2, c3, c4); + PDFCPP_CATCH; +} + +void +PDFlib::setgray(float g) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setcolor(p, "fillstroke", "gray", g, 0, 0, 0); + PDFCPP_CATCH; +} + +void +PDFlib::setgray_fill(float g) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setcolor(p, "fill", "gray", g, 0, 0, 0); + PDFCPP_CATCH; +} + +void +PDFlib::setgray_stroke(float g) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setcolor(p, "stroke", "gray", g, 0, 0, 0); + PDFCPP_CATCH; +} + +void +PDFlib::setrgbcolor(float red, float green, float blue) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setcolor(p, "fillstroke", "rgb", red, green, blue, 0); + PDFCPP_CATCH; +} + +void +PDFlib::setrgbcolor_fill(float red, float green, float blue) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setcolor(p, "fill", "rgb", red, green, blue, 0); + PDFCPP_CATCH; +} + +void +PDFlib::setrgbcolor_stroke(float red, float green, float blue) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setcolor(p, "stroke", "rgb", red, green, blue, 0); + PDFCPP_CATCH; +} + +/* p_draw.c */ + +void +PDFlib::arc(float x, float y, float r, float alpha, float beta) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_arc(p, x, y, r, alpha, beta); + PDFCPP_CATCH; +} + +void +PDFlib::arcn(float x, float y, float r, float alpha, float beta) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_arcn(p, x, y, r, alpha, beta); + PDFCPP_CATCH; +} + +void +PDFlib::circle(float x, float y, float r) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_circle(p, x, y, r); + PDFCPP_CATCH; +} + +void +PDFlib::clip() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_clip(p); + PDFCPP_CATCH; +} + +void +PDFlib::closepath() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_closepath(p); + PDFCPP_CATCH; +} + +void +PDFlib::closepath_fill_stroke() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_closepath_fill_stroke(p); + PDFCPP_CATCH; +} + +void +PDFlib::closepath_stroke() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_closepath_stroke(p); + PDFCPP_CATCH; +} + +void +PDFlib::curveto(float x1, float y1, float x2, float y2, float x3, float y3) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_curveto(p, x1, y1, x2, y2, x3, y3); + PDFCPP_CATCH; +} + +void +PDFlib::endpath() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_endpath(p); + PDFCPP_CATCH; +} + +void +PDFlib::fill() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_fill(p); + PDFCPP_CATCH; +} + +void +PDFlib::fill_stroke() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_fill_stroke(p); + PDFCPP_CATCH; +} + +void +PDFlib::lineto(float x, float y) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_lineto(p, x, y); + PDFCPP_CATCH; +} + +void +PDFlib::moveto(float x, float y) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_moveto(p, x, y); + PDFCPP_CATCH; +} + +void +PDFlib::rect(float x, float y, float width, float height) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_rect(p, x, y, width, height); + PDFCPP_CATCH; +} + +void +PDFlib::stroke() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_stroke(p); + PDFCPP_CATCH; +} + +/* p_encoding.c */ + +void +PDFlib::encoding_set_char(string encoding, int slot, string glyphname, int uv) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_encoding_set_char(p, CHAR(encoding), slot, + CHAR(glyphname), uv); + PDFCPP_CATCH; +} + +/* p_font.c */ + +int +PDFlib::findfont(string fontname, string encoding, int embed) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + PDFCPP_TRY + + retval = m_PDFlib_api->PDF_findfont(p, CHAR(fontname), + CHAR(encoding), embed); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::load_font(string fontname, string encoding, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + PDFCPP_TRY + retval = m_PDFlib_api->PDF_load_font(p, CHAR(fontname), 0, CHAR(encoding), + CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::setfont(int font, float fontsize) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setfont(p, font, fontsize); + PDFCPP_CATCH; +} + +/* p_gstate.c */ + +void +PDFlib::concat(float a, float b, float c, float d, float e, float f) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_concat(p, a, b, c, d, e, f); + PDFCPP_CATCH; +} + +void +PDFlib::initgraphics() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_initgraphics(p); + PDFCPP_CATCH; +} + +void +PDFlib::restore() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_restore(p); + PDFCPP_CATCH; +} + +void +PDFlib::rotate(float phi) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_rotate(p, phi); + PDFCPP_CATCH; +} + +void +PDFlib::save() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_save(p); + PDFCPP_CATCH; +} + +void +PDFlib::scale(float sx, float sy) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_scale(p, sx, sy); + PDFCPP_CATCH; +} + +void +PDFlib::setdash(float b, float w) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setdash(p, b, w); + PDFCPP_CATCH; +} + +void +PDFlib::setdashpattern(string optlist) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setdashpattern(p, CHAR(optlist)); + PDFCPP_CATCH; +} + +void +PDFlib::setflat(float flatness) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setflat(p, flatness); + PDFCPP_CATCH; +} + +void +PDFlib::setlinecap(int linecap) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setlinecap(p, linecap); + PDFCPP_CATCH; +} + +void +PDFlib::setlinejoin(int linejoin) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setlinejoin(p, linejoin); + PDFCPP_CATCH; +} + +void +PDFlib::setlinewidth(float width) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setlinewidth(p, width); + PDFCPP_CATCH; +} + +void +PDFlib::setmatrix( float a, float b, float c, float d, float e, float f) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setmatrix(p, a, b, c, d, e, f); + PDFCPP_CATCH; +} + +void +PDFlib::setmiterlimit(float miter) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setmiterlimit(p, miter); + PDFCPP_CATCH; +} + +void +PDFlib::setpolydash(float *darray, int length) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_setpolydash(p, darray, length); + PDFCPP_CATCH; +} + +void +PDFlib::skew(float alpha, float beta) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_skew(p, alpha, beta); + PDFCPP_CATCH; +} + +void +PDFlib::translate(float tx, float ty) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_translate(p, tx, ty); + PDFCPP_CATCH; +} + +/* p_hyper.c */ + +int +PDFlib::add_bookmark(string text, int parent, bool p_open) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + PDFCPP_TRY + retval = m_PDFlib_api->PDF_add_bookmark2(p, CHAR(text), (int) LEN(text), + parent, p_open); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::add_nameddest(string name, string optlist) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_add_nameddest(p, CHAR(name), 0, CHAR(optlist)); + PDFCPP_CATCH; +} + +void +PDFlib::set_info(string key, string value) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY + m_PDFlib_api->PDF_set_info2(p, CHAR(key), CHAR(value), + (int) LEN(value)); + PDFCPP_CATCH; +} + +/* p_icc.c */ + +int +PDFlib::load_iccprofile(string profilename, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_load_iccprofile(p, CHAR(profilename), 0, + CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +/* p_image.c */ + +void +PDFlib::add_thumbnail(int image) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_add_thumbnail(p, image); + PDFCPP_CATCH; +} + +void +PDFlib::close_image(int image) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_close_image(p, image); + PDFCPP_CATCH; +} + +void +PDFlib::fit_image (int image, float x, float y, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_fit_image(p, image, x, y, CHAR(optlist)); + PDFCPP_CATCH; +} + +int +PDFlib::load_image (string imagetype, string filename, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_load_image(p, CHAR(imagetype), + CHAR(filename),0, CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::open_CCITT(string filename, int width, int height, bool BitReverse, + int K, bool BlackIs1) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + { + retval = m_PDFlib_api->PDF_open_CCITT(p, CHAR(filename), width, height, + BitReverse, K, BlackIs1); + } + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::open_image(string imagetype, string source, const char *data, long len, + int width, int height, int components, int bpc, string params) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + { + retval = m_PDFlib_api->PDF_open_image(p, CHAR(imagetype), CHAR(source), + data, len, width, height, components, bpc, CHAR(params)); + } + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::open_image_file(string imagetype, string filename, + string stringparam, int intparam) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + { + retval = m_PDFlib_api->PDF_open_image_file(p, CHAR(imagetype), + CHAR(filename), CHAR(stringparam), intparam); + } + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::place_image(int image, float x, float y, float p_scale) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_place_image(p, image, x, y, p_scale); + PDFCPP_CATCH; +} + +/* p_params.c */ + +string +PDFlib::get_parameter(string key, float modifier) PDF_THROWS(PDFlib::Exception) +{ + const char *retval = NULL; + + PDFCPP_TRY + { + retval = m_PDFlib_api->PDF_get_parameter(p, CHAR(key), modifier); + } + PDFCPP_CATCH; + + if (retval) + return retval; + else + return ""; +} + +float +PDFlib::get_value(string key, float modifier) PDF_THROWS(PDFlib::Exception) +{ + float retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_get_value(p, CHAR(key), modifier); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::set_parameter(string key, string value) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_set_parameter(p, CHAR(key), CHAR(value)); + PDFCPP_CATCH; +} + +void +PDFlib::set_value(string key, float value) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_set_value(p, CHAR(key), value); + PDFCPP_CATCH; +} + +/* p_pattern.c */ + +int +PDFlib::begin_pattern(float width, float height, float xstep, float ystep, + int painttype) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + + retval = m_PDFlib_api->PDF_begin_pattern(p, width, height, + xstep, ystep, painttype); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::end_pattern() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_end_pattern(p); + PDFCPP_CATCH; +} + +/* p_pdi.c */ + +void +PDFlib::close_pdi(int doc) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_close_pdi(p, doc); + PDFCPP_CATCH; +} + +void +PDFlib::close_pdi_page(int page) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_close_pdi_page(p, page); + PDFCPP_CATCH; +} + +void +PDFlib::fit_pdi_page (int page, float x, float y, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_fit_pdi_page(p, page, x, y, CHAR(optlist)); + PDFCPP_CATCH; +} + +string +PDFlib::get_pdi_parameter(string key, int doc, int page, int reserved, int *len) + PDF_THROWS(PDFlib::Exception) +{ + const char *retval = NULL; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_get_pdi_parameter(p, CHAR(key), + doc, page, reserved, len); + PDFCPP_CATCH; + + if (retval) + return retval; + else + return ""; +} + +float +PDFlib::get_pdi_value(string key, int doc, int page, int reserved) + PDF_THROWS(PDFlib::Exception) +{ + float retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_get_pdi_value(p, CHAR(key), doc, page,reserved); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::open_pdi(string filename, string optlist, int reserved) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_open_pdi(p, CHAR(filename), + CHAR(optlist), reserved); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::open_pdi_page(int doc, int pagenumber, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + PDFCPP_TRY + retval = m_PDFlib_api->PDF_open_pdi_page(p, doc, pagenumber, + CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::place_pdi_page(int page, float x, float y, float sx, float sy) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_place_pdi_page(p, page, x, y, sx, sy); + PDFCPP_CATCH; +} + +int +PDFlib::process_pdi(int doc, int page, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_process_pdi(p, doc, page, CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +/* p_resource.c */ + +void +PDFlib::create_pvf(string filename, void *data, size_t size, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY + m_PDFlib_api->PDF_create_pvf(p, CHAR(filename), 0, data, size, CHAR(optlist)); + PDFCPP_CATCH; +} + +int +PDFlib::delete_pvf(string filename) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_delete_pvf(p, CHAR(filename), 0); + PDFCPP_CATCH; + + return retval; +} + +/* p_shading.c */ +int +PDFlib::shading (string shtype, float x0, float y0, float x1, float y1, + float c1, float c2, float c3, float c4, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_shading(p, CHAR(shtype), x0, y0, x1, y1, + c1, c2, c3, c4, CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +int +PDFlib::shading_pattern (int shade, string optlist) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_shading_pattern(p, shade, CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::shfill (int shade) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY + m_PDFlib_api->PDF_shfill(p, shade); + PDFCPP_CATCH; +} + +/* p_template.c */ + +int +PDFlib::begin_template(float width, float height) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY retval = m_PDFlib_api->PDF_begin_template(p, width, height); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::end_template() PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_end_template(p); + PDFCPP_CATCH; +} + +/* p_text.c */ + +void +PDFlib::continue_text(string text) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_continue_text2(p, CHAR(text), (int) LEN(text)); + PDFCPP_CATCH; +} + +void +PDFlib::fit_textline(string text, float x, float y, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY + m_PDFlib_api->PDF_fit_textline(p, CHAR(text), (int) LEN(text), x, y, CHAR(optlist)); + PDFCPP_CATCH; +} + +void +PDFlib::set_text_pos(float x, float y) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_set_text_pos(p, x, y); + PDFCPP_CATCH; +} + +void +PDFlib::show(string text) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_show2(p, CHAR(text), (int) LEN(text)); + PDFCPP_CATCH; +} + +int +PDFlib::show_boxed(string text, float left, float top, + float width, float height, string hmode, string feature) + PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + { + retval = m_PDFlib_api->PDF_show_boxed(p, CHAR(text), left, top, width, + height, CHAR(hmode), CHAR(feature)); + } + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::show_xy(string text, float x, float y) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_show_xy2(p, CHAR(text), (int) LEN(text), x, y); + PDFCPP_CATCH; +} + +float +PDFlib::stringwidth(string text, int font, float fontsize) + PDF_THROWS(PDFlib::Exception) +{ + float retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_stringwidth2(p, CHAR(text), + (int) LEN(text), font, fontsize); + PDFCPP_CATCH; + + return retval; +} + +/* p_type3.c */ + +void +PDFlib::begin_font(string fontname, float a, float b, + float c, float d, float e, float f, string optlist) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_begin_font(p, CHAR(fontname), 0, + a, b, c, d, e, f, CHAR(optlist)); + PDFCPP_CATCH; +} + +void +PDFlib::begin_glyph(string glyphname, float wx, float llx, float lly, + float urx, float ury) PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_begin_glyph(p, CHAR(glyphname), wx, llx, lly, urx, ury); + PDFCPP_CATCH; +} + +void +PDFlib::end_font() + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_end_font(p); + PDFCPP_CATCH; +} + +void +PDFlib::end_glyph() + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_end_glyph(p); + PDFCPP_CATCH; +} + +/* p_xgstate.c */ + +int +PDFlib::create_gstate (string optlist) PDF_THROWS(PDFlib::Exception) +{ + int retval = 0; + + PDFCPP_TRY + retval = m_PDFlib_api->PDF_create_gstate(p, CHAR(optlist)); + PDFCPP_CATCH; + + return retval; +} + +void +PDFlib::set_gstate(int gstate) + PDF_THROWS(PDFlib::Exception) +{ + PDFCPP_TRY m_PDFlib_api->PDF_set_gstate(p, gstate); + PDFCPP_CATCH; +} diff --git a/src/libs/pdflib/bind/pdflib/cpp/pdflib.hpp b/src/libs/pdflib/bind/pdflib/cpp/pdflib.hpp new file mode 100644 index 0000000000..c9fca0e0ed --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/pdflib.hpp @@ -0,0 +1,312 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +// $Id: pdflib.hpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// +// in sync with pdflib.h 1.151.2.22 +// +// C++ wrapper for PDFlib +// +// + +#ifndef PDFLIB_HPP +#define PDFLIB_HPP + +#include + + using namespace std; + +// We use PDF as a C++ class name, therefore hide the actual C struct +// name for PDFlib usage with C++. + +#define PDF_THROWS_CPP_EXCEPTIONS + +#include "pdflib.h" + + +#ifdef PDF_THROWS_CPP_EXCEPTIONS +#define PDF_THROWS(x) throw (x) +#define PDF_THROWS_NOTHING throw () +#else +#define PDFlib PDF +#define PDF_THROWS(x) +#define PDF_THROWS_NOTHING +#endif + + +// The C++ class wrapper for PDFlib + +class PDFlib { +public: +#ifdef PDF_THROWS_CPP_EXCEPTIONS + class Exception + { + public: + Exception(string errmsg, int errnum, string apiname, void *opaque); + string get_message(); + string get_errmsg(); + int get_errnum(); + string get_apiname(); + const void *get_opaque(); + private: + string m_errmsg; + int m_errnum; + string m_apiname; + void * m_opaque; + }; // Exception + + PDFlib(errorproc_t errorproc = NULL, + allocproc_t allocproc = NULL, + reallocproc_t reallocproc = NULL, + freeproc_t freeproc = NULL, + void *opaque = NULL) PDF_THROWS(Exception); + + PDFlib(allocproc_t allocproc, + reallocproc_t reallocproc, + freeproc_t freeproc, + void *opaque = NULL) PDF_THROWS(Exception); + +#else // PDF_THROWS_CPP_EXCEPTIONS + + PDFlib(errorproc_t errorproc = NULL, + allocproc_t allocproc = NULL, + reallocproc_t reallocproc = NULL, + freeproc_t freeproc = NULL, + void *opaque = NULL); + +#endif // PDF_THROWS_CPP_EXCEPTIONS + + ~PDFlib() PDF_THROWS_NOTHING; + + /* p_annots.c */ + void add_launchlink(float llx, float lly, float urx, float ury, + string filename) PDF_THROWS(PDFlib::Exception); + void add_locallink(float llx, float lly, float urx, float ury, + int page, string optlist) PDF_THROWS(PDFlib::Exception); + void add_note(float llx, float lly, float urx, float ury, + string contents, string title, string icon, bool open) + PDF_THROWS(PDFlib::Exception); + void add_pdflink(float llx, float lly, float urx, float ury, + string filename, int page, + string optlist) PDF_THROWS(PDFlib::Exception); + void add_weblink(float llx, float lly, float urx, float ury, string url) + PDF_THROWS(PDFlib::Exception); + void attach_file(float llx, float lly, float urx, float ury, + string filename, string description, string author, + string mimetype, string icon) PDF_THROWS(PDFlib::Exception); + void set_border_color(float red, float green, float blue) + PDF_THROWS(PDFlib::Exception); + void set_border_dash(float b, float w) PDF_THROWS(PDFlib::Exception); + void set_border_style(string style, float width) + PDF_THROWS(PDFlib::Exception); + + /* p_basic.c */ + void begin_page(float width, float height) PDF_THROWS(PDFlib::Exception); + void close() PDF_THROWS(PDFlib::Exception); + void end_page() PDF_THROWS(PDFlib::Exception); + string get_apiname() PDF_THROWS(PDFlib::Exception); + const char *get_buffer(long *size) PDF_THROWS(PDFlib::Exception); + string get_errmsg() PDF_THROWS(PDFlib::Exception); + int get_errnum() PDF_THROWS(PDFlib::Exception); + int get_majorversion() PDF_THROWS_NOTHING; + int get_minorversion() PDF_THROWS_NOTHING; + void * get_opaque() PDF_THROWS(PDFlib::Exception); + // Overloaded generic open and close methods + int open(string filename) PDF_THROWS(PDFlib::Exception); + int open(FILE *fp) PDF_THROWS(PDFlib::Exception); + void open(writeproc_t writeproc) PDF_THROWS(PDFlib::Exception); + int open_fp(FILE *fp) PDF_THROWS(PDFlib::Exception); + int open_file(string filename) PDF_THROWS(PDFlib::Exception); + void open_mem(writeproc_t writeproc) PDF_THROWS(PDFlib::Exception); + + /* p_block.c */ + int fill_imageblock(int page, string blockname, int image, string optlist) + PDF_THROWS(PDFlib::Exception); + int fill_pdfblock(int page, string blockname, int contents, string optlist) + PDF_THROWS(PDFlib::Exception); + int fill_textblock(int page, string blockname, string text, string optlist) + PDF_THROWS(PDFlib::Exception); + + /* p_color.c */ + int makespotcolor(string spotname, int reserved) + PDF_THROWS(PDFlib::Exception); + void setcolor(string fstype, string colorspace, + float c1, float c2, float c3, float c4) PDF_THROWS(PDFlib::Exception); + void setgray(float g) PDF_THROWS(PDFlib::Exception); + void setgray_fill(float g) PDF_THROWS(PDFlib::Exception); + void setgray_stroke(float g) PDF_THROWS(PDFlib::Exception); + void setrgbcolor(float red, float green, float blue) + PDF_THROWS(PDFlib::Exception); + void setrgbcolor_fill(float red, float green, float blue) + PDF_THROWS(PDFlib::Exception); + void setrgbcolor_stroke(float red, float green, float blue) + PDF_THROWS(PDFlib::Exception); + + /* p_draw.c */ + void arc(float x, float y, float r, float alpha, float beta) + PDF_THROWS(PDFlib::Exception); + void arcn(float x, float y, float r, float alpha, float beta) + PDF_THROWS(PDFlib::Exception); + void circle(float x, float y, float r) PDF_THROWS(PDFlib::Exception); + void clip() PDF_THROWS(PDFlib::Exception); + void closepath() PDF_THROWS(PDFlib::Exception); + void closepath_fill_stroke() PDF_THROWS(PDFlib::Exception); + void closepath_stroke() PDF_THROWS(PDFlib::Exception); + void curveto(float x1, float y1, float x2, float y2, float x3, float y3) + PDF_THROWS(PDFlib::Exception); + void endpath() PDF_THROWS(PDFlib::Exception); + void fill() PDF_THROWS(PDFlib::Exception); + void fill_stroke() PDF_THROWS(PDFlib::Exception); + void lineto(float x, float y) PDF_THROWS(PDFlib::Exception); + void moveto(float x, float y) PDF_THROWS(PDFlib::Exception); + void rect(float x, float y, float width, float height) + PDF_THROWS(PDFlib::Exception); + void stroke() PDF_THROWS(PDFlib::Exception); + + /* p_encoding.c */ + void encoding_set_char(string encoding, int slot, string glyphname, + int uv) PDF_THROWS(PDFlib::Exception); + + /* p_font.c */ + int findfont(string fontname, string encoding, int embed) + PDF_THROWS(PDFlib::Exception); + int load_font(string fontname, string encoding, string optlist) + PDF_THROWS(PDFlib::Exception); + void setfont(int font, float fontsize) PDF_THROWS(PDFlib::Exception); + + /* p_gstate.c */ + void concat(float a, float b, float c, float d, float e, float f) + PDF_THROWS(PDFlib::Exception); + void initgraphics() PDF_THROWS(PDFlib::Exception); + void restore() PDF_THROWS(PDFlib::Exception); + void rotate(float phi) PDF_THROWS(PDFlib::Exception); + void save() PDF_THROWS(PDFlib::Exception); + void scale(float sx, float sy) PDF_THROWS(PDFlib::Exception); + void setdash(float b, float w) PDF_THROWS(PDFlib::Exception); + void setdashpattern(string optlist) PDF_THROWS(PDFlib::Exception); + void setflat(float flatness) PDF_THROWS(PDFlib::Exception); + void setlinecap(int linecap) PDF_THROWS(PDFlib::Exception); + void setlinejoin(int linejoin) PDF_THROWS(PDFlib::Exception); + void setlinewidth(float width) PDF_THROWS(PDFlib::Exception); + void setmatrix(float a, float b, float c, float d, float e, float f) + PDF_THROWS(PDFlib::Exception); + void setmiterlimit(float miter) PDF_THROWS(PDFlib::Exception); + void setpolydash(float *darray, int length) PDF_THROWS(PDFlib::Exception); + void skew(float alpha, float beta) PDF_THROWS(PDFlib::Exception); + void translate(float tx, float ty) PDF_THROWS(PDFlib::Exception); + + /* p_hyper.c */ + int add_bookmark(string text, int parent, bool open) + PDF_THROWS(PDFlib::Exception); + void add_nameddest (string name, string optlist) PDF_THROWS(PDFlib::Exception); + void set_info(string key, string value) PDF_THROWS(PDFlib::Exception); + + /* p_icc.c */ + int load_iccprofile(string profilename, string optlist) + PDF_THROWS(PDFlib::Exception); + + /* p_image.c */ + void add_thumbnail(int image) PDF_THROWS(PDFlib::Exception); + void close_image(int image) PDF_THROWS(PDFlib::Exception); + void fit_image (int image, float x, float y, string optlist) + PDF_THROWS(PDFlib::Exception); + int load_image (string imagetype, string filename, string optlist) + PDF_THROWS(PDFlib::Exception); + int open_CCITT(string filename, int width, int height, + bool BitReverse, int K, bool BlackIs1) PDF_THROWS(PDFlib::Exception); + int open_image(string imagetype, string source, const char *data, + long len, int width, int height, int components, int bpc, + string params) PDF_THROWS(PDFlib::Exception); + int open_image_file(string imagetype, string filename, + string stringparam, int intparam) PDF_THROWS(PDFlib::Exception); + void place_image(int image, float x, float y, float scale) + PDF_THROWS(PDFlib::Exception); + + /* p_params.c */ + string get_parameter(string key, float modifier) + PDF_THROWS(PDFlib::Exception); + float get_value(string key, float modifier) PDF_THROWS(PDFlib::Exception); + void set_parameter(string key, string value) PDF_THROWS(PDFlib::Exception); + void set_value(string key, float value) PDF_THROWS(PDFlib::Exception); + + /* p_pattern.c */ + int begin_pattern(float width, float height, float xstep, float ystep, + int painttype) PDF_THROWS(PDFlib::Exception); + void end_pattern() PDF_THROWS(PDFlib::Exception); + + /* p_pdi.c */ + void close_pdi(int doc) PDF_THROWS(PDFlib::Exception); + void close_pdi_page(int page) PDF_THROWS(PDFlib::Exception); + void fit_pdi_page (int page, float x, float y, string optlist) + PDF_THROWS(PDFlib::Exception); + string get_pdi_parameter(string key, int doc, int page, int reserved, + int *len) PDF_THROWS(PDFlib::Exception); + float get_pdi_value(string key, int doc, int page, int reserved) + PDF_THROWS(PDFlib::Exception); + int open_pdi(string filename, string stringparam, int reserved) + PDF_THROWS(PDFlib::Exception); + int open_pdi_page(int doc, int pagenumber, string optlist) + PDF_THROWS(PDFlib::Exception); + void place_pdi_page(int page, float x, float y, float sx, float sy) + PDF_THROWS(PDFlib::Exception); + int process_pdi(int doc, int page, string optlist) + PDF_THROWS(PDFlib::Exception); + + /* p_resource.c */ + void create_pvf(string filename, void *data, size_t size, string options) + PDF_THROWS(PDFlib::Exception); + int delete_pvf(string filename) PDF_THROWS(PDFlib::Exception); + + /* p_shading.c */ + int shading (string shtype, float x0, float y0, float x1, float y1, + float c1, float c2, float c3, float c4, string optlist) + PDF_THROWS(PDFlib::Exception); + int shading_pattern (int shading, string optlist) + PDF_THROWS(PDFlib::Exception); + void shfill (int shading) PDF_THROWS(PDFlib::Exception); + + /* p_template.c */ + int begin_template(float width, float height) PDF_THROWS(PDFlib::Exception); + void end_template() PDF_THROWS(PDFlib::Exception); + + /* p_text.c */ + void continue_text(string text) PDF_THROWS(PDFlib::Exception); + void fit_textline(string text, float x, float y, string optlist) + PDF_THROWS(PDFlib::Exception); + void set_text_pos(float x, float y) PDF_THROWS(PDFlib::Exception); + void show(string text) PDF_THROWS(PDFlib::Exception); + int show_boxed(string text, float left, float top, + float width, float height, string hmode, string feature) + PDF_THROWS(PDFlib::Exception); + void show_xy(string text, float x, float y) PDF_THROWS(PDFlib::Exception); + float stringwidth(string text, int font, float fontsize) + PDF_THROWS(PDFlib::Exception); + + /* p_type3.c */ + void begin_font(string fontname, float a, float b, float c, float d, + float e, float f, string optlist) PDF_THROWS(PDFlib::Exception); + void begin_glyph(string glyphname, float wx, float llx, float lly, + float urx, float ury) PDF_THROWS(PDFlib::Exception); + void end_font() PDF_THROWS(PDFlib::Exception); + void end_glyph() PDF_THROWS(PDFlib::Exception); + + /* p_xgstate.c */ + int create_gstate (string optlist) PDF_THROWS(PDFlib::Exception); + void set_gstate(int gstate) PDF_THROWS(PDFlib::Exception); + + +private: + PDF *p; + const PDFlib_api *m_PDFlib_api; +}; + +#endif // PDFLIB_HPP diff --git a/src/libs/pdflib/bind/pdflib/cpp/quickreference.cpp b/src/libs/pdflib/bind/pdflib/cpp/quickreference.cpp new file mode 100644 index 0000000000..140145a4ec --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/quickreference.cpp @@ -0,0 +1,102 @@ +// $Id: quickreference.cpp,v 1.1 2004/10/06 17:46:40 laplace Exp $ +// +// PDFlib/PDI client: mini imposition demo +// +#include + +#include "pdflib.hpp" + +int +main(void) +{ + try { + PDFlib *p; // pointer to the PDFlib class + int manual, page; + int font, row, col; + const int maxrow = 2; + const int maxcol = 2; + char optlist[128]; + int startpage = 1, endpage = 4; + const float width = 500, height = 770; + int pageno; + const string infile = "reference.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + const string searchpath = "../data"; + + p = new PDFlib(); + + // open new PDF file + if (p->open_file("quickreference.pdf") == -1) { + cerr << "Error: " << p->get_errmsg() << endl; + return 2; + } + + p->set_parameter("SearchPath", searchpath); + + // This line is required to avoid problems on Japanese systems + p->set_parameter("hypertextencoding", "host"); + + p->set_info("Creator", "quickreference.cpp"); + p->set_info("Author", "Thomas Merz"); + p->set_info("Title", "mini imposition demo (C++)"); + + manual = p->open_pdi(infile, "", 0); + if (manual == -1) { + cerr << "Error: " << p->get_errmsg() << endl; + return 2; + } + + row = 0; + col = 0; + + p->set_parameter("topdown", "true"); + + for (pageno = startpage; pageno <= endpage; pageno++) { + if (row == 0 && col == 0) { + p->begin_page(width, height); + font = p->load_font("Helvetica-Bold", "host", ""); + p->setfont(font, 18); + p->set_text_pos(24, 24); + p->show("PDFlib Quick Reference"); + } + + page = p->open_pdi_page(manual, pageno, ""); + + if (page == -1) { + cerr << "Error: " << p->get_errmsg() << endl; + return 2; + } + + sprintf(optlist, "scale %f", (float) 1/maxrow); + p->fit_pdi_page(page, width/maxcol*col, + (row + 1) * height/maxrow, optlist); + p->close_pdi_page(page); + + col++; + if (col == maxcol) { + col = 0; + row++; + } + if (row == maxrow) { + row = 0; + p->end_page(); + } + } + + // finish the last partial page + if (row != 0 || col != 0) + p->end_page(); + + p->close(); + p->close_pdi(manual); + + } + catch (PDFlib::Exception &ex) { + cerr << "PDFlib exception occurred in quickreference sample: " << endl; + cerr << "[" << ex.get_errnum() << "] " << ex.get_apiname() + << ": " << ex.get_errmsg() << endl; + return 2; + } + + return 0; +} diff --git a/src/libs/pdflib/bind/pdflib/cpp/quickreference.dsp b/src/libs/pdflib/bind/pdflib/cpp/quickreference.dsp new file mode 100644 index 0000000000..24bcd0f158 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/quickreference.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="quickreference" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=quickreference - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "quickreference.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "quickreference.mak" CFG="quickreference - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "quickreference - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "quickreference - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "quickreference - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /version:4.0 /subsystem:console /debug /machine:I386 /out:"pdfclock.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /machine:I386 /out:"release\quickreference.exe" /libpath:"..\..\..\libs\pdflib\Release" /libpath:"..\..\pdflib" + +!ELSEIF "$(CFG)" == "quickreference - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "../../../libs/pdflib" /I "../../pdflib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /machine:I386 /out:"hello.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib /nologo /version:4.0 /subsystem:console /pdb:none /debug /machine:I386 /libpath:"..\..\..\libs\pdflib\Debug" /libpath:"..\..\pdflib" +# SUBTRACT LINK32 /map + +!ENDIF + +# Begin Target + +# Name "quickreference - Win32 Release" +# Name "quickreference - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib.cpp +# End Source File +# Begin Source File + +SOURCE=.\quickreference.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\pdflib.hpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/cpp/readme.txt b/src/libs/pdflib/bind/pdflib/cpp/readme.txt new file mode 100644 index 0000000000..ad5a68f4e3 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/cpp/readme.txt @@ -0,0 +1,3 @@ +Notes on the PDFlib C++ binding: + +(none) diff --git a/src/libs/pdflib/bind/pdflib/cpp/samples.mcp b/src/libs/pdflib/bind/pdflib/cpp/samples.mcp new file mode 100644 index 0000000000..226b8473ee Binary files /dev/null and b/src/libs/pdflib/bind/pdflib/cpp/samples.mcp differ diff --git a/src/libs/pdflib/bind/pdflib/data/LuciduxSans-Oblique.afm b/src/libs/pdflib/bind/pdflib/data/LuciduxSans-Oblique.afm new file mode 100644 index 0000000000..ec2cbe6f90 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/data/LuciduxSans-Oblique.afm @@ -0,0 +1,497 @@ +StartFontMetrics 2.0 +Comment Copyright (c) 2000 Bigelow & Holmes Inc. and Y&Y, Inc. +Comment Patents pending. All Rights Reserved. +Comment Lucidux is a trademark of Bigelow & Holmes Inc. +Comment CreationDate: 2000 Mar 04 11:21:33 +Comment For other Bigelow & Holmes fonts see http://www.YandY.com +Version 000.200 +Notice Copyright (C) 2000 Bigelow & Holmes Inc. and Y&Y, Inc. All rights reserved. +FullName Lucidux Sans Oblique +FamilyName LuciduxSans +Weight Normal +ItalicAngle -11.3 +IsFixedPitch false +UnderlinePosition -100 +UnderlineThickness 50 +FontName LuciduxSans-Oblique +FontBBox -114 -211 1095 993 +Comment UniqueID 5096732 +CapHeight 723 +XHeight 530 +Ascender 771 +Descender -193 +EncodingScheme AdobeStandardEncoding +StartCharMetrics 337 +C 32 ; WX 278 ; N space ; B 0 0 0 0 ; +C 33 ; WX 278 ; N exclam ; B 91 0 332 723 ; +C 34 ; WX 355 ; N quotedbl ; B 163 530 464 771 ; +C 35 ; WX 556 ; N numbersign ; B 55 0 645 723 ; +C 36 ; WX 556 ; N dollar ; B 58 -60 586 783 ; +C 37 ; WX 889 ; N percent ; B 118 -18 915 741 ; +C 38 ; WX 667 ; N ampersand ; B 65 -18 706 741 ; +C 40 ; WX 333 ; N parenleft ; B 116 -145 447 771 ; +C 41 ; WX 333 ; N parenright ; B 11 -145 343 771 ; +C 42 ; WX 389 ; N asterisk ; B 131 367 482 723 ; +C 43 ; WX 584 ; N plus ; B 102 48 598 530 ; +C 44 ; WX 278 ; N comma ; B 48 -157 223 120 ; +C 45 ; WX 333 ; N hyphen ; B 94 253 355 325 ; +C 46 ; WX 278 ; N period ; B 79 0 223 120 ; +C 47 ; WX 278 ; N slash ; B -58 -145 452 723 ; +C 48 ; WX 556 ; N zero ; B 96 -18 605 741 ; +C 49 ; WX 556 ; N one ; B 112 0 512 741 ; +C 50 ; WX 556 ; N two ; B 50 0 573 741 ; +C 51 ; WX 556 ; N three ; B 76 -18 567 741 ; +C 52 ; WX 556 ; N four ; B 56 0 580 723 ; +C 53 ; WX 556 ; N five ; B 78 -18 602 723 ; +C 54 ; WX 556 ; N six ; B 95 -18 605 741 ; +C 55 ; WX 556 ; N seven ; B 108 0 675 723 ; +C 56 ; WX 556 ; N eight ; B 80 -18 623 741 ; +C 57 ; WX 556 ; N nine ; B 82 -18 592 741 ; +C 58 ; WX 278 ; N colon ; B 91 0 293 530 ; +C 59 ; WX 278 ; N semicolon ; B 60 -157 293 530 ; +C 60 ; WX 584 ; N less ; B 109 48 639 530 ; +C 61 ; WX 584 ; N equal ; B 84 163 616 416 ; +C 62 ; WX 584 ; N greater ; B 61 48 591 530 ; +C 63 ; WX 556 ; N question ; B 183 0 614 741 ; +C 64 ; WX 1015 ; N at ; B 173 -18 994 741 ; +C 65 ; WX 667 ; N A ; B 9 0 655 723 ; +C 66 ; WX 667 ; N B ; B 81 0 688 723 ; +C 67 ; WX 722 ; N C ; B 118 -18 801 741 ; +C 68 ; WX 722 ; N D ; B 81 0 762 723 ; +C 69 ; WX 667 ; N E ; B 93 0 762 723 ; +C 70 ; WX 611 ; N F ; B 93 0 729 723 ; +C 71 ; WX 778 ; N G ; B 106 -18 827 741 ; +C 72 ; WX 722 ; N H ; B 81 0 786 723 ; +C 73 ; WX 278 ; N I ; B 88 0 335 723 ; +C 74 ; WX 500 ; N J ; B 1 -145 555 723 ; +C 75 ; WX 667 ; N K ; B 93 0 738 723 ; +C 76 ; WX 556 ; N L ; B 81 0 552 723 ; +C 77 ; WX 833 ; N M ; B 81 0 897 723 ; +C 78 ; WX 722 ; N N ; B 81 0 786 723 ; +C 79 ; WX 778 ; N O ; B 107 -18 816 741 ; +C 80 ; WX 667 ; N P ; B 81 0 756 723 ; +C 81 ; WX 778 ; N Q ; B 107 -145 816 741 ; +C 82 ; WX 722 ; N R ; B 81 0 718 723 ; +C 83 ; WX 667 ; N S ; B 64 -18 704 741 ; +C 84 ; WX 611 ; N T ; B 139 0 746 723 ; +C 85 ; WX 722 ; N U ; B 122 -18 786 723 ; +C 86 ; WX 667 ; N V ; B 162 0 806 723 ; +C 87 ; WX 944 ; N W ; B 157 0 1077 723 ; +C 88 ; WX 667 ; N X ; B 13 0 793 723 ; +C 89 ; WX 667 ; N Y ; B 160 0 798 723 ; +C 90 ; WX 611 ; N Z ; B 50 0 706 723 ; +C 91 ; WX 278 ; N bracketleft ; B 44 -145 420 771 ; +C 92 ; WX 278 ; N backslash ; B 116 -145 278 723 ; +C 93 ; WX 278 ; N bracketright ; B -16 -145 359 771 ; +C 94 ; WX 469 ; N asciicircum ; B 76 289 509 723 ; +C 95 ; WX 556 ; N underscore ; B 34 -72 508 0 ; +C 97 ; WX 556 ; N a ; B 69 -12 543 542 ; +C 98 ; WX 556 ; N b ; B 74 -12 579 771 ; +C 99 ; WX 500 ; N c ; B 87 -12 552 542 ; +C 100 ; WX 556 ; N d ; B 83 -12 635 771 ; +C 101 ; WX 556 ; N e ; B 89 -12 564 542 ; +C 102 ; WX 278 ; N f ; B 85 0 461 783 ; +C 103 ; WX 556 ; N g ; B 14 -205 590 542 ; +C 104 ; WX 556 ; N h ; B 75 0 570 771 ; +C 105 ; WX 222 ; N i ; B 63 0 304 723 ; +C 106 ; WX 222 ; N j ; B -114 -205 307 723 ; +C 107 ; WX 500 ; N k ; B 75 0 547 771 ; +C 108 ; WX 222 ; N l ; B 63 0 313 771 ; +C 109 ; WX 833 ; N m ; B 75 0 846 542 ; +C 110 ; WX 556 ; N n ; B 75 0 570 542 ; +C 111 ; WX 556 ; N o ; B 86 -12 576 542 ; +C 112 ; WX 556 ; N p ; B 36 -193 579 542 ; +C 113 ; WX 556 ; N q ; B 83 -193 587 542 ; +C 114 ; WX 333 ; N r ; B 75 0 434 542 ; +C 115 ; WX 500 ; N s ; B 61 -12 508 542 ; +C 116 ; WX 278 ; N t ; B 97 -12 379 636 ; +C 117 ; WX 556 ; N u ; B 92 -12 587 530 ; +C 118 ; WX 500 ; N v ; B 115 0 600 530 ; +C 119 ; WX 722 ; N w ; B 112 0 821 530 ; +C 120 ; WX 500 ; N x ; B 14 0 578 530 ; +C 121 ; WX 500 ; N y ; B 75 -193 600 530 ; +C 122 ; WX 500 ; N z ; B 36 0 564 530 ; +C 123 ; WX 334 ; N braceleft ; B 67 -145 431 771 ; +C 124 ; WX 260 ; N bar ; B 65 -145 320 771 ; +C 125 ; WX 334 ; N braceright ; B 28 -145 392 771 ; +C 126 ; WX 584 ; N asciitilde ; B 94 201 605 377 ; +C 161 ; WX 333 ; N exclamdown ; B 79 -193 321 530 ; +C 162 ; WX 556 ; N cent ; B 149 0 617 723 ; +C 163 ; WX 556 ; N sterling ; B 59 0 609 741 ; +C 165 ; WX 556 ; N yen ; B 110 0 671 723 ; +C 167 ; WX 556 ; N section ; B 38 -163 610 741 ; +C 168 ; WX 556 ; N currency ; B 97 143 604 580 ; +C 169 ; WX 191 ; N quotesingle ; B 160 506 310 771 ; +C 171 ; WX 556 ; N guillemotleft ; B 109 48 579 482 ; +C 180 ; WX 278 ; N periodcentered ; B 127 240 271 360 ; +C 182 ; WX 537 ; N paragraph ; B 151 -145 586 723 ; +C 187 ; WX 556 ; N guillemotright ; B 83 48 553 482 ; +C 191 ; WX 611 ; N questiondown ; B 77 -211 508 530 ; +C 193 ; WX 333 ; N grave ; B 209 626 406 783 ; +C 194 ; WX 333 ; N acute ; B 188 626 449 783 ; +C 195 ; WX 333 ; N circumflex ; B 121 626 462 783 ; +C 196 ; WX 333 ; N tilde ; B 129 626 477 741 ; +C 197 ; WX 333 ; N macron ; B 135 627 463 699 ; +C 198 ; WX 333 ; N breve ; B 160 626 486 783 ; +C 199 ; WX 333 ; N dotaccent ; B 243 626 360 723 ; +C 200 ; WX 333 ; N dieresis ; B 153 626 447 711 ; +C 202 ; WX 333 ; N ring ; B 201 626 427 848 ; +C 203 ; WX 333 ; N cedilla ; B 44 -211 228 0 ; +C 205 ; WX 333 ; N hungarumlaut ; B 100 626 515 783 ; +C 206 ; WX 333 ; N ogonek ; B 61 -181 225 0 ; +C 207 ; WX 333 ; N caron ; B 153 626 494 783 ; +C 225 ; WX 1000 ; N AE ; B 9 0 1095 723 ; +C 227 ; WX 370 ; N ordfeminine ; B 139 402 436 741 ; +C 232 ; WX 556 ; N Lslash ; B 68 0 552 723 ; +C 233 ; WX 778 ; N Oslash ; B 47 -18 881 741 ; +C 234 ; WX 1000 ; N OE ; B 107 -18 1095 741 ; +C 235 ; WX 365 ; N ordmasculine ; B 145 402 448 741 ; +C 241 ; WX 889 ; N ae ; B 69 -12 897 542 ; +C 245 ; WX 222 ; N dotlessi ; B 63 0 265 530 ; +C 248 ; WX 222 ; N lslash ; B 60 0 329 771 ; +C 249 ; WX 611 ; N oslash ; B 68 -12 649 542 ; +C 250 ; WX 944 ; N oe ; B 87 -12 951 542 ; +C 251 ; WX 611 ; N germandbls ; B 63 -12 602 783 ; +C -1 ; WX 667 ; N Aacute ; B 9 0 690 940 ; +C -1 ; WX 667 ; N Abreve ; B 9 0 686 940 ; +C -1 ; WX 667 ; N Acircumflex ; B 9 0 662 940 ; +C -1 ; WX 667 ; N Adieresis ; B 9 0 655 868 ; +C -1 ; WX 667 ; N Agrave ; B 9 0 655 940 ; +C -1 ; WX 667 ; N Amacron ; B 9 0 663 856 ; +C -1 ; WX 667 ; N Aogonek ; B 9 -181 655 723 ; +C -1 ; WX 667 ; N Aring ; B 9 0 655 945 ; +C -1 ; WX 667 ; N Atilde ; B 9 0 677 898 ; +C -1 ; WX 722 ; N Cacute ; B 118 -18 801 940 ; +C -1 ; WX 722 ; N Ccaron ; B 118 -18 801 940 ; +C -1 ; WX 722 ; N Ccedilla ; B 118 -211 801 741 ; +C -1 ; WX 722 ; N Ccircumflex ; B 118 -18 801 940 ; +C -1 ; WX 722 ; N Cdotaccent ; B 118 -18 801 880 ; +C -1 ; WX 722 ; N Dcaron ; B 81 0 762 940 ; +C -1 ; WX 722 ; N Dcroat ; B 68 0 763 723 ; +C -1 ; WX 667 ; N Eacute ; B 93 0 762 940 ; +C -1 ; WX 667 ; N Ebreve ; B 93 0 762 940 ; +C -1 ; WX 667 ; N Ecaron ; B 93 0 762 940 ; +C -1 ; WX 667 ; N Ecircumflex ; B 93 0 762 940 ; +C -1 ; WX 667 ; N Edieresis ; B 93 0 762 868 ; +C -1 ; WX 667 ; N Edotaccent ; B 93 0 762 880 ; +C -1 ; WX 667 ; N Egrave ; B 93 0 762 940 ; +C -1 ; WX 667 ; N Emacron ; B 93 0 762 856 ; +C -1 ; WX 722 ; N Eng ; B 81 -205 786 723 ; +C -1 ; WX 667 ; N Eogonek ; B 93 -181 762 723 ; +C -1 ; WX 722 ; N Eth ; B 68 0 763 723 ; +C -1 ; WX 556 ; N Euro ; B 52 -18 671 740 ; +C -1 ; WX 778 ; N Gbreve ; B 106 -18 827 940 ; +C -1 ; WX 778 ; N Gcircumflex ; B 106 -18 827 940 ; +C -1 ; WX 778 ; N Gcommaaccent ; B 106 -211 827 741 ; +C -1 ; WX 778 ; N Gdotaccent ; B 106 -18 827 880 ; +C -1 ; WX 722 ; N Hbar ; B 81 0 834 723 ; +C -1 ; WX 722 ; N Hcircumflex ; B 81 0 786 940 ; +C -1 ; WX 735 ; N IJ ; B 88 -145 790 723 ; +C -1 ; WX 278 ; N Iacute ; B 88 0 495 940 ; +C -1 ; WX 278 ; N Ibreve ; B 88 0 489 940 ; +C -1 ; WX 278 ; N Icircumflex ; B 88 0 466 940 ; +C -1 ; WX 278 ; N Idieresis ; B 88 0 451 868 ; +C -1 ; WX 278 ; N Idotaccent ; B 88 0 364 880 ; +C -1 ; WX 278 ; N Igrave ; B 88 0 368 940 ; +C -1 ; WX 278 ; N Imacron ; B 88 0 466 856 ; +C -1 ; WX 278 ; N Iogonek ; B 37 -181 335 723 ; +C -1 ; WX 278 ; N Itilde ; B 88 0 481 898 ; +C -1 ; WX 500 ; N Jcircumflex ; B 1 -145 674 940 ; +C -1 ; WX 667 ; N Kcommaaccent ; B 93 -211 738 723 ; +C -1 ; WX 556 ; N Lacute ; B 81 0 552 940 ; +C -1 ; WX 556 ; N Lcaron ; B 81 0 569 723 ; +C -1 ; WX 556 ; N Lcommaaccent ; B 81 -211 552 723 ; +C -1 ; WX 556 ; N Ldot ; B 81 0 552 723 ; +C -1 ; WX 722 ; N Nacute ; B 81 0 786 940 ; +C -1 ; WX 722 ; N Ncaron ; B 81 0 786 940 ; +C -1 ; WX 722 ; N Ncommaaccent ; B 81 -211 786 723 ; +C -1 ; WX 722 ; N Ntilde ; B 81 0 786 898 ; +C -1 ; WX 778 ; N Oacute ; B 107 -18 816 940 ; +C -1 ; WX 778 ; N Obreve ; B 107 -18 816 940 ; +C -1 ; WX 778 ; N Ocircumflex ; B 107 -18 816 940 ; +C -1 ; WX 778 ; N Odieresis ; B 107 -18 816 868 ; +C -1 ; WX 778 ; N Ograve ; B 107 -18 816 940 ; +C -1 ; WX 778 ; N Ohungarumlaut ; B 107 -18 847 940 ; +C -1 ; WX 778 ; N Omacron ; B 107 -18 816 856 ; +C -1 ; WX 778 ; N Otilde ; B 107 -18 816 898 ; +C -1 ; WX 722 ; N Racute ; B 81 0 718 940 ; +C -1 ; WX 722 ; N Rcaron ; B 81 0 718 940 ; +C -1 ; WX 722 ; N Rcommaaccent ; B 81 -211 718 723 ; +C -1 ; WX 667 ; N Sacute ; B 64 -18 704 940 ; +C -1 ; WX 667 ; N Scaron ; B 64 -18 704 940 ; +C -1 ; WX 667 ; N Scedilla ; B 64 -191 704 741 ; +C -1 ; WX 667 ; N Scircumflex ; B 64 -18 704 940 ; +C -1 ; WX 667 ; N Scommaaccent ; B 64 -211 704 741 ; +C -1 ; WX 611 ; N Tbar ; B 139 0 746 723 ; +C -1 ; WX 611 ; N Tcaron ; B 139 0 746 940 ; +C -1 ; WX 611 ; N Tcedilla ; B 139 -191 746 723 ; +C -1 ; WX 611 ; N Tcommaaccent ; B 139 -211 746 723 ; +C -1 ; WX 667 ; N Thorn ; B 81 0 729 723 ; +C -1 ; WX 722 ; N Uacute ; B 122 -18 786 940 ; +C -1 ; WX 722 ; N Ubreve ; B 122 -18 786 940 ; +C -1 ; WX 722 ; N Ucircumflex ; B 122 -18 786 940 ; +C -1 ; WX 722 ; N Udieresis ; B 122 -18 786 868 ; +C -1 ; WX 722 ; N Ugrave ; B 122 -18 786 940 ; +C -1 ; WX 722 ; N Uhungarumlaut ; B 122 -18 815 940 ; +C -1 ; WX 722 ; N Umacron ; B 122 -18 786 856 ; +C -1 ; WX 722 ; N Uogonek ; B 122 -181 786 723 ; +C -1 ; WX 722 ; N Uring ; B 122 -18 786 993 ; +C -1 ; WX 722 ; N Utilde ; B 122 -18 786 898 ; +C -1 ; WX 944 ; N Wcircumflex ; B 157 0 1077 940 ; +C -1 ; WX 667 ; N Yacute ; B 160 0 798 940 ; +C -1 ; WX 667 ; N Ycircumflex ; B 160 0 798 940 ; +C -1 ; WX 667 ; N Ydieresis ; B 160 0 798 868 ; +C -1 ; WX 611 ; N Zacute ; B 50 0 706 940 ; +C -1 ; WX 611 ; N Zcaron ; B 50 0 706 940 ; +C -1 ; WX 611 ; N Zdotaccent ; B 50 0 706 880 ; +C -1 ; WX 556 ; N aacute ; B 69 -12 607 783 ; +C -1 ; WX 556 ; N abreve ; B 69 -12 607 783 ; +C -1 ; WX 556 ; N acircumflex ; B 69 -12 578 783 ; +C -1 ; WX 556 ; N adieresis ; B 69 -12 554 711 ; +C -1 ; WX 333 ; N afii57929 ; B 228 549 369 771 ; +C -1 ; WX 556 ; N agrave ; B 69 -12 543 783 ; +C -1 ; WX 556 ; N amacron ; B 69 -12 569 699 ; +C -1 ; WX 556 ; N aogonek ; B 69 -181 543 542 ; +C -1 ; WX 333 ; N apostrophe ; B 228 549 369 771 ; +C -1 ; WX 556 ; N aring ; B 69 -12 543 848 ; +C -1 ; WX 556 ; N atilde ; B 69 -12 578 741 ; +C -1 ; WX 260 ; N brokenbar ; B 65 -145 320 771 ; +C -1 ; WX 500 ; N cacute ; B 87 -12 610 783 ; +C -1 ; WX 500 ; N ccaron ; B 87 -12 624 783 ; +C -1 ; WX 500 ; N ccedilla ; B 87 -211 552 542 ; +C -1 ; WX 500 ; N ccircumflex ; B 87 -12 592 783 ; +C -1 ; WX 500 ; N cdotaccent ; B 87 -12 552 723 ; +C -1 ; WX 333 ; N commaaccent ; B 45 -211 227 -54 ; +C -1 ; WX 737 ; N copyright ; B 72 0 810 723 ; +C -1 ; WX 615 ; N dcaron ; B 83 -12 769 771 ; +C -1 ; WX 556 ; N dcroat ; B 83 -12 688 771 ; +C -1 ; WX 400 ; N degree ; B 171 452 467 741 ; +C -1 ; WX 584 ; N divide ; B 102 0 598 578 ; +C -1 ; WX 222 ; N dotlessj ; B -114 -205 268 530 ; +C -1 ; WX 556 ; N eacute ; B 89 -12 603 783 ; +C -1 ; WX 556 ; N ebreve ; B 89 -12 597 783 ; +C -1 ; WX 556 ; N ecaron ; B 89 -12 606 783 ; +C -1 ; WX 556 ; N ecircumflex ; B 89 -12 579 783 ; +C -1 ; WX 556 ; N edieresis ; B 89 -12 565 711 ; +C -1 ; WX 556 ; N edotaccent ; B 89 -12 564 723 ; +C -1 ; WX 556 ; N egrave ; B 89 -12 564 783 ; +C -1 ; WX 556 ; N emacron ; B 89 -12 574 699 ; +C -1 ; WX 556 ; N eng ; B 75 -205 570 542 ; +C -1 ; WX 556 ; N eogonek ; B 89 -181 564 542 ; +C -1 ; WX 602 ; N eth ; B 87 -12 624 818 ; +C -1 ; WX 556 ; N gbreve ; B 14 -205 612 783 ; +C -1 ; WX 556 ; N gcircumflex ; B 14 -205 590 783 ; +C -1 ; WX 556 ; N gcommaaccent ; B 14 -205 590 848 ; +C -1 ; WX 556 ; N gdotaccent ; B 14 -205 590 723 ; +C -1 ; WX 556 ; N hbar ; B 75 0 570 771 ; +C -1 ; WX 556 ; N hcircumflex ; B 75 0 616 976 ; +C -1 ; WX 222 ; N iacute ; B 63 0 436 783 ; +C -1 ; WX 222 ; N ibreve ; B 63 0 430 783 ; +C -1 ; WX 222 ; N icircumflex ; B 63 0 406 783 ; +C -1 ; WX 222 ; N idieresis ; B 63 0 391 711 ; +C -1 ; WX 222 ; N igrave ; B 63 0 308 783 ; +C -1 ; WX 444 ; N ij ; B 63 -205 529 723 ; +C -1 ; WX 222 ; N imacron ; B 63 0 407 699 ; +C -1 ; WX 222 ; N iogonek ; B 8 -181 304 723 ; +C -1 ; WX 222 ; N itilde ; B 63 0 421 741 ; +C -1 ; WX 222 ; N jcircumflex ; B -114 -205 401 783 ; +C -1 ; WX 500 ; N kcommaaccent ; B 75 -211 547 771 ; +C -1 ; WX 500 ; N kgreenlandic ; B 75 0 547 530 ; +C -1 ; WX 222 ; N lacute ; B 63 0 463 976 ; +C -1 ; WX 292 ; N lcaron ; B 63 0 452 771 ; +C -1 ; WX 222 ; N lcommaaccent ; B -2 -211 313 771 ; +C -1 ; WX 334 ; N ldot ; B 63 0 410 771 ; +C -1 ; WX 584 ; N logicalnot ; B 114 145 611 434 ; +C -1 ; WX 222 ; N longs ; B 70 0 406 783 ; +C -1 ; WX 556 ; N mu ; B 30 -193 587 530 ; +C -1 ; WX 584 ; N multiply ; B 79 55 620 523 ; +C -1 ; WX 556 ; N nacute ; B 75 0 588 783 ; +C -1 ; WX 604 ; N napostrophe ; B 110 0 618 771 ; +C -1 ; WX 278 ; N nbspace ; B 0 0 0 0 ; +C -1 ; WX 556 ; N ncaron ; B 75 0 613 783 ; +C -1 ; WX 556 ; N ncommaaccent ; B 75 -211 570 542 ; +C -1 ; WX 556 ; N ntilde ; B 75 0 584 741 ; +C -1 ; WX 556 ; N oacute ; B 86 -12 603 783 ; +C -1 ; WX 556 ; N obreve ; B 86 -12 597 783 ; +C -1 ; WX 556 ; N ocircumflex ; B 86 -12 576 783 ; +C -1 ; WX 556 ; N odieresis ; B 86 -12 576 711 ; +C -1 ; WX 556 ; N ograve ; B 86 -12 576 783 ; +C -1 ; WX 556 ; N ohungarumlaut ; B 86 -12 705 783 ; +C -1 ; WX 556 ; N omacron ; B 86 -12 576 699 ; +C -1 ; WX 834 ; N onehalf ; B 65 -18 841 741 ; +C -1 ; WX 834 ; N onequarter ; B 89 -18 839 741 ; +C -1 ; WX 333 ; N onesuperior ; B 187 289 376 734 ; +C -1 ; WX 556 ; N otilde ; B 86 -12 588 741 ; +C -1 ; WX 584 ; N plusminus ; B 51 0 613 578 ; +C -1 ; WX 333 ; N racute ; B 75 0 510 783 ; +C -1 ; WX 333 ; N rcaron ; B 75 0 500 783 ; +C -1 ; WX 333 ; N rcommaaccent ; B 34 -211 434 542 ; +C -1 ; WX 737 ; N registered ; B 72 0 810 723 ; +C -1 ; WX 500 ; N sacute ; B 61 -12 582 783 ; +C -1 ; WX 500 ; N scaron ; B 61 -12 596 783 ; +C -1 ; WX 500 ; N scedilla ; B 61 -191 508 542 ; +C -1 ; WX 500 ; N scircumflex ; B 61 -12 563 783 ; +C -1 ; WX 500 ; N scommaaccent ; B 61 -211 508 542 ; +C -1 ; WX 333 ; N sfthyphen ; B 94 253 355 325 ; +C -1 ; WX 278 ; N tbar ; B 69 -12 379 636 ; +C -1 ; WX 375 ; N tcaron ; B 97 -12 517 824 ; +C -1 ; WX 278 ; N tcedilla ; B 69 -191 379 636 ; +C -1 ; WX 278 ; N tcommaaccent ; B 46 -211 379 636 ; +C -1 ; WX 556 ; N thorn ; B 36 -193 579 771 ; +C -1 ; WX 834 ; N threequarters ; B 112 -18 884 741 ; +C -1 ; WX 333 ; N threesuperior ; B 94 278 419 734 ; +C -1 ; WX 333 ; N twosuperior ; B 94 289 437 734 ; +C -1 ; WX 556 ; N uacute ; B 92 -12 600 783 ; +C -1 ; WX 556 ; N ubreve ; B 92 -12 594 783 ; +C -1 ; WX 556 ; N ucircumflex ; B 92 -12 587 783 ; +C -1 ; WX 556 ; N udieresis ; B 92 -12 587 711 ; +C -1 ; WX 556 ; N ugrave ; B 92 -12 587 783 ; +C -1 ; WX 556 ; N uhungarumlaut ; B 92 -12 682 783 ; +C -1 ; WX 556 ; N umacron ; B 92 -12 587 699 ; +C -1 ; WX 556 ; N uni20AC ; B 52 -18 671 740 ; +C -1 ; WX 556 ; N uogonek ; B 92 -181 587 530 ; +C -1 ; WX 556 ; N uring ; B 92 -12 587 848 ; +C -1 ; WX 556 ; N utilde ; B 92 -12 587 741 ; +C -1 ; WX 722 ; N wcircumflex ; B 112 0 821 783 ; +C -1 ; WX 500 ; N yacute ; B 75 -193 600 783 ; +C -1 ; WX 500 ; N ycircumflex ; B 75 -193 600 783 ; +C -1 ; WX 500 ; N ydieresis ; B 75 -193 600 711 ; +C -1 ; WX 500 ; N zacute ; B 36 0 564 783 ; +C -1 ; WX 500 ; N zcaron ; B 36 0 579 783 ; +C -1 ; WX 500 ; N zdotaccent ; B 36 0 564 723 ; +EndCharMetrics +StartComposites 132 +CC Aacute 2 ; PCC A 0 0 ; PCC acute 210 157 ; +CC Abreve 2 ; PCC A 0 0 ; PCC breve 169 157 ; +CC Acircumflex 2 ; PCC A 0 0 ; PCC circumflex 168 157 ; +CC Adieresis 2 ; PCC A 0 0 ; PCC dieresis 168 157 ; +CC Agrave 2 ; PCC A 0 0 ; PCC grave 126 157 ; +CC Amacron 2 ; PCC A 0 0 ; PCC macron 169 157 ; +CC Atilde 2 ; PCC A 0 0 ; PCC tilde 168 157 ; +CC Cacute 2 ; PCC C 0 0 ; PCC acute 281 157 ; +CC Ccaron 2 ; PCC C 0 0 ; PCC caron 250 157 ; +CC Ccircumflex 2 ; PCC C 0 0 ; PCC circumflex 250 157 ; +CC Cdotaccent 2 ; PCC C 0 0 ; PCC dotaccent 250 157 ; +CC Dcaron 2 ; PCC D 0 0 ; PCC caron 167 157 ; +CC Eacute 2 ; PCC E 0 0 ; PCC acute 240 157 ; +CC Ebreve 2 ; PCC E 0 0 ; PCC breve 193 157 ; +CC Ecaron 2 ; PCC E 0 0 ; PCC caron 191 157 ; +CC Ecircumflex 2 ; PCC E 0 0 ; PCC circumflex 199 157 ; +CC Edieresis 2 ; PCC E 0 0 ; PCC dieresis 192 157 ; +CC Edotaccent 2 ; PCC E 0 0 ; PCC dotaccent 192 157 ; +CC Egrave 2 ; PCC E 0 0 ; PCC grave 156 157 ; +CC Emacron 2 ; PCC E 0 0 ; PCC macron 186 157 ; +CC Gbreve 2 ; PCC G 0 0 ; PCC breve 256 157 ; +CC Gcircumflex 2 ; PCC G 0 0 ; PCC circumflex 256 157 ; +CC Gdotaccent 2 ; PCC G 0 0 ; PCC dotaccent 257 157 ; +CC Hcircumflex 2 ; PCC H 0 0 ; PCC circumflex 194 157 ; +CC Iacute 2 ; PCC I 0 0 ; PCC acute 15 157 ; +CC Ibreve 2 ; PCC I 0 0 ; PCC breve -28 157 ; +CC Icircumflex 2 ; PCC I 0 0 ; PCC circumflex -28 157 ; +CC Idieresis 2 ; PCC I 0 0 ; PCC dieresis -28 157 ; +CC Idotaccent 2 ; PCC I 0 0 ; PCC dotaccent -27 157 ; +CC Igrave 2 ; PCC I 0 0 ; PCC grave -70 157 ; +CC Imacron 2 ; PCC I 0 0 ; PCC macron -28 157 ; +CC Itilde 2 ; PCC I 0 0 ; PCC tilde -28 157 ; +CC Jcircumflex 2 ; PCC J 0 0 ; PCC circumflex 180 157 ; +CC Lacute 2 ; PCC L 0 0 ; PCC acute 24 157 ; +CC Ldot 2 ; PCC L 0 0 ; PCC dotaccent 245 -313 ; +CC Nacute 2 ; PCC N 0 0 ; PCC acute 226 157 ; +CC Ncaron 2 ; PCC N 0 0 ; PCC caron 195 157 ; +CC Ntilde 2 ; PCC N 0 0 ; PCC tilde 207 157 ; +CC Oacute 2 ; PCC O 0 0 ; PCC acute 265 157 ; +CC Obreve 2 ; PCC O 0 0 ; PCC breve 222 157 ; +CC Ocircumflex 2 ; PCC O 0 0 ; PCC circumflex 222 157 ; +CC Odieresis 2 ; PCC O 0 0 ; PCC dieresis 222 157 ; +CC Ograve 2 ; PCC O 0 0 ; PCC grave 180 157 ; +CC Ohungarumlaut 2 ; PCC O 0 0 ; PCC hungarumlaut 301 157 ; +CC Omacron 2 ; PCC O 0 0 ; PCC macron 222 157 ; +CC Otilde 2 ; PCC O 0 0 ; PCC tilde 222 157 ; +CC Racute 2 ; PCC R 0 0 ; PCC acute 192 157 ; +CC Rcaron 2 ; PCC R 0 0 ; PCC caron 143 157 ; +CC Sacute 2 ; PCC S 0 0 ; PCC acute 193 157 ; +CC Scaron 2 ; PCC S 0 0 ; PCC caron 162 157 ; +CC Scircumflex 2 ; PCC S 0 0 ; PCC circumflex 161 157 ; +CC Tcaron 2 ; PCC T 0 0 ; PCC caron 139 157 ; +CC Uacute 2 ; PCC U 0 0 ; PCC acute 243 157 ; +CC Ubreve 2 ; PCC U 0 0 ; PCC breve 201 157 ; +CC Ucircumflex 2 ; PCC U 0 0 ; PCC circumflex 201 157 ; +CC Udieresis 2 ; PCC U 0 0 ; PCC dieresis 201 157 ; +CC Ugrave 2 ; PCC U 0 0 ; PCC grave 159 157 ; +CC Uhungarumlaut 2 ; PCC U 0 0 ; PCC hungarumlaut 269 157 ; +CC Umacron 2 ; PCC U 0 0 ; PCC macron 201 157 ; +CC Uring 2 ; PCC U 0 0 ; PCC ring 201 145 ; +CC Utilde 2 ; PCC U 0 0 ; PCC tilde 201 157 ; +CC Wcircumflex 2 ; PCC W 0 0 ; PCC circumflex 311 157 ; +CC Yacute 2 ; PCC Y 0 0 ; PCC acute 213 157 ; +CC Ycircumflex 2 ; PCC Y 0 0 ; PCC circumflex 178 157 ; +CC Ydieresis 2 ; PCC Y 0 0 ; PCC dieresis 178 157 ; +CC Zacute 2 ; PCC Z 0 0 ; PCC acute 170 157 ; +CC Zcaron 2 ; PCC Z 0 0 ; PCC caron 145 157 ; +CC Zdotaccent 2 ; PCC Z 0 0 ; PCC dotaccent 145 157 ; +CC aacute 2 ; PCC a 0 0 ; PCC acute 158 0 ; +CC abreve 2 ; PCC a 0 0 ; PCC breve 121 0 ; +CC acircumflex 2 ; PCC a 0 0 ; PCC circumflex 116 0 ; +CC adieresis 2 ; PCC a 0 0 ; PCC dieresis 107 0 ; +CC agrave 2 ; PCC a 0 0 ; PCC grave 74 0 ; +CC amacron 2 ; PCC a 0 0 ; PCC macron 106 0 ; +CC aring 2 ; PCC a 0 0 ; PCC ring 116 0 ; +CC atilde 2 ; PCC a 0 0 ; PCC tilde 101 0 ; +CC cacute 2 ; PCC c 0 0 ; PCC acute 161 0 ; +CC ccaron 2 ; PCC c 0 0 ; PCC caron 130 0 ; +CC ccircumflex 2 ; PCC c 0 0 ; PCC circumflex 130 0 ; +CC cdotaccent 2 ; PCC c 0 0 ; PCC dotaccent 130 0 ; +CC eacute 2 ; PCC e 0 0 ; PCC acute 154 0 ; +CC ebreve 2 ; PCC e 0 0 ; PCC breve 111 0 ; +CC ecaron 2 ; PCC e 0 0 ; PCC caron 112 0 ; +CC ecircumflex 2 ; PCC e 0 0 ; PCC circumflex 117 0 ; +CC edieresis 2 ; PCC e 0 0 ; PCC dieresis 118 0 ; +CC edotaccent 2 ; PCC e 0 0 ; PCC dotaccent 112 0 ; +CC egrave 2 ; PCC e 0 0 ; PCC grave 69 0 ; +CC emacron 2 ; PCC e 0 0 ; PCC macron 111 0 ; +CC gbreve 2 ; PCC g 0 0 ; PCC breve 126 0 ; +CC gcircumflex 2 ; PCC g 0 0 ; PCC circumflex 125 0 ; +CC gdotaccent 2 ; PCC g 0 0 ; PCC dotaccent 120 0 ; +CC hcircumflex 2 ; PCC h 0 0 ; PCC circumflex 115 193 ; +CC iacute 2 ; PCC dotlessi 0 0 ; PCC acute -13 0 ; +CC ibreve 2 ; PCC dotlessi 0 0 ; PCC breve -56 0 ; +CC icircumflex 2 ; PCC dotlessi 0 0 ; PCC circumflex -56 0 ; +CC idieresis 2 ; PCC dotlessi 0 0 ; PCC dieresis -56 0 ; +CC igrave 2 ; PCC dotlessi 0 0 ; PCC grave -98 0 ; +CC imacron 2 ; PCC dotlessi 0 0 ; PCC macron -56 0 ; +CC itilde 2 ; PCC dotlessi 0 0 ; PCC tilde -56 0 ; +CC lacute 2 ; PCC l 0 0 ; PCC acute -24 193 ; +CC nacute 2 ; PCC n 0 0 ; PCC acute 139 0 ; +CC ncaron 2 ; PCC n 0 0 ; PCC caron 119 0 ; +CC ntilde 2 ; PCC n 0 0 ; PCC tilde 107 0 ; +CC oacute 2 ; PCC o 0 0 ; PCC acute 154 0 ; +CC obreve 2 ; PCC o 0 0 ; PCC breve 111 0 ; +CC ocircumflex 2 ; PCC o 0 0 ; PCC circumflex 111 0 ; +CC odieresis 2 ; PCC o 0 0 ; PCC dieresis 111 0 ; +CC ograve 2 ; PCC o 0 0 ; PCC grave 69 0 ; +CC ohungarumlaut 2 ; PCC o 0 0 ; PCC hungarumlaut 190 0 ; +CC omacron 2 ; PCC o 0 0 ; PCC macron 111 0 ; +CC otilde 2 ; PCC o 0 0 ; PCC tilde 111 0 ; +CC racute 2 ; PCC r 0 0 ; PCC acute 61 0 ; +CC rcaron 2 ; PCC r 0 0 ; PCC caron 6 0 ; +CC sacute 2 ; PCC s 0 0 ; PCC acute 133 0 ; +CC scaron 2 ; PCC s 0 0 ; PCC caron 102 0 ; +CC scircumflex 2 ; PCC s 0 0 ; PCC circumflex 101 0 ; +CC uacute 2 ; PCC u 0 0 ; PCC acute 151 0 ; +CC ubreve 2 ; PCC u 0 0 ; PCC breve 108 0 ; +CC ucircumflex 2 ; PCC u 0 0 ; PCC circumflex 108 0 ; +CC udieresis 2 ; PCC u 0 0 ; PCC dieresis 108 0 ; +CC ugrave 2 ; PCC u 0 0 ; PCC grave 72 0 ; +CC uhungarumlaut 2 ; PCC u 0 0 ; PCC hungarumlaut 167 0 ; +CC umacron 2 ; PCC u 0 0 ; PCC macron 108 0 ; +CC uring 2 ; PCC u 0 0 ; PCC ring 108 0 ; +CC utilde 2 ; PCC u 0 0 ; PCC tilde 108 0 ; +CC wcircumflex 2 ; PCC w 0 0 ; PCC circumflex 198 0 ; +CC yacute 2 ; PCC y 0 0 ; PCC acute 127 0 ; +CC ycircumflex 2 ; PCC y 0 0 ; PCC circumflex 91 0 ; +CC ydieresis 2 ; PCC y 0 0 ; PCC dieresis 91 0 ; +CC zacute 2 ; PCC z 0 0 ; PCC acute 115 0 ; +CC zcaron 2 ; PCC z 0 0 ; PCC caron 85 0 ; +CC zdotaccent 2 ; PCC z 0 0 ; PCC dotaccent 82 0 ; +EndComposites +EndFontMetrics diff --git a/src/libs/pdflib/bind/pdflib/data/LuciduxSans-Oblique.pfa b/src/libs/pdflib/bind/pdflib/data/LuciduxSans-Oblique.pfa new file mode 100644 index 0000000000..33dcbc980c --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/data/LuciduxSans-Oblique.pfa @@ -0,0 +1,947 @@ +%!PS-AdobeFont-1.1: LuciduxSans-Oblique 000.200 +%%CreationDate: 2000 Mar 04 11:21:33 + +% Copyright (C) 2000 Bigelow & Holmes Inc. and Y&Y, Inc. +% Patents pending. All Rights Reserved. +% Lucidux is a trademark of Bigelow & Holmes Inc. + +% Permission is hereby granted, free of charge, to any person obtaining a +% copy of these Fonts and associated documentation files (the "Font Software"), +% to deal in the Font Software, including without limitation the rights to +% use, copy, merge, publish, distribute, sublicense, and/or sell copies of +% the Font Software, and to permit persons to whom the Font Software is +% furnished to do so, subject to the following conditions: + +% The above copyright, trademark, patent notices and this permission notice +% shall be included in all copies of one or more of the Software. + +% The Font Software may not be modified, alterered, or added to, and in +% particular the designs of glyphs or characters in the Fonts may not be +% modified nor may additional glyphs or characters be added to the Fonts, +% except that composite characters composed of two or more characters in the +% Fonts may be created using the seac (Standard Encoding Accented Character) +% Type 1 operator. + +% THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF +% COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BIGELOW & +% HOLMES INC. OR Y&Y, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +% LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR +% CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +% ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +% OTHER DEALINGS IN THE FONT SOFTWARE. + +% Except as contained in this notice, the names of Bigelow & Holmes Inc. +% and Y&Y, Inc. shall not be used in advertising or otherwise to promote +% the sale, use or other dealings in this Font Software without prior +% written authorization from the Bigelow & Holmes Inc. and Y&Y, Inc. + +% For further information, contact: +% mailto:support@yandy.com or mailto:design@bigelowandholmes.com +% For other Bigelow & Holmes fonts see http://www.YandY.com + +12 dict begin +/FontInfo 9 dict dup begin + /version (000.200) readonly def + /Notice (Copyright (C) 2000 Bigelow & Holmes Inc. and Y&Y, Inc. All rights reserved.) readonly def + /FullName (Lucidux Sans Oblique) readonly def + /FamilyName (LuciduxSans) readonly def + /Weight (Normal) readonly def + /ItalicAngle -11.3 def + /isFixedPitch false def + /UnderlinePosition -100 def + /UnderlineThickness 50 def +end readonly def +/FontName /LuciduxSans-Oblique def +/PaintType 0 def +/FontType 1 def +/FontMatrix [0.001 0 0.0002 0.001 0 0] readonly def +/Encoding StandardEncoding def +/FontBBox{-114 -211 1095 993}readonly def +/UniqueID 5096732 def +currentdict end +currentfile eexec +8053514D28EC28DA1630165FAB262882D3FD7667933E8516EE9710995B33AD6AFA66AE56E3B4F8 +1A010BA2D16746155E0B46B8233AF9FC6FB5A1DE6E6D7277AEC5CE81679028F3B440619FB93E88 +614EBEE63F9A83374DA4CF45FCBBACEBE22717D34438C9B2E3DC7580F497AC697EA20AC096930F +E90934EA8FFE999902BA55F2149DEADDCBC4CF03F530F526450856BF8F3CE1C247AA6810D725B6 +E4CB0C6B7DC3B7B5FBE22909A1ED01A6BCEFAE9A709DB1D61BF8A223420C27BC28535F3C5C58CE +BD7239771F455E727EB9C9025F7B0B98D9C49F8A33E8C9A67A30CBC40719B9902A42978F54386A +B019C6EED778074F809506075C7CF394AFF792A52C36CC8FCE79BAABF945F6AB3AE924FBF89F12 +D0D56822E09D7226051E5235D975B5A7E02610477A9B9148DA4E93861FF37C54BBB2F3196A5A37 +94CC7C8B06CB9817A184DD7B41CF130CA812FD511CC539DA6AE1E3D8D57C26DC2630D87CA276CB +0B55BEC3BB4626608A4DE50E3CBF313230AFAA9E86F83366003B63876ED7072ADF068B03629105 +DE8544254F4129096C4FCB741029ED5BA6CB35A252101753C6C281596F941C8920384006DC05B0 +7524CE87D7417B91C09BBEB93B101B235AB55AA83002BBEB2985F027DFBBC44788AEDC34EF62DC +2A09A392092F1A50F78EA5581DFC60B398AC14788E3B34B0668E36052A5CEE9B99194450D5EF58 +09CE4A135E0748A0B303CE38670BF1259F07723DE12F4CD22AF12BD694E18ED00771D33F9526DA +174BDF8B8A436D9393EBE156CCA73F0BF8918F0B38391DFF01B58AAEB19CDC034A8AF404241B38 +76EF2BA5BCA0B558529249379A42CF8760EEA3940C75D8BB8E8B73F93AF59AD85BCA1CBAD644AE +A6250A5D31A85622C0679181F4C77750A5B677F9E8E15DE7BF691BEE2D69968CA11564E06C0329 +26537AC3FABA055613A724B3963FE5D55CE9ACA3CB3B60A441545B5A0FC5997997B5A3F0E1278B +22BD9261203FF2843678148A6F35DAFD8A84FB0A31C02D199BE33C6D5028BA15BCD58A16B4A2EA +B46183B6C91682BF4D8FD64F91D8EE0AB4BE4C2F3B6563ECDD4EEC06069E63D1DB4C0444C4FADB +70C16B6C29BB621E1F5F55405E90D965A6AB5870C30A02BF977C49062B104C6D9F9E4B1B1B1FE4 +E4A19F5B2B36DDD1B9015B2BDF27CC38376393DFA5610A2AA765ED36F113A7F8534AE0ABFCEA93 +DCD5BC0C00B77742E6B92C88CD296CE78F6DDDF463FADF15D59F986035CAD7998191B9002D536F +D1578FA40E4B18D23164AFFD6C91D7B636497C86F743D14AB370FA25BFE68047223B3890AE5348 +BBD1A35D5B80579A6C1754EF5FC435A2D3F2131FC63525294329133007E8A2FDF8C3CCBB235577 +F0B8A91BDEB2648A833F63382FDB32E2E646CFF228F1F326F51E086D3023FFFC9185C666BF727C +4AD617741FF3DF6B205D21D7C2AA1616421AC49E94FF2F1A04A33ED9A13218C10650FCF75865E0 +CB7F08D250D3511E22D34E28DEFD4A44FBC573C888C769600053C088DA2D643AD043C4339F7581 +A38D4CDA6DC5005E90251D38F1FBA1AC10C679894D096C7572DE0E6CE0B8B3C8281DEC22BF337C +9D8ACC39B5A5030FC54E46C779AEF20DCA8926C5FE6422DB9AA089113A3E001A97E8762B68D7BE +E7E9AABC8F098161B076C10A9D560F9094A41114F56746C6ABB9E9F3454CDCE50669B0AB11F795 +1E928CA3A37EFEFCFF97D42127A373A35CC54D054150ACC4851969E4C848EF44B9B2C2F314DA9A +C684A09C35569DB4D0CEF7511AE719DEB3181C47E7F95FECB8BC2A1F8301350D7384E67B7EEAB7 +6EDAD4C361E8910F3A4538B0528E8E2338267506B8BAB757C203D9F96B01AA67534BBC736D108C +376EB8500E121768BFA217A6D0EB02DF688E9F664B4F15FD5CEAF0EF820B15AEFF20C18103865F +2C0457C39EA7F37FC5B1F02B45B85B91AFD59E3ACCF6392845FD5F0D197AE0DA7D2B992542CF20 +72AF36CD6DAF3E96E5B56F28F072D844A0114B35FCA75ED7B2ACFA9C71093A78ED1F749120C4AF +661B8D6CF18F054C459A8B939B30A6D72E9349794436167F048723E1E18A04E6DF65584DB34B89 +8313151E9E59E504B5EC388EE6B744F5D7E037BD99275D7DFA5D2ECFE2538B49B315B3A6994326 +8FE326CEB209E407BD9801C65321F3180E00DFA768DD7733EBBB5BD1FE14A96A1B86F5D7DBEF3A +EDAE880D7CFA4890E330A131C9B32E5EF275776B6E458ACAD52467570309F73B4E6BF16A18FE88 +DD79CFA7CB98E02F92AD7431B0474178BFE342DD6022BB7FA6443C7D8054D5CBB1055F515686A3 +2CF31102B435C4ADBE6D72CE5F5103FBABEE30CDC37580CCDB54DE8FB3CA1E43562D73B29788B8 +E1F3350F82DF5039C8E06D3B2191A750DF0AB9D2922A0DB6B4673E5226422BD81B58C058E5581F +A8E17C9935BEEAD10D3EC338BF825502700FF94619611955A6D7DDF55AAAE6B1EF2F9EDA1E7EDC +7D5B11B2771D03382A2594D9A08DDF522FBB8ED5183BDAD992530639F351586FDF24C4B9D9037E +8B97E36502F7DACB52E4C4602F5224BF8C1FC37908EA64FC8A2A5F05902E4B8BEFBCFBDE971A8F +82A99BDCCC29CE2677B832D08493D5463B13B25829BBD265201808D7412CB41A6B3CE3461CF737 +463EB19D3FCC05507A71AD250537CC05458FDB7ACDA9343892F3B27E215C572FB42D8AA9F4300A +1C282AB7F83BB28FBD134716EE09BE26488306488CD8E869647493156D540B90C2288FF1F359D9 +9685CB6EFEDAA78FD29F1302C67E97B01B8DAF5E6D77E16885460294F195C390B3D6ACEF2383DA +E3E4FFE6BA911C50F27B3AC9508F44327AB89DA58965079F3719EFC76B159B68328BDB139C1104 +54D7601E22D7E5EA501F805C5BF4FBA3EA051152EDEEDF0CC05D7C6765F194C5AEACD110816D94 +C6B30E978E4B07202AD3F748411BAF9200376B2FF1926255BA38A461A127FA8AC8C9B8BC3B4F83 +8A48515191B4A8C228FCB7680EA09D1EB9A482C1FCF5FB9320C3FCD37388EDE07099D0254F33BB +AE55EED41766B96278B46DF7CBECFA52D0DF759EE64C1CF9ADD80521CDDD11B8F137C40F0EF319 +632D5FAC752ECC0A398DAE6130B3E01AEA8D6804A7F2BCF6844A5E74398E626003FB64BD0F1B2E +99E3657FE6DCFD80B2F469D92EF076BACFAF61E14DF817C5E24EBD1CF9F1C0B4583F287E9E2FBB +048A2A00023514E4920F46289E4185C539C27D80F459B32D5EB2D43275C91CD09989731F423E33 +5263CF83F2215DD6649A39824DB3B89350CEE31C6C07D04C9B679DA07A78793A4CA3B75F7E31B9 +901C4379B103187BD1FCB473A327E9FCC7D45C9AC6F6EFB2DAD1817CA2F8976550116F9C3B6471 +CF39F1843F07E168303EE34EA83A84E3EDCD145B453856AD21FEEB480649CE489A42A3116115BD +BDE85F9F801D59AA8DDAE8603A6F778785C47E41FD3535F867A0C6EA2601492A64EFAC053E529A +5D1A77FF58F784050BFF66694145C44603100D079BD633A0F90200A14D92B717D58D639C5E119E +479C0B92DD6058791715D07F21646CDA08D5EF31E7F9D5722A48DCF8451B9C969254651801358A +A13244B9BF93E4B1B4C952574A1548E8C0A49B57F471F4C5093FFCAAE3DDD38E80C33A101BF195 +241E673F671438EC54DECBD006B6C9E3DB67C4B5AB05B9162900CD66F19B0EB3BF559B48D50F8D +CA100F63FE834A93AC0F9A0BAD4245E947CD848FA3277E24CADC2C477B2EEA0B2A339F0E7CF450 +CA0EF79D3A6C28598825E03FE55B4180A2494E097391D4D910ABDBFB2237275CC30606EC425B20 +472A229E8C778235A0DF2A002DA99A5DF4E83AC2816AE5229BAADEE4723AABEDF48C57017EF06C +8F1C4113C3C0B584453C96CC454835159E34F00B6FBECB94A79D21425D14506D23D0A918770BEE +69D60EF872BD5799A51149D875A8D6FFBA73830C4A5E0BC8D8CE28E72E9BCF3B32CC864A12E44B +1E8B9934BA0D2EF9DECA37431E542E0861CC85C8A7974440965995E0F773506FB7936F6613F023 +251C315267899ED6879FE1FD27C90E2579B4517B379DE6B9219FE84842D7206C6614C18722D6AB +5665B9E4294E178D8A141A3CA7F3413D922B4EFC6AC99F84870CD1655154E04E3C78DAB918F951 +5565D481F38DF8795940603CA0CBDE93F5455BB10DC043CF37342C03778F47ACA9BD2BA8502591 +9DB8199EC26FD75901809188CA821F99194480A7C3670D8B0B89C65A9D9FA372C6FD56075C3072 +E27B9ADFFBAFE39E646FC526DDEA73EB9B18E8A9D92D087A21A86C48DED12B0E11B9D04E1C1016 +9F2D1BF2E6E6AF8CD15028D54087DF5322503C931538C0E56BCA5CEBEAE300CD44C285EEBB5508 +7500BCD00B7DEC624F1758DA5E1D9AC0B7C3DBE5E8F1A7F87CBAE422D63E267FB7245736EB76DF +F82B54B156921AA5D31044CB1A2E88C1D0B108C4512543C2D8F001A104E2BE729B0AF4864F32A9 +2FB8385A1005753F545DC69D66B1ED980B9AEB13B3A0921BB13EFC532152C2A258D88ED3DA9B15 +2901A965A8108FF88B834DFBA4D80CA96148BDB3E13C037515872718FB22FEB61999671C1DFDFA +0AD97032B8E4CE1B3ADEFB01C6327AD2C492EC3B7439ED80E6BC296888225511FEBE1F165411E1 +A18FF41C2363D1538BB9CEF5DD7667BE52A28BAB7D4D8AE6823CCE5FCFD6284D4AC21B42B5F42E +81ED445D914F558CADF62907E1C37EC0AED73FA6DCC88529E6379C30B9B61C2E72CFF7CD919C08 +B81C924A65EDB08776E3762A109DA8B55B5F89C30A2AA4335EF6D5B6FC91F5BB9031F529EF6250 +08AF9BD044416428349CE319F1E98BBDF46C95628DF86B62F0385DDB5288D3BA3AA48DBFB0A726 +3BD3CBD87A75B52E2FA4E6E74BE7E335888EEE6EC40005B39C758A4E06FF9BCCF75ED94D643948 +B04691E7C46286D7D611A238A07ACD1FFC9F742F9DE1F570C8EDD01C6C3C03A1EE45E0783AD514 +BC071640BDB313C33D1BB81D4C8B59B4437B58BDFFEA478464E828F4DED42C55C9DC3C27C8A867 +BD8E754069FC1DECD51E5B3FAA42B39B429DACE417AA2BDDC825D2AF88D08BA85A54B65B96F15F +8594B13E09526BF8AB8A674DACBDCF1984739CFC1DD40BC2F64B1A4F7AADF93891FC191896A6AA +CD01598F655BF7BF4B681832A5E08EF9FB17A505AFF213A3D2CD5C4CF2DFB6861BC85CED1BEA11 +9C3715324857B8604F941543B85D97E52801CC4ABB95649CA733E6C393F480E0A16963A2CB3801 +37215CE5802D673337E6308D46F8AE275E26F19746CB319D3E4340AE879DBB7FC553DAEC61C4AA +56DEAFFDEFD42FA1DC5C45C28FD9F66E5D6F00489D53A3367BCAE8A81286E3A89F6091B43C245D +F6C7B6F9C35C47D639FDD264DD716603D8B3BABEF8785AC4F0740C6FB7EABC7BAE61A4517C1BF6 +F69DBF9F009500E576409BB69A4853CFBC72438829B86D6276DA9A6A0EB1F1711F730638DA6B91 +8A381890FC8EAD040297C85BD0307A62CC45A5BE691D1D258CB9F9BB776A32DC6F3624E9C897B2 +3FB5215AE222438504ED14C1553662AF4EEC414B8DD564DD78F713B1470750E5D143A0CD8475C9 +C85DE3AA5B8D06A527BA8100FD346D7B091FF5B4242099BBD680C7F4378BA86D70CF9AF604A812 +E51B64E0A6F26A3E278B58C67B5A49AD185BCE7EBD99597DF1BB5C0522EA51701D654DB5E2C657 +62EC461A245CB956B0B18FD09BDB2CB0617EC2D89EC932CC5F989938DFDE6487C29CD8308FB3A6 +4149590DC7AAFA3C9A79AC31B80152B8D49CECEB7FCBD28FDB98001E95D3C5AA65D63A3F2CD4F9 +A7EA2D5BB4D820D4C0A0ED49AB0643574ADA5276A9E6DD59B019C49B17EBB7DE7F2B400C54C852 +374DAA0539F683C3D684775CDE0EC09485B60FF2122A0EA168B4528253FD3EED1C9FBAF78B0D7F +1F1C6B509E3D8ECDA6D2E92C963319808EA7B268A3C37FAE564C84C78B450E67B2B69441051380 +D5AC704BDEE2EBE93D29E32B574A622FF6610DA773CA34210CF5D835BCB2BF121877D69B1ECB56 +3D694DA5995CF3F9C8CB525CFABF344D638EA8475790A055AFF046A32A8EC2691606B0F00141B2 +ADF78382AE4B6A7A16378D1AEA1B35C92E4DBA9183157A8F7AE96E7267E220315B3A00F204C235 +4C3350AD42833115AA3B783FEDD36D660165E7758F11D99EA3E8F0306F8989EE3ADCC5FB561381 +AB45CA683B78A35AD3BACA299770505F33E815BCBD0F513F5E7EA12A8782749142F94BA886B521 +64EDCB12EBF6DFB715C485D7A25AC051F71BF026D71D428320AD284CFCCF833756988279C2249F +F4E2282520CDC423376238BB57A4C6A7E29CEDAFEDF2F224F69FFD6B291664C898BC5F049DEDCE +4BB359CAE6F055E2A8160D24A96AB6E1CA0AD93FB80D95F7AB5083DA60336AF05A6DB33EA47651 +28F7273D09B3F0501E89CA21BD8E0A87FEA3BB92BAC38134100071BD46AA4B164472DD6EFFC697 +4C3C52B0B5D1849E1196D0D4B159FC4F7177D2DCF985BC6629DDDD1876EF83F522EFB7A4A7BD98 +98E439122195523E1825120A209F1D4DE2FEE3B9110AECE61ED044A1B0981ADEB82AF59B6B8FE7 +88B4DD6600098A4780914AD5BBF6CF66B53B642B0D57C4929BA0912888E995411C20A7F52E05E4 +BF3A2D7847ECE17DE0D6ACD79379988B2115B2469E39C24CE54A9D31114184F9865C07D707A2CB +14A2F45B62A19C5E3ADFC090F2F53C97458EDF8EBE0D23A1680CBE18AA90B694153E8E9A805E77 +B878C9CDE4D6D4532B6C1BAD4A42F7BB1EE748BAE521686B11A18B9FB97D10229997B718EFAF6E +EB3C223059083F3143E57DF2990229FEFCC5E91600CB3DC2602703F8256C663FF753B636475B05 +ECA220FF5D9897A3080C38440DC9C0095D3ADFB49C24E3B4CAAC89F5E4FB2527B54ECD34B4F094 +4D3C39657DF53FBB696C352E5AD9EA245BB4D61018E34154916DA4C227B2BC55034C67F373E65A +A4F3A9838DEF143CBA0409DE99206E3D31DF19AE24189613B4B11B47359966B72624A83D88A897 +696E2CED831E895A4C9337DFE19483AA3F967E2A483149EFB53B53791078B06E43DC859F84F35A +9201DD09588E695C707169258B18C7E8A72AD464786E9188E017125642D9D56427F18C8622426E +4144451E56108E615EE15A26419F0AB0AF19EDE2988C982BEBBCC99506EB5D9D2D22940E3CB28F +EECBCF8AF67F81F196D53462FAC860FA0076A902A785AC346A2DCD064294CE87602F3791D3E178 +88A5167DBB5FFF6DA15F221C47C50851FA7D81B7AFB2F7B8AE72566EA5EC5CDBE149CA15E1E07D +43F42497A7CCE6E2FB21168960446F31071F5F101BAEA8A1687ABE5BB00F564CFDC8A41D04826A +BDB6DDBAF8F02413F1E5E40446A74F64D287A16A70A305B38C5D58C40C80B2646CB7B9A8440715 +EA1A1496E10B1EC58357B6296548635A5709724B0858D0E56F1778590FA592DA34B0F5085BF1AB +F06B5B31C7C1119CF65D17106A5A657C737D1A3289F74DD8258BEB910EA530E1406CE6D0E78589 +BFD383BC20EDA6FF09D8DF2B9232053C4DD8A43D659BD28FEE42E451C14C5BC39C3689B1225869 +724668393B0D1917A4F85F9171054D30F6E77B8210CEE239F6E72D55463AF4729DAE9DCF007371 +6BB69BB5C57EEADCEE8387E600A7F9DBB36A25FB3B31E78E03019A19B8470ABF9691F2158B6CD0 +1A834164ACD7E6BB471C88E31A3A3EE5FD793EC2B66B459DB7643AF4E99A683B7CF84644F3149C +1D9108C93CF41A60696DCE71C0B9D0DB1DEEEFD812ECFC40CAB9E970FA0262D2428C515377043B +C9111E2972EB943FDFBE04ACDF77259A2E16A11BF14223871B00DCAA88CA0E43E4CFB615395FA5 +130AE496BC9F039055520187A5A03A491760CA2F755C7E8A9237A9FF40A3E10837B4A6C5731542 +9BDB0A55A29059D73AB0A7C12FC31267185279AE9DBC0DBFB0E431CF2A094C4B5EFFE835D627DA +FBED6C6F1E4993912FEF954036AD8F1554376369DC38C61AA9DA8E02233552BD769B3036992B47 +F3387D09F9AA1980C5312999899E4A4EF3C7BF90C8579C883D7B0BA2242E40F9A95501614B241C +4ECA8CB31071EC6EB6CEBBB917A0FCD3B12ADD6046AF3790668D9AEE87DAB0160F37DDB2230DD6 +51BB701E72A9B05A998516EE6F506B3504AF675A9DECF7A3719B16253F94B1A0D873582A61471F +B0F9CA6B9A4143DA90C60FA53F2D6C741F4D15E26AD2BAC61DFC0817EAF480D67F16D4A88183C6 +EEE75732772FCB0B31D149E2082AB91E9F2FD4C4569EC5FC46F1754E0C1E0A4EA3EEAF7A871DCD +9B05FA45A170D3052D1734A38F56B7D3F835CB8D375E7772B389AC5B924CCE960EE53019BF1322 +4918E1672C65D14331F32FFC0189762EF3EE777D0BFE48D5AB94B498D097D79ABD0FCF53A1402C +A94FFCDAE7FF694A99718B8111EA52CBD0A5F228A393852B2F9A1BB5AE74C39AAF9B8260FA6255 +A2946815E5AC55075074CC2BF6E3BF30F6B9477E6F162114485F80F8F271FB3100B5A6851AA333 +8B9FD55C62632BF3ED4ECDE95D8C291AF0B4E0C04766C061295095C3F157047A0A6CBB8B83D220 +623E2F28C8D1068C751C8C0EBDB1B0C92EF2E410EBF3DF9CA11624D481BA44C5B46424EA8F5E1F +EE45A6157DB420DD1168C77218A55BE868AF011AD844592BAF82CACF37A614AA4173C2BEE42D07 +1D21C2C136171CE5E3AF793BBDFB8F4DD613DABEAA00127156A60BFA49616EB454018FD2226DBC +1C31398BE17A926E67C3A9B51E54CC1BA91579AC3F36FA1C90C0497AE6BCC1FB9AC399BA49F855 +DFA95D303DF17D7578227087FEA07E4833EAB50170E4B2E1964F3227D69921887A462AA939F118 +2AF3310257B9DCB70AA063AF79E8D70D3EB52099A4D5B17F90F4D8D465EEED09BD4EC53811491A +9AE9A2648679CD4551FB68F7A8A32AE41B5C1C4BD79E0E538BFC58F4468FFB81B5341BE9AB45EB +05148D080B74CFB0E4F290A2E9A8B165DE52999A107608596F6DB9198545B252EC068C0330E1E5 +C9A613380C9421107EFA5BC4A65688143FD0C13165E2FC77705F1890E423C00BFA8C01AEBB6CF8 +094762D8E14CB390E63673FF5CFA983DEB170021104CD0A01407C0C4E4C3CDE146D749202B3DE7 +2FA97DAE1F89C28000727A7A7735DEFACBD19BEB8B34E63F0AF0D64F7F7A3CF3D8B579A69FD70B +449E677ACB9C2059A4B800AF36B03224F0729CE60C4DAAA4312AF1144932BAA474164C09377913 +57E38ED1F81403D3D70E87AC620E404B67D176EA3FC388F0996D29E558518F321EF9E48C0B58C9 +D5EA596C020A2283AB53240B58CFB2F3A1CF9203DA24BC43D8D41AB27248A5FD3F1DF2D9C25AC2 +2BE2FDC79C3C9688AAC025E2ED0E2FDCAE9C01F5E93892E7DCEA21FC6A75C3B33B0150C3E5EA36 +A8BB9598297550155B6F7947218F41CACCD3BE58AFA2329EAFB9E21AD9A143B97218D0FC606897 +301D358A70705F155525572CDBC419518271ECC052EBA5A9BC514AAEDB63C164306A63731C21A8 +499F2290DC24D81A4E461B7452FDC0E2ABDC89A7D98EE00ADC4DF87A3767A07948308EC40C3418 +FAA51ED4BB717794472D2F0D9D4B20C8801FA37B8E595946A2331A30A2464275AE3AC8EFAD8A22 +7CAB2C93E118D5B06D8A71C290887CF7ED7AF4601B54B3F1F6E0CA5C540768B44B64E6E7E58F8E +3FC5DBFF8BDD0B4A34A35589F8A4E85A46B3C6598D93666996D984E076F97A532D5FAA6C676502 +86979E208B03E95BF39B57DCBD25F21D325A2A6830F88476F9B8245FAB4BB958C9DEA3ABADF877 +6F4E8B710E2A8A34E8EDCF51F7BDBEFDA7536EC603C6EC7787AB070E4A1E347CD2A8A71B2E51B9 +EC40844FFABBF21DDE78FFB26E77F71D67D00E54E1C2D4C93C400BCAF2F420F728870C613A3095 +66E2CD17671EB9D17328C888543D2B07BE7B3673C3CA3BE4575EFCE4C41CDAEA9DE3FC724147A7 +62B48566F9904C89F56F21416C7D06BB2C4388E8AC2EE8405FC8699CE296ECCA953AC57A563FAD +DC3CD09320AEA8141A5B8D40B7E36589E15C903FD3AA21A879216CDCDDF7A6A380C66977DB988E +571805923D17A42138474486AD92D40E1DD87155F86189675A26686CA3237B74BBFE82F501E03B +4C6926E604E58ED619EB2DF4C6489A26C4D45E56C2433BCBF66401994AB0EA8DAA93FC93ADEA8C +C03838F50C47A343DBBD8EBAC78E2FE61369D79657EFEA08521DC8F24105495E10C45C24293712 +32EF31B24C63EAACC85C59864325429BF906E90C027C0C2AA5093B92FF293BBB45F4FF8711F81E +361DA2198EEA0BC761CD8C0D9D3032D0ED03AE529072FDB7120F8C8704FDD41FE4E35FE20AB947 +F25C83AA2A2B1893A2A1C1904C94B524F03F0645526B886D116848B9032B76707F46C65678EC17 +D83965BC5564ECAB2674F38AB2A7BCD544E6BADFA39BC5DDD8E0776FA466D923FA75DE28F8187A +63CE60F1B96CB9681FEEF4C432FD75A1B7A753112D79C9521262D9199AA1151475BA5C95E8A272 +34DD27F6CB2CA3D7F36457A0E16FAACBF59807672C8A08E498182755754A6722853AC9C5EC246B +153F5879BC910AC2647B9517EC12307FFE30997DC2A96B6742F4C3E7A2978FE29A4DF5D19B8B97 +06ED7379EA6096D13B7C69BCFAC8D00101BF38FD6712F348A6D82E7E7DA0A6D551F4AAD036FFE4 +FE558161270ECA320FEE2CA914CB22470275484F10D9EB1CE7782E5336729729009804B7FA5227 +E301E841608090F109929B395894907E410F8088FE16E61D820206E5852A06E52F0487A1867719 +EE4182F57FEFAED44FF16C5D07F8050CF36232368BE568360E8E5E36B0A389812C4C38D6E06599 +B394023C5AC862F10418D45B897535242EA4B85C0B39889CCB51350244F360A7C15FE9BE8D4FEA +4DCBD99DCA136E4AC27A6232B0E4051CA30E28D7334FA443CEDEEA4D9D1E47106667C6129E40E6 +8E033D54E8B41FD0B8C7297B92C641D4F31C4E8D4884590678A90BBDA4A0550A7A6608313221C9 +E23D40886A154FC3B81882E2E2A239B4051D78FE495F336BC1B157EEDB434B31CAFBB9A14D008E +DE727F5949F4EB5FC2104DAED0D1A48113172099A72D05AE12771006FB8CFE05B2368B9B42CB21 +EF2C18F61A8C4379E8C37C5CA661E79C8DE56AB6DA4A6364150FA27A2F94E56713C674F30C0EBF +F9B725B754688D2E8EDABD5A4E0C8595BE5BFF2313BD5B53DF71282C6C2EBF49AFA6004AF2CA21 +577C3F1CC44FF3C2B4025D914D943759060B1106E062957CD43E01AFA864140B0002ABE6A325ED +10385B3AA72C49C77EA067401C7F155F282B96397B84E0E6DD4E28480F4D09C1396E51DF7ACA92 +C47732C752BB28DBF2FE284A689FA6EF092A0B8FDE8253023D0C3A2F9437B57C6082CC5C88E6DA +831A0DFC932A009FF4ED36DC187562EDCE833EB70F3E128F918DDA9089B521AB1215ED6AD8328B +3371C660AA42EA386345169CC9936C74EC5B9442F34E43E0A6648C61DBC00A6595F4F27F3E59D7 +2123B7F84D4496F80BA60C3FD3B6DB97821E11DE92918F74DCD48CABE3A5F4BB20606B7232D1B2 +3C86ABE6DF561F496F45BA03EC89A84585CBD62E0E3C1E33ECB2B2EC80BE4F65958EBCFE42BB29 +43B6E396560BADAD5DF6E3DC4CF1222AC2E339A9A861DC8B4A85449918A5BB7C3E0A449F392B42 +192DF15A0C9F0DE2843DD0BA26FD8162734FBA4DAB878F29639B95E58CA740C33B618293908388 +2530C11416F949D4D1E78D5A61549A21AA6C038FD4AA8EA1F65FD68AFBF9BCB4797512CCE43C69 +0650A8648F2E84922B34A064A44060E9010C6CB700AFDCF765F16A76677A4D60A4A4D3BF23DB87 +C411A480F2FEBDB08B45582B4F15B486225512D4A0123126B79996FB409D9A1C2CAD9C4DCC0E26 +2F20B16D218A03C053FC84A52548AA808B278355E897B0418CC7710762163A97F5291D6F4C2DA6 +220D6A4A18F7970326BEAA3B11CDC64203330B73DB774EEFDEC7C5894525328817AE98EC67D06C +E232D3213BFE16CEA3B41AA69A8F573A69EBDBE40BEC1E25A83B89378643F8CF5BAE906389A403 +B8BB2A2A073EB58E4676C55E9BCE21DA1055E61D89AFF8E5286F80C97BBEE472D1337A9FAF0900 +576407AC06AF4E2D2F78E262CD203EB3094280A5F406B261C8F481B59F8833A0D0EB6B125EB7E5 +206E2C89A35B35964E52D0B3DBDAE7008F0C299C0498DD84149AFFAA9A3377144FC90ED52C6AB6 +E2544ADC6CC58B73F3898F7D0DA5FDCC54D9E676AA747894991038A5CF2AA4F65BFBAAE4D32C82 +1A21C5B284FB37D3DE45C2C92B29C8A3C911B01915586D8C4D57C5C6A0F1BA3E9D436B523D4D00 +C0CCD3E7EEC13736EF20E744E1ABE9AEABD32931DAD3DD2BC88388105C65C211C7F853A1C90BE6 +51645E4C9793B0F95C1FFCD3BEE11994F3C05D444D8C2511A0D5468457D2F4E749A5927E59EC9F +85F69D5057956FD0B70D69DBAD0E8DBAC7EC1410262929F7C53D316333375F23E6B686DDDF2AF8 +7BBC56729714372E5D5B04E8BAD8011718211293A3402CA94AD423362745028B8BCEED09670183 +7A47BA659CB282CF51403ED3E74EBB6D51A79C6951EDF9C65828A0F360D402A8593CD484EC2AFA +E543288B28E89ACF7070679F4DD79E2C98E81D06A2EC6FA93F4DD34DDC143B56F5734AC27B3F3B +FC696BEDCEA113F035249AF11C9BB38A891384E7F4ABDFA8B7F9F9EFB9CD5C7CCE4FB2CBCD1624 +20D265BF6D62C8318043E37FCE4EB54EFDC6B0AC22C86BBC2E1C3F8A179BA736ABCA0686CCF489 +1EB7B9F6073791F7DFE3A4EBB89C17EFB81459573F62AEBCE3751D7C2FFF6F8BB1F846649F1706 +F06CB4078914BA7A03D9A2F3184960D6F7D0D15283267BAB1D3A85C6743F57B2372958BEEFDFC7 +088224A09298E43ABA58DD5F7E181B3055759734BFBCE114B8D10C104CC9AD471251A993709571 +27E120FD7CC83381C321E1B607FE7EDA1D7BCC0420E04921B3E14FD0774987A6277C5C9E94BF06 +3BF0AACF88D14438067509DC123972A3C63545D7D8A23EA7CA721A3BB7611B42439949C537369E +B5706C4DF7ABB673A5319FCD42C4EA0B876A158E476DBE914F129FF88C1FDC6FD9C81EE073DB7D +81AE7EB717CC78420C08693C0ADFF3D5A6B2580FB03FAEE2B28B68368F05DA7E6164C0356D81A1 +736118C656798D2A59B931D337B36983851B846848A1AB2F18717A1BA02B5F86559FD693CD965E +B4F334FEF23B3C7F64CB1BBE86ED595695CB11AF4F32C26046059E4DCDD149EF2E47D81147F375 +A8432FA727386BC5D5D509711A258920F163FA24A7C7B936BF6F78DFB85FF1731670885DA6E7CF +92C36B13416CB099DFA12775332013B5EC11A4B1884E458EC62BA2D313625380E875653529BD18 +046C1C6C4BFA4885484497174F0C73DBF92B1921130F4398B76B6F5495725E33E930B677D6A60E +E388F5699F5347ED8B520F6AB9B71A9F417BDA923EA6FAD6298D253BD55DD27806A53E926604F6 +5E51E217DE1A3F57DE33B9CC678CF0590590D174F6822236FBEC7234BE06F07F886B408684CC84 +AEAA429AC7240BBAFE45121F40D01938AF2C5D247CD696255FEABD9159256F51689B339A7843ED +1763FF2B357E5ED39FE9E3053A74C588181C15694F0CA77FD721CE0AF61D68B8CE913124888383 +E51F4795874CFEE6C13B30415D4AA6377BB37DB5E2654E745D483B6FAEDAC975DB56CFEDAC6264 +C935D83D0372DA2B98B84CAB5450AE2335E409EB7E210451DE1FE08FC78CAC720B6FEE56BB6DFB +5B3D83EF2092E890CEF54412FA3AF3F92AE24CF4E53F2CA48429A7EE2DDC34EACACB484CF02116 +3B303B38546D9799FFB37B0D5F9394108F518AC824FEAA68DAC5B5159DFBD469996F80F1DC41DE +5AB6ED10D3FED9A298F39483052311BC6E7CADCE546AD8E65820DE1F47AF5882E9F035ED64C3A5 +F1368E1AE38DCBD80F4AFE0DC427BDC881110A292A023D8922745EE3FEEB057048CDE275AC0E17 +1681A3FFA7264AED9BA03E3FE3DF81A463FE2AE5B362BC89920FB6A6A6FF1CEB9F24E61B3D0219 +6FF0F2837326DA8F943AAD0317F68B7B3F81457785FAC57F882CAD078CC502D2AFCF64260EF779 +461D622A117E5DA766F2FCC7033B87717628451992EA4158A16FA3C889226B2FC0540C220BB480 +FA2AE0170E69C8FE97AB89AF3A5C7A0A398F34F2FFCB20A56A1D691A303A84AE09FF399497E638 +4E8EB6FDF67D941B424C84C58B9B5FCA6484370467F6F0DDD5B407156F6A41422CEC15FF38BC87 +7264D0558AB3A84F3B92FAE804D9F15FCA39F4ADD22821E636F01C3F25C3DAAF48DBC646428CFB +A690373961CEFCBDF1E747A735716FCA30AA72F3776F279E8CD6D223FF9A3C133CE93AE7B4D901 +61F1B2589F51E33387558D96ED493599554BCD3124D9F9E4F85076636862E3FA9E9C33704C0716 +684E2315AAB19CA54CD8774EAF4542CA2AC861C186A9660BD1FF972B341B825A7CE829970EC32E +646DAE9103E1AD2F337E880D3149000B1A4C3703EBA589B9D6324AB5AEDEF54102057226F43BDC +BD4C2542596218F50F3D9B8BD86241060E55385CF40CD1BB32D3361573B645D09840CAAA9F692A +5802D4E6863B23EB526834FB9FEC4C8BECE83B1DDDAF0E78EF6CB5691A83C2F45D62CD2D7BFED1 +6B6B1844942E43E7473305BF88551F0AB7B4DAADEB544E5344D77D7FD76190FB008CDF09D762C3 +E67C3796B1906E2F16A2F6EA46E0E266520D823B36F5D30B834C75E2A58C97B26B07A912F30B48 +9C8DD9BED4A4C76A9C4CC099AE2524D1B760CA6A1047CA8CF682CE6E6D7532E132477DAFA145FA +B571DFA8D9690C87FC9F7BAD55ED0FBD266E3C3CF618D94D2F0796C1AC2E86CD06C8C671A2528C +B5331C751DF60166841FC61A2D498FCA1DB077C8AB3FEF45F3C918A062DCBB3FF10199B62FACDE +9F6D7633603B3A4DE267D013A8C6FAA0EFCDCDD7EC38A82E9EEB177CB1AFF3A22B590B9F2F00EF +B44B5AA6E1A912181DE1F5E0BB6253F63D47FE9F9E6CBC3B4E7E5AD767841B7FF40FE9433651A2 +9B70ECC43C193A34CC5271BFF7682F5431B32E10B60F8F776168EDF198734846E93308502962F1 +7895AC2A253D367C4FC280EF45CFB287DB362CA5DD712342F7BC1DBC91E3F014F6C9CBE60757A4 +BDA19A16792D98BEDEC85C5DEBF5FEF45C1ED6A9529F0C071ABBE824293650959BE5446B21A23D +76FD9575729A7248BFC08A07505D539DCDC7E946D96130EB592DC2C5B0BC669EEFE149BD07741A +C388859D10337E07E3FB75132BA943BA0495834E297FBA2AAA671E4507FAC24823234FC0CDD166 +49C5577465675958A863B64683DE16F205F3FD5C00258D590B1A4832B094632DB6EF8C2829F753 +918516633859AF29552DB3E6D1F74F5AB15BA7216F900D3A708317B971375D11D4F4F9BC831299 +2E751FD31D0DADA44B0CB303C6AF3B3A6090B55CCA087DD0F4A16B25CC2B1E249C4F08622AB6E9 +D16B938DAE0E57E441151DE90FE40A7DC4DEDB300C99E967FAD2A1808A4DE6B106F743DAD775D3 +0BEDAA3C9D18A93F5024BB89887D373771EBFE8CB04AF4BB0B17B3CE4208D401E1BAC23F36241B +4166BF66F2A7CE59A240396FE8D6F37EAF30E1482639ABAE1FA3B05A9F1A915BEBCAD0C39EA72E +7FDA4326F02649B5765ABAA6136A53E96224E5320D8FD9CDB0C354EB729FD37302078E4418AC5C +CF29DF19A686C7031AC6BB28AB99608F3D92FEEE1D795E444B819624FE3BA235C6116118A7BBE2 +D3FCA93D01096D8B39186FA74D112B2E9548D3F08909F19F34872AB08075A3586E9674627E2DE2 +80D2358F2D4A39919FD4359E3F3016293B5EC420AAD2EED0DA0621C1F4F67FEDBCB3F52D2475BC +697F9637655DE73D38D37DD7BEFA8FFB241D41009B0CF30E8F749BAB37DA0E8A21873647ADB342 +C2D34B19C195B6FCB0CE92005ACFF149DFBAB097E7FA7D456C774BA66C7F901E6B627EB3D8D2E8 +64ABED0B7B43E036491486909C67ACA1BE8E375F3CC269242FDF813720ED71114D65B5EE33E2A9 +BB4D0025D8703095458592CFAB5F1D89EB134B4C74AD59D12B04CAB6D60775D5F61E9EA9F549B8 +DFD662C1DC2E67912A7C83CD6996718274D196DE9F8DAF382C05B71EF24ED35D23B92A63A8BD06 +BEE8B178A39AE50669135E28FB18752C39007998AEE3FECA68091FF94531EE2341731C8010BEE1 +95CFBC398F2A6A8B9356BC9315C3C65AD4155F577275CB4697AB8322149F68B3F49E0D697B5E9B +14EEEA36572128D2CB97299EB9039A26971720AD09DC033C5F3E72A8CF5099F0C661F061AA73D8 +F7B7EF6A3231D71B8CA31D0F1EF511C7C43F67904F777CDC99B99EBC339064F7873A205F766DA5 +1979E93AD7987BC1046E08584D1E0BE1D6A2FEE34E8AADE64624DDC3113DE99505D10343A5D92E +D737201CA31EE3A14EC98EA89090BD0CA90694ECA4D225E29584621EE6621CA1D9E5CBC7A7510F +4EDA32274D13D9293A786E8723D3E49A5F647B98DC14C3C11141EF875CCDCBEB9812F0FF225598 +AADB836BAE5714060DCBF2CAC0C6C042F6B5389EFC01776CDF4992A78C371A657596BAAC97738F +2EB75200C47BF7653A561983C7ADF807D676E25BE355F3B76247EAB21F32A8A0F010B7454848C1 +17EFE1705F67B72E1CBEFFB821F839FC141699507607BB181C68A360366F0167F9CC39DD4D0DFF +8464C8FA4AE47894BA20D5DA5E40C604BEC10441352A3EA8890CAFFA5A64E0BC07D8645660F9D6 +F830A271719846CBB7A5850E17E3F3924C55951C31F7E6ED1CB887FB95CFDD7B99746E8F3E773A +EF8EFAF5071B8E41A7755334C2E2931AE15B7DE4E64938286BA03111CCB90AB09EC39CC12A8A45 +82B1D54BC5140FCBF51BA190A6A439C81ED22E0182A1083AFA1A03EA8A4D546D6B564E618D553E +D313DD35D5E1FFC8D7BDC15B1F4E8BE094DDA24F0E8109198ED8B0810F5D13AD2A9C97ECE518B8 +377E054CEBB3B85EF73B4C4F0FF59A1F727131B00C5E4A1E3A2215D7523E7A80F32CD80E21BF89 +F10E5E93697448D743518C0A5C5905365C3E80C2C3896D36424006CF72B613B20668792F0C3903 +AF69A59FC29BA87633BDAA063B27CC0DAF6882B0378499F627FB184A1F3DF2FAEA6DCC4333E1A8 +4D62DCC8BBA596500EBECF3C5353893BD07F7D282EC9F8050D892B00972F99DECA3923C5F77BC5 +E62BF3E9F78C268AFAC2C00F5639790F2C255A41A3C660916B2CD25D2F075D6FCCDB8ED7780206 +990039B0A2440E59065A07418EBC53D7F35F4C1FBD10ED357D3B25E1B2AB42EF8A0C1C1BC30F62 +4BA98E317A9FAF0943480765BCB5DF0192DA204EB1DECF7766F4F57D27209203525598C4EAD672 +DFA16C99E1F5E92EA7CB142A1B929E282D8D3257E898D89CE32B25E4A0649EFCBBAD87441B2612 +372C15922BD6E6E46CAC07871D3A903FC9A16F2608AD8E2BF2FDF62CEC4D133DA9F3C371425418 +0987F8CE7BF4E907A63A6624A8BC08511380234E3B9F8E9943AF99DE6E1943F7055ED5A6467D71 +97146BA48B6C6A9B6802D2EDF7F7B0C55C66E53E94338468C334C4BCFAB842E4E62CEF3A86D052 +FEBDBF6059692E5446309E6AAAD7C3AFF70864F2F6D70AD9AD75D2AAB8436A750580C3969317F9 +850D7BF6EFDD3EC9142712F8611FDE2948E3457352E299C81B20ADA11055AC1162FD3CB67F34B3 +DDDFD0FAA99B5912641FD82C2999A16AF3110D4CEDF7598A402446FF14AA065979F32B11511B7B +692325EAB481B179CA6BA09DC0B0F2C6278570C6E93592093CE5EFFAE490619D58BBA6906924D5 +F9107E2CB71FF8D826868928F08A3E43DD6CF61CAE912DACE89BED9970506489CF6966A31A360A +AAFB25EC26735DD44241FCBDECF0F8ABB89DB3410D9477D4615A13F67E082A8958F8E1D1FA730C +4E9AECC71075FFF0002D2013BC8F1ACFEA24BCDDAC5591D8740646157EBD7606F66929F89C0BDD +57ECF5AAF3E99CBADB9F5C9F70ACCAE2B7E99221F7B489DF9042B80F24C9B5675DDE6BE8098726 +98DEB1A014F0E8E917E17990162BB9B149401CD4EF82D47C53AC369CD89BB7FBC2A9283D9114E4 +1BAF3D17A717B214C60F20576A058BC603C8D2D0E1FE42F473DF6491ED0F3DA6D960DEDDF80D64 +A23908E8B03C204EDC0F9CB787B8758408188BB2F0899519B826FBCCFF69978EAA8499E38EEBC6 +CBF6475A1B8682E6562D5A1B538303C4E313BA8C63A2442D9F182743FFFEB953D40E7B71CFC867 +2954CFFB39B3DDF0AFA03687F3FE8E5BDE44F5F6E9D3DACFAB5178239DDA89FAB6ACF15D46676B +1E0F093DE8FA0F099B045AE0039C2A4AB450B6CD6D9FB9A0F0A16D31CDABCC2300A449DF463B4E +37988EF16AB0A56E64A30382741AFCCF386EB6F41D2B8E99F1A1F63C9EEA6646A48069C736EF4A +C5074FEABA3FCE00F33B1C4B2E0442175127E022EBAFEF645A40B8FE006C9FC16812FE62468B31 +BE648C96799F9E227A2E96F629EAA1FA0C26A7DC8EDFA916059CAD8DDA35BD1DFAE4AD4C6F4E92 +D4B89D862C0C4EE1C458F7E9BAFD67C731922220A20C57E7E84A92B14CA7CD0C4E6BC1467A7543 +D97A1933BE0C0263E0ADE5F9A4434C45C17576314946B4825A07417D94D061CF0B71AF2F1E1F8B +7030F0E7210A7DEE8882E64DD777A5BF247EA5708607E2200AD0EE450225CF17277A97C13F2642 +09A5F83A46501CAF0AC674596379FCA3B9B2C71DAC24106826FB99ADE52A978B10C4408C637101 +D500C9198642552A88184038042E3E7193D6AEE4B65D706287C60375C250B6547205D84938D4BF +FA8F71A2596F5EBF115D2386FB639E37286C4B0ACE6C45AC4E0A3BC02DE8DEF7E2628D6C4D4D2C +21495B16D6FACECF7783FD44E20AF622D2F3829BDA0D9326A46C13FFAFF179A740F22483D99E05 +82E81E9DDEA9741F916A13C1AC247E52705389A75805C01FD9B361EA097A7D47EAB1DFD13D9111 +86E60F0B69823C6E0402F51F66D3677F4DC68B83B8DBFCE9A9769C9EC6631AAD5484738C024D1B +DB71BBEDED98E518D3D8043B762FC1A3A17966B1A3EA1E59585D23B697D988CE36E337726FAD4F +1192EFDF2CE53D58991441CE981A640CF683D412CFF40243A0C5959A717542756E185A4689F265 +D080FB0D762EBB2DB9B37C47A87E9FCAD6A8C032D6C914636710D9CDB3B082FCA62907E93DC849 +8998BF5BEF3BEEC31EEC205F536C39B1ECD0BAE888AFB1E43CA0978A97C1A51E1E822A9BA9E7AA +27DE81A573C822C8C58D62186FAA9F326FD31AD9641DC196C3676F32171F118A8C500D564048B4 +315C4EFDE53CCCA5D19BF70E6C0B9613037E95DE267B05CEA87AA3C3C66A07B266CD5F7FD39B8F +A6B4D8E72D8F4DFD4FA52A00A1D66CDA36711090FF5E182416BD3E0BD7248426C4E7F9F02CE817 +88B7D33AB94AC6F41634DC7E622BC11C1D2249915F21CB9B80713B106943F87CC97772A9B84C63 +FB5F13771E485967D2292BEA3BD017C6C6061DD0E593863C5ED982775274C0582D715A3170CFF6 +B895EB61F999BEC8A5528BB33282F22B9675AC71A489041FDCAF51D51A19D81811025440EFB49A +50C1EC14FE04596C14A7DD8F4F9D9071EA40328D21D05E89267E710E704FCAC607D55E9E3EA88D +63C0EFAB004CE589474A3945414EA5CA9A77C6A7E1CB00BEF416931CBB42625BE1D4D892616676 +791D41E6986F98AF29DF13A42F086546DA429C9FD464AEB7FD8647276704ECEC2E3282016C931C +74DF9DFDE9218A703ED29989AEBD5F08480F63994FCB03BA872C737B33851F164B6EAA40687E76 +35C82BB6134CF945FA1D074441C150B32CC01417203FFEFAFA07D4E6581CE31CF48FF6B4AD7103 +896C5B120ECAA67CADED19B6C3E1C273954AA518B112478ACF06F57C6F631844A781CC82A18283 +ACD80EB5BAA7A08D6910EC9C212DC483C31FAE516E286F735E616E46239076D1860A52382B28F2 +893E22A5E81ABD92C1E71D7D73A6F75BBD8EC4E62975F6B13B83431B93C84CF8B04B5923D43209 +530261BF3D92221485111B8428D0D347BF494A3DFB92CDE7F4FC1EFFC6E7B0E58AC3000CE36C2B +E8194932A52702604FFF93BBE313B41DBDE474DFC3619F3A861FC8BE35B2F2F72E0E0D76D2CABE +A25CEFDBAFFC084CAD9B8C56F4817CA2291AA2E05F9D5A47CF83EC6889A9CD709095B531FC39EA +9EF7AFC813814806927D226078633A71E92455A4347B07DAE5CBF9448CD54361757ED686809868 +79B159F3D906A4469622BBA3BC63921BB45E0DBDF4E6B412C576FF8D1545C258FDE4AA76E3A588 +C506467395AA8EF1F5C4D42DA413D42E17032C4994690FF655839E65AF9352E70A0B522353D154 +D8B5F3278D8596FC07744708BBA8220190AD78AD44A4D97F42C57BE89E281EC8EAA3227DE396C2 +51D22BDC019D95AE8DD73D01463DF9A9654440314B2A8AA78EA16EE5441FF358C83934E5B22DED +527050FEBB7523148EA2CCCEDEBCE2B19608AD9A03321108EE9BB0AE167CE3E996783DD7FB22BA +6DF7620741F7ABD1B970A72A7535B3C43210D8A6F87389BB4A6BE7BA1A4481383D448303691368 +04F99FC313500F5E064F5DBFF1194894B9F120A669D67E5C321B5EBB041B9CC9B85B2FE2DCA0AA +0FA5B2B389BF1B0A60498E425D31CE00052F5D8E24F04E01880E92E29CD963C99948876D9DCDD9 +306DCA082EE3A8BFF3B1D4A8CE9302B9DA4C9BBEE9BA9941C7C19A761F5699F9F8874E86597A92 +46A156B1338435A1DF700BE1E6D365698B99EF460D558DF976E7CBF9305226FC0BD8EEF41CD8C4 +5659452C5AFD8CDC6A7681883B460E34E88A0346B5B41AF8CE56542395AE7D9EE630C1547BDE1E +EEF0464ED5D8A59F487422BF14B69CAEA9FE4B44B35E8C224A28ED01FA3F478A132F5EDC9D55F9 +D53B5891DBBD462F35C373921D6E062190C01840AF421AB8884F209D3572A3BCBBE0061E7D3CC8 +0A40259088D0A7F82A865776AE02979749394798E0A65CC74ED6B4E7EE07062060CAA5889E324C +284B40D11B22AD49144797F9E2852692199840586D98003C218D355F499A4B4F3CC4ECE85F043C +8B17448EAB12502219616E73FBC9E024E002746A4DC4A4746CCE089B5BDA14546CECC0AC036862 +1E5EE5F3333AEE176866F22F79E7C4B3C4C0F013F019A8423F0BDFB0BD069CEB21AC533304EE10 +DA6133A3909B0F2CCCB61084F14699C7BDC7FAAF7E08E5A978270D2FDBAE6B5E02B2801217605C +788C9899B9B82EFECB9CB02AB2AE5FB157D50681F1D43C159CDF46B1F05491C5E439F24A9D0BB5 +EE1C2F520AE58E4628981F03F36957130C2880C2738C84C87DCB79EB5C7C130EEF0490859BEEDD +FEA0C624BF8265229826292F3BC6FB29A27A850A6D69087568EF9506DDE2E900B1C37EDE3C8605 +7E6A0E97C178A67BECB622405A4F99D5E0F9F9B9762AD25503C2BF02E5C36AA819BC8C37141975 +F3AB1C7E4C4418E5E56D2E16BF99B856C47BA738ACAA7068D81E76A24F197C74C04D3E72CFDCEF +B6EF052EA7A436105D27D7566552311A03E29076296D4818EF7BBBDA18AC6626EA7BBF3CA28EBC +0359E0F66ED49C89AC23314D585524AD63B48DD63CEDC066416D142583A75383F0FA138D53EE8A +FB81CDEDEBC90B676373B712485726B8049EF6717599976972412A75BBDAD6A4570FD95F58A4DD +043424F7DA4AD1FAAB8B8F974B955704B634F9C3CF0F297EAB66218CC678D31DB4FCAA789DEF80 +F13BCAE4855EFD9F86251A4A6A746B157F61905C001EA4438A1F00AEEE8E161D879546EF2BAF6D +40AAEF9494E127B291E3DCD29941A52563BC402FE9EA357B853A21B4E50D5BE2BCC93912FDDBF6 +B46A2DD3AF397F0E09E39AEE129F12ACC6AC407426102766381593D73933F41C08A6D293C88374 +0A51B2102AC1A3F71BB46BEFACAC04D80532D6E36D89C716BBA853D447200FC27649E38580EC1D +A1728D07629D9676E2B7CDE31C46A31DF5F9A9CFD04EBEB1797BE6FBC58C29C8C135259BCA6B09 +BA7292B965358F6C79B75084923E0BDC1DDD214A6578DC4A4A968F3844CCE1216ED1C1966816FF +99B4B7CDACF2F3D363AFA381467328D72843D61AAABF4B752E36B334BA23FA1D834DCC959B4DFD +DE5C32DAC6D5D3DE385FE3791EDD62551101D9E219B77E2C51CCF63E219C51B330F197DBCA948B +3727CDEFE782BC7513A9A11045F0F184AF1DDF2FB654B5CFA2FD7CEE4E198137CBF8C16C902FF2 +B35FC7DDB8E769750E2920895758D853897EC2C2E79B5763B88530B4A5A4E10A20A71E7991CAD0 +26F8DFB9EA166D8B58CE596FB9E456AE276DB602716EBE339D81C15E62D2CFF2A356B97B7A6D70 +CAAE6276DBF3E41D995CC20B76450342314805FFB74639217E2316CD2FA6406DD5A88B6987EA6F +A23E620A461B075B81DE8F4F2F4AF703FB16C5166E9620A50DAEE9827F6E05C913B1B07C70B550 +A3855F63CB1F18B21B2C0B64C930FA01DF40503D486E3ADCD31FB244A2590AA19FDD395C1E52FA +833A69A0D8DB922897291EBE520006A949C6228520906590426DC9FC298D3B4909DF305C2B41CF +7BA0181A437C88BEBFCE09FB9DC21829ABF5CC5A72004F7DC1A04310E9AAFEE3844528B52C6034 +06DE4AA5FE8A70DE9347DD2D129B9D0C96B1E2B8B67006B4F6763162ADEB702739AC0A3F2F4B3D +C1181A0AF575A90DE3F4808D399D57E4BA2AD9C33AD87DEF44E1A72817B14893E7344BD33DC104 +6583526AAE6FB4B19B7A4890B3B38B06DECC81F7C8B8754924E32F09F1DF35AB1E63918D643BFF +E12EE8A4EECD816FCC648883E67B8D8C3D37869D75BC0E38CE6C213E17B624F5A82604922E4CEB +6047A7002CC260CAFE7E501E7DBCC71D08F0C0267B3391D58C00F17322E18A88648B59460101C9 +801950A6AE05F90367E1D0B2B68AA7C82997747998CF36E2BAB18F80B9225BB8303D9C68ADD86A +AFE9DDEB4E7AA39B3BC61FAF63477C355C7C04324ED3BC943EEEBA3BC2E2C0C156C2874A3663D0 +1C1F8EA826A1DDCA09566637D4B5AFCBD2FC112DF0F35E2C0D6F385AD575C1480DBEE713527655 +00ECDBADCDE426C3B33781B4FC5926576708998537EDEF5AF2AF65C0198B0957B7C0C822B033D4 +8D3B547A32FEEA3A45BDCF869287C981D3EA1BA6928944D62DD3F4C21BD2DB628C1C8707B343AA +97199ED1ACB52CCCD0822A4538E12FAB15D704812D19D04C7A0A4AA1B1B360FA6A6876A8C79CB6 +4E0EFF153C65C1F0226B5DF7100BD9D0F3CA6567BAD1ADB1E695AA440579A8B643AD4B4FC12982 +A46B1A97323B9CA57D3F9C4F4F257274EEE06669D83A6A64B1CB90DDE54EECCAAE923D234D7FBE +F89A04C755B1C92CE5E20086222413D8F4555EB4E452124F83AF92EEDFCD0FE63FABFF189DCEBD +5FD618F956E206F3970C558818136E95EFC257227553B790BDE15B2BA19A775D6F1A6909C7E877 +C50803ECBD75868D20700EA708416A947C8D4CAA9E20B1C26790063B68C4A517D805A1EDF22357 +3607C6E7EB571F13B61F294A3ADA65B6551A35163B2B09FF48204DA33C39228B90EBC2C42066D4 +3CF90E8152C9640F72314C415855B1A20C46F0CB69D91E690FC601A430F1605E710D1B6DE24B4C +BF183DAABCD4EB1F9A064B1C0EE66CF8583EDB4B929623BA1D0DAA518DDF244B33101930182E96 +620CF26D9FFD672FF7CE2E7A1E6C1FD5E263175D4383A9824006E3A24EF54BEA370BF09C4467D9 +9C7DA12786EAF43DBF0FEC582315890C8DF0BDFDFE60E50EB05D7D9CBB57E5AD8B680AACF1E600 +AC70ADAA467EB9FE4CE9FB15AB3B1733D1668D5DE1195E02810780D977F72CB8A249CB6060F756 +5B09D6D6205AD0F63566C56DAC006CD80A67FC4B522BFD5F0AB88EC6E46715B95074F7AD5EA332 +347F5F288DD1955B11674F46BB0FFBD3AEEB0B89926FFFF951D3A1F29633B3270863D3AE368974 +77BA28AD8245374F09B2F75D7930AA74118400C96AEC68A49F69F8402201BE29D5ED5009FBE347 +0D5B1F37C59383294CEC3BA4FFFCA5EEA6471E41F1CFD3B366719228263E4194CB7D91F729CEC4 +134414C18719D5F66A90707F0B8763C23C369EA27F3475F4E5BC18DF91713338EDC64E37398107 +E858D2FA86B34319F630175CC0EA0C0A69AFB950B6A44DC453725391EC4E2BE1D94EC660A728CA +3C9E9154DE885AE99B2255A8E503617C494ABED9974699A39F0AC8204C67D25B377F44A083CB75 +B36181284C75D1E43D457E1FABF44587267FEB0335D5951411A54EB0D3C95E0C8E5B99BE2023D9 +56D3AA605760175DB8BEB96AB13B5719B9DB208D676FAD5B7268AE7BBF16BD6D446B4C0049C363 +E40436A562786CB908194A7B8779B8E643C4EDD8F7B04B38D7CBDD011CB962A9E96297567A9F3A +82FAA696F6BDD100E5D74824BF84B16DD619CE7C9EC8C835EEE6DB5CD3CB8C41F39BC18E8DD7CF +94B139222930B39F9E1BA15981DE9F82D4C7797513FAC518C1D4F2EA30E803E0E3B665E21E073D +275A173CC2615DF9A69DA5CCFA720CD300486F03E34DA79856DF7716584940DD3F786BBA10B315 +3AA3D81C17CB2B5964A5259E9B739AD177532F8C1160E44666E4D0C3C3DCBB6A873B9797CF0239 +35459FFCFA6C463605A8A77C74AA9AE3E5A989FF03E7C55776696D21F11E801CB1AFD551234152 +EAC591D789E70FBD147C908ED8DA319A41F9714A7F1FC023F112CEDF88B4EEAE8794CADE8A1AAB +68D9EDF19082C4F7DA38865C3B905783BC9CAAB7E16CB1F5EFDA2F6AE513CC50544160687A6C82 +1B54E5F897DF81EA0004B763D02FDE7FC4ADA768CC7F2830C7D7BF5C446B15804E7777CAEA78FB +9F14D3B95A6EB62B4A310CE75725D1372DFE08BDFD7AA8FA58D36DB1D2C33DBD632BD5D0056135 +53E846815D995AEA6D8422ED35EE328231F57ED0A5BA065E1296FB513CC584A0205DC34C2D1ACC +580041F4806B3B7E163BF3CAF9C9102AED1DBF23017F6EE5F14A486977BF8E4801BF9BED1992D5 +4001E7D6015454F9A7D3A39424E1D16D1D0456CBE4EC4B28C019A0CF581089C068C796FEFF4768 +0C7306A4E0905D91BFE9C874786574164C09374FFF473212CD28F7549C85F742F6EDFD34A3EC96 +7311092F305CCDB9439101F9DE2341A0A341C19EB86718FC837473C31DE015530BE489A3DE1719 +6AD8D52BEC8207DC2C52AD1B6DA14E2E5E55E18E588182C49377F4F83FB1B878351B25B1B480D1 +369E69DD6F5FF1079170D185B3E9D104AD4EA0D325B03274C53AC0FF5C499CC106BDADFA07EC3A +5279475AC5F1807A2AEF64FA1C8ED95D8D865502337CE250177B18940C49310A81AFFEA7290A53 +8CE2806DB563CB130EC43166E6262F40BAC7A10C3176B0F5CF263491B90C3D9E16F1451063A0FC +28C4CF2F5B879583F4E7F28CF7BCCB3C24A12064037F04EA84F2A99D37EE787B023973EED0A62F +7791A1EC592A009512F93F5C798398AADE97B26CBA03C04C4324FCE97EB5789C3FAFB6BBB4AEEB +E241CF464AB0B78502DBCBFD29986A2BEDAC0F44AD4CDB15B1143DBC7FFEFF6C57914328176489 +5B315178BD0EAB310FE4D364D31B424ABE7F5192B89C1D1E92D27AC1E749A5D7FB1788552F5662 +08731B8A6766C0EC3B06740BF336BD314F8CD0A29E77F9368A088A99ABD60B880AFDA377E9C1D8 +CD4BE7E77010BF09396858526C49540AF6AD87112D07A83330703CCBE88869287262F1DB69F17A +E09BC16BCB22A5A7AE2F979956498E74A754B94971FF67645808FF9189E89019B8EEF8D48BE24C +98A031AA823115B638F5014FE507198CEA3CAC92D8A237BB0E49F2C02689E9E776E16F21A1139B +AB3311433B6373BF536E30A5959410D66823DE25B870E3C8568E0F95995DDA5D76D3817728D9CC +C39E53869EE7F5A0D4D662389CBCDE890600A581451DA0A37427237AAD1D77E0EA543A00B8379A +55F55AB79E5A1D44ED010C6847A3A657AF68A894E4E3AA45B88EF00A82B7ECF590BAABC2371B0D +5320001C3D1FA425F6F57B13C7EC69B64AB4B21F8C00E3D63DEC8C56713ACA560A0A349A1BF0FD +A614CDFE65E935B40F502B7D914BBDB4A77F5A4AAE5A2CFFEB26D5A58E3E50FDAA8D34811CEB61 +CF811D37C92A53CF493A7D6157CB48AA26367FAE934BB478ABE1EA432CB77F2411E7DEA7F65540 +B904CED9DB4BFA3ED733505DCF97D1971A66317E516F7F04EA905325C263EBB7BD8513B73D74B9 +220FB92616250EDE3F72169BCD8304FD8BC3A27B7C103E0045F769DB56A418AE8880AD56BC9E9C +DC833AE39C55A3C2948CA60384171CF9C207EE9BA9CE27BDFE3471C65DE1D617C6407133346AA2 +C25A88F42C08E72B12A32A2061800D825C31CD595D92FB6DB14FF28B309F1D317DBB1AFDE68221 +D98262E4A264F5A35570F40368D638BA8FAE9871F39782A6B46D8F3545186DDB8277A7C7EFB96D +5F09EA49652C129B4C54B872D8A409BDB611ABE271DF3300A7F3E8C8E161017FD0188580C954F8 +C4CC674E22FEB88CF5E0ABD19A284A0D9D91F2EC95F9A93F1D35FCA8D00BCAD8C6612E92C358DF +A868DA9C5DBFD73B01D11C38CA5F131564872BDC60F819BC5BFD15FD8E75AB533DAC3548B8266F +8D1D596DE55166BA58B3003A07182C7C0F69D4B1F298233262F2E7AF2B24A3CCFB725BDE5A5E48 +D7E9565970651803930E70E4189529CD573697A81C0B0A61ECDCF942F3339FDE20D1DDC8086202 +D1D3609AD6603E3690A79A285E1692353124196549C913077D3F8C6646975591A42AF8B5DDEE53 +78238DFB9624F44365ADDEAD9ED557CF4D8CAC26BFDDD772CEB98C5B366AFB2140959055EEE647 +90206F72E58E161E8773F8FF59582AB55B1B3E638399539F630E11780E5352ED6EE9737876FCC1 +763241305257C279854203A088F4782C30C6EAA125C8A6FC26212C535E66789980970DC0803E50 +6671FE3E96928BA55FE297368079A35A67B7FE13C8DC465C360E22A406DDF868FF4FFA3CFA6955 +0AD36656CC1CD19A1A1836FECE37B79F458DB40D42DE82D4E5ADA8BBB910EA51154948346FFFC2 +46EB10EF2660EDA4BFFFFFE6FF201D5A3CDD09528066C739255F4C23D39389E59FEC4407021D2E +0A870C6C627C32DAD68511ED8C91C05BD746BAA819D9900AD5102EFE6360858FBCD2F9A71FFFCE +AEC72FD18B5767336D08446AE9D69486C9C593CEDB8A91EB0804DD709C757DEAE3F9E6D6248AC8 +F8CC65E617965AF69FE99CCBA7189B288FCD4C1CE3DE8EEA0776D38B8A2B8F01679C2270356046 +C9310723589B7F396E9FB18C628EE7A83AE57F6D1817C1D94FD3EC6C45CD6728C82EA72E2CEED8 +2F0857A6143CCC6EAAE0B443EC7D274D7974B895948F6483C58F0F33FBD311D498E0A029012249 +8DFC0A644CDDC892B8CF603F7A6D39F7B650EF99E0C0F7D1611227BC3BC8BDCADED093902193EF +A008E6C5E52E032914165156CD97FBFA0B423447A8BF6CE288047D77F0B7A9E4932F89F6560C47 +B02738DF984BB26E0548423BAC15FD9FEF5B46CB5B396A3472CCC0D61B334B7DEB439892BF377D +BE2435787D0145F410E19640224A3DBF881521D31888AC1A4FA69A5E90852811B13596B546F159 +340A0F66E06251A095204556D8175A10A57EF634A6152B036F9EBF2F3639DFDE53C3CBB14CA209 +EA4BDA72BB143299E5EEDE1B535D45F07B24495918E7C71879E2F03467AA3D19C0D63F61A6252B +724EBD3EC0E343BB4F627B02914972D07DE8298CD128FD99A1D484BB1B5CA373F4E2491D24BAFC +320DA213FD2DA7F2B09DB190CDD2F30BDA955E44096617E5AD294DD32E35CB60CFA20615DB6337 +C23D83054F5E6F595FD907D150272AE09C66216DFB4F743E3B2E62B7D53B5E8E7667B289A00CE7 +B96B0B53244F3D124FF980C0BA68306C01FE4A8F282EF4C8D6568A53D90F3B05EB14E26BF96777 +50BF259A58735E2AABF4F003380CB8CB8EE541507C36BE19B2C46A2A2657FBD11BEB0A30BFA051 +2A6D3C9F8E26FF2C72BBD173EF0F04C8DB3DC608336C84829D5D54571A90F1B7728E0AA3108802 +C8992B6987B27FAE219EA24AF3F178DBBC7B455C9B59402B4BF3B265929C02D95B8BB3BFDFF9A0 +9639B4E1CD845B1340915489A7AA9AA19AD6822CD437E52033499D9CE1BE3A351811661CC140A8 +66E9BD299727F14813431B7DE87A015E84298EDACEB0BF034A9BFA2CDA13EEF9970FE8BD269246 +7BBA1FD66B349217DAB37501E98D330623D2E7BFFCB076ECCAA19D835074DBB07C6395F6930C5B +67077B26210227DD697D0B6F46FC88C182BEA5C5A4BFBE33D772AB706215308854A30AD2D065C7 +708A4AE333C65CE0BC2B0F22F0B60EA61197BBA3AF236D9E1FBF21DB6BEAD9AE94C3B28A3DA552 +09827CC8752A7BA6763EF1A943AAA5E60726B4015CF14D16F1352D433C5F4AE74D2D2B31204F05 +06966383AAF38A5CF0E5ECBD1B792BD1073B25A8CC4D0D2E1650AB4E931D89A2A619F860BC7244 +1DDB888F0324BB646DCCCE2D491F5FA75E598CF2651B0323187F3A8DB5A8BB4BD59367871B76F4 +ACBAB3D7153CD215540799F29EC08139EB9918AF0FF098ABF8554A9035A16442A5C202389076DC +D6E23751A85FD1B3F3AEA19E043B8A3EEB75C40C70EF918FA4102973E0E8615959F28807C3D20C +DB9E972E392745BC632B451FEA1FE04A410C8077B035AFA74F1B701FD91753B0D01BB3DE1AFE1B +E79802710DAB4DCE481870EE559F8C677D4C978D20CAF4474804F1F053812E67CACB662427B560 +458532D532C202E4942221A492EB14885148C43B62F8A0D19EF45490FF38CCAD1FA02C378EC0AC +44600B2CB28B244C787150A468BA7FA4986BC2E3A93A18531243E0B836988DD2C196AD291A305D +D91F3B4DA47CA75BD05FF0513FE10F844072E60AC651AEB7BC78DF6FC3A5E8E37584B0E45B457C +046557A3B3586442803328D2BE2C286456F34F8DFC1D1478377DA6847CF53C1ACA05AD72999E77 +C0FC0A262120BEA3FA83AC099756309B444596C26486208726CBE32558991EF39838798463BA21 +1345B85FD8FDA2A2FE834C488DDE8F8264A5E86246DB3AAB30B75B8C51A71EA729DAEF0F03FBF5 +B020AD02E09D43803126C34C11CFF1A69F2AE2DF39274ECAEC92C868989335190E6E2C245925D7 +1F45B1A4593578338BBFA6A2E2CAD3CE8AE00E97F5039B430DD9EC8A77404BC1231589F7FD32CE +3AFD2D0238085FF6FEFE450C9A2014463C41F4D3312DD98FF27A039BC894AC993961F81ED116B6 +5CA0BB449011527101A0D1168CB8CCCA699231C96ADF616582C557E4ADE73B0377F825C9AB0BB3 +C789F46535E0A3843A9955F292DC9A3E046E3990A558004478B12A2ADE2A95626FAC0F60DEA236 +0C0BB784F5073DE5185CD81565FBFF1189F47DCA5B947C59CA154C13F38260D51C47989D1C60DA +57D3ED1C8BD10A54D0D646F901D9B2E4A08D0477BB3B06E99C4CC3BEE8AD49CBFCD70FCA133F71 +0F8C2E8AD72191B672A37EC62BB27BC5905C70EEB185D4E801028764F2B3FCFA28321264950971 +37FDD160FC2F91B01A55F41CE24DCF84FFCA957D272FF4B8CCD8DAFC196816F258F12000975EEA +8284FE1C9894B140C717B9892B2F1FB1F9A63F27342363A34E280F42FC7517070062F3B45FD468 +4836E9B48C7BD721105B0D8D2FE65C759E47AF34C2D99EFA576DBC7B390597ED274AE0AFE364C7 +66B24E9C267AB0E6AF79E29D9A61A1141440FFEF47FAC973E1277122833B65CCD0C1669E8E0943 +CA94CDF9879F5B3540D9DA03B314274B338EECB14D93F6B229ED1BF061E0E662601F4BB44EC49D +58CFE25CF826B28F9885B8DC6C171F5D9F886E28BCB68291B0A00BBF8AE9A10F5B137AED55165B +CD3044786C0464EEAD2641B5B416ACE8B4D15B48E12D509D42188E3F3143E56AB28C85A3C312ED +F114B8931C57E66CCCED4CAB926F6CE5AE543CE2858C16AD0ABBEF49C66614255285549465F618 +12207C1DE430353F9C84D69D0D8AD5DD6594CF1770DBE352E41F5E12793A51CC70F386133B0EE8 +F96E4249F7DE76AE85233938BA8DFD4E8006F53FAFECF02DD407816873A76CD4EC41B175170ABD +70951C54647063553EB4E5EB14C900DBD377D2413575C50381317CA959747CE3E354768728484D +7B9AAC935EA5B17616DB1F80CC1D1DFDC1DAA780384B3475A816F4CDC3E92F307FD5373BFF893F +AF1E294259719699A387068094F8DEA44146EFEF7E079A131D9727347F351AF955CC435C07AD95 +49B8B1D75D19C5C465753BB77355FCA71406B77A6AF3204AFF93B4CD3E34E90A88DAC6D9A9A453 +37BC6AE499E07CEB31D14798FF0F55E2D8FC111B7D095554E7751BF71C3D4A7C33199C3E320246 +04B645D1D7029ABF2FC1801D4314E01D1C209A4F1ADB0FA96FE882B7416FA41AACC9EFA6879E53 +971A639D90B2AD319D259507E73A536575CE9251AAB41BF174395A5657E83FBC9D7003889561EB +AF9AC04CF2BF8E7310B7E6659812D19248CF6991DEB4C2A396AE00E725DEA00528CE08FD8D1D59 +5D1DD69D556F4584D50A80D51FCA123E8A35E13E5BD9EE977E09A692D821832B4ABDF01DA3ADEE +6AFCB27D3A7799711E3442FB8F83AC27FBD12BB7345D71F1F9712DA9DF2111FC10CFFCE8770699 +55011A4D38355B005B531AD274A09EEBFB8CD6A1F964A4DB7907B1781E52C42514D7858AD21CE9 +E6D97817432229CBC8CDDD5F0917F3FD35F9E62EDE71102A96CCEA949CDD94C1ACD847241C4FCE +BFFE7FF6028FFBC05E999F1C1C002FF395502643782D78543ADE03568B73A269266556CB545B7A +8D4177A782264B71BCC4B6B605C75B62ACFD6485D2E5D07A7FF53BF84A28FE086ADCE032D12729 +03D7C9901FF0E71C2E2411F6157A4CDDC9260E47A768CE48F099D4DB84868741913274F219DAA8 +068E82298242261D9BC0F4515298CA81FDD19215E5380EB4F46B1ADDD33BC8520361121C624BE4 +FFF8339DAE4776EA251776F6AB33AB8FDE785B6A94DBA8C960F95136308D09B4BA32D25F3A8CCB +2BE5AE8B4468A302435F4DD30EE92D165D12A463CF5BDADF434804CBF1686D4F5433D01E50F60C +DB832DB19E52CAAFC73DFD28510228646F610869C0CEC899C497B272D470F4B8B7710AD23E8059 +8BE10019858015F16FFC232CE4D5336370DF76EBBDA878CF686E3331D814EC72CDD40C5BCDEBEC +AF33C40081A4C27B1B21522F4BB7A92A674C5456EABC8D90827D747012F268C84C16E7AB4401AD +4E7F96FB64E0C83631A44723C9F35278174A56DE96322E152B3FE95658D11EF4C0BE5C0BCC1349 +0293310B10B0C8CCFA2479D50439A8B40F5CA0955A2D30E9327364080A83A1896B1A062793A557 +2DF318BEDDA17F3E662C0D4B41D8C348C1F2CCDE37392D715C4BC89BB5F9DD323E6AC6C3EAE658 +0B61EC042A91C45C6D72250CA6CB87B660389672933ED446B7D80D88E1A0BCC9D618C67B26D8A0 +12FB02C68FA7E4FC9FC91A22926C2D8F48F2371709E8151C31F5F4D40C6E75280FF9428F13D559 +DB7D37F75456E9B53B271BA496EE76A1AFF092390E5B896145C1ECFE3D39359634F9B942BE156E +9951FEC9D81A290469961303EF4ECFC1C050540A5FC778D18BFAB6FF326814CB256DD315F9C224 +8466F67E996E67DE3B772A4BD0238BC5C532F387B5F2A8546E6703B35E86D59716972B0C0883A0 +9C37410CE21704956BF6F5BFD93355B079C6405DACF179254BC08E415D0ED560CF9D7D786A4149 +DDD69FF12EFF44F4628D39830AABB8E951C9D6F2D80EA8EBE498CFA76E47BF82C76246A337346D +005EE988C82DBB8D1FD4729E2234A549666FF469D15349402B322A205E69CFB65A2C93E5C51B7D +D45F2E488DDBF1AC7BBA4484E0013A456DB8568BC8C48F8DB292055062FD73D01C47D5A48A0B6D +EAA5485F2D3717899AA9A7C861247DE19E3EF236506A76A7CF6A03335FD453DA1A319E209E71AB +A95C7727805EF257093573A1F963ECCDD8D5EB00CA24F323A74703EEA66668B38E76DC53A00542 +C61C737EBB67552C8C0D90A04D30109F562105E03A669AA93168FABCE3F6E8F15D0F94A7DF9659 +447E45F00570C63B74449D628471A70754B8A5C3DD4B7F1257CB9C02360CA1118EF42445B81A77 +8E671CF4B94BF5EC261A34A7EA7BD65B80D149F68CE50320DBC63E45BAD02BBF09C28D50A021E6 +0859FC9BFB6ABB71F874C39547291060CA4AD86BA98D6F106C945924EB226B0604E65D41C70921 +8822B9BF062BB0795E8CA290DDAA2FFE6ABE37D13995731F008F06CDF4654AE43F6D0F180E9430 +2FF7F71349F12D0E6C5D7BB8981A94930A6C1CF5799F5B3A64486A1B279E5DFEF99FB82CED12F1 +9C5B9A80CDE6D8AC2AABCAA1D2FDDC03455E69EDBCA45654321A7CEE805D3555A6870CD69DFAFE +8DC3DFFB20FD9DEF9EC095BBDF1894543A2EED30B416083E0C976F099569B95722D48ECD95258D +6FDFED1E14427F44A56F25B974FCB4D47F5749564EFEC60A783695924CD5E6569339F6E43C6696 +00A478AD5ACFEDA6E60835F19274BFE1E9085AE42DDBC2CEE9B856BBDEA49C0BBD66A400509D22 +B75C8AC63FFC5D82758FD22D9CBBFAAC44FB258BC893977E823D00F3837172AF051B69FFB4B427 +3911ADEBEA9D520F234BA4D8FC3E3C363238CD744402D096FA5078681AC3CAD245F9FFB510EC68 +13DCE93C66BF83C0AE307ABF446F4E1091745F57C941544336DD8F59749E832B5437C3AB8994B0 +82914781AF7EA09208D7F1BD45DD6D21FDBF11031AF0CAF929C39DB34BCB05144821082D1471E9 +E6526937C7F78DA1113ED907D7C0C03A6EB8D72BC0BD292EA13B0C92295FAD404DDE1212DBB454 +C3BE0EA56E5270B6E5FB81918AFA8D8574582D3464869C07188211730888ED6F5405BE928A9928 +E851A4CF29DBF352F3D257525B708FA7A1303B55A532E4C1258A5F6A0D12995802529CBD6E65AA +AA602E4220815A5AB18673FFA922789D35943DE4157F63142B3CBD2C8FC0E0CE664AAE02BE5A93 +C97CEE6FA6F8F6AB841857B3887FA143F6B9610B2F3AFD3740F3E0B442B5AC065AF833C29F01E2 +29FC382804E896DED6E0F676CD666F8787DD406DB5C69C9A2847E18BCE2FD27A138AA93379CE8C +37891058DC1C5515CA5F23380D3530050EE56F6B9732E4A0185B4D8FEDFB1E7460AA13771EF4DF +05D74602200CC84DFF2A103D3748D6198756F4749B74AA32B2F30F700D1F08E71E1645BF2C9A4F +544544E13F1439825969ACC1A6DC057348702E1CFD18DC3B697B28B042E39CB7B09C80E70707F2 +13C636A75753EBF406B599010D028940E9312B75BFEEC39C0030BD18333404479447210F91684D +BE2105B852064B685C3C6028C7178FC5CA73C17F0954C93F6B2C4B2191175D4CDDFEDF41FC4048 +0F0C8B8B369A27F550AC1D353FA11B318DEEBB01B4B8FC7AA6F06828968E1FE4F9B5B96F9D3017 +1866B8D14485287A60037526E721739C7CD0C17F6F64FD99EE76623F71C48C0A982E50CAE84DE3 +D25F5F1AABBC058FFA718AF92327E4FEBF106F744C170EAB07749FFB69633FD98E480CB281AA03 +93E6DE2159DD6B99C790167E538CD79D6155775604F644D040E43869DB91A4D00875EA13440FC3 +902AD40066380C2F83443B0499206BE189DDA2076DF315B58D6BCC0C89D42A699225676A47144B +04DF1BA596017F3A2E2EC3D513CDD2A9F184070CCE94C96F7BF6CFF00D922748BFC1C8597C7668 +F116989E7F08CA14585BF06880EF1A073FB8A77075074957BC126EE2BD330BB4C569A23009D01C +A08D0F691A6BCE9C4B5A50AE33A8D7C8948FBE555D9A0BD39BF49EA21811C515CD384361D5A0DC +611DBD505058A43122D8D9647FE84DC4DDC8BFFA1E31D3FEBA54276784D9B36CA7614B9938700F +59C39289B78213122F7B4602CB59013CB72E028C3D297E574A6B43A0C68BE116BDA1276BACC516 +73FAE3818E011213F0F87AB6DB1888140BBEC4F1119C00E4A62288F0F5E23B6058099F3F65FE3B +3E074385ECBE56E5DA88FE13C1EC3E7FDF22E775C7E1FD0CBC4B7FE931B7395A2E9350B69C484C +389628F1A7A85CF10B665734B60C4A945FC79388EA356FE1A03C9FB016DE980B8BC3B9BB8BAF80 +16FEFCBBC66690E1356BB97AFF51F98CEA4837A418557E5FC1619D069FC59A4A4C3EC08714D00A +8F1AA53F8B59C403C123A8C04EE38025DB14CB7CF964A4DB792E25A9E8FB5743817EF7F9000B3F +EADF7726EAFCB71940D2A9FDDAA02AA62D8B13EE70FCAC1358A34591AC3CCD3F163B4DA0EACE30 +0467E63CF26F6BCEA3EB934AC6775DE665AED32C8119293CBA154DAED637633C0253D4E001CC2F +699E318C5D2413FB8468B43EF418EA0C6C2314AEFD5E429F3BEDDDD122DE559D0725A44B31A749 +0F653D9A9233117B76237DE8B27E4C1886423A04F999792ACCCCA4BA4CD7BF35C785FA07D65672 +223E0C8661CE11EC0FBD391AA4B990CD353CAF98135827FBEBD98BBA4D618CC0BFE026589EAEAE +55DAF78E0597BC770A36751261192555BE810C82F6A736BA2AE6D3D8043B761826D440F795280B +03AAC4CEB41DB919A67C2AC68947B39B70D9C4918CC8512FC2F7C663190A81E33335A5A6196E95 +39A276D49FB75DD408570144DEACEC7153917E6494A56A1D8E8B3A2D06D997A9AF15575E4F50E1 +FC7A1067291BF0E9C69FBE1784AABA9874712B1E37F3EEBDE499E3FC6B3B9A9F15C620ADCB559A +8F79A17C5403411C1F72CC343B1FC1A639C5B5CA0D2D0B75DAD4B0B4834D7948A1B82D2AD1C6AF +FC0664EE1E82A6445E1BDDBE61CE2E5FA89CBA747ACB305C0458C71D1C40278FD48840C3EDBD15 +DEF854810CEA55DBD03FC20A63F7D2027A6553C053E153DB79D08A447835E252216DEFC01C2262 +32C8EA4A13A477207A37180A21E6C36DBF11DB159966F862B6BEEAAC2AABC9DA188F0D10AFCE82 +588F6457AADB7C3B4DE2FC6DB3EAF91E09FB2D1C748F0584E037F1C901F532217F2BA27C4491AA +8EF780DEF8177C2E80ACEFA425508D81737A008B6D9342130799AAFB7F5BE5A4F05EEC34F93F5A +4DF2F01EC3AB9574D32AE530A6BDD9EAE39AB88FF21FA502C434730537D38AE69F747A0413E4B0 +7B6AFCABCC807FEA7088AC8C96FB6DA878C08E2A114AE417AF245C6302B705C1B7A8FAB1CC76B3 +08A71E905602C35799828ED1185048EC2B5C01465E70A996655C6AD5B9638DB6FBDF425980BB31 +642A9B57CB1675E94804F6C3D35679E3C37A020D361D6FBDACF6963689201B8EEC706CFF2D5107 +41B4BEAA7FAF600D3608CEFFB406B06887C1A1A1D08093EC3C7510D292278ABB7193DD9988BF2F +E9A6612422B8E44656EBC88D9299F9FE5DA3AD9DBE9D75A2D49E4CF8BBE6A794039E5F69931ED3 +40081841C762AB97ED85F786692038DD1B59D89EAF49920E768E7F7F1EDD29C75DB9C1D3617E75 +B1940DB46CE53264F3992A1FB5BDEB1799F5D3A695A63BA2C6D33D594C5C365683C66FBA942B2E +FD09F3F0BCA92248D5F30FC7C7189D8B01B13D4D50CA60091F590407AFEB4EC2076B5B92F0B30F +4041F2E4100EA471A066E823695F1D2233F2A6E03F8CA102E0C155334330EECEE15147827AEA8E +C014A0C08E6CA126D9CE917861CF2111B5E03DDFAA0CAC9AE2F6B2E6AE961D4377AD47041999B9 +CD86A17ECAB5315823ECC411598F37B7E756190DCC6A1FDA59FE638C1A93907E04CF90DB5C7224 +FD8719E57D5A430C429E210FD49FBD3CEC3F24D845EBF8F5A088F68E19CF7D339887AF3C298912 +26CB77855A7F2683F257407C708BBAA4C4B9DB8745270C8980BFF767BB06561B3015B9932294D9 +5DB8A1040D7BF9E3D40A63C617DAF8EE7644D5B0D6308FB171EF3E78614648A321C5FDE3AD8184 +4BB85BBD99592562D7002347ABC2638E9338F26CCF0743087FECD56D3CA82B6849BEB2ECD7D377 +CA06361AB29CF13EB1DBDC56F86BDFEB451AD6C48915FDD35A14E7A6911837AD87CA3E38199C09 +16374140E83C9AF1A8A85C56DE956FAEC1D75541F4ED3B64C99D951180E1B8F64F1F8B7B45B159 +F8F5A0D426766C68D7B072EF6974F3ADF3A5BE90B7E9A21FEDCF47E29E7414C80C845C5D93B8B1 +D9FA86B1CA0E22558DF8EBCD439EB920BAB797536C174C458B1550F2EE8D7A784521F02517F8EC +A4F71CB240FB5F9D86E4F51F9151F403B0AC8A72C0FB6842356941FC3A2370996C9642CBBBCB08 +9BA6A5CB6FB9E2BAFA06E84F0E2E549E0EE23B21821E626077FAA50F021A23D42FBF4A7C4829E7 +26708780FE7B0613923D556F039B934712658859E8E685E74141499E09EAD6FCB62B0CE175A021 +36887CC85EDA5D3B8377AD464EEBDBDA46D0ABB1446D87AE5F0A45E3A94F1C6281647A0B899954 +410DD0DE1117BA611AA431F573CC4DA9CDA2FD3AD71C37A4FFF7B8250212797DFC54B99A8A6067 +A27D70D6FE72DF3C59247CD853E07CCDBB6A74F6B228B19F5FC764222E63D09BDDAE37245516DD +37517F13E23205C8B0D0CE1AEE7612D61D962A67559E3FD96566C1BA374D07A9A462B499734332 +5C78AFA5230AB300EB23F6A225DC7C7C7233403713774A190AEF9B6E7AAB5D8B887EB7F1F8F585 +C9B3118AA1C30F80284BCE0E730E247085FF7B1CD7E0988F36BAA813C8FCD339887407D4882AB3 +74112DE05DDFA5139EDB6AE5B583E031157980C2D52169D49775FBA8B4E1D906EA4B8E10DAB35E +203CA01FA7629BB5325218A005637EB76CD3E55D11B771FA770C337E6CEEB465A8D7F1597F6551 +B2FF65FC891033FADF0389DBC588C8DFBD1DA9AFCACCE38582B167C3E36210B9AD5551E75067BC +50AD37890806683F8028D06ED899E9B198A9EFBD321A3AC3C6D9FE41B644CD37B66412E5720D14 +47A89CFE14AF540B5DE8E900E9D66C21BD6528D636F6AE5293F1C9444883F0C15C41D79EBBDC25 +4BFAF1005645A73FFE6C2F657CAAE102E0BB5E787471E929F7F8DD97C6E59659925F0C3D741BA0 +9CE501E074E78CF9333485AEF2730507157A422D843A19CA1DE2B808D5F0A22318A1B9CC5E07C5 +5CF186372472A2C737D87499294A5C5E8EA50EEB7947C833AEF8A3CD932D4A7E4B8FD99C74604A +BCA2B4AA067CA63C1CFBAF9FCD793B00F452011DF2DECB602EDE3FFB8A06FAA52489EF4EE736F0 +B8C5FB0B6B9BC8B59E9ECEEA1D22668FBC908A89EFFDE0DF6BAC4D0A7A7F038DD8EFC85F177970 +9B4DB3949C6943F9E080853762B79D5BD391C6B066BF52547320E2C8358D0C0CEE994C89CA1CA9 +F37CD219736C2C01AD74993103C4E992FEE17503A00F025A55A882DBB711112E3A247623DC65D5 +14FF7CEC646305862AFEB7BF057B1816F9CDAD7DA4A1DAA6E26682FAFD0A7D20F88F37FF51BD77 +734B1EDE7092B809A214CC1C12EC8B8434F34E0DB6C249D3553C548E2A00D71D2C4723D9E10F76 +05E66FDD97F90C26DB0864421B57313FC2A345D31829B0B25450E2CB4ABEC4FB9D1F39A2D68BCF +BF41B93F92B39E7EC6DA3912DF9BCA1686DAD2F69EDB26B37C1205A1409187C8274A50ECB0434A +D03524EFCF0BD29131EA2B6DC7115FD69D98E4D8D9C38DB3A9A5AF5605A13E627F4EAB13B08911 +B44E2E6C678004F88DA3FE2DD09C3407220DEA3DCAC845C89049D9370DD8383EF4CD3B684AC7B0 +A61B688FA132868C52A27DCF6C885EA96B5313627164D532C3C70CADA13EC5124E940C55837008 +78D64D77AF0A13F4803E2716A1C6973130AFC4954A6800461DE890AF174C3501D575C1F3A3661C +0974B3D4CDFEC08205DBFC683D6F265DFDE654C623F30BDF9CBE83262869767D243291A7BC5747 +8929BD6231701D3C493E47C54824F073C45739A179BE64EED97B01B6161840BD9DBF4E54B2BD1A +2768FD02108989F4A41D4A727100E5B9B1CCFE3891BD70A6926AA1DE689620DE6925CF29F10657 +91FEFBACA00068DA6A1AF89E0DB4C042B97517EB6AA79BDAC43EE8FEB822F8BF616BFD7123200C +BAA27C8468BB472F93DB1A012BAF9B0A4B5F826D6E2DACB093022BBAB16FA3ECA34CF711BCE815 +CFF4C2D72F49020C34EC029DDB65E0793F9ABACE04003CC7FDAEC84340964BF7010B37F05AC17D +B406FDD7975C49FB46280D6599C47C0123FB86218D242338BC54F8566CB38FD2425F70379E0123 +C9D0A53B3BC609BA0586E7BAA48C889DB4AC331FBACC669C2E14F3419C6B0F58E75FC76C405C42 +E9562D33FAF544941B0F8CF79DC26F83A14F1D8746BFBF020D4D443D22CEC07432C921187827E1 +D52C93DE2743A75320E55169F2D619B78C0A0089CA20C6832FDF1116145FD98BF771ECCD42DB59 +BD173B046FD71DDDBF9D9AFEBBAD6116B1863427EE0D81713BEB43CD0EB9166296FDEE311EB20C +013B3F7601CE6229425FBD8B28A0972A81A8D1C0484289F5561B69C2ADDDBB70F75F770DF38996 +8FE1C7D6DB3872BE6EA35EB1C7B56D4593016541D22EC5C71A635CCCF52D6A621A9122D14C37C2 +93EA5CE08E368E8292F7C98B2500229B04A5E1C96924E802A3BC0FB5E58B8F778A6E57AA8C64C2 +759E0C8B63083DF8F46FC3761FC9F984EEA18C5A932A144E58DAA18FD55F51FAAB06E1D28F2655 +09365235B5E44F1453E3B0624C6E3709641AB1C5814FAE6642D852DA32AC7B54FE8560BF3ADD3A +B3033BA8923A0884E565D1CADC4D09C8A52CBDDD039E2C83769058DD389F86F71852F10998B4E3 +A758498F4A9B79CA6C334019901CC779B9A6B005569A0E192AE2628E16A8BCBD70276E36E175CA +A41E221A3502A046B178FAACF020A1CF03188D8764730809B2D37A45FAA742D7E591BE258B4172 +6D91960670CAE77ADADEC51A672A7F7624057603FFEF82622FBFBD4E0EF4661151429E37A64B5F +4CE3C03D593AD9F504597EB6F0528F36399B33F30CC3B2F96F3733A8013041EB3A6AAF4B0A45FE +F733D1FC07D44693D6AF26F4E3A902C8F20A7AFA23A9726F334C4E6120855EB049172A34E4BD0C +93C3003AA814CF57C912C53C6254E3B37F494C99AFAEF3ED92ED9D1A3826C812C315F5D1C78641 +1EA2CD5ED850E596EC26CD63CF6AD87D0A43B9F44E0A297180416C2B551D6DB874E7E11E0D23AF +306F045C7F67B6F54AA8A588084EC5FC95BEC9E4591231BE11A52E398B863C32B7256475C6EBCB +5F2313D750C7742E3E838C62DE54311278BBCCCD5116DD957EB97D34D6452700C1847581DC82AF +67E3288DAE3B6F16E9DC35799C1C85F9A568DCFB9839960C8D28F11261375C4A19B4DF0B2DE321 +AEF39EEFE81A28147876D457931A141E1E6FB18DE81582DE371EB7304AC7BFCD7E116E7277DC4B +041A8E304CD6AFC986E037D112DEE3B26D0B353D8011FA8B0E9B048CB382D6C4C7BB82AC2E0EC2 +FB6C4D904FB9E6D3A9FB83F88605DAB42E02C7982B894B945787E8C61E3A256F42D36B2632DFB7 +CD62BB7EFD676D42A155F0FB6475B51008729CCF23957B468946D4286272C7510DB2D0645EE78B +AF3F051730DDB1F7D56092BEC76E82B76D201A470D3946BE6AD863533526D66DAE5914DEC93438 +77BFDB7C2F01D9886354059CB8EFE4270058D3A06146B213C36D1B342D457DB8673BFFAC4315BC +CEE9ABCC370920E95F8637B83480D8C978C093CE085EA1B4E01CE104C94AC744BC0E69671AB889 +CDE75E6CD976FD2D0FA70C306B6D36C4511E70AEA5B6655512372FD55C016432A3CD9417D97D0A +4C228BE55911C32419A0FE5F16EC9A6071AAAE1D851F74AE0710056014BF9630039F6637EEF891 +99BF3CF081C955795B4467EAE95019BAC7EF36FA79D9F97F3D33DF2251F44B99D13DCB7D832378 +24E4BE48A308529C6BC428B12CF69A6127EFC21121444DCC37F9A7A3F2730F02D8D3FE9581CA2B +88BE913CF948A95152A64566A881389A059E5BEE75841870787C4720DC6FAD43F12F853EEC7A65 +FE5ED736DF222CE1E386B806BEA91AF7F7F72EEC0EFDF895471D76057854AA61255D6E2EA52813 +62153D6F589FA2FBD0376DF21968B0FA750B30D65EDCA7FC2D85702361C4CAF1CD043E48485C45 +1534C56AA12BCDE172F23F6738D165A320CDF987B827BC566FB90EDD853C6D7C567C095AA5DA9D +379415125D7C67919EF3B8D982A1469169016064F637708A327E68EF2C5AF23BFE04C1AB598DF0 +85BC3CB55A0646850932FA352A9E8AE66017D9837AF4129339680A1E55C160E4A049F31FCC2A25 +76C7EB46248B94CE3519BAC922CF46F1E1E9A7B8A75F47AAE73EBF0A994CF247A0D08E65AB321A +059CB4EE443F720EE5BB46A1271305FF9884F5EC3E63DFE059B32849E88FB974A4A091DBB853D9 +B39DBC19E523D69925A419E891E8AEA1476B14BCC1BA4AE031263CB83BEEF7C7060362BC08D82A +6415FD9958CF428D4C43961DBEBAD1FB7D77663700DC73B80F6692E862A5FA8E5B31C028B6C7C8 +A7C11B3B1B0A79787ADABD6D1E37306118CA3505DC3C07372641E721DA4C5460A82CC6CA846FA5 +49CE1054C7C096FCE1AE70765DDDA2679F035226A0321F422FF944689BB614169B7E41FA56AB25 +E1CBD33DD1612E53D4484F49526800E2FF17233E262E3BCEE284CF7451B81F07037C7B9D724EB6 +40D32F49D2CF36A63E8F41D967BE05EE2B1A96B0C1CA58ACC971CBA30074970DEEBC91B0D66ACF +6DF605332DD97B1BE3CB54B7A8EECB390FBE859084BCD1A458ACEB0042C778FED53D5EAB466A28 +10EAB53A25E40F97B0550FEB048F83E8CA232DCE97FE280E98F43867A62D7F9EB5DA265435C783 +2BDB173271FA2AE0A3863D03AE13F0CF54B7DF774767F87D1BAA65CEE822C038A6F91AB256CB68 +23B9C505D77EE082844FD8C7072CA789737FE8D6F4D6621CED1DEC6C9756F1195DCCF09244FB8E +87BE0077EA745DA363F398328CD3B22EC1EAE10BD08E5FCEEED39B7E0B86305628FAC28A050C75 +A6F17864E16BE855C2E4A1998B83AB94AE09FA37B69FE6673F4D1D241ED9ABE53FFA2175777364 +7B5F07FF8CE2BC3121EA092FCE04072647C5645C1937B7EFE57CC1D6C2652F8EE4F5F7788A7243 +AC033876ECAFD7C5DB01D09F00830661A8F01C0FFB7CEDF7C23E620A78733A50028CAD88D33DF1 +58CE6A1F833C2AE7E57C875CF29304DD96DADBFE1DC590FE866C066EA6EF0C78F7FBE8229200E4 +8A0E6FD4AC0A81623255CCE187ADB8AEEA7C1D791EC5901ACF30074FBF6C97AECB19BCE7CD96A2 +58C901D1FFC4A79446EF7BE7A9080AEEFB054372C30F3555D3654D5CC2DE0BFA214B00A5764B9D +69B0F02B420647C0C61CAED3755896D4A9E872CD95D0FE6DF1D3799626E818B802435C6AF74308 +5F0AC41AE3618C4D345C509E9E689C8934EDA9F76A17F8F056ADD5367884E14AA984C28FEF4F5D +4D9776E0133A4A550F7964F43E2C9E8AF8B54C9F81FC7818A6C80B2C3319690A5CD785D00320C5 +8FC00E762F2A1D8102F8EB7A3EA692928900CEBF2764907E75CCA0F1500C546D931B9ECC96A53E +CA6FA69EBAEF1F09EC6F4FD6C16B34243F5639C9F9DA5C4E2851D7A21E76FCB35F5D2E8EBA7CA7 +AB688C96F27D782C335BBB3DCF7CF8EEB322FE5692CF2EBC2E363F12ACCF9F7A513BBBB024FF94 +788BAF7086ECEFFDAEA528D8168D8BD43E428D4BD7A0E5F9414C116BD6E42D257882EB8634CBC6 +D11B5AEA305DD6C628387C6E489B9A871CED2085903463470A10E8B85433BB7865B7B9B955ED04 +60691CCF814A0BA81F6C20C2B19877E4F37C406744BA5FEAD343EDC4B42BC0040B8FDEA21BDCF3 +047030A1E62365FBEBB3E0C419DB4DB280BEC3CBBDE80DAE0088D1AA03DD1A8A3313FC744EBEEF +1E993482AADE395EB6024A67BC90A4DD121D8D2A82BC9B50B817843CBBC79A2810FDE2A148BDDC +183C9B8391CD0FD80817E39F299028420A09939D41C1351C2562E20A45BF8392ADB750A1AA3245 +24D61999129D827D4C28BDCBF3A9DF6207BF8C33337B19F886B9326AB723071652AAC0CCD5FD1F +2D47062848BC1AEF1032B35F8F20AF5739BE6B0F7A612559A36CA3814F4807CF62B65FD6DCF1F0 +26F31D2523B523DA3A55270EDA57C727C69EC945911028F9F6E56234B3A400FDF92C80C1D42211 +F661DEC84271C010E2450B08500534530BB6CFBECDC8FEA688C2CCEFB0FCD77744CF4E0719FBC5 +CED407B114EB2F51E266F5BB9766F831ADEBDC8485C4B519ED77A1BC98BB56BBE0E5940D3BD1D2 +46ECAFD652DE1BA803D2798645CEBA92D6E6E123852D27BBD75F9946CC17E2DB56008231D07BEE +887EF18AC9F99EEFCF1B2BFAE8F99987B61451AD50DDD548DED93CE69161A2E67435E9BA5EDB8C +2EEA6088D4F71FACE28CA3B27628C3EAA0C59A1049EF61DDCF048F587F725082F557953FE0B804 +8B7B38A196A66A975557F6F5749B52474DB4AC594AEF8181876EB84277E2699F637DB5AA2F5B46 +20CC1037D83881D63D7E8DD3430C307E4646466F94E529BCB54EE9A7F8A795DD789683615CB182 +623D16D1F80257B9FC1759C798CD3917648F992A34BC685B3F6798D398E762E0E0F3F86B6933B0 +D7AF1ADC561B621BA00828F89E21335B079738ACCAB8D88AE5C406AE9CB920708F41110E6D7ED4 +315330E6FDFCBFEBB541CE32E5F93C5FF1396BDF250232E9893CEB5F87F5E4165A9FE1AD8D71C0 +7C23B65B875A7331F59340874222B9F3085B25E4F00F11154AAAC24562B2BFA901B960426A4E6C +E481ED163C9AB39E6426C4CCE2B20E8C72B1C108C405977D45C460115FF4EC599C9BBE75F8BF4F +0D186A2FE9309D9F50768E829531C40BB63297C382B19DBCE41D5E5E91F4B58D98990291D9CFF1 +EFCCC6F8B1F8CEDC8076825B673121609812A297D6B9564B4048C8A899631D351A438621003BF8 +AEA0B738AE619E99C0531D175EBCAE621B836CD9C593358E03CBA68498B05BA0B56F233F59DC52 +0699C21985E63F5A4A3F77CB74A2AE1946AC5C78DAC2AB7728EAC7B5CF10A97755059B1EAD6640 +91C8ED90AB4EE76F827F1AE1EF1DD9A50396C1832FDC24754A976878A49F6E87AE9B2195F82BDD +DB8D035BC0343CA13815B3A4A6DFE42D6F59C07E017F8CF207711397897435E3C5B914AC719210 +FA8D12A2909E11FFF50A2C47299916A49D4E180F5BCA51F0F3EA76E549A04A1A117279FDA57CA0 +6A069A4578525471537268F263E8A150D14C266383B94E61972B189525D99A9BA9D65E4F0EED37 +88C2DA2B5D476FE2A70EACB7CAA301BABCCEBD031B12A8AF178D371232AD0A47DB8972E7722BDF +BA44356EB7C5D7B6EAB76305BE2267F4F8F7F3579F8CEFB2919FCB14FE218197B6C2997BEF23DF +8FBB588F2DCF0F2D3AE1F057FC2049FD732C238981F5FBD1B057B49A4C0092BC958780EE01BEE2 +A4F42B0486935409EAB9E8E1C0E8D7D46D834A09E191FEDBA815094F745B87F2BAAEAB278B0FD7 +C68A95363FAA80A24BD3CD02979B6C0A168A7C056370020D4E70721FD0309D6405D1E61FB307B1 +5C54FF8139EAE59C2A1BA1D893A7D26609296369763BA51577B5C9A7497A7DAE54E939C289E4D0 +C925B456EA7A08DE43D89BA5AD3E5E629637AAA91BDE15D982A3FF9971C6EDCC8568B3A262DB7A +B3BD950E4C9A372D2995B7EF38DF40246F2EF7366A8DD25074BB52FAD66589E892DC53B0F76D94 +E54381D0D5ACE114E8B1114E1233419C688B207F2982633960DF741AC2D97B9CBE1C492F2F7A70 +EA70968F75DC7C49F3F17864ACD90177CA8E0E1F02BA7EEDA27271F2ADBCD7F8C980CAC6ABA671 +8E3BAC6016FB2BDB2D44A81A0967386BF9E6212797B0F2F9A9B2B4A2015DE47D4722289E5632FC +3BDCE60F5F1AF5D1033BAFA4366FA938B1DC63A799190319CF16236EEAA454585C3D22DA9E28CA +C0174C9C878075F29692C9865C54726316A0016E148F37210E1C90BFDE8FF6A6AE696529B3039A +1BA3C28179C198035CE42A1F794B290814BC98EE2F46A39750DDD65C873F25D173ACDEE1A5BC53 +1564EA76995DCF122E4E1D05F6E84524A2FE136E6BE115F8E3E80AAEC073A150DDFA6394B0FE5B +0398FC08F49C2B271960182F63ECCC2F71C973A0768F5D1464D86CFA932B9FEBAEA87EF97E0FCD +6EFE7E4BBED09C2184902176FB7D2EA1A885250D338EA4C8FE4DF827A402CB4D511B730E98C644 +D3009A2A6AA30604DCC012F9B3833AC40FB72040EBB22FF3CCF65697158F50248F2ED01F749570 +6684DCA7556FABF359CCC3A73FEB39E2AABBE9E337C1B338EA33CF54BF25B8B9788F418CFB064E +0667948946027A755ABFBA7A72EE83D34533F95A72F34A724181C6E52C1944D11F6DD2B2AB4E1E +3C9BB1C94A0782DDB2B63BDA717DDAE42618B99E24AAD06B5463DFDC8C055F39820911D2BF2605 +3CC93F110ED75B5F48DA4599454C03461C95F48A1915EE53689C05AE84A7B1D3938FF5B3AC5F5A +34A1BA2725FA5BDBA7B6C272FBA86731207502C8BBECCEF03B6CD4E50FE6FDEFFC87E74F48816A +566A1222BE1F47491DBD73E4DECB5791BA834D4D1C99C497985959A1847B817751C4ABAF98D96A +6F995AE37DB073655CBFBB9DC91497CCA1434BCDEBD5F83CB160E74963BA96F0E795FF727061C4 +D0CA9FFA9B373762EC0FE39E1CD41C6D2434537D159EEE9ECFDD6F3564F31452035D2303D7938A +AF260E8442D58EF5BFDA2DA2FEA1D89582C1E13903CE2002BBCBE0F79D623A3498A7333B1F9A9F +383795981679F5DC5F1B782F20F3464D00107970B2B05FED2A02BA813C66BCFC67385B79EF4358 +AAA05039F1765780177E1CF51A5B4CE720D491C16D929495015AACABC3F898068EC8EE33895AF7 +2AA3EB7203BCAAAE9ACB00390BF9AA87B113C230FB9B1442FA0C2102DBDEB3B95B712F05407B9B +7012A0602009A6A69474181B552E8398D8B9093E588427C2A4EE8F601332A89DE59724C07DD39A +C83B5FA441256A517117801E56FE217B47764C79B4250A8ABF00B60B6B68A7919A4BCDAF8C9A6B +590F6A7F93C361D74606B0C96A6242A515E859032AF658E3817943FCAC6981FE1D7C865D5CC57E +000A3F1E9535E0C45105ED0B0BD4700C29E9C89441C931785925B711E1FD4E8ECCBB3F7A3AD63F +68C41C1BCE45557139D329C076E167DDD4FFAAE81D4664353D03C20759354232D85EA6869854EA +2D9E8AA9300D3DF0039A0A0AB73D018476B5F9BA8B5CCA9A20270FC1CEA623630FBA1ACFB66BB6 +BBE9A218855F07DCA2479EB8876354533186C7FEC2D63B3974D3FB8C3F5064BC8A0EAD9B8F1698 +85F93B1BEB0181242D76A94956BBC5314E57515C3ACFFAE5CFA1C1584715C4290A850847C06995 +18B2CA576B128EBD9BE61196EB0A2CCC51477707D1D073CCAD6851501EA673966FE65E2342C54C +05C81CD80FFDF78FDCC77A0C0E8C5FABA906C1FDD4D08DE0184BCEC1BF9E6F7AAB80862A4E5EF6 +509ECFCD45D48A74EA2886D244A361256E8B8112DDDD5432C68936FD7FC2D5A62722BB50183470 +11DC2FE65B2C7E28005347EE495FE071E59DF2326E9C4B91D324BE9185D3511212B2A2E47CFA7B +D1A4CD5CB3CB986488FC985E7624737A00F18C547852AC26658210C94C2F84761BA0230AB0F484 +18D591E115C6016EC39B97F8B12899FD7A4C1C6B155EF17EF46AEC8FC6F5D10353EBAD43D87C44 +A085A86F9DBA13F0BEB46C85DA96D08C1D9BC65E2E5443631AE92FDDD68E3E24A2F2249E36460D +F1CCBB2CF80A5D1545D8AC3D71D9B11098EA4DC944B4D1F83E43DD9C3804B101220A74692FF7E2 +281D509FA230567FD325D0D2717150C52C557506D61DDDD33430230E74F6E9ADC722B24A7471AA +9ABE1942AFB075E2AF7A1EBABF205EE7C89EFA9807BA76E28F12406B0B2B8E3404768EF607131D +E759494BFA1B2F935415299734E0C68EAF737D44F207163E16AF0CEE304CB57E5AFE3E5DA24DA2 +4513A3BE9F1A7E489AAFFBA73F46E0475705AFB8C0762FB011FF6AA4CF201BDC4F519BE49E18EF +C5406269E9850A8D70BE682451B541094FB99C7DC23693A2761826BE7531E4FF4F853FB38EE944 +94E51A45991E256F0E9B841945351EC27AA28F33717EE276D3F1ACCDA6584A89C11F9FA0878B98 +96ED230C9440E6DE15F6F16D3DFFF568CF1DFDCD629A0259C174C5B366A13C545AFBF7EBAB3499 +6F7F0EED236BDFB8B20CCA618BB717E63658DC3805C259AF55E1A515AAC1E6D1A25AF80925D54E +3AB059F1634D966AC7A184B22D03CB000F766C60C579684CA613D8B6DCEBD3202C11D117797435 +D88FA620A0CA34E7C1242E2AF58EE6B102C15D6D19EEFD837E360AAD094BA6C646FB18FA15C2A2 +3755DF7B1A5E78460E3625BC0496B864405BC5EB57690ED18A7402F5A5EBA9FE39AD3B89000652 +90DFDE4604A8837DB0E8C15CED65679FCBAE5E36AD6361CB1BAD709F4CC7EB620D4F36FBB41CB9 +CF1A58E92D31E48419D4C3E265E465AC1D1A72CA49FEFB007BE89FC577BE36EA07CC77DD456A4B +9A1B534347A9FCEB1E342B3BDAA514289DBC68C504A3F0BA2F2CBDB2FEA9BEE064FD28B616594C +B9544AE541ED7C3BD384D5AF90E04F3054D3525A1650A14A61F9458A5B57645310C6BF0E4228C4 +8368E50433AD91AB68C5420BC0D280BC01DE983DE039B205B82349BB16F96F6AE3563335B0BA23 +ECE046C4C8B74545AED35F6686A53AD04CCADF82D6158907BD7849D308E8211FCAE32A0D7C6530 +833520005842093FDEE243B68BED8ED474CA329F4456D46E3EA01E4E8D350C710CFA5211B7DDE4 +1119BF82249E7BC7CF2B34A7AB2CAD5919DB030F08DCB38203537B864E208AB2AF0E7C71D6241D +D52068080641FF8F0ABF3C7870D3ED073C858E9037868D4CFC078E65E2781146550320B5760C6D +C267F0FCBDA013AC5D3E53104D29FC7BE967F94756337BA8326A4236CF1BF6ABEFE33ACFCCDB6E +FB14F847D0966FA25C3712ACB68FB1D43323198D2114FB4699814307311A06EE32E6BA0874D891 +C33471BEB116209013F89F843F47B3EB599F0D3C4E9FE3AB5164C6E9A91D219E0BE9E651A01A1F +373FC8650A81A3303756D63CE841C7577DF7915FDF112897393B3CD3C3607DA7C6DCCEF2352595 +E532F8FF9E6636F90AC733CFA66FB911768C0CCEC0FA71E7E13E6291D5DF3CBD60E13B9979BC1A +AD37FD2F1927B9755212E6ACF5DF241F231D8C46F656F85F563DACEFF22B117535332CA805099F +1EDAE0D808021C9F401B44A5AD7B60A447E229D8BB7B0808C152F2008D6762C95E5461399DE9D8 +CE542B5F9B706D0D3A57F2FC0E8C0773414A9E68434D1FDDF5B6FFBEB267F68D9D9161774094FE +01239404823F2CCBA524C1C01716D2FBBA0084127ACF78EE9DFBAA0ED8F78BE95C86C125940CC4 +4B212C731159B19C0B408E99D4C548AA46B2AE843FE48E468198F8D95756960612B4202102F3E4 +D52B3820494459555FA4023263706F11B42893695D07F0EB8E127DFD37A97E91D5DC7FB0196446 +E01D601FBB5B8760E4AB2C29748812902D70DD542768348BA72474CB11002B3F8409B8EE61E994 +40F953E188265FD44098477F84C792A1370D6E69886F2B1519FD44C3D8A5864BDA156A7ECDA773 +07A0E02FDD14EEC81E3B47290710078FFC0327CD05EF83322B2895F5EFD50316AB6DD8E4728C41 +6E53A4D1FBFF227B6AA74AF674D610ABE75232164D67A28888CD1761F1495EA4E952D7C6E9DFF7 +F34BB44BF18EA414A777D0287FDE8D87AF5961964C3983B34CDA085C809460FE1AC18BA1EF66F7 +6BFE1DED0C4D2F5BB503464F6AE24C3EB1D8A0FFBAD22E62CD09A44C42F5AC9F65639A617A4BE5 +A7ED95ED939485671FADE5118C8C62B27903D13C872899813B511C16246D0EB28FD225992E4C45 +1FBACB81875A8BC56CC80F6CFFF53BCF0E13B5613D8E67183029B7297FED40D4A0094F69B05FF2 +2021C2E27B7581B9C02D849D58D53F6BE9B1393C0089EC07CB15624FAA4B85ED8221E559351E51 +78AB83CAC67F38C972A8A1763993356BE358E73378AAAE22FB2345EB68C09D61B7CA2A7217F396 +C25F8D1230E81CE01269DCE2FE7006BB68F50375A53A38FF7F387F19120260AD9E8E39A797AC33 +E85D7BD2F960A3E8606F7C7AC756279BC3B0DDDC2575D29800AF220D0928DCFEC6FD9A287A5E8E +3CAD8D3FE4ED4904100163695F2C32B3BC9C3074E2AC1E28EFC899EF49D1424199663BEB347F6E +E1 + +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 +cleartomark + diff --git a/src/libs/pdflib/bind/pdflib/data/blocks.pdf b/src/libs/pdflib/bind/pdflib/data/blocks.pdf new file mode 100644 index 0000000000..13beaad876 Binary files /dev/null and b/src/libs/pdflib/bind/pdflib/data/blocks.pdf differ diff --git a/src/libs/pdflib/bind/pdflib/data/boilerplate.pdf b/src/libs/pdflib/bind/pdflib/data/boilerplate.pdf new file mode 100644 index 0000000000..52960c388b Binary files /dev/null and b/src/libs/pdflib/bind/pdflib/data/boilerplate.pdf differ diff --git a/src/libs/pdflib/bind/pdflib/data/nesrin.jpg b/src/libs/pdflib/bind/pdflib/data/nesrin.jpg new file mode 100644 index 0000000000..10f7d8f880 Binary files /dev/null and b/src/libs/pdflib/bind/pdflib/data/nesrin.jpg differ diff --git a/src/libs/pdflib/bind/pdflib/data/reference.pdf b/src/libs/pdflib/bind/pdflib/data/reference.pdf new file mode 100644 index 0000000000..b09c28dfe9 Binary files /dev/null and b/src/libs/pdflib/bind/pdflib/data/reference.pdf differ diff --git a/src/libs/pdflib/bind/pdflib/data/stationery.pdf b/src/libs/pdflib/bind/pdflib/data/stationery.pdf new file mode 100644 index 0000000000..f9cf7f0691 Binary files /dev/null and b/src/libs/pdflib/bind/pdflib/data/stationery.pdf differ diff --git a/src/libs/pdflib/bind/pdflib/java/jsp/businesscard.jsp b/src/libs/pdflib/bind/pdflib/java/jsp/businesscard.jsp new file mode 100644 index 0000000000..e6a762f693 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/jsp/businesscard.jsp @@ -0,0 +1,86 @@ +<%@page import="java.io.*, javax.servlet.*, com.pdflib.pdflib" %><% + + /* $Id: businesscard.jsp,v 1.1 2004/10/06 17:46:41 laplace Exp $ + * + * businesscard.jsp + */ + + + int font; + pdflib p = null ; + int i, blockcontainer, pdipage; + String infile = "boilerplate.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary. + * + * Note that this directory must also contain the LuciduxSans font + * outline and metrics files. + */ + String searchpath = "../data"; + String[][] data = { + { "name", "Victor Kraxi" }, + { "business.title", "Chief Paper Officer" }, + { "business.address.line1", "17, Aviation Road" }, + { "business.address.city", "Paperfield" }, + { "business.telephone.voice","phone +1 234 567-89" }, + { "business.telephone.fax", "fax +1 234 567-98" }, + { "business.email", "victor@kraxi.com" }, + { "business.homepage", "www.kraxi.com" }, + }; + + byte[] buf; + ServletOutputStream output; + + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "businesscard.jsp"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title","PDFlib block processing sample (JSP)"); + + blockcontainer = p.open_pdi(infile, "", 0); + if (blockcontainer == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + pdipage = p.open_pdi_page(blockcontainer, 1, ""); + if (pdipage == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.begin_page(20, 20); // dummy page size + + // This will adjust the page size to the block container's size. + p.fit_pdi_page(pdipage, 0, 0, "adjustpage"); + + // Fill all text blocks with dynamic data + for (i = 0; i < (int) data.length; i++) { + if (p.fill_textblock(pdipage, data[i][0], data[i][1], + "embedding encoding=winansi") == -1) { + System.err.println("Warning: " + p.get_errmsg()); + } + } + + p.end_page(); // close page + p.close_pdi_page(pdipage); + + p.close(); // close PDF document + p.close_pdi(blockcontainer); + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + output = response.getOutputStream(); + output.write(buf); + output.close(); +%> diff --git a/src/libs/pdflib/bind/pdflib/java/jsp/chartab.jsp b/src/libs/pdflib/bind/pdflib/java/jsp/chartab.jsp new file mode 100644 index 0000000000..f8b69827f8 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/jsp/chartab.jsp @@ -0,0 +1,115 @@ +<%@page import="java.io.*, javax.servlet.*, com.pdflib.pdflib" %><% + + /* $Id: chartab.jsp,v 1.1 2004/10/06 17:46:41 laplace Exp $ + * + * chartab.jsp + */ + + /* change these as required */ + String fontname = "LuciduxSans-Oblique"; + + /* This is where font/image/PDF input files live. Adjust as necessary. */ + String searchpath = "../data"; + + /* list of encodings to use */ + String encodings[] = { "iso8859-1", "iso8859-2", "iso8859-15" }; + int ENCODINGS = 3; + float FONTSIZE= 16; + float TOP = 700; + float LEFT = 50; + float YINCR = 2*FONTSIZE; + float XINCR = 2*FONTSIZE; + + /* whether or not to embed the font */ + int embed = 1; + + String buf; + float x, y; + int row, col, font, codepage; + + pdflib p = null ; + byte[] outbuf; + ServletOutputStream output; + + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.set_parameter("openaction", "fitpage"); + p.set_parameter("fontwarning", "true"); + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "chartab.jsp"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "Character table (Java/JSP)"); + + /* loop over all encodings */ + for (codepage = 0; codepage < ENCODINGS; codepage++) + { + p.begin_page(595, 842); /* start a new page */ + + /* print the heading and generate the bookmark */ + font = p.load_font("Helvetica", "winansi", ""); + p.setfont(font, FONTSIZE); + if (embed == 1) { + buf = fontname + " (" + encodings[codepage] + ") embedded"; + } else{ + buf = fontname + " (" + encodings[codepage] + ") not embedded"; + } + + p.show_xy(buf, LEFT - XINCR, TOP + 3 * YINCR); + p.add_bookmark(buf, 0, 0); + + /* print the row and column captions */ + p.setfont(font, 2 * FONTSIZE/3); + + for (row = 0; row < 16; row++) + { + buf ="x" + (Integer.toHexString(row)).toUpperCase(); + p.show_xy(buf, LEFT + row*XINCR, TOP + YINCR); + + buf = (Integer.toHexString(row)).toUpperCase() + "x"; + p.show_xy(buf, LEFT - XINCR, TOP - row * YINCR); + } + + /* print the character table */ + if (embed == 1) { + buf = "embedding"; + } else{ + buf = ""; + } + font = p.load_font(fontname, encodings[codepage],buf); + p.setfont(font, FONTSIZE); + + y = TOP; + x = LEFT; + + for (row = 0; row < 16; row++) + { + for (col = 0; col < 16; col++) { + buf = String.valueOf((char)(16*row + col)); + p.show_xy(buf, x, y); + x += XINCR; + } + x = LEFT; + y -= YINCR; + } + + p.end_page(); /* close page */ + } + p.close(); /* close PDF document */ + + outbuf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(outbuf.length); + + output = response.getOutputStream(); + output.write(outbuf); + output.close(); +%> diff --git a/src/libs/pdflib/bind/pdflib/java/jsp/hello.jsp b/src/libs/pdflib/bind/pdflib/java/jsp/hello.jsp new file mode 100644 index 0000000000..d086f94f8a --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/jsp/hello.jsp @@ -0,0 +1,46 @@ +<%@page import="java.io.*, javax.servlet.*, com.pdflib.pdflib" %><% + + /* $Id: hello.jsp,v 1.1 2004/10/06 17:46:41 laplace Exp $ + * + * hello.jsp + */ + + int font; + pdflib p; + byte[] buf; + ServletOutputStream output; + + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.set_info("Creator", "hello.jsp"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title", "Hello world (Java/JSP)!"); + + p.begin_page(595, 842); /* start a new page */ + + font = p.load_font("Helvetica-Bold", "winansi", ""); + + p.setfont(font, 18); + + p.set_text_pos(50, 700); + p.show("Hello world!"); + p.continue_text("(says Java/JSP)"); + p.end_page(); /* close page */ + + p.close(); /* close PDF document */ + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + output = response.getOutputStream(); + output.write(buf); + output.close(); +%> diff --git a/src/libs/pdflib/bind/pdflib/java/jsp/image.jsp b/src/libs/pdflib/bind/pdflib/java/jsp/image.jsp new file mode 100644 index 0000000000..486c920ef7 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/jsp/image.jsp @@ -0,0 +1,52 @@ +<%@page import="java.io.*, javax.servlet.*, com.pdflib.pdflib" %><% +/* $Id: image.jsp,v 1.1 2004/10/06 17:46:41 laplace Exp $ + * + * image.jsp + */ + + int image; + float width, height; + pdflib p; + String imagefile = "nesrin.jpg"; + byte[] buf; + ServletOutputStream output; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + String searchpath = "../data"; + + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "image.jsp"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title", "image sample (JSP)"); + + image = p.load_image("auto", imagefile, ""); + + if (image == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + /* dummy page size, will be adjusted by PDF_fit_image() */ + p.begin_page(10, 10); + p.fit_image(image, (float) 0.0, (float) 0.0, "adjustpage"); + p.close_image(image); + p.end_page(); + + p.close(); + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + output = response.getOutputStream(); + output.write(buf); + output.close(); +%> diff --git a/src/libs/pdflib/bind/pdflib/java/jsp/invoice.jsp b/src/libs/pdflib/bind/pdflib/java/jsp/invoice.jsp new file mode 100644 index 0000000000..5f4cc40e82 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/jsp/invoice.jsp @@ -0,0 +1,167 @@ +<%@page import="java.io.*, + javax.servlet.*, + java.text.*, + java.util.*, + com.pdflib.pdflib" + %><% + + /* $Id: invoice.jsp,v 1.1 2004/10/06 17:46:41 laplace Exp $ + * + * invoice.jsp + */ + + pdflib p = null ; + int i, form, pdipage, regularfont, boldfont; + String infile = "stationery.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + String searchpath = "../data"; + final float col1 = 55; + final float col2 = 100; + final float col3 = 330; + final float col4 = 430; + final float col5 = 530; + float fontsize = 12, leading, y; + float sum, total; + float pagewidth = 595, pageheight = 842; + Date now = new Date(); + DateFormat fulldate = DateFormat.getDateInstance(DateFormat.LONG); + + byte[] buf; + ServletOutputStream output; + + String closingtext = + "30 days warranty starting at the day of sale. " + + "This warranty covers defects in workmanship only. " + + "Kraxi Systems, Inc. will, at its option, repair or replace the " + + "product under the warranty. This warranty is not transferable. " + + "No returns or exchanges will be accepted for wet products."; + + String[][] data = { + { "Super Kite", "20", "2"}, + { "Turbo Flyer", "40", "5"}, + { "Giga Trash", "180", "1"}, + { "Bare Bone Kit", "50", "3"}, + { "Nitty Gritty", "20", "10"}, + { "Pretty Dark Flyer", "75", "1"}, + { "Free Gift", "0", "1"}, + }; + + String[] months = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; + + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "invoice.jsp"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title", "PDFlib invoice generation demo (Java/JSP)"); + + form = p.open_pdi(infile, "", 0); + if (form == -1) { + System.err.println("Couldn't open infile '" + infile + "'.\n"); + System.exit(1); + } + + pdipage = p.open_pdi_page(form, 1, ""); + if (pdipage == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + boldfont = p.load_font("Helvetica-Bold", "winansi", ""); + regularfont = p.load_font("Helvetica", "winansi", ""); + leading = fontsize + 2; + + // Establish coordinates with the origin in the upper left corner. + p.set_parameter("topdown", "true"); + + p.begin_page(pagewidth, pageheight); // A4 page + + p.fit_pdi_page(pdipage, 0, pageheight, ""); + p.close_pdi_page(pdipage); + + p.setfont(regularfont, fontsize); + + // Print the address + y = 170; + p.set_value("leading", leading); + + p.show_xy("John Q. Doe", col1, y); + p.continue_text("255 Customer Lane"); + p.continue_text("Suite B"); + p.continue_text("12345 User Town"); + p.continue_text("Everland"); + + // Print the header and date + + p.setfont(boldfont, fontsize); + y = 300; + p.show_xy("INVOICE", col1, y); + + p.fit_textline(fulldate.format(now), col5, y, "position {100 0}"); + + // Print the invoice header line + p.setfont(boldfont, fontsize); + + // "position {0 0}" is left-aligned, "position {100 0}" right-aligned + y = 370; + p.fit_textline("ITEM", col1, y, "position {0 0}"); + p.fit_textline("DESCRIPTION", col2, y, "position {0 0}"); + p.fit_textline("QUANTITY", col3, y, "position {100 0}"); + p.fit_textline("PRICE", col4, y, "position {100 0}"); + p.fit_textline("AMOUNT", col5, y, "position {100 0}"); + + // Print the article list + + p.setfont(regularfont, fontsize); + y += 2*leading; + total = 0; + + for (i = 0; i < data.length; i++) { + p.show_xy(Integer.toString(i+1), col1, y); + p.show_xy(data[i][0], col2, y); + p.fit_textline(data[i][2], col3, y, "position {100 0}"); + p.fit_textline(data[i][1], col4, y, "position {100 0}"); + sum = 0; + + sum = Integer.parseInt(data[i][2]) * Integer.parseInt(data[i][1]); + p.fit_textline(Float.toString(sum), col5, y, "position {100 0}"); + + y += leading; + total += sum; + } + + y += leading; + p.setfont(boldfont, fontsize); + p.fit_textline(Float.toString(total), col5, y, "position {100 0}"); + + // Print the closing text + + y += 5*leading; + p.setfont(regularfont, fontsize); + p.set_value("leading", leading); + p.show_boxed(closingtext, + col1, y + 4*leading, col5-col1, 4*leading, "justify", ""); + + p.end_page(); + p.close(); + p.close_pdi(form); + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + output = response.getOutputStream(); + output.write(buf); + output.close(); +%> diff --git a/src/libs/pdflib/bind/pdflib/java/jsp/pdfclock.jsp b/src/libs/pdflib/bind/pdflib/java/jsp/pdfclock.jsp new file mode 100644 index 0000000000..a33efce267 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/jsp/pdfclock.jsp @@ -0,0 +1,114 @@ +<%@page import="java.io.*, + javax.servlet.*, + java.text.*, + java.util.*, + com.pdflib.pdflib" %><% + /* $Id: pdfclock.jsp,v 1.1 2004/10/06 17:46:41 laplace Exp $ + * + * PDFclock.jsp + */ + + pdflib p; + int tm_hour, tm_min, tm_sec, alpha; + float RADIUS = 200.0f; + float MARGIN = 20.0f; + SimpleDateFormat format; + Date now = new Date(); + byte[] buf; + ServletOutputStream output; + + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.set_info("Creator", "pdfclock.jsp"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title", "PDF clock (Java/JSP)"); + + p.begin_page( (int) (2 * (RADIUS + MARGIN)), + (int) (2 * (RADIUS + MARGIN))); + + p.translate(RADIUS + MARGIN, RADIUS + MARGIN); + p.setcolor("fillstroke", "rgb", 0.0f, 0.0f, 1.0f, 0.0f); + p.save(); + + // minute strokes + p.setlinewidth(2.0f); + for (alpha = 0; alpha < 360; alpha += 6) + { + p.rotate(6.0f); + p.moveto(RADIUS, 0.0f); + p.lineto(RADIUS-MARGIN/3, 0.0f); + p.stroke(); + } + + p.restore(); + p.save(); + + // 5 minute strokes + p.setlinewidth(3.0f); + for (alpha = 0; alpha < 360; alpha += 30) + { + p.rotate(30.0f); + p.moveto(RADIUS, 0.0f); + p.lineto(RADIUS-MARGIN, 0.0f); + p.stroke(); + } + + format = new SimpleDateFormat("hh"); + tm_hour= Integer.parseInt(format.format(now)); + format = new SimpleDateFormat("mm"); + tm_min = Integer.parseInt(format.format(now)); + format = new SimpleDateFormat("ss"); + tm_sec = Integer.parseInt(format.format(now)); + + // draw hour hand + p.save(); + p.rotate((-((tm_min/60.0f) + tm_hour - 3.0f) * 30.0f)); + p.moveto(-RADIUS/10, -RADIUS/20); + p.lineto(RADIUS/2, 0.0f); + p.lineto(-RADIUS/10, RADIUS/20); + p.closepath(); + p.fill(); + p.restore(); + + // draw minute hand + p.save(); + p.rotate((-((tm_sec/60.0f) + tm_min - 15.0f) * 6.0f)); + p.moveto(-RADIUS/10, -RADIUS/20); + p.lineto(RADIUS * 0.8f, 0.0f); + p.lineto(-RADIUS/10, RADIUS/20); + p.closepath(); + p.fill(); + p.restore(); + + // draw second hand + p.setcolor("fillstroke", "rgb", 1.0f, 0.0f, 0.0f, 0.0f); + p.setlinewidth(2); + p.save(); + p.rotate(-((tm_sec - 15.0f) * 6.0f)); + p.moveto(-RADIUS/5, 0.0f); + p.lineto(RADIUS, 0.0f); + p.stroke(); + p.restore(); + + // draw little circle at center + p.circle(0f, 0f, RADIUS/30); + p.fill(); + + p.restore(); + p.end_page(); + p.close(); + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + output = response.getOutputStream(); + output.write(buf); + output.close(); +%> diff --git a/src/libs/pdflib/bind/pdflib/java/jsp/quickreference.jsp b/src/libs/pdflib/bind/pdflib/java/jsp/quickreference.jsp new file mode 100644 index 0000000000..c68e3a5aa7 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/jsp/quickreference.jsp @@ -0,0 +1,94 @@ +<%@page import="java.io.*, + javax.servlet.*, + com.pdflib.pdflib" %><% + /* $Id: quickreference.jsp,v 1.1 2004/10/06 17:46:41 laplace Exp $ + * + * quickreference.jsp + */ + + int font, row, col, i; + int manual, pages; + final int maxrow=2, maxcol=2; + int startpage = 1, endpage = 4; + final float width = 500, height = 770; + int pageno; + String infile = "reference.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary. */ + String searchpath = "../data"; + byte[] buf; + ServletOutputStream output; + + pdflib p; + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "quickreference.jsp"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title", "quickreference (Java/JSP)"); + + manual = p.open_pdi(infile, "", 0); + row = 0; + col = 0; + i = 0; + + if (manual == -1){ + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + + p.set_parameter("topdown", "true"); + + for (pageno = startpage; pageno <= endpage; pageno++) { + if (row == 0 && col == 0) { + i++; + p.begin_page(width, height); + font = p.load_font("Helvetica-Bold", "winansi", ""); + p.setfont(font, 18); + p.set_text_pos(24, 24); + p.show("PDFlib Quick Reference"); + } + + pages = p.open_pdi_page(manual, pageno, ""); + + if (pages == -1) { + System.err.println("Error: " + p.get_errmsg()); + System.exit(1); + } + p.fit_pdi_page(manual, width/maxcol*col, + (row + 1) * height/maxrow, "scale " + (float)1/maxrow); + + p.close_pdi_page(pages); + + col++; + if (col == maxcol) { + col = 0; + row++; + } + if (row == maxrow) { + row = 0; + p.end_page(); + } + } + // finish the last partial page + if (row != 0 || col != 0) + p.end_page(); + + p.close(); + p.close_pdi(manual); + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + output = response.getOutputStream(); + output.write(buf); + output.close(); +%> diff --git a/src/libs/pdflib/bind/pdflib/java/readme.txt b/src/libs/pdflib/bind/pdflib/java/readme.txt new file mode 100644 index 0000000000..af2bc104e8 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/readme.txt @@ -0,0 +1,232 @@ +Using the JSP and servlet examples +================================== + +Before using the examples you must either copy the relevant +image and PDF files to an appropriate location, or modify +the paths in the source code to point to the sample files. + +Note: If you find corrections to the instructions below, or +can contribute configuration hints for other environments +we'll be happy to hear from you -- please send all suggestions +to support@pdflib.com. + + +Exception: PDFlib already loaded in another classloader +======================================================= + +When using PDFlib (on any platform) with an application server you +may encounter the following exception: + +java.lang.UnsatisfiedLinkError: Native Library +C:\WINNT\system32\pdf_java.dll already loaded in another classloader + +This is caused by multiple classloaders trying to load the PDFlib class, +and therefore the PDFlib native libary, into the server's address space +simultaneously. The problem can be avoided by putting pdflib.jar into +the global class path instead of the classpath of the web application. +The PDFlib shared library/DLL should still be placed in an accessible +system directory. + +For example, for Tomcat consider the following directories for pdflib.jar: +bad: WEB-INF/lib +good: $CATALINA_HOME/shared/lib + + +Using PDFlib with IBM Visual Age for Java +========================================== + +- Add pdflib.jar to your project. + +- Place pdf_java.dll in the \winnt\system32 directory, or some + other directory contained in the PATH environment variable. + +- Relative pathnames in PDFlib function calls are interpreted relative + to the java bin directory, not the project directory. For this reason + the output of the supplied PDFlib samples may end up in some strange + place. Absolute path names work. + + +Using PDFlib with Borland JBuilder +================================== + +- Having pdflib.java in the same directory as the project file + seems to confuse JBuilder. + +- On Windows pdf_java.dll must be placed in the \winnt\system32 directory, + or some other directory contained in the PATH environment variable. + On Linux libpdf_java.so should be placed in /usr/lib or a similar + well-known (to the system) directory. + +- Relative pathnames in PDFlib function calls are interpreted relative + to the JBuilder bin directory, not the project directory. For this + reason the output of the supplied PDFlib samples may end up in some + strange place. Absolute path names work. + + +Using PDFlib with MacroMedia ColdFusion MX +========================================== + +We recommend the PDFlib Java edition (instead of the COM edition) for +use with ColdFusion MX. Install the PDFlib Java edition by extracting +pdflib.jar and pdf_java.dll into a folder defined in ColdFusion MX's +Java classpath and the system's PATH variable (might as well just use +C:/CFusionMX/lib). If you previously used the PDFlib COM edition +with ColdFusion you have to change the tag parameters in +the CF file as follows: + + + + +Using PDFlib with Allaire JRun +============================== + +In order to use PDFlib with JRun the following is suggested: + +- Copy PDFlib.jar and lib_java.dll to the .../JRun/servers/lib directory. + +- Make sure that the lib directory is contained in the servlet.jnipath + property. This property can be set from the management console, or + specified in a local.properties file. + + +Using PDFlib with J2EE-compliant servers +======================================== + +In order to use PDFlib with J2EE do the following: + +- Add the following lines in the file $J2EE_HOME/lib/security/server.policy + in order to allow the PDFlib native library to be loaded: + + // default permissions granted to all domains + grant { + permission java.lang.RuntimePermission "loadLibrary.*"; + permission java.lang.RuntimePermission "accessClassInPackage.*"; + ... + +- Use the deployment tool to add pdflib.jar to the project as an external + jar library. + It seems that pdflib.jar must be placed in the %J2EE_HOME%/lib directory; + otherwise the server will attempt to load the PDFlib shared library + multiply, resulting in the error message "shared library already loaded". + +- pdf_java.dll or libpdf_java.so must be accessible in some system path, + e.g. \winnt\system32 or /usr/local/lib, or via PATH/LD_LIBRARY_PATH. + +- The PATH and CLASSPATH variables should point to the bin subdirectories + of J2EE and JDK. + + +Using PDFlib with Tomcat +======================== + +In order to use PDFlib with Apache Tomcat do the following: + +- Put the PDFlib shared library or DLL (e.g. pdf_java.dll) into a directly + which is accessible systemwide (e.g. C:\winnt\system32). + +- It is suggested to load PDFlib as early as possible. Loading PDFlib later + in the servlet (e.g., via repositories) may fail due to different + class loaders. + +- Put pdflib.jar into + $CATALINA_HOME/common/lib (Tomcat 3) or + $CATALINA_HOME/shared/lib (Tomcat 4). + +- Add a line similar to the file tomcat.properties: + + wrapper.env="/usr/local/lib:/usr/lib:/lib" + +- After building or installing PDFlib it may help to update the shared + library cache via + + ldconfig -v (or similar command depending on your Unix version) + + + +Using PDFlib with IBM WebSphere Application Server +================================================== + +The instructions in this section apply to WebSphere 3 and 4. +For WebSphere 5 please refer to the section above on J2EE-compliant +servers. + +Servlets are loaded with a custom class loader. For this reason, +the pdflib.jar file has to be located in the Application Server's +classpath rather than the web application's classpath. + +To locate the pdflib.jar file in the app server's classpath, place the jar +file in the \\lib directory and edit the +admin.config file. In the admin.config file add the path to the jar file +to the setting labeled: + +com.ibm.ejs.sm.adminserver.classpath + +If you use the Websphere Application Assembly Tool you can add pdflib.jar +to your project. + +The DLL or .so must be located somewhere on the machine's path. +The winnt\system32 directory works for Windows, the bin directory +of WAS on Solaris. + +On the AS/400 make sure that the PDFLIB and PDF_JAVA SRVPGM can be +found in the library list of the jobs running your Java apps. The +easiest way to achieve this is to copy these SRVPGMs to the QGPL +library. In most cases this library is found in every LIBL. + + +Using PDFlib on Mac OS X +======================== + +On Mac OS X the shared PDFlib library for Java, which has a default file +name of libpdf_java.dylib, must be renamed to libpdf_java.jnilib. The +PDFlib build process does this automatically. + +The default search path for JNI libraries on OS X is as follows: + + .:/usr/lib:/usr/lib/java:/lib: + /System/Library/Frameworks/JavaVM.framework/Versions/1.2/Libraries + +You can extend the JNI search path by defining the DYLD_LIBRARY_PATH +with more directories. + + +Using PDFlib with Apple WebObjects +================================== + +To the best of our knowledge, the following should be sufficient in order +to use PDFlib with WebObjects: + +- Use the java-framework-maker tool to create a new WebObjects Framework, + and select PDFlib.jar as input package. + +- Add the new framework to your project. + + +Using PDFlib with Lotus Notes +============================= + +We don't have first-hand experience with deploying PDFlib in Notes. +However, a user contributed the following information: + +> Apparently when you compile the Java code and then you run the code, Domino +> is not using the same paths. To compile the code you need to add the +> pdflib.jar to the project. This can be done by clicking the Edit Project +> button and browsing to the directory where the file is located and then +> adding the file to the project. This will allow you to compile the code +> without errors. If you are a programmer you will assume that since the +> code compiled therefore Domino knows where the Java class resides but you +> know what happens when you assume. The second thing that you need to do is +> create a "\com\pdflib" directory within your Notes directory and put the +> pdflib.class file in that directory. When you specify "import +> com.pdflib.pdflib" this is where Java will go to look for the class +> then it executes it. I found documentation that said that you can add a +> path my adding a line in the notes.ini file "JavaUserClasses=yourpath" but +> it did not work. + + +Using PDFlib on SGI IRIX +======================== + +Use the LD_LIBRARYN32_PATH environment variable (as opposed to the +traditional LD_LIBRARY_PATH) in order to set the directory where the +PDFlib shared library for Java will be found. diff --git a/src/libs/pdflib/bind/pdflib/java/servlet/businesscardServlet.java b/src/libs/pdflib/bind/pdflib/java/servlet/businesscardServlet.java new file mode 100644 index 0000000000..d5213bab65 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/servlet/businesscardServlet.java @@ -0,0 +1,103 @@ +/* $Id: businesscardServlet.java,v 1.1 2004/10/06 17:46:42 laplace Exp $ + * + * PDFlib client: hello servlet example in Java + */ + +import java.io.*; +import javax.servlet.*; + +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class businesscardServlet extends GenericServlet +{ + public void service(ServletRequest request, ServletResponse response) + { + int font; + pdflib p = null ; + int i, blockcontainer, page; + String infile = "boilerplate.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary. + * + * Note that this directory must also contain the LuciduxSans font + * outline and metrics files. + */ + String searchpath = "../data"; + String[][] data = { + { "name", "Victor Kraxi" }, + { "business.title", "Chief Paper Officer" }, + { "business.address.line1", "17, Aviation Road" }, + { "business.address.city", "Paperfield" }, + { "business.telephone.voice","phone +1 234 567-89" }, + { "business.telephone.fax", "fax +1 234 567-98" }, + { "business.email", "victor@kraxi.com" }, + { "business.homepage", "www.kraxi.com" }, + }; + byte[] buf; + ServletOutputStream out; + + try{ + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "businesscard.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title","PDFlib block processing sample (Java)"); + + blockcontainer = p.open_pdi(infile, "", 0); + if (blockcontainer == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + page = p.open_pdi_page(blockcontainer, 1, ""); + if (page == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.begin_page(20, 20); // dummy page size + + // This will adjust the page size to the block container's size. + p.fit_pdi_page(page, 0, 0, "adjustpage"); + + // Fill all text blocks with dynamic data + for (i = 0; i < (int) data.length; i++) { + if (p.fill_textblock(page, data[i][0], data[i][1], + "embedding encoding=winansi") == -1) { + System.err.println("Warning: " + p.get_errmsg()); + } + } + + p.end_page(); // close page + p.close_pdi_page(page); + + p.close(); // close PDF document + p.close_pdi(blockcontainer); + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + out = response.getOutputStream(); + out.write(buf); + out.close(); + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in businesscard sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/servlet/chartabServlet.java b/src/libs/pdflib/bind/pdflib/java/servlet/chartabServlet.java new file mode 100644 index 0000000000..42b65fd148 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/servlet/chartabServlet.java @@ -0,0 +1,136 @@ +/* $Id: chartabServlet.java,v 1.1 2004/10/06 17:46:42 laplace Exp $ + * + * PDFlib client: hello servlet example in Java + */ + +import java.io.*; +import javax.servlet.*; + +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class chartabServlet extends GenericServlet +{ + /* change these as required */ + static final String fontname = "LuciduxSans-Oblique"; + + /* This is where font/image/PDF input files live. Adjust as necessary. */ + static final String searchpath = "../data"; + + /* list of encodings to use */ + static final String encodings[] = { "iso8859-1", "iso8859-2", "iso8859-15" }; + static final int ENCODINGS = 3; + static final float FONTSIZE = 16; + static final float TOP = 700; + static final float LEFT = 50; + static final float YINCR = 2*FONTSIZE; + static final float XINCR = 2*FONTSIZE; + + public void service(ServletRequest request, ServletResponse response) + { + /* whether or not to embed the font */ + int embed = 1; + + String buf; + float x, y; + int row, col, font, page; + + pdflib p = null ; + byte[] outbuf; + ServletOutputStream out; + + try{ + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("openaction", "fitpage"); + p.set_parameter("fontwarning", "true"); + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "chartabServlet.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "Character table (Java/Servlet)"); + + /* loop over all encodings */ + for (page = 0; page < ENCODINGS; page++) + { + p.begin_page(595, 842); /* start a new page */ + + /* print the heading and generate the bookmark */ + font = p.load_font("Helvetica", "winansi", ""); + p.setfont(font, FONTSIZE); + if (embed == 1) { + buf = fontname + " (" + encodings[page] + ") embedded"; + } else{ + buf = fontname + " (" + encodings[page] + ") not embedded"; + } + + p.show_xy(buf, LEFT - XINCR, TOP + 3 * YINCR); + p.add_bookmark(buf, 0, 0); + + /* print the row and column captions */ + p.setfont(font, 2 * FONTSIZE/3); + + for (row = 0; row < 16; row++) + { + buf ="x" + (Integer.toHexString(row)).toUpperCase(); + p.show_xy(buf, LEFT + row*XINCR, TOP + YINCR); + + buf = (Integer.toHexString(row)).toUpperCase() + "x"; + p.show_xy(buf, LEFT - XINCR, TOP - row * YINCR); + } + + /* print the character table */ + if (embed == 1) { + buf = "embedding"; + } else{ + buf = ""; + } + font = p.load_font(fontname, encodings[page],buf); + p.setfont(font, FONTSIZE); + + y = TOP; + x = LEFT; + + for (row = 0; row < 16; row++) + { + for (col = 0; col < 16; col++) { + buf = String.valueOf((char)(16*row + col)); + p.show_xy(buf, x, y); + x += XINCR; + } + x = LEFT; + y -= YINCR; + } + + p.end_page(); /* close page */ + } + p.close(); /* close PDF document */ + + outbuf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(outbuf.length); + + out = response.getOutputStream(); + out.write(outbuf); + out.close(); + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in chartab sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/servlet/helloServlet.java b/src/libs/pdflib/bind/pdflib/java/servlet/helloServlet.java new file mode 100644 index 0000000000..d3855be1f7 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/servlet/helloServlet.java @@ -0,0 +1,65 @@ +/* $Id: helloServlet.java,v 1.1 2004/10/06 17:46:42 laplace Exp $ + * + * PDFlib client: hello servlet example in Java + */ + +import java.io.*; +import javax.servlet.*; + +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class helloServlet extends GenericServlet +{ + public void service(ServletRequest request, ServletResponse response) + { + int font; + pdflib p = null; + byte[] buf; + ServletOutputStream out; + + try{ + p = new pdflib(); + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_info("Creator", "helloServlet.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "Hello world (Java/Servlet)!"); + + p.begin_page(595, 842); /* start a new page */ + + font = p.load_font("Helvetica-Bold", "winansi", ""); + + p.setfont(font, 18); + + p.set_text_pos(50, 700); + p.show("Hello world!"); + p.continue_text("(says Java/Servlet)"); + p.end_page(); /* close page */ + + p.close(); /* close PDF document */ + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + out = response.getOutputStream(); + out.write(buf); + out.close(); + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in hello sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/servlet/imageServlet.java b/src/libs/pdflib/bind/pdflib/java/servlet/imageServlet.java new file mode 100644 index 0000000000..d3c0f2c5c6 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/servlet/imageServlet.java @@ -0,0 +1,80 @@ +/* $Id: imageServlet.java,v 1.1 2004/10/06 17:46:42 laplace Exp $ + * + * PDFlib client: image example in JavaServlet + */ + +import java.io.*; +import javax.servlet.*; +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class imageServlet extends GenericServlet +{ + public void service (ServletRequest request, ServletResponse response) + { + int image; + float width, height; + pdflib p = null; + String imagefile = "nesrin.jpg"; + byte[] buf; + ServletOutputStream output; + int manual, page; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + String searchpath = "../data"; + + try{ + + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "imageServlet.java"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title", "image sample (JavaServlet)"); + + if (request.getParameter("image") != null){ + imagefile = request.getParameter("image") ; + } + + image = p.load_image("auto", imagefile, ""); + + if (image == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + + /* dummy page size, will be adjusted by PDF_fit_image() */ + p.begin_page(10, 10); + p.fit_image(image, (float) 0.0, (float) 0.0, "adjustpage"); + p.close_image(image); + p.end_page(); + + p.close(); + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + output = response.getOutputStream(); + output.write(buf); + output.close(); + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in hello sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/servlet/invoiceServlet.java b/src/libs/pdflib/bind/pdflib/java/servlet/invoiceServlet.java new file mode 100644 index 0000000000..7aa4811dff --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/servlet/invoiceServlet.java @@ -0,0 +1,184 @@ +/* $Id: invoiceServlet.java,v 1.1 2004/10/06 17:46:42 laplace Exp $ + * + * PDFlib client: invoice servlet example in Java + */ + +import java.io.*; +import java.text.*; // DateFormat +import java.util.*; // Date +import javax.servlet.*; + +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class invoiceServlet extends GenericServlet +{ + public void service(ServletRequest request, ServletResponse response) + { + + pdflib p = null ; + int i, form, page, regularfont, boldfont; + String infile = "stationery.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + String searchpath = "../data"; + final float col1 = 55; + final float col2 = 100; + final float col3 = 330; + final float col4 = 430; + final float col5 = 530; + float fontsize = 12, leading, y; + float sum, total; + float pagewidth = 595, pageheight = 842; + Date now = new Date(); + DateFormat fulldate = DateFormat.getDateInstance(DateFormat.LONG); + byte[] buf; + ServletOutputStream out; + + String closingtext = + "30 days warranty starting at the day of sale. " + + "This warranty covers defects in workmanship only. " + + "Kraxi Systems, Inc. will, at its option, repair or replace the " + + "product under the warranty. This warranty is not transferable. " + + "No returns or exchanges will be accepted for wet products."; + + String[][] data = { + { "Super Kite", "20", "2"}, + { "Turbo Flyer", "40", "5"}, + { "Giga Trash", "180", "1"}, + { "Bare Bone Kit", "50", "3"}, + { "Nitty Gritty", "20", "10"}, + { "Pretty Dark Flyer", "75", "1"}, + { "Free Gift", "0", "1"}, + }; + + String[] months = { + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + }; + + try{ + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "invoiceServlet.java"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title", + "PDFlib invoice generation demo (Java/Servlet)"); + + form = p.open_pdi(infile, "", 0); + if (form == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + page = p.open_pdi_page(form, 1, ""); + if (page == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + boldfont = p.load_font("Helvetica-Bold", "winansi", ""); + regularfont = p.load_font("Helvetica", "winansi", ""); + leading = fontsize + 2; + + // Establish coordinates with the origin in the upper left corner. + p.set_parameter("topdown", "true"); + + p.begin_page(pagewidth, pageheight); // A4 page + + p.fit_pdi_page(page, 0, pageheight, ""); + p.close_pdi_page(page); + + p.setfont(regularfont, fontsize); + + // Print the address + y = 170; + p.set_value("leading", leading); + + p.show_xy("John Q. Doe", col1, y); + p.continue_text("255 Customer Lane"); + p.continue_text("Suite B"); + p.continue_text("12345 User Town"); + p.continue_text("Everland"); + + // Print the header and date + + p.setfont(boldfont, fontsize); + y = 300; + p.show_xy("INVOICE", col1, y); + + p.fit_textline(fulldate.format(now), col5, y, "position {100 0}"); + + // Print the invoice header line + p.setfont(boldfont, fontsize); + + // "position {0 0}" is left-aligned, "position {100 0}" right-aligned + y = 370; + p.fit_textline("ITEM", col1, y, "position {0 0}"); + p.fit_textline("DESCRIPTION", col2, y, "position {0 0}"); + p.fit_textline("QUANTITY", col3, y, "position {100 0}"); + p.fit_textline("PRICE", col4, y, "position {100 0}"); + p.fit_textline("AMOUNT", col5, y, "position {100 0}"); + + // Print the article list + + p.setfont(regularfont, fontsize); + y += 2*leading; + total = 0; + + for (i = 0; i < data.length; i++) { + p.show_xy(Integer.toString(i+1), col1, y); + p.show_xy(data[i][0], col2, y); + p.fit_textline(data[i][2], col3, y, "position {100 0}"); + p.fit_textline(data[i][1], col4, y, "position {100 0}"); + sum = 0; + + sum = Integer.parseInt(data[i][2]) * Integer.parseInt(data[i][1]); + p.fit_textline(Float.toString(sum), col5, y, "position {100 0}"); + + y += leading; + total += sum; + } + + y += leading; + p.setfont(boldfont, fontsize); + p.fit_textline(Float.toString(total), col5, y, "position {100 0}"); + + // Print the closing text + + y += 5*leading; + p.setfont(regularfont, fontsize); + p.set_value("leading", leading); + p.show_boxed(closingtext, + col1, y + 4*leading, col5-col1, 4*leading, "justify", ""); + + p.end_page(); + p.close(); + p.close_pdi(form); + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + out = response.getOutputStream(); + out.write(buf); + out.close(); + + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in invoice sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/servlet/pdfclockServlet.java b/src/libs/pdflib/bind/pdflib/java/servlet/pdfclockServlet.java new file mode 100644 index 0000000000..2243bd698d --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/servlet/pdfclockServlet.java @@ -0,0 +1,134 @@ +/* $Id: pdfclockServlet.java,v 1.1 2004/10/06 17:46:42 laplace Exp $ + * + * PDFlib client: pdfclock example in Java + */ + +import java.io.*; +import java.text.*; // SimpleDateFormat +import java.util.*; // Date +import javax.servlet.*; +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class pdfclockServlet extends GenericServlet +{ + public void service (ServletRequest request, ServletResponse response) + { + pdflib p = null; + int tm_hour, tm_min, tm_sec, alpha; + float RADIUS = 200.0f; + float MARGIN = 20.0f; + SimpleDateFormat format; + Date now = new Date(); + + try{ + p = new pdflib(); + byte[] buf; + ServletOutputStream out; + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_info("Creator", "pdfclockServlet.java"); + p.set_info("Author", "Thomas Merz"); + p.set_info("Title", "PDF clock (Java/servlet)"); + + p.begin_page( (int) (2 * (RADIUS + MARGIN)), + (int) (2 * (RADIUS + MARGIN))); + + p.translate(RADIUS + MARGIN, RADIUS + MARGIN); + p.setcolor("fillstroke", "rgb", 0.0f, 0.0f, 1.0f, 0.0f); + p.save(); + + // minute strokes + p.setlinewidth(2.0f); + for (alpha = 0; alpha < 360; alpha += 6) + { + p.rotate(6.0f); + p.moveto(RADIUS, 0.0f); + p.lineto(RADIUS-MARGIN/3, 0.0f); + p.stroke(); + } + + p.restore(); + p.save(); + + // 5 minute strokes + p.setlinewidth(3.0f); + for (alpha = 0; alpha < 360; alpha += 30) + { + p.rotate(30.0f); + p.moveto(RADIUS, 0.0f); + p.lineto(RADIUS-MARGIN, 0.0f); + p.stroke(); + } + + format = new SimpleDateFormat("hh"); + tm_hour= Integer.parseInt(format.format(now)); + format = new SimpleDateFormat("mm"); + tm_min = Integer.parseInt(format.format(now)); + format = new SimpleDateFormat("ss"); + tm_sec = Integer.parseInt(format.format(now)); + + // draw hour hand + p.save(); + p.rotate((-((tm_min/60.0f) + tm_hour - 3.0f) * 30.0f)); + p.moveto(-RADIUS/10, -RADIUS/20); + p.lineto(RADIUS/2, 0.0f); + p.lineto(-RADIUS/10, RADIUS/20); + p.closepath(); + p.fill(); + p.restore(); + + // draw minute hand + p.save(); + p.rotate((-((tm_sec/60.0f) + tm_min - 15.0f) * 6.0f)); + p.moveto(-RADIUS/10, -RADIUS/20); + p.lineto(RADIUS * 0.8f, 0.0f); + p.lineto(-RADIUS/10, RADIUS/20); + p.closepath(); + p.fill(); + p.restore(); + + // draw second hand + p.setcolor("fillstroke", "rgb", 1.0f, 0.0f, 0.0f, 0.0f); + p.setlinewidth(2); + p.save(); + p.rotate(-((tm_sec - 15.0f) * 6.0f)); + p.moveto(-RADIUS/5, 0.0f); + p.lineto(RADIUS, 0.0f); + p.stroke(); + p.restore(); + + // draw little circle at center + p.circle(0f, 0f, RADIUS/30); + p.fill(); + + p.restore(); + p.end_page(); + p.close(); + + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + out = response.getOutputStream(); + out.write(buf); + out.close(); + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in pdfclock sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + + + } +} diff --git a/src/libs/pdflib/bind/pdflib/java/servlet/quickreferenceServlet.java b/src/libs/pdflib/bind/pdflib/java/servlet/quickreferenceServlet.java new file mode 100644 index 0000000000..e2591dece5 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/java/servlet/quickreferenceServlet.java @@ -0,0 +1,108 @@ +/* $Id: quickreferenceServlet.java,v 1.1 2004/10/06 17:46:42 laplace Exp $ + * + * PDFlib/PDI client: mini imposition demo + */ + +import java.io.*; +import javax.servlet.*; +import com.pdflib.pdflib; +import com.pdflib.PDFlibException; + +public class quickreferenceServlet extends GenericServlet +{ + public void service (ServletRequest request, ServletResponse response) + { + int font, row = 0 , col = 0 , i; + int manual, pages; + final int maxrow=2, maxcol=2; + int startpage = 1, endpage = 4; + final float width = 500, height = 770; + int pageno; + String infile = "reference.pdf"; + /* This is where font/image/PDF input files live. Adjust as necessary.*/ + String searchpath = "../data"; + byte[] buf; + ServletOutputStream output; + pdflib p = null; + + try{ + p = new pdflib(); + + // Generate a PDF in memory; insert a file name to create PDF on disk + if (p.open_file("") == -1) { + throw new Exception("Couldn't create PDF output.\n"); + } + + p.set_parameter("SearchPath", searchpath); + + p.set_info("Creator", "quickreferenceServlet.java"); + p.set_info("Author", "Rainer Ploeckl"); + p.set_info("Title", "imposition demo (Java/Servlet)"); + + manual = p.open_pdi(infile, "", 0); + i = 0; + + if (manual == -1){ + throw new Exception("Error: " + p.get_errmsg()); + } + + p.set_parameter("topdown", "true"); + + for (pageno = startpage; pageno <= endpage; pageno++) { + if (row == 0 && col == 0) { + i++; + p.begin_page(width, height); + font = p.load_font("Helvetica-Bold", "winansi", ""); + p.setfont(font, 18); + p.set_text_pos(24, 24); + p.show("PDFlib Quick Reference"); + } + + pages = p.open_pdi_page(manual, pageno, ""); + + if (pages == -1) { + throw new Exception("Error: " + p.get_errmsg()); + } + + p.fit_pdi_page(manual, width/maxcol*col, + (row + 1) * height/maxrow, "scale " + (float)1/maxrow); + p.close_pdi_page(pages); + + col++; + if (col == maxcol) { + col = 0; + row++; + } + if (row == maxrow) { + row = 0; + p.end_page(); + } + } + + // finish the last partial page + if (row != 0 || col != 0) + p.end_page(); + + p.close(); + p.close_pdi(manual); + buf = p.get_buffer(); + + response.setContentType("application/pdf"); + response.setContentLength(buf.length); + + output = response.getOutputStream(); + output.write(buf); + output.close(); + } catch (PDFlibException e) { + System.err.print("PDFlib exception occurred in quickreference sample:\n"); + System.err.print("[" + e.get_errnum() + "] " + e.get_apiname() + + ": " + e.getMessage() + "\n"); + } catch (Exception e) { + System.err.println(e.getMessage()); + } finally { + if (p != null) { + p.delete(); /* delete the PDFlib object */ + } + } + } +} diff --git a/src/libs/pdflib/bind/pdflib/perl/Makefile b/src/libs/pdflib/bind/pdflib/perl/Makefile new file mode 100644 index 0000000000..35c99666f9 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/Makefile @@ -0,0 +1,48 @@ +# Makefile for PDFlib's Perl binding +# $Id: Makefile,v 1.1 2004/10/06 17:46:42 laplace Exp $ + +top_builddir = ../../.. + +include $(top_builddir)/config/mkcommon.inc + +INCLUDES = $(PDFLIBINC) $(PERLBOOLDEF) $(PERLINCLUDE) +# special CFLAGS, as -ansi is not working here. +CFLAGS = $(DEFS) $(DEFINES) $(INCLUDES) + +PERLBIN = $(PERL) -I. -I.libs +LANG_LIBDIR = $(PERLLIBDIR) +BINDEXTERNALLIBS= $(PERLLINK) + +LIBNAME = pdflib_pl$(LA) +OBJ = pdflib_pl$(LO) +SRC = pdflib_pl.c + +include $(top_builddir)/config/mkbind.inc + +test:: all + -$(PERLBIN) hello.pl + -$(PERLBIN) image.pl + -$(PERLBIN) pdfclock.pl + -$(PERLBIN) chartab.pl + -$(PERLBIN) invoice.pl + -$(PERLBIN) businesscard.pl + -$(PERLBIN) quickreference.pl + +smoke:: test + -$(PERLBIN) smoketest.pl + +install:: $(SWIG_LIB) + $(LIBTOOL) --mode=install \ + $(INSTALL_DATA) $(SWIG_LIB) $(LANG_LIBDIR) + $(INSTALL_DATA) pdflib_pl.pm $(LANG_LIBDIR) + +uninstall:: + $(LIBTOOL) --mode=uninstall \ + $(RM) $(LANG_LIBDIR)/$(SWIG_LIB) $(LANG_LIBDIR)/pdflib_pl.pm + +clean:: + $(RM) smoke_c_?.pdf + $(RM) hello.pdf image.pdf pdfclock.pdf chartab.pdf invoice.pdf + $(RM) businesscard.pdf quickreference.pdf + +# Automatically generated dependencies diff --git a/src/libs/pdflib/bind/pdflib/perl/Perl.dsp b/src/libs/pdflib/bind/pdflib/perl/Perl.dsp new file mode 100644 index 0000000000..b543466544 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/Perl.dsp @@ -0,0 +1,140 @@ +# Microsoft Developer Studio Project File - Name="Perl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Perl - Win32 perlAS56 +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Perl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Perl.mak" CFG="Perl - Win32 perlAS56" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Perl - Win32 perlAS56" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Perl - Win32 perlAS58" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Perl - Win32 perl5005" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Perl - Win32 perlAS56" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "perlAS56" +# PROP BASE Intermediate_Dir "perlAS56" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "perlAS56" +# PROP Intermediate_Dir "perlAS56" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "c:\programme\Perl\lib\CORE" /I "c:\programme\Perl\lib\CORE\win32" /I "..\..\..\libs\pdflib" /D "WIN32" /D "_MT" /D "PDFLIB_STATIC" /FR /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "c:\programme\Perl\lib\CORE" /I "c:\programme\Perl56\lib\CORE" /I "..\..\..\libs\pdflib" /D "WIN32" /D "_MT" /D "PDFLIB_STATIC" /FR /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib perl56.lib pdflib.lib /nologo /base:"0x55330000" /dll /pdb:none /machine:I386 /out:"perlAS56\pdflib_pl.dll" /libpath:"c:\programme\Perl\lib\CORE" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib perl56.lib pdflib.lib /nologo /base:"0x55330000" /dll /pdb:none /machine:I386 /out:"perlAS56\pdflib_pl.dll" /libpath:"c:\programme\Perl56\lib\CORE" /libpath:"c:\programme\Perl\lib\CORE" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "Perl - Win32 perlAS58" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "perlAS58" +# PROP BASE Intermediate_Dir "perlAS58" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "perlAS58" +# PROP Intermediate_Dir "perlAS58" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "c:\programme\Perl\lib\CORE" /I "c:\programme\Perl\lib\CORE\win32" /I "..\..\..\libs\pdflib" /D "WIN32" /D "_MT" /D "PDFLIB_STATIC" /FR /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "c:\programme\Perl58\lib\CORE" /I "c:\programme\Perl58\lib\CORE\win32" /I "..\..\..\libs\pdflib" /D "WIN32" /D "_MT" /D "PDFLIB_STATIC" /FR /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib perl56.lib pdflib.lib /nologo /base:"0x55330000" /dll /pdb:none /machine:I386 /out:"perlAS58\pdflib_pl.dll" /libpath:"c:\programme\Perl\lib\CORE" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib perl58.lib pdflib.lib /nologo /base:"0x55330000" /dll /pdb:none /machine:I386 /out:"perlAS58\pdflib_pl.dll" /libpath:"c:\programme\Perl58\lib\CORE" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "Perl - Win32 perl5005" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "perl5005" +# PROP BASE Intermediate_Dir "perl5005" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "perl5005" +# PROP Intermediate_Dir "perl5005" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "c:\programme\Perl5.005\lib\CORE" /I "c:\programme\Perl5.005\lib\CORE\win32" /I "..\..\..\libs\pdflib" /D "WIN32" /D "_MT" /D "PDFLIB_STATIC" /D "PERL_OBJECT" /FR /YX /FD /c /Tp +# ADD CPP /nologo /MT /W3 /O2 /I "c:\programme\Perl5.005\lib\CORE" /I "c:\programme\Perl5.005\lib\CORE\win32" /I "..\..\..\libs\pdflib" /D "WIN32" /D "_MT" /D "PDFLIB_STATIC" /D "PERL_OBJECT" /FR /YX /FD /c /Tp +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib perlcore.lib /nologo /base:"0x55330000" /dll /pdb:none /machine:I386 /out:"perl5005\pdflib_pl.dll" /libpath:"c:\programme\Perl5.005\lib\CORE" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pdflib.lib perlcore.lib /nologo /base:"0x55330000" /dll /pdb:none /machine:I386 /out:"perl5005\pdflib_pl.dll" /libpath:"c:\programme\Perl5.005\lib\CORE" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT LINK32 /debug + +!ENDIF + +# Begin Target + +# Name "Perl - Win32 perlAS56" +# Name "Perl - Win32 perlAS58" +# Name "Perl - Win32 perl5005" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib_pl.c +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/perl/businesscard.pl b/src/libs/pdflib/bind/pdflib/perl/businesscard.pl new file mode 100644 index 0000000000..3a2998286e --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/businesscard.pl @@ -0,0 +1,82 @@ +#!/usr/bin/perl +# $Id: businesscard.pl,v 1.1 2004/10/06 17:46:42 laplace Exp $ +# +# PDFlib client: block processing example in C +# + +use pdflib_pl 5.0; + +$infile = "boilerplate.pdf"; +# This is where font/image/PDF input files live. Adjust as necessary. +# +# Note that this directory must also contain the LuciduxSans font outline +# and metrics files. +# +$searchpath = "../data"; + +%data = ( "name" => "Victor Kraxi", + "business.title" => "Chief Paper Officer", + "business.address.line1" => "17, Aviation Road", + "business.address.city" => "Paperfield", + "business.telephone.voice" => "phone +1 234 567-89", + "business.telephone.fax" => "fax +1 234 567-98", + "business.email" => "victor\@kraxi.com", + "business.homepage" => "www.kraxi.com" + ); + +# create a new PDFlib object +$p = PDF_new(); + +eval { + # open new PDF file + if (PDF_open_file($p, "businesscard.pdf") == -1){ + printf ("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + PDF_set_parameter($p, "SearchPath", $searchpath); + + # This line is required to avoid problems on Japanese systems + PDF_set_parameter($p, "hypertextencoding", "winansi"); + + PDF_set_info($p, "Creator", "businesscard.pl"); + PDF_set_info($p, "Author", "Thomas Merz"); + PDF_set_info($p, "Title", "PDFlib block processing sample (Perl)"); + + $blockcontainer = PDF_open_pdi($p, $infile, "", 0); + if ($blockcontainer == -1){ + printf ("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + $page = PDF_open_pdi_page($p, $blockcontainer, 1, ""); + if ($page == -1){ + printf ("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + PDF_begin_page($p, 20, 20); # dummy page size + + # This will adjust the page size to the block container's size. + PDF_fit_pdi_page($p, $page, 0, 0, "adjustpage"); + + # Fill all text blocks with dynamic data + foreach $elem(keys %data){ + if (PDF_fill_textblock($p, $page, $elem, $data{$elem}, + "embedding encoding=winansi") == -1) { + printf ("Warning: %s\n", PDF_get_errmsg($p)); + } + } + + PDF_end_page($p); # close page + PDF_close_pdi_page($p, $page); + + PDF_close($p); # close PDF document + PDF_close_pdi($p, $blockcontainer); +}; +if ($@) { + printf("businesscard: PDFlib Exception occurred:\n"); + printf(" $@\n"); + exit; +} +PDF_delete($p); # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/perl/chartab.pl b/src/libs/pdflib/bind/pdflib/perl/chartab.pl new file mode 100644 index 0000000000..8d9482f48a --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/chartab.pl @@ -0,0 +1,107 @@ +#!/usr/bin/perl +# $Id: chartab.pl,v 1.1 2004/10/06 17:46:42 laplace Exp $ +# +# PDFlib client: hello example in Perl +# + +use pdflib_pl 5.0; + +# change these as required +$fontname = "LuciduxSans-Oblique"; + +# This is where font/image/PDF input files live. Adjust as necessary. +$searchpath = "../data"; + +# list of encodings to use +@encodings = ( "iso8859-1", "iso8859-2", "iso8859-15" ); + +# whether or not to embed the font +$embed = 1; + +use constant "FONTSIZE" => 16; +use constant "TOP" => 700; +use constant "LEFT" => 50; +use constant "YINCR" => 2*FONTSIZE; +use constant "XINCR" => 2*FONTSIZE; + +# create a new PDFlib object +$p = PDF_new(); + +eval { + # open new PDF file + if (PDF_open_file($p, "chartab.pdf") == 0) { + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + PDF_set_parameter($p, "openaction", "fitpage"); + PDF_set_parameter($p, "fontwarning", "true"); + PDF_set_parameter($p, "SearchPath", $searchpath); + + # This line is required to avoid problems on Japanese systems + PDF_set_parameter($p, "hypertextencoding", "winansi"); + + PDF_set_info($p, "Creator", "chartab.pl"); + PDF_set_info($p, "Author", "Thomas Merz"); + PDF_set_info($p, "Title", "Character table (Perl)"); + + # loop over all encodings + for ($page = 0; $page <= $#encodings; $page++) + { + PDF_begin_page($p, 595, 842); # start a new page + + # print the heading and generate the bookmark + $font = PDF_load_font($p, "Helvetica", "winansi", ""); + PDF_setfont($p, $font, FONTSIZE); + $buf = sprintf("%s (%s) %sembedded", + $fontname, $encodings[$page], $embed ? "" : "not "); + + PDF_show_xy($p, $buf, LEFT - XINCR, TOP + 3 * YINCR); + PDF_add_bookmark($p, $buf, 0, 0); + + # print the row and column captions + PDF_setfont($p, $font, 2 * FONTSIZE/3); + + for ($row = 0; $row < 16; $row++) + { + $buf = sprintf("x%X", $row); + PDF_show_xy($p, $buf, LEFT + $row*XINCR, TOP + YINCR); + + $buf = sprintf("%Xx", $row); + PDF_show_xy($p, $buf, LEFT - XINCR, TOP - $row * YINCR); + } + + # print the character table + $font = PDF_load_font($p, $fontname, $encodings[$page], + $embed ? "embedding": ""); + PDF_setfont($p, $font, FONTSIZE); + + $y = TOP; + $x = LEFT; + + for ($row = 0; $row < 16; $row++) + { + for ($col = 0; $col < 16; $col++) { + $buf = sprintf("%c", 16*$row + $col); + PDF_show_xy($p, $buf, $x, $y); + $x += XINCR; + } + $x = LEFT; + $y -= YINCR; + } + + PDF_end_page($p); # close page + } + + + PDF_close($p); # close PDF document + +}; + +if ($@) { + printf("chartab: PDFlib Exception occurred:\n"); + printf(" $@\n"); + exit; +} + +PDF_delete($p); # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/perl/hello.pl b/src/libs/pdflib/bind/pdflib/perl/hello.pl new file mode 100644 index 0000000000..1df38cb738 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/hello.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl +# $Id: hello.pl,v 1.1 2004/10/06 17:46:42 laplace Exp $ +# +# PDFlib client: hello example in Perl +# + +use pdflib_pl 5.0; + +# create a new PDFlib object +$p = PDF_new(); + +eval { + # open new PDF file + if (PDF_open_file($p, "hello.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + # This line is required to avoid problems on Japanese systems + PDF_set_parameter($p, "hypertextencoding", "winansi"); + + PDF_set_info($p, "Creator", "hello.pl"); + PDF_set_info($p, "Author", "Thomas Merz"); + PDF_set_info($p, "Title", "Hello world (Perl)!"); + + PDF_begin_page($p, 595, 842); # start a new page + + $font = PDF_load_font($p, "Helvetica-Bold", "winansi", ""); + + PDF_setfont($p, $font, 24.0); + PDF_set_text_pos($p, 50, 700); + PDF_show($p, "Hello world!"); + PDF_continue_text($p, "(says Perl)"); + PDF_end_page($p); # close page + + PDF_close($p); # close PDF document +}; + +if ($@) { + printf("hello: PDFlib Exception occurred:\n"); + printf(" $@\n"); + exit; +} + +PDF_delete($p); # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/perl/image.pl b/src/libs/pdflib/bind/pdflib/perl/image.pl new file mode 100644 index 0000000000..52f3d935d9 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/image.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl +# $Id: image.pl,v 1.1 2004/10/06 17:46:42 laplace Exp $ +# +# PDFlib client: image example in Perl +# + +use pdflib_pl 5.0; + +# This is where font/image/PDF input files live. Adjust as necessary. +$searchpath = "../data"; +$imagefile = "nesrin.jpg"; + +$p = PDF_new(); + +eval { + if (PDF_open_file($p, "image.pdf") == -1){ + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + PDF_set_parameter($p, "SearchPath", $searchpath); + + # This line is required to avoid problems on Japanese systems + PDF_set_parameter($p, "hypertextencoding", "winansi"); + + PDF_set_info($p, "Creator", "image.pl"); + PDF_set_info($p, "Author", "Thomas Merz"); + PDF_set_info($p, "Title", "image sample (Perl)"); + + + $image = PDF_load_image($p, "auto", $imagefile, ""); + die "Couldn't open image '$imagefile'" if ($image == -1); + + # dummy page size, will be adjusted by PDF_fit_image() + PDF_begin_page($p, 10, 10); + PDF_fit_image($p, $image, 0, 0, "adjustpage"); + PDF_close_image($p, $image); + PDF_end_page($p); # close page + + PDF_close($p); # close PDF document +}; +if ($@) { + printf("image: PDFlib Exception occurred:\n"); + printf(" $@\n"); + exit; +} + +PDF_delete($p); # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/perl/invoice.pl b/src/libs/pdflib/bind/pdflib/perl/invoice.pl new file mode 100644 index 0000000000..e4d01937b6 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/invoice.pl @@ -0,0 +1,156 @@ +#!/usr/bin/perl +# $Id: invoice.pl,v 1.1 2004/10/06 17:46:42 laplace Exp $ +# +# PDFlib client: invoice generation demo +# + +use pdflib_pl 5.0; + +$col1 = 55; +$col2 = 100; +$col3 = 330; +$col4 = 430; +$col5 = 530; +$fontsize = 12; +$pagewidth = 595; +$pageheight = 842; +$fontsize = 12; +$infile = "stationery.pdf"; +# This is where font/image/PDF input files live. Adjust as necessary. +$searchpath = "../data"; +$closingtext = + "30 days warranty starting at the day of sale. " . + "This warranty covers defects in workmanship only. " . + "Kraxi Systems, Inc. will, at its option, repair or replace the " . + "product under the warranty. This warranty is not transferable. " . + "No returns or exchanges will be accepted for wet products."; + +@data = ( {name=>"Super Kite", price=>20, quantity=>2}, + {name=>"Turbo Flyer", price=>40, quantity=>5}, + {name=>"Giga Trasch", price=>180, quantity=>1}, + {name=>"Bare Bone Kit", price=>50, quantity=>3}, + {name=>"Nitty Gritty", price=>20, quantity=>10}, + {name=>"Pretty Dark Flyer", price=>75, quantity=>1}, + {name=>"Free Gift", price=>0, quantity=>1} + ); + +@months = ( "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December"); + +# create a new PDFlib object +$p = PDF_new(); + +eval { + # open new PDF file + if (PDF_open_file($p, "invoice.pdf") == -1){ + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + PDF_set_parameter($p, "SearchPath", $searchpath); + + # This line is required to avoid problems on Japanese systems + PDF_set_parameter($p, "hypertextencoding", "winansi"); + + PDF_set_info($p, "Creator", "invoice.pl"); + PDF_set_info($p, "Author", "Thomas Merz"); + PDF_set_info($p, "Title", "PDFlib invoice generation demo (Perl)"); + + $form = PDF_open_pdi($p, $infile, "", 0); + if ($form == -1){ + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + $page = PDF_open_pdi_page($p, $form, 1, ""); + if ($page == -1){ + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + + $boldfont = PDF_load_font($p, "Helvetica-Bold", "winansi", ""); + $regularfont = PDF_load_font($p, "Helvetica", "winansi", ""); + $leading = $fontsize + 2; + + # Establish coordinates with the origin in the upper left corner. + PDF_set_parameter($p, "topdown", "true"); + + PDF_begin_page($p, $pagewidth, $pageheight); # A4 page + + PDF_fit_pdi_page($p, $page, 0, $pageheight, ""); + PDF_close_pdi_page($p, $page); + + PDF_setfont($p, $regularfont, $fontsize); + + # print the address + $y = 170; + PDF_set_value($p, "leading", $leading); + + PDF_show_xy($p, "John Q. Doe", $col1, $y); + PDF_continue_text($p, "255 Customer Lane"); + PDF_continue_text($p, "Suite B"); + PDF_continue_text($p, "12345 User Town"); + PDF_continue_text($p, "Everland"); + + # print the header and date + + PDF_setfont($p, $boldfont, $fontsize); + $y = 300; + PDF_show_xy($p, "INVOICE", $col1, $y); + + $buf = sprintf("%s %d, %d", $months[(localtime)[4]], (localtime)[3], + (localtime)[5]+1900); + PDF_fit_textline($p, $buf, $col5, $y, "position {100 0}"); + + + # print the invoice header line + PDF_setfont($p, $boldfont, $fontsize); + + # "position {0 0}" is left-aligned, "position {100 0}" right-aligned + $y = 370; + PDF_fit_textline($p, "ITEM", $col1, $y, "position {0 0}"); + PDF_fit_textline($p, "DESCRIPTION", $col2, $y, "position {0 0}"); + PDF_fit_textline($p, "QUANTITY", $col3, $y, "position {100 0}"); + PDF_fit_textline($p, "PRICE", $col4, $y, "position {100 0}"); + PDF_fit_textline($p, "AMOUNT", $col5, $y, "position {100 0}"); + + PDF_setfont($p, $regularfont, $fontsize); + $y += 2*$leading; + $total = 0; + for ($i = 0; $i <= $#data; $i++){ + PDF_show_xy($p, $i+1, $col1, $y); + + PDF_show_xy($p, $data[$i]{name}, $col2, $y); + PDF_fit_textline($p, $data[$i]{quantity}, $col3, $y, "position {100 0}"); + PDF_fit_textline($p, $data[$i]{price}, $col4, $y, "position {100 0}"); + $sum = $data[$i]{price}*$data[$i]{quantity}; + $buf = sprintf("%.2f", $sum); + PDF_fit_textline($p, $buf, $col5, $y, "position {100 0}"); + $y += $leading; + $total +=$sum; + } + + $y += $leading; + PDF_setfont($p, $boldfont, $fontsize); + PDF_fit_textline($p,sprintf("%.2f",$total), $col5, $y, "position {100 0}"); + + # Print the closing text + + $y +=5*$leading; + PDF_setfont($p, $regularfont, $fontsize); + PDF_set_value($p, "leading", $leading); + PDF_show_boxed($p, $closingtext, + $col1, $y + 4*$leading, $col5-$col1, 4*$leading, "justify", ""); + + PDF_end_page($p); + PDF_close($p); + PDF_close_pdi($p, $form); +}; +if ($@) { + printf("invoice: PDFlib Exception occurred:\n"); + printf(" $@\n"); + exit; +} + +PDF_delete($p); diff --git a/src/libs/pdflib/bind/pdflib/perl/pdfclock.cgi.pl b/src/libs/pdflib/bind/pdflib/perl/pdfclock.cgi.pl new file mode 100644 index 0000000000..cbd83b080c --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/pdfclock.cgi.pl @@ -0,0 +1,103 @@ +#!/usr/bin/perl +# $Id: pdfclock.cgi.pl,v 1.1 2004/10/06 17:46:42 laplace Exp $ +# +# PDFlib client: pdfclock CGI example in Perl +# + +use pdflib_pl 5.0; + +$RADIUS = 200.0; +$MARGIN = 20.0; + +$p = PDF_new(); + +PDF_open_file($p, ""); + +# This line is required to avoid problems on Japanese systems +PDF_set_parameter($p, "hypertextencoding", "winansi"); + +PDF_set_info($p, "Creator", "pdfclock.cgi.pl"); +PDF_set_info($p, "Author", "Thomas Merz"); +PDF_set_info($p, "Title", "PDF clock (Perl/CGI)"); + +PDF_begin_page($p, 2 * ($RADIUS + $MARGIN), 2 * ($RADIUS + $MARGIN)); + +PDF_translate($p, $RADIUS + $MARGIN, $RADIUS + $MARGIN); +PDF_setcolor($p, "fillstroke", "rgb", 0.0, 0.0, 1.0, 0.0); +PDF_save($p); + +# minute strokes +PDF_setlinewidth($p, 2.0); +for ($alpha = 0; $alpha < 360; $alpha += 6) +{ + PDF_rotate($p, 6.0); + PDF_moveto($p, $RADIUS, 0.0); + PDF_lineto($p, $RADIUS-$MARGIN/3, 0.0); + PDF_stroke($p); +} + +PDF_restore($p); +PDF_save($p); + +# 5 minute strokes +PDF_setlinewidth($p, 3.0); +for ($alpha = 0; $alpha < 360; $alpha += 30) +{ + PDF_rotate($p, 30.0); + PDF_moveto($p, $RADIUS, 0.0); + PDF_lineto($p, $RADIUS-$MARGIN, 0.0); + PDF_stroke($p); +} + +($tm_sec,$tm_min,$tm_hour) = localtime(time); + +# draw hour hand +PDF_save($p); +PDF_rotate($p, (-(($tm_min/60.0) + $tm_hour - 3.0) * 30.0)); +PDF_moveto($p, -$RADIUS/10, -$RADIUS/20); +PDF_lineto($p, $RADIUS/2, 0.0); +PDF_lineto($p, -$RADIUS/10, $RADIUS/20); +PDF_closepath($p); +PDF_fill($p); +PDF_restore($p); + +# draw minute hand +PDF_save($p); +PDF_rotate($p, (-(($tm_sec/60.0) + $tm_min - 15.0) * 6.0)); +PDF_moveto($p, -$RADIUS/10, -$RADIUS/20); +PDF_lineto($p, $RADIUS * 0.8, 0.0); +PDF_lineto($p, -$RADIUS/10, $RADIUS/20); +PDF_closepath($p); +PDF_fill($p); +PDF_restore($p); + +# draw second hand +PDF_setcolor($p, "fillstroke", "rgb", 1.0, 0.0, 0.0, 0.0); +PDF_setlinewidth($p, 2); +PDF_save($p); +PDF_rotate($p, -(($tm_sec - 15.0) * 6.0)); +PDF_moveto($p, -$RADIUS/5, 0.0); +PDF_lineto($p, $RADIUS, 0.0); +PDF_stroke($p); +PDF_restore($p); + +# draw little circle at center +PDF_circle($p, 0, 0, $RADIUS/30); +PDF_fill($p); + +PDF_restore($p); +PDF_end_page($p); + +PDF_close($p); + +$buf = PDF_get_buffer($p); + +# the following is required on Windows systems +binmode(STDOUT); + +print "Content-Type: application/pdf\n"; +print "Content-Length: " . length($buf) . "\n"; +print "Content-Disposition: inline; filename=" . "pdfclock.cgi.pl.pdf" . "\n\n"; +print $buf; + +PDF_delete($p); diff --git a/src/libs/pdflib/bind/pdflib/perl/pdfclock.pl b/src/libs/pdflib/bind/pdflib/perl/pdfclock.pl new file mode 100644 index 0000000000..297bd4d883 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/pdfclock.pl @@ -0,0 +1,103 @@ +#!/usr/bin/perl +# $Id: pdfclock.pl,v 1.1 2004/10/06 17:46:42 laplace Exp $ +# +# PDFlib client: pdfclock example in Perl +# + +use pdflib_pl 5.0; + +$RADIUS = 200.0; +$MARGIN = 20.0; + +$p = PDF_new(); +eval{ + if (PDF_open_file($p, "pdfclock.pdf") == -1){ + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + # This line is required to avoid problems on Japanese systems + PDF_set_parameter($p, "hypertextencoding", "winansi"); + + PDF_set_info($p, "Creator", "pdfclock.pl"); + PDF_set_info($p, "Author", "Thomas Merz"); + PDF_set_info($p, "Title", "PDF clock (Perl)"); + + PDF_begin_page($p, 2 * ($RADIUS + $MARGIN), 2 * ($RADIUS + $MARGIN)); + + PDF_translate($p, $RADIUS + $MARGIN, $RADIUS + $MARGIN); + PDF_setcolor($p, "fillstroke", "rgb", 0.0, 0.0, 1.0, 0.0); + PDF_save($p); + + # minute strokes + PDF_setlinewidth($p, 2.0); + for ($alpha = 0; $alpha < 360; $alpha += 6) + { + PDF_rotate($p, 6.0); + PDF_moveto($p, $RADIUS, 0.0); + PDF_lineto($p, $RADIUS-$MARGIN/3, 0.0); + PDF_stroke($p); + } + + PDF_restore($p); + PDF_save($p); + + # 5 minute strokes + PDF_setlinewidth($p, 3.0); + for ($alpha = 0; $alpha < 360; $alpha += 30) + { + PDF_rotate($p, 30.0); + PDF_moveto($p, $RADIUS, 0.0); + PDF_lineto($p, $RADIUS-$MARGIN, 0.0); + PDF_stroke($p); + } + + ($tm_sec,$tm_min,$tm_hour) = localtime(time); + + # draw hour hand + PDF_save($p); + PDF_rotate($p, (-(($tm_min/60.0) + $tm_hour - 3.0) * 30.0)); + PDF_moveto($p, -$RADIUS/10, -$RADIUS/20); + PDF_lineto($p, $RADIUS/2, 0.0); + PDF_lineto($p, -$RADIUS/10, $RADIUS/20); + PDF_closepath($p); + PDF_fill($p); + PDF_restore($p); + + # draw minute hand + PDF_save($p); + PDF_rotate($p, (-(($tm_sec/60.0) + $tm_min - 15.0) * 6.0)); + PDF_moveto($p, -$RADIUS/10, -$RADIUS/20); + PDF_lineto($p, $RADIUS * 0.8, 0.0); + PDF_lineto($p, -$RADIUS/10, $RADIUS/20); + PDF_closepath($p); + PDF_fill($p); + PDF_restore($p); + + # draw second hand + PDF_setcolor($p, "fillstroke", "rgb", 1.0, 0.0, 0.0, 0.0); + PDF_setlinewidth($p, 2); + PDF_save($p); + PDF_rotate($p, -(($tm_sec - 15.0) * 6.0)); + PDF_moveto($p, -$RADIUS/5, 0.0); + PDF_lineto($p, $RADIUS, 0.0); + PDF_stroke($p); + PDF_restore($p); + + # draw little circle at center + PDF_circle($p, 0, 0, $RADIUS/30); + PDF_fill($p); + + PDF_restore($p); + PDF_end_page($p); + + PDF_close($p); + +}; +if ($@) { + printf("pdfclock: PDFlib Exception occurred:\n"); + printf(" $@\n"); + exit; +} + +PDF_delete($p); # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/perl/pdflib_pl.c b/src/libs/pdflib/bind/pdflib/perl/pdflib_pl.c new file mode 100644 index 0000000000..5cccef574f --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/pdflib_pl.c @@ -0,0 +1,3614 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdflib_pl.c,v 1.1 2004/10/06 17:46:42 laplace Exp $ + * + * Wrapper code for the PDFlib Perl binding + * + * in sync with pdflib.h 1.151.2.22 + * + */ + +/* + * The PERL_OBJECT #define is only required for ActivePerl < 5.6 + * + * IMPORTANT: in this case the code must be compiled in C++ mode! + */ +#if defined(WIN32) && \ + defined(PERL_REVISION) && defined(PERL_VERSION) && \ + PERL_REVISION == 5 && PERL_VERSION < 6 +#define PERL_OBJECT +#endif + +#ifdef __cplusplus +#include +#include + +extern "C" { +#endif /* __cplusplus */ + +#undef DEBUG +#include +#include +#include +#undef free +#undef malloc +#include + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +/* Compilers which are not strictly ANSI conforming can set PDF_VOLATILE + * to an empty value. + */ +#ifndef PDF_VOLATILE +#define PDF_VOLATILE volatile +#endif + +/* Definitions for compiling Perl extensions on a variety of machines */ + +#if defined(WIN32) || defined(__WIN32__) +# if defined(_MSC_VER) +# define SWIGEXPORT(a,b) __declspec(dllexport) a b +# else +# if defined(__BORLANDC__) +# define SWIGEXPORT(a,b) a _export b +# else +# define SWIGEXPORT(a,b) a b +# endif +# endif +#else +# define SWIGEXPORT(a,b) a b +#endif + +/* #defines for older Perl versions < 5.005_50 */ +#if !defined(PERL_REVISION) || \ + ((PERL_REVISION >= 5) && \ + ((PERL_VERSION<5) || ((PERL_VERSION==5) && (PERL_SUBVERSION<50)))) +#ifndef PL_sv_yes +#define PL_sv_yes sv_yes +#endif +#ifndef PL_na +#define PL_na na +#endif +#endif + +#ifdef PERL_OBJECT +#define MAGIC_PPERL CPerlObj *pPerl = (CPerlObj *) this; +#define MAGIC_CAST (int (CPerlObj::*)(SV *, MAGIC *)) +#define SWIGCLASS_STATIC +#else +#define MAGIC_PPERL +#define MAGIC_CAST +#define SWIGCLASS_STATIC static +#endif + +#include + +#ifdef SWIG_GLOBAL +#ifdef __cplusplus +#define SWIGSTATIC extern "C" +#else +#define SWIGSTATIC +#endif +#endif + +#ifndef SWIGSTATIC +#define SWIGSTATIC static +#endif + +typedef struct SwigPtrType { + char *name; + int len; + void *(*cast)(void *); + struct SwigPtrType *next; +} SwigPtrType; + +/* Pointer cache structure */ +typedef struct { + int stat; /* Status (valid) bit */ + SwigPtrType *tp; /* Pointer to type structure */ + char name[256]; /* Given datatype name */ + char mapped[256]; /* Equivalent name */ +} SwigCacheType; + +static int SwigPtrMax = 64; /* Max entries that can be currently held */ +static int SwigPtrN = 0; /* Current number of entries */ +static int SwigPtrSort = 0; /* Status flag indicating sort */ +static SwigPtrType *SwigPtrTable = 0; /* Table containing pointer equivalences */ +static int SwigStart[256]; /* Table containing starting positions */ + +/* Cached values */ +#define SWIG_CACHESIZE 8 +#define SWIG_CACHEMASK 0x7 +static SwigCacheType SwigCache[SWIG_CACHESIZE]; +static int SwigCacheIndex = 0; +static int SwigLastCache = 0; + +/* Sort comparison function */ +static int swigsort(const void *data1, const void *data2) { + SwigPtrType *d1 = (SwigPtrType *) data1; + SwigPtrType *d2 = (SwigPtrType *) data2; + return strcmp(d1->name,d2->name); +} + +/* Binary Search function */ +static int swigcmp(const void *key, const void *data) { + char *k = (char *) key; + SwigPtrType *d = (SwigPtrType *) data; + return strncmp(k,d->name,d->len); +} + +/* Register a new datatype with the type-checker */ + +#ifndef PERL_OBJECT +SWIGSTATIC +void SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *)) { +#else +SWIGSTATIC +#define SWIG_RegisterMapping(a,b,c) _SWIG_RegisterMapping(pPerl, a,b,c) +void _SWIG_RegisterMapping(CPerlObj *pPerl, char *origtype, char *newtype, void *(*cast)(void *)) { +#endif + + int i; + SwigPtrType *t = 0, *t1; + + if (!SwigPtrTable) { + SwigPtrTable = (SwigPtrType *) malloc(SwigPtrMax*sizeof(SwigPtrType)); + SwigPtrN = 0; + } + if (SwigPtrN >= SwigPtrMax) { + SwigPtrMax = 2*SwigPtrMax; + SwigPtrTable = (SwigPtrType *) realloc(SwigPtrTable,SwigPtrMax*sizeof(SwigPtrType)); + } + for (i = 0; i < SwigPtrN; i++) + if (strcmp(SwigPtrTable[i].name,origtype) == 0) { + t = &SwigPtrTable[i]; + break; + } + if (!t) { + t = &SwigPtrTable[SwigPtrN]; + t->name = origtype; + t->len = strlen(t->name); + t->cast = 0; + t->next = 0; + SwigPtrN++; + } + while (t->next) { + if (strcmp(t->name,newtype) == 0) { + if (cast) t->cast = cast; + return; + } + t = t->next; + } + t1 = (SwigPtrType *) malloc(sizeof(SwigPtrType)); + t1->name = newtype; + t1->len = strlen(t1->name); + t1->cast = cast; + t1->next = 0; + t->next = t1; + SwigPtrSort = 0; +} + +/* Function for getting a pointer value */ + +#ifndef PERL_OBJECT +SWIGSTATIC +char *SWIG_GetPtr(SV *sv, void **ptr, char *_t) +#else +SWIGSTATIC +#define SWIG_GetPtr(a,b,c) _SWIG_GetPtr(pPerl,a,b,c) +char *_SWIG_GetPtr(CPerlObj *pPerl, SV *sv, void **ptr, char *_t) +#endif +{ + char temp_type[256]; + char *name,*_c; + int len,i,start,end; + IV tmp = 0; + SwigPtrType *sp,*tp; + SwigCacheType *cache; + + /* If magical, apply more magic */ + + if (SvGMAGICAL(sv)) + mg_get(sv); + + /* Check to see if this is an object */ + if (sv_isobject(sv)) { + SV *tsv = (SV*) SvRV(sv); + if ((SvTYPE(tsv) == SVt_PVHV)) { + MAGIC *mg; + if (SvMAGICAL(tsv)) { + mg = mg_find(tsv,'P'); + if (mg) { + SV *rsv = mg->mg_obj; + if (sv_isobject(rsv)) { + tmp = SvIV((SV*)SvRV(rsv)); + } + } + } else { + return "Not a valid pointer value"; + } + } else { + tmp = SvIV((SV*)SvRV(sv)); + } + if (!_t) { + *(ptr) = (void *) tmp; + return (char *) 0; + } + } else if (! SvOK(sv)) { /* Check for undef */ + *(ptr) = (void *) 0; + return (char *) 0; + } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ + *(ptr) = (void *) 0; + if (!SvROK(sv)) + return (char *) 0; + else + return "Not a valid pointer value"; + } else { /* Don't know what it is */ + *(ptr) = (void *) 0; + return "Not a valid pointer value"; + } + if (_t) { + /* Now see if the types match */ + + if (!sv_isa(sv,_t)) { + _c = HvNAME(SvSTASH(SvRV(sv))); + if (!SwigPtrSort) { + qsort((void *) SwigPtrTable, SwigPtrN, sizeof(SwigPtrType), swigsort); + for (i = 0; i < 256; i++) { + SwigStart[i] = SwigPtrN; + } + for (i = SwigPtrN-1; i >= 0; i--) { + SwigStart[(int) SwigPtrTable[i].name[0]] = i; + } + for (i = 255; i >= 1; i--) { + if (SwigStart[i-1] > SwigStart[i]) + SwigStart[i-1] = SwigStart[i]; + } + SwigPtrSort = 1; + for (i = 0; i < SWIG_CACHESIZE; i++) + SwigCache[i].stat = 0; + } + /* First check cache for matches. Uses last cache value as starting point */ + cache = &SwigCache[SwigLastCache]; + for (i = 0; i < SWIG_CACHESIZE; i++) { + if (cache->stat) { + if (strcmp(_t,cache->name) == 0) { + if (strcmp(_c,cache->mapped) == 0) { + cache->stat++; + *ptr = (void *) tmp; + if (cache->tp->cast) *ptr = (*(cache->tp->cast))(*ptr); + return (char *) 0; + } + } + } + SwigLastCache = (SwigLastCache+1) & SWIG_CACHEMASK; + if (!SwigLastCache) cache = SwigCache; + else cache++; + } + + start = SwigStart[(int) _t[0]]; + end = SwigStart[_t[0]+1]; + sp = &SwigPtrTable[start]; + while (start < end) { + if (swigcmp(_t,sp) == 0) break; + sp++; + start++; + } + if (start >= end) sp = 0; + if (sp) { + while (swigcmp(_t,sp) == 0) { + name = sp->name; + len = sp->len; + tp = sp->next; + while(tp) { + if (tp->len >= 255) { + return _c; + } + strcpy(temp_type,tp->name); + strncat(temp_type,_t+len,255-tp->len); + if (sv_isa(sv,temp_type)) { + /* Get pointer value */ + *ptr = (void *) tmp; + if (tp->cast) *ptr = (*(tp->cast))(*ptr); + + strcpy(SwigCache[SwigCacheIndex].mapped,_c); + strcpy(SwigCache[SwigCacheIndex].name,_t); + SwigCache[SwigCacheIndex].stat = 1; + SwigCache[SwigCacheIndex].tp = tp; + SwigCacheIndex = SwigCacheIndex & SWIG_CACHEMASK; + return (char *) 0; + } + tp = tp->next; + } + /* Hmmm. Didn't find it this time */ + sp++; + } + } + /* Didn't find any sort of match for this data. + Get the pointer value and return the received type */ + *ptr = (void *) tmp; + return _c; + } else { + /* Found a match on the first try. Return pointer value */ + *ptr = (void *) tmp; + return (char *) 0; + } + } + *ptr = (void *) tmp; + return (char *) 0; +} + +#ifdef __cplusplus +extern "C" +#endif +#ifndef PERL_OBJECT +/* If we don't use the XS macro it doesn't work with all Perl configurations */ +SWIGEXPORT(/* */, XS(boot_pdflib_pl)); +#else +SWIGEXPORT(void,boot_pdflib_pl)(CV *cv, CPerlObj *pPerl); +#endif + +#include + +/* The following sick stuff is an attempt to make recent Perl versions + * work with recent SWIG versions compiled with recent MS VC++ versions. + */ +#ifdef _MSC_VER + #undef setjmp + #define setjmp _setjmp + #undef longjmp +#endif + +#include "pdflib.h" + +/* exception handling is currently not thread-safe! */ +#define SWIG_exception(msg) croak(msg) +static jmp_buf exception_buffer; +static int exception_status; +static char error_message[1024]; + +/* Exception handling */ +#define try if ((exception_status = setjmp(exception_buffer)) == 0) +#define catch(error) else if (exception_status == error) +#define throw(error) longjmp(exception_buffer, error) + +/* PDFlib error handler */ + +static void +pdf_swig_errorhandler(PDF *p, int errortype, const char* shortmsg) +{ + sprintf(error_message, "PDFlib Error %s\n", shortmsg); + + /* Issue a warning message and continue for non-fatal errors */ + if (errortype == PDF_NonfatalError) { + fprintf(stderr, error_message); + return; + } + + /* ...and throw an exception */ + throw(errortype); +} + +/* export the PDFlib routines to the shared library */ +#ifdef __MWERKS__ +#pragma export on +#endif + +/* p_annots.c */ +XS(_wrap_PDF_add_launchlink) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * PDF_VOLATILE _arg5; + dXSARGS ; + + if (items != 6) + croak("Usage: PDF_add_launchlink(p, llx, lly, urx, ury, filename);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_add_launchlink. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (char *) SvPV(ST(5),PL_na); + + try { PDF_add_launchlink(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_add_locallink) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + int PDF_VOLATILE _arg5; + char * PDF_VOLATILE _arg6; + dXSARGS ; + + if (items != 7) + croak("Usage: PDF_add_locallink(p, llx, lly, urx, ury, page, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_add_locallink. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (int )SvIV(ST(5)); + _arg6 = (char *) SvPV(ST(6),PL_na); + + try { PDF_add_locallink(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_add_note) { + PDF * p; + float llx; + float lly; + float urx; + float ury; + char * PDF_VOLATILE contents; + size_t len_cont; + char * PDF_VOLATILE title; + size_t len_title; + char * PDF_VOLATILE icon; + int PDF_VOLATILE open; + dXSARGS ; + + if (items != 9) + croak("Usage: PDF_add_note(p, llx, lly, urx, ury, contents, title, icon, open);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_add_note. Expected PDFPtr."); + XSRETURN(1); + } + llx = (float ) SvNV(ST(1)); + lly = (float ) SvNV(ST(2)); + urx = (float ) SvNV(ST(3)); + ury = (float ) SvNV(ST(4)); + contents = (char *) SvPV(ST(5),len_cont); + title = (char *) SvPV(ST(6),len_title); + icon = (char *) SvPV(ST(7),PL_na); + open = (int )SvIV(ST(8)); + + try { PDF_add_note2(p,llx,lly,urx,ury,contents,(int)len_cont,title,(int)len_title,icon,open); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_add_pdflink) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * PDF_VOLATILE _arg5; + int PDF_VOLATILE _arg6; + char * PDF_VOLATILE _arg7; + dXSARGS ; + + if (items != 8) + croak("Usage: PDF_add_pdflink(p, llx, lly, urx, ury, filename, page, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_add_pdflink. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (char *) SvPV(ST(5),PL_na); + _arg6 = (int )SvIV(ST(6)); + _arg7 = (char *) SvPV(ST(7),PL_na); + + try { PDF_add_pdflink(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_add_weblink) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * PDF_VOLATILE _arg5; + dXSARGS ; + + if (items != 6) + croak("Usage: PDF_add_weblink(p, llx, lly, urx, ury, url);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_add_weblink. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (char *) SvPV(ST(5),PL_na); + + try { PDF_add_weblink(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_attach_file) { + PDF * p; + float llx; + float lly; + float urx; + float ury; + char * PDF_VOLATILE filename; + char * PDF_VOLATILE description; + size_t len_descr; + char * PDF_VOLATILE author; + size_t len_auth; + char * PDF_VOLATILE mimetype; + char * PDF_VOLATILE icon; + dXSARGS ; + + if (items != 10) + croak("Usage: PDF_attach_file(p, llx, lly, urx, ury, filename, description, author, mimetype, icon);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_attach_file. Expected PDFPtr."); + XSRETURN(1); + } + llx = (float ) SvNV(ST(1)); + lly = (float ) SvNV(ST(2)); + urx = (float ) SvNV(ST(3)); + ury = (float ) SvNV(ST(4)); + filename = (char *) SvPV(ST(5),PL_na); + description = (char *) SvPV(ST(6),len_descr); + author = (char *) SvPV(ST(7),len_auth); + mimetype = (char *) SvPV(ST(8),PL_na); + icon = (char *) SvPV(ST(9),PL_na); + + try { PDF_attach_file2(p,llx,lly,urx,ury,filename,0,description,(int) len_descr,author,(int) len_auth,mimetype,icon); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_set_border_color) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_set_border_color(p, red, green, blue);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_set_border_color. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + + try { PDF_set_border_color(_arg0,_arg1,_arg2,_arg3); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_set_border_dash) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_set_border_dash(p, w, b);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_set_border_dash. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_set_border_dash(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_set_border_style) { + PDF * _arg0; + char * PDF_VOLATILE _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_set_border_style(p, style, width);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_set_border_style. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_set_border_style(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +/* p_basic.c */ +XS(_wrap_PDF_begin_page) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_begin_page(p, width, height);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_begin_page. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_begin_page(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_close) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_close(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_close. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_close(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_delete) { + PDF * p; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_delete(p);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_delete. Expected PDFPtr."); + XSRETURN(1); + } + + /* no try catch here */ + PDF_delete(p); + + XSRETURN(0); +} + +XS(_wrap_PDF_end_page) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_end_page(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_end_page. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_end_page(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_get_apiname) { + char * _result; + PDF * _arg0; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_get_apiname(p);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_get_apiname. Expected PDFPtr."); + XSRETURN(1); + } + + try { + _result = (char *)PDF_get_apiname(_arg0); + } else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setpv((SV*)ST(argvi++),(char *) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_get_buffer) { + const char * _result; + PDF * _arg0; + long size; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_get_buffer(p);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0, "PDFPtr")) { + croak("Type error in argument 1 of PDF_get_buffer. Expected PDFPtr."); + XSRETURN(1); + } + + try { _result = (char *)PDF_get_buffer(_arg0, &size); + } + else { + SWIG_exception(error_message); + } + + ST(0) = sv_newmortal(); + sv_setpvn((SV*)ST(0), (char *) _result, size); + XSRETURN(1); +} + +XS(_wrap_PDF_get_errmsg) { + char * _result; + PDF * _arg0; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_get_errmsg(p);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_get_errmsg. Expected PDFPtr."); + XSRETURN(1); + } + + try { + _result = (char *)PDF_get_errmsg(_arg0); + } else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setpv((SV*)ST(argvi++),(char *) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_get_errnum) { + int _result; + PDF * _arg0; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_get_errnum(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_get_errnum. Expected PDFPtr."); + XSRETURN(1); + } + + try { _result = (int )PDF_get_errnum(_arg0); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_new) { + PDF * _result; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + char versionbuf[32]; + + if (items != 0) + croak("Usage: PDF_new();"); + + try { + _result = (PDF*)PDF_new2(pdf_swig_errorhandler, NULL, NULL, NULL, NULL); + + if (_result) { +#if defined(ACTIVEPERL_VERSION) + sprintf(versionbuf, "ASperl %s", PERLFILEVERSION); +#elif defined(PERL_REVISION) && defined(PERL_VERSION) && defined(PERL_SUBVERSION) + sprintf(versionbuf, "Perl %d.%d.%d", + PERL_REVISION, PERL_VERSION, PERL_SUBVERSION); +#else + sprintf(versionbuf, "Perl"); +#endif + PDF_set_parameter(_result, "binding", versionbuf); + } else { + SWIG_exception("PDF_new: internal error"); + } + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setref_pv(ST(argvi++),"PDFPtr", (void *) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_open_file) { + int _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_open_file(p,filename);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_open_file. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + + try { _result = (int )PDF_open_file(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +/* p_block.c */ + +XS(_wrap_PDF_fill_imageblock) { + int _result; + PDF * p; + int PDF_VOLATILE page; + char * PDF_VOLATILE blockname; + int PDF_VOLATILE image; + char * PDF_VOLATILE optlist; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_fill_imageblock(p, page, blockname, image, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_fill_imageblock. Expected PDFPtr."); + XSRETURN(1); + } + page = (int )SvIV(ST(1)); + blockname = (char *) SvPV(ST(2),PL_na); + image = (int )SvIV(ST(3)); + optlist = (char *) SvPV(ST(4),PL_na); + + try { _result = (int )PDF_fill_imageblock(p,page, blockname, image, optlist); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_fill_pdfblock) { + int _result; + PDF * p; + int PDF_VOLATILE page; + char * PDF_VOLATILE blockname; + int PDF_VOLATILE contents; + char * PDF_VOLATILE optlist; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_fill_pdfblock(p, page, blockname, contents, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_fill_pdfblock. Expected PDFPtr."); + XSRETURN(1); + } + page = (int )SvIV(ST(1)); + blockname = (char *) SvPV(ST(2),PL_na); + contents = (int )SvIV(ST(3)); + optlist = (char *) SvPV(ST(4),PL_na); + + try { _result = (int )PDF_fill_pdfblock(p,page, blockname, contents, optlist); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_fill_textblock) { + int _result; + PDF * p; + int PDF_VOLATILE page; + char * PDF_VOLATILE blockname; + char * PDF_VOLATILE text; + size_t len; + char * PDF_VOLATILE optlist; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_fill_textblock(p, page, blockname, text, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_fill_textblock. Expected PDFPtr."); + XSRETURN(1); + } + page = (int )SvIV(ST(1)); + blockname = (char *) SvPV(ST(2),PL_na); + text = (char *) SvPV(ST(3),len); + optlist = (char *) SvPV(ST(4),PL_na); + + try { _result = (int )PDF_fill_textblock(p,page, blockname, text, len, optlist); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + + +/* p_color.c */ + +XS(_wrap_PDF_makespotcolor) { + int _result; + PDF * p; + char * PDF_VOLATILE spotname; + int PDF_VOLATILE reserved = 0; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + /* to be compatible to old buggy version we allow two or three parameters */ + if (items != 3 && items != 2) + croak("Usage: PDF_makespotcolor(p, spotname);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_makespotcolor. Expected PDFPtr."); + XSRETURN(1); + } + spotname = (char *) SvPV(ST(1),PL_na); + /* Ignore "reserved" parameter, was buggy in V4 wrapper, V5 need 0 */ + /* reserved = (int )SvIV(ST(2)); */ + + try { _result = (int )PDF_makespotcolor(p, spotname, reserved); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_setcolor) { + PDF * _arg0; + char * PDF_VOLATILE _arg1; + char * PDF_VOLATILE _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + int argvi = 0; + dXSARGS ; + + if (items != 7) + croak("Usage: PDF_setcolor(p, fstype, colorspace, c1, c2, c3, c4);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setcolor. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (char *) SvPV(ST(2),PL_na); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (float ) SvNV(ST(5)); + _arg6 = (float ) SvNV(ST(6)); + + try { PDF_setcolor(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(argvi); +} + +XS(_wrap_PDF_setgray) { + PDF * _arg0; + float _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setgray(p, gray);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setgray. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + + try { PDF_setcolor(_arg0, "fillstroke", "gray", _arg1, 0, 0, 0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setgray_fill) { + PDF * _arg0; + float _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setgray_fill(p, gray);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setgray_fill. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + + try { PDF_setcolor(_arg0, "fill", "gray", _arg1, 0, 0, 0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setgray_stroke) { + PDF * _arg0; + float _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setgray_stroke(p, gray);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setgray_stroke. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + + try { PDF_setcolor(_arg0, "stroke", "gray", _arg1, 0, 0, 0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setrgbcolor) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_setrgbcolor(p, red, green, blue);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setrgbcolor. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + + try { PDF_setcolor(_arg0, "fillstroke", "rgb", _arg1, _arg2, _arg3,0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setrgbcolor_fill) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_setrgbcolor_fill(p, red, green, blue);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setrgbcolor_fill. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + + try { PDF_setcolor(_arg0, "fill", "rgb", _arg1, _arg2, _arg3, 0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setrgbcolor_stroke) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_setrgbcolor_stroke(p,red,green,blue);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setrgbcolor_stroke. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + + try { PDF_setcolor(_arg0, "stroke", "rgb", _arg1, _arg2, _arg3, 0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +/* p_draw.c */ + +XS(_wrap_PDF_arc) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + dXSARGS ; + + if (items != 6) + croak("Usage: PDF_arc(p, x, y, r, alpha, beta);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_arc. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (float ) SvNV(ST(5)); + + try { PDF_arc(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_arcn) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + int argvi = 0; + dXSARGS ; + + if (items != 6) + croak("Usage: PDF_arcn(p, x, y, r, alpha, beta);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_arcn. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (float ) SvNV(ST(5)); + + try { PDF_arcn(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5); + } + else { + SWIG_exception(error_message); + } + XSRETURN(argvi); +} + +XS(_wrap_PDF_circle) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_circle(p, x, y, r);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_circle. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + + try { PDF_circle(_arg0,_arg1,_arg2,_arg3); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_clip) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_clip(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_clip. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_clip(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_closepath) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_closepath(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_closepath. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_closepath(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_closepath_fill_stroke) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_closepath_fill_stroke(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_closepath_fill_stroke. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_closepath_fill_stroke(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_closepath_stroke) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_closepath_stroke(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_closepath_stroke. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_closepath_stroke(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_curveto) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + dXSARGS ; + + if (items != 7) + croak("Usage: PDF_curveto(p, x1, y1, x2, y2, x3, y3);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_curveto. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (float ) SvNV(ST(5)); + _arg6 = (float ) SvNV(ST(6)); + + try { PDF_curveto(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_endpath) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_endpath(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_endpath. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_endpath(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_fill) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_fill(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_fill. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_fill(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_fill_stroke) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_fill_stroke(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_fill_stroke. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_fill_stroke(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_lineto) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_lineto(p, x, y);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_lineto. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_lineto(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_moveto) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_moveto(p, x, y);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_moveto. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_moveto(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_rect) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_rect(p, x, y, width, height);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_rect. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + + try { PDF_rect(_arg0,_arg1,_arg2,_arg3,_arg4); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_stroke) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_stroke(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_stroke. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_stroke(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +/* p_encoding.c */ + +XS(_wrap_PDF_encoding_set_char) { + PDF * p; + char * PDF_VOLATILE encoding; + int PDF_VOLATILE slot; + char * PDF_VOLATILE glyphname; + int PDF_VOLATILE uv; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_encoding_set_char(p, encoding, slot, glyphname, uv);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_encoding_set_char. Expected PDFPtr."); + XSRETURN(1); + } + + encoding = (char *) SvPV(ST(1),PL_na); + slot = (int )SvIV(ST(2)); + glyphname = (char *) SvPV(ST(3),PL_na); + uv = (int )SvIV(ST(4)); + + try { PDF_encoding_set_char(p, encoding, slot, glyphname, uv); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(0); +} + + +/* p_font.c */ + +XS(_wrap_PDF_findfont) { + int _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + char * PDF_VOLATILE _arg2; + int PDF_VOLATILE _arg3; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_findfont(p, fontname, encoding, embed);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_findfont. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (char *) SvPV(ST(2),PL_na); + _arg3 = (int )SvIV(ST(3)); + + try { _result = (int )PDF_findfont(_arg0,_arg1,_arg2,_arg3); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_load_font) { + int _result; + PDF * p; + char * PDF_VOLATILE fontname; + char * PDF_VOLATILE encoding; + char * PDF_VOLATILE optlist; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_load_font(p, fontname, encoding, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_load_font. Expected PDFPtr."); + XSRETURN(1); + } + fontname = (char *) SvPV(ST(1),PL_na); + encoding = (char *) SvPV(ST(2),PL_na); + optlist = (char *) SvPV(ST(3),PL_na); + + try { _result = (int )PDF_load_font(p, fontname, 0, encoding, optlist); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_setfont) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_setfont(p, font, fontsize);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setfont. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_setfont(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +/* p_gstate.c */ + +XS(_wrap_PDF_concat) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + dXSARGS ; + + if (items != 7) + croak("Usage: PDF_concat(p, a, b, c, d, e, f);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_concat. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (float ) SvNV(ST(5)); + _arg6 = (float ) SvNV(ST(6)); + + try { PDF_concat(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_initgraphics) { + PDF * _arg0; + int argvi = 0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_initgraphics(p);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_initgraphics. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_initgraphics(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(argvi); +} + +XS(_wrap_PDF_restore) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_restore(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_restore. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_restore(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_rotate) { + PDF * _arg0; + float _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_rotate(p, phi);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_rotate. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + + try { PDF_rotate(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_save) { + PDF * _arg0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_save(p);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_save. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_save(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_scale) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_scale(p, sx, sy);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_scale. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_scale(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setdash) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_setdash(p, b, w);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setdash. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_setdash(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setdashpattern) { + PDF * p; + char * PDF_VOLATILE optlist; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setdashpattern(p, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setdashpattern. Expected PDFPtr."); + XSRETURN(1); + } + optlist = (char *) SvPV(ST(1),PL_na); + + try { PDF_setdashpattern(p, optlist); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setflat) { + PDF * _arg0; + float _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setflat(p, flatness);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setflat. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + + try { PDF_setflat(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setlinecap) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setlinecap(p, linecap);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setlinecap. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + + try { PDF_setlinecap(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setlinejoin) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setlinejoin(p, linejoin);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setlinejoin. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + + try { PDF_setlinejoin(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setlinewidth) { + PDF * _arg0; + float _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setlinewidth(p, width);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setlinewidth. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + + try { PDF_setlinewidth(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setmatrix) { + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + int argvi = 0; + dXSARGS ; + + if (items != 7) + croak("Usage: PDF_setmatrix(p, a, b, c, d, e, f);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setmatrix. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (float ) SvNV(ST(5)); + _arg6 = (float ) SvNV(ST(6)); + + try { PDF_setmatrix(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } + else { + SWIG_exception(error_message); + } + XSRETURN(argvi); +} + +XS(_wrap_PDF_setmiterlimit) { + PDF * _arg0; + float _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setmiterlimit(p, miter);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_setmiterlimit. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + + try { PDF_setmiterlimit(_arg0,_arg1); +} + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_setpolydash) { + PDF *p; + SV *val; + AV *av; + float carray[MAX_DASH_LENGTH]; + int PDF_VOLATILE length; + int i; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_setpolydash(p, arrayref);"); + + if (SWIG_GetPtr(ST(0),(void **) &p, "PDFPtr")) { + croak("Type error in argument 1 of PDF_setpolydash. Expected PDFPtr."); + XSRETURN(1); + } + + if (!SvROK(ST(1))) { + croak("Type error in argument 2 of PDF_setpolydash. Expected reference to array."); + XSRETURN(1); + } + + av = (AV *) SvRV(ST(1)); + length = (int) av_len(av) + 1; + + if (length > MAX_DASH_LENGTH) + length = MAX_DASH_LENGTH; + + for (i = 0; i < length; i++) { + val = *av_fetch(av, i, 0); + if ((!SvNOK(val)) && (!SvIOK(val))) { + croak("expected a reference to a float array in PDF_setpolydash\n"); + } + carray[i] = SvNV(val); + } + + try { PDF_setpolydash(p, carray, length); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(0); +} + +XS(_wrap_PDF_skew) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_skew(p, alpha, beta);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_skew. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_skew(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_translate) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_translate(p, tx, ty);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_translate. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_translate(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +/* p_hyper.c */ + +XS(_wrap_PDF_add_bookmark) { + int _result; + PDF * p; + char * PDF_VOLATILE text; + size_t len; + int PDF_VOLATILE parent; + int PDF_VOLATILE open; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_add_bookmark(p, text, parent, open);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_add_bookmark. Expected PDFPtr."); + XSRETURN(1); + } + text = (char *) SvPV(ST(1),len); + parent = (int )SvIV(ST(2)); + open = (int )SvIV(ST(3)); + + try { _result = PDF_add_bookmark2(p,text,(int) len,parent,open); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_add_nameddest) { + PDF * p; + char * PDF_VOLATILE name; + char * PDF_VOLATILE optlist; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_add_nameddest(p, name, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_add_nameddest. Expected PDFPtr."); + XSRETURN(1); + } + name = (char *) SvPV(ST(1),PL_na); + optlist = (char *) SvPV(ST(2),PL_na); + + try { PDF_add_nameddest(p, name, 0, optlist); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_set_info) { + PDF * p; + char * PDF_VOLATILE key; + char * PDF_VOLATILE value; + size_t len; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_set_info(p, key, value);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_set_info. Expected PDFPtr."); + XSRETURN(1); + } + key = (char *) SvPV(ST(1),PL_na); + value = (char *) SvPV(ST(2),len); + + try { PDF_set_info2(p,key,value,(int) len); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +/* p_icc.c */ + +XS(_wrap_PDF_load_iccprofile) { + int _result; + PDF * p; + char * PDF_VOLATILE profilename; + char * PDF_VOLATILE optlist; + int argvi = 0; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_load_iccprofile(p, profilename, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_load_iccprofile. Expected PDFPtr."); + XSRETURN(1); + } + profilename = (char *) SvPV(ST(1),PL_na); + optlist = (char *) SvPV(ST(2),PL_na); + + try { _result = PDF_load_iccprofile(p, profilename, 0, optlist); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + + +/* p_image.c */ + +XS(_wrap_PDF_add_thumbnail) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + int argvi = 0; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_add_thumbnail(p, image);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_add_thumbnail. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + + try { PDF_add_thumbnail(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(argvi); +} + +XS(_wrap_PDF_close_image) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_close_image(p, image);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_close_image. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + + try { PDF_close_image(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_fit_image) { + PDF * p; + int image; + float x; + float y; + char * PDF_VOLATILE optlist; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_fit_image(p, image, x, y, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_fit_image. Expected PDFPtr."); + XSRETURN(1); + } + image = (int )SvIV(ST(1)); + x = (float ) SvNV(ST(2)); + y = (float ) SvNV(ST(3)); + optlist = (char *) SvPV(ST(4),PL_na); + + try { PDF_fit_image(p, image, x, y, optlist); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_load_image) { + int _result; + PDF * p; + char * PDF_VOLATILE imagetype; + char * PDF_VOLATILE filename; + char * PDF_VOLATILE optlist; + int argvi = 0; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_load_image(p, imagetype, filename, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_load_image. Expected PDFPtr."); + XSRETURN(1); + } + imagetype = (char *) SvPV(ST(1),PL_na); + filename = (char *) SvPV(ST(2),PL_na); + optlist = (char *) SvPV(ST(3),PL_na); + + try { _result = PDF_load_image(p, imagetype, filename, 0, optlist); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + + +XS(_wrap_PDF_open_CCITT) { + int _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + int PDF_VOLATILE _arg2; + int PDF_VOLATILE _arg3; + int PDF_VOLATILE _arg4; + int PDF_VOLATILE _arg5; + int PDF_VOLATILE _arg6; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 7) + croak("Usage: PDF_open_CCITT(p, filename, width, height, BitReverse, K, BlackIs1);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_open_CCITT. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (int )SvIV(ST(2)); + _arg3 = (int )SvIV(ST(3)); + _arg4 = (int )SvIV(ST(4)); + _arg5 = (int )SvIV(ST(5)); + _arg6 = (int )SvIV(ST(6)); + + try { _result = (int )PDF_open_CCITT(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_open_image) { + int _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + char * PDF_VOLATILE _arg2; + char * PDF_VOLATILE _arg3; + long PDF_VOLATILE _arg4; + int PDF_VOLATILE _arg5; + int PDF_VOLATILE _arg6; + int PDF_VOLATILE _arg7; + int PDF_VOLATILE _arg8; + char * PDF_VOLATILE _arg9; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 10) + croak("Usage: PDF_open_image(p, imagetype, source, data, length, width, height, components, bpc, params);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_open_image. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (char *) SvPV(ST(2),PL_na); + _arg3 = (char *) SvPV(ST(3),PL_na); + _arg4 = (long )SvIV(ST(4)); + _arg5 = (int )SvIV(ST(5)); + _arg6 = (int )SvIV(ST(6)); + _arg7 = (int )SvIV(ST(7)); + _arg8 = (int )SvIV(ST(8)); + _arg9 = (char *) SvPV(ST(9),PL_na); + + try { _result = (int )PDF_open_image(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7,_arg8,_arg9); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_open_image_file) { + int _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + char * PDF_VOLATILE _arg2; + char * PDF_VOLATILE _arg3; + int PDF_VOLATILE _arg4; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_open_image_file(p, imagetype, filename, stringparam, intparam);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_open_image_file. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (char *) SvPV(ST(2),PL_na); + _arg3 = (char *) SvPV(ST(3),PL_na); + _arg4 = (int )SvIV(ST(4)); + + try { _result = (int )PDF_open_image_file(_arg0,_arg1,_arg2,_arg3,_arg4); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_place_image) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + float _arg2; + float _arg3; + float _arg4; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_place_image(p, image, x, y, scale);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_place_image. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + + try { PDF_place_image(_arg0,_arg1,_arg2,_arg3,_arg4); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +/* p_params.c */ + +XS(_wrap_PDF_get_parameter) { + char * _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + float _arg2; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_get_parameter(p, key, modifier);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_get_parameter. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (float ) SvNV(ST(2)); + + try { _result = (char *)PDF_get_parameter(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setpv((SV*)ST(argvi++),(char *) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_get_value) { + float _result; + PDF * p; + char * PDF_VOLATILE key; + float value; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_get_value(p, key, modifier);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + /* allow get_value with null-pointer */ + p = (PDF *)0; + /*croak("Type error in argument 1 of PDF_get_value. Expected PDFPtr."); + XSRETURN(1); + */ + } + key = (char *) SvPV(ST(1),PL_na); + value = (float ) SvNV(ST(2)); + + try { _result = (float )PDF_get_value(p,key,value); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setnv(ST(argvi++), (double) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_set_parameter) { + PDF * _arg0; + char * PDF_VOLATILE _arg1; + char * PDF_VOLATILE _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_set_parameter(p, key, value);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_set_parameter. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (char *) SvPV(ST(2),PL_na); + + try { PDF_set_parameter(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_set_value) { + PDF * _arg0; + char * PDF_VOLATILE _arg1; + float _arg2; + int argvi = 0; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_set_value(p, key, value);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_set_value. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_set_value(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(argvi); +} + +/* p_pattern.c */ + +XS(_wrap_PDF_begin_pattern) { + int _result; + PDF * _arg0; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + int PDF_VOLATILE _arg5; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 6) + croak("Usage: PDF_begin_pattern(p, width, height, xstep, ystep, painttype);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_begin_pattern. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (int )SvIV(ST(5)); + + try { _result = (int )PDF_begin_pattern(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_end_pattern) { + PDF * _arg0; + int argvi = 0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_end_pattern(p);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_end_pattern. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_end_pattern(_arg0); + } + else { + SWIG_exception(error_message); + } + XSRETURN(argvi); +} + +/* p_pdi.c */ +XS(_wrap_PDF_close_pdi) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + int argvi = 0; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_close_pdi(p, doc);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_close_pdi. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + + try { PDF_close_pdi(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(argvi); +} + +XS(_wrap_PDF_close_pdi_page) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + int argvi = 0; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_close_pdi_page(p, page);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_close_pdi_page. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + + try { PDF_close_pdi_page(_arg0,_arg1); + } + else { + SWIG_exception(error_message); + } + XSRETURN(argvi); +} + +XS(_wrap_PDF_fit_pdi_page) { + PDF * p; + int PDF_VOLATILE page; + float x; + float y; + char * PDF_VOLATILE optlist; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_fit_pdi_page(p, page, x, y, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_fit_pdi_page. Expected PDFPtr."); + XSRETURN(1); + } + page = (int )SvIV(ST(1)); + x = (float ) SvNV(ST(2)); + y = (float ) SvNV(ST(3)); + optlist = (char *) SvPV(ST(4),PL_na); + + try { PDF_fit_pdi_page(p, page, x, y, optlist); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + + +XS(_wrap_PDF_get_pdi_parameter) { + char * _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + int PDF_VOLATILE _arg2; + int PDF_VOLATILE _arg3; + int PDF_VOLATILE _arg4; + int len; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_get_pdi_parameter(p, key, doc, page, reserved);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_get_pdi_parameter. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (int )SvIV(ST(2)); + _arg3 = (int )SvIV(ST(3)); + _arg4 = (int )SvIV(ST(4)); + + try { _result = (char *)PDF_get_pdi_parameter(_arg0,_arg1,_arg2,_arg3,_arg4, &len); + } + else { + SWIG_exception(error_message); + } + + ST(0) = sv_newmortal(); + sv_setpvn((SV*)ST(0), (char *) _result, len); + XSRETURN(1); +} + +XS(_wrap_PDF_get_pdi_value) { + float _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + int PDF_VOLATILE _arg2; + int PDF_VOLATILE _arg3; + int PDF_VOLATILE _arg4; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_get_pdi_value(p, key, doc, page, reserved);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_get_pdi_value. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (int )SvIV(ST(2)); + _arg3 = (int )SvIV(ST(3)); + _arg4 = (int )SvIV(ST(4)); + + try { _result = (float )PDF_get_pdi_value(_arg0,_arg1,_arg2,_arg3,_arg4); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setnv(ST(argvi++), (double) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_open_pdi) { + int _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + char * PDF_VOLATILE _arg2; + int PDF_VOLATILE _arg3; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_open_pdi(p, filename, stringparam, reserved);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_open_pdi. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (char *) SvPV(ST(2),PL_na); + _arg3 = (int )SvIV(ST(3)); + + try { _result = (int )PDF_open_pdi(_arg0,_arg1,_arg2,_arg3); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_open_pdi_page) { + int _result; + PDF * _arg0; + int PDF_VOLATILE _arg1; + int PDF_VOLATILE _arg2; + char * PDF_VOLATILE _arg3; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_open_pdi_page(p, doc, page, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_open_pdi_page. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + _arg2 = (int )SvIV(ST(2)); + _arg3 = (char *) SvPV(ST(3),PL_na); + + try { _result = (int )PDF_open_pdi_page(_arg0,_arg1,_arg2,_arg3); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_place_pdi_page) { + PDF * _arg0; + int PDF_VOLATILE _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + dXSARGS ; + + if (items != 6) + croak("Usage: PDF_place_pdi_page(p, image, x, y, sx, sy);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_place_pdi_page. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (int )SvIV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (float ) SvNV(ST(5)); + + try { PDF_place_pdi_page(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_process_pdi) { + int _result; + PDF * p; + int PDF_VOLATILE doc; + int PDF_VOLATILE page; + char * PDF_VOLATILE optlist; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_process_pdi(p, doc, page, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_process_pdi. Expected PDFPtr."); + XSRETURN(1); + } + doc = (int )SvIV(ST(1)); + page = (int )SvIV(ST(2)); + optlist = (char *) SvPV(ST(3),PL_na); + + try { _result = (int )PDF_process_pdi(p, doc, page, optlist); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + + +/* p_resource.c */ + +XS(_wrap_PDF_create_pvf) { + PDF * p; + char * PDF_VOLATILE filename; + char * PDF_VOLATILE data; + size_t size; + char * PDF_VOLATILE optlist; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_create_pvf(p, filename, data, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_create_pvf. Expected PDFPtr."); + XSRETURN(1); + } + filename = (char *) SvPV(ST(1),PL_na); + data = (char *) SvPV(ST(2),size); + optlist = (char *) SvPV(ST(3),PL_na); + + try { PDF_create_pvf(p, filename, 0, data, size, optlist); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_delete_pvf) { + int _result; + PDF * p; + char * PDF_VOLATILE filename; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_delete_pvf(p, filename);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_delete_pvf. Expected PDFPtr."); + XSRETURN(1); + } + filename = (char *) SvPV(ST(1),PL_na); + + try { _result = (int )PDF_delete_pvf(p, filename, 0); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + + +/* p_shading.c */ + +XS(_wrap_PDF_shading) { + int _result; + PDF * p; + char * PDF_VOLATILE shtype; + float x0; + float y0; + float x1; + float y1; + float c1; + float c2; + float c3; + float c4; + char * PDF_VOLATILE optlist; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 11) + croak("Usage: PDF_shading(p, shtype, x0, y0, x1, y1, c1, c2, c3, c4, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_shading. Expected PDFPtr."); + XSRETURN(1); + } + shtype = (char *) SvPV(ST(1),PL_na); + x0 = (float ) SvNV(ST(2)); + y0 = (float ) SvNV(ST(3)); + x1 = (float ) SvNV(ST(4)); + y1 = (float ) SvNV(ST(5)); + c1 = (float ) SvNV(ST(6)); + c2 = (float ) SvNV(ST(7)); + c3 = (float ) SvNV(ST(8)); + c4 = (float ) SvNV(ST(9)); + optlist = (char *) SvPV(ST(10),PL_na); + + try { _result = (int )PDF_shading(p, shtype, x0, y0, x1, y1, c1, c2, c3, c4, optlist); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_shading_pattern) { + int _result; + PDF * p; + int PDF_VOLATILE shading; + char * PDF_VOLATILE optlist; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_shading_pattern(p, shading, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_shading_pattern. Expected PDFPtr."); + XSRETURN(1); + } + shading = (int )SvIV(ST(1)); + optlist = (char *) SvPV(ST(2),PL_na); + + try { _result = (int )PDF_shading_pattern(p, shading, optlist); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_shfill) { + PDF * p; + int PDF_VOLATILE shading; + int argvi = 0; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_shfill(p, shading);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_shfill. Expected PDFPtr."); + XSRETURN(1); + } + + shading = (int )SvIV(ST(1)); + + try { PDF_shfill(p, shading); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(argvi); +} + + +/* p_template.c */ + +XS(_wrap_PDF_begin_template) { + int _result; + PDF * _arg0; + float _arg1; + float _arg2; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_begin_template(p, width, height);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_begin_template. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { _result = (int )PDF_begin_template(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_end_template) { + PDF * _arg0; + int argvi = 0; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_end_template(p);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_end_template. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_end_template(_arg0); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(argvi); +} + +/* p_text.c */ + +XS(_wrap_PDF_continue_text) { + PDF * p; + char * PDF_VOLATILE text; + size_t len; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_continue_text(p, text);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_continue_text. Expected PDFPtr."); + XSRETURN(1); + } + text = (char *) SvPV(ST(1), len); + + try { PDF_continue_text2(p, text, (int) len); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_fit_textline) { + PDF * p; + char * PDF_VOLATILE text; + size_t len; + float x; + float y; + char * PDF_VOLATILE optlist; + dXSARGS ; + + if (items != 5) + croak("Usage: PDF_fit_textline(p, text, x, y, optlist);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_fit_textline. Expected PDFPtr."); + XSRETURN(1); + } + text = (char *) SvPV(ST(1), len); + x = (float ) SvNV(ST(2)); + y = (float ) SvNV(ST(3)); + optlist = (char *) SvPV(ST(4), PL_na); + + try { PDF_fit_textline(p, text, (int) len, x, y, optlist); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_set_text_pos) { + PDF * _arg0; + float _arg1; + float _arg2; + dXSARGS ; + + if (items != 3) + croak("Usage: PDF_set_text_pos(p, x, y);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_set_text_pos. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (float ) SvNV(ST(1)); + _arg2 = (float ) SvNV(ST(2)); + + try { PDF_set_text_pos(_arg0,_arg1,_arg2); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_show) { + PDF * _arg0; + char * PDF_VOLATILE _arg1; + dXSARGS ; + size_t len; + + if (items != 2) + croak("Usage: PDF_show(p, text);"); + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_show. Expected PDFPtr."); + XSRETURN(1); + } + _arg1 = (char *) SvPV(ST(1), len); + + try { PDF_show2(_arg0,_arg1, (int) len); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_show_boxed) { + int _result; + PDF * _arg0; + char * PDF_VOLATILE _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + char * PDF_VOLATILE _arg6; + char * PDF_VOLATILE _arg7; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 8) + croak("Usage: PDF_show_boxed(p, text, left, top, width, height, hmode, feature);"); + + if (SWIG_GetPtr(ST(0),(void **) &_arg0,"PDFPtr")) { + croak("Type error in argument 1 of PDF_show_boxed. Expected PDFPtr."); + XSRETURN(1); + } + + _arg1 = (char *) SvPV(ST(1),PL_na); + _arg2 = (float ) SvNV(ST(2)); + _arg3 = (float ) SvNV(ST(3)); + _arg4 = (float ) SvNV(ST(4)); + _arg5 = (float ) SvNV(ST(5)); + _arg6 = (char *) SvPV(ST(6),PL_na); + _arg7 = (char *) SvPV(ST(7),PL_na); + + try { _result = (int )PDF_show_boxed(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + +XS(_wrap_PDF_show_xy) { + PDF * p; + char * PDF_VOLATILE text; + float x; + float y; + size_t len; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_show_xy(p, text, x, y);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_show_xy. Expected PDFPtr."); + XSRETURN(1); + } + text = (char *) SvPV(ST(1), len); + x = (float ) SvNV(ST(2)); + y = (float ) SvNV(ST(3)); + + try { PDF_show_xy2(p,text, (int) len, x,y); + } + else { + SWIG_exception(error_message); + } + XSRETURN(0); +} + +XS(_wrap_PDF_stringwidth) { + float _result; + PDF * p; + char * PDF_VOLATILE text; + int PDF_VOLATILE font; + float fontsize; + int PDF_VOLATILE argvi = 0; + size_t len; + dXSARGS ; + + if (items != 4) + croak("Usage: PDF_stringwidth(p, text, font, fontsize);"); + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_stringwidth. Expected PDFPtr."); + XSRETURN(1); + } + text = (char *) SvPV(ST(1), len); + font = (int )SvIV(ST(2)); + fontsize = (float ) SvNV(ST(3)); + + try { _result = (float )PDF_stringwidth2(p,text, (int) len, font,fontsize); + } + else { + SWIG_exception(error_message); + } + ST(argvi) = sv_newmortal(); + sv_setnv(ST(argvi++), (double) _result); + XSRETURN(argvi); +} + +/* p_type3.c */ + +XS(_wrap_PDF_begin_font) { + PDF * p; + char * PDF_VOLATILE fontname; + float a, b, c, d, e, f; + char * PDF_VOLATILE optlist; + dXSARGS ; + + if (items != 9) + croak("Usage: PDF_begin_font(p, fontname, a, b, c, d, e, f, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_begin_font. Expected PDFPtr."); + XSRETURN(1); + } + + fontname = (char *) SvPV(ST(1),PL_na); + a = (float )SvNV(ST(2)); + b = (float )SvNV(ST(3)); + c = (float )SvNV(ST(4)); + d = (float )SvNV(ST(5)); + e = (float )SvNV(ST(6)); + f = (float )SvNV(ST(7)); + optlist = (char *) SvPV(ST(8),PL_na); + + try { PDF_begin_font(p, fontname, 0, a, b, c, d, e, f, optlist); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(0); +} + +XS(_wrap_PDF_begin_glyph) { + PDF * p; + char * PDF_VOLATILE glyphname; + float wx, llx, lly, urx, ury; + dXSARGS ; + + if (items != 7) + croak("Usage: PDF_begin_glyph(p, glyphname, wx, llx, lly, urx, ury);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_begin_glyph. Expected PDFPtr."); + XSRETURN(1); + } + + glyphname = (char *) SvPV(ST(1),PL_na); + wx = (float )SvIV(ST(2)); + llx = (float )SvIV(ST(3)); + lly = (float )SvIV(ST(4)); + urx = (float )SvIV(ST(5)); + ury = (float )SvIV(ST(6)); + + try { PDF_begin_glyph(p, glyphname, wx, llx, lly, urx, ury); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(0); +} + +XS(_wrap_PDF_end_font) { + PDF * p; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_end_font(p);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_end_font. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_end_font(p); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(0); +} + +XS(_wrap_PDF_end_glyph) { + PDF * p; + dXSARGS ; + + if (items != 1) + croak("Usage: PDF_end_glyph(p);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_end_glyph. Expected PDFPtr."); + XSRETURN(1); + } + + try { PDF_end_glyph(p); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(0); +} + +/* p_xgstate.c */ + +/* +5 int PDF_create_gstate (p, char *optlist) +*/ +XS(_wrap_PDF_create_gstate) { + int _result; + PDF * p; + char * PDF_VOLATILE optlist; + int PDF_VOLATILE argvi = 0; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_create_gstate(p, optlist);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_create_gstate. Expected PDFPtr."); + XSRETURN(1); + } + optlist = (char *) SvPV(ST(1),PL_na); + + try { _result = (int )PDF_create_gstate(p, optlist); + } + else { + SWIG_exception(error_message); + } + + ST(argvi) = sv_newmortal(); + sv_setiv(ST(argvi++),(IV) _result); + XSRETURN(argvi); +} + + +XS(_wrap_PDF_set_gstate) { + PDF * p; + int PDF_VOLATILE gstate; + dXSARGS ; + + if (items != 2) + croak("Usage: PDF_set_gstate(p, gstate);"); + + if (SWIG_GetPtr(ST(0),(void **) &p,"PDFPtr")) { + croak("Type error in argument 1 of PDF_set_gstate. Expected PDFPtr."); + XSRETURN(1); + } + + gstate = (int )SvIV(ST(1)); + + try { PDF_set_gstate(p, gstate); + } + else { + SWIG_exception(error_message); + } + + XSRETURN(0); +} + + + +XS(_wrap_perl5_pdflib_var_init) { + dXSARGS; + (void) items; + + XSRETURN(1); +} +#ifdef __cplusplus +extern "C" +#endif +XS(boot_pdflib_pl) { + dXSARGS; + char *file = __FILE__; + newXS("pdflibc::var_pdflib_init", _wrap_perl5_pdflib_var_init, file); + + (void) items; + + /* Boot the PDFlib core */ + PDF_boot(); + + newXS("pdflibc::PDF_add_launchlink", _wrap_PDF_add_launchlink, file); + newXS("pdflibc::PDF_add_locallink", _wrap_PDF_add_locallink, file); + newXS("pdflibc::PDF_add_note", _wrap_PDF_add_note, file); + newXS("pdflibc::PDF_add_pdflink", _wrap_PDF_add_pdflink, file); + newXS("pdflibc::PDF_add_weblink", _wrap_PDF_add_weblink, file); + newXS("pdflibc::PDF_attach_file", _wrap_PDF_attach_file, file); + newXS("pdflibc::PDF_set_border_color", _wrap_PDF_set_border_color, file); + newXS("pdflibc::PDF_set_border_dash", _wrap_PDF_set_border_dash, file); + newXS("pdflibc::PDF_set_border_style", _wrap_PDF_set_border_style, file); + + newXS("pdflibc::PDF_begin_page", _wrap_PDF_begin_page, file); + newXS("pdflibc::PDF_close", _wrap_PDF_close, file); + newXS("pdflibc::PDF_delete", _wrap_PDF_delete, file); + newXS("pdflibc::PDF_end_page", _wrap_PDF_end_page, file); + newXS("pdflibc::PDF_get_buffer", _wrap_PDF_get_buffer, file); + newXS("pdflibc::PDF_new", _wrap_PDF_new, file); + newXS("pdflibc::PDF_open_file", _wrap_PDF_open_file, file); + newXS("pdflibc::PDF_get_errmsg", _wrap_PDF_get_errmsg, file); + newXS("pdflibc::PDF_get_apiname", _wrap_PDF_get_apiname, file); + newXS("pdflibc::PDF_get_errnum", _wrap_PDF_get_errnum, file); + + newXS("pdflibc::PDF_fill_imageblock", _wrap_PDF_fill_imageblock, file); + newXS("pdflibc::PDF_fill_pdfblock", _wrap_PDF_fill_pdfblock, file); + newXS("pdflibc::PDF_fill_textblock", _wrap_PDF_fill_textblock, file); + + newXS("pdflibc::PDF_makespotcolor", _wrap_PDF_makespotcolor, file); + newXS("pdflibc::PDF_setcolor", _wrap_PDF_setcolor, file); + newXS("pdflibc::PDF_setgray", _wrap_PDF_setgray, file); + newXS("pdflibc::PDF_setgray_fill", _wrap_PDF_setgray_fill, file); + newXS("pdflibc::PDF_setgray_stroke", _wrap_PDF_setgray_stroke, file); + newXS("pdflibc::PDF_setrgbcolor", _wrap_PDF_setrgbcolor, file); + newXS("pdflibc::PDF_setrgbcolor_fill", _wrap_PDF_setrgbcolor_fill, file); + newXS("pdflibc::PDF_setrgbcolor_stroke", _wrap_PDF_setrgbcolor_stroke, file); + + newXS("pdflibc::PDF_arc", _wrap_PDF_arc, file); + newXS("pdflibc::PDF_arcn", _wrap_PDF_arcn, file); + newXS("pdflibc::PDF_circle", _wrap_PDF_circle, file); + newXS("pdflibc::PDF_clip", _wrap_PDF_clip, file); + newXS("pdflibc::PDF_closepath", _wrap_PDF_closepath, file); + newXS("pdflibc::PDF_closepath_fill_stroke", _wrap_PDF_closepath_fill_stroke, file); + newXS("pdflibc::PDF_closepath_stroke", _wrap_PDF_closepath_stroke, file); + newXS("pdflibc::PDF_curveto", _wrap_PDF_curveto, file); + newXS("pdflibc::PDF_endpath", _wrap_PDF_endpath, file); + newXS("pdflibc::PDF_fill", _wrap_PDF_fill, file); + newXS("pdflibc::PDF_fill_stroke", _wrap_PDF_fill_stroke, file); + newXS("pdflibc::PDF_lineto", _wrap_PDF_lineto, file); + newXS("pdflibc::PDF_moveto", _wrap_PDF_moveto, file); + newXS("pdflibc::PDF_rect", _wrap_PDF_rect, file); + newXS("pdflibc::PDF_stroke", _wrap_PDF_stroke, file); + + newXS("pdflibc::PDF_encoding_set_char", _wrap_PDF_encoding_set_char, file); + + newXS("pdflibc::PDF_findfont", _wrap_PDF_findfont, file); + newXS("pdflibc::PDF_load_font", _wrap_PDF_load_font, file); + newXS("pdflibc::PDF_setfont", _wrap_PDF_setfont, file); + + newXS("pdflibc::PDF_concat", _wrap_PDF_concat, file); + newXS("pdflibc::PDF_initgraphics", _wrap_PDF_initgraphics, file); + newXS("pdflibc::PDF_restore", _wrap_PDF_restore, file); + newXS("pdflibc::PDF_rotate", _wrap_PDF_rotate, file); + newXS("pdflibc::PDF_save", _wrap_PDF_save, file); + newXS("pdflibc::PDF_scale", _wrap_PDF_scale, file); + newXS("pdflibc::PDF_setdash", _wrap_PDF_setdash, file); + newXS("pdflibc::PDF_setdashpattern", _wrap_PDF_setdashpattern, file); + newXS("pdflibc::PDF_setflat", _wrap_PDF_setflat, file); + newXS("pdflibc::PDF_setlinecap", _wrap_PDF_setlinecap, file); + newXS("pdflibc::PDF_setlinejoin", _wrap_PDF_setlinejoin, file); + newXS("pdflibc::PDF_setlinewidth", _wrap_PDF_setlinewidth, file); + newXS("pdflibc::PDF_setmatrix", _wrap_PDF_setmatrix, file); + newXS("pdflibc::PDF_setmiterlimit", _wrap_PDF_setmiterlimit, file); + newXS("pdflibc::PDF_setpolydash", _wrap_PDF_setpolydash, file); + newXS("pdflibc::PDF_skew", _wrap_PDF_skew, file); + newXS("pdflibc::PDF_translate", _wrap_PDF_translate, file); + + newXS("pdflibc::PDF_add_bookmark", _wrap_PDF_add_bookmark, file); + newXS("pdflibc::PDF_add_nameddest", _wrap_PDF_add_nameddest, file); + newXS("pdflibc::PDF_set_info", _wrap_PDF_set_info, file); + + newXS("pdflibc::PDF_load_iccprofile", _wrap_PDF_load_iccprofile, file); + + newXS("pdflibc::PDF_add_thumbnail", _wrap_PDF_add_thumbnail, file); + newXS("pdflibc::PDF_close_image", _wrap_PDF_close_image, file); + newXS("pdflibc::PDF_fit_image", _wrap_PDF_fit_image, file); + newXS("pdflibc::PDF_load_image", _wrap_PDF_load_image, file); + newXS("pdflibc::PDF_open_CCITT", _wrap_PDF_open_CCITT, file); + newXS("pdflibc::PDF_open_image", _wrap_PDF_open_image, file); + newXS("pdflibc::PDF_open_image_file", _wrap_PDF_open_image_file, file); + newXS("pdflibc::PDF_place_image", _wrap_PDF_place_image, file); + + newXS("pdflibc::PDF_get_parameter", _wrap_PDF_get_parameter, file); + newXS("pdflibc::PDF_get_value", _wrap_PDF_get_value, file); + newXS("pdflibc::PDF_set_parameter", _wrap_PDF_set_parameter, file); + newXS("pdflibc::PDF_set_value", _wrap_PDF_set_value, file); + + newXS("pdflibc::PDF_begin_pattern", _wrap_PDF_begin_pattern, file); + newXS("pdflibc::PDF_end_pattern", _wrap_PDF_end_pattern, file); + + newXS("pdflibc::PDF_close_pdi", _wrap_PDF_close_pdi, file); + newXS("pdflibc::PDF_close_pdi_page", _wrap_PDF_close_pdi_page, file); + newXS("pdflibc::PDF_fit_pdi_page", _wrap_PDF_fit_pdi_page, file); + newXS("pdflibc::PDF_get_pdi_parameter", _wrap_PDF_get_pdi_parameter, file); + newXS("pdflibc::PDF_get_pdi_value", _wrap_PDF_get_pdi_value, file); + newXS("pdflibc::PDF_open_pdi", _wrap_PDF_open_pdi, file); + newXS("pdflibc::PDF_open_pdi_page", _wrap_PDF_open_pdi_page, file); + newXS("pdflibc::PDF_place_pdi_page", _wrap_PDF_place_pdi_page, file); + newXS("pdflibc::PDF_process_pdi", _wrap_PDF_process_pdi, file); + + newXS("pdflibc::PDF_create_pvf", _wrap_PDF_create_pvf, file); + newXS("pdflibc::PDF_delete_pvf", _wrap_PDF_delete_pvf, file); + + newXS("pdflibc::PDF_shading", _wrap_PDF_shading, file); + newXS("pdflibc::PDF_shading_pattern", _wrap_PDF_shading_pattern, file); + newXS("pdflibc::PDF_shfill", _wrap_PDF_shfill, file); + + newXS("pdflibc::PDF_begin_template", _wrap_PDF_begin_template, file); + newXS("pdflibc::PDF_end_template", _wrap_PDF_end_template, file); + + newXS("pdflibc::PDF_continue_text", _wrap_PDF_continue_text, file); + newXS("pdflibc::PDF_fit_textline", _wrap_PDF_fit_textline, file); + newXS("pdflibc::PDF_set_text_pos", _wrap_PDF_set_text_pos, file); + newXS("pdflibc::PDF_show", _wrap_PDF_show, file); + newXS("pdflibc::PDF_show_boxed", _wrap_PDF_show_boxed, file); + newXS("pdflibc::PDF_show_xy", _wrap_PDF_show_xy, file); + newXS("pdflibc::PDF_stringwidth", _wrap_PDF_stringwidth, file); + + newXS("pdflibc::PDF_begin_font", _wrap_PDF_begin_font, file); + newXS("pdflibc::PDF_begin_glyph", _wrap_PDF_begin_glyph, file); + newXS("pdflibc::PDF_end_font", _wrap_PDF_end_font, file); + newXS("pdflibc::PDF_end_glyph", _wrap_PDF_end_glyph, file); + + newXS("pdflibc::PDF_create_gstate", _wrap_PDF_create_gstate, file); + newXS("pdflibc::PDF_set_gstate", _wrap_PDF_set_gstate, file); + +/* + * These are the pointer type-equivalency mappings. + * (Used by the SWIG pointer type-checker). + */ + SWIG_RegisterMapping("unsigned short","short",0); + SWIG_RegisterMapping("PDF","struct PDF_s",0); + SWIG_RegisterMapping("long","unsigned long",0); + SWIG_RegisterMapping("long","signed long",0); + SWIG_RegisterMapping("signed short","short",0); + SWIG_RegisterMapping("signed int","int",0); + SWIG_RegisterMapping("short","unsigned short",0); + SWIG_RegisterMapping("short","signed short",0); + SWIG_RegisterMapping("unsigned long","long",0); + SWIG_RegisterMapping("int","unsigned int",0); + SWIG_RegisterMapping("int","signed int",0); + SWIG_RegisterMapping("unsigned int","int",0); + SWIG_RegisterMapping("struct PDF_s","PDF",0); + SWIG_RegisterMapping("signed long","long",0); + ST(0) = &PL_sv_yes; + XSRETURN(1); +} diff --git a/src/libs/pdflib/bind/pdflib/perl/pdflib_pl.pm b/src/libs/pdflib/bind/pdflib/perl/pdflib_pl.pm new file mode 100644 index 0000000000..6024ebd3e4 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/pdflib_pl.pm @@ -0,0 +1,174 @@ +# $Id: pdflib_pl.pm,v 1.1 2004/10/06 17:46:42 laplace Exp $ +package pdflib_pl; +require Exporter; +require DynaLoader; +$VERSION=5.0; +@ISA = qw(Exporter DynaLoader); +package pdflibc; +bootstrap pdflib_pl; +var_pdflib_init(); +@EXPORT = qw( ); + +# ---------- BASE METHODS ------------- + +package pdflib_pl; + +sub TIEHASH { + my ($classname,$obj) = @_; + return bless $obj, $classname; +} + +sub CLEAR { } + +sub this { + my $ptr = shift; + return tied(%$ptr); +} + + +# ------- FUNCTION WRAPPERS -------- + +package pdflib_pl; + +# p_annots.c +*PDF_add_launchlink = *pdflibc::PDF_add_launchlink; +*PDF_add_locallink = *pdflibc::PDF_add_locallink; +*PDF_add_note = *pdflibc::PDF_add_note; +*PDF_add_pdflink = *pdflibc::PDF_add_pdflink; +*PDF_add_weblink = *pdflibc::PDF_add_weblink; +*PDF_attach_file = *pdflibc::PDF_attach_file; +*PDF_set_border_color = *pdflibc::PDF_set_border_color; +*PDF_set_border_dash = *pdflibc::PDF_set_border_dash; +*PDF_set_border_style = *pdflibc::PDF_set_border_style; +# p_basic.c +*PDF_begin_page = *pdflibc::PDF_begin_page; +*PDF_close = *pdflibc::PDF_close; +*PDF_delete = *pdflibc::PDF_delete; +*PDF_end_page = *pdflibc::PDF_end_page; +*PDF_get_apiname = *pdflibc::PDF_get_apiname; +*PDF_get_buffer = *pdflibc::PDF_get_buffer; +*PDF_get_errmsg = *pdflibc::PDF_get_errmsg; +*PDF_get_errnum = *pdflibc::PDF_get_errnum; +*PDF_new = *pdflibc::PDF_new; +*PDF_open_file = *pdflibc::PDF_open_file; +# p_block.c +*PDF_fill_imageblock = *pdflibc::PDF_fill_imageblock; +*PDF_fill_pdfblock = *pdflibc::PDF_fill_pdfblock; +*PDF_fill_textblock = *pdflibc::PDF_fill_textblock; +# p_color.c +*PDF_makespotcolor = *pdflibc::PDF_makespotcolor; +*PDF_setcolor = *pdflibc::PDF_setcolor; +*PDF_setgray = *pdflibc::PDF_setgray; +*PDF_setgray_fill = *pdflibc::PDF_setgray_fill; +*PDF_setgray_stroke = *pdflibc::PDF_setgray_stroke; +*PDF_setrgbcolor = *pdflibc::PDF_setrgbcolor; +*PDF_setrgbcolor_fill = *pdflibc::PDF_setrgbcolor_fill; +*PDF_setrgbcolor_stroke = *pdflibc::PDF_setrgbcolor_stroke; +# p_draw.c +*PDF_arc = *pdflibc::PDF_arc; +*PDF_arcn = *pdflibc::PDF_arcn; +*PDF_circle = *pdflibc::PDF_circle; +*PDF_clip = *pdflibc::PDF_clip; +*PDF_closepath = *pdflibc::PDF_closepath; +*PDF_closepath_fill_stroke = *pdflibc::PDF_closepath_fill_stroke; +*PDF_closepath_stroke = *pdflibc::PDF_closepath_stroke; +*PDF_curveto = *pdflibc::PDF_curveto; +*PDF_endpath = *pdflibc::PDF_endpath; +*PDF_fill = *pdflibc::PDF_fill; +*PDF_fill_stroke = *pdflibc::PDF_fill_stroke; +*PDF_lineto = *pdflibc::PDF_lineto; +*PDF_moveto = *pdflibc::PDF_moveto; +*PDF_rect = *pdflibc::PDF_rect; +*PDF_stroke = *pdflibc::PDF_stroke; +# p_encoding.c +*PDF_encoding_set_char = *pdflibc::PDF_encoding_set_char; +# p_font.c +*PDF_findfont = *pdflibc::PDF_findfont; +*PDF_load_font = *pdflibc::PDF_load_font; +*PDF_setfont = *pdflibc::PDF_setfont; +# p_gstate.c +*PDF_concat = *pdflibc::PDF_concat; +*PDF_initgraphics = *pdflibc::PDF_initgraphics; +*PDF_restore = *pdflibc::PDF_restore; +*PDF_rotate = *pdflibc::PDF_rotate; +*PDF_save = *pdflibc::PDF_save; +*PDF_scale = *pdflibc::PDF_scale; +*PDF_setdash = *pdflibc::PDF_setdash; +*PDF_setdashpattern = *pdflibc::PDF_setdashpattern; +*PDF_setflat = *pdflibc::PDF_setflat; +*PDF_setlinecap = *pdflibc::PDF_setlinecap; +*PDF_setlinejoin = *pdflibc::PDF_setlinejoin; +*PDF_setlinewidth = *pdflibc::PDF_setlinewidth; +*PDF_setmatrix = *pdflibc::PDF_setmatrix; +*PDF_setmiterlimit = *pdflibc::PDF_setmiterlimit; +*PDF_setpolydash = *pdflibc::PDF_setpolydash; +*PDF_skew = *pdflibc::PDF_skew; +*PDF_translate = *pdflibc::PDF_translate; +# p_hyper.c +*PDF_add_bookmark = *pdflibc::PDF_add_bookmark; +*PDF_add_nameddest = *pdflibc::PDF_add_nameddest; +*PDF_set_info = *pdflibc::PDF_set_info; +# p_icc.c +*PDF_load_iccprofile = *pdflibc::PDF_load_iccprofile; +# p_image.c +*PDF_add_thumbnail = *pdflibc::PDF_add_thumbnail; +*PDF_close_image = *pdflibc::PDF_close_image; +*PDF_fit_image = *pdflibc::PDF_fit_image; +*PDF_load_image = *pdflibc::PDF_load_image; +*PDF_open_CCITT = *pdflibc::PDF_open_CCITT; +*PDF_open_image = *pdflibc::PDF_open_image; +*PDF_open_image_file = *pdflibc::PDF_open_image_file; +*PDF_place_image = *pdflibc::PDF_place_image; +# p_parmas.c +*PDF_get_parameter = *pdflibc::PDF_get_parameter; +*PDF_get_value = *pdflibc::PDF_get_value; +*PDF_set_parameter = *pdflibc::PDF_set_parameter; +*PDF_set_value = *pdflibc::PDF_set_value; +# p_pattern.c +*PDF_begin_pattern = *pdflibc::PDF_begin_pattern; +*PDF_end_pattern = *pdflibc::PDF_end_pattern; +# p_pdi.c +*PDF_close_pdi = *pdflibc::PDF_close_pdi; +*PDF_close_pdi_page = *pdflibc::PDF_close_pdi_page; +*PDF_fit_pdi_page = *pdflibc::PDF_fit_pdi_page; +*PDF_get_pdi_parameter = *pdflibc::PDF_get_pdi_parameter; +*PDF_get_pdi_value = *pdflibc::PDF_get_pdi_value; +*PDF_open_pdi = *pdflibc::PDF_open_pdi; +*PDF_open_pdi_page = *pdflibc::PDF_open_pdi_page; +*PDF_place_pdi_page = *pdflibc::PDF_place_pdi_page; +*PDF_process_pdi = *pdflibc::PDF_process_pdi; +# p_resource.c +*PDF_create_pvf = *pdflibc::PDF_create_pvf; +*PDF_delete_pvf = *pdflibc::PDF_delete_pvf; +# p_shading.c +*PDF_shading = *pdflibc::PDF_shading; +*PDF_shading_pattern = *pdflibc::PDF_shading_pattern; +*PDF_shfill = *pdflibc::PDF_shfill; +# p_template.c +*PDF_begin_template = *pdflibc::PDF_begin_template; +*PDF_end_template = *pdflibc::PDF_end_template; +# p_text.c +*PDF_continue_text = *pdflibc::PDF_continue_text; +*PDF_fit_textline = *pdflibc::PDF_fit_textline; +*PDF_set_text_pos = *pdflibc::PDF_set_text_pos; +*PDF_show = *pdflibc::PDF_show; +*PDF_show_boxed = *pdflibc::PDF_show_boxed; +*PDF_show_xy = *pdflibc::PDF_show_xy; +*PDF_stringwidth = *pdflibc::PDF_stringwidth; +# p_type3.c +*PDF_begin_font = *pdflibc::PDF_begin_font; +*PDF_begin_glyph = *pdflibc::PDF_begin_glyph; +*PDF_end_font = *pdflibc::PDF_end_font; +*PDF_end_glyph = *pdflibc::PDF_end_glyph; +# p_xgstate.c +*PDF_create_gstate = *pdflibc::PDF_create_gstate; +*PDF_set_gstate = *pdflibc::PDF_set_gstate; + + +@EXPORT = qw( PDF_add_launchlink PDF_add_locallink PDF_add_note PDF_add_pdflink PDF_add_weblink PDF_attach_file PDF_set_border_color PDF_set_border_dash PDF_set_border_style PDF_begin_page PDF_close PDF_delete PDF_end_page PDF_get_apiname PDF_get_buffer PDF_get_errmsg PDF_get_errnum PDF_new PDF_open_file PDF_fill_imageblock PDF_fill_pdfblock PDF_fill_textblock PDF_makespotcolor PDF_setcolor PDF_setgray PDF_setgray_fill PDF_setgray_stroke PDF_setrgbcolor PDF_setrgbcolor_fill PDF_setrgbcolor_stroke PDF_arc PDF_arcn PDF_circle PDF_clip PDF_closepath PDF_closepath_fill_stroke PDF_closepath_stroke PDF_curveto PDF_endpath PDF_fill PDF_fill_stroke PDF_lineto PDF_moveto PDF_rect PDF_stroke PDF_encoding_set_char PDF_findfont PDF_load_font PDF_setfont PDF_concat PDF_initgraphics PDF_restore PDF_rotate PDF_save PDF_scale PDF_setdash PDF_setdashpattern PDF_setflat PDF_setlinecap PDF_setlinejoin PDF_setlinewidth PDF_setmatrix PDF_setmiterlimit PDF_setpolydash PDF_skew PDF_translate PDF_add_bookmark PDF_add_nameddest PDF_set_info PDF_load_iccprofile PDF_add_thumbnail PDF_close_image PDF_fit_image PDF_load_image PDF_open_CCITT PDF_open_image PDF_open_image_file PDF_place_image PDF_get_parameter PDF_get_value PDF_set_parameter PDF_set_value PDF_begin_pattern PDF_end_pattern PDF_close_pdi PDF_close_pdi_page PDF_fit_pdi_page PDF_get_pdi_parameter PDF_get_pdi_value PDF_open_pdi PDF_open_pdi_page PDF_place_pdi_page PDF_process_pdi PDF_create_pvf PDF_delete_pvf PDF_shading PDF_shading_pattern PDF_shfill PDF_begin_template PDF_end_template PDF_continue_text PDF_fit_textline PDF_set_text_pos PDF_show PDF_show_boxed PDF_show_xy PDF_stringwidth PDF_begin_font PDF_begin_glyph PDF_end_font PDF_end_glyph PDF_create_gstate PDF_set_gstate ); + +# ------- VARIABLE STUBS -------- + +package pdflib_pl; + +1; diff --git a/src/libs/pdflib/bind/pdflib/perl/quickreference.pl b/src/libs/pdflib/bind/pdflib/perl/quickreference.pl new file mode 100644 index 0000000000..2fcf391579 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/quickreference.pl @@ -0,0 +1,92 @@ +#!/usr/bin/perl +# $Id: quickreference.pl,v 1.1 2004/10/06 17:46:42 laplace Exp $ +# +# PDFlib/PDI client: mini imposition demo +# + +use pdflib_pl 5.0; + +$infile = "reference.pdf"; +# This is where font/image/PDF input files live. Adjust as necessary. +$searchpath = "../data"; +$maxrow = 2; +$maxcol = 2; +$pagecount = 4; +$width = 500.0; +$height = 770.0; +$startpage = 1; +$endpage = 4; + +$p = PDF_new(); +eval{ + if (PDF_open_file($p, "quickreference.pdf") == -1) { + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + PDF_set_parameter($p, "SearchPath", $searchpath); + + # This line is required to avoid problems on Japanese systems + PDF_set_parameter($p, "hypertextencoding", "winansi"); + + PDF_set_info($p, "Creator", "quickreference.pl"); + PDF_set_info($p, "Author", "Thomas Merz"); + PDF_set_info($p, "Title", "mini imposition demo (Perl)"); + + $manual = PDF_open_pdi($p, $infile, "", 0); + if ($manual == -1) { + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + $row = 0; + $col = 0; + + PDF_set_parameter($p, "topdown", "true"); + + for ($pageno = $startpage; $pageno <= $endpage; $pageno++) { + if ($row == 0 && $col == 0) { + PDF_begin_page($p, $width, $height); + $font = PDF_load_font($p, "Helvetica-Bold", "winansi", ""); + PDF_setfont($p, $font, 18); + PDF_set_text_pos($p, 24, 24); + PDF_show($p, "PDFlib Quick Reference"); + } + + $page = PDF_open_pdi_page($p, $manual, $pageno, ""); + + if ($page == -1) { + printf("Error: %s\n", PDF_get_errmsg($p)); + exit; + } + + PDF_fit_pdi_page($p, $page, + $width/$maxcol*$col, ($row + 1) * $height/$maxrow, "scale ". 1/$maxrow); + PDF_close_pdi_page($p, $page); + + $col++; + if ($col == $maxcol) { + $col = 0; + $row++; + } + if ($row == $maxrow) { + $row = 0; + PDF_end_page($p); + } + } + + # finish the last partial page + if ($row != 0 || $col != 0) { + PDF_end_page($p); + } + + PDF_close($p); + PDF_close_pdi($p, $manual); +}; +if ($@) { + printf("quickreference: PDFlib Exception occurred:\n"); + printf(" $@\n"); + exit; +} + +PDF_delete($p); diff --git a/src/libs/pdflib/bind/pdflib/perl/readme.txt b/src/libs/pdflib/bind/pdflib/perl/readme.txt new file mode 100644 index 0000000000..4c21748748 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/perl/readme.txt @@ -0,0 +1,27 @@ +ActivePerl versions +=================== + +- ActivePerl 5.6 is _not_ binary compatible to older versions of ActivePerl + with respect to extensions. For this reason the same PDFlib DLL can _not_ + be used with ActivePerl 5.6 and older versions. The "oldperl" directory + of the PDFlib binary distribution for Windows contains a PDFlib DLL for + ActivePerl versions before 5.6. + + +Compiling PDFlib for ActivePerl on Win32 +======================================== +(not relevant for users of the binary distribution) + +The distribution is set up to be compiled with ActivePerl 5.6. + +With some minor modification you can also compile with ActivePerl +versions older than 5.6 (the MSVC project contains an "oldperl" configuration +with all of this): + +- Run the compiler in C++ mode (required by ActiveState). In MSVC++ 6 there + doesn't seem to be a GUI option for C++ mode, but the compiler switch + /Tp works. + +- Change the Perl include and lib paths appropriately. + +- Change perl56.lib to perlcore.lib. diff --git a/src/libs/pdflib/bind/pdflib/php/businesscard.php b/src/libs/pdflib/bind/pdflib/php/businesscard.php new file mode 100644 index 0000000000..1ec086a050 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/businesscard.php @@ -0,0 +1,81 @@ + "Victor Kraxi", + "business.title" => "Chief Paper Officer", + "business.address.line1" => "17, Aviation Road", + "business.address.city" => "Paperfield", + "business.telephone.voice" => "phone +1 234 567-89", + "business.telephone.fax" => "fax +1 234 567-98", + "business.email" => "victor@kraxi.com", + "business.homepage" => "www.kraxi.com" + ); + +$p = PDF_new(); + +/* open new PDF file; insert a file name to create the PDF on disk */ +if (PDF_open_file($p, "") == 0) { + die("Error: " . PDF_get_errmsg($p)); +} + +PDF_set_parameter($p, "SearchPath", $searchpath); + +/* This line is required to avoid problems on Japanese systems */ +PDF_set_parameter($p, "hypertextencoding", "winansi"); + +PDF_set_info($p, "Creator", "businesscard.php"); +PDF_set_info($p, "Author", "Thomas Merz"); +PDF_set_info($p, "Title", "PDFlib block processing sample (PHP)"); + +$blockcontainer = PDF_open_pdi($p, $infile, "", 0); +if ($blockcontainer == 0){ + die ("Error: " . PDF_get_errmsg($p)); +} + +$page = PDF_open_pdi_page($p, $blockcontainer, 1, ""); +if ($page == 0){ + die ("Error: " . PDF_get_errmsg($p)); +} + +PDF_begin_page($p, 20, 20); /* dummy page size */ + +/* This will adjust the page size to the block container's size. */ +PDF_fit_pdi_page($p, $page, 0, 0, "adjustpage"); + +/* Fill all text blocks with dynamic data */ +foreach ($data as $key => $value){ + if (PDF_fill_textblock($p, $page, $key, $value, + "embedding encoding=winansi") == 0) { + printf("Warning: %s\n ", PDF_get_errmsg($p)); + } +} + +PDF_end_page($p); /* close page */ +PDF_close_pdi_page($p, $page); + +PDF_close($p); /* close PDF document */ +PDF_close_pdi($p, $blockcontainer); + +$buf = PDF_get_buffer($p); +$len = strlen($buf); + +header("Content-type: application/pdf"); +header("Content-Length: $len"); +header("Content-Disposition: inline; filename=businesscard.pdf"); +print $buf; + +PDF_delete($p); /* delete the PDFlib object */ +?> diff --git a/src/libs/pdflib/bind/pdflib/php/chartab.php b/src/libs/pdflib/bind/pdflib/php/chartab.php new file mode 100644 index 0000000000..ecf8424f98 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/chartab.php @@ -0,0 +1,105 @@ + diff --git a/src/libs/pdflib/bind/pdflib/php/ext/pdf/Makefile.php-404.in b/src/libs/pdflib/bind/pdflib/php/ext/pdf/Makefile.php-404.in new file mode 100644 index 0000000000..6e05e279b2 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/ext/pdf/Makefile.php-404.in @@ -0,0 +1,8 @@ + +LTLIBRARY_NAME = libpdf.la +LTLIBRARY_SOURCES = pdf.c +LTLIBRARY_SHARED_NAME = libpdf_php.la +PDFLIB_SHARED_LIBBADD = -lpdf +LTLIBRARY_SHARED_LIBADD = $(PDFLIB_SHARED_LIBBADD) + +include $(top_srcdir)/build/dynlib.mk diff --git a/src/libs/pdflib/bind/pdflib/php/ext/pdf/config.m4 b/src/libs/pdflib/bind/pdflib/php/ext/pdf/config.m4 new file mode 100644 index 0000000000..7a43110544 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/ext/pdf/config.m4 @@ -0,0 +1,29 @@ +dnl $Id: config.m4,v 1.1 2004/10/06 17:46:43 laplace Exp $ + +PHP_ARG_WITH(pdflib,whether to include PDFlib support, +[ --with-pdflib[=DIR] Include PDFlib 4.x support. DIR is the PDFlib + base install directory, defaults to /usr/local + Set DIR to "shared" to build as dl, or "shared,DIR" + to build as dl and still specify DIR.]) + + case "$PHP_PDFLIB" in + yes) + PHP_EXTENSION(pdf, $ext_shared) + AC_DEFINE(HAVE_PDFLIB,1,[ ]) + AC_SUBST(PDFLIB_SHARED_LIBADD) + PHP_ADD_LIBRARY(pdf, PDFLIB_SHARED_LIBADD) + ;; + no) + ;; + *) + dnl build from a installed/binary pdflib distribution + if test -f "$PHP_PDFLIB/include/pdflib.h" ; then + PHP_EXTENSION(pdf, $ext_shared) + AC_DEFINE(HAVE_PDFLIB,1,[ ]) + AC_SUBST(PDFLIB_SHARED_LIBADD) + PHP_ADD_LIBRARY_WITH_PATH(pdf, $withval/lib, PDFLIB_SHARED_LIBADD) + PHP_ADD_INCLUDE($PHP_PDFLIB/include) + else + AC_MSG_ERROR([pdflib.h not found under $PHP_PDFLIB/include/]) + fi ;; + esac diff --git a/src/libs/pdflib/bind/pdflib/php/ext/pdf/config.php-406+.m4 b/src/libs/pdflib/bind/pdflib/php/ext/pdf/config.php-406+.m4 new file mode 100644 index 0000000000..bd828e9b3a --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/ext/pdf/config.php-406+.m4 @@ -0,0 +1,40 @@ +dnl $Id: config.php-406+.m4,v 1.1 2004/10/06 17:46:43 laplace Exp $ + +PHP_ARG_WITH(pdflib,whether to include PDFlib support, +[ --with-pdflib[=DIR] Include PDFlib 4.x support. DIR is the PDFlib + base install directory, defaults to /usr/local + Set DIR to "shared" to build as dl, or "shared,DIR" + to build as dl and still specify DIR.]) + + PHP_SUBST(PDFLIB_SHARED_LIBADD) + PHP_EXTENSION(pdf, $ext_shared) + + case "$PHP_PDFLIB" in + yes) + AC_CHECK_LIB(pdf, PDF_open_pdi, [ + AC_DEFINE(HAVE_PDFLIB,1,[ ]) + PHP_ADD_LIBRARY(pdf,, PDFLIB_SHARED_LIBADD) + ],[ + AC_MSG_ERROR(PDFlib extension requires PDFlib 4.x.) + ]) + PHP_ADD_LIBRARY(pdf,, PDFLIB_SHARED_LIBADD) + ;; + no) + ;; + *) + test -f $PHP_PDFLIB/include/pdflib.h && PDFLIB_INCLUDE="$PHP_PDFLIB/include" + if test -n "$PDFLIB_INCLUDE" ; then + PHP_CHECK_LIBRARY(pdf, PDF_open_pdi, [ + AC_DEFINE(HAVE_PDFLIB,1,[ ]) + PHP_ADD_LIBRARY_WITH_PATH(pdf, $PHP_PDFLIB/lib, PDFLIB_SHARED_LIBADD) + PHP_ADD_INCLUDE($PDFLIB_INCLUDE) + ],[ + AC_MSG_ERROR(PDFlib extension requires PDFlib 4.x.) + ],[ + -L$PHP_PDFLIB/lib + ]) + else + AC_MSG_ERROR([pdflib.h not found under $PHP_PDFLIB/include/]) + + fi ;; + esac diff --git a/src/libs/pdflib/bind/pdflib/php/ext/pdf/libs.php-404.mk b/src/libs/pdflib/bind/pdflib/php/ext/pdf/libs.php-404.mk new file mode 100644 index 0000000000..9ff618293b --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/ext/pdf/libs.php-404.mk @@ -0,0 +1,8 @@ +include $(top_builddir)/config_vars.mk +LTLIBRARY_OBJECTS = $(LTLIBRARY_SOURCES:.c=.lo) $(LTLIBRARY_OBJECTS_X) +LTLIBRARY_SHARED_OBJECTS = $(LTLIBRARY_OBJECTS:.lo=.slo) +$(LTLIBRARY_SHARED_NAME): $(LTLIBRARY_SHARED_OBJECTS) $(LTLIBRARY_DEPENDENCIES) + $(SHARED_LIBTOOL) --mode=link $(COMPILE) $(LDFLAGS) -o $@ -avoid-version -module -rpath $(phplibdir) $(LTLIBRARY_LDFLAGS) $(LTLIBRARY_OBJECTS) $(LTLIBRARY_SHARED_LIBADD) + $(SHARED_LIBTOOL) --mode=install cp $@ $(phplibdir) + +targets = $(LTLIBRARY_SHARED_NAME) diff --git a/src/libs/pdflib/bind/pdflib/php/ext/pdf/pdf.c b/src/libs/pdflib/bind/pdflib/php/ext/pdf/pdf.c new file mode 100644 index 0000000000..8e43576537 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/ext/pdf/pdf.c @@ -0,0 +1,3573 @@ +/* + +----------------------------------------------------------------------+ + | PHP version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2003 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Uwe Steinmann | + | Rainer Schaaf | + +----------------------------------------------------------------------+ +*/ + +/* $Id: pdf.c,v 1.1 2004/10/06 17:46:43 laplace Exp $ */ + +/* Bootstrap of PDFlib Feature setup */ +#define PDF_FEATURE_SERIAL + + +/* derived from: + Id: pdf.c,v 1.112.2.5 2003/04/30 21:54:02 iliaa Exp + + with some exeptions: + - pdf_get_major/minorversion not included, as pdf_get_value supports this + without a PDF-object + - #if ZEND_MODULE_API_NO >= 20010901 for new ZEND_MODULE support, + so that it compiles with older PHP Versions too + - TSRMLS fixes included only with ZEND_MODULE_API_NO >= 20010901 + would break older builds otherwise + - new PHP streams #if ZEND_MODULE_API_NO >= 20020429 && HAVE_PHP_STREAM + TODO: CVS (1.107/108/109/112) + - added better support to see if it comes as binary from PDFlib GmbH. + - change from emalloc to safe_emalloc (112.2.4 -> 112.2.5) not included + (would not be backwardcompatible with older php builds) + - TODO: merge back to PHP-CVS + */ + +/* pdflib 2.02 ... 4.0x is subject to the ALADDIN FREE PUBLIC LICENSE. + Copyright (C) 1997-1999 Thomas Merz. 2000-2002 PDFlib GmbH */ + +/* Note that there is no code from the pdflib package in this file */ + +/* {{{ includes + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "php_globals.h" +#include "zend_list.h" +#include "ext/standard/head.h" +#include "ext/standard/info.h" +#include "ext/standard/file.h" + +#if HAVE_LIBGD13 +#include "ext/gd/php_gd.h" +#if HAVE_GD_BUNDLED +#include "ext/gd/libgd/gd.h" +#else +#include "gd.h" +#endif +static int le_gd; +#endif + +#ifdef HAVE_UNISTD_H +# include +#endif +#ifdef PHP_WIN32 +# include +# include +#endif +/* }}} */ + +#if HAVE_PDFLIB + +#include "php_pdf.h" + +#if ((100*PDFLIB_MAJORVERSION+10*PDFLIB_MINORVERSION+PDFLIB_REVISION) >= 500) + /* This wrapper code will work only with PDFlib V5 or greater, + * because the special handling for returning 0 instead of -1 + * for PHP is now done in the PDFlib kernel + */ +#else + +#error "PDFlib version does not match PHP-wrapper code" + +#endif /* PDFlib >= V5 */ + +#undef VIRTUAL_DIR + +static int le_pdf; + +/* {{{ pdf_functions[] + */ +function_entry pdf_functions[] = { + /* p_font.c */ + PHP_FE(pdf_add_launchlink, NULL) + PHP_FE(pdf_add_locallink, NULL) + PHP_FE(pdf_add_note, NULL) + PHP_FE(pdf_add_pdflink, NULL) + PHP_FE(pdf_add_weblink, NULL) + PHP_FE(pdf_attach_file, NULL) + PHP_FE(pdf_set_border_color, NULL) + PHP_FE(pdf_set_border_dash, NULL) + PHP_FE(pdf_set_border_style, NULL) + + /* p_basic.c */ + PHP_FE(pdf_begin_page, NULL) + PHP_FE(pdf_close, NULL) + PHP_FE(pdf_delete, NULL) + PHP_FE(pdf_end_page, NULL) + PHP_FE(pdf_get_buffer, NULL) + PHP_FE(pdf_new, NULL) + PHP_FE(pdf_open_file, NULL) + + /* p_block.c */ + PHP_FE(pdf_fill_imageblock, NULL) + PHP_FE(pdf_fill_pdfblock, NULL) + PHP_FE(pdf_fill_textblock, NULL) + + /* p_color.c */ + PHP_FE(pdf_makespotcolor, NULL) + PHP_FE(pdf_setcolor, NULL) + PHP_FE(pdf_setgray_fill, NULL) /* deprecated (since 4.0) */ + PHP_FE(pdf_setgray_stroke, NULL) /* deprecated (since 4.0) */ + PHP_FE(pdf_setgray, NULL) /* deprecated (since 4.0) */ + PHP_FE(pdf_setrgbcolor_fill, NULL) /* deprecated (since 4.0) */ + PHP_FE(pdf_setrgbcolor_stroke, NULL)/* deprecated (since 4.0) */ + PHP_FE(pdf_setrgbcolor, NULL) /* deprecated (since 4.0) */ + + /* p_draw.c */ + PHP_FE(pdf_arc, NULL) + PHP_FE(pdf_arcn, NULL) + PHP_FE(pdf_circle, NULL) + PHP_FE(pdf_clip, NULL) + PHP_FE(pdf_closepath, NULL) + PHP_FE(pdf_closepath_fill_stroke, NULL) + PHP_FE(pdf_closepath_stroke, NULL) + PHP_FE(pdf_curveto, NULL) + PHP_FE(pdf_endpath, NULL) + PHP_FE(pdf_fill, NULL) + PHP_FE(pdf_fill_stroke, NULL) + PHP_FE(pdf_lineto, NULL) + PHP_FE(pdf_moveto, NULL) + PHP_FE(pdf_rect, NULL) + PHP_FE(pdf_stroke, NULL) + + /* p_encoding.c */ + PHP_FE(pdf_encoding_set_char, NULL) + + /* p_font.c */ + PHP_FE(pdf_findfont, NULL) + PHP_FE(pdf_load_font, NULL) + PHP_FE(pdf_setfont, NULL) + + /* p_gstate.c */ + PHP_FE(pdf_concat, NULL) + PHP_FE(pdf_initgraphics, NULL) + PHP_FE(pdf_restore, NULL) + PHP_FE(pdf_rotate, NULL) + PHP_FE(pdf_save, NULL) + PHP_FE(pdf_scale, NULL) + PHP_FE(pdf_setdash, NULL) + PHP_FE(pdf_setdashpattern, NULL) + PHP_FE(pdf_setflat, NULL) + PHP_FE(pdf_setlinecap, NULL) + PHP_FE(pdf_setlinejoin, NULL) + PHP_FE(pdf_setlinewidth, NULL) + PHP_FE(pdf_setmatrix, NULL) + PHP_FE(pdf_setmiterlimit, NULL) + PHP_FE(pdf_setpolydash, NULL) /* deprecated since V5.0 */ + PHP_FE(pdf_skew, NULL) + PHP_FE(pdf_translate, NULL) + + /* p_hyper.c */ + PHP_FE(pdf_add_bookmark, NULL) + PHP_FE(pdf_add_nameddest, NULL) + PHP_FE(pdf_set_info, NULL) + + /* p_icc.c */ + PHP_FE(pdf_load_iccprofile, NULL) + + /* p_image.c */ + PHP_FE(pdf_add_thumbnail, NULL) + PHP_FE(pdf_close_image, NULL) + PHP_FE(pdf_fit_image, NULL) + PHP_FE(pdf_load_image, NULL) + PHP_FE(pdf_open_ccitt, NULL) /* deprecated since V5.0 */ + PHP_FE(pdf_open_image, NULL) /* deprecated since V5.0 */ + PHP_FE(pdf_open_image_file, NULL) /* deprecated since V5.0 */ + PHP_FE(pdf_place_image, NULL) /* deprecated since V5.0 */ + + /* p_params.c */ + PHP_FE(pdf_get_parameter, NULL) + PHP_FE(pdf_get_value, NULL) + PHP_FE(pdf_set_parameter, NULL) + PHP_FE(pdf_set_value, NULL) + + /* p_pattern.c */ + PHP_FE(pdf_begin_pattern, NULL) + PHP_FE(pdf_end_pattern, NULL) + + /* p_pdi.c */ + PHP_FE(pdf_close_pdi, NULL) + PHP_FE(pdf_close_pdi_page, NULL) + PHP_FE(pdf_fit_pdi_page, NULL) + PHP_FE(pdf_get_pdi_parameter, NULL) + PHP_FE(pdf_get_pdi_value, NULL) + PHP_FE(pdf_open_pdi, NULL) + PHP_FE(pdf_open_pdi_page, NULL) + PHP_FE(pdf_place_pdi_page, NULL) /* deprecated since V5.0 */ + PHP_FE(pdf_process_pdi, NULL) + + /* p_resource.c */ + PHP_FE(pdf_create_pvf, NULL) + PHP_FE(pdf_delete_pvf, NULL) + + /* p_shading.c */ + PHP_FE(pdf_shading, NULL) + PHP_FE(pdf_shading_pattern, NULL) + PHP_FE(pdf_shfill, NULL) + + /* p_template.c */ + PHP_FE(pdf_begin_template, NULL) + PHP_FE(pdf_end_template, NULL) + + /* p_text.c */ + PHP_FE(pdf_continue_text, NULL) + PHP_FE(pdf_fit_textline, NULL) + PHP_FE(pdf_set_text_pos, NULL) + PHP_FE(pdf_show, NULL) + PHP_FE(pdf_show_boxed, NULL) + PHP_FE(pdf_show_xy, NULL) + PHP_FE(pdf_stringwidth, NULL) + + /* p_type3.c */ + PHP_FE(pdf_begin_font, NULL) + PHP_FE(pdf_begin_glyph, NULL) + PHP_FE(pdf_end_font, NULL) + PHP_FE(pdf_end_glyph, NULL) + + /* p_xgstate.c */ + PHP_FE(pdf_create_gstate, NULL) + PHP_FE(pdf_set_gstate, NULL) + + /* exception handling */ + PHP_FE(pdf_get_errnum, NULL) + PHP_FE(pdf_get_errmsg, NULL) + PHP_FE(pdf_get_apiname, NULL) + + /* End of the official PDFLIB V3.x/V4.x/V5.x API */ + +#if HAVE_LIBGD13 + /* not supported by PDFlib GmbH */ + PHP_FE(pdf_open_memory_image, NULL) +#endif + + {NULL, NULL, NULL} +}; +/* }}} */ + +/* {{{ pdf_module_entry + */ +zend_module_entry pdf_module_entry = { +#if ZEND_MODULE_API_NO >= 20010901 + STANDARD_MODULE_HEADER, +#endif + "pdf", + pdf_functions, + PHP_MINIT(pdf), + PHP_MSHUTDOWN(pdf), + NULL, + NULL, + PHP_MINFO(pdf), +#if ZEND_MODULE_API_NO >= 20010901 + NO_VERSION_YET, +#endif + STANDARD_MODULE_PROPERTIES +}; +/* }}} */ + +#ifdef COMPILE_DL_PDF +ZEND_GET_MODULE(pdf) +#endif + +/* PHP/PDFlib internal functions */ +/* {{{ _free_pdf_doc + */ +static void _free_pdf_doc(zend_rsrc_list_entry *rsrc) +{ + PDF *pdf = (PDF *)rsrc->ptr; + PDF_delete(pdf); +} +/* }}} */ + +/* {{{ custom_errorhandler + */ +static void custom_errorhandler(PDF *p, int errnum, const char *shortmsg) +{ + if (errnum == PDF_NonfatalError) + { + /* + * PDFlib warnings should be visible to the user. + * If he decides to live with PDFlib warnings + * he may use the PDFlib function + * pdf_set_parameter($p, "warning" 0) to switch off + * the warnings inside PDFlib. + */ + php_error(E_WARNING, "PDFlib warning %s", shortmsg); + } + else + { + /* give up in all other cases */ + php_error(E_ERROR, "PDFlib error %s", shortmsg); + } +} +/* }}} */ + +/* {{{ pdf_emalloc + */ +static void *pdf_emalloc(PDF *p, size_t size, const char *caller) +{ + return(emalloc(size)); +} +/* }}} */ + +/* {{{ pdf_realloc + */ +static void *pdf_realloc(PDF *p, void *mem, size_t size, const char *caller) +{ + return(erealloc(mem, size)); +} +/* }}} */ + +/* {{{ pdf_efree + */ +static void pdf_efree(PDF *p, void *mem) +{ + efree(mem); +} +/* }}} */ + +/* {{{ PHP_MINFO_FUNCTION + */ +PHP_MINFO_FUNCTION(pdf) +{ + char tmp[32]; + + snprintf(tmp, 31, "%d.%02d", PDF_get_majorversion(), PDF_get_minorversion() ); + tmp[31]=0; + + php_info_print_table_start(); + php_info_print_table_row(2, "PDF Support", "enabled" ); + php_info_print_table_row(2, "PDFlib GmbH Version", PDFLIB_VERSIONSTRING ); + php_info_print_table_row(2, "Revision", "$Revision: 1.1 $" ); + php_info_print_table_end(); + +} +/* }}} */ + +/* {{{ PHP_MINIT_FUNCTION + */ +PHP_MINIT_FUNCTION(pdf) +{ + if ((PDF_get_majorversion() != PDFLIB_MAJORVERSION) || + (PDF_get_minorversion() != PDFLIB_MINORVERSION)) { + php_error(E_ERROR,"PDFlib error: Version mismatch in wrapper code"); + } + le_pdf = zend_register_list_destructors_ex(_free_pdf_doc, NULL, "pdf object", module_number); + + /* this does something like setlocale("C", ...) in PDFlib 3.x */ + PDF_boot(); + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MSHUTDOWN_FUNCTION + */ +PHP_MSHUTDOWN_FUNCTION(pdf) +{ + PDF_shutdown(); + return SUCCESS; +} +/* }}} */ + + +/* p_annots.c */ + +/* {{{ proto void pdf_add_launchlink(int pdfdoc, float llx, float lly, float urx, float ury, string filename) + * Add a launch annotation (to a target of arbitrary file type). */ +PHP_FUNCTION(pdf_add_launchlink) +{ + zval **p, **llx, **lly, **urx, **ury, **filename; + PDF *pdf; + const char * vfilename; + + if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &p, &llx, &lly, &urx, &ury, &filename) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_double_ex(llx); + convert_to_double_ex(lly); + convert_to_double_ex(urx); + convert_to_double_ex(ury); + convert_to_string_ex(filename); + +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(filename), &vfilename TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(filename), &vfilename); +# endif +#else + vfilename = Z_STRVAL_PP(filename); +#endif + + PDF_add_launchlink(pdf, + (float) Z_DVAL_PP(llx), + (float) Z_DVAL_PP(lly), + (float) Z_DVAL_PP(urx), + (float) Z_DVAL_PP(ury), + vfilename); + + RETURN_TRUE; +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto void pdf_add_locallink(int pdfdoc, float llx, float lly, float urx, float ury, int page, string optlist) + * Add a link annotation to a target within the current PDF file. */ +PHP_FUNCTION(pdf_add_locallink) +{ + zval **p, **llx, **lly, **urx, **ury, **page, **optlist; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &p, &llx, &lly, &urx, &ury, &page, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_double_ex(llx); + convert_to_double_ex(lly); + convert_to_double_ex(urx); + convert_to_double_ex(ury); + convert_to_long_ex(page); + convert_to_string_ex(optlist); + + PDF_add_locallink(pdf, + (float) Z_DVAL_PP(llx), + (float) Z_DVAL_PP(lly), + (float) Z_DVAL_PP(urx), + (float) Z_DVAL_PP(ury), + Z_LVAL_PP(page), + Z_STRVAL_PP(optlist)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_add_note(int pdfdoc, float llx, float lly, float urx, float ury, string contents, string title, string icon, int open) + * Add a note annotation. icon is one of of "comment", "insert", "note", "paragraph", "newparagraph", "key", or "help". */ +PHP_FUNCTION(pdf_add_note) +{ + zval **p, **llx, **lly, **urx, **ury, **contents, **title, **icon, **open; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 9 || zend_get_parameters_ex(9, &p, &llx, &lly, &urx, &ury, &contents, &title, &icon, &open) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_double_ex(llx); + convert_to_double_ex(lly); + convert_to_double_ex(urx); + convert_to_double_ex(ury); + convert_to_string_ex(contents); + convert_to_string_ex(title); + convert_to_string_ex(icon); + convert_to_long_ex(open); + + PDF_add_note2(pdf, + (float) Z_DVAL_PP(llx), + (float) Z_DVAL_PP(lly), + (float) Z_DVAL_PP(urx), + (float) Z_DVAL_PP(ury), + Z_STRVAL_PP(contents), + Z_STRLEN_PP(contents), + Z_STRVAL_PP(title), + Z_STRLEN_PP(title), + Z_STRVAL_PP(icon), + Z_LVAL_PP(open)); + + RETURN_TRUE; +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto void pdf_add_pdflink(int pdfdoc, float llx, float lly, float urx, float ury, string filename, int page, string optlist) + * Add a file link annotation (to a PDF target). */ +PHP_FUNCTION(pdf_add_pdflink) +{ + zval **p, **llx, **lly, **urx, **ury, **filename, **page, **optlist; + PDF *pdf; + const char * vfilename; + + if (ZEND_NUM_ARGS() != 8 || zend_get_parameters_ex(8, &p, &llx, &lly, &urx, &ury, &filename, &page, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_double_ex(llx); + convert_to_double_ex(lly); + convert_to_double_ex(urx); + convert_to_double_ex(ury); + convert_to_string_ex(filename); + convert_to_long_ex(page); + convert_to_string_ex(optlist); +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(filename), &vfilename TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(filename), &vfilename); +# endif +#else + vfilename = Z_STRVAL_PP(filename); +#endif + + PDF_add_pdflink(pdf, (float) Z_DVAL_PP(llx), + (float) Z_DVAL_PP(lly), + (float) Z_DVAL_PP(urx), + (float) Z_DVAL_PP(ury), + vfilename, + Z_LVAL_PP(page), + Z_STRVAL_PP(optlist)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_add_weblink(int pdfdoc, float llx, float lly, float urx, float ury, string url) + * Add a weblink annotation to a target URL on the Web. */ +PHP_FUNCTION(pdf_add_weblink) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + convert_to_string_ex(arg6); + PDF_add_weblink(pdf, (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3), + (float) Z_DVAL_PP(arg4), + (float) Z_DVAL_PP(arg5), + Z_STRVAL_PP(arg6)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_attach_file(int pdfdoc, float lly, float lly, float urx, float ury, string filename, string description, string author, string mimetype, string icon) + * Add a file attachment annotation. icon is one of "graph", "paperclip", "pushpin", or "tag". */ +PHP_FUNCTION(pdf_attach_file) +{ + zval **p, **llx, **lly, **urx, **ury, **filename, **description, **author, **mimetype, **icon; + PDF *pdf; + const char * vfilename; + + if (ZEND_NUM_ARGS() != 10 || zend_get_parameters_ex(10, &p, &llx, &lly, &urx, &ury, &filename, &description, &author, &mimetype, &icon) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_double_ex(llx); + convert_to_double_ex(lly); + convert_to_double_ex(urx); + convert_to_double_ex(ury); + convert_to_string_ex(filename); + convert_to_string_ex(description); + convert_to_string_ex(author); + convert_to_string_ex(mimetype); + convert_to_string_ex(icon); + +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(filename), &vfilename TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(filename), &vfilename); +# endif +#else + vfilename = Z_STRVAL_PP(filename); +#endif + + + PDF_attach_file2(pdf, + (float) Z_DVAL_PP(llx), + (float) Z_DVAL_PP(lly), + (float) Z_DVAL_PP(urx), + (float) Z_DVAL_PP(ury), + vfilename, + 0, + Z_STRVAL_PP(description), + Z_STRLEN_PP(description), + Z_STRVAL_PP(author), + Z_STRLEN_PP(author), + Z_STRVAL_PP(mimetype), + Z_STRVAL_PP(icon)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_set_border_color(int pdfdoc, float red, float green, float blue) + * Set the border color for all kinds of annotations. */ +PHP_FUNCTION(pdf_set_border_color) +{ + zval **arg1, **arg2, **arg3, **arg4; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + PDF_set_border_color(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_set_border_dash(int pdfdoc, float b, float w) + * Set the border dash style for all kinds of annotations. See PDF_setdash(). */ +PHP_FUNCTION(pdf_set_border_dash) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + PDF_set_border_dash(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_set_border_style(int pdfdoc, string style, float width) + * Set the border style for all kinds of annotations. style is "solid" or "dashed". */ +PHP_FUNCTION(pdf_set_border_style) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + convert_to_double_ex(arg3); + PDF_set_border_style(pdf, Z_STRVAL_PP(arg2), (float) Z_DVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* p_basic.c */ + +/* {{{ proto void pdf_begin_page(int pdfdoc, float width, float height) + * Add a new page to the document. */ +PHP_FUNCTION(pdf_begin_page) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + PDF_begin_page(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_close(int pdfdoc) + * Close the generated PDF file, and release all document-related resources. */ +PHP_FUNCTION(pdf_close) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_close(pdf); + + RETURN_TRUE; +} + +/* }}} */ + +/* {{{ proto bool pdf_delete(int pdfdoc) + * Delete the PDF object, and free all internal resources. */ +PHP_FUNCTION(pdf_delete) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + +#ifndef Z_RESVAL /* for php 4.0.3pl1 */ +#define Z_RESVAL(zval) (zval).value.lval +#define Z_RESVAL_PP(zval_pp) Z_RESVAL(**zval_pp) +#endif + zend_list_delete(Z_RESVAL_PP(arg1)); + + RETURN_TRUE; +} + +/* }}} */ + +/* {{{ proto void pdf_end_page(int pdfdoc) + * Finish the page. */ +PHP_FUNCTION(pdf_end_page) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_end_page(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto int pdf_get_apiname(int pdfdoc); + * Get the name of the API function which threw the last exception or failed. */ +PHP_FUNCTION(pdf_get_apiname) +{ + zval **p; + PDF *pdf; + char *buffer; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + buffer = PDF_get_apiname(pdf); + + RETURN_STRING(buffer, 1); +} +/* }}} */ + +/* {{{ proto int pdf_get_buffer(int pdfdoc) + * Get the contents of the PDF output buffer. The result must be used by the client before calling any other PDFlib function. */ +PHP_FUNCTION(pdf_get_buffer) +{ + zval **arg1; + long size; + PDF *pdf; + const char *buffer; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + buffer = PDF_get_buffer(pdf, &size); + + RETURN_STRINGL((char *)buffer, size, 1); +} + +/* }}} */ + +/* {{{ proto int pdf_get_errmsg(int pdfdoc); + * Get the contents of the PDF output buffer. The result must be used by + * the client before calling any other PDFlib function. */ +PHP_FUNCTION(pdf_get_errmsg) +{ + zval **p; + PDF *pdf; + char *buffer; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + buffer = PDF_get_errmsg(pdf); + + RETURN_STRING(buffer, 1); +} +/* }}} */ + +/* {{{ proto int pdf_get_errnum(int pdfdoc); + * Get the descriptive text of the last thrown exception, or the reason of + * a failed function call.*/ +PHP_FUNCTION(pdf_get_errnum) +{ + zval **p; + PDF *pdf; + int retval; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + retval = PDF_get_errnum(pdf); + + RETURN_LONG(retval); +} +/* }}} */ + +/* {{{ proto int pdf_new() + * Creates a new PDF object */ +PHP_FUNCTION(pdf_new) +{ + PDF *pdf; + + pdf = PDF_new2(custom_errorhandler, pdf_emalloc, pdf_realloc, pdf_efree, NULL); + if (pdf != NULL) { + PDF_set_parameter(pdf, "imagewarning", "true"); + + /* Trigger special handling of PDFlib-handles for PHP */ + PDF_set_parameter(pdf, "hastobepos", "true"); + PDF_set_parameter(pdf, "binding", "PHP"); + ZEND_REGISTER_RESOURCE(return_value, pdf, le_pdf); + } else { + php_error(E_ERROR, "PDF_new: internal error"); + } + +} + +/* }}} */ + +/* {{{ proto int pdf_open_file(int pdfdoc [, char filename]) + * Create a new PDF file using the supplied file name. */ +PHP_FUNCTION(pdf_open_file) +{ + zval **p, **filename; + int pdf_file; + const char *vfilename; + int argc; + PDF *pdf; + + if((argc = ZEND_NUM_ARGS()) > 2) + WRONG_PARAM_COUNT; + + if (argc == 1) { + if (zend_get_parameters_ex(1, &p) == FAILURE) + WRONG_PARAM_COUNT; + } else { + if (zend_get_parameters_ex(2, &p, &filename) == FAILURE) + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + if (argc == 2) { + convert_to_string_ex(filename); +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(filename), &vfilename TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(filename), &vfilename); +# endif +#else + vfilename = Z_STRVAL_PP(filename); +#endif + + pdf_file = PDF_open_file(pdf, vfilename); + } else { + /* open in memory */ + pdf_file = PDF_open_file(pdf, ""); + } + + RETURN_LONG(pdf_file); /* change return from -1 to 0 handled by PDFlib */ +} + +/* }}} */ + +/* p_block.c */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_fill_imageblock(int pdfdoc, int page, string spotname, int image, string optlist); + * Process an image block according to its properties. */ +PHP_FUNCTION(pdf_fill_imageblock) +{ + zval **p, **page, **blockname, **image, **optlist; + PDF *pdf; + int retval; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &page, &blockname, &image, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(page); + convert_to_string_ex(blockname); + convert_to_long_ex(image); + convert_to_string_ex(optlist); + + retval = PDF_fill_imageblock(pdf, + Z_LVAL_PP(page), + Z_STRVAL_PP(blockname), + Z_LVAL_PP(image), + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* change return from -1 to 0 handled by PDFlib */ +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_fill_pdfblock(int pdfdoc, int page, string spotname, int contents, string optlist); + * Process a PDF block according to its properties. */ +PHP_FUNCTION(pdf_fill_pdfblock) +{ + zval **p, **page, **blockname, **contents, **optlist; + PDF *pdf; + int retval; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &page, &blockname, &contents, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(page); + convert_to_string_ex(blockname); + convert_to_long_ex(contents); + convert_to_string_ex(optlist); + + retval = PDF_fill_pdfblock(pdf, + Z_LVAL_PP(page), + Z_STRVAL_PP(blockname), + Z_LVAL_PP(contents), + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* change return from -1 to 0 handled by PDFlib */ +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_fill_textblock(int pdfdoc, int page, string spotname, string text, string optlist); + * Process a text block according to its properties. */ +PHP_FUNCTION(pdf_fill_textblock) +{ + zval **p, **page, **blockname, **text, **optlist; + PDF *pdf; + int retval; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &page, &blockname, &text, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(page); + convert_to_string_ex(blockname); + convert_to_string_ex(text); + convert_to_string_ex(optlist); + + retval = PDF_fill_textblock(pdf, + Z_LVAL_PP(page), + Z_STRVAL_PP(blockname), + Z_STRVAL_PP(text), + Z_STRLEN_PP(text), + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* change return from -1 to 0 handled by PDFlib */ +} +/* }}} */ + +/* p_color.c */ + +/* {{{ proto int pdf_makespotcolor(int pdfdoc, string spotname); + * Make a named spot color from the current color. */ +PHP_FUNCTION(pdf_makespotcolor) +{ + zval **arg1, **arg2; + PDF *pdf; + int spotcolor; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + + spotcolor = PDF_makespotcolor(pdf, + Z_STRVAL_PP(arg2), + Z_STRLEN_PP(arg2)); + + RETURN_LONG(spotcolor); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto void pdf_setcolor(int pdfdoc, string fstype, string colorspace, float c1 [, float c2 [, float c3 [, float c4]]]); + * Set the current color space and color. fstype is "fill", "stroke", or "both". */ +PHP_FUNCTION(pdf_setcolor) +{ + zval **p, **fstype, **colorspace, **c1, **c2, **c3, **c4; + PDF *pdf; + int argc = ZEND_NUM_ARGS(); + + if(argc < 4 || argc > 7) { + WRONG_PARAM_COUNT; + } + switch(argc) { + case 4: + if(zend_get_parameters_ex(4, &p, &fstype, &colorspace, &c1) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + case 5: + if(zend_get_parameters_ex(5, &p, &fstype, &colorspace, &c1, &c2) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + case 6: + if(zend_get_parameters_ex(6, &p, &fstype, &colorspace, &c1, &c2, &c3) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + case 7: + if(zend_get_parameters_ex(7, &p, &fstype, &colorspace, &c1, &c2, &c3, &c4) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(fstype); + convert_to_string_ex(colorspace); + convert_to_double_ex(c1); + if(argc > 4) convert_to_double_ex(c2); + if(argc > 5) convert_to_double_ex(c3); + if(argc > 6) convert_to_double_ex(c4); + + + PDF_setcolor(pdf, + Z_STRVAL_PP(fstype), + Z_STRVAL_PP(colorspace), + (float) Z_DVAL_PP(c1), + (float) ((argc>4) ? Z_DVAL_PP(c2):0), + (float) ((argc>5) ? Z_DVAL_PP(c3):0), + (float) ((argc>6) ? Z_DVAL_PP(c4):0)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setgray(int pdfdoc, float value) + * Depricated user pdf_setcolor instead */ +PHP_FUNCTION(pdf_setgray) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + PDF_setcolor(pdf, "both", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setgray_fill(int pdfdoc, float value) + * Depricated user pdf_setcolor instead */ +PHP_FUNCTION(pdf_setgray_fill) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + PDF_setcolor(pdf, "fill", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setgray_stroke(int pdfdoc, float value) + * Depricated user pdf_setcolor instead */ +PHP_FUNCTION(pdf_setgray_stroke) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + PDF_setcolor(pdf, "stroke", "gray", (float) Z_DVAL_PP(arg2), 0, 0, 0); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setrgbcolor(int pdfdoc, float red, float green, float blue) + * Depricated user pdf_setcolor instead */ +PHP_FUNCTION(pdf_setrgbcolor) +{ + zval **arg1, **arg2, **arg3, **arg4; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + PDF_setcolor(pdf, "both", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setrgbcolor_fill(int pdfdoc, float red, float green, float blue) + * Depricated user pdf_setcolor instead */ +PHP_FUNCTION(pdf_setrgbcolor_fill) +{ + zval **arg1, **arg2, **arg3, **arg4; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + PDF_setcolor(pdf, "fill", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setrgbcolor_stroke(int pdfdoc, float red, float green, float blue) + * Depricated user pdf_setcolor instead */ +PHP_FUNCTION(pdf_setrgbcolor_stroke) +{ + zval **arg1, **arg2, **arg3, **arg4; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + PDF_setcolor(pdf, "stroke", "rgb", (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), 0); + RETURN_TRUE; +} +/* }}} */ + +/* p_draw.c */ + +/* {{{ proto void pdf_arc(int pdfdoc, float x, float y, float r, float alpha, float beta) + * Draw a counterclockwise circular arc from alpha to beta degrees. */ +PHP_FUNCTION(pdf_arc) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + convert_to_double_ex(arg6); + + PDF_arc(pdf, (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3), + (float) Z_DVAL_PP(arg4), + (float) Z_DVAL_PP(arg5), + (float) Z_DVAL_PP(arg6)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_arcn(int pdfdoc, float x, float y, float r, float alpha, float beta); + * Draw a clockwise circular arc from alpha to beta degrees. */ +PHP_FUNCTION(pdf_arcn) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + convert_to_double_ex(arg6); + + PDF_arcn(pdf, + (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3), + (float) Z_DVAL_PP(arg4), + (float) Z_DVAL_PP(arg5), + (float) Z_DVAL_PP(arg6)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_circle(int pdfdoc, float x, float y, float r) + * Draw a circle with center (x, y) and radius r. */ +PHP_FUNCTION(pdf_circle) +{ + zval **arg1, **arg2, **arg3, **arg4; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + PDF_circle(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_clip(int pdfdoc) + * Use the current path as clipping path. */ +PHP_FUNCTION(pdf_clip) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_clip(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_closepath(int pdfdoc) + * Close the current path. */ +PHP_FUNCTION(pdf_closepath) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_closepath(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_closepath_fill_stroke(int pdfdoc) + * Close the path, fill, and stroke it. */ +PHP_FUNCTION(pdf_closepath_fill_stroke) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_closepath_fill_stroke(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_closepath_stroke(int pdfdoc) + * Close the path, and stroke it. */ +PHP_FUNCTION(pdf_closepath_stroke) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_closepath_stroke(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_curveto(int pdfdoc, float x1, float y1, float x2, float y2, float x3, float y3) + * Draw a Bezier curve from the current point, using 3 more control points. */ +PHP_FUNCTION(pdf_curveto) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + convert_to_double_ex(arg6); + convert_to_double_ex(arg7); + + PDF_curveto(pdf, (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3), + (float) Z_DVAL_PP(arg4), + (float) Z_DVAL_PP(arg5), + (float) Z_DVAL_PP(arg6), + (float) Z_DVAL_PP(arg7)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_endpath(int pdfdoc) + * End the current path without filling or stroking it. */ +PHP_FUNCTION(pdf_endpath) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_endpath(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_fill(int pdfdoc) + * Fill the interior of the path with the current fill color. */ +PHP_FUNCTION(pdf_fill) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_fill(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_fill_stroke(int pdfdoc) + * Fill and stroke the path with the current fill and stroke color. */ +PHP_FUNCTION(pdf_fill_stroke) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_fill_stroke(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_lineto(int pdfdoc, float x, float y) + * Draw a line from the current point to (x, y). */ +PHP_FUNCTION(pdf_lineto) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + PDF_lineto(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_moveto(int pdfdoc, float x, float y) + * Set the current point. */ +PHP_FUNCTION(pdf_moveto) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + PDF_moveto(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_rect(int pdfdoc, float x, float y, float width, float height) + * Draw a rectangle at lower left (x, y) with width and height. */ +PHP_FUNCTION(pdf_rect) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + + PDF_rect(pdf, (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3), + (float) Z_DVAL_PP(arg4), + (float) Z_DVAL_PP(arg5)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_stroke(int pdfdoc) + * Stroke the path with the current color and line width, and clear it. */ +PHP_FUNCTION(pdf_stroke) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_stroke(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* p_encoding.c */ + +/* {{{ proto void pdf_encoding_set_char(int pdfdoc, string encoding, int slot, string glyphname, int uv); + * Add a glyph name to a custom encoding. */ +PHP_FUNCTION(pdf_encoding_set_char) +{ + zval **p, **encoding, **slot, **glyphname, **uv; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &encoding, &slot, &glyphname, &uv) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(encoding); + convert_to_long_ex(slot); + convert_to_string_ex(glyphname); + convert_to_long_ex(uv); + + PDF_encoding_set_char(pdf, + Z_STRVAL_PP(encoding), + Z_LVAL_PP(slot), + Z_STRVAL_PP(glyphname), + Z_LVAL_PP(uv)); + + RETURN_TRUE; +} +/* }}} */ + + +/* p_font.c */ + +/* {{{ proto int pdf_findfont(int pdfdoc, string fontname, string encoding [, int embed]) + * Search a font, and prepare it for later use. PDF_load_font() is recommended. */ +PHP_FUNCTION(pdf_findfont) +{ + zval **arg1, **arg2, **arg3, **arg4; + int embed, font; + const char *fontname, *encoding; + PDF *pdf; + + switch (ZEND_NUM_ARGS()) { + case 3: + if (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + embed = 0; + break; + case 4: + if (zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_long_ex(arg4); + embed = Z_LVAL_PP(arg4); + break; + default: + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + fontname = Z_STRVAL_PP(arg2); + + convert_to_string_ex(arg3); + encoding = Z_STRVAL_PP(arg3); + + font = PDF_findfont(pdf, fontname, encoding, embed); + + RETURN_LONG(font); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_load_font(int pdfdoc, string fontname, string encoding, string optlist); + * Open and search a font, and prepare it for later use.*/ +PHP_FUNCTION(pdf_load_font) +{ + zval **p, **fontname, **encoding, **optlist; + PDF *pdf; + int reserved = 0; + int retval; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &p, &fontname, &encoding, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(fontname); + convert_to_string_ex(encoding); + convert_to_string_ex(optlist); + + retval = PDF_load_font(pdf, + Z_STRVAL_PP(fontname), + reserved, + Z_STRVAL_PP(encoding), + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto void pdf_setfont(int pdfdoc, int font, float fontsize) + * Set the current font in the given size, using a font handle returned by PDF_load_font(). */ +PHP_FUNCTION(pdf_setfont) +{ + zval **arg1, **arg2, **arg3; + int font; + float fontsize; + PDF *pdf; + + if(ZEND_NUM_ARGS() != 3) + WRONG_PARAM_COUNT; + if (zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) + WRONG_PARAM_COUNT; + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_long_ex(arg2); + font = Z_LVAL_PP(arg2); + + convert_to_double_ex(arg3); + fontsize = (float)Z_DVAL_PP(arg3); + + PDF_setfont(pdf, font, fontsize); + + RETURN_TRUE; +} +/* }}} */ + +/* p_gstate.c */ + +/* {{{ proto void pdf_concat(int pdfdoc, float a, float b, float c, float d, float e, float f) + * Concatenate a matrix to the current transformation matrix. */ +PHP_FUNCTION(pdf_concat) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + convert_to_double_ex(arg6); + convert_to_double_ex(arg7); + + PDF_concat(pdf, + (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3), + (float) Z_DVAL_PP(arg4), + (float) Z_DVAL_PP(arg5), + (float) Z_DVAL_PP(arg6), + (float) Z_DVAL_PP(arg7)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_initgraphics(int pdfdoc); + * Reset all color and graphics state parameters to their defaults. */ +PHP_FUNCTION(pdf_initgraphics) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_initgraphics(pdf); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_restore(int pdfdoc) + * Restore the most recently saved graphics state. */ +PHP_FUNCTION(pdf_restore) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_restore(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_rotate(int pdfdoc, float angle) + * Rotate the coordinate system by phi degrees. */ +PHP_FUNCTION(pdf_rotate) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + PDF_rotate(pdf, (float) Z_DVAL_PP(arg2)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_save(int pdfdoc) + * Save the current graphics state. */ +PHP_FUNCTION(pdf_save) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_save(pdf); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_scale(int pdfdoc, float x_scale, float y_scale) + * Scale the coordinate system. */ +PHP_FUNCTION(pdf_scale) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + PDF_scale(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setdash(int pdfdoc, float black, float white) + * Set the current dash pattern to b black and w white units. */ +PHP_FUNCTION(pdf_setdash) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + PDF_setdash(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setdashpattern(int pdfdoc, string optlist) + * Set a more complicated dash pattern defined by an optlist. */ +PHP_FUNCTION(pdf_setdashpattern) +{ + zval **p, **optlist; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &p, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(optlist); + + PDF_setdashpattern(pdf, Z_STRVAL_PP(optlist)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setflat(int pdfdoc, float flatness) + * Set the flatness to a value between 0 and 100 inclusive. */ +PHP_FUNCTION(pdf_setflat) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + + PDF_setflat(pdf, (float) Z_DVAL_PP(arg2)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setlinecap(int pdfdoc, int linecap) + * Set the linecap parameter to a value between 0 and 2 inclusive. */ +PHP_FUNCTION(pdf_setlinecap) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_long_ex(arg2); + + PDF_setlinecap(pdf, Z_LVAL_PP(arg2)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setlinejoin(int pdfdoc, int linejoin) + * Set the line join parameter to a value between 0 and 2 inclusive. */ +PHP_FUNCTION(pdf_setlinejoin) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_long_ex(arg2); + + PDF_setlinejoin(pdf, Z_LVAL_PP(arg2)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setlinewidth(int pdfdoc, float width) + * Set the current linewidth to width. */ +PHP_FUNCTION(pdf_setlinewidth) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + PDF_setlinewidth(pdf, (float) Z_DVAL_PP(arg2)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setmatrix(int pdfdoc, float a, float b, float c, float d, float e, float f) + * Explicitly set the current transformation matrix. */ +PHP_FUNCTION(pdf_setmatrix) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + convert_to_double_ex(arg6); + convert_to_double_ex(arg7); + + PDF_setmatrix(pdf, + (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3), + (float) Z_DVAL_PP(arg4), + (float) Z_DVAL_PP(arg5), + (float) Z_DVAL_PP(arg6), + (float) Z_DVAL_PP(arg7)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setmiterlimit(int pdfdoc, float value) + * Set the miter limit to a value greater than or equal to 1. */ +PHP_FUNCTION(pdf_setmiterlimit) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + + PDF_setmiterlimit(pdf, (float) Z_DVAL_PP(arg2)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_setpolydash(int pdfdoc, float darray) + * Deprecated, use PDF_setdashpattern() instead. */ +PHP_FUNCTION(pdf_setpolydash) +{ + zval **arg1, **arg2; + HashTable *array; + int len, i; + float *darray; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_array_ex(arg2); + array = Z_ARRVAL_PP(arg2); + len = zend_hash_num_elements(array); + + /* TODO: ohne Malloc: maximum ist 8 ... */ + if (NULL == (darray = emalloc(len * sizeof(double)))) { + RETURN_FALSE; + } + zend_hash_internal_pointer_reset(array); + for (i=0; i 2) { + convert_to_long_ex(parent); + parentid = Z_LVAL_PP(parent); + + if (ZEND_NUM_ARGS() > 3) { + convert_to_long_ex(open); + p_open = Z_LVAL_PP(open); + } else { + p_open = 0; + } + } else { + parentid = 0; + p_open = 0; + } + + /* will never return 0 */ + id = PDF_add_bookmark2(pdf, + Z_STRVAL_PP(text), + Z_STRLEN_PP(text), + parentid, + p_open); + + RETURN_LONG(id); +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto void pdf_add_nameddest(int pdfdoc, string name, string optlist) + * Set a more complicated dash pattern defined by an optlist. */ +PHP_FUNCTION(pdf_add_nameddest) +{ + zval **p, **name, **optlist; + PDF *pdf; + int reserved = 0; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &p, &name, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(name); + convert_to_string_ex(optlist); + + PDF_add_nameddest(pdf, + Z_STRVAL_PP(name), + reserved, + Z_STRVAL_PP(optlist)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto bool pdf_set_info(int pdfdoc, string key, string value) + * Fill document information field key with value. key is one of "Subject", "Title", "Creator", "Author", "Keywords", or a user-defined key. */ +PHP_FUNCTION(pdf_set_info) +{ + zval **p, **key, **value; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &p, &key, &value) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(key); + convert_to_string_ex(value); + + PDF_set_info2(pdf, + Z_STRVAL_PP(key), + Z_STRVAL_PP(value), + Z_STRLEN_PP(value)); + + RETURN_TRUE; +} +/* }}} */ + +/* p_icc.c */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_load_iccprofile(int pdfdoc, string profilename, string optlist); + * Search an ICC profile, and prepare it for later use. */ +PHP_FUNCTION(pdf_load_iccprofile) +{ + zval **p, **profilename, **optlist; + PDF *pdf; + int reserved = 0; + char * vprofilename; + int retval; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &p, &profilename, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(profilename); + convert_to_string_ex(optlist); + +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(profilename), &vprofilename TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(profilename), &vprofilename); +# endif +#else + vprofilename = Z_STRVAL_PP(profilename); +#endif + + + retval = PDF_load_iccprofile(pdf, + vprofilename, + reserved, + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* p_image.c */ + +/* {{{ proto void pdf_add_thumbnail(int pdfdoc, int image); + * Add an existing image as thumbnail for the current page. */ +PHP_FUNCTION(pdf_add_thumbnail) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_long_ex(arg2); + + PDF_add_thumbnail(pdf, + Z_LVAL_PP(arg2)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_close_image(int pdfdoc, int image) + * Close an image retrieved with PDF_load_image(). */ +PHP_FUNCTION(pdf_close_image) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + convert_to_long_ex(arg2); + + PDF_close_image(pdf, Z_LVAL_PP(arg2)); +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto void pdf_fit_image(int pdfdoc, int image, float x, float y, string optlist); + * Place an image or template at (x, y) with various options. */ +PHP_FUNCTION(pdf_fit_image) +{ + zval **p, **image, **x, **y, **optlist; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &image, &x, &y, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(image); + convert_to_double_ex(x); + convert_to_double_ex(y); + convert_to_string_ex(optlist); + + PDF_fit_image(pdf, + Z_LVAL_PP(image), + (float)Z_DVAL_PP(x), + (float)Z_DVAL_PP(y), + Z_STRVAL_PP(optlist)); + + RETURN_TRUE +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_load_image(int pdfdoc, string imagetype, string filename, string optlist); + * Open a (disk-based or virtual) image file with various options.*/ +PHP_FUNCTION(pdf_load_image) +{ + zval **p, **imagetype, **filename, **optlist; + PDF *pdf; + const char *vfilename; + int reserved = 0; + int retval; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &p, &imagetype, &filename, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(imagetype); + convert_to_string_ex(filename); + convert_to_string_ex(optlist); + +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(filename), &vfilename TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(filename), &vfilename); +# endif +#else + vfilename = Z_STRVAL_PP(filename); +#endif + + retval = PDF_load_image(pdf, + Z_STRVAL_PP(imagetype), + vfilename, + reserved, + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto int pdf_open_ccitt(int pdfdoc, string filename, int width, int height, int bitreverse, int k, int blackls1) + * Deprecated, use PDF_load_image() instead. */ +PHP_FUNCTION(pdf_open_ccitt) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7; + PDF *pdf; + int pdf_image; + char *image; + + if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(arg2), &image TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(arg2), &image); +# endif +#else + image = Z_STRVAL_PP(arg2); +#endif + + convert_to_long_ex(arg3); + convert_to_long_ex(arg4); + convert_to_long_ex(arg5); + convert_to_long_ex(arg6); + convert_to_long_ex(arg7); + + pdf_image = PDF_open_CCITT(pdf, + image, + Z_LVAL_PP(arg3), + Z_LVAL_PP(arg4), + Z_LVAL_PP(arg5), + Z_LVAL_PP(arg6), + Z_LVAL_PP(arg7)); + + RETURN_LONG(pdf_image); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto int pdf_open_image(int pdfdoc, string imagetype, string source, string data, long length, int width, int height, int components, int bpc, string params) + * Deprecated, use PDF_load_image() with virtual files instead. */ +PHP_FUNCTION(pdf_open_image) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6, **arg7, **arg8, **arg9, **arg10; + PDF *pdf; + int pdf_image; + + if (ZEND_NUM_ARGS() != 10 || zend_get_parameters_ex(10, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + convert_to_string_ex(arg3); + convert_to_string_ex(arg4); + convert_to_long_ex(arg5); + convert_to_long_ex(arg6); + convert_to_long_ex(arg7); + convert_to_long_ex(arg8); + convert_to_long_ex(arg9); + convert_to_string_ex(arg10); + + pdf_image = PDF_open_image(pdf, + Z_STRVAL_PP(arg2), + Z_STRVAL_PP(arg3), + Z_STRVAL_PP(arg4), + Z_LVAL_PP(arg5), + Z_LVAL_PP(arg6), + Z_LVAL_PP(arg7), + Z_LVAL_PP(arg8), + Z_LVAL_PP(arg9), + Z_STRVAL_PP(arg10)); + + RETURN_LONG(pdf_image); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto int pdf_open_image_file(int pdfdoc, string imagetype, string filename, string stringparam, int intparam) + * Deprecated, use PDF_load_image() instead. */ +PHP_FUNCTION(pdf_open_image_file) +{ + zval **p, **imagetype, **filename, **stringparam, **intparam; + PDF *pdf; + int pdf_image, argc; + const char *vfilename; + + switch ((argc = ZEND_NUM_ARGS())) { + case 3: + if (zend_get_parameters_ex(3, &p, &imagetype, &filename) == FAILURE) + WRONG_PARAM_COUNT; + break; + case 5: + if (zend_get_parameters_ex(5, &p, &imagetype, &filename, &stringparam, &intparam) == FAILURE) + WRONG_PARAM_COUNT; + break; + default: + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(imagetype); + convert_to_string_ex(filename); + +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(filename), &vfilename TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(filename), &vfilename); +# endif +#else + vfilename = Z_STRVAL_PP(filename); +#endif + + if (argc == 3) { + pdf_image = PDF_open_image_file(pdf, Z_STRVAL_PP(imagetype), vfilename, "", 0); + } else { + convert_to_string_ex(stringparam); + convert_to_long_ex(intparam); + + pdf_image = PDF_open_image_file(pdf, + Z_STRVAL_PP(imagetype), + vfilename, + Z_STRVAL_PP(stringparam), + Z_LVAL_PP(intparam)); + } + + RETURN_LONG(pdf_image); /* offset handled in PDFlib Kernel */ + +} +/* }}} */ + +/* {{{ proto void pdf_place_image(int pdfdoc, int image, float x, float y, float scale) + * Deprecated, use PDF_fit_image() instead. */ +PHP_FUNCTION(pdf_place_image) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_long_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + + PDF_place_image(pdf, Z_LVAL_PP(arg2), (float) Z_DVAL_PP(arg3), (float) Z_DVAL_PP(arg4), (float) Z_DVAL_PP(arg5)); + RETURN_TRUE; +} +/* }}} */ + +/* p_params.c */ + +/* {{{ proto string pdf_get_parameter(int pdfdoc, string key, float modifier) + * Get the contents of some PDFlib parameter with string type. */ +PHP_FUNCTION(pdf_get_parameter) +{ + zval **argv[3]; + int argc = ZEND_NUM_ARGS(); + PDF *pdf; + char *value; + + if(((argc < 2) || (argc > 3)) || zend_get_parameters_array_ex(argc, argv) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_string_ex(argv[1]); + + if(0 == (strcmp(Z_STRVAL_PP(argv[1]), "version"))) { + value = (char *) PDF_get_parameter(0, Z_STRVAL_PP(argv[1]), 0.0); + RETURN_STRING(value, 1); + } else if(0 == (strcmp(Z_STRVAL_PP(argv[1]), "pdi"))) { + value = (char *) PDF_get_parameter(0, Z_STRVAL_PP(argv[1]), 0.0); + RETURN_STRING(value, 1); + } else { + ZEND_FETCH_RESOURCE(pdf, PDF *, argv[0], -1, "pdf object", le_pdf); + } + + if(argc == 3) { + convert_to_double_ex(argv[2]); + value = (char *) PDF_get_parameter(pdf, Z_STRVAL_PP(argv[1]), (float) Z_DVAL_PP(argv[2])); + } else { + value = (char *) PDF_get_parameter(pdf, Z_STRVAL_PP(argv[1]), 0.0); + } + + RETURN_STRING(value, 1); +} +/* }}} */ + +/* {{{ proto float pdf_get_value(int pdfdoc, string key, float modifier) + * Get the value of some PDFlib parameter with float type. */ +PHP_FUNCTION(pdf_get_value) +{ + zval **argv[3]; + int argc = ZEND_NUM_ARGS(); + PDF *pdf; + double value; + + if(((argc < 2) || (argc > 3)) || zend_get_parameters_array_ex(argc, argv) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_string_ex(argv[1]); + if(argc == 3) + convert_to_double_ex(argv[2]); + + if(0 == (strcmp(Z_STRVAL_PP(argv[1]), "major"))) { + value = PDF_get_value(0, Z_STRVAL_PP(argv[1]), 0); + RETURN_DOUBLE(value); + } else if(0 == (strcmp(Z_STRVAL_PP(argv[1]), "minor"))) { + value = PDF_get_value(0, Z_STRVAL_PP(argv[1]), 0); + RETURN_DOUBLE(value); + } else if(0 == (strcmp(Z_STRVAL_PP(argv[1]), "revision"))) { + value = PDF_get_value(0, Z_STRVAL_PP(argv[1]), 0); + RETURN_DOUBLE(value); + } else { + ZEND_FETCH_RESOURCE(pdf, PDF *, argv[0], -1, "pdf object", le_pdf); + } + + if(argc < 3) { + value = PDF_get_value(pdf, + Z_STRVAL_PP(argv[1]), + 0.0); + } else { + value = PDF_get_value(pdf, + Z_STRVAL_PP(argv[1]), + (float)Z_DVAL_PP(argv[2])); + } + + RETURN_DOUBLE(value); +} +/* }}} */ + +/* {{{ proto void pdf_set_parameter(int pdfdoc, string key, string value) + * Set some PDFlib parameter with string type. */ +PHP_FUNCTION(pdf_set_parameter) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + convert_to_string_ex(arg3); + + PDF_set_parameter(pdf, Z_STRVAL_PP(arg2), Z_STRVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_set_value(int pdfdoc, string key, float value) + * Set the value of some PDFlib parameter with float type. */ +PHP_FUNCTION(pdf_set_value) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + convert_to_double_ex(arg3); + PDF_set_value(pdf, Z_STRVAL_PP(arg2), (float)Z_DVAL_PP(arg3)); + + RETURN_TRUE; +} +/* }}} */ + +/* p_pattern.c */ + +/* {{{ proto int pdf_begin_pattern(int pdfdoc, float width, float height, float xstep, float ystep, int painttype); + * Start a new pattern definition. */ +PHP_FUNCTION(pdf_begin_pattern) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5, **arg6; + PDF *pdf; + int pattern_image; + + if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + convert_to_double_ex(arg4); + convert_to_double_ex(arg5); + convert_to_long_ex(arg6); + + pattern_image = PDF_begin_pattern(pdf, + (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3), + (float) Z_DVAL_PP(arg4), + (float) Z_DVAL_PP(arg5), + Z_LVAL_PP(arg6)); + + RETURN_LONG(pattern_image); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto void pdf_end_pattern(int pdfdoc); + * Finish the pattern definition. */ +PHP_FUNCTION(pdf_end_pattern) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + PDF_end_pattern(pdf); + + RETURN_TRUE; +} +/* }}} */ + +/* p_pdi.c */ + +/* {{{ proto void pdf_close_pdi(int pdfdoc, int doc); + * Close all open page handles, and close the input PDF document. */ +PHP_FUNCTION(pdf_close_pdi) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_long_ex(arg2); + + PDF_close_pdi(pdf, + Z_LVAL_PP(arg2)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_close_pdi_page(int pdfdoc, int page); + * Close the page handle, and free all page-related resources. */ +PHP_FUNCTION(pdf_close_pdi_page) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_long_ex(arg2); + + PDF_close_pdi_page(pdf, + Z_LVAL_PP(arg2)); + + RETURN_TRUE; +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto void pdf_fit_pdi_page(int pdfdoc, int page, float x, float y, string optlist); + * Place an imported PDF page with the lower left corner at (x, y) with + * various options.*/ +PHP_FUNCTION(pdf_fit_pdi_page) +{ + zval **p, **page, **x, **y, **optlist; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &page, &x, &y, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(page); + convert_to_double_ex(x); + convert_to_double_ex(y); + convert_to_string_ex(optlist); + + PDF_fit_pdi_page(pdf, + Z_LVAL_PP(page), + (float)Z_DVAL_PP(x), + (float)Z_DVAL_PP(y), + Z_STRVAL_PP(optlist)); + + RETURN_TRUE +} +/* }}} */ + +/* TODO [reserved] */ +/* {{{ proto string pdf_get_pdi_parameter(int pdfdoc, string key, int doc, int page, int reserved); + * Get the contents of some PDI document parameter with string type. */ +PHP_FUNCTION(pdf_get_pdi_parameter) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5; + PDF *pdf; + const char *buffer; + int size; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + convert_to_long_ex(arg3); + convert_to_long_ex(arg4); + convert_to_long_ex(arg5); + + buffer = PDF_get_pdi_parameter(pdf, + Z_STRVAL_PP(arg2), + Z_LVAL_PP(arg3), + Z_LVAL_PP(arg4), + Z_LVAL_PP(arg5), + &size); + + RETURN_STRINGL((char *)buffer, size, 1); +} +/* }}} */ + +/* TODO [reserved] */ +/* {{{ proto float pdf_get_pdi_value(int pdfdoc, string key, int doc, int page, int reserved); + * Get the contents of some PDI document parameter with numerical type. */ +PHP_FUNCTION(pdf_get_pdi_value) +{ + zval **arg1, **arg2, **arg3, **arg4, **arg5; + PDF *pdf; + double value; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + convert_to_long_ex(arg3); + convert_to_long_ex(arg4); + convert_to_long_ex(arg5); + + value = (double)PDF_get_pdi_value(pdf, + Z_STRVAL_PP(arg2), + Z_LVAL_PP(arg3), + Z_LVAL_PP(arg4), + Z_LVAL_PP(arg5)); + + RETURN_DOUBLE(value); +} +/* }}} */ + +/* TODO [optlist, reserved] */ +/* {{{ proto int pdf_open_pdi(int pdfdoc, string filename, string optlist, int reserved); + * Open a (disk-based or virtual) PDF document and prepare it for later use. */ +PHP_FUNCTION(pdf_open_pdi) +{ + zval **arg1, **arg2, **arg3, **arg4; + PDF *pdf; + int pdi_handle; + char *file; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + convert_to_string_ex(arg3); + convert_to_long_ex(arg4); + +#ifdef VIRTUAL_DIR +# if ZEND_MODULE_API_NO >= 20010901 + virtual_filepath(Z_STRVAL_PP(arg2), &file TSRMLS_CC); +# else + virtual_filepath(Z_STRVAL_PP(arg2), &file); +# endif +#else + file = Z_STRVAL_PP(arg2); +#endif + + pdi_handle = PDF_open_pdi(pdf, + file, + Z_STRVAL_PP(arg3), + Z_LVAL_PP(arg4)); + + RETURN_LONG(pdi_handle); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_open_pdi_page(int pdfdoc, int doc, int pagenumber, string optlist); + * Prepare a page for later use with PDF_place_pdi_page(). */ +PHP_FUNCTION(pdf_open_pdi_page) +{ + zval **p, **doc, **pagenumber, **optlist; + PDF *pdf; + int pdi_image; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &p, &doc, &pagenumber, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(doc); + convert_to_long_ex(pagenumber); + convert_to_string_ex(optlist); + + pdi_image = PDF_open_pdi_page(pdf, + Z_LVAL_PP(doc), + Z_LVAL_PP(pagenumber), + Z_STRVAL_PP(optlist)); + + RETURN_LONG(pdi_image); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto void pdf_place_pdi_page(int pdfdoc, int page, float x, float y, float sx, float sy) + * Deprecated, use PDF_fit_pdi_page( ) instead. */ +PHP_FUNCTION(pdf_place_pdi_page) +{ + zval **p, **page, **x, **y, **sx, **sy; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &p, &page, &x, &y, &sx, &sy) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(page); + convert_to_double_ex(x); + convert_to_double_ex(y); + convert_to_double_ex(sx); + convert_to_double_ex(sy); + + PDF_place_pdi_page(pdf, + Z_LVAL_PP(page), + (float) Z_DVAL_PP(x), + (float) Z_DVAL_PP(y), + (float) Z_DVAL_PP(sx), + (float) Z_DVAL_PP(sy)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto int pdf_process_pdi(int pdfdoc, int doc, int page, string optlist); + * Perform various actions on a PDI document. */ +PHP_FUNCTION(pdf_process_pdi) +{ + zval **p, **doc, **page, **optlist; + PDF *pdf; + int retval; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &p, &doc, &page, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(doc); + convert_to_long_ex(page); + convert_to_string_ex(optlist); + + retval = PDF_process_pdi(pdf, + Z_LVAL_PP(doc), + Z_LVAL_PP(page), + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* p_resource.c */ + +/* TODO [optlist] */ +/* {{{ proto void pdf_create_pvf(int pdfdoc, string filename, string data, string optlist); + * Create a new virtual file. */ +PHP_FUNCTION(pdf_create_pvf) +{ + zval **p, **filename, **data, **optlist; + PDF *pdf; + int reserved = 0; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &p, &filename, &data, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(filename); + convert_to_string_ex(data); + convert_to_string_ex(optlist); + + PDF_create_pvf(pdf, + Z_STRVAL_PP(filename), + reserved, + Z_STRVAL_PP(data), + Z_STRLEN_PP(data), + Z_STRVAL_PP(optlist)); + + RETURN_TRUE +} +/* }}} */ + +/* {{{ proto int pdf_delete_pvf(int pdfdoc, string filname); + * Delete a virtual file. */ +PHP_FUNCTION(pdf_delete_pvf) +{ + zval **p, **filename; + PDF *pdf; + int retval; + int reserved = 0; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &p, &filename) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(filename); + + retval = PDF_delete_pvf(pdf, + Z_STRVAL_PP(filename), + reserved); + + RETURN_LONG(retval); /* change return from -1 to 0 handled by PDFlib */ +} +/* }}} */ + +/* p_shading.c */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_shading(int pdfdoc, string type, float x0, float y0, float x1, float y1, float c1, float c2, float c3, float c4, string optlist); + * Define a color blend (smooth shading) from the current fill color to the supplied color. */ +PHP_FUNCTION(pdf_shading) +{ + zval **p, **type, **x0, **y0, **x1, **y1, **c1, **c2, **c3, **c4, **optlist; + PDF *pdf; + int retval; + + if (ZEND_NUM_ARGS() != 11 || zend_get_parameters_ex(11, &p, &type, &x0, &y0, &x1, &y1, &c1, &c2, &c3, &c4, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(type); + convert_to_double_ex(x0); + convert_to_double_ex(y0); + convert_to_double_ex(x1); + convert_to_double_ex(y1); + convert_to_double_ex(c1); + convert_to_double_ex(c2); + convert_to_double_ex(c3); + convert_to_double_ex(c4); + convert_to_string_ex(optlist); + + retval = PDF_shading(pdf, + Z_STRVAL_PP(type), + (float) Z_DVAL_PP(x0), + (float) Z_DVAL_PP(y0), + (float) Z_DVAL_PP(x1), + (float) Z_DVAL_PP(y1), + (float) Z_DVAL_PP(c1), + (float) Z_DVAL_PP(c2), + (float) Z_DVAL_PP(c3), + (float) Z_DVAL_PP(c4), + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto int pdf_shading_pattern(int pdfdoc, int shading, string optlist); + * Define a shading pattern using a shading object. */ +PHP_FUNCTION(pdf_shading_pattern) +{ + zval **p, **shading, **optlist; + PDF *pdf; + int retval; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &p, &shading, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(shading); + convert_to_string_ex(optlist); + + retval = PDF_shading_pattern(pdf, + Z_LVAL_PP(shading), + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto void pdf_shfill(int pdfdoc, int shading); + * Fill an area with a shading, based on a shading object. */ +PHP_FUNCTION(pdf_shfill) +{ + zval **p, **shading; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &p, &shading) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(shading); + + PDF_shfill(pdf, + Z_LVAL_PP(shading)); + + RETURN_TRUE; +} +/* }}} */ + +/* p_template.c */ + +/* {{{ proto int pdf_begin_template(int pdfdoc, float width, float height); + * Start a new template definition. */ +PHP_FUNCTION(pdf_begin_template) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + int tmpl_image; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + + tmpl_image = PDF_begin_template(pdf, + (float) Z_DVAL_PP(arg2), + (float) Z_DVAL_PP(arg3)); + + RETURN_LONG(tmpl_image); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto void pdf_end_template(int pdfdoc); + * Finish a template definition. */ +PHP_FUNCTION(pdf_end_template) +{ + zval **arg1; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + + PDF_end_template(pdf); + + RETURN_TRUE; +} +/* }}} */ + +/* p_text.c */ + +/* {{{ proto void pdf_continue_text(int pdfdoc, string text) + * Print text at the next line. The spacing between lines is determined by the "leading" parameter. */ +PHP_FUNCTION(pdf_continue_text) +{ + zval **p, **text; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &p, &text) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(text); + + PDF_continue_text2(pdf, + Z_STRVAL_PP(text), + Z_STRLEN_PP(text)); + RETURN_TRUE; +} +/* }}} */ + +/* TODO [optlist] */ +/* {{{ proto void pdf_fit_textline(int pdfdoc, int text, float x, float y, string optlist); + * Place an imported PDF page with the lower left corner at (x, y) with + * various options.*/ +PHP_FUNCTION(pdf_fit_textline) +{ + zval **p, **text, **x, **y, **optlist; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &p, &text, &x, &y, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(text); + convert_to_double_ex(x); + convert_to_double_ex(y); + convert_to_string_ex(optlist); + + PDF_fit_textline(pdf, + Z_STRVAL_PP(text), + Z_STRLEN_PP(text), + (float)Z_DVAL_PP(x), + (float)Z_DVAL_PP(y), + Z_STRVAL_PP(optlist)); + + RETURN_TRUE +} +/* }}} */ + +/* {{{ proto void pdf_set_text_pos(int pdfdoc, float x, float y) + * Set the text output position. */ +PHP_FUNCTION(pdf_set_text_pos) +{ + zval **arg1, **arg2, **arg3; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_double_ex(arg2); + convert_to_double_ex(arg3); + PDF_set_text_pos(pdf, (float) Z_DVAL_PP(arg2), (float) Z_DVAL_PP(arg3)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_show(int pdfdoc, string text) + * Print text in the current font and size at the current position. */ +PHP_FUNCTION(pdf_show) +{ + zval **arg1, **arg2; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + + convert_to_string_ex(arg2); + PDF_show2(pdf, Z_STRVAL_PP(arg2), Z_STRLEN_PP(arg2)); + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto int pdf_show_boxed(int pdfdoc, string text, float x, float y, float width, float height, string hmode [, string feature]) + * Format text in the current font and size into the supplied text box according to the requested formatting mode, which must be one of "left", "right", "center", "justify", or "fulljustify". If width and height are 0, only a single line is placed at the point (left, top) in the requested mode. */ +PHP_FUNCTION(pdf_show_boxed) +{ + zval **argv[8]; + int argc = ZEND_NUM_ARGS(); + int nr; + char *feature; + PDF *pdf; + + if (((argc < 7) || (argc > 8)) || zend_get_parameters_array_ex(argc, argv) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, argv[0], -1, "pdf object", le_pdf); + + convert_to_string_ex(argv[1]); + convert_to_double_ex(argv[2]); + convert_to_double_ex(argv[3]); + convert_to_double_ex(argv[4]); + convert_to_double_ex(argv[5]); + convert_to_string_ex(argv[6]); + + if(argc == 8) { + convert_to_string_ex(argv[7]); + feature = Z_STRVAL_PP(argv[7]); + } else { + feature = NULL; + } + + nr = PDF_show_boxed(pdf, Z_STRVAL_PP(argv[1]), + (float) Z_DVAL_PP(argv[2]), + (float) Z_DVAL_PP(argv[3]), + (float) Z_DVAL_PP(argv[4]), + (float) Z_DVAL_PP(argv[5]), + Z_STRVAL_PP(argv[6]), + feature); + + RETURN_LONG(nr); +} +/* }}} */ + +/* {{{ proto void pdf_show_xy(int pdfdoc, string text, float x, float y) + * Print text in the current font at (x, y). */ +PHP_FUNCTION(pdf_show_xy) +{ + zval **p, **text, **x, **y; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &p, &text, &x, &y) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(text); + convert_to_double_ex(x); + convert_to_double_ex(y); + + PDF_show_xy2(pdf, + Z_STRVAL_PP(text), + Z_STRLEN_PP(text), + (float) Z_DVAL_PP(x), + (float) Z_DVAL_PP(y)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto float pdf_stringwidth(int pdfdoc, string text [, int font, float fontsize]) + * Return the width of text in an arbitrary font. */ +PHP_FUNCTION(pdf_stringwidth) +{ + zval **p, **text, **font, **fontsize; + int p_font; + double width, p_fontsize; + PDF *pdf; + + switch (ZEND_NUM_ARGS()) { + case 2: + if (zend_get_parameters_ex(2, &p, &text) == FAILURE) + WRONG_PARAM_COUNT; + break; + case 4: + if (zend_get_parameters_ex(4, &p, &text, &font, &fontsize) == FAILURE) + WRONG_PARAM_COUNT; + convert_to_long_ex(font); + break; + default: + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(text); + if (ZEND_NUM_ARGS() == 2) { + p_font = (int)PDF_get_value(pdf, "font", 0); + p_fontsize = PDF_get_value(pdf, "fontsize", 0); + } else { + convert_to_long_ex(font); + p_font = Z_LVAL_PP(font); + convert_to_double_ex(fontsize); + p_fontsize = Z_DVAL_PP(fontsize); + } + width = (double) PDF_stringwidth2(pdf, + Z_STRVAL_PP(text), + Z_STRLEN_PP(text), + p_font, + (float)p_fontsize); + + RETURN_DOUBLE(width); +} +/* }}} */ + +/* p_type3.c */ + +/* TODO [optlist] */ +/* {{{ proto void pdf_begin_font(string fontname, int subtype, float a, float b, + float c, float d, float e, float f, string optlist); + * Start a type 3 font definition. */ +PHP_FUNCTION(pdf_begin_font) +{ + zval **p, **fontname, **a, **b, **c, **d, **e, **f, **optlist; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 9 || zend_get_parameters_ex(9, &p, &fontname, &a, &b, &c, &d, &e, &f, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(fontname); + convert_to_double_ex(a); + convert_to_double_ex(b); + convert_to_double_ex(c); + convert_to_double_ex(d); + convert_to_double_ex(e); + convert_to_double_ex(f); + convert_to_string_ex(optlist); + + PDF_begin_font(pdf, + Z_STRVAL_PP(fontname), + 0, + (float) Z_DVAL_PP(a), + (float) Z_DVAL_PP(b), + (float) Z_DVAL_PP(c), + (float) Z_DVAL_PP(d), + (float) Z_DVAL_PP(e), + (float) Z_DVAL_PP(f), + Z_STRVAL_PP(optlist)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_begin_glyph(int pdfdoc, string glyphname, float wx, float llx, float lly, float urx, float ury) + * Start a type 3 glyph definition. */ +PHP_FUNCTION(pdf_begin_glyph) +{ + zval **p, **glyphname, **wx, **llx, **lly, **urx, **ury; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &p, &glyphname, &wx, &llx, &lly, &urx, &ury) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(glyphname); + convert_to_double_ex(wx); + convert_to_double_ex(llx); + convert_to_double_ex(lly); + convert_to_double_ex(urx); + convert_to_double_ex(ury); + + PDF_begin_glyph(pdf, + Z_STRVAL_PP(glyphname), + (float) Z_DVAL_PP(wx), + (float) Z_DVAL_PP(llx), + (float) Z_DVAL_PP(lly), + (float) Z_DVAL_PP(urx), + (float) Z_DVAL_PP(ury)); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_end_font(int pdfdoc); + * Terminate a type 3 font definition. */ +PHP_FUNCTION(pdf_end_font) +{ + zval **p; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + + PDF_end_font(pdf); + + RETURN_TRUE; +} +/* }}} */ + +/* {{{ proto void pdf_end_glyph(int pdfdoc); + * Terminate a type 3 glyph definition. */ +PHP_FUNCTION(pdf_end_glyph) +{ + zval **p; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + + PDF_end_glyph(pdf); + + RETURN_TRUE; +} +/* }}} */ + +/* p_xgstate.c */ + +/* {{{ proto int pdf_create_gstate(int pdfdoc, string optlist); + * Create a gstate object definition. */ +PHP_FUNCTION(pdf_create_gstate) +{ + zval **p, **optlist; + PDF *pdf; + int retval; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &p, &optlist) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_string_ex(optlist); + + retval = PDF_create_gstate(pdf, + Z_STRVAL_PP(optlist)); + + RETURN_LONG(retval); /* offset handled in PDFlib Kernel */ +} +/* }}} */ + +/* {{{ proto void pdf_set_gstate(int pdfdoc, int gstate); + * Activate a gstate object. */ +PHP_FUNCTION(pdf_set_gstate) +{ + zval **p, **gstate; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &p, &gstate) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, p, -1, "pdf object", le_pdf); + + convert_to_long_ex(gstate); + + PDF_set_gstate(pdf, + Z_LVAL_PP(gstate)); + + RETURN_TRUE; +} +/* }}} */ + +/* End of the official PDFlib GmbH V3.x/V4.x/V5.x API */ + +#if HAVE_LIBGD13 +/* {{{ proto int pdf_open_memory_image(int pdfdoc, int image) + Takes an GD image and returns an image for placement in a PDF document */ +PHP_FUNCTION(pdf_open_memory_image) +{ + zval **arg1, **arg2; + int i, j, color, count; + int pdf_image; + gdImagePtr im; + unsigned char *buffer, *ptr; + PDF *pdf; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf); + ZEND_GET_RESOURCE_TYPE_ID(le_gd,"gd"); + if(!le_gd) + { + php_error(E_ERROR, "Unable to find handle for GD image stream. Please check the GD extension is loaded."); + } + ZEND_FETCH_RESOURCE(im, gdImagePtr, arg2, -1, "Image", le_gd); + + count = 3 * im->sx * im->sy; + buffer = (unsigned char *) emalloc(count); + + ptr = buffer; + for(i=0; isy; i++) { + for(j=0; jsx; j++) { +#if HAVE_LIBGD20 + if(gdImageTrueColor(im)) { + if (im->tpixels && gdImageBoundsSafe(im, j, i)) { + color = gdImageTrueColorPixel(im, j, i); + *ptr++ = (color >> 16) & 0xFF; + *ptr++ = (color >> 8) & 0xFF; + *ptr++ = color & 0xFF; + } + } else { +#endif + if (im->pixels && gdImageBoundsSafe(im, j, i)) { + color = im->pixels[i][j]; + *ptr++ = im->red[color]; + *ptr++ = im->green[color]; + *ptr++ = im->blue[color]; + } +#if HAVE_LIBGD20 + } +#endif + } + } + + pdf_image = PDF_open_image(pdf, "raw", "memory", buffer, im->sx*im->sy*3, im->sx, im->sy, 3, 8, NULL); + efree(buffer); + + if (pdf_image == 0) { + efree(buffer); + RETURN_FALSE; + } + + RETURN_LONG(pdf_image); /* offset handled in PDFlib Kernel */ +} +/* }}} */ +#endif /* HAVE_LIBGD13 */ + +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 + */ diff --git a/src/libs/pdflib/bind/pdflib/php/ext/pdf/php_pdf.h b/src/libs/pdflib/bind/pdflib/php/ext/pdf/php_pdf.h new file mode 100644 index 0000000000..d3183d2040 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/ext/pdf/php_pdf.h @@ -0,0 +1,207 @@ +/* + +----------------------------------------------------------------------+ + | PHP version 4.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Uwe Steinmann | + +----------------------------------------------------------------------+ +*/ + +/* $Id: php_pdf.h,v 1.1 2004/10/06 17:46:43 laplace Exp $ */ +/* Derived from: + Id: php_pdf.h,v 1.22 2001/11/30 04:46:35 sniper Exp */ + +#ifndef PHP_PDF_H +#define PHP_PDF_H + +#if HAVE_PDFLIB + +#include + +extern zend_module_entry pdf_module_entry; +#define pdf_module_ptr &pdf_module_entry + +PHP_MINFO_FUNCTION(pdf); +PHP_MINIT_FUNCTION(pdf); +PHP_MSHUTDOWN_FUNCTION(pdf); + +/* p_font.c */ +PHP_FUNCTION(pdf_add_launchlink); +PHP_FUNCTION(pdf_add_locallink); +PHP_FUNCTION(pdf_add_note); +PHP_FUNCTION(pdf_add_pdflink); +PHP_FUNCTION(pdf_add_weblink); +PHP_FUNCTION(pdf_attach_file); +PHP_FUNCTION(pdf_set_border_color); +PHP_FUNCTION(pdf_set_border_dash); +PHP_FUNCTION(pdf_set_border_style); + +/* p_basic.c */ +PHP_FUNCTION(pdf_begin_page); +PHP_FUNCTION(pdf_close); +PHP_FUNCTION(pdf_delete); +PHP_FUNCTION(pdf_end_page); +PHP_FUNCTION(pdf_get_apiname); +PHP_FUNCTION(pdf_get_errmsg); +PHP_FUNCTION(pdf_get_errnum); +PHP_FUNCTION(pdf_get_buffer); +PHP_FUNCTION(pdf_new); +PHP_FUNCTION(pdf_open_file); + +/* p_block.c */ +PHP_FUNCTION(pdf_fill_imageblock); +PHP_FUNCTION(pdf_fill_pdfblock); +PHP_FUNCTION(pdf_fill_textblock); + +/* p_color.c */ +PHP_FUNCTION(pdf_makespotcolor); +PHP_FUNCTION(pdf_setcolor); +PHP_FUNCTION(pdf_setgray_fill); /* deprecated (since 4.0) */ +PHP_FUNCTION(pdf_setgray_stroke); /* deprecated (since 4.0) */ +PHP_FUNCTION(pdf_setgray); /* deprecated (since 4.0) */ +PHP_FUNCTION(pdf_setrgbcolor_fill); /* deprecated (since 4.0) */ +PHP_FUNCTION(pdf_setrgbcolor_stroke);/* deprecated (since 4.0) */ +PHP_FUNCTION(pdf_setrgbcolor); /* deprecated (since 4.0) */ + +/* p_draw.c */ +PHP_FUNCTION(pdf_arc); +PHP_FUNCTION(pdf_arcn); +PHP_FUNCTION(pdf_circle); +PHP_FUNCTION(pdf_clip); +PHP_FUNCTION(pdf_closepath); +PHP_FUNCTION(pdf_closepath_fill_stroke); +PHP_FUNCTION(pdf_closepath_stroke); +PHP_FUNCTION(pdf_curveto); +PHP_FUNCTION(pdf_endpath); +PHP_FUNCTION(pdf_fill); +PHP_FUNCTION(pdf_fill_stroke); +PHP_FUNCTION(pdf_lineto); +PHP_FUNCTION(pdf_moveto); +PHP_FUNCTION(pdf_rect); +PHP_FUNCTION(pdf_stroke); + +/* p_encoding.c */ +PHP_FUNCTION(pdf_encoding_set_char); + +/* p_font.c */ +PHP_FUNCTION(pdf_findfont); +PHP_FUNCTION(pdf_load_font); +PHP_FUNCTION(pdf_setfont); + +/* p_gstate.c */ +PHP_FUNCTION(pdf_concat); +PHP_FUNCTION(pdf_initgraphics); +PHP_FUNCTION(pdf_restore); +PHP_FUNCTION(pdf_rotate); +PHP_FUNCTION(pdf_save); +PHP_FUNCTION(pdf_scale); +PHP_FUNCTION(pdf_setdash); +PHP_FUNCTION(pdf_setdashpattern); +PHP_FUNCTION(pdf_setflat); +PHP_FUNCTION(pdf_setlinecap); +PHP_FUNCTION(pdf_setlinejoin); +PHP_FUNCTION(pdf_setlinewidth); +PHP_FUNCTION(pdf_setmatrix); +PHP_FUNCTION(pdf_setmiterlimit); +PHP_FUNCTION(pdf_setpolydash); /* deprecated since V5.0 */ +PHP_FUNCTION(pdf_skew); +PHP_FUNCTION(pdf_translate); + +/* p_hyper.c */ +PHP_FUNCTION(pdf_add_bookmark); +PHP_FUNCTION(pdf_add_nameddest); +PHP_FUNCTION(pdf_set_info); + +/* p_icc.c */ +PHP_FUNCTION(pdf_load_iccprofile); + +/* p_image.c */ +PHP_FUNCTION(pdf_add_thumbnail); +PHP_FUNCTION(pdf_close_image); +PHP_FUNCTION(pdf_fit_image); +PHP_FUNCTION(pdf_load_image); +PHP_FUNCTION(pdf_open_ccitt); /* deprecated since V5.0 */ +PHP_FUNCTION(pdf_open_image); /* deprecated since V5.0 */ +PHP_FUNCTION(pdf_open_image_file); /* deprecated since V5.0 */ +PHP_FUNCTION(pdf_place_image); /* deprecated since V5.0 */ + +/* p_params.c */ +PHP_FUNCTION(pdf_get_parameter); +PHP_FUNCTION(pdf_get_value); +PHP_FUNCTION(pdf_set_parameter); +PHP_FUNCTION(pdf_set_value); + +/* p_pattern.c */ +PHP_FUNCTION(pdf_begin_pattern); +PHP_FUNCTION(pdf_end_pattern); + +/* p_pdi.c */ +PHP_FUNCTION(pdf_close_pdi); +PHP_FUNCTION(pdf_close_pdi_page); +PHP_FUNCTION(pdf_fit_pdi_page); +PHP_FUNCTION(pdf_get_pdi_parameter); +PHP_FUNCTION(pdf_get_pdi_value); +PHP_FUNCTION(pdf_open_pdi); +PHP_FUNCTION(pdf_open_pdi_page); +PHP_FUNCTION(pdf_place_pdi_page); /* deprecated since V5.0 */ +PHP_FUNCTION(pdf_process_pdi); + +/* p_resource.c */ +PHP_FUNCTION(pdf_create_pvf); +PHP_FUNCTION(pdf_delete_pvf); + +/* p_shading.c */ +PHP_FUNCTION(pdf_shading); +PHP_FUNCTION(pdf_shading_pattern); +PHP_FUNCTION(pdf_shfill); + +/* p_template.c */ +PHP_FUNCTION(pdf_begin_template); +PHP_FUNCTION(pdf_end_template); + +/* p_text.c */ +PHP_FUNCTION(pdf_continue_text); +PHP_FUNCTION(pdf_fit_textline); +PHP_FUNCTION(pdf_set_text_pos); +PHP_FUNCTION(pdf_show); +PHP_FUNCTION(pdf_show_boxed); +PHP_FUNCTION(pdf_show_xy); +PHP_FUNCTION(pdf_stringwidth); + +/* p_type3.c */ +PHP_FUNCTION(pdf_begin_font); +PHP_FUNCTION(pdf_begin_glyph); +PHP_FUNCTION(pdf_end_font); +PHP_FUNCTION(pdf_end_glyph); + +/* p_xgstate.c */ +PHP_FUNCTION(pdf_create_gstate); +PHP_FUNCTION(pdf_set_gstate); + + +#if HAVE_LIBGD13 +/* not supported by PDFlib GmbH */ +PHP_FUNCTION(pdf_open_memory_image); +#endif + +#ifdef ZTS +#define PDFG(v) TSRMG(pdf_globals_id, php_pdf_globals *, v) +#else +#define PDFG(v) (pdf_globals.v) +#endif + + +#else +#define pdf_module_ptr NULL +#endif +#define phpext_pdf_ptr pdf_module_ptr +#endif /* PHP_PDF_H */ diff --git a/src/libs/pdflib/bind/pdflib/php/hello.php b/src/libs/pdflib/bind/pdflib/php/hello.php new file mode 100644 index 0000000000..f867ea2dc0 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/hello.php @@ -0,0 +1,40 @@ + diff --git a/src/libs/pdflib/bind/pdflib/php/image.php b/src/libs/pdflib/bind/pdflib/php/image.php new file mode 100644 index 0000000000..eeb0766de4 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/image.php @@ -0,0 +1,47 @@ + diff --git a/src/libs/pdflib/bind/pdflib/php/invoice.php b/src/libs/pdflib/bind/pdflib/php/invoice.php new file mode 100644 index 0000000000..5bfa489ade --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/invoice.php @@ -0,0 +1,152 @@ +"Super Kite", "price"=>20, "quantity"=>2), + array("name"=>"Turbo Flyer", "price"=>40, "quantity"=>5), + array("name"=>"Giga Trasch", "price"=>180, "quantity"=>1), + array("name"=>"Bare Bone Kit", "price"=>50, "quantity"=>3), + array("name"=>"Nitty Gritty", "price"=>20, "quantity"=>10), + array("name"=>"Pretty Dark Flyer","price"=>75, "quantity"=>1), + array("name"=>"Free Gift", "price"=>0, "quantity"=>1) + ); + +$months = array( "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December"); + +$p = PDF_new(); + +/* open new PDF file; insert a file name to create the PDF on disk */ +if (PDF_open_file($p, "") == 0) { + die("Error: " . PDF_get_errmsg($p)); +} + +PDF_set_parameter($p, "SearchPath", $searchpath); + +/* This line is required to avoid problems on Japanese systems */ +PDF_set_parameter($p, "hypertextencoding", "winansi"); + +PDF_set_info($p, "Creator", "invoice.php"); +PDF_set_info($p, "Author", "Thomas Merz"); +PDF_set_info($p, "Title", "PDFlib invoice generation demo (PHP)"); + +$form = PDF_open_pdi($p, $infile, "", 0); +if ($form == 0){ + die("Error: " . PDF_get_errmsg($p)); +} + +$page = PDF_open_pdi_page($p, $form, 1, ""); +if ($page == 0){ + die("Error: " . PDF_get_errmsg($p)); +} + + +$boldfont = PDF_load_font($p, "Helvetica-Bold", "winansi", ""); +$regularfont = PDF_load_font($p, "Helvetica", "winansi", ""); +$leading = $fontsize + 2; + +/* Establish coordinates with the origin in the upper left corner. */ +PDF_set_parameter($p, "topdown", "true"); + +PDF_begin_page($p, $pagewidth, $pageheight); /* A4 page */ + +PDF_fit_pdi_page($p, $page, 0, $pageheight, ""); +PDF_close_pdi_page($p, $page); + +PDF_setfont($p, $regularfont, $fontsize); + +/* print the address */ +$y = 170; +PDF_set_value($p, "leading", $leading); + +PDF_show_xy($p, "John Q. Doe", $col1, $y); +PDF_continue_text($p, "255 Customer Lane"); +PDF_continue_text($p, "Suite B"); +PDF_continue_text($p, "12345 User Town"); +PDF_continue_text($p, "Everland"); + +/* print the header and date */ + +PDF_setfont($p, $boldfont, $fontsize); +$y = 300; +PDF_show_xy($p, "INVOICE", $col1, $y); +$time = localtime(); +$buf = sprintf("%s %d, %d", $months[$time[4]], $time[3], $time[5]+1900); +PDF_fit_textline($p, $buf, $col5, $y, "position {100 0}"); + + +/* print the invoice header line */ +PDF_setfont($p, $boldfont, $fontsize); + +/* "position {0 0}" is left-aligned, "position {100 0}" right-aligned */ +$y = 370; +PDF_fit_textline($p, "ITEM", $col1, $y, "position {0 0}"); +PDF_fit_textline($p, "DESCRIPTION", $col2, $y, "position {0 0}"); +PDF_fit_textline($p, "QUANTITY", $col3, $y, "position {100 0}"); +PDF_fit_textline($p, "PRICE", $col4, $y, "position {100 0}"); +PDF_fit_textline($p, "AMOUNT", $col5, $y, "position {100 0}"); + +PDF_setfont($p, $regularfont, $fontsize); +$y += 2*$leading; +$total = 0; + +for ($i = 0; $i < count($data); $i++){ + PDF_show_xy($p, $i+1, $col1, $y); + + PDF_show_xy($p, $data[$i]{"name"}, $col2, $y); + PDF_fit_textline($p, $data[$i]{"quantity"}, $col3, $y, "position {100 0}"); + PDF_fit_textline($p, $data[$i]{"price"}, $col4, $y, "position {100 0}"); + $sum = $data[$i]{"price"}*$data[$i]{"quantity"}; + $buf = sprintf("%.2f", $sum); + PDF_fit_textline($p, $buf, $col5, $y, "position {100 0}"); + $y += $leading; + $total +=$sum; +} + +$y += $leading; +PDF_setfont($p, $boldfont, $fontsize); +PDF_fit_textline($p,sprintf("%.2f",$total), $col5, $y, "position {100 0}"); + +/* Print the closing text */ + +$y +=5*$leading; +PDF_setfont($p, $regularfont, $fontsize); +PDF_set_value($p, "leading", $leading); +PDF_show_boxed($p, $closingtext, + $col1, $y + 4*$leading, $col5-$col1, 4*$leading, "justify", ""); + +PDF_end_page($p); +PDF_close($p); +PDF_close_pdi($p, $form); + +$buf = PDF_get_buffer($p); +$len = strlen($buf); + +header("Content-type: application/pdf"); +header("Content-Length: $len"); +header("Content-Disposition: inline; filename=hello.pdf"); +print $buf; + +PDF_delete($p); +?> diff --git a/src/libs/pdflib/bind/pdflib/php/pdfclock.php b/src/libs/pdflib/bind/pdflib/php/pdfclock.php new file mode 100644 index 0000000000..1f83c8ee56 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/pdfclock.php @@ -0,0 +1,102 @@ + diff --git a/src/libs/pdflib/bind/pdflib/php/quickreference.php b/src/libs/pdflib/bind/pdflib/php/quickreference.php new file mode 100644 index 0000000000..746d01ff93 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/quickreference.php @@ -0,0 +1,89 @@ + diff --git a/src/libs/pdflib/bind/pdflib/php/readme.txt b/src/libs/pdflib/bind/pdflib/php/readme.txt new file mode 100644 index 0000000000..7501b76b03 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/php/readme.txt @@ -0,0 +1,243 @@ +=================================== +Notes on the PDFlib binding for PHP +=================================== + +The binary distribution of PDFlib supports using PDFlib as a loadable +module (DSO) in PHP. This implies some restrictions, but simplifies PDFlib +deployment a lot. Using PDFlib as a loadable module is the recommended +way for using PDFlib with PHP. + +If the loadable module does not fit your needs, the binary distribution +also includes a precompiled PDFlib library (bind/c/lib/libpdf.*), to be used in +your custom build process for PHP. This will allow you to integrate PDFlib +(including the PDI functionality) into your own PHP build process. + +Please note that only PDFlib Lite is available in source form. +PDFlib, PDFlib+PDI, and the PDFlib Personalization Server (PPS) are +available for commercial licensing only, and therefore require a +binary package. + +If your distribution does not contain the expected binaries, please contact +bindings@pdflib.com. We only include binaries for the most common PHP versions +to not overload the download package. Please include the platform and the +exact PHP version you are looking for. + +Of course you may also use PDFlib for PHP with the source distribution, but +since there are so many PHP configuration options we will only give a rough +overview how to do this. + +Summary of this document: + +- "Loadable Module (DSO)" + The recommended way for using PDFlib with PHP. + If you could not find a DSO for your PHP version/platform in the distribution + please contact bindings@pdflib.com. + +- "Rebuild PHP" + If the loadable module does not fit your needs, or if DSO modules are not + supported on your platform, you can rebuild PHP with PDFlib support. + Caution: this requires substantially more effort than the loadable module. + +- "Samples" + How to set up the supplied PDFlib examples. + + +Loadable Module +=============== + +Use the PDFlib loadable module from the "bind/php/" directory +of the PDFlib binary distribution. The name of the loadable module depends +on the platform: + + - Windows: libpdf_php.dll + - Linux: libpdf_php.so + - Other Unix systems: libpdf_php.* with the appropriate shared + library suffix + +The following conditions must be met in order to use PDFlib as a +loadable module: + + - PHP on your platform must support DSOs. This is the case on Windows + and many Unix platforms, but not all. For example, PHP does not support + DSOs on Mac OS X before PHP 4.3.0. + + - PDFlib support must not already have been compiled into your PHP version. + If your PHP already includes PDFlib support (this is the case for + versions of PHP distributed with many Linux distributions) you must + rebuild PHP with the "-with-pdflib=no" configure option. + (*HINT* for maintainers of Linux distributions: + include PDFlib support for PHP as DSO, this allows easier updates) + + - Several properties of your PHP version must match the loadable module + of PDFlib. The supplied binary modules for PDFlib have been built as + follows: + - nondebug version + - for supported PHP version numbers see "bind/php/ + - thread-safe (only relevant for Windows) + + If you get an error message similar to the following your PHP version + number does not match that of the PDFlib module: + Warning: pdf: Unable to initialize module + Module compiled with debug=0, thread-safety=1 module API=20001214 + PHP compiled with debug=0, thread-safety=1 module API=20001222 + Unfortunately new PHP version simply deny loading a wrong module + whithout any specific error message. + + All of these options must match. + + +If you can't meet the above conditions you must choose to "Rebuild PHP" as +described below (or ask us whether your combination will be available soon). + + +Installing the module on Windows: + + - Our DLLs have been tested with the binary PHP distribution which is + available from http://www.php.net. + + - The PDFlib binary distribution for Windows contains several DLLs + for different versions of PHP. Currently we offer the following + flavors: + + - "php-4.1.0\libpdf_php.dll" was built for PHP 4.1.0/4.1.1/4.2.0 + - "php-4.2.1\libpdf_php.dll" was built for PHP 4.2.1-4.3.5 + + - For the PHP installation please follow the documentation of your + PHP distribution and copy "bind/php//libpdf_php.dll" + to the directory which is specified in the "extension_dir" line in + php.ini. + +Installing the module on Unix: + + - The PDFlib binary distribution for Unix contains several shared libraries + for different versions of PHP. Currently we offer the following + flavors: + + - "php-4.1.0\libpdf_php.*" was built for PHP 4.1.0, 4.1.1, 4.2.0 + - "php-4.2.1\libpdf_php.*" was built for PHP 4.2.1-4.3.5 + + - Copy the file libpdf_php.* from the directory "bind/php/" + of the PDFlib binary distribution to the directory which is specified in + the "extension_dir" line in php.ini. + + +Using the module: + + - If you decide to load PDFlib each time PHP starts insert one line in + php.ini: + extension=libpdf_php.dll (on Windows) + or + extension = libpdf_php.so (on Unix) + + and restart apache, so that the changes are recognized. + You may check whether the installation did work. If you + don't find a PDF section please check your logfiles for the reason. + + - Without the "extension = ..." line in php.ini you must include the + following line in your PHP scripts: + dl("libpdf_php.dll"); (on Windows) + or + dl("libpdf_php.so"); (on Unix) + + In this case your php.ini needs these settings: + - php.ini must include the line "safe_mode=Off". + - php.ini must include the line "enable_dl=On". + + + +Rebuild PHP +=========== + +If the loadable module does not fit your needs, or if DSO modules are not +supported on your platform, you can rebuild PHP with PDFlib support. + +WARNING: this option requires substantial experience with building PHP. +It is not a matter of simply calling "make" and waiting for the result. +If you never built PHP from source code it is strongly recommended to +avoid this option. + +When recompiling PHP using the library from the binary PDFlib distribution +you have to use the library located in the "bind/c" directory of the PDFlib +distribution. + +Note: Building PDFlib for PHP from the source code of PDFlib is not supported +by PDFlib GmbH since we supply precompiled binaries (although it should work, +and therefore you will find hints how to do it below). + +Unix + - Unpack the PDFlib binary distribution to , + or unpack the PDFlib source distribution to , and + issue the command + + $ ./configure; make; make install + + - Copy some PDFlib support files for PHP to your PHP source tree (check + the section "Support Files" below to see which files apply to your + PHP version. + + $ cp /bind/php/ext/pdf/ /ext/pdf + + and rebuild the PHP configure script in the PHP directory (only + neccesary if you decided to use our config.m4 script): + + $ ./buildconf + + - For rebuilding PHP add the following to your PHP configure options: + --with-pdflib=/bind/c + + or if building PDFlib from source: + --with-pdflib[=] + + where will typically be something like + /usr/local or similar (the directory where "lib" and "include" for PDFlib + reside). + + - Now rebuild PHP as usual, and install it. + +Windows + - Create PDFlib.lib from the PDFlib sources. Change the project settings + to create a "Multithreaded DLL" library named pdflib.lib. + + - Copy the required PDFlib support files (see below) for PHP to your + PHP source tree. + + C:\> copy \bind\php\ext\pdf\ \ext\pdf + + - Now rebuild libpdf_php.dll. + + +Support files + The following files have to be copied from bind/php/ext/pdf to the ext/pdf + directory of your PHP source tree. Replacing config.m4 is optional, but + the config.m4 supplied by us is much simpler and therefor makes less + troubles if you manage to go through the buildconf process. + + Which files are needed depends on the PHP version you use: + + PHP 4.1.0-4.1.1 + config.php-406+.m4 -> config.m4 + pdf.c -> pdf.c + php_pdf.h -> php_pdf.h + + PHP 4.2.1-4.2.3 + config.php-406+.m4 -> config.m4 + pdf.c -> pdf.c + php_pdf.h -> php_pdf.h + + PHP 4.3.0-4.3.5 + pdf.c -> pdf.c + php_pdf.h -> php_pdf.h + + +Samples +======= + +To use the samples: + + - Copy some files: + $ cp bind/php/*.php .../htdocs # (to your htdocs directory) + $ cp bind/data/* .../htdocs/data # (to your htdocs) + + - point your browser to the sample files + + - enjoy the generated PDFs diff --git a/src/libs/pdflib/bind/pdflib/python/Makefile b/src/libs/pdflib/bind/pdflib/python/Makefile new file mode 100644 index 0000000000..df62bb7eb8 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/Makefile @@ -0,0 +1,56 @@ +# Makefile for PDFlib's Python binding +# $Id: Makefile,v 1.1 2004/10/06 17:46:43 laplace Exp $ + +top_builddir = ../../.. + +include $(top_builddir)/config/mkcommon.inc + +INCLUDES = $(PDFLIBINC) $(PYINCLUDE) +# special CFLAGS, as -ansi is not working here. +CFLAGS = $(DEFS) $(DEFINES) $(INCLUDES) + +LANG_LIBDIR = $(PYTHONLIBDIR) + +LIBNAME = pdflib_py$(LA) +OBJ = pdflib_py$(LO) +SRC = pdflib_py.c + + +include $(top_builddir)/config/mkbind.inc + +test:: all + @-(. ./pdflib_py$(LA); cd .libs; cp $$library_names ..) + -$(LIBTOOL_EXE) python hello.py + -$(LIBTOOL_EXE) python image.py + -$(LIBTOOL_EXE) python pdfclock.py + -$(LIBTOOL_EXE) python chartab.py + -$(LIBTOOL_EXE) python invoice.py + -$(LIBTOOL_EXE) python businesscard.py + -$(LIBTOOL_EXE) python quickreference.py + +smoke:: test + +install:: $(LIBNAME) + @-if test -f .libs/libpdflib_py.dylib; then \ + $(INSTALL_DATA) .libs/pdflib_py.so $(LANG_LIBDIR); \ + else \ + $(LIBTOOL) --mode=install $(INSTALL_DATA) \ + $(LIBNAME) $(LANG_LIBDIR); \ + fi + +uninstall:: + @-if test -f .libs/libpdflib_py.dylib; then \ + $(LIBTOOL) --mode=uninstall $(RM) $(LANG_LIBDIR)/pdflib_py.so\ + else \ + $(LIBTOOL) --mode=uninstall $(RM) $(LANG_LIBDIR)/$(LIBNAME) \ + fi + +clean:: + @-if test -f pdflib_py.la; then \ + (. ./pdflib_py.la; $(RM) $$library_names) \ + fi + $(RM) smoke_c_?.pdf + $(RM) hello.pdf image.pdf pdfclock.pdf chartab.pdf invoice.pdf + $(RM) businesscard.pdf quickreference.pdf + +# Automatically generated dependencies diff --git a/src/libs/pdflib/bind/pdflib/python/Python.dsp b/src/libs/pdflib/bind/pdflib/python/Python.dsp new file mode 100644 index 0000000000..e3e37047e5 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/Python.dsp @@ -0,0 +1,202 @@ +# Microsoft Developer Studio Project File - Name="Python" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Python - Win32 python23 +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Python.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Python.mak" CFG="Python - Win32 python23" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Python - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Python - Win32 oldpython" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Python - Win32 python21" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Python - Win32 python22" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Python - Win32 python23" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Python - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Python___Win32_Release" +# PROP BASE Intermediate_Dir "Python___Win32_Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /O2 /I "c:\Programme\Python20\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python15.lib /nologo /dll /debug /machine:I386 /out:"pdflib.dll" /pdbtype:sept +# SUBTRACT BASE LINK32 /nodefaultlib +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python20.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"pdflib_py.dll" /libpath:"c:\programme\python20\libs" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT LINK32 /debug /nodefaultlib + +!ELSEIF "$(CFG)" == "Python - Win32 oldpython" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Python___Win32_oldpython" +# PROP BASE Intermediate_Dir "Python___Win32_oldpython" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "oldpython" +# PROP Intermediate_Dir "oldpython" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "c:\Programme\Python 1.5.2\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "c:\Programme\Python 1.5.2\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python15.lib libpng.lib libtiff.lib zlib.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"pdflib_py.dll" /libpath:"..\..\..\..\libs\zlib" /libpath:"c:\programme\python 1.5.2\libs" /libpath:"..\..\..\libs\pdflib" /libpath:"..\..\..\..\libs\libpng" /libpath:"..\..\..\..\libs\libtiff" +# SUBTRACT BASE LINK32 /debug /nodefaultlib +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python15.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"oldpython/pdflib_py.dll" /libpath:"c:\programme\python 1.5.2\libs" /libpath:"..\..\..\libs\pdflib" +# SUBTRACT LINK32 /debug /nodefaultlib + +!ELSEIF "$(CFG)" == "Python - Win32 python21" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Python___Win32_python21" +# PROP BASE Intermediate_Dir "Python___Win32_python21" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "python21" +# PROP Intermediate_Dir "python21" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "D:\Programme\Python21\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "C:\Programme\Python21\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python15.lib libpng.lib libtiff.lib zlib.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"pdflib_py.dll" /libpath:"..\..\..\..\libs\zlib" /libpath:"c:\programme\python21\libs" /libpath:"..\..\..\libs\pdflib" /libpath:"..\..\..\..\libs\libpng" /libpath:"..\..\..\..\libs\libtiff" +# SUBTRACT BASE LINK32 /debug /nodefaultlib +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python21.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"python21/pdflib_py.dll" /libpath:"C:\programme\python21\libs" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT LINK32 /debug /nodefaultlib + +!ELSEIF "$(CFG)" == "Python - Win32 python22" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Python___Win32_python22" +# PROP BASE Intermediate_Dir "Python___Win32_python22" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "python22" +# PROP Intermediate_Dir "python22" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "C:\Programme\Python21\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "C:\Programme\Python22\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python21.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"python21/pdflib_py.dll" /libpath:"C:\programme\python21\libs" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT BASE LINK32 /debug /nodefaultlib +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python22.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"python22/pdflib_py.dll" /libpath:"C:\programme\python22\libs" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT LINK32 /debug /nodefaultlib + +!ELSEIF "$(CFG)" == "Python - Win32 python23" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Python___Win32_python23" +# PROP BASE Intermediate_Dir "Python___Win32_python23" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Python23" +# PROP Intermediate_Dir "Python23" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "C:\Programme\Python22\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "C:\Programme\Python23\include" /I "..\..\..\libs\pdflib" /D "__WIN32__" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python22.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"python22/pdflib_py.dll" /libpath:"C:\programme\python22\libs" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT BASE LINK32 /debug /nodefaultlib +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib python23.lib pdflib.lib /nologo /base:"0x55340000" /dll /pdb:none /machine:I386 /out:"python23/pdflib_py.dll" /libpath:"C:\programme\python23\libs" /libpath:"..\..\..\libs\pdflib\Release" +# SUBTRACT LINK32 /debug /nodefaultlib + +!ENDIF + +# Begin Target + +# Name "Python - Win32 Release" +# Name "Python - Win32 oldpython" +# Name "Python - Win32 python21" +# Name "Python - Win32 python22" +# Name "Python - Win32 python23" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pdflib_py.c +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/python/businesscard.py b/src/libs/pdflib/bind/pdflib/python/businesscard.py new file mode 100644 index 0000000000..f2f201856c --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/businesscard.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +# $Id: businesscard.py,v 1.1 2004/10/06 17:46:43 laplace Exp $ +# +# PDFlib client: block processing example in Python +# + +from sys import * +from pdflib_py import * + +infile = "boilerplate.pdf" + +# This is where font/image/PDF input files live. Adjust as necessary. +# +# Note that this directory must also contain the LuciduxSans font outline +# and metrics files. +# +searchpath = "../data" + +data_name = [ + "name", + "business.title", + "business.address.line1", + "business.address.city", + "business.telephone.voice", + "business.telephone.fax", + "business.email", + "business.homepage" ] + +data_value = [ + "Victor Kraxi", + "Chief Paper Officer", + "17, Aviation Road", + "Paperfield", + "phone +1 234 567-89", + "fax +1 234 567-98", + "victor@kraxi.com", + "www.kraxi.com" ] + +BLOCKCOUNT = 8 + +p = PDF_new() + +if PDF_open_file(p, "businesscard.pdf") == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +# Set the search path for fonts and PDF files +PDF_set_parameter(p, "SearchPath", searchpath) + +# This line is required to avoid problems on Japanese systems +PDF_set_parameter(p, "hypertextencoding", "winansi") + +PDF_set_info(p, "Creator", "businesscard.c") +PDF_set_info(p, "Author", "Thomas Merz") +PDF_set_info(p, "Title","PDFlib block processing sample (C)") + +blockcontainer = PDF_open_pdi(p, infile, "", 0) +if blockcontainer == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +page = PDF_open_pdi_page(p, blockcontainer, 1, "") +if page == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +PDF_begin_page(p, 20, 20) # dummy page size + +# This will adjust the page size to the block container's size. +PDF_fit_pdi_page(p, page, 0, 0, "adjustpage") + +# Fill all text blocks with dynamic data +for i in range(0, BLOCKCOUNT, 1): + if PDF_fill_textblock(p, page, data_name[i], data_value[i], \ + "embedding encoding=winansi") == -1: + print "Warning: " + PDF_get_errmsg(p) + "\n" + +PDF_end_page(p) # close page */ +PDF_close_pdi_page(p, page) + +PDF_close(p) # close PDF document */ +PDF_close_pdi(p, blockcontainer) + +PDF_delete(p) # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/python/chartab.py b/src/libs/pdflib/bind/pdflib/python/chartab.py new file mode 100644 index 0000000000..057b37e90e --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/chartab.py @@ -0,0 +1,95 @@ +#!/usr/bin/python +# $Id: chartab.py,v 1.1 2004/10/06 17:46:43 laplace Exp $ +# +# PDFlib client: hello character table in Python +# + +from sys import * +from pdflib_py import * + +# change these as required +fontname = "LuciduxSans-Oblique" + +# This is where font/image/PDF input files live. Adjust as necessary. +searchpath = "../data" + +# list of encodings to use +encoding = ["iso8859-1", "iso8859-2", "iso8859-15"] + +# whether or not to embed the font +embed = "" +# embed = "not " +embedding = "embedding" +# embedding = "" + +ENCODINGS = 3 +FONTSIZE = 16 +TOP = 700 +LEFT = 50 +YINCR = 2*FONTSIZE +XINCR = 2*FONTSIZE + +# create a new PDFlib object +p = PDF_new() + +# open new PDF file +if PDF_open_file(p, "chartab.pdf") == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +PDF_set_parameter(p, "openaction", "fitpage") +PDF_set_parameter(p, "fontwarning", "true") + +PDF_set_parameter(p, "SearchPath", searchpath) + +# This line is required to avoid problems on Japanese systems +PDF_set_parameter(p, "hypertextencoding", "winansi") + +PDF_set_info(p, "Creator", "chartab.c") +PDF_set_info(p, "Author", "Thomas Merz") +PDF_set_info(p, "Title", "Character table (C)") + +# loop over all encodings +for page in range(0, ENCODINGS, 1): + PDF_begin_page(p, 595, 842) # start a new page + + # print the heading and generate the bookmark + font = PDF_load_font(p, "Helvetica", "winansi", "") + PDF_setfont(p, font, FONTSIZE) + buf = fontname + " (" + encoding[page] + ") " + embed + "embedded" + + PDF_show_xy(p, buf, LEFT - XINCR, TOP + 3 * YINCR) + PDF_add_bookmark(p, buf, 0, 0) + + # print the row and column captions + PDF_setfont(p, font, 2 * FONTSIZE/3) + + for row in range(0, 16, 1): + buf = "x" + repr(row) + PDF_show_xy(p, buf, LEFT + row*XINCR, TOP + YINCR) + + buf = "x" + repr(row) + PDF_show_xy(p, buf, LEFT - XINCR, TOP - row * YINCR) + + # print the character table + font = PDF_load_font(p, fontname, encoding[page], embedding) + PDF_setfont(p, font, FONTSIZE) + + y = TOP + x = LEFT + + for row in range(0, 16, 1): + for col in range(0, 16, 1): + val = (16*row + col) + if val != 0: + buf = chr(val) + PDF_show_xy(p, buf, x, y) + x += XINCR + x = LEFT + y -= YINCR + + PDF_end_page(p) # close page + +PDF_close(p) # close PDF document + +PDF_delete(p) # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/python/hello.py b/src/libs/pdflib/bind/pdflib/python/hello.py new file mode 100644 index 0000000000..de576d8f0d --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/hello.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# $Id: hello.py,v 1.1 2004/10/06 17:46:43 laplace Exp $ +# +# PDFlib client: hello example in Python +# + +from sys import * +from pdflib_py import * + +# create a new PDFlib object +p = PDF_new() + +# open new PDF file +if PDF_open_file(p, "hello.pdf") == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +# This line is required to avoid problems on Japanese systems +PDF_set_parameter(p, "hypertextencoding", "winansi") + +PDF_set_info(p, "Author", "Thomas Merz") +PDF_set_info(p, "Creator", "hello.py") +PDF_set_info(p, "Title", "Hello world (Python)") + +PDF_begin_page(p, 595, 842) # start a new page + +font = PDF_load_font(p, "Helvetica-Bold", "winansi", "") + +PDF_setfont(p, font, 24) +PDF_set_text_pos(p, 50, 700) +PDF_show(p, "Hello world!") +PDF_continue_text(p, "(says Python)") +PDF_end_page(p) # close page + +PDF_close(p) # close PDF document + +PDF_delete(p) # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/python/image.py b/src/libs/pdflib/bind/pdflib/python/image.py new file mode 100644 index 0000000000..def94a4005 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/image.py @@ -0,0 +1,45 @@ +#!/usr/bin/python +# $Id: image.py,v 1.1 2004/10/06 17:46:43 laplace Exp $ +# +# PDFlib client: image example in Python +# + +from sys import * +from pdflib_py import * + +imagefile = "nesrin.jpg" + +# This is where font/image/PDF input files live. Adjust as necessary. +searchpath = "../data" + + +p = PDF_new() + +if PDF_open_file(p, "image.pdf") == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +PDF_set_parameter(p, "SearchPath", searchpath) + +# This line is required to avoid problems on Japanese systems +PDF_set_parameter(p, "hypertextencoding", "winansi") + +PDF_set_info(p, "Creator", "image.py") +PDF_set_info(p, "Author", "Thomas Merz") +PDF_set_info(p, "Title", "image sample (Python)") + +image = PDF_load_image(p, "auto", imagefile, "") + +if image == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(3) + +# dummy page size, will be adjusted by PDF_fit_image() +PDF_begin_page(p, 10, 10) +PDF_fit_image(p, image, 0, 0, "adjustpage") +PDF_close_image(p, image) +PDF_end_page(p) # close page + +PDF_close(p) # close PDF document + +PDF_delete(p) diff --git a/src/libs/pdflib/bind/pdflib/python/invoice.py b/src/libs/pdflib/bind/pdflib/python/invoice.py new file mode 100644 index 0000000000..b64ac19503 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/invoice.py @@ -0,0 +1,161 @@ +#!/usr/bin/python +# $Id: invoice.py,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib client: invoice generation demo +# + +from sys import * +import time +import fpformat +from pdflib_py import * + +infile = "stationery.pdf" + +# This is where font/image/PDF input files live. Adjust as necessary. +searchpath = "../data" + +col1 = 55 +col2 = 100 +col3 = 330 +col4 = 430 +col5 = 530 +fontsize = 12 +pagewidth = 595 +pageheight = 842 +closingtext = \ + "30 days warranty starting at the day of sale. " +\ + "This warranty covers defects in workmanship only. " +\ + "Kraxi Systems, Inc. will, at its option, repair or replace the " +\ + "product under the warranty. This warranty is not transferable. " +\ + "No returns or exchanges will be accepted for wet products." + +data_name = [ + "Super Kite", + "Turbo Flyer", + "Giga Trash", + "Bare Bone Kit", + "Nitty Gritty", + "Pretty Dark Flyer", + "Free Gift" ] +data_price = [ 20, 40, 180, 50, 20, 75, 0] +data_quantity = [ 2, 5, 1, 3, 10, 1, 1] + + +ARTICLECOUNT = 6 + +p = PDF_new() + +PDF_set_parameter(p, "tracefile", "invoice.trace") +PDF_set_parameter(p, "debug", "t") +# open new PDF file +if PDF_open_file(p, "invoice.pdf") == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +PDF_set_parameter(p, "SearchPath", searchpath) + +# This line is required to avoid problems on Japanese systems +PDF_set_parameter(p, "hypertextencoding", "winansi") + +PDF_set_info(p, "Creator", "invoice.c") +PDF_set_info(p, "Author", "Thomas Merz") +PDF_set_info(p, "Title", "PDFlib invoice generation demo (C)") + +form = PDF_open_pdi(p, infile, "", 0) +if form == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +page = PDF_open_pdi_page(p, form, 1, "") +if page == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +boldfont = PDF_load_font(p, "Helvetica-Bold", "winansi", "") +regularfont = PDF_load_font(p, "Helvetica", "winansi", "") +leading = fontsize + 2 + +# Establish coordinates with the origin in the upper left corner. +PDF_set_parameter(p, "topdown", "true") + +PDF_begin_page(p, pagewidth, pageheight) # A4 page + +PDF_fit_pdi_page(p, page, 0, pageheight, "") +PDF_close_pdi_page(p, page) + +PDF_setfont(p, regularfont, fontsize) + +# Print the address +y = 170 +PDF_set_value(p, "leading", leading) + +PDF_show_xy(p, "John Q. Doe", col1, y) +PDF_continue_text(p, "255 Customer Lane") +PDF_continue_text(p, "Suite B") +PDF_continue_text(p, "12345 User Town") +PDF_continue_text(p, "Everland") + +# Print the header and date + +PDF_setfont(p, boldfont, fontsize) +y = 300 +PDF_show_xy(p, "INVOICE", col1, y) + +buf = time.strftime("%x", time.gmtime(time.time())) +PDF_fit_textline(p, buf, col5, y, "position {100 0}") + +# Print the invoice header line +PDF_setfont(p, boldfont, fontsize) + +# "position {0 0}" is left-aligned, "position {100 0}" right-aligned +y = 370 +PDF_fit_textline(p, "ITEM", col1, y, "position {0 0}") +PDF_fit_textline(p, "DESCRIPTION", col2, y, "position {0 0}") +PDF_fit_textline(p, "QUANTITY", col3, y, "position {100 0}") +PDF_fit_textline(p, "PRICE", col4, y, "position {100 0}") +PDF_fit_textline(p, "AMOUNT", col5, y, "position {100 0}") + +# Print the article list + +PDF_setfont(p, regularfont, fontsize) +y += 2*leading +total = 0 + +for i in range(0, ARTICLECOUNT, 1): + buf = repr(i) + i +=1 + PDF_show_xy(p, buf, col1, y) + + PDF_show_xy(p, data_name[i], col2, y) + + buf = repr(data_quantity[i]) + PDF_fit_textline(p, buf, col3, y, "position {100 0}") + + buf = fpformat.fix(data_price[i], 2) + PDF_fit_textline(p, buf, col4, y, "position {100 0}") + + sum = data_price[i] * data_quantity[i] + buf = fpformat.fix(sum, 2) + PDF_fit_textline(p, buf, col5, y, "position {100 0}") + + y += leading + total += sum + +y += leading +PDF_setfont(p, boldfont, fontsize) +buf = fpformat.fix(total, 2) +PDF_fit_textline(p, buf, col5, y, "position {100 0}") + +# Print the closing text + +y += 5*leading +PDF_setfont(p, regularfont, fontsize) +PDF_set_value(p, "leading", leading) +PDF_show_boxed(p, closingtext, + col1, y + 4*leading, col5-col1, 4*leading, "justify", "") + +PDF_end_page(p) +PDF_close(p) +PDF_close_pdi(p, form) + +PDF_delete(p) diff --git a/src/libs/pdflib/bind/pdflib/python/pdfclock.py b/src/libs/pdflib/bind/pdflib/python/pdfclock.py new file mode 100644 index 0000000000..480d7ea1a0 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/pdfclock.py @@ -0,0 +1,96 @@ +#!/usr/bin/python +# $Id: pdfclock.py,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib client: pdfclock example in Python +# + +from sys import * +from time import * +from pdflib_py import * + +RADIUS = 200.0 +MARGIN = 20.0 + +p = PDF_new() + +if PDF_open_file(p, "pdfclock.pdf") == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +# This line is required to avoid problems on Japanese systems +PDF_set_parameter(p, "hypertextencoding", "winansi") + +PDF_set_info(p, "Creator", "pdfclock.py") +PDF_set_info(p, "Author", "Thomas Merz") +PDF_set_info(p, "Title", "PDF clock (Python)") + +PDF_begin_page(p, 2 * (RADIUS + MARGIN), 2 * (RADIUS + MARGIN)) + +PDF_translate(p, RADIUS + MARGIN, RADIUS + MARGIN) +PDF_setcolor(p, "fillstroke", "rgb", 0.0, 0.0, 1.0, 0.0) +PDF_save(p) + +# minute strokes +PDF_setlinewidth(p, 2.0) +for alpha in range(0, 360, 6): + PDF_rotate(p, 6.0) + PDF_moveto(p, RADIUS, 0.0) + PDF_lineto(p, RADIUS-MARGIN/3, 0.0) + PDF_stroke(p) + +PDF_restore(p) +PDF_save(p) + +# 5 minute strokes +PDF_setlinewidth(p, 3.0) +for alpha in range(0, 360, 30): + PDF_rotate(p, 30.0) + PDF_moveto(p, RADIUS, 0.0) + PDF_lineto(p, RADIUS-MARGIN, 0.0) + PDF_stroke(p) + +(tm_year, tm_month, tm_day, +tm_hour, tm_min, tm_sec, +tm_weekday, tm_julian, tm_ds) = localtime(time()) + +# draw hour hand +PDF_save(p) +PDF_rotate(p, (-((tm_min/60.0) + tm_hour - 3.0) * 30.0)) +PDF_moveto(p, -RADIUS/10, -RADIUS/20) +PDF_lineto(p, RADIUS/2, 0.0) +PDF_lineto(p, -RADIUS/10, RADIUS/20) +PDF_closepath(p) +PDF_fill(p) +PDF_restore(p) + +# draw minute hand +PDF_save(p) +PDF_rotate(p, (-((tm_sec/60.0) + tm_min - 15.0) * 6.0)) +PDF_moveto(p, -RADIUS/10, -RADIUS/20) +PDF_lineto(p, RADIUS * 0.8, 0.0) +PDF_lineto(p, -RADIUS/10, RADIUS/20) +PDF_closepath(p) +PDF_fill(p) +PDF_restore(p) + +# draw second hand +PDF_setcolor(p, "fillstroke", "rgb", 1.0, 0.0, 0.0, 0.0) +PDF_setlinewidth(p, 2) +PDF_save(p) +PDF_rotate(p, -((tm_sec - 15.0) * 6.0)) +PDF_moveto(p, -RADIUS/5, 0.0) +PDF_lineto(p, RADIUS, 0.0) +PDF_stroke(p) +PDF_restore(p) + +# draw little circle at center +PDF_circle(p, 0, 0, RADIUS/30) +PDF_fill(p) + +PDF_restore(p) + +PDF_end_page(p) + +PDF_close(p) + +PDF_delete(p) # delete the PDFlib object diff --git a/src/libs/pdflib/bind/pdflib/python/pdflib_py.c b/src/libs/pdflib/bind/pdflib/python/pdflib_py.c new file mode 100644 index 0000000000..565a2d95f7 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/pdflib_py.c @@ -0,0 +1,3248 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdflib_py.c,v 1.1 2004/10/06 17:46:44 laplace Exp $ + * + * Wrapper code for the PDFlib Python binding + * + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +#include +#ifdef __cplusplus +} +#endif + +/* Compilers which are not strictly ANSI conforming can set PDF_VOLATILE + * to an empty value. + */ +#ifndef PDF_VOLATILE +#define PDF_VOLATILE volatile +#endif + +/* Definitions for Windows/Unix exporting */ +#if defined(__WIN32__) +# if defined(_MSC_VER) +# define SWIGEXPORT(a,b) __declspec(dllexport) a b +# else +# if defined(__BORLANDC__) +# define SWIGEXPORT(a,b) a _export b +# else +# define SWIGEXPORT(a,b) a b +# endif +# endif +#else +# define SWIGEXPORT(a,b) a b +#endif + +#ifdef SWIG_GLOBAL +#ifdef __cplusplus +#define SWIGSTATIC extern "C" +#else +#define SWIGSTATIC +#endif +#endif + +#ifndef SWIGSTATIC +#define SWIGSTATIC static +#endif + +typedef struct { + char *name; + PyObject *(*get_attr)(void); + int (*set_attr)(PyObject *); +} swig_globalvar; + +typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar **vars; + int nvars; + int maxvars; +} swig_varlinkobject; + +/* ---------------------------------------------------------------------- + swig_varlink_repr() + + Function for python repr method + ---------------------------------------------------------------------- */ + +static PyObject * +swig_varlink_repr(swig_varlinkobject *v) +{ + v = v; + return PyString_FromString(""); +} + +/* --------------------------------------------------------------------- + swig_varlink_print() + + Print out all of the global variable names + --------------------------------------------------------------------- */ + +static int +swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) +{ + + int i = 0; + flags = flags; + fprintf(fp,"Global variables { "); + while (v->vars[i]) { + fprintf(fp,"%s", v->vars[i]->name); + i++; + if (v->vars[i]) fprintf(fp,", "); + } + fprintf(fp," }\n"); + return 0; +} + +/* -------------------------------------------------------------------- + swig_varlink_getattr + + This function gets the value of a variable and returns it as a + PyObject. In our case, we'll be looking at the datatype and + converting into a number or string + -------------------------------------------------------------------- */ + +static PyObject * +swig_varlink_getattr(swig_varlinkobject *v, char *n) +{ + int i = 0; + char temp[128]; + + while (v->vars[i]) { + if (strcmp(v->vars[i]->name,n) == 0) { + return (*v->vars[i]->get_attr)(); + } + i++; + } + sprintf(temp,"C global variable %s not found.", n); + PyErr_SetString(PyExc_NameError,temp); + return NULL; +} + +/* ------------------------------------------------------------------- + swig_varlink_setattr() + + This function sets the value of a variable. + ------------------------------------------------------------------- */ + +static int +swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) +{ + char temp[128]; + int i = 0; + while (v->vars[i]) { + if (strcmp(v->vars[i]->name,n) == 0) { + return (*v->vars[i]->set_attr)(p); + } + i++; + } + sprintf(temp,"C global variable %s not found.", n); + PyErr_SetString(PyExc_NameError,temp); + return 1; +} + +statichere PyTypeObject varlinktype = { +/* PyObject_HEAD_INIT(&PyType_Type) Note : This doesn't work on some machines */ + PyObject_HEAD_INIT(0) + 0, + "varlink", /* Type name */ + sizeof(swig_varlinkobject), /* Basic size */ + 0, /* Itemsize */ + 0, /* Deallocator */ + (printfunc) swig_varlink_print, /* Print */ + (getattrfunc) swig_varlink_getattr, /* get attr */ + (setattrfunc) swig_varlink_setattr, /* Set attr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_mapping*/ + 0, /* tp_hash */ +}; + +/* Create a variable linking object for use later */ + +SWIGSTATIC PyObject * +SWIG_newvarlink(void) +{ + swig_varlinkobject *result = 0; + result = PyMem_NEW(swig_varlinkobject,1); + varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ + result->ob_type = &varlinktype; + /* _Py_NewReference(result); Does not seem to be necessary */ + result->nvars = 0; + result->maxvars = 64; + result->vars = (swig_globalvar **) malloc(64*sizeof(swig_globalvar *)); + result->vars[0] = 0; + result->ob_refcnt = 0; + Py_XINCREF((PyObject *) result); + return ((PyObject*) result); +} + +#ifdef PDFLIB_UNUSED +SWIGSTATIC void +SWIG_addvarlink(PyObject *p, char *name, + PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) +{ + swig_varlinkobject *v; + v= (swig_varlinkobject *) p; + + if (v->nvars >= v->maxvars -1) { + v->maxvars = 2*v->maxvars; + v->vars = (swig_globalvar **) realloc(v->vars,v->maxvars*sizeof(swig_globalvar *)); + if (v->vars == NULL) { + fprintf(stderr,"SWIG : Fatal error in initializing Python module.\n"); + exit(1); + } + } + v->vars[v->nvars] = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + v->vars[v->nvars]->name = (char *) malloc(strlen(name)+1); + strcpy(v->vars[v->nvars]->name,name); + v->vars[v->nvars]->get_attr = get_attr; + v->vars[v->nvars]->set_attr = set_attr; + v->nvars++; + v->vars[v->nvars] = 0; +} + +#endif /* PDFLIB_UNUSED */ + +#include + +#ifdef SWIG_GLOBAL +#ifdef __cplusplus +#define SWIGSTATIC extern "C" +#else +#define SWIGSTATIC +#endif +#endif + +#ifndef SWIGSTATIC +#define SWIGSTATIC static +#endif + + +/* SWIG pointer structure */ + +typedef struct SwigPtrType { + char *name; /* Datatype name */ + int len; /* Length (used for optimization) */ + void *(*cast)(void *); /* Pointer casting function */ + struct SwigPtrType *next; /* Linked list pointer */ +} SwigPtrType; + +/* Pointer cache structure */ + +typedef struct { + int stat; /* Status (valid) bit */ + SwigPtrType *tp; /* Pointer to type structure */ + char name[256]; /* Given datatype name */ + char mapped[256]; /* Equivalent name */ +} SwigCacheType; + +/* Some variables */ + +static int SwigPtrMax = 64; /* Max entries that can be currently held */ + /* This value may be adjusted dynamically */ +static int SwigPtrN = 0; /* Current number of entries */ +static int SwigPtrSort = 0; /* Status flag indicating sort */ +static int SwigStart[256]; /* Starting positions of types */ + +/* Pointer table */ +static SwigPtrType *SwigPtrTable = 0; /* Table containing pointer equivalences */ + +/* Cached values */ + +#define SWIG_CACHESIZE 8 +#define SWIG_CACHEMASK 0x7 +static SwigCacheType SwigCache[SWIG_CACHESIZE]; +static int SwigCacheIndex = 0; +static int SwigLastCache = 0; + +/* Sort comparison function */ +static int swigsort(const void *data1, const void *data2) { + SwigPtrType *d1 = (SwigPtrType *) data1; + SwigPtrType *d2 = (SwigPtrType *) data2; + return strcmp(d1->name,d2->name); +} + +/* Binary Search function */ +static int swigcmp(const void *key, const void *data) { + char *k = (char *) key; + SwigPtrType *d = (SwigPtrType *) data; + return strncmp(k,d->name,d->len); +} + +/* Register a new datatype with the type-checker */ + +SWIGSTATIC +void SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *)) { + + int i; + SwigPtrType *t = 0,*t1; + + /* Allocate the pointer table if necessary */ + + if (!SwigPtrTable) { + SwigPtrTable = (SwigPtrType *) malloc(SwigPtrMax*sizeof(SwigPtrType)); + SwigPtrN = 0; + } + /* Grow the table */ + if (SwigPtrN >= SwigPtrMax) { + SwigPtrMax = 2*SwigPtrMax; + SwigPtrTable = (SwigPtrType *) realloc((char *) SwigPtrTable,SwigPtrMax*sizeof(SwigPtrType)); + } + for (i = 0; i < SwigPtrN; i++) + if (strcmp(SwigPtrTable[i].name,origtype) == 0) { + t = &SwigPtrTable[i]; + break; + } + if (!t) { + t = &SwigPtrTable[SwigPtrN]; + t->name = origtype; + t->len = strlen(t->name); + t->cast = 0; + t->next = 0; + SwigPtrN++; + } + + /* Check for existing entry */ + + while (t->next) { + if ((strcmp(t->name,newtype) == 0)) { + if (cast) t->cast = cast; + return; + } + t = t->next; + } + + /* Now place entry (in sorted order) */ + + t1 = (SwigPtrType *) malloc(sizeof(SwigPtrType)); + t1->name = newtype; + t1->len = strlen(t1->name); + t1->cast = cast; + t1->next = 0; + t->next = t1; + SwigPtrSort = 0; +} + +/* Make a pointer value string */ + +SWIGSTATIC +void SWIG_MakePtr(char *_c, const void *_ptr, char *type) { + static char _hex[16] = + {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f'}; + unsigned long _p, _s; + char _result[20], *_r; /* Note : a 64-bit hex number = 16 digits */ + _r = _result; + _p = (unsigned long) _ptr; + if (_p > 0) { + while (_p > 0) { + _s = _p & 0xf; + *(_r++) = _hex[_s]; + _p = _p >> 4; + } + *_r = '_'; + while (_r >= _result) + *(_c++) = *(_r--); + } else { + strcpy (_c, "NULL"); + } + if (_ptr) + strcpy (_c, type); +} + +/* Function for getting a pointer value */ + +SWIGSTATIC +char *SWIG_GetPtr(char *_c, void **ptr, char *_t) +{ + unsigned long _p; + char temp_type[256]; + char *name; + int i, len; + SwigPtrType *sp,*tp; + SwigCacheType *cache; + int start, end; + _p = 0; + + /* Pointer values must start with leading underscore */ + if (*_c == '_') { + _c++; + /* Extract hex value from pointer */ + while (*_c) { + if ((*_c >= '0') && (*_c <= '9')) + _p = (_p << 4) + (*_c - '0'); + else if ((*_c >= 'a') && (*_c <= 'f')) + _p = (_p << 4) + ((*_c - 'a') + 10); + else + break; + _c++; + } + + if (_t) { + if (strcmp(_t,_c)) { + if (!SwigPtrSort) { + qsort((void *) SwigPtrTable, SwigPtrN, sizeof(SwigPtrType), swigsort); + for (i = 0; i < 256; i++) { + SwigStart[i] = SwigPtrN; + } + for (i = SwigPtrN-1; i >= 0; i--) { + SwigStart[(int) (SwigPtrTable[i].name[1])] = i; + } + for (i = 255; i >= 1; i--) { + if (SwigStart[i-1] > SwigStart[i]) + SwigStart[i-1] = SwigStart[i]; + } + SwigPtrSort = 1; + for (i = 0; i < SWIG_CACHESIZE; i++) + SwigCache[i].stat = 0; + } + + /* First check cache for matches. Uses last cache value as starting point */ + cache = &SwigCache[SwigLastCache]; + for (i = 0; i < SWIG_CACHESIZE; i++) { + if (cache->stat) { + if (strcmp(_t,cache->name) == 0) { + if (strcmp(_c,cache->mapped) == 0) { + cache->stat++; + *ptr = (void *) _p; + if (cache->tp->cast) *ptr = (*(cache->tp->cast))(*ptr); + return (char *) 0; + } + } + } + SwigLastCache = (SwigLastCache+1) & SWIG_CACHEMASK; + if (!SwigLastCache) cache = SwigCache; + else cache++; + } + /* We have a type mismatch. Will have to look through our type + mapping table to figure out whether or not we can accept this datatype */ + + start = SwigStart[(int) _t[1]]; + end = SwigStart[(int) _t[1]+1]; + sp = &SwigPtrTable[start]; + while (start < end) { + if (swigcmp(_t,sp) == 0) break; + sp++; + start++; + } + if (start >= end) sp = 0; + /* Try to find a match for this */ + if (sp) { + while (swigcmp(_t,sp) == 0) { + name = sp->name; + len = sp->len; + tp = sp->next; + /* Try to find entry for our given datatype */ + while(tp) { + if (tp->len >= 255) { + return _c; + } + strcpy(temp_type,tp->name); + strncat(temp_type,_t+len,255-tp->len); + if (strcmp(_c,temp_type) == 0) { + + strcpy(SwigCache[SwigCacheIndex].mapped,_c); + strcpy(SwigCache[SwigCacheIndex].name,_t); + SwigCache[SwigCacheIndex].stat = 1; + SwigCache[SwigCacheIndex].tp = tp; + SwigCacheIndex = SwigCacheIndex & SWIG_CACHEMASK; + + /* Get pointer value */ + *ptr = (void *) _p; + if (tp->cast) *ptr = (*(tp->cast))(*ptr); + return (char *) 0; + } + tp = tp->next; + } + sp++; + /* Hmmm. Didn't find it this time */ + } + } + /* Didn't find any sort of match for this data. + Get the pointer value and return the received type */ + *ptr = (void *) _p; + return _c; + } else { + /* Found a match on the first try. Return pointer value */ + *ptr = (void *) _p; + return (char *) 0; + } + } else { + /* No type specified. Good luck */ + *ptr = (void *) _p; + return (char *) 0; + } + } else { + if (strcmp (_c, "NULL") == 0) { + *ptr = (void *) 0; + return (char *) 0; + } + *ptr = (void *) 0; + return _c; + } +} + +#include + +#include "pdflib.h" + + +/* Exception handling */ + +#define try PDF_TRY(p) +#define catch PDF_CATCH(p) { \ + char errmsg[1024];\ + sprintf(errmsg, "PDFlib Error [%d] %s: %s", PDF_get_errnum(p),\ + PDF_get_apiname(p), PDF_get_errmsg(p));\ + PyErr_SetString(PyExc_SystemError,errmsg); \ + return NULL; \ + } + +/* export the PDFlib routines to the shared library */ +#ifdef __MWERKS__ +#pragma export on +#endif + +static PyObject *_wrap_PDF_new(PyObject *self, PyObject *args) { + PDF *p; + char _ptemp[128]; + char versionbuf[32]; + + if(!PyArg_ParseTuple(args,":PDF_new")) + return NULL; + + p = PDF_new(); + + if (p) { +#if defined(PY_VERSION) + sprintf(versionbuf, "Python %s", PY_VERSION); +#elif defined(PATCHLEVEL) + sprintf(versionbuf, "Python %s", PATCHLEVEL); +#else + sprintf(versionbuf, "Python (unknown)"); +#endif + PDF_set_parameter(p, "binding", versionbuf); + } + else { + PyErr_SetString(PyExc_SystemError, "PDFlib error: in PDF_new()"); + return NULL; + } + + SWIG_MakePtr(_ptemp, (char *) p,"_PDF_p"); + return Py_BuildValue("s",_ptemp); +} + +static PyObject *_wrap_PDF_delete(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_delete",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_delete. Expected _PDF_p."); + return NULL; + } + } + + PDF_delete(p); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_open_file(PyObject *self, PyObject *args) { + int _result; + PDF * p; + char * _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ss:PDF_open_file",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_open_file. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_open_file(p,_arg1); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_close(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_close",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_close. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_close(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_get_buffer(PyObject *self, PyObject *args) { + char * _result; + PDF * p; + char * _argc0 = 0; + long size; + + if(!PyArg_ParseTuple(args,"s:PDF_get_buffer",&_argc0)) + return NULL; + + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError, + "Type error in argument 1 of PDF_get_buffer. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (char *)PDF_get_buffer(p, &size); + } catch; + return Py_BuildValue("s#", _result, (int) size); +} + +static PyObject *_wrap_PDF_begin_page(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_begin_page",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_begin_page. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_begin_page(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_end_page(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_end_page",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_end_page. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_end_page(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_get_errmsg(PyObject *self, PyObject *args) { + PyObject * _resultobj; + char * _result; + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_get_errmsg",&_argc0)) + return NULL; + + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_get_errmsg. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (char *)PDF_get_errmsg(p); + } catch; + _resultobj = Py_BuildValue("s", _result); + return _resultobj; +} + +static PyObject *_wrap_PDF_get_apiname(PyObject *self, PyObject *args) { + PyObject * _resultobj; + char * _result; + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_get_apiname",&_argc0)) + return NULL; + + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_get_apiname. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (char *)PDF_get_apiname(p); + } catch; + _resultobj = Py_BuildValue("s", _result); + return _resultobj; +} + +static PyObject *_wrap_PDF_get_errnum(PyObject *self, PyObject *args) { + PyObject * _resultobj; + int _result; + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_get_errnum",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_get_errnum. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_get_errnum(p); + } catch; + _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyObject *_wrap_PDF_set_parameter(PyObject *self, PyObject *args) { + PDF * p; + char * _arg1; + char * _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sss:PDF_set_parameter",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_set_parameter. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_set_parameter(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_get_parameter(PyObject *self, PyObject *args) { + PyObject * _resultobj; + char * _result; + PDF * p; + char * _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssf:PDF_get_parameter",&_argc0,&_arg1,&_arg2)) + return NULL; + + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_get_parameter. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (char *)PDF_get_parameter(p,_arg1,_arg2); + } catch; + _resultobj = Py_BuildValue("s", _result); + return _resultobj; +} + +static PyObject *_wrap_PDF_set_value(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + char * _arg1; + float _arg2; + char * _argc0 = 0; + + self = self; + if(!PyArg_ParseTuple(args,"ssf:PDF_set_value",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_set_value. Expected _PDF_p."); + return NULL; + } + } +{ + try { PDF_set_value(p,_arg1,_arg2); + } catch; +} Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_get_value(PyObject *self, PyObject *args) { + PyObject * _resultobj; + float _result; + PDF * p; + char * _arg1; + float _arg2; + char * _argc0 = 0; + + self = self; + if(!PyArg_ParseTuple(args,"ssf:PDF_get_value",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_get_value. Expected _PDF_p."); + return NULL; + } + } +{ + try { _result = (float)PDF_get_value(p,_arg1,_arg2); + } catch; +} _resultobj = Py_BuildValue("f",_result); + return _resultobj; +} + +static PyObject *_wrap_PDF_findfont(PyObject *self, PyObject *args) { + int _result; + PDF * p; + char * _arg1; + char * _arg2; + int _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sssi:PDF_findfont",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_findfont. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_findfont(p,_arg1,_arg2,_arg3); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_setfont(PyObject *self, PyObject *args) { + PDF * p; + int _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sif:PDF_setfont",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setfont. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setfont(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_show(PyObject *self, PyObject *args) { + PDF * p; + char * _arg1; + char * _argc0 = 0; + int len; + + if(!PyArg_ParseTuple(args,"ss:PDF_show",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_show. Expected _PDF_p."); + return NULL; + } + } + + try { + len = PyString_Size(PyTuple_GetItem(args, 1)); + PDF_show2(p,_arg1, len); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_show_xy(PyObject *self, PyObject *args) { + PDF * p; + char * _arg1; + float _arg2; + float _arg3; + char * _argc0 = 0; + int len; + + if(!PyArg_ParseTuple(args,"ssff:PDF_show_xy",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_show_xy. Expected _PDF_p."); + return NULL; + } + } + + try { + len = PyString_Size(PyTuple_GetItem(args, 1)); + PDF_show_xy2(p,_arg1, len, _arg2,_arg3); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_continue_text(PyObject *self, PyObject *args) { + PDF * p; + char * _arg1; + char * _argc0 = 0; + int len; + + if(!PyArg_ParseTuple(args,"ss:PDF_continue_text",&_argc0,&_arg1)) + return NULL; + + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_continue_text. Expected _PDF_p."); + return NULL; + } + } + + try { + len = PyString_Size(PyTuple_GetItem(args, 1)); + PDF_continue_text2(p,_arg1, len); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_show_boxed(PyObject *self, PyObject *args) { + int _result; + PDF * p; + char * _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + char * _arg6; + char * _arg7; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssffffss:PDF_show_boxed",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6,&_arg7)) + return NULL; + + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_show_boxed. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_show_boxed(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7); + } catch; + + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_set_text_pos(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_set_text_pos",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_set_text_pos. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_set_text_pos(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_stringwidth(PyObject *self, PyObject *args) { + float _result; + PDF * p; + char * _arg1; + int _arg2; + float _arg3; + char * _argc0 = 0; + int len; + + if(!PyArg_ParseTuple(args,"ssif:PDF_stringwidth",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_stringwidth. Expected _PDF_p."); + return NULL; + } + } + + try { + len = PyString_Size(PyTuple_GetItem(args, 1)); + _result = (float)PDF_stringwidth2(p,_arg1, len, _arg2,_arg3); + } catch; + return Py_BuildValue("f",_result); +} + +static PyObject *_wrap_PDF_setdash(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_setdash",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setdash. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setdash(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setpolydash(PyObject *self, PyObject *args) { + PyObject *val; + PDF *p; + float fval, carray[MAX_DASH_LENGTH]; + int PDF_VOLATILE length, i; + char *_argc0 = NULL; + PyObject *_argc1 = NULL; + + if(!PyArg_ParseTuple(args, "sO:PDF_setpolydash", &_argc0, &_argc1)) + return NULL; + + if (!_argc0 || SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError, + "Type error in argument 1 of PDF_setpolydash. Expected _PDF_p."); + return NULL; + } + + if (!_argc1 || !PyTuple_Check(_argc1)) { + PyErr_SetString(PyExc_TypeError, + "Type error in argument 2 of PDF_setpolydash. Expected float tuple."); + return NULL; + } + + length = PyTuple_Size(_argc1); + + if (length > MAX_DASH_LENGTH) + length = MAX_DASH_LENGTH; + + for (i = 0; i < length; i++) { + val = PyTuple_GetItem(_argc1, i); + if (!PyArg_Parse(val, "f:PDF_setpolydash", &fval)) { + PyErr_SetString(PyExc_TypeError, + "Type error in argument 2 of PDF_setpolydash. Expected float."); + return NULL; + } + carray[i] = fval; + } + + try { PDF_setpolydash(p, carray, length); + } catch; + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setflat(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sf:PDF_setflat",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setflat. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setflat(p,_arg1); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setlinejoin(PyObject *self, PyObject *args) { + PDF * p; + int _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"si:PDF_setlinejoin",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setlinejoin. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setlinejoin(p,_arg1); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setlinecap(PyObject *self, PyObject *args) { + PDF * p; + int _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"si:PDF_setlinecap",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setlinecap. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setlinecap(p,_arg1); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setmiterlimit(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sf:PDF_setmiterlimit",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setmiterlimit. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setmiterlimit(p,_arg1); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setlinewidth(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sf:PDF_setlinewidth",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setlinewidth. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setlinewidth(p,_arg1); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_save(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_save",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_save. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_save(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_restore(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_restore",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_restore. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_restore(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_translate(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_translate",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_translate. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_translate(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_scale(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_scale",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_scale. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_scale(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_rotate(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sf:PDF_rotate",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_rotate. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_rotate(p,_arg1); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_skew(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_skew",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_skew. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_skew(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_concat(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffff:PDF_concat", + &_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6)) + return NULL; + + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError, + "Type error in argument 1 of PDF_concat. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_concat(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_moveto(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_moveto",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_moveto. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_moveto(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_lineto(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_lineto",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_lineto. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_lineto(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_curveto(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffff:PDF_curveto",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_curveto. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_curveto(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_circle(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sfff:PDF_circle",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_circle. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_circle(p,_arg1,_arg2,_arg3); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_arc(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sfffff:PDF_arc",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_arc. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_arc(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_rect(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffff:PDF_rect",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_rect. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_rect(p,_arg1,_arg2,_arg3,_arg4); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_closepath(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_closepath",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_closepath. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_closepath(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_stroke(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_stroke",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_stroke. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_stroke(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_closepath_stroke(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_closepath_stroke",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_closepath_stroke. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_closepath_stroke(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_fill(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_fill",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_fill. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_fill(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_fill_stroke(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_fill_stroke",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_fill_stroke. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_fill_stroke(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_closepath_fill_stroke(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_closepath_fill_stroke",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_closepath_fill_stroke. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_closepath_fill_stroke(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_endpath(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_endpath",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_endpath. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_endpath(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_clip(PyObject *self, PyObject *args) { + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_clip",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_clip. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_clip(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setgray_fill(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sf:PDF_setgray_fill",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setgray_fill. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setcolor(p, "fill", "gray", _arg1, 0, 0, 0); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setgray_stroke(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sf:PDF_setgray_stroke",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setgray_stroke. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setcolor(p, "stroke", "gray", _arg1, 0, 0, 0); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setgray(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sf:PDF_setgray",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setgray. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setcolor(p, "fillstroke", "gray", _arg1, 0, 0, 0); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setrgbcolor_fill(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sfff:PDF_setrgbcolor_fill",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setrgbcolor_fill. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setcolor(p, "fill", "rgb", _arg1, _arg2, _arg3, 0); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setrgbcolor_stroke(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sfff:PDF_setrgbcolor_stroke",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setrgbcolor_stroke. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setcolor(p, "stroke", "rgb", _arg1, _arg2, _arg3, 0); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_setrgbcolor(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sfff:PDF_setrgbcolor",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setrgbcolor. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setcolor(p, "fillstroke", "rgb", _arg1, _arg2, _arg3, 0); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_place_image(PyObject *self, PyObject *args) { + PDF * p; + int _arg1; + float _arg2; + float _arg3; + float _arg4; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sifff:PDF_place_image",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_place_image. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_place_image(p,_arg1,_arg2,_arg3,_arg4); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_open_image(PyObject *self, PyObject *args) { + int _result; + PDF * p; + char * _arg1; + char * _arg2; + char * _arg3; + long _arg4; + int _arg5; + int _arg6; + int _arg7; + int _arg8; + char * _arg9; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssssliiiis:PDF_open_image",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6,&_arg7,&_arg8,&_arg9)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_open_image. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_open_image(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7,_arg8,_arg9); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_close_image(PyObject *self, PyObject *args) { + PDF * p; + int _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"si:PDF_close_image",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_close_image. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_close_image(p,_arg1); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_open_image_file(PyObject *self, PyObject *args) { + int _result; + PDF * p; + char * _arg1; + char * _arg2; + char * _arg3; + int _arg4; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssssi:PDF_open_image_file",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_open_image_file. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_open_image_file(p,_arg1,_arg2,_arg3,_arg4); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_open_CCITT(PyObject *self, PyObject *args) { + int _result; + PDF * p; + char * _arg1; + int _arg2; + int _arg3; + int _arg4; + int _arg5; + int _arg6; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssiiiii:PDF_open_CCITT",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_open_CCITT. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_open_CCITT(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_add_bookmark(PyObject *self, PyObject *args) { + int _result; + PDF * p; + char * _arg1; + int len; + int _arg2; + int _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssii:PDF_add_bookmark",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_add_bookmark. Expected _PDF_p."); + return NULL; + } + } + + try { + len = PyString_Size(PyTuple_GetItem(args, 1)); + _result = (int)PDF_add_bookmark2(p,_arg1,len,_arg2,_arg3); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_set_info(PyObject *self, PyObject *args) { + PDF * p; + char * _arg1; + char * _arg2; + int len; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sss:PDF_set_info",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_set_info. Expected _PDF_p."); + return NULL; + } + } + + try { + len = PyString_Size(PyTuple_GetItem(args, 2)); + PDF_set_info2(p,_arg1,_arg2,len); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_attach_file(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * _arg5; + char * _arg6; + int len_descr; + char * _arg7; + int len_auth; + char * _arg8; + char * _arg9; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffsssss:PDF_attach_file",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6,&_arg7,&_arg8,&_arg9)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_attach_file. Expected _PDF_p."); + return NULL; + } + } + + try { + len_descr = PyString_Size(PyTuple_GetItem(args, 6)); + len_auth = PyString_Size(PyTuple_GetItem(args, 7)); + PDF_attach_file2(p,_arg1,_arg2,_arg3,_arg4,_arg5,0, + _arg6,len_descr,_arg7,len_auth,_arg8,_arg9); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_add_note(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * _arg5; + char * _arg6; + char * _arg7; + int _arg8; + int len_cont; + int len_title; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffsssi:PDF_add_note",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6,&_arg7,&_arg8)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_add_note. Expected _PDF_p."); + return NULL; + } + } + + try { + len_cont = PyString_Size(PyTuple_GetItem(args, 5)); + len_title = PyString_Size(PyTuple_GetItem(args, 6)); + PDF_add_note2(p,_arg1,_arg2,_arg3,_arg4,_arg5,len_cont,_arg6,len_title,_arg7,_arg8); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_add_pdflink(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * _arg5; + int _arg6; + char * _arg7; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffsis:PDF_add_pdflink",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6,&_arg7)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_add_pdflink. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_add_pdflink(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_add_launchlink(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * _arg5; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffs:PDF_add_launchlink",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_add_launchlink. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_add_launchlink(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_add_locallink(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + int _arg5; + char * _arg6; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffis:PDF_add_locallink",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_add_locallink. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_add_locallink(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_add_weblink(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char * _arg5; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffs:PDF_add_weblink",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_add_weblink. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_add_weblink(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_set_border_style(PyObject *self, PyObject *args) { + PDF * p; + char * _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssf:PDF_set_border_style",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_set_border_style. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_set_border_style(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_set_border_color(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + float _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sfff:PDF_set_border_color",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_set_border_color. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_set_border_color(p,_arg1,_arg2,_arg3); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_set_border_dash(PyObject *self, PyObject *args) { + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_set_border_dash",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_set_border_dash. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_set_border_dash(p,_arg1,_arg2); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_open_pdi(PyObject *self, PyObject *args) { + PyObject * _resultobj; + int _result; + PDF * p; + char * _arg1; + char * _arg2; + int _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sssi:PDF_open_pdi",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_open_pdi. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_open_pdi(p,_arg1,_arg2,_arg3); + } catch; + _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyObject *_wrap_PDF_close_pdi(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + int _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"si:PDF_close_pdi",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_close_pdi. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_close_pdi(p,_arg1); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_open_pdi_page(PyObject *self, PyObject *args) { + PyObject * _resultobj; + int _result; + PDF * p; + int _arg1; + int _arg2; + char * _arg3; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"siis:PDF_open_pdi_page",&_argc0,&_arg1,&_arg2,&_arg3)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_open_pdi_page. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_open_pdi_page(p,_arg1,_arg2,_arg3); + } catch; + _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyObject *_wrap_PDF_close_pdi_page(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + int _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"si:PDF_close_pdi_page",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_close_pdi_page. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_close_pdi_page(p,_arg1); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_place_pdi_page(PyObject *self, PyObject *args) { + PDF * p; + int _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"siffff:PDF_place_pdi_page",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_place_image. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_place_pdi_page(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_get_pdi_parameter(PyObject *self, PyObject *args) { + char * _result; + PDF * p; + char * _arg1; + int _arg2; + int _arg3; + int _arg4; + int size; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssiii:PDF_get_pdi_parameter",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_get_pdi_parameter. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (char *)PDF_get_pdi_parameter(p,_arg1,_arg2,_arg3,_arg4, &size); + } catch; + return Py_BuildValue("s#", _result, (int) size); +} + +static PyObject *_wrap_PDF_get_pdi_value(PyObject *self, PyObject *args) { + PyObject * _resultobj; + float _result; + PDF * p; + char * _arg1; + int _arg2; + int _arg3; + int _arg4; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssiii:PDF_get_pdi_value",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_get_pdi_value. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (float)PDF_get_pdi_value(p,_arg1,_arg2,_arg3,_arg4); + } catch; + _resultobj = Py_BuildValue("f",_result); + return _resultobj; +} + +static PyObject *_wrap_PDF_makespotcolor(PyObject *self, PyObject *args) { + PyObject * _resultobj; + int _result; + PDF * p; + char * _arg1; + int _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"ssi:PDF_makespotcolor",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_makespotcolor. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_makespotcolor(p,_arg1,_arg2); + } catch; + _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyObject *_wrap_PDF_setcolor(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + char * _arg1; + char * _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sssffff:PDF_setcolor",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setcolor. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setcolor(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_begin_pattern(PyObject *self, PyObject *args) { + PyObject * _resultobj; + int _result; + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + int _arg5; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffi:PDF_begin_pattern",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_begin_pattern. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_begin_pattern(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyObject *_wrap_PDF_end_pattern(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_end_pattern",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_end_pattern. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_end_pattern(p); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_begin_template(PyObject *self, PyObject *args) { + PyObject * _resultobj; + int _result; + PDF * p; + float _arg1; + float _arg2; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sff:PDF_begin_template",&_argc0,&_arg1,&_arg2)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_begin_template. Expected _PDF_p."); + return NULL; + } + } + + try { _result = (int)PDF_begin_template(p,_arg1,_arg2); + } catch; + _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + +static PyObject *_wrap_PDF_end_template(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_end_template",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_end_template. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_end_template(p); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_arcn(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sfffff:PDF_arcn",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_arcn. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_arcn(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_add_thumbnail(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + int _arg1; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"si:PDF_add_thumbnail",&_argc0,&_arg1)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_add_thumbnail. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_add_thumbnail(p,_arg1); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_setmatrix(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"sffffff:PDF_setmatrix",&_argc0,&_arg1,&_arg2,&_arg3,&_arg4,&_arg5,&_arg6)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setmatrix. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_setmatrix(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_initgraphics(PyObject *self, PyObject *args) { + PyObject * _resultobj; + PDF * p; + char * _argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_initgraphics",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_initgraphics. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_initgraphics(p); + } catch; + Py_INCREF(Py_None); + _resultobj = Py_None; + return _resultobj; +} + +static PyObject *_wrap_PDF_begin_font(PyObject *self, PyObject *args) { + PDF *p; + char *_argc0 = 0; + char *name; + float a, b, c, d, e, f; + char *optlist; + + if(!PyArg_ParseTuple(args,"ssffffffs:PDF_begin_font",&_argc0,&name,&a,&b,&c,&d,&e,&f,&optlist)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_begin_font. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_begin_font(p, name, 0, a, b, c, d, e, f, optlist); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_end_font(PyObject *self, PyObject *args) { + PDF *p; + char *_argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_end_font",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_end_font. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_end_font(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_begin_glyph(PyObject *self, PyObject *args) { + PDF *p; + char *_argc0 = 0; + char *name; + float wx; + float llx; + float lly; + float urx; + float ury; + + if(!PyArg_ParseTuple(args,"ssfffff:PDF_begin_glyph",&_argc0,&name,&wx,&llx,&lly,&urx,&ury)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_begin_glyph. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_begin_glyph(p, name, wx, llx, lly, urx, ury); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_end_glyph(PyObject *self, PyObject *args) { + PDF *p; + char *_argc0 = 0; + + if(!PyArg_ParseTuple(args,"s:PDF_end_glyph",&_argc0)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_end_glyph. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_end_glyph(p); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_encoding_set_char(PyObject *self, PyObject *args) { + PDF *p; + char *_argc0 = 0; + char *encoding; + int slot; + char *glyphname; + int uv; + + if(!PyArg_ParseTuple(args,"ssisi:PDF_encoding_set_char",&_argc0,&encoding,&slot,&glyphname,&uv)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_encoding_set_char. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_encoding_set_char(p, encoding, slot, glyphname, uv); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_set_gstate(PyObject *self, PyObject *args) { + PDF *p; + char *_argc0 = 0; + int handle; + + if(!PyArg_ParseTuple(args,"si:PDF_set_gstate",&_argc0,&handle)) + return NULL; + if (_argc0) { + if (SWIG_GetPtr(_argc0,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_set_gstate. Expected _PDF_p."); + return NULL; + } + } + + try { PDF_set_gstate(p, handle); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_fill_imageblock(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + int page; + char *blockname; + int image; + char *optlist; + + if(!PyArg_ParseTuple(args,"sisis:PDF_fill_imageblock",&py_p,&page,&blockname,&image,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_fill_imageblock. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_fill_imageblock(p, page, blockname, image, optlist); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_fill_pdfblock(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + int page; + char *blockname; + int contents; + char *optlist; + + if(!PyArg_ParseTuple(args,"sisis:PDF_fill_pdfblock",&py_p,&page,&blockname,&contents,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_fill_pdfblock. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_fill_pdfblock(p, page, blockname, contents, optlist); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_fill_textblock(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + int page; + char *blockname; + char *text; + int len; + char *optlist; + + if(!PyArg_ParseTuple(args,"sisss:PDF_fill_textblock",&py_p,&page,&blockname,&text,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_fill_textblock. Expected _PDF_p."); + return NULL; + } + } + + try { + len = PyString_Size(PyTuple_GetItem(args, 3)); + _result = PDF_fill_textblock(p, page, blockname, text, len, optlist); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_load_font(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + char *fontname; + char *encoding; + char *optlist; + + if(!PyArg_ParseTuple(args,"ssss:PDF_load_font",&py_p,&fontname,&encoding,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_load_font. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_load_font(p, fontname, 0, encoding, optlist); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_setdashpattern(PyObject *self, PyObject *args) { + PDF *p; + char *py_p = 0; + char *optlist; + + if(!PyArg_ParseTuple(args,"ss:PDF_setdashpattern",&py_p,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_setdashpattern. Expected _PDF_p."); + return NULL; + } + } + + try { + PDF_setdashpattern(p, optlist); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_add_nameddest(PyObject *self, PyObject *args) { + PDF *p; + char *py_p = 0; + char *name; + char *optlist; + + if(!PyArg_ParseTuple(args,"sss:PDF_add_nameddest",&py_p,&name,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_add_nameddest. Expected _PDF_p."); + return NULL; + } + } + + try { + PDF_add_nameddest(p, name, 0, optlist); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_load_iccprofile(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + char *profilename; + char *optlist; + + if(!PyArg_ParseTuple(args,"sss:PDF_load_iccprofile",&py_p,&profilename,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_load_iccprofile. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_load_iccprofile(p, profilename, 0, optlist); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_fit_image(PyObject *self, PyObject *args) { + PDF *p; + char *py_p = 0; + int image; + float x; + float y; + char *optlist; + + if(!PyArg_ParseTuple(args,"siffs:PDF_fit_image",&py_p,&image,&x,&y,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_fit_image. Expected _PDF_p."); + return NULL; + } + } + + try { + PDF_fit_image(p, image, x, y, optlist); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_load_image(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + char *imagetype; + char *filename; + char *optlist; + + if(!PyArg_ParseTuple(args,"ssss:PDF_load_image",&py_p,&imagetype,&filename,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_load_image. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_load_image(p, imagetype, filename, 0, optlist); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_fit_pdi_page(PyObject *self, PyObject *args) { + PDF *p; + char *py_p = 0; + int page; + float x; + float y; + char *optlist; + + if(!PyArg_ParseTuple(args,"siffs:PDF_fit_pdi_page",&py_p,&page,&x,&y,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_fit_pdi_page. Expected _PDF_p."); + return NULL; + } + } + + try { + PDF_fit_pdi_page(p, page, x, y, optlist); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_process_pdi(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + int doc; + int page; + char *optlist; + + if(!PyArg_ParseTuple(args,"siis:PDF_process_pdi",&py_p,&doc,&page,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_process_pdi. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_process_pdi(p, doc, page, optlist); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_create_pvf(PyObject *self, PyObject *args) { + PDF *p; + char *py_p = 0; + char *filename; + void *data; + char *optlist; + int size; + + if(!PyArg_ParseTuple(args,"sss#s:PDF_create_pvf", &py_p,&filename,&data,&size, &optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_create_pvf. Expected _PDF_p."); + return NULL; + } + } + + try { + PDF_create_pvf(p, filename, 0, data, size, optlist); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_delete_pvf(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + char *filename; + + if(!PyArg_ParseTuple(args,"ss:PDF_delete_pvf",&py_p,&filename)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_delete_pvf. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_delete_pvf(p, filename, 0); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_shading(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + char *shtype; + float x0; + float yy0; + float x1; + float yy1; + float c1; + float c2; + float c3; + float c4; + char *optlist; + + if(!PyArg_ParseTuple(args,"ssffffffffs:PDF_shading",&py_p,&shtype,&x0,&yy0,&x1,&yy1,&c1,&c2,&c3,&c4,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_shading. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_shading(p, shtype, x0, yy0, x1, yy1, c1, c2, c3, c4, optlist); + } catch; + return Py_BuildValue("i",_result); +} +static PyObject *_wrap_PDF_shading_pattern(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + int shading; + char *optlist; + + if(!PyArg_ParseTuple(args,"sis:PDF_shading_pattern",&py_p,&shading,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_shading_pattern. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_shading_pattern(p, shading, optlist); + } catch; + return Py_BuildValue("i",_result); +} + +static PyObject *_wrap_PDF_shfill(PyObject *self, PyObject *args) { + PDF *p; + char *py_p = 0; + int shading; + + if(!PyArg_ParseTuple(args,"si:PDF_shfill",&py_p,&shading)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_shfill. Expected _PDF_p."); + return NULL; + } + } + + try { + PDF_shfill(p, shading); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_fit_textline(PyObject *self, PyObject *args) { + PDF *p; + char *py_p = 0; + char *text; + int len; + float x; + float y; + char *optlist; + + if(!PyArg_ParseTuple(args,"ssffs:PDF_fit_textline",&py_p,&text,&x,&y,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_fit_textline. Expected _PDF_p."); + return NULL; + } + } + + try { + len = PyString_Size(PyTuple_GetItem(args, 1)); + PDF_fit_textline(p, text, len, x, y, optlist); + } catch; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_PDF_create_gstate(PyObject *self, PyObject *args) { + int _result; + PDF *p; + char *py_p = 0; + char *optlist; + + if(!PyArg_ParseTuple(args,"ss:PDF_create_gstate",&py_p,&optlist)) + return NULL; + if (py_p) { + if (SWIG_GetPtr(py_p,(void **) &p,"_PDF_p")) { + PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of PDF_create_gstate. Expected _PDF_p."); + return NULL; + } + } + + try { + _result = PDF_create_gstate(p, optlist); + } catch; + return Py_BuildValue("i",_result); +} + + +static PyMethodDef pdflibMethods[] = { + { "PDF_set_border_dash", _wrap_PDF_set_border_dash, 1 }, + { "PDF_set_border_color", _wrap_PDF_set_border_color, 1 }, + { "PDF_set_border_style", _wrap_PDF_set_border_style, 1 }, + { "PDF_add_weblink", _wrap_PDF_add_weblink, 1 }, + { "PDF_add_locallink", _wrap_PDF_add_locallink, 1 }, + { "PDF_add_launchlink", _wrap_PDF_add_launchlink, 1 }, + { "PDF_add_pdflink", _wrap_PDF_add_pdflink, 1 }, + { "PDF_add_note", _wrap_PDF_add_note, 1 }, + { "PDF_attach_file", _wrap_PDF_attach_file, 1 }, + { "PDF_set_info", _wrap_PDF_set_info, 1 }, + { "PDF_add_bookmark", _wrap_PDF_add_bookmark, 1 }, + { "PDF_open_CCITT", _wrap_PDF_open_CCITT, 1 }, + { "PDF_close_image", _wrap_PDF_close_image, 1 }, + { "PDF_open_image", _wrap_PDF_open_image, 1 }, + { "PDF_open_image_file", _wrap_PDF_open_image_file, 1 }, + { "PDF_place_image", _wrap_PDF_place_image, 1 }, + { "PDF_setrgbcolor", _wrap_PDF_setrgbcolor, 1 }, + { "PDF_setrgbcolor_stroke", _wrap_PDF_setrgbcolor_stroke, 1 }, + { "PDF_setrgbcolor_fill", _wrap_PDF_setrgbcolor_fill, 1 }, + { "PDF_setgray", _wrap_PDF_setgray, 1 }, + { "PDF_setgray_stroke", _wrap_PDF_setgray_stroke, 1 }, + { "PDF_setgray_fill", _wrap_PDF_setgray_fill, 1 }, + { "PDF_clip", _wrap_PDF_clip, 1 }, + { "PDF_endpath", _wrap_PDF_endpath, 1 }, + { "PDF_closepath_fill_stroke", _wrap_PDF_closepath_fill_stroke, 1 }, + { "PDF_fill_stroke", _wrap_PDF_fill_stroke, 1 }, + { "PDF_fill", _wrap_PDF_fill, 1 }, + { "PDF_closepath_stroke", _wrap_PDF_closepath_stroke, 1 }, + { "PDF_stroke", _wrap_PDF_stroke, 1 }, + { "PDF_closepath", _wrap_PDF_closepath, 1 }, + { "PDF_rect", _wrap_PDF_rect, 1 }, + { "PDF_arc", _wrap_PDF_arc, 1 }, + { "PDF_circle", _wrap_PDF_circle, 1 }, + { "PDF_curveto", _wrap_PDF_curveto, 1 }, + { "PDF_lineto", _wrap_PDF_lineto, 1 }, + { "PDF_moveto", _wrap_PDF_moveto, 1 }, + { "PDF_skew", _wrap_PDF_skew, 1 }, + { "PDF_concat", _wrap_PDF_concat, 1 }, + { "PDF_rotate", _wrap_PDF_rotate, 1 }, + { "PDF_scale", _wrap_PDF_scale, 1 }, + { "PDF_translate", _wrap_PDF_translate, 1 }, + { "PDF_restore", _wrap_PDF_restore, 1 }, + { "PDF_save", _wrap_PDF_save, 1 }, + { "PDF_setlinewidth", _wrap_PDF_setlinewidth, 1 }, + { "PDF_setmiterlimit", _wrap_PDF_setmiterlimit, 1 }, + { "PDF_setlinecap", _wrap_PDF_setlinecap, 1 }, + { "PDF_setlinejoin", _wrap_PDF_setlinejoin, 1 }, + { "PDF_setflat", _wrap_PDF_setflat, 1 }, + { "PDF_setpolydash", _wrap_PDF_setpolydash, 1 }, + { "PDF_setdash", _wrap_PDF_setdash, 1 }, + { "PDF_stringwidth", _wrap_PDF_stringwidth, 1 }, + { "PDF_set_text_pos", _wrap_PDF_set_text_pos, 1 }, + { "PDF_continue_text", _wrap_PDF_continue_text, 1 }, + { "PDF_show_boxed", _wrap_PDF_show_boxed, 1 }, + { "PDF_show_xy", _wrap_PDF_show_xy, 1 }, + { "PDF_show", _wrap_PDF_show, 1 }, + { "PDF_setfont", _wrap_PDF_setfont, 1 }, + { "PDF_findfont", _wrap_PDF_findfont, 1 }, + { "PDF_set_parameter", _wrap_PDF_set_parameter, 1 }, + { "PDF_get_parameter", _wrap_PDF_get_parameter, 1 }, + { "PDF_get_value", _wrap_PDF_get_value, 1 }, + { "PDF_set_value", _wrap_PDF_set_value, 1 }, + { "PDF_end_page", _wrap_PDF_end_page, 1 }, + { "PDF_begin_page", _wrap_PDF_begin_page, 1 }, + { "PDF_get_buffer", _wrap_PDF_get_buffer, 1 }, + { "PDF_close", _wrap_PDF_close, 1 }, + { "PDF_open_file", _wrap_PDF_open_file, 1 }, + { "PDF_delete", _wrap_PDF_delete, 1 }, + { "PDF_new", _wrap_PDF_new, 1 }, + { "PDF_initgraphics", _wrap_PDF_initgraphics, 1 }, + { "PDF_setmatrix", _wrap_PDF_setmatrix, 1 }, + { "PDF_add_thumbnail", _wrap_PDF_add_thumbnail, 1 }, + { "PDF_arcn", _wrap_PDF_arcn, 1 }, + { "PDF_end_template", _wrap_PDF_end_template, 1 }, + { "PDF_begin_template", _wrap_PDF_begin_template, 1 }, + { "PDF_end_pattern", _wrap_PDF_end_pattern, 1 }, + { "PDF_begin_pattern", _wrap_PDF_begin_pattern, 1 }, + { "PDF_setcolor", _wrap_PDF_setcolor, 1 }, + { "PDF_makespotcolor", _wrap_PDF_makespotcolor, 1 }, + { "PDF_get_pdi_value", _wrap_PDF_get_pdi_value, 1 }, + { "PDF_get_pdi_parameter", _wrap_PDF_get_pdi_parameter, 1 }, + { "PDF_close_pdi_page", _wrap_PDF_close_pdi_page, 1 }, + { "PDF_place_pdi_page", _wrap_PDF_place_pdi_page, 1 }, + { "PDF_open_pdi_page", _wrap_PDF_open_pdi_page, 1 }, + { "PDF_close_pdi", _wrap_PDF_close_pdi, 1 }, + { "PDF_open_pdi", _wrap_PDF_open_pdi, 1 }, + { "PDF_begin_font", _wrap_PDF_begin_font, 1 }, + { "PDF_end_font", _wrap_PDF_end_font, 1 }, + { "PDF_begin_glyph", _wrap_PDF_begin_glyph, 1 }, + { "PDF_end_glyph", _wrap_PDF_end_glyph, 1 }, + { "PDF_encoding_set_char", _wrap_PDF_encoding_set_char, 1 }, + { "PDF_set_gstate", _wrap_PDF_set_gstate, 1 }, + + { "PDF_fill_imageblock", _wrap_PDF_fill_imageblock, 1 }, + { "PDF_fill_pdfblock", _wrap_PDF_fill_pdfblock, 1 }, + { "PDF_fill_textblock", _wrap_PDF_fill_textblock, 1 }, + { "PDF_load_font", _wrap_PDF_load_font, 1 }, + { "PDF_setdashpattern", _wrap_PDF_setdashpattern, 1 }, + { "PDF_add_nameddest", _wrap_PDF_add_nameddest, 1 }, + { "PDF_load_iccprofile", _wrap_PDF_load_iccprofile, 1 }, + { "PDF_fit_image", _wrap_PDF_fit_image, 1 }, + { "PDF_load_image", _wrap_PDF_load_image, 1 }, + { "PDF_fit_pdi_page", _wrap_PDF_fit_pdi_page, 1 }, + { "PDF_process_pdi", _wrap_PDF_process_pdi, 1 }, + { "PDF_create_pvf", _wrap_PDF_create_pvf, 1 }, + { "PDF_delete_pvf", _wrap_PDF_delete_pvf, 1 }, + { "PDF_shading", _wrap_PDF_shading, 1 }, + { "PDF_shading_pattern", _wrap_PDF_shading_pattern, 1 }, + { "PDF_shfill", _wrap_PDF_shfill, 1 }, + { "PDF_fit_textline", _wrap_PDF_fit_textline, 1 }, + { "PDF_create_gstate", _wrap_PDF_create_gstate, 1 }, + + { "PDF_get_errmsg", _wrap_PDF_get_errmsg, 1 }, + { "PDF_get_apiname", _wrap_PDF_get_apiname, 1 }, + { "PDF_get_errnum", _wrap_PDF_get_errnum, 1 }, + + { NULL, NULL } +}; +static PyObject *SWIG_globals; +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT(void,initpdflib_py)() { + PyObject *m, *d; + SWIG_globals = SWIG_newvarlink(); + m = Py_InitModule("pdflib_py", pdflibMethods); + d = PyModule_GetDict(m); + + /* Boot the PDFlib core */ + PDF_boot(); +/* + * These are the pointer type-equivalency mappings. + * (Used by the SWIG pointer type-checker). + */ + SWIG_RegisterMapping("_signed_long","_long",0); + SWIG_RegisterMapping("_struct_PDF_s","_PDF",0); + SWIG_RegisterMapping("_long","_unsigned_long",0); + SWIG_RegisterMapping("_long","_signed_long",0); + SWIG_RegisterMapping("_PDF","_struct_PDF_s",0); + SWIG_RegisterMapping("_unsigned_long","_long",0); + SWIG_RegisterMapping("_signed_int","_int",0); + SWIG_RegisterMapping("_unsigned_short","_short",0); + SWIG_RegisterMapping("_signed_short","_short",0); + SWIG_RegisterMapping("_unsigned_int","_int",0); + SWIG_RegisterMapping("_short","_unsigned_short",0); + SWIG_RegisterMapping("_short","_signed_short",0); + SWIG_RegisterMapping("_int","_unsigned_int",0); + SWIG_RegisterMapping("_int","_signed_int",0); +} diff --git a/src/libs/pdflib/bind/pdflib/python/quickreference.py b/src/libs/pdflib/bind/pdflib/python/quickreference.py new file mode 100644 index 0000000000..8cffbe1420 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/quickreference.py @@ -0,0 +1,81 @@ +#!/usr/bin/python +# $Id: quickreference.py,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib/PDI client: mini imposition demo +# + +from sys import * +from pdflib_py import * + +maxrow = 2 +maxcol = 2 +startpage = 1 +endpage = 4 +width = 500.0 +height = 770.0 + +infile = "reference.pdf" +searchpath = "../data" + +p = PDF_new() + +if PDF_open_file(p, "quickreference.pdf") == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +PDF_set_parameter(p, "SearchPath", searchpath) + +# This line is required to avoid problems on Japanese systems +PDF_set_parameter(p, "hypertextencoding", "winansi") + +PDF_set_info(p, "Creator", "quickreference.py") +PDF_set_info(p, "Author", "Thomas Merz") +PDF_set_info(p, "Title", "mini imposition demo (Python)") + +manual = PDF_open_pdi(p, infile, "", 0) + +if manual == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + +row = 0 +col = 0 + +PDF_set_parameter(p, "topdown", "true") + +for pageno in range(startpage, endpage+1): + if row == 0 and col == 0: + PDF_begin_page(p, width, height) + font = PDF_load_font(p, "Helvetica-Bold", "winansi", "") + PDF_setfont(p, font, 18) + PDF_set_text_pos(p, 24, 24) + PDF_show(p, "PDFlib 4.0 Quick Reference") + + page = PDF_open_pdi_page(p, manual, pageno, "") + + if page == -1: + print "Error: " + PDF_get_errmsg(p) + "\n" + exit(2) + + optlist = "scale " + repr(1.0/maxrow) + + PDF_fit_pdi_page(p, page, + width/maxcol*col, (row + 1) * height/maxrow, optlist) + PDF_close_pdi_page(p, page) + + col = col+1 + if col == maxcol: + col = 0 + row = row+1 + + if row == maxrow: + row = 0 + PDF_end_page(p) + +# finish the last partial page +if row != 0 or col != 0: + PDF_end_page(p) + +PDF_close(p) +PDF_close_pdi(p, manual) +PDF_delete(p) diff --git a/src/libs/pdflib/bind/pdflib/python/readme.txt b/src/libs/pdflib/bind/pdflib/python/readme.txt new file mode 100644 index 0000000000..bab4726af9 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/python/readme.txt @@ -0,0 +1,6 @@ +Python binding on Mac OS X +========================== + +The build process creates pdflib_py.dylib (as usual on Mac OS X), but Python +wants to have pdflib_py.so. Therefore you must rename pdflib_py.dylib to +pdflib_py.so before you can use the binaries. diff --git a/src/libs/pdflib/bind/pdflib/tcl/Makefile b/src/libs/pdflib/bind/pdflib/tcl/Makefile new file mode 100644 index 0000000000..cb1f46e70c --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/Makefile @@ -0,0 +1,61 @@ +# Makefile for PDFlib's Tcl binding +# $Id: Makefile,v 1.1 2004/10/06 17:46:44 laplace Exp $ + +top_builddir = ../../.. + +include $(top_builddir)/config/mkcommon.inc + +INCLUDES = $(PDFLIBINC) $(TCLINCLUDE) + +LANG_LIBDIR = $(TCLPACKAGEDIR) + +LIBNAME = pdflib_tcl$(LA) +OBJ = pdflib_tcl$(LO) +SRC = pdflib_tcl.c + + +include $(top_builddir)/config/mkbind.inc + +test:: all + @cp pkgIndex.tcl .libs + -$(LIBTOOL_EXE) $(TCLBIN) hello.tcl + -$(LIBTOOL_EXE) $(TCLBIN) image.tcl + -$(LIBTOOL_EXE) $(TCLBIN) pdfclock.tcl + -$(LIBTOOL_EXE) $(TCLBIN) chartab.tcl + -$(LIBTOOL_EXE) $(TCLBIN) invoice.tcl + -$(LIBTOOL_EXE) $(TCLBIN) businesscard.tcl + -$(LIBTOOL_EXE) $(TCLBIN) quickreference.tcl + +smoke:: test + +install:: $(LIBNAME) + if test ! -d $(LANG_LIBDIR) ; then \ + mkdir -p $(LANG_LIBDIR); \ + chmod 755 $(LANG_LIBDIR); \ + fi + $(INSTALL_DATA) pkgIndex.tcl $(LANG_LIBDIR) + @-if test -f .libs/libpdflib_tcl.dylib; then \ + $(INSTALL_DATA) .libs/pdflib_tcl.dylib $(LANG_LIBDIR); \ + else \ + $(LIBTOOL) --mode=install $(INSTALL_DATA) \ + $(LIBNAME) $(LANG_LIBDIR); \ + fi + +uninstall:: + @-if test -f .libs/libpdflib_tcl.dylib; then \ + $(LIBTOOL) --mode=uninstall $(RM) \ + $(LANG_LIBDIR)/pdflib_tcl.dylib \ + $(LANG_LIBDIR)/pkgIndex.tcl; \ + else \ + $(LIBTOOL) --mode=uninstall $(RM) \ + $(LANG_LIBDIR)/$(LIBNAME) \ + $(LANG_LIBDIR)/pkgIndex.tcl; \ + fi + $(RM) $(LANG_LIBDIR) + +clean:: + $(RM) hello.pdf image.pdf pdfclock.pdf chartab.pdf invoice.pdf + $(RM) businesscard.pdf quickreference.pdf + + +# Automatically generated dependencies diff --git a/src/libs/pdflib/bind/pdflib/tcl/Tcl.dsp b/src/libs/pdflib/bind/pdflib/tcl/Tcl.dsp new file mode 100644 index 0000000000..ee062e4b41 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/Tcl.dsp @@ -0,0 +1,109 @@ +# Microsoft Developer Studio Project File - Name="Tcl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Tcl - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Tcl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Tcl.mak" CFG="Tcl - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Tcl - Win32 Release mtDLL" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Tcl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Tcl - Win32 Release mtDLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release_mtDLL" +# PROP BASE Intermediate_Dir "Release_mtDLL" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "" +# PROP Intermediate_Dir "Release_mtDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "..\..\..\libs\pdflib" /I "c:\programme\tcl\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\..\..\libs\pdflib" /I "c:\programme\tcl\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub82.lib /nologo /base:"0x55350000" /dll /pdb:none /machine:I386 /out:"pdflib_tcl.dll" /libpath:"c:\programme\tcl\lib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub84.lib pdflib.lib /nologo /base:"0x55350000" /dll /pdb:none /machine:I386 /out:"pdflib_tcl.dll" /libpath:"..\..\..\libs\pdflib\Release_mtDLL" /libpath:"c:\programme\tcl\lib" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "Tcl - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Tcl___Win32_Release" +# PROP BASE Intermediate_Dir "Tcl___Win32_Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /O2 /I "..\..\..\libs\pdflib" /I "c:\programme\tcl\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "..\..\..\libs\pdflib" /I "c:\programme\tcl\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_MT" /D "PDFLIB_STATIC" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /x +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub84.lib pdflib.lib /nologo /base:"0x55350000" /dll /pdb:none /machine:I386 /out:"pdflib_tcl.dll" /libpath:"..\..\..\libs\pdflib\Release_mtDLL" /libpath:"c:\programme\tcl\lib" +# SUBTRACT BASE LINK32 /debug +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib tclstub84.lib pdflib.lib /nologo /base:"0x55350000" /dll /pdb:none /machine:I386 /out:"pdflib_tcl.dll" /libpath:"..\..\..\libs\pdflib\Release" /libpath:"c:\programme\tcl\lib" +# SUBTRACT LINK32 /debug + +!ENDIF + +# Begin Target + +# Name "Tcl - Win32 Release mtDLL" +# Name "Tcl - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=pdflib_tcl.c +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/bind/pdflib/tcl/businesscard.tcl b/src/libs/pdflib/bind/pdflib/tcl/businesscard.tcl new file mode 100644 index 0000000000..1b3d3cba8d --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/businesscard.tcl @@ -0,0 +1,90 @@ +#!/bin/sh +# $Id: businesscard.tcl,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib client: block processing example in tcl +# + +# Hide the exec to Tcl but not to the shell by appending a backslash\ +exec tclsh "$0" ${1+"$@"} + +# The lappend line is unnecessary if PDFlib has been installed +# in the Tcl package directory +set auto_path [linsert $auto_path 0 .libs .] + +package require pdflib 5.0 + +set infile "boilerplate.pdf" + +global blockName blockValue + +proc block_add {id name value} { + global blockName blockValue + set blockName($id) $name + set blockValue($id) $value +} + +block_add 0 "name" "Victor Kraxi" +block_add 1 "business.title" "Chief Paper Officer" +block_add 2 "business.address.line1" "17, Aviation Road" +block_add 3 "business.address.city" "Paperfield" +block_add 4 "business.telephone.voice" "phone +1 234 567-89" +block_add 5 "business.telephone.fax" "fax +1 234 567-98" +block_add 6 "business.email" "victor@kraxi.com" +block_add 7 "business.homepage" "www.kraxi.com" + +set BLOCKCOUNT 8 + +set p [PDF_new] + +# This is where font/image/PDF input files live. Adjust as necessary. +# +# Note that this directory must also contain the LuciduxSans font outline +# and metrics files. +# +PDF_set_parameter $p "SearchPath" "../data" + +if {[PDF_open_file $p "businesscard.pdf"] == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +PDF_set_info $p "Creator" "businesscard.tcl" +PDF_set_info $p "Author" "Thomas Merz" +PDF_set_info $p "Title" "PDFlib block processing sample (Tcl)" + +set blockcontainer [PDF_open_pdi $p $infile "" 0] +if {$blockcontainer == -1} { + puts stderr "Error: % [PDF_get_errmsg $p]" + exit +} + +set page [PDF_open_pdi_page $p $blockcontainer 1 ""] +if {$page == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +# dummy page size +PDF_begin_page $p 20 20 + +# This will adjust the page size to the block container's size. +PDF_fit_pdi_page $p $page 0 0 "adjustpage" + +# Fill all text blocks with dynamic data +for { set i 0} {$i < $BLOCKCOUNT} {set i [expr $i + 1]} { + if {[PDF_fill_textblock $p $page $blockName($i) $blockValue($i) \ + "embedding encoding=winansi"] == -1} { + puts stderr "Warning: [PDF_get_errmsg $p]" + } +} + +# close page +PDF_end_page $p +PDF_close_pdi_page $p $page + +# close PDF document +PDF_close $p +PDF_close_pdi $p $blockcontainer + +# delete the PDFlib object +PDF_delete $p diff --git a/src/libs/pdflib/bind/pdflib/tcl/chartab.tcl b/src/libs/pdflib/bind/pdflib/tcl/chartab.tcl new file mode 100644 index 0000000000..c3e906fe0a --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/chartab.tcl @@ -0,0 +1,102 @@ +#!/bin/sh +# $Id: chartab.tcl,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib client: character table example in Tcl +# + +# Hide the exec to Tcl but not to the shell by appending a backslash\ +exec tclsh "$0" ${1+"$@"} + +# The lappend line is unnecessary if PDFlib has been installed +# in the Tcl package directory +set auto_path [linsert $auto_path 0 .libs .] + +package require pdflib 5.0 + +# Adjust as you need. +set fontname "LuciduxSans-Oblique" +set searchpath "../data" +set encnames "iso8859-1 iso8859-2 iso8859-15" +set embedflag "embedding" +set embednote "embedded" +set fontsize 16 +set top 700 +set left 50 +set xincr [expr {2 * $fontsize}] +set yincr [expr {2 * $fontsize}] + +# create a new PDFlib object +set p [PDF_new] + +# open new PDF file +if {[PDF_open_file $p "chartab.pdf"] == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +if { [catch { + + PDF_set_info $p "Creator" "chartab.tcl" + PDF_set_info $p "Author" "Thomas Merz" + PDF_set_info $p "Title" "Character table (Tcl)" + + PDF_set_parameter $p "openaction" "fitpage" + PDF_set_parameter $p "fontwarning" "true" + PDF_set_parameter $p "SearchPath" $searchpath + + foreach encoding $encnames { + + # start a new page + PDF_begin_page $p 595 842 + + set font [PDF_load_font $p "Helvetica" "winansi" ""] + PDF_setfont $p $font $fontsize + + # title and bookmark + set text "$fontname ($encoding) $embednote" + PDF_show_xy $p $text [expr {$left - $xincr}] [expr {$top + 3 * $yincr}] + PDF_add_bookmark $p $text 0 0 + + # print the row and column captions + PDF_setfont $p $font [expr {2 * $fontsize / 3}] + + # character code labels + for {set row 0} {$row < 16} {incr row} { + + set text [format "x%X" $row] + PDF_show_xy $p $text \ + [expr {$left + $row * $xincr}] [expr {$top + $yincr}] + + set text [format "%Xx" $row] + PDF_show_xy $p $text \ + [expr {$left - $xincr}] [expr {$top - $row * $yincr}] + } + + # print the character table + set font [PDF_load_font $p $fontname $encoding $embedflag] + PDF_setfont $p $font $fontsize + + set x $left + set y $top + for {set row 0} {$row < 16} {incr row} { + for {set col 0} {$col < 16} {incr col} { + set text [format "%c" [expr {int(16*$row + $col)}]] + PDF_show_xy $p $text $x $y + incr x $xincr + } + set x $left + incr y -$yincr + } + + PDF_end_page $p + } + + # close PDF document + PDF_close $p + +} result] } { + puts stderr "$result" +} + +# delete the PDFlib object +PDF_delete $p diff --git a/src/libs/pdflib/bind/pdflib/tcl/hello.tcl b/src/libs/pdflib/bind/pdflib/tcl/hello.tcl new file mode 100644 index 0000000000..041a57af4b --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/hello.tcl @@ -0,0 +1,45 @@ +#!/bin/sh +# $Id: hello.tcl,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib client: hello example in Tcl +# + +# Hide the exec to Tcl but not to the shell by appending a backslash\ +exec tclsh "$0" ${1+"$@"} + +# The lappend line is unnecessary if PDFlib has been installed +# in the Tcl package directory +set auto_path [linsert $auto_path 0 .libs .] + +package require pdflib 5.0 + +# create a new PDFlib object +set p [PDF_new] + +# open new PDF file +if {[PDF_open_file $p "hello.pdf"] == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +PDF_set_info $p "Creator" "hello.tcl" +PDF_set_info $p "Author" "Thomas Merz" +PDF_set_info $p "Title" "Hello world (Tcl)" + +# start a new page +PDF_begin_page $p 595 842 + +set font [PDF_load_font $p "Helvetica-Bold" "winansi" ""] + +PDF_setfont $p $font 24.0 +PDF_set_text_pos $p 50 700 +PDF_show $p "Hello world!" +PDF_continue_text $p "(says Tcl)" +# close page +PDF_end_page $p + +# close PDF document +PDF_close $p + +# delete the PDFlib object +PDF_delete $p diff --git a/src/libs/pdflib/bind/pdflib/tcl/image.tcl b/src/libs/pdflib/bind/pdflib/tcl/image.tcl new file mode 100644 index 0000000000..07d501cc97 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/image.tcl @@ -0,0 +1,48 @@ +#!/bin/sh +# $Id: image.tcl,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib client: image example in Tcl +# + +# Hide the exec to Tcl but not to the shell by appending a backslash\ +exec tclsh "$0" ${1+"$@"} + +# The lappend line is unnecessary if PDFlib has been installed +# in the Tcl package directory +set auto_path [linsert $auto_path 0 .libs .] + +package require pdflib 5.0 + +set p [PDF_new] +set imagefile "nesrin.jpg" + +# This is where font/image/PDF input files live. Adjust as necessary. +set searchpath "../data" + +if {[PDF_open_file $p "image.pdf"] == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +PDF_set_parameter $p "SearchPath" $searchpath + +PDF_set_info $p "Creator" "image.tcl" +PDF_set_info $p "Author" "Thomas Merz" +PDF_set_info $p "Title" "image sample (Tcl)" + +set image [PDF_load_image $p "auto" $imagefile ""] + +if {$image == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +# We generate a page with arbitrary dimensions +PDF_begin_page $p 10 10 +PDF_fit_image $p $image 0 0 "adjustpage" +PDF_close_image $p $image +PDF_end_page $p + +PDF_close $p + +PDF_delete $p diff --git a/src/libs/pdflib/bind/pdflib/tcl/invoice.tcl b/src/libs/pdflib/bind/pdflib/tcl/invoice.tcl new file mode 100644 index 0000000000..f1f81c739e --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/invoice.tcl @@ -0,0 +1,167 @@ +#!/bin/sh +# $Id: invoice.tcl,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib client: invoice generation demo +# + +# Hide the exec to Tcl but not to the shell by appending a backslash\ +exec tclsh "$0" ${1+"$@"} + +# The lappend line is unnecessary if PDFlib has been installed +# in the Tcl package directory +set auto_path [linsert $auto_path 0 .libs .] + +package require pdflib 5.0 + +set infile "stationery.pdf" +set searchpath "../data" +set col1 55.0 +set col2 100.0 +set col3 330.0 +set col4 430.0 +set col5 530.0 +set fontsize 12.0 +set pagewidth 595.0 +set pageheight 842.0 + +set closingtext \ +"30 days warranty starting at the day of sale. \ +This warranty covers defects in workmanship only. \ +Kraxi Systems, Inc. will, at its option, repair or replace the \ +product under the warranty. This warranty is not transferable. \ +No returns or exchanges will be accepted for wet products." + +global articleName articlePrice articleQuantity + +proc article_add {id name price quantity} { + global articleName articlePrice articleQuantity + set articleName($id) $name + set articlePrice($id) $price + set articleQuantity($id) $quantity +} + +article_add 0 "Super Kite" 20 2 +article_add 1 "Turbo Flyer" 40 5 +article_add 2 "Giga Trash" 180 1 +article_add 3 "Bare Bone Kit" 50 3 +article_add 4 "Nitty Gritty" 20 10 +article_add 5 "Pretty Dark Flyer" 75 1 +article_add 6 "Free Gift" 0 1 + +set ARTICLECOUNT 7 + +# create a new PDFlib object +set p [PDF_new] + +# open new PDF file +if {[PDF_open_file $p "invoice.pdf"] == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +PDF_set_parameter $p "SearchPath" $searchpath + +PDF_set_info $p "Creator" "invoice.c" +PDF_set_info $p "Author" "Thomas Merz" +PDF_set_info $p "Title" "PDFlib invoice generation demo (TCL)" + +set form [PDF_open_pdi $p $infile "" 0] +if {$form == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +set page [PDF_open_pdi_page $p $form 1 ""] +if {$page == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +set boldfont [PDF_load_font $p "Helvetica-Bold" "winansi" ""] +set regularfont [PDF_load_font $p "Helvetica" "winansi" ""] +set leading [expr $fontsize + 2] + +# Establish coordinates with the origin in the upper left corner. +PDF_set_parameter $p "topdown" "true" + +# A4 page +PDF_begin_page $p $pagewidth $pageheight + +PDF_fit_pdi_page $p $page 0 $pageheight "" +PDF_close_pdi_page $p $page + +PDF_setfont $p $regularfont $fontsize + +# Print the address +set y 170 +PDF_set_value $p "leading" $leading + +PDF_show_xy $p "John Q. Doe" $col1 $y +PDF_continue_text $p "255 Customer Lane" +PDF_continue_text $p "Suite B" +PDF_continue_text $p "12345 User Town" +PDF_continue_text $p "Everland" + +# Print the header and date + +PDF_setfont $p $boldfont $fontsize +set y 300 +PDF_show_xy $p "INVOICE" $col1 $y + +set buf [clock format [clock seconds] -format "%B %d, %Y"] +PDF_fit_textline $p $buf $col5 $y "position {100 0}" + +# Print the invoice header line +PDF_setfont $p $boldfont $fontsize + +# "position {0 0}" is left-aligned, "position {100 0}" right-aligned +set y 370 +PDF_fit_textline $p "ITEM" $col1 $y "position {0 0}" +PDF_fit_textline $p "DESCRIPTION" $col2 $y "position {0 0}" +PDF_fit_textline $p "QUANTITY" $col3 $y "position {100 0}" +PDF_fit_textline $p "PRICE" $col4 $y "position {100 0}" +PDF_fit_textline $p "AMOUNT" $col5 $y "position {100 0}" + +# Print the article list + +PDF_setfont $p $regularfont $fontsize +set y [expr $y + 2*$leading] +set total 0 + +for {set i 0} {$i < $ARTICLECOUNT} {set i [expr $i + 1]} { + PDF_show_xy $p [expr $i + 1] $col1 $y + + PDF_show_xy $p $articleName($i) $col2 $y + + PDF_fit_textline $p $articleName($i) $col3 $y "position {100 0}" + + set buf [format "%.2f" $articlePrice($i)] + PDF_fit_textline $p $buf $col4 $y "position {100 0}" + + set sum [ expr $articlePrice($i) * $articleQuantity($i)] + set buf [format "%.2f" $sum] + PDF_fit_textline $p $buf $col5 $y "position {100 0}" + + set y [expr $y + $leading] + set total [expr $total + $sum] +} + +set y [expr $y + $leading] +PDF_setfont $p $boldfont $fontsize +set buf [format "%.2f" $total] +PDF_fit_textline $p $buf $col5 $y "position {100 0}" + +# Print the closing text + +set y [expr $y + 5*$leading] +PDF_setfont $p $regularfont $fontsize +PDF_set_value $p "leading" $leading +PDF_show_boxed $p $closingtext \ + $col1 [expr $y + 4*$leading] [expr $col5-$col1] [expr 4*$leading]\ + "justify" "" + +PDF_end_page $p +PDF_close $p +PDF_close_pdi $p $form + +PDF_delete $p diff --git a/src/libs/pdflib/bind/pdflib/tcl/pdfclock.tcl b/src/libs/pdflib/bind/pdflib/tcl/pdfclock.tcl new file mode 100644 index 0000000000..31eefa7341 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/pdfclock.tcl @@ -0,0 +1,109 @@ +#!/bin/sh +# $Id: pdfclock.tcl,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib client: pdfclock example in Tcl +# + +# Hide the exec to Tcl but not to the shell by appending a backslash\ +exec tclsh "$0" ${1+"$@"} + +# The lappend line is unnecessary if PDFlib has been installed +# in the Tcl package directory +set auto_path [linsert $auto_path 0 .libs .] + +package require pdflib 5.0 + +set RADIUS 200.0 +set MARGIN 20.0 + +set p [PDF_new] + +if {[PDF_open_file $p "pdfclock.pdf"] == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" +} + + +PDF_set_info $p "Creator" "pdfclock.tcl" +PDF_set_info $p "Author" "Thomas Merz" +PDF_set_info $p "Title" "PDF clock (Tcl)" + +PDF_begin_page $p [expr 2 * ($RADIUS + $MARGIN)] [expr 2 * ($RADIUS + $MARGIN)] + +PDF_translate $p [expr $RADIUS + $MARGIN] [expr $RADIUS + $MARGIN] +PDF_setcolor $p "fillstroke" "rgb" 0.0 0.0 1.0 0.0 +PDF_save $p + +# minute strokes +PDF_setlinewidth $p 2.0 +for {set alpha 0} {$alpha < 360} {set alpha [expr $alpha + 6]} { + PDF_rotate $p 6.0 + PDF_moveto $p $RADIUS 0.0 + PDF_lineto $p [expr $RADIUS-$MARGIN/3] 0.0 + PDF_stroke $p +} + +PDF_restore $p +PDF_save $p + +# 5 minute strokes +PDF_setlinewidth $p 3.0 +for {set alpha 0} {$alpha < 360} {set alpha [expr $alpha + 30]} { + PDF_rotate $p 30.0 + PDF_moveto $p $RADIUS 0.0 + PDF_lineto $p [expr $RADIUS-$MARGIN] 0.0 + PDF_stroke $p +} + +set tm_hour [ clock format [clock seconds] -format "%I" ] +set tm_min [ clock format [clock seconds] -format "%M" ] +set tm_sec [ clock format [clock seconds] -format "%S" ] + +# This is a Tcl-itis: when the clock returns "08" seconds, tm_sec +# won't be recognized as an integer. Therefore we "cast" it to integer. +# Note that this doesn't happen with, for example, the value "07" +# because this is a valid octal number... + +scan $tm_hour %d tm_hour +scan $tm_min %d tm_min +scan $tm_sec %d tm_sec + +# draw hour hand +PDF_save $p +PDF_rotate $p [expr -(($tm_min/60.0) + $tm_hour - 3.0) * 30.0] +PDF_moveto $p [expr -$RADIUS/10] [expr -$RADIUS/20] +PDF_lineto $p [expr $RADIUS/2] 0.0 +PDF_lineto $p [expr -$RADIUS/10] [expr $RADIUS/20] +PDF_closepath $p +PDF_fill $p +PDF_restore $p + +# draw minute hand +PDF_save $p +PDF_rotate $p [expr -(($tm_sec/60.0) + $tm_min - 15.0) * 6.0] +PDF_moveto $p [expr -$RADIUS/10] [expr -$RADIUS/20] +PDF_lineto $p [expr $RADIUS * 0.8] 0.0 +PDF_lineto $p [expr -$RADIUS/10] [expr $RADIUS/20] +PDF_closepath $p +PDF_fill $p +PDF_restore $p + +# draw second hand +PDF_setcolor $p "fillstroke" "rgb" 1.0 0.0 0.0 0.0 +PDF_setlinewidth $p 2 +PDF_save $p +PDF_rotate $p [expr -(($tm_sec - 15.0) * 6.0)] +PDF_moveto $p [expr -$RADIUS/5] 0.0 +PDF_lineto $p $RADIUS 0.0 +PDF_stroke $p +PDF_restore $p + +# draw little circle at center +PDF_circle $p 0 0 [expr $RADIUS/30] +PDF_fill $p + +PDF_restore $p + +PDF_end_page $p +PDF_close $p + +PDF_delete $p diff --git a/src/libs/pdflib/bind/pdflib/tcl/pdflib_tcl.c b/src/libs/pdflib/bind/pdflib/tcl/pdflib_tcl.c new file mode 100644 index 0000000000..e8f3411cd5 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/pdflib_tcl.c @@ -0,0 +1,4333 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdflib_tcl.c,v 1.1 2004/10/06 17:46:44 laplace Exp $ + * + * in sync with pdflib.h 1.151.2.22 + * + * Wrapper code for the PDFlib Tcl binding + * + */ + +/* + * Build with STUBS enabled + * + * if building with older TCL Versions than 8.2 you have to undef this + */ +#define USE_TCL_STUBS + +#include + +#include +#include + +#if defined(__WIN32__) +# define WIN32_LEAN_AND_MEAN +# include +# undef WIN32_LEAN_AND_MEAN + +# if defined(__WIN32__) && \ + (defined(_MSC_VER) || (defined(__GNUC__) && defined(__declspec))) +# define SWIGEXPORT(a,b) __declspec(dllexport) a b +# else +# if defined(__BORLANDC__) +# define SWIGEXPORT(a,b) a _export b +# else +# define SWIGEXPORT(a,b) a b +# endif +# endif +#else +# define SWIGEXPORT(a,b) a b +#endif + +#include + +#ifdef SWIG_GLOBAL +#ifdef __cplusplus +#define SWIGSTATIC extern "C" +#else +#define SWIGSTATIC +#endif +#endif + +#ifndef SWIGSTATIC +#define SWIGSTATIC static +#endif + +/* SWIG pointer structure */ + +typedef struct SwigPtrType { + char *name; /* Datatype name */ + int len; /* Length (used for optimization) */ + void *(*cast)(void *); /* Pointer casting function */ + struct SwigPtrType *next; /* Linked list pointer */ +} SwigPtrType; + +/* Pointer cache structure */ + +typedef struct { + int stat; /* Status (valid) bit */ + SwigPtrType *tp; /* Pointer to type structure */ + char name[256]; /* Given datatype name */ + char mapped[256]; /* Equivalent name */ +} SwigCacheType; + +/* Some variables */ + +static int SwigPtrMax = 64; /* Max entries that can be currently held */ + /* This value may be adjusted dynamically */ +static int SwigPtrN = 0; /* Current number of entries */ +static int SwigPtrSort = 0; /* Status flag indicating sort */ +static int SwigStart[256]; /* Starting positions of types */ + +/* Pointer table */ +static SwigPtrType *SwigPtrTable = 0; /* Table containing pointer equivalences */ + +/* Cached values */ + +#define SWIG_CACHESIZE 8 +#define SWIG_CACHEMASK 0x7 +static SwigCacheType SwigCache[SWIG_CACHESIZE]; +static int SwigCacheIndex = 0; +static int SwigLastCache = 0; + +/* Sort comparison function */ +static int swigsort(const void *data1, const void *data2) { + SwigPtrType *d1 = (SwigPtrType *) data1; + SwigPtrType *d2 = (SwigPtrType *) data2; + return strcmp(d1->name,d2->name); +} + +/* Binary Search function */ +static int swigcmp(const void *key, const void *data) { + char *k = (char *) key; + SwigPtrType *d = (SwigPtrType *) data; + return strncmp(k,d->name,d->len); +} + +/* Register a new datatype with the type-checker */ + +SWIGSTATIC +void SWIG_RegisterMapping(char *origtype, char *newtype, void *(*cast)(void *)) { + + int i; + SwigPtrType *t = 0,*t1; + + /* Allocate the pointer table if necessary */ + + if (!SwigPtrTable) { + SwigPtrTable = (SwigPtrType *) malloc(SwigPtrMax*sizeof(SwigPtrType)); + SwigPtrN = 0; + } + /* Grow the table */ + if (SwigPtrN >= SwigPtrMax) { + SwigPtrMax = 2*SwigPtrMax; + SwigPtrTable = (SwigPtrType *) realloc((char *) SwigPtrTable,SwigPtrMax*sizeof(SwigPtrType)); + } + for (i = 0; i < SwigPtrN; i++) + if (strcmp(SwigPtrTable[i].name,origtype) == 0) { + t = &SwigPtrTable[i]; + break; + } + if (!t) { + t = &SwigPtrTable[SwigPtrN]; + t->name = origtype; + t->len = strlen(t->name); + t->cast = 0; + t->next = 0; + SwigPtrN++; + } + + /* Check for existing entry */ + + while (t->next) { + if ((strcmp(t->name,newtype) == 0)) { + if (cast) t->cast = cast; + return; + } + t = t->next; + } + + /* Now place entry (in sorted order) */ + + t1 = (SwigPtrType *) malloc(sizeof(SwigPtrType)); + t1->name = newtype; + t1->len = strlen(t1->name); + t1->cast = cast; + t1->next = 0; + t->next = t1; + SwigPtrSort = 0; +} + +/* Make a pointer value string */ + +SWIGSTATIC +void SWIG_MakePtr(char *_c, const void *_ptr, char *type) { + static char _hex[16] = + {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f'}; + unsigned long _p, _s; + char _result[20], *_r; /* Note : a 64-bit hex number = 16 digits */ + _r = _result; + _p = (unsigned long) _ptr; + if (_p > 0) { + while (_p > 0) { + _s = _p & 0xf; + *(_r++) = _hex[_s]; + _p = _p >> 4; + } + *_r = '_'; + while (_r >= _result) + *(_c++) = *(_r--); + } else { + strcpy (_c, "NULL"); + } + if (_ptr) + strcpy (_c, type); +} + +/* Function for getting a pointer value */ + +SWIGSTATIC +char *SWIG_GetPtr(char *_c, void **ptr, char *_t) +{ + unsigned long _p; + char temp_type[256]; + char *name; + int i, len; + SwigPtrType *sp,*tp; + SwigCacheType *cache; + int start, end; + _p = 0; + + /* Pointer values must start with leading underscore */ + if (*_c == '_') { + _c++; + /* Extract hex value from pointer */ + while (*_c) { + if ((*_c >= '0') && (*_c <= '9')) + _p = (_p << 4) + (*_c - '0'); + else if ((*_c >= 'a') && (*_c <= 'f')) + _p = (_p << 4) + ((*_c - 'a') + 10); + else + break; + _c++; + } + + if (_t) { + if (strcmp(_t,_c)) { + if (!SwigPtrSort) { + qsort((void *) SwigPtrTable, SwigPtrN, sizeof(SwigPtrType), swigsort); + for (i = 0; i < 256; i++) { + SwigStart[i] = SwigPtrN; + } + for (i = SwigPtrN-1; i >= 0; i--) { + SwigStart[(int) (SwigPtrTable[i].name[1])] = i; + } + for (i = 255; i >= 1; i--) { + if (SwigStart[i-1] > SwigStart[i]) + SwigStart[i-1] = SwigStart[i]; + } + SwigPtrSort = 1; + for (i = 0; i < SWIG_CACHESIZE; i++) + SwigCache[i].stat = 0; + } + + /* First check cache for matches. Uses last cache value as starting point */ + cache = &SwigCache[SwigLastCache]; + for (i = 0; i < SWIG_CACHESIZE; i++) { + if (cache->stat) { + if (strcmp(_t,cache->name) == 0) { + if (strcmp(_c,cache->mapped) == 0) { + cache->stat++; + *ptr = (void *) _p; + if (cache->tp->cast) *ptr = (*(cache->tp->cast))(*ptr); + return (char *) 0; + } + } + } + SwigLastCache = (SwigLastCache+1) & SWIG_CACHEMASK; + if (!SwigLastCache) cache = SwigCache; + else cache++; + } + /* We have a type mismatch. Will have to look through our type + mapping table to figure out whether or not we can accept this datatype */ + + start = SwigStart[(int) _t[1]]; + end = SwigStart[(int) _t[1]+1]; + sp = &SwigPtrTable[start]; + while (start < end) { + if (swigcmp(_t,sp) == 0) break; + sp++; + start++; + } + if (start >= end) sp = 0; + /* Try to find a match for this */ + if (sp) { + while (swigcmp(_t,sp) == 0) { + name = sp->name; + len = sp->len; + tp = sp->next; + /* Try to find entry for our given datatype */ + while(tp) { + if (tp->len >= 255) { + return _c; + } + strcpy(temp_type,tp->name); + strncat(temp_type,_t+len,255-tp->len); + if (strcmp(_c,temp_type) == 0) { + + strcpy(SwigCache[SwigCacheIndex].mapped,_c); + strcpy(SwigCache[SwigCacheIndex].name,_t); + SwigCache[SwigCacheIndex].stat = 1; + SwigCache[SwigCacheIndex].tp = tp; + SwigCacheIndex = SwigCacheIndex & SWIG_CACHEMASK; + + /* Get pointer value */ + *ptr = (void *) _p; + if (tp->cast) *ptr = (*(tp->cast))(*ptr); + return (char *) 0; + } + tp = tp->next; + } + sp++; + /* Hmmm. Didn't find it this time */ + } + } + /* Didn't find any sort of match for this data. + Get the pointer value and return the received type */ + *ptr = (void *) _p; + return _c; + } else { + /* Found a match on the first try. Return pointer value */ + *ptr = (void *) _p; + return (char *) 0; + } + } else { + /* No type specified. Good luck */ + *ptr = (void *) _p; + return (char *) 0; + } + } else { + if (strcmp (_c, "NULL") == 0) { + *ptr = (void *) 0; + return (char *) 0; + } + *ptr = (void *) 0; + return _c; + } +} + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef MAC_TCL +#pragma export on +#endif +SWIGEXPORT(int,Pdflib_Init)(Tcl_Interp *); +SWIGEXPORT(int,Pdflib_SafeInit)(Tcl_Interp *); +SWIGEXPORT(int,Pdflib_tcl_SafeInit)(Tcl_Interp *); +SWIGEXPORT(int,Pdflib_tcl_Init)(Tcl_Interp *); +SWIGEXPORT(int,Pdf_tcl_Init)(Tcl_Interp *); +SWIGEXPORT(int,Pdf_tcl_SafeInit)(Tcl_Interp *); +#ifdef MAC_TCL +#pragma export off +#endif +#ifdef __cplusplus +} +#endif + +#include + +#include "pdflib.h" + +/* Exception handling */ + +#define try PDF_TRY(p) +#define catch PDF_CATCH(p) {\ + char errmsg[1024];\ + sprintf(errmsg, "PDFlib Error [%d] %s: %s", PDF_get_errnum(p),\ + PDF_get_apiname(p), PDF_get_errmsg(p));\ + Tcl_SetResult(interp, errmsg, TCL_STATIC);\ + return TCL_ERROR; \ + } + +/* Unicode support is only available in Tcl 8.2 and higher */ + +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION >= 82 + +/* + * Unicode strings for page description text and hyper text strings + */ + +static char * +GetStringUnicodePDFChars(PDF *p, Tcl_Interp *interp, Tcl_Obj *objPtr, int *lenP) +{ + Tcl_UniChar *unistring = NULL; + size_t len = 0; + + if (objPtr) { + unistring = Tcl_GetUnicode(objPtr); + if (unistring) { + len = (size_t) Tcl_UniCharLen(unistring); + } + } + + *lenP = (int) (2 * len); + return (char *) unistring; +} + + +#else /* Tcl version older than 8.2 */ + +/* The cheap version doesn't know about Unicode strings */ + +#define GetStringUnicodePDFChars(p, interp, objPtr, lenP) \ + Tcl_GetStringFromObj(objPtr, NULL) + +#endif /* Tcl version older than 8.2 */ + +/* export the PDFlib routines to the shared library */ +#ifdef __MWERKS__ +#pragma export on +#endif + +/* p_annots.c */ + +static int +_wrap_PDF_add_launchlink(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char *_arg5; + + if (argc != 7) { + Tcl_SetResult(interp, "Wrong # args. PDF_add_launchlink p llx lly urx ury filename ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_add_launchlink. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = argv[6]; + + try { PDF_add_launchlink(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_add_locallink(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + int _arg5; + char *_arg6; + + if (argc != 8) { + Tcl_SetResult(interp, "Wrong # args. PDF_add_locallink p llx lly urx ury page optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_add_locallink. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + if (Tcl_GetInt(interp, argv[6], &_arg5) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 6 of PDF_add_locallink.", TCL_STATIC); + return TCL_ERROR; + } + _arg6 = argv[7]; + + try { PDF_add_locallink(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_add_note(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + double llx; + double lly; + double urx; + double ury; + char *contents; + char *title; + char *icon; + int open; + char *res; + int len_cont; + int len_title; + + if (objc != 10) { + Tcl_SetResult(interp, "Wrong # args. PDF_add_note p llx lly urx ury contents title icon open ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_add_note. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[2], &llx) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve llx in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[3], &lly) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve lly in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[4], &urx) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve urx in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[5], &ury) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve ury in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if ((contents = GetStringUnicodePDFChars(p, interp, objv[6], &len_cont)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve contents argument in PDF_add_note", TCL_STATIC); + return TCL_ERROR; + } + + if ((title = GetStringUnicodePDFChars(p, interp, objv[7], &len_title)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve title argument in PDF_add_note", TCL_STATIC); + return TCL_ERROR; + } + + if ((icon = Tcl_GetStringFromObj(objv[8], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve icon in PDF_add_note", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[9], &open) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve open argument in PDF_add_note", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_add_note2(p, (float) llx, (float) lly, (float) urx, + (float) ury,contents,len_cont,title,len_title,icon,open); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_add_pdflink(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char *_arg5; + int _arg6; + char *_arg7; + + if (argc != 9) { + Tcl_SetResult(interp, "Wrong # args. PDF_add_pdflink p llx lly urx ury filename page optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_add_pdflink. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = argv[6]; + if (Tcl_GetInt(interp, argv[7], &_arg6) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 7 of PDF_add_pdflink.", TCL_STATIC); + return TCL_ERROR; + } + _arg7 = argv[8]; + + try { PDF_add_pdflink(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_add_weblink(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + char *_arg5; + + if (argc != 7) { + Tcl_SetResult(interp, "Wrong # args. PDF_add_weblink p llx lly urx ury url ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_add_weblink. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = argv[6]; + + try { PDF_add_weblink(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_attach_file(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + double llx; + double lly; + double urx; + double ury; + char *filename; + char *description; + char *author; + char *mimetype; + char *icon; + char *res; + int len_descr; + int len_autho; + + if (objc != 11) { + Tcl_SetResult(interp, "Wrong # args. PDF_attach_file p llx lly urx ury filename description author mimetype icon ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res,(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_attach_file. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[2], &llx) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve llx in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[3], &lly) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve lly in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[4], &urx) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve urx in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[5], &ury) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve ury in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if ((filename = Tcl_GetStringFromObj(objv[6], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve filename in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if ((description = GetStringUnicodePDFChars(p, interp, objv[7], &len_descr)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve description argument in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if ((author = GetStringUnicodePDFChars(p, interp, objv[8], &len_autho)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve author argument in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if ((mimetype = Tcl_GetStringFromObj(objv[9], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve mimetype in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + if ((icon = Tcl_GetStringFromObj(objv[10], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve icon in PDF_attach_file", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_attach_file2(p, (float) llx, (float) lly, + (float) urx, (float) ury,filename,0,description,len_descr, + author,len_autho,mimetype,icon); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_set_border_color(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_set_border_color p red green blue ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_set_border_color. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + + try { PDF_set_border_color(p,_arg1,_arg2,_arg3); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_set_border_dash(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_set_border_dash p b w ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_set_border_dash. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_set_border_dash(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_set_border_style(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + char *_arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_set_border_style p style width ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_set_border_style. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = argv[2]; + _arg2 = (float) atof(argv[3]); + + try { PDF_set_border_style(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +/* p_basic.c */ + +static int +_wrap_PDF_begin_page(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_begin_page p width height ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_begin_page. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_begin_page(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_close(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_close p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_close. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_close(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_delete(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_delete p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_delete. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + PDF_delete(p); + + return TCL_OK; +} + +static int +_wrap_PDF_end_page(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_end_page p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_end_page. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_end_page(p); + } catch; + + return TCL_OK; +} + +static int _wrap_PDF_get_apiname(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + char volatile *_result = NULL; + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_get_apiname p",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_get_apiname. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { + _result = (char *)PDF_get_apiname(p); + Tcl_SetResult(interp, (char *) _result, TCL_VOLATILE); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_get_buffer(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + + const char volatile *buffer = NULL; + PDF *p; + Tcl_Obj *result; + char *res; + long size; + + if (objc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_get_buffer p", TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_get_buffer. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + try { + buffer = PDF_get_buffer(p, &size); + result = Tcl_GetObjResult(interp); + +/* ByteArrays appeared only in Tcl 8.1 */ +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION >= 81 + Tcl_SetByteArrayObj(result, (unsigned char *) buffer, (int) size); +#else /* Tcl 8.0 */ + Tcl_SetStringObj(result, (char *) buffer, (int) size); +#endif /* Tcl 8.0 */ + + } catch; + + return TCL_OK; +} + +static int _wrap_PDF_get_errmsg(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + char volatile *_result = NULL; + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_get_errmsg p",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_get_errmsg. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { + _result = (char *)PDF_get_errmsg(p); + Tcl_SetResult(interp, (char *) _result, TCL_VOLATILE); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_get_errnum(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_get_errnum p",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_get_errnum. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + try { + _result = (int)PDF_get_errnum(p); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_new(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + char versionbuf[32]; + + if (argc != 1) { + Tcl_SetResult(interp, "Wrong # args. PDF_new ",TCL_STATIC); + return TCL_ERROR; + } + + p = (PDF *)PDF_new(); + + if (p) { + +/* The GetVersion API appeared in Tcl 8.1 */ +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION >= 81 + int major, minor, type, patchlevel; + Tcl_GetVersion(&major, &minor, &patchlevel, &type); + sprintf(versionbuf, "Tcl %d.%d%c%d", major, minor, "ab."[type], patchlevel); +#else +#ifdef TCL_PATCH_LEVEL + sprintf(versionbuf, "Tcl %s", TCL_PATCH_LEVEL); +#else + sprintf(versionbuf, "Tcl (unknown)"); +#endif +#endif + PDF_set_parameter(p, "binding", versionbuf); + PDF_set_parameter(p, "textformat", "auto2"); + PDF_set_parameter(p, "hypertextformat", "auto2"); + PDF_set_parameter(p, "hypertextencoding", ""); + } + /* TODO: else show some error */ + + SWIG_MakePtr(interp->result, (void *) p,"_PDF_p"); + return TCL_OK; +} + +static int +_wrap_PDF_open_file(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + char *_arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_open_file p filename ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_open_file. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = argv[2]; + + try { _result = (int)PDF_open_file(p,_arg1); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +/* p_block.c */ + +static int +_wrap_PDF_fill_imageblock(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int volatile _result = -1; + PDF *p; + char *res; + int len = 0; + int page; + char *blockname; + int image; + char *optlist; + int error; + + if (objc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_fill_imageblock p page blockname image optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_fill_imageblock. Expected _PDF_p, received ", + TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((error = Tcl_GetIntFromObj(interp, objv[2], &page)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve page argument in PDF_fill_imageblock", TCL_STATIC); + return TCL_ERROR; + } + + if ((blockname = Tcl_GetStringFromObj(objv[3], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve blockname argument in PDF_fill_imageblock", TCL_STATIC); + return TCL_ERROR; + } + if ((error = Tcl_GetIntFromObj(interp, objv[4], &image)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve image argument in PDF_fill_imageblock", TCL_STATIC); + return TCL_ERROR; + } + + if ((optlist = Tcl_GetStringFromObj(objv[5], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve optlist argument in PDF_fill_imageblock", TCL_STATIC); + return TCL_ERROR; + } + + + try { + _result = (int)PDF_fill_imageblock(p, page, blockname, image, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_fill_pdfblock(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int volatile _result = -1; + PDF *p; + char *res; + int len = 0; + int page; + char * blockname; + int contents; + char * optlist; + int error; + + if (objc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_fill_pdfblock p page blockname contents optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_fill_pdfblock. Expected _PDF_p, received ", + TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((error = Tcl_GetIntFromObj(interp, objv[2], &page)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve page argument in PDF_fill_pdfblock", TCL_STATIC); + return TCL_ERROR; + } + + if ((blockname = Tcl_GetStringFromObj(objv[3], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve blockname argument in PDF_fill_pdfblock", TCL_STATIC); + return TCL_ERROR; + } + if ((error = Tcl_GetIntFromObj(interp, objv[4], &contents)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve contents argument in PDF_fill_pdfblock", TCL_STATIC); + return TCL_ERROR; + } + + if ((optlist = Tcl_GetStringFromObj(objv[5], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve optlist argument in PDF_fill_pdfblock", TCL_STATIC); + return TCL_ERROR; + } + + + try { + _result = (int)PDF_fill_pdfblock(p, page, blockname, contents, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_fill_textblock(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int volatile _result = -1; + PDF *p; + char *res; + int len = 0; + int page; + char * blockname; + char *text; + int text_len = 0; + char * optlist; + int error; + + if (objc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_fill_textblock p page blockname text optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_fill_textblock. Expected _PDF_p, received ", + TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((error = Tcl_GetIntFromObj(interp, objv[2], &page)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve page argument in PDF_fill_textblock", TCL_STATIC); + return TCL_ERROR; + } + + if ((blockname = Tcl_GetStringFromObj(objv[3], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve blockname argument in PDF_fill_textblock", TCL_STATIC); + return TCL_ERROR; + } + if ((text = GetStringUnicodePDFChars(p, interp, objv[4], &text_len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve text argument in PDF_fill_textblock", TCL_STATIC); + return TCL_ERROR; + } + + + if ((optlist = Tcl_GetStringFromObj(objv[5], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve optlist argument in PDF_fill_textblock", TCL_STATIC); + return TCL_ERROR; + } + + + try { + _result = (int)PDF_fill_textblock(p, page, blockname, text, text_len, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +/* p_color.c */ + +static int +_wrap_PDF_makespotcolor(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + char *spotname; + int reserved = 0; + + if (argc != 4 && argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_makespotcolor p spotname",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_makespotcolor. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + spotname = argv[2]; + /* ignore "reserved" argument was a bug in V4 wrapper */ + /* reserved = (int) atol(argv[3]); */ + + try { _result = (int)PDF_makespotcolor(p, spotname, reserved); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_setcolor(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + char *_arg1; + char *_arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + + if (argc != 8) { + Tcl_SetResult(interp, "Wrong # args. PDF_setcolor p fstype colorspace c1 c2 c3 c4 ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setcolor. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = argv[2]; + _arg2 = argv[3]; + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = (float) atof(argv[6]); + _arg6 = (float) atof(argv[7]); + + try { PDF_setcolor(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setgray(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setgray p g ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setgray. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + + try { PDF_setcolor(p, "fillstroke", "gray", _arg1, 0, 0, 0); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setgray_fill(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setgray_fill p g ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setgray_fill. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + + try { PDF_setcolor(p, "fill", "gray", _arg1, 0, 0, 0); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setgray_stroke(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setgray_stroke p g ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setgray_stroke. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + + try { PDF_setcolor(p, "stroke", "gray", _arg1, 0, 0, 0); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setrgbcolor(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_setrgbcolor p red green blue ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setrgbcolor. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + + try { PDF_setcolor(p, "fillstroke", "rgb", _arg1, _arg2, _arg3, 0); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setrgbcolor_fill(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_setrgbcolor_fill p red green blue ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setrgbcolor_fill. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + + try { PDF_setcolor(p, "fill", "rgb", _arg1, _arg2, _arg3, 0); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setrgbcolor_stroke(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_setrgbcolor_stroke p red green blue ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setrgbcolor_stroke. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + + try { PDF_setcolor(p, "stroke", "rgb", _arg1, _arg2, _arg3, 0); + } catch; + + return TCL_OK; +} + +/* p_draw.c */ + +static int +_wrap_PDF_arc(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + + if (argc != 7) { + Tcl_SetResult(interp, "Wrong # args. PDF_arc p x y r alpha beata ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_arc. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = (float) atof(argv[6]); + + try { PDF_arc(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_arcn(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + + if (argc != 7) { + Tcl_SetResult(interp, "Wrong # args. PDF_arcn p x y r alpha beta ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_arcn. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = (float) atof(argv[6]); + + try { PDF_arcn(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_circle(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_circle p x y r ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_circle. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + + try { PDF_circle(p,_arg1,_arg2,_arg3); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_clip(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_clip p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_clip. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_clip(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_closepath(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_closepath p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_closepath. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_closepath(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_closepath_fill_stroke(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_closepath_fill_stroke p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_closepath_fill_stroke. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_closepath_fill_stroke(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_closepath_stroke(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_closepath_stroke p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_closepath_stroke. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_closepath_stroke(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_curveto(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + + if (argc != 8) { + Tcl_SetResult(interp, "Wrong # args. PDF_curveto p x1 y1 x2 y2 x3 y3 ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_curveto. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = (float) atof(argv[6]); + _arg6 = (float) atof(argv[7]); + + try { PDF_curveto(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_endpath(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_endpath p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_endpath. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_endpath(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_fill(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_fill p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_fill. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_fill(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_fill_stroke(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_fill_stroke p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_fill_stroke. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_fill_stroke(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_lineto(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_lineto p x y ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_lineto. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_lineto(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_moveto(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_moveto p x y ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_moveto. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_moveto(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_rect(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + + if (argc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_rect p x y width height ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_rect. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + + try { PDF_rect(p,_arg1,_arg2,_arg3,_arg4); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_stroke(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_stroke p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_stroke. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_stroke(p); + } catch; + + return TCL_OK; +} + +/* p_encoding.c */ + +static int +_wrap_PDF_encoding_set_char(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + char *encoding; + int slot; + char *glyphname; + int uv; + + if (argc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_encoding_set_char p encoding slot glyphname uv ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_encoding_set_char. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + encoding = argv[2]; + slot = (int) atol(argv[3]); + glyphname = argv[4]; + uv = (int) atol(argv[5]); + + try { PDF_encoding_set_char(p, encoding, slot, glyphname, uv); + } catch; + + return TCL_OK; +} + +/* p_font.c */ + +static int +_wrap_PDF_findfont(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + char *_arg1; + char *_arg2; + int _arg3; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_findfont p fontname encoding embed ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_findfont. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = argv[2]; + _arg2 = argv[3]; + + if (Tcl_GetInt(interp, argv[4], &_arg3) != TCL_OK) { + Tcl_SetResult(interp, "Type error in argument 4 of PDF_findfont: ", + TCL_STATIC); + Tcl_AppendResult(interp, argv[4], (char *) NULL); + return TCL_ERROR; + } + + try { _result = (int)PDF_findfont(p,_arg1,_arg2,_arg3); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_load_font(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int volatile _result = -1; + PDF *p; + char *res; + int len = 0; + int len1; + char *fontname; + char *encoding; + char *optlist; + + if (objc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_load_font p fontname encoding optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_load_font. Expected _PDF_p, received ", + TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((fontname = GetStringUnicodePDFChars(p, interp, objv[2], &len1)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve fontname argument in PDF_load_font", TCL_STATIC); + return TCL_ERROR; + } + if ((encoding = Tcl_GetStringFromObj(objv[3], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve encoding argument in PDF_load_font", TCL_STATIC); + return TCL_ERROR; + } + if ((optlist = Tcl_GetStringFromObj(objv[4], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve optlist argument in PDF_load_font", TCL_STATIC); + return TCL_ERROR; + } + + + try { + _result = (int)PDF_load_font(p, fontname, len1, encoding, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_setfont(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_setfont p font fontsize ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setfont. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetInt(interp, argv[2], &_arg1) != TCL_OK) { + Tcl_SetResult(interp, "Type error in argument 2 of PDF_setfont: ", + TCL_STATIC); + Tcl_AppendResult(interp, argv[2], (char *) NULL); + return TCL_ERROR; + } + _arg2 = (float) atof(argv[3]); + + try { PDF_setfont(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +/* p_gstate.c */ + +static int +_wrap_PDF_concat(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + + if (argc != 8) { + Tcl_SetResult(interp, + "Wrong # args. PDF_concat p a b c d e f ", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_concat. Expected _PDF_p, received ", + TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = (float) atof(argv[6]); + _arg6 = (float) atof(argv[7]); + + try { PDF_concat(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_initgraphics(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_initgraphics p ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_initgraphics. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_initgraphics(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_restore(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_restore p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_restore. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_restore(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_rotate(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_rotate p phi ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_rotate. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + + try { PDF_rotate(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_save(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_save p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_save. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_save(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_scale(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_scale p sx sy ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_scale. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_scale(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setdash(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_setdash p b w ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setdash. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_setdash(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setdashpattern(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + char *optlist; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setdashpattern p optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setdashpattern. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + optlist = argv[2]; + + try { PDF_setdashpattern(p, optlist); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setflat(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setflat p flatness ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setflat. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (float) atof(argv[2]); + + try { PDF_setflat(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setlinecap(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setlinecap p linecap ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setlinecap. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetInt(interp, argv[2], &_arg1) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 2 of PDF_setlinecap.", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_setlinecap(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setlinejoin(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setlinejoin p linejoin ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setlinejoin. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetInt(interp, argv[2], &_arg1) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 2 of PDF_setlinejoin.", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_setlinejoin(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setlinewidth(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setlinewidth p width ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setlinewidth. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + + try { PDF_setlinewidth(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setmatrix(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + float _arg6; + + if (argc != 8) { + Tcl_SetResult(interp, "Wrong # args. PDF_setmatrix p a b c d e f ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setmatrix. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = (float) atof(argv[6]); + _arg6 = (float) atof(argv[7]); + + try { PDF_setmatrix(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setmiterlimit(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_setmiterlimit p miter ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_setmiterlimit. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + + try { PDF_setmiterlimit(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_setpolydash(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + float carray[MAX_DASH_LENGTH]; + double dval; + int length, i; + Tcl_Obj *val; + char *res; + + if (objc != 3) { + Tcl_SetResult(interp, + "Wrong # args. PDF_setpolydash p darray length ", TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_setpolydash. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_ListObjLength(interp, objv[2], &length) != TCL_OK) { + Tcl_SetResult(interp, + "Couldn't retrieve array length in PDF_setpolydash", TCL_STATIC); + return TCL_ERROR; + } + if (length > MAX_DASH_LENGTH) + length = MAX_DASH_LENGTH; + + for (i = 0; i < length; i++) { + if (Tcl_ListObjIndex(interp, objv[2], i, &val) != TCL_OK || + Tcl_GetDoubleFromObj(interp, val, &dval) != TCL_OK) { + Tcl_SetResult(interp, + "Couldn't retrieve array value in PDF_setpolydash", TCL_STATIC); + return TCL_ERROR; + } + carray[i] = (float) dval; + } + + try { PDF_setpolydash(p, carray, length); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_skew(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_skew p alpha beta ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_skew. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_skew(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_translate(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_translate p tx ty ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_translate. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_translate(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +/* p_hyper.c */ + +static int +_wrap_PDF_add_bookmark(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int volatile _result = -1; + PDF *p; + char *_arg1; + int _arg2; + int _arg3; + char *res; + int error; + int len; + + if (objc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_add_bookmark p text parent open ", TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer in PDF_add_bookmark", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_add_bookmark. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((_arg1 = GetStringUnicodePDFChars(p, interp, objv[2], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve text argument in PDF_add_bookmark", TCL_STATIC); + return TCL_ERROR; + } + + if ((error = Tcl_GetIntFromObj(interp, objv[3], &_arg2)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve parent argument in PDF_add_bookmark", TCL_STATIC); + return TCL_ERROR; + } + + if ((error = Tcl_GetIntFromObj(interp, objv[4], &_arg3)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve open argument in PDF_add_bookmark", TCL_STATIC); + return TCL_ERROR; + } + + try { _result = (int)PDF_add_bookmark2(p,_arg1,len,_arg2,_arg3); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_add_nameddest(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + char *name; + char *optlist; + char *res; + int len; + + if (objc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_add_nameddest p name optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_add_nameddest. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((name = Tcl_GetStringFromObj(objv[2], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve name argument in PDF_add_nameddest", TCL_STATIC); + return TCL_ERROR; + } + + if ((optlist = Tcl_GetStringFromObj(objv[3], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve optlist argument in PDF_add_nameddest", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_add_nameddest(p, name, 0, optlist); + } catch; + + return TCL_OK; +} + + +static int +_wrap_PDF_set_info(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + char *_arg1; + char *_arg2; + char *res; + int len; + + if (objc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_set_info p key value ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_set_info. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((_arg1 = Tcl_GetStringFromObj(objv[2], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve key argument in PDF_set_info", TCL_STATIC); + return TCL_ERROR; + } + + if ((_arg2 = GetStringUnicodePDFChars(p, interp, objv[3], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve value argument in PDF_set_info", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_set_info2(p,_arg1,_arg2,len); + } catch; + + return TCL_OK; +} + +/* p_icc.c */ + +static int +_wrap_PDF_load_iccprofile(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int volatile _result = -1; + PDF *p; + char *profilename; + char *optlist; + char *res; + int len; + + if (objc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_load_iccprofile p profilename optlist", TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer in PDF_load_iccprofile", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_load_iccprofile. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((profilename = Tcl_GetStringFromObj(objv[2], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve profilename argument in PDF_load_iccprofile", TCL_STATIC); + return TCL_ERROR; + } + if ((optlist = Tcl_GetStringFromObj(objv[3], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve optlist argument in PDF_load_iccprofile", TCL_STATIC); + return TCL_ERROR; + } + + try { _result = (int)PDF_load_iccprofile(p, profilename, 0, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + + +/* p_image.c */ + +static int +_wrap_PDF_add_thumbnail(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + PDF *p; + int _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_add_thumbnail p image ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_add_thumbnail. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (int) atol(argv[2]); + + try { PDF_add_thumbnail(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_close_image(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_close_image p image ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_close_image. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetInt(interp, argv[2], &_arg1) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 2 of PDF_close_image.", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_close_image(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_fit_image(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int image; + float x; + float y; + char *optlist; + + if (argc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_fit_image p image x y optlist",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_fit_image. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetInt(interp, argv[2], &image) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument image of PDF_fit_image.", TCL_STATIC); + return TCL_ERROR; + } + x = (float) atof(argv[3]); + y = (float) atof(argv[4]); + optlist = argv[5]; + + try { PDF_fit_image(p, image, x, y, optlist); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_load_image(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int volatile _result = -1; + PDF *p; + char *res; + char *imagetype; + char *filename; + char *optlist; + int len = 0; + int fnam_len = 0; + + if (objc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_load_image p imagetype filename optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_load_image. Expected _PDF_p, received ", + TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((imagetype = Tcl_GetStringFromObj(objv[2], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve imagetype argument in PDF_load_image", TCL_STATIC); + return TCL_ERROR; + } + if ((filename = Tcl_GetStringFromObj(objv[3], &fnam_len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve filename argument in PDF_load_image", TCL_STATIC); + return TCL_ERROR; + } + + if ((optlist = Tcl_GetStringFromObj(objv[4], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve optlist argument in PDF_load_image", TCL_STATIC); + return TCL_ERROR; + } + + + try { + _result = (int)PDF_load_image(p, imagetype, filename, 0, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + + +static int +_wrap_PDF_open_CCITT(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + char *_arg1; + int _arg2; + int _arg3; + int _arg4; + int _arg5; + int _arg6; + + if (argc != 8) { + Tcl_SetResult(interp, "Wrong # args. PDF_open_CCITT p filename width height BitReverse K BlackIs1 ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_open_CCITT. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = argv[2]; + if (Tcl_GetInt(interp, argv[3], &_arg2) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 3 of PDF_open_CCITT.", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetInt(interp, argv[4], &_arg3) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 4 of PDF_open_CCITT.", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetInt(interp, argv[5], &_arg4) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 5 of PDF_open_CCITT.", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetInt(interp, argv[6], &_arg5) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 6 of PDF_open_CCITT.", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetInt(interp, argv[7], &_arg6) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 7 of PDF_open_CCITT.", TCL_STATIC); + return TCL_ERROR; + } + + try { _result = (int)PDF_open_CCITT(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_open_image(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + + int volatile _result = -1; + PDF *p; + char *_arg1; + char *_arg2; + char *_arg3; + long _arg4; + int _arg5; + int _arg6; + int _arg7; + int _arg8; + char *_arg9; + int len = 0; + char *res; + + if (objc != 11) { + Tcl_SetResult(interp, "Wrong # args. PDF_open_image p imagetype source data length width height components bpc params", TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer in PDF_open_image", + TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_open_image. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((_arg1 = Tcl_GetStringFromObj(objv[2], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve imagetype argument in PDF_open_image", TCL_STATIC); + return TCL_ERROR; + } + if ((_arg2 = Tcl_GetStringFromObj(objv[3], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve source argument in PDF_open_image", TCL_STATIC); + return TCL_ERROR; + } + +/* ByteArrays appeared only in Tcl 8.1 */ + +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION >= 81 + + if ((_arg3 = (char *) Tcl_GetByteArrayFromObj(objv[4], &len)) == NULL) { + +#else /* Tcl 8.0 */ + + if ((_arg3 = (char *) Tcl_GetStringFromObj(objv[4], &len)) == NULL) { +#endif /* Tcl 8.0 */ + + Tcl_SetResult(interp, + "Couldn't retrieve data argument in PDF_open_image", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetLongFromObj(interp, objv[5], &_arg4) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 5 of PDF_open_image.", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetIntFromObj(interp, objv[6], &_arg5) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 6 of PDF_open_image.", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetIntFromObj(interp, objv[7], &_arg6) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 7 of PDF_open_image.", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetIntFromObj(interp, objv[8], &_arg7) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 8 of PDF_open_image.", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetIntFromObj(interp, objv[9], &_arg8) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 9 of PDF_open_image.", TCL_STATIC); + return TCL_ERROR; + } + if ((_arg9 = Tcl_GetStringFromObj(objv[10], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve argument 10 in PDF_open_image", TCL_STATIC); + return TCL_ERROR; + } + + try { + _result = (int)PDF_open_image(p,_arg1,_arg2,_arg3,_arg4,_arg5,_arg6,_arg7,_arg8,_arg9); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_open_image_file(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + char *_arg1; + char *_arg2; + char *_arg3; + int _arg4; + + if (argc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_open_image_file p imagetype filename stringparam intparam ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_open_image_file. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = argv[2]; + _arg2 = argv[3]; + _arg3 = argv[4]; + if (Tcl_GetInt(interp, argv[5], &_arg4) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 5 of PDF_open_image_file.", TCL_STATIC); + return TCL_ERROR; + } + + try { _result = (int)PDF_open_image_file(p,_arg1,_arg2,_arg3,_arg4); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_place_image(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int _arg1; + float _arg2; + float _arg3; + float _arg4; + + if (argc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_place_image p image x y scale ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_place_image. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + if (Tcl_GetInt(interp, argv[2], &_arg1) != TCL_OK) { + Tcl_SetResult(interp, + "Type error in argument 2 of PDF_place_image.", TCL_STATIC); + return TCL_ERROR; + } + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + + try { PDF_place_image(p,_arg1,_arg2,_arg3,_arg4); + } catch; + + return TCL_OK; +} + +/* p_params.c */ + + +static int _wrap_PDF_get_parameter(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + char volatile *_result = NULL; + PDF *p; + char *_arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_get_parameter p key modifier ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_get_parameter. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = argv[2]; + _arg2 = (float) atof(argv[3]); + + try { + _result = (char *)PDF_get_parameter(p,_arg1,_arg2); + Tcl_SetResult(interp, (char *) _result, TCL_VOLATILE); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_get_value(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + float volatile _result = 0; + PDF *p; + char *_arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_get_value p key modifier ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + p = NULL; + } + _arg1 = argv[2]; + _arg2 = (float) atof(argv[3]); + + if (p != NULL) { + try { _result = (float)PDF_get_value(p,_arg1,_arg2); + } catch; + } else { + _result = (float)PDF_get_value(p,_arg1,_arg2); + } + + Tcl_PrintDouble(interp,(double) _result, interp->result); + return TCL_OK; +} + +static int +_wrap_PDF_set_parameter(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + char *_arg1; + char *_arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_set_parameter p key value ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_set_parameter. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = argv[2]; + _arg2 = argv[3]; + + try { + PDF_set_parameter(p, _arg1, _arg2); + + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_set_value(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + PDF *p; + char *_arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_set_value p key value ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_set_value. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = argv[2]; + _arg2 = (float) atof(argv[3]); + + try { PDF_set_value(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +/* p_pattern.c */ + +static int +_wrap_PDF_begin_pattern(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + float _arg1; + float _arg2; + float _arg3; + float _arg4; + int _arg5; + + if (argc != 7) { + Tcl_SetResult(interp, "Wrong # args. PDF_begin_pattern p width height xstep ystep painttype ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_begin_pattern. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = (int) atol(argv[6]); + + try { _result = (int)PDF_begin_pattern(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_end_pattern(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_end_pattern p ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_end_pattern. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_end_pattern(p); + } catch; + + return TCL_OK; +} + +/* p_pdi.c */ + +static int +_wrap_PDF_close_pdi(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_close_pdi p doc ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_close_pdi. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (int) atol(argv[2]); + + try { PDF_close_pdi(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_close_pdi_page(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int _arg1; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_close_pdi_page p page ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_close_pdi_page. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (int) atol(argv[2]); + + try { PDF_close_pdi_page(p,_arg1); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_fit_pdi_page(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int page; + float x; + float y; + char *optlist; + + if (argc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_fit_pdi_page p page x y optlist",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_fit_pdi_page. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + page = (int) atol(argv[2]); + x = (float) atof(argv[3]); + y = (float) atof(argv[4]); + optlist = argv[5]; + + try { PDF_fit_pdi_page(p, page, x, y, optlist); + } catch; + + return TCL_OK; +} + + +static int +_wrap_PDF_get_pdi_parameter(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + char volatile * _result = NULL; + PDF *p; + char *_arg1; + int _arg2; + int _arg3; + int _arg4; + int len; + + if (argc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_get_pdi_parameter p key doc page reserved ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_get_pdi_parameter. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = argv[2]; + _arg2 = (int) atol(argv[3]); + _arg3 = (int) atol(argv[4]); + _arg4 = (int) atol(argv[5]); + + try { + _result = (char *)PDF_get_pdi_parameter(p,_arg1,_arg2,_arg3,_arg4, &len); + /* TODO: return a string object */ + Tcl_SetResult(interp, (char *) _result, TCL_VOLATILE); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_get_pdi_value(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + float volatile _result = -1; + PDF *p; + char *_arg1; + int _arg2; + int _arg3; + int _arg4; + + if (argc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_get_pdi_value p key doc page reserved ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_get_pdi_value. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = argv[2]; + _arg2 = (int) atol(argv[3]); + _arg3 = (int) atol(argv[4]); + _arg4 = (int) atol(argv[5]); + + try { _result = (float)PDF_get_pdi_value(p,_arg1,_arg2,_arg3,_arg4); + } catch; + + Tcl_PrintDouble(interp,(double) _result, interp->result); + return TCL_OK; +} + +static int +_wrap_PDF_open_pdi(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + char *_arg1; + char *_arg2; + int _arg3; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_open_pdi p filename stringparam reserved ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_open_pdi. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = argv[2]; + _arg2 = argv[3]; + _arg3 = (int) atol(argv[4]); + + try { _result = (int)PDF_open_pdi(p,_arg1,_arg2,_arg3); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_open_pdi_page(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + int _arg1; + int _arg2; + char *_arg3; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_open_pdi_page p doc pagenumber optlist ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_open_pdi_page. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (int) atol(argv[2]); + _arg2 = (int) atol(argv[3]); + _arg3 = argv[4]; + + try { _result = (int)PDF_open_pdi_page(p,_arg1,_arg2,_arg3); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_place_pdi_page(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int _arg1; + float _arg2; + float _arg3; + float _arg4; + float _arg5; + + if (argc != 7) { + Tcl_SetResult(interp, "Wrong # args. PDF_place_pdi_page p page x y sx sy",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_place_pdi_page. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (int) atol(argv[2]); + _arg2 = (float) atof(argv[3]); + _arg3 = (float) atof(argv[4]); + _arg4 = (float) atof(argv[5]); + _arg5 = (float) atof(argv[6]); + + try { PDF_place_pdi_page(p,_arg1,_arg2,_arg3,_arg4,_arg5); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_process_pdi(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + int doc; + int page; + char *optlist; + + if (argc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_process_pdi p doc page optlist ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_process_pdi. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + doc = (int) atol(argv[2]); + page = (int) atol(argv[3]); + optlist = argv[4]; + + try { _result = (int)PDF_process_pdi(p, doc, page, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + + +/* p_resource.c */ + +static int +_wrap_PDF_create_pvf(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + char *filename; + char *data; + char *optlist; + int len = 0; + int dlen = 0; + char *res; + + if (objc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_create_pvf p filename data optlist ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_create_pvf. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((filename = Tcl_GetStringFromObj(objv[2], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve filename argument in PDF_create_pvf", TCL_STATIC); + return TCL_ERROR; + } + + if ((data = Tcl_GetStringFromObj(objv[3], &dlen)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve data argument in PDF_create_pvf", TCL_STATIC); + return TCL_ERROR; + } + if ((optlist = Tcl_GetStringFromObj(objv[4], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve optlist argument in PDF_create_pvf", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_create_pvf(p, filename, 0, (void *)data, (size_t)dlen, optlist); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_delete_pvf(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + int volatile _result = -1; + PDF *p; + char *filename; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_delete_pvf p filename ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_delete_pvf. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + filename = argv[2]; + + try { _result = (int)PDF_delete_pvf(p, filename, 0); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + + +/* p_shading.c */ + +static int +_wrap_PDF_shading(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + int volatile _result = -1; + PDF *p; + char *shtype; + float x0; + float y0; + float x1; + float y1; + float c1; + float c2; + float c3; + float c4; + char *optlist; + + if (argc != 12) { + Tcl_SetResult(interp, "Wrong # args. PDF_shading p shtype x0 y0 x1 y1 c1 c2 c3 c4 optlist",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_shading. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + shtype = argv[2]; + x0 = (float) atof(argv[3]); + y0 = (float) atof(argv[4]); + x1 = (float) atof(argv[5]); + y1 = (float) atof(argv[6]); + c1 = (float) atof(argv[7]); + c2 = (float) atof(argv[8]); + c3 = (float) atof(argv[9]); + c4 = (float) atof(argv[10]); + optlist = argv[11]; + + try { _result = (int)PDF_shading(p, shtype, x0, y0, x1, y1, c1, c2, c3, c4, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_shading_pattern(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + int volatile _result = -1; + PDF *p; + int shading; + char *optlist; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_shading_pattern p shading optlist",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_shading_pattern. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + shading = (int) atol(argv[2]); + optlist = argv[3]; + + try { _result = (int)PDF_shading_pattern(p, shading, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_shfill(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + PDF *p; + int shading; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_shfill p shading ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_shfill. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + shading = (int) atol(argv[2]); + + try { PDF_shfill(p, shading); + } catch; + + return TCL_OK; +} + +/* p_template.c */ + +static int +_wrap_PDF_begin_template(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + int volatile _result = -1; + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_begin_template p width height ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_begin_template. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { _result = (int)PDF_begin_template(p,_arg1,_arg2); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_end_template(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_end_template p ",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_end_template. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_end_template(p); + } catch; + + return TCL_OK; +} + +/* p_text.c */ + +static int +_wrap_PDF_continue_text(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + char *_arg1; + int len = 0; + char *res; + + if (objc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_continue_text p text ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_continue_text. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((_arg1 = GetStringUnicodePDFChars(p, interp, objv[2], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve text argument in PDF_continue_text", TCL_STATIC); + return TCL_ERROR; + } + + try { + PDF_continue_text2(p, _arg1, len); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_fit_textline(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + char *text; + double x; + double y; + char *optlist; + int textlen = 0; + int len = 0; + char *res; + + if (objc != 6) { + Tcl_SetResult(interp, "Wrong # args. PDF_fit_textline p text x y optlist",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_fit_textline. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((text = GetStringUnicodePDFChars(p, interp, objv[2], &textlen)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve text argument in PDF_fit_textline", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[3], &x) != TCL_OK) { + Tcl_SetResult(interp, + "Couldn't retrieve x argument in PDF_fit_textline", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetDoubleFromObj(interp, objv[4], &y) != TCL_OK) { + Tcl_SetResult(interp, + "Couldn't retrieve y argument in PDF_fit_textline", TCL_STATIC); + return TCL_ERROR; + } + if ((optlist = Tcl_GetStringFromObj(objv[5], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve optlist argument in PDF_fit_textline", TCL_STATIC); + return TCL_ERROR; + } + + try { + PDF_fit_textline(p, text, textlen, (float) x, (float) y, optlist); + } catch; + + return TCL_OK; +} + + +static int +_wrap_PDF_set_text_pos(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + float _arg1; + float _arg2; + + if (argc != 4) { + Tcl_SetResult(interp, "Wrong # args. PDF_set_text_pos p x y ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_set_text_pos. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + _arg1 = (float) atof(argv[2]); + _arg2 = (float) atof(argv[3]); + + try { PDF_set_text_pos(p,_arg1,_arg2); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_show(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + char *_arg1; + int len = 0; + char *res; + + if (objc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_show p text ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_show. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((_arg1 = GetStringUnicodePDFChars(p, interp, objv[2], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve text argument in PDF_show", TCL_STATIC); + return TCL_ERROR; + } + + try { PDF_show2(p, _arg1, len); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_show_boxed(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + int volatile _result = -1; + PDF *p; + char *res; + int len1 = 0; + int len = 0; + char *_arg1; + double _arg2; + double _arg3; + double _arg4; + double _arg5; + char *_arg6; + char *_arg7; + + if (objc != 9) { + Tcl_SetResult(interp, "Wrong # args. PDF_show_boxed p text left top width height hmode feature ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, + "Type error in argument 1 of PDF_show_boxed. Expected _PDF_p, received ", + TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((_arg1 = GetStringUnicodePDFChars(p, interp, objv[2], &len1)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve text argument in PDF_show_boxed", TCL_STATIC); + return TCL_ERROR; + } + + if (Tcl_GetDoubleFromObj(interp, objv[3], &_arg2) != TCL_OK) { + Tcl_SetResult(interp, + "Couldn't retrieve x argument in PDF_show_boxed", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetDoubleFromObj(interp, objv[4], &_arg3) != TCL_OK) { + Tcl_SetResult(interp, + "Couldn't retrieve y argument in PDF_show_boxed", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetDoubleFromObj(interp, objv[5], &_arg4) != TCL_OK) { + Tcl_SetResult(interp, + "Couldn't retrieve width argument in PDF_show_boxed", TCL_STATIC); + return TCL_ERROR; + } + if (Tcl_GetDoubleFromObj(interp, objv[6], &_arg5) != TCL_OK) { + Tcl_SetResult(interp, + "Couldn't retrieve height argument in PDF_show_boxed", TCL_STATIC); + return TCL_ERROR; + } + + if ((_arg6 = Tcl_GetStringFromObj(objv[7], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve mode argument in PDF_show_boxed", TCL_STATIC); + return TCL_ERROR; + } + + if ((_arg7 = Tcl_GetStringFromObj(objv[8], &len)) == NULL) { + Tcl_SetResult(interp, + "Couldn't retrieve mode argument in PDF_show_boxed", TCL_STATIC); + return TCL_ERROR; + } + + try { + _result = (int)PDF_show_boxed2(p, _arg1, len1, (float)_arg2, (float)_arg3, (float)_arg4, (float)_arg5,_arg6,_arg7); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + +static int +_wrap_PDF_show_xy(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + PDF *p; + char *_arg1; + double _arg2; + double _arg3; + int len = 0, error; + char *res; + + if (objc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_show_xy p text x y ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p, "_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_show_xy. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((_arg1 = GetStringUnicodePDFChars(p, interp, objv[2], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve text argument in PDF_show_xy", TCL_STATIC); + return TCL_ERROR; + } + + if ((error = Tcl_GetDoubleFromObj(interp, objv[3], &_arg2)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve x argument in PDF_show_xy", TCL_STATIC); + return TCL_ERROR; + } + + if ((error = Tcl_GetDoubleFromObj(interp, objv[4], &_arg3)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve y argument in PDF_show_xy", TCL_STATIC); + return TCL_ERROR; + } + + try { + PDF_show_xy2(p, _arg1, len, (float) _arg2, (float) _arg3); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_stringwidth(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + float volatile _result = -1; + PDF *p; + char *_arg1; + int _arg2; + double _arg3; + int len = 0, error; + char *res; + Tcl_Obj *resultPtr; + + if (objc != 5) { + Tcl_SetResult(interp, "Wrong # args. PDF_stringwidth p text font fontsize ",TCL_STATIC); + return TCL_ERROR; + } + + if ((res = Tcl_GetStringFromObj(objv[1], NULL)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve PDF pointer in PDF_stringwidth", TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(res, (void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_stringwidth. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, res, (char *) NULL); + return TCL_ERROR; + } + + if ((_arg1 = GetStringUnicodePDFChars(p, interp, objv[2], &len)) == NULL) { + Tcl_SetResult(interp, "Couldn't retrieve text argument in PDF_stringwidth", TCL_STATIC); + return TCL_ERROR; + } + + if ((error = Tcl_GetIntFromObj(interp, objv[3], &_arg2)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve font argument in PDF_stringwidth", TCL_STATIC); + return TCL_ERROR; + } + + if ((error = Tcl_GetDoubleFromObj(interp, objv[4], &_arg3)) != TCL_OK) { + Tcl_SetResult(interp, "Couldn't retrieve fontsize argument in PDF_stringwidth", TCL_STATIC); + return TCL_ERROR; + } + + try { + _result = (float) PDF_stringwidth2(p, _arg1, len, _arg2, (float) _arg3); + } catch; + + resultPtr = Tcl_GetObjResult(interp); + Tcl_SetDoubleObj(resultPtr, (double) _result); + + return TCL_OK; +} + +/* p_type3.c */ + +static int +_wrap_PDF_begin_font(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + char *fontname; + float a, b, c, d, e, f; + char *optlist; + + if (argc != 10) { + Tcl_SetResult(interp, "Wrong # args. PDF_begin_font p fontname a b c d e f optlist",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_begin_font. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + fontname = argv[2]; + a = (float) atof(argv[3]); + b = (float) atof(argv[4]); + c = (float) atof(argv[5]); + d = (float) atof(argv[6]); + e = (float) atof(argv[7]); + f = (float) atof(argv[8]); + optlist = argv[9]; + + try { PDF_begin_font(p, fontname, 0, a, b, c, d, e, f, optlist); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_begin_glyph(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + char *name; + float wx, llx, lly, urx, ury; + + if (argc != 8) { + Tcl_SetResult(interp, "Wrong # args. PDF_begin_glyph p glyphname flag value ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_begin_glyph. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + name = argv[2]; + wx = (float) atof(argv[3]); + llx = (float) atof(argv[4]); + lly = (float) atof(argv[5]); + urx = (float) atof(argv[6]); + ury = (float) atof(argv[7]); + + try { PDF_begin_glyph(p, name, wx, llx, lly, urx, ury); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_end_font(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_end_font p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_end_font. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_end_font(p); + } catch; + + return TCL_OK; +} + +static int +_wrap_PDF_end_glyph(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + + if (argc != 2) { + Tcl_SetResult(interp, "Wrong # args. PDF_end_glyph p ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_end_glyph. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + + try { PDF_end_glyph(p); + } catch; + + return TCL_OK; +} + +/* p_xgstate.c */ + +static int +_wrap_PDF_create_gstate(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + + int volatile _result = -1; + PDF *p; + char *optlist; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_create_gstate p optlist",TCL_STATIC); + return TCL_ERROR; + } + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_create_gstate. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + optlist = argv[2]; + + try { _result = (int)PDF_create_gstate(p, optlist); + } catch; + + sprintf(interp->result,"%ld", (long) _result); + return TCL_OK; +} + + +static int +_wrap_PDF_set_gstate(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { + PDF *p; + int handle; + + if (argc != 3) { + Tcl_SetResult(interp, "Wrong # args. PDF_set_gstate p gstate ",TCL_STATIC); + return TCL_ERROR; + } + + if (SWIG_GetPtr(argv[1],(void **) &p,"_PDF_p")) { + Tcl_SetResult(interp, "Type error in argument 1 of PDF_set_gstate. Expected _PDF_p, received ", TCL_STATIC); + Tcl_AppendResult(interp, argv[1], (char *) NULL); + return TCL_ERROR; + } + handle = (int) atol(argv[2]); + + try { PDF_set_gstate(p, handle); + } catch; + + return TCL_OK; +} + + + +/* This is required to make our extension work with safe Tcl interpreters */ +SWIGEXPORT(int,Pdflib_SafeInit)(Tcl_Interp *interp) +{ + return TCL_OK; +} + +/* This is required to satisfy pkg_mkIndex */ +SWIGEXPORT(int,Pdflib_tcl_SafeInit)(Tcl_Interp *interp) +{ + return Pdflib_SafeInit(interp); +} + +/* This is required to satisfy pkg_mkIndex */ +SWIGEXPORT(int,Pdflib_tcl_Init)(Tcl_Interp *interp) +{ + return Pdflib_Init(interp); +} + +/* This is required to satisfy pkg_mkIndex */ +SWIGEXPORT(int,Pdf_tcl_Init)(Tcl_Interp *interp) +{ + return Pdflib_Init(interp); +} + +/* This is required to satisfy pkg_mkIndex */ +SWIGEXPORT(int,Pdf_tcl_SafeInit)(Tcl_Interp *interp) +{ + return Pdflib_SafeInit(interp); +} + +SWIGEXPORT(int,Pdflib_Init)(Tcl_Interp *interp) +{ + if (interp == 0) + return TCL_ERROR; + +#ifdef USE_TCL_STUBS + if (Tcl_InitStubs(interp, "8.2", 0) == NULL) { + return TCL_ERROR; + } +#else + if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 1) == NULL) { + return TCL_ERROR; + } +#endif + + /* Boot the PDFlib core */ + PDF_boot(); + + /* Tell Tcl which package we are going to define */ + Tcl_PkgProvide(interp, "pdflib", PDFLIB_VERSIONSTRING); + + Tcl_CreateCommand(interp, "PDF_add_launchlink", (Tcl_CmdProc*) _wrap_PDF_add_launchlink, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_add_locallink", (Tcl_CmdProc*) _wrap_PDF_add_locallink, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_add_note", (Tcl_ObjCmdProc*) _wrap_PDF_add_note, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_add_pdflink", (Tcl_CmdProc*) _wrap_PDF_add_pdflink, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_add_weblink", (Tcl_CmdProc*) _wrap_PDF_add_weblink, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_attach_file", (Tcl_ObjCmdProc*) _wrap_PDF_attach_file, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_set_border_color", (Tcl_CmdProc*) _wrap_PDF_set_border_color, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_set_border_dash", (Tcl_CmdProc*) _wrap_PDF_set_border_dash, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_set_border_style", (Tcl_CmdProc*) _wrap_PDF_set_border_style, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_begin_page", (Tcl_CmdProc*) _wrap_PDF_begin_page, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_close", (Tcl_CmdProc*) _wrap_PDF_close, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_delete", (Tcl_CmdProc*) _wrap_PDF_delete, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_end_page", (Tcl_CmdProc*) _wrap_PDF_end_page, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_get_buffer", (Tcl_ObjCmdProc*) _wrap_PDF_get_buffer, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_new", (Tcl_CmdProc*) _wrap_PDF_new, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_open_file", (Tcl_CmdProc*) _wrap_PDF_open_file, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateObjCommand(interp, "PDF_fill_imageblock", (Tcl_ObjCmdProc*) _wrap_PDF_fill_imageblock, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_fill_pdfblock", (Tcl_ObjCmdProc*) _wrap_PDF_fill_pdfblock, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_fill_textblock", (Tcl_ObjCmdProc*) _wrap_PDF_fill_textblock, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_makespotcolor", (Tcl_CmdProc*) _wrap_PDF_makespotcolor, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setcolor", (Tcl_CmdProc*) _wrap_PDF_setcolor, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setgray", (Tcl_CmdProc*) _wrap_PDF_setgray, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setgray_fill", (Tcl_CmdProc*) _wrap_PDF_setgray_fill, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setgray_stroke", (Tcl_CmdProc*) _wrap_PDF_setgray_stroke, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setrgbcolor", (Tcl_CmdProc*) _wrap_PDF_setrgbcolor, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setrgbcolor_fill", (Tcl_CmdProc*) _wrap_PDF_setrgbcolor_fill, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setrgbcolor_stroke", (Tcl_CmdProc*) _wrap_PDF_setrgbcolor_stroke, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_arc", (Tcl_CmdProc*) _wrap_PDF_arc, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_arcn", (Tcl_CmdProc*) _wrap_PDF_arcn, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_circle", (Tcl_CmdProc*) _wrap_PDF_circle, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_clip", (Tcl_CmdProc*) _wrap_PDF_clip, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_closepath", (Tcl_CmdProc*) _wrap_PDF_closepath, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_closepath_fill_stroke", (Tcl_CmdProc*) _wrap_PDF_closepath_fill_stroke, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_closepath_stroke", (Tcl_CmdProc*) _wrap_PDF_closepath_stroke, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_curveto", (Tcl_CmdProc*) _wrap_PDF_curveto, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_endpath", (Tcl_CmdProc*) _wrap_PDF_endpath, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_fill", (Tcl_CmdProc*) _wrap_PDF_fill, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_fill_stroke", (Tcl_CmdProc*) _wrap_PDF_fill_stroke, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_lineto", (Tcl_CmdProc*) _wrap_PDF_lineto, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_moveto", (Tcl_CmdProc*) _wrap_PDF_moveto, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_rect", (Tcl_CmdProc*) _wrap_PDF_rect, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_stroke", (Tcl_CmdProc*) _wrap_PDF_stroke, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_encoding_set_char", (Tcl_CmdProc*) _wrap_PDF_encoding_set_char, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_findfont", (Tcl_CmdProc*) _wrap_PDF_findfont, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_load_font", (Tcl_ObjCmdProc*) _wrap_PDF_load_font, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setfont", (Tcl_CmdProc*) _wrap_PDF_setfont, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_concat", (Tcl_CmdProc*) _wrap_PDF_concat, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_initgraphics", (Tcl_CmdProc*) _wrap_PDF_initgraphics, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_restore", (Tcl_CmdProc*) _wrap_PDF_restore, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_rotate", (Tcl_CmdProc*) _wrap_PDF_rotate, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_save", (Tcl_CmdProc*) _wrap_PDF_save, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_scale", (Tcl_CmdProc*) _wrap_PDF_scale, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setdash", (Tcl_CmdProc*) _wrap_PDF_setdash, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setdashpattern", (Tcl_CmdProc*) _wrap_PDF_setdashpattern, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setflat", (Tcl_CmdProc*) _wrap_PDF_setflat, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setlinecap", (Tcl_CmdProc*) _wrap_PDF_setlinecap, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setlinejoin", (Tcl_CmdProc*) _wrap_PDF_setlinejoin, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setlinewidth", (Tcl_CmdProc*) _wrap_PDF_setlinewidth, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setmatrix", (Tcl_CmdProc*) _wrap_PDF_setmatrix, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_setmiterlimit", (Tcl_CmdProc*) _wrap_PDF_setmiterlimit, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_setpolydash", (Tcl_ObjCmdProc*) _wrap_PDF_setpolydash, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_skew", (Tcl_CmdProc*) _wrap_PDF_skew, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_translate", (Tcl_CmdProc*) _wrap_PDF_translate, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateObjCommand(interp, "PDF_add_bookmark", (Tcl_ObjCmdProc*) _wrap_PDF_add_bookmark, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_add_nameddest", (Tcl_ObjCmdProc*) _wrap_PDF_add_nameddest, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_set_info", (Tcl_ObjCmdProc*) _wrap_PDF_set_info, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateObjCommand(interp, "PDF_load_iccprofile", (Tcl_ObjCmdProc*) _wrap_PDF_load_iccprofile, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_add_thumbnail", (Tcl_CmdProc*) _wrap_PDF_add_thumbnail, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_close_image", (Tcl_CmdProc*) _wrap_PDF_close_image, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_fit_image", (Tcl_CmdProc*) _wrap_PDF_fit_image, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_load_image", (Tcl_ObjCmdProc*) _wrap_PDF_load_image, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_open_CCITT", (Tcl_CmdProc*) _wrap_PDF_open_CCITT, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_open_image", (Tcl_ObjCmdProc*) _wrap_PDF_open_image, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_open_image_file", (Tcl_CmdProc*) _wrap_PDF_open_image_file, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_place_image", (Tcl_CmdProc*) _wrap_PDF_place_image, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_get_parameter", (Tcl_CmdProc*) _wrap_PDF_get_parameter, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_get_value", (Tcl_CmdProc*) _wrap_PDF_get_value, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_set_parameter", (Tcl_CmdProc*) _wrap_PDF_set_parameter, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_set_value", (Tcl_CmdProc*) _wrap_PDF_set_value, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_begin_pattern", (Tcl_CmdProc*) _wrap_PDF_begin_pattern, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_end_pattern", (Tcl_CmdProc*) _wrap_PDF_end_pattern, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_close_pdi", (Tcl_CmdProc*) _wrap_PDF_close_pdi, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_close_pdi_page", (Tcl_CmdProc*) _wrap_PDF_close_pdi_page, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_fit_pdi_page", (Tcl_CmdProc*) _wrap_PDF_fit_pdi_page, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_get_pdi_parameter", (Tcl_CmdProc*) _wrap_PDF_get_pdi_parameter, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_get_pdi_value", (Tcl_CmdProc*) _wrap_PDF_get_pdi_value, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_open_pdi", (Tcl_CmdProc*) _wrap_PDF_open_pdi, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_open_pdi_page", (Tcl_CmdProc*) _wrap_PDF_open_pdi_page, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_place_pdi_page", (Tcl_CmdProc*) _wrap_PDF_place_pdi_page, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_process_pdi", (Tcl_CmdProc*) _wrap_PDF_process_pdi, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateObjCommand(interp, "PDF_create_pvf", (Tcl_ObjCmdProc*) _wrap_PDF_create_pvf, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_delete_pvf", (Tcl_CmdProc*) _wrap_PDF_delete_pvf, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_shading", (Tcl_CmdProc*) _wrap_PDF_shading, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_shading_pattern", (Tcl_CmdProc*) _wrap_PDF_shading_pattern, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_shfill", (Tcl_CmdProc*) _wrap_PDF_shfill, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_begin_template", (Tcl_CmdProc*) _wrap_PDF_begin_template, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_end_template", (Tcl_CmdProc*) _wrap_PDF_end_template, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateObjCommand(interp, "PDF_continue_text", (Tcl_ObjCmdProc*) _wrap_PDF_continue_text, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_fit_textline", (Tcl_ObjCmdProc*) _wrap_PDF_fit_textline, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_set_text_pos", (Tcl_CmdProc*) _wrap_PDF_set_text_pos, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_show", (Tcl_ObjCmdProc*) _wrap_PDF_show, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_show_boxed", (Tcl_ObjCmdProc*) _wrap_PDF_show_boxed, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_show_xy", (Tcl_ObjCmdProc*) _wrap_PDF_show_xy, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateObjCommand(interp, "PDF_stringwidth", (Tcl_ObjCmdProc*) _wrap_PDF_stringwidth, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_begin_font", (Tcl_CmdProc*) _wrap_PDF_begin_font, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_begin_glyph", (Tcl_CmdProc*) _wrap_PDF_begin_glyph, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_end_font", (Tcl_CmdProc*) _wrap_PDF_end_font, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_end_glyph", (Tcl_CmdProc*) _wrap_PDF_end_glyph, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_create_gstate", (Tcl_CmdProc*) _wrap_PDF_create_gstate, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_set_gstate", (Tcl_CmdProc*) _wrap_PDF_set_gstate, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + + Tcl_CreateCommand(interp, "PDF_get_errmsg", (Tcl_CmdProc*) _wrap_PDF_get_errmsg, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_get_errnum", (Tcl_CmdProc*) _wrap_PDF_get_errnum, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "PDF_get_apiname", (Tcl_CmdProc*) _wrap_PDF_get_apiname, (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL); + +/* + * These are the pointer type-equivalency mappings. + * (Used by the SWIG pointer type-checker). + */ + SWIG_RegisterMapping("_signed_long","_long",0); + SWIG_RegisterMapping("_struct_PDF_s","_PDF",0); + SWIG_RegisterMapping("_long","_unsigned_long",0); + SWIG_RegisterMapping("_long","_signed_long",0); + SWIG_RegisterMapping("_PDF","_struct_PDF_s",0); + SWIG_RegisterMapping("_unsigned_long","_long",0); + SWIG_RegisterMapping("_signed_int","_int",0); + SWIG_RegisterMapping("_unsigned_short","_short",0); + SWIG_RegisterMapping("_signed_short","_short",0); + SWIG_RegisterMapping("_unsigned_int","_int",0); + SWIG_RegisterMapping("_short","_unsigned_short",0); + SWIG_RegisterMapping("_short","_signed_short",0); + SWIG_RegisterMapping("_int","_unsigned_int",0); + SWIG_RegisterMapping("_int","_signed_int",0); + return TCL_OK; +} diff --git a/src/libs/pdflib/bind/pdflib/tcl/pkgIndex.tcl b/src/libs/pdflib/bind/pdflib/tcl/pkgIndex.tcl new file mode 100644 index 0000000000..48ce0184e2 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/pkgIndex.tcl @@ -0,0 +1,11 @@ +# Tcl package index file, version 1.1 +# This file is generated by the "pkg_mkIndex" command +# and sourced either when an application starts up or +# by a "package unknown" script. It invokes the +# "package ifneeded" command to set up package-related +# information so that packages will be loaded automatically +# in response to "package require" commands. When this +# script is sourced, the variable $dir must contain the +# full path name of this file's directory. + +package ifneeded pdflib 5.0 [list load [file join $dir pdflib_tcl[info sharedlibextension]]] diff --git a/src/libs/pdflib/bind/pdflib/tcl/quickreference.tcl b/src/libs/pdflib/bind/pdflib/tcl/quickreference.tcl new file mode 100644 index 0000000000..5a8fff0e87 --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/quickreference.tcl @@ -0,0 +1,89 @@ +#!/bin/sh +# $Id: quickreference.tcl,v 1.1 2004/10/06 17:46:44 laplace Exp $ +# +# PDFlib/PDI client: mini imposition demo +# + +# Hide the exec to Tcl but not to the shell by appending a backslash\ +exec tclsh "$0" ${1+"$@"} + +# The lappend line is unnecessary if PDFlib has been installed +# in the Tcl package directory +set auto_path [linsert $auto_path 0 .libs .] + +package require pdflib 5.0 + +set maxrow 2 +set maxcol 2 +set startpage 1 +set endpage 4 +set width 500.0 +set height 770.0 +set infile "reference.pdf" +# This is where font/image/PDF input files live. Adjust as necessary. +set searchpath "../data" + +set p [PDF_new] + +if {[PDF_open_file $p "quickreference.pdf"] == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +PDF_set_parameter $p "SearchPath" $searchpath + +PDF_set_info $p "Creator" "quickreference.tcl" +PDF_set_info $p "Author" "Thomas Merz" +PDF_set_info $p "Title" "Mini Imposition Demo (Tcl)" + +set manual [PDF_open_pdi $p $infile "" 0] +if {$manual == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit +} + +set row 0 +set col 0 + +PDF_set_parameter $p "topdown" "true" + +for {set pageno $startpage} {$pageno <= $endpage} \ + {set pageno [expr $pageno + 1]} { + if {$row == 0 && $col == 0} { + PDF_begin_page $p $width $height + set font [PDF_load_font $p "Helvetica-Bold" "winansi" ""] + PDF_setfont $p $font 18 + PDF_set_text_pos $p 24 [expr 24] + PDF_show $p "PDFlib Quick Reference" + } + + set page [PDF_open_pdi_page $p $manual $pageno ""] + + if {$page == -1} { + puts stderr "Error: [PDF_get_errmsg $p]" + exit + } + + set scale [expr {1.0/$maxrow}] + PDF_fit_pdi_page $p $page [expr $width/$maxcol*$col] \ + [expr ($row + 1) * $height/$maxrow] "scale $scale" + PDF_close_pdi_page $p $page + + set col [expr $col + 1] + if {$col == $maxcol} { + set col 0 + set row [expr $row + 1] + } + if {$row == $maxrow} { + set row 0 + PDF_end_page $p + } +} + +# finish the last partial page +if {$row != 0 || $col != 0} { + PDF_end_page $p +} +PDF_close $p +PDF_close_pdi $p $manual +PDF_delete $p diff --git a/src/libs/pdflib/bind/pdflib/tcl/readme.txt b/src/libs/pdflib/bind/pdflib/tcl/readme.txt new file mode 100644 index 0000000000..bc6c7f0c7a --- /dev/null +++ b/src/libs/pdflib/bind/pdflib/tcl/readme.txt @@ -0,0 +1,53 @@ +Notes on the PDFlib Tcl binding +=============================== + +Unix +==== + +- You may have to change the name of the tclsh binary in the + example scripts if you want to run them directly. Alternatively, + you may want to create a symbolic link pointing to the installed + version of tclsh. + + +Mac OS X +======== + +- The default build procedure for the PDFlib Tcl wrapper does not + work for Tcl 8.3 and above on Mac OS X. + + These Tcl versions need a "Mach-O dynamically linked shared library ppc", + whereas our build process creates a "Mach-O bundle ppc" + + You can build a PDFlib extension for Tcl by applying the following changes: + + - remove the "-module" option for the linking step (you find this in + ~/config/mkbind.inc) + + Note: Undo this change to build other PDFlib language bindings. + + - now libtool only accepts libraries starting with "lib", therefore: + -> apply the following change in bind/pdflib/tcl/Makefile: + LIBNAME = pdflib_tcl$(LA) + to + LIBNAME = libpdf_tcl$(LA) + + - change in pkgIndex.tcl: + pdflib_tcl -> libpdf_tcl + +Alternatively, you can request a precompiled binary for Tcl on OS X from +bindings@pdflib.com. Note that this service is only available for users +with a commercial PDFlib license, and not PDFlib Lite. + + +How to build the PDFlib wrapper for Tcl 8.0 or 8.1 +================================================== + +The precompiled versions of the PDFlib wrapper for Tcl require Tcl 8.2 or +above. The wrapper code can also be compiled with Tcl 8.0 or 8.1, although +is is not supported by the configure and Makefile process. +Do the following for building PDFlib with Tcl 8.0 or 8.1: + +- #undef USE_TCL_STUBS in pdflib_tcl.c + +- Add -ltcl to the linker command, and an appropriate -L option. diff --git a/src/libs/pdflib/config/aclocal.m4 b/src/libs/pdflib/config/aclocal.m4 new file mode 100644 index 0000000000..49a3273d57 --- /dev/null +++ b/src/libs/pdflib/config/aclocal.m4 @@ -0,0 +1,3583 @@ +# libtool.m4 - Configure libtool for the host system. -*-Shell-script-*- +## Copyright 1996, 1997, 1998, 1999, 2000, 2001 +## Free Software Foundation, Inc. +## Originally by Gordon Matzigkeit , 1996 +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## +## As a special exception to the GNU General Public License, if you +## distribute this file as part of a program that contains a +## configuration script generated by Autoconf, you may include it under +## the same distribution terms that you use for the rest of that program. + +# serial 46 AC_PROG_LIBTOOL + +AC_DEFUN([AC_PROG_LIBTOOL], +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +]) + +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl + +_LT_AC_PROG_ECHO_BACKSLASH +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_SAVE + AC_LANG_C + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_RESTORE]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + + # recent cygwin and mingw systems supply a stub DllMain which the user + # can override, but on older systems we have to supply one + AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain, + [AC_TRY_LINK([], + [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*); + DllMain (0, 0, 0);], + [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])]) + + case $host/$CC in + *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*) + # old mingw systems require "-dll" to link a DLL, while more recent ones + # require "-mdll" + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mdll" + AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch, + [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])]) + CFLAGS="$SAVE_CFLAGS" ;; + *-*-cygwin* | *-*-pw32*) + # cygwin systems need to pass --dll to the linker, and not link + # crt.o which will require a WinMain@16 definition. + lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;; + esac + ;; + ]) +esac + +_LT_AC_LTCONFIG_HACK + +]) + +# AC_LIBTOOL_HEADER_ASSERT +# ------------------------ +AC_DEFUN([AC_LIBTOOL_HEADER_ASSERT], +[AC_CACHE_CHECK([whether $CC supports assert without backlinking], + [lt_cv_func_assert_works], + [case $host in + *-*-solaris*) + if test "$GCC" = yes && test "$with_gnu_ld" != yes; then + case `$CC --version 2>/dev/null` in + [[12]].*) lt_cv_func_assert_works=no ;; + *) lt_cv_func_assert_works=yes ;; + esac + fi + ;; + esac]) + +if test "x$lt_cv_func_assert_works" = xyes; then + AC_CHECK_HEADERS(assert.h) +fi +])# AC_LIBTOOL_HEADER_ASSERT + +# _LT_AC_CHECK_DLFCN +# -------------------- +AC_DEFUN([_LT_AC_CHECK_DLFCN], +[AC_CHECK_HEADERS(dlfcn.h) +])# _LT_AC_CHECK_DLFCN + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_NM]) +AC_REQUIRE([AC_OBJEXT]) +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [dnl + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) # Its linker distinguishes data from code symbols + lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +irix*) + symcode='[[BCDEGRST]]' + ;; +solaris* | sysv5*) + symcode='[[BDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $host_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + symcode='[[ABCDGISTW]]' +fi + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. +lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + rm -f conftest* + cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[[]] = +{ +EOF + sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$no_builtin_flag" + if AC_TRY_EVAL(ac_link) && test -s conftest; then + pipe_works=yes + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AC_FD_CC + fi + else + echo "cannot find nm_test_var in $nlist" >&AC_FD_CC + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC + fi + else + echo "$progname: failed program was:" >&AC_FD_CC + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" +if test -z "$lt_cv_sys_global_symbol_pipe"; then + global_symbol_to_cdecl= + global_symbol_to_c_name_address= +else + global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" + global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" +fi +if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; +then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi +]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + +# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR +# --------------------------------- +AC_DEFUN([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR], +[# Find the correct PATH separator. Usually this is `:', but +# DJGPP uses `;' like DOS. +if test "X${PATH_SEPARATOR+set}" != Xset; then + UNAME=${UNAME-`uname 2>/dev/null`} + case X$UNAME in + *-DOS) lt_cv_sys_path_separator=';' ;; + *) lt_cv_sys_path_separator=':' ;; + esac + PATH_SEPARATOR=$lt_cv_sys_path_separator +fi +])# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +AC_DIVERT_POP +])# _LT_AC_PROG_ECHO_BACKSLASH + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ------------------------------------------------------------------ +AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], +[if test "$cross_compiling" = yes; then : + [$4] +else + AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +}] +EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_unknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_AC_TRY_DLOPEN_SELF + +# AC_LIBTOOL_DLOPEN_SELF +# ------------------- +AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], +[if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + cygwin* | mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +])# AC_LIBTOOL_DLOPEN_SELF + +AC_DEFUN([_LT_AC_LTCONFIG_HACK], +[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([[\\"\\`$\\\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([[\\"\\`\\\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" +need_locks="$enable_libtool_lock" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +if test x"$host" != x"$build"; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi + +# Transform linux* to *-*-linux-gnu*, to support old configure scripts. +case $host_os in +linux-gnu*) ;; +linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="[$]2" + +## FIXME: this should be a separate macro +## +AC_MSG_CHECKING([for objdir]) +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +AC_MSG_RESULT($objdir) +## +## END FIXME + + +## FIXME: this should be a separate macro +## +AC_ARG_WITH(pic, +[ --with-pic try to use only PIC/non-PIC objects [default=use both]], +pic_mode="$withval", pic_mode=default) +test -z "$pic_mode" && pic_mode=default + +# We assume here that the value for lt_cv_prog_cc_pic will not be cached +# in isolation, and that seeing it set (from the cache) indicates that +# the associated values are set (in the cache) correctly too. +AC_MSG_CHECKING([for $compiler option to produce PIC]) +AC_CACHE_VAL(lt_cv_prog_cc_pic, +[ lt_cv_prog_cc_pic= + lt_cv_prog_cc_shlib= + lt_cv_prog_cc_wl= + lt_cv_prog_cc_static= + lt_cv_prog_cc_no_builtin= + lt_cv_prog_cc_can_build_shared=$can_build_shared + + if test "$GCC" = yes; then + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-static' + + case $host_os in + aix*) + # Below there is a dirty hack to force normal static linking with -ldl + # The problem is because libdl dynamically linked with both libc and + # libC (AIX C++ library), which obviously doesn't included in libraries + # list by gcc. This cause undefined symbols with -static flags. + # This hack allows C programs to be linked with "-static -ldl", but + # not sure about C++ programs. + lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | irix5* | irix6* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_cv_prog_cc_pic='-fno-common' + ;; + cygwin* | mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_cv_prog_cc_pic='-DDLL_EXPORT' + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_cv_prog_cc_pic=-Kconform_pic + fi + ;; + *) + lt_cv_prog_cc_pic='-fPIC' + ;; + esac + else + # PORTME Check for PIC flags for the system compiler. + case $host_os in + aix3* | aix4* | aix5*) + lt_cv_prog_cc_wl='-Wl,' + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_cv_prog_cc_static='-Bstatic' + else + lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + # PDFlib added + i370*) + lt_cv_prog_cc_wl='-Wl,dll' + lt_cv_prog_cc_pic='-W c,expo,dll -Wc,"GONUM"' + ;; + hpux9* | hpux10* | hpux11*) + # Is there a better lt_cv_prog_cc_static that works with the bundled CC? + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" + lt_cv_prog_cc_pic='+Z' + ;; + + irix5* | irix6*) + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + cygwin* | mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_cv_prog_cc_pic='-DDLL_EXPORT' + ;; + + newsos6) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + ;; + + osf3* | osf4* | osf5*) + # All OSF/1 code is PIC. + lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_static='-non_shared' + ;; + + sco3.2v5*) + lt_cv_prog_cc_pic='-Kpic' + lt_cv_prog_cc_static='-dn' + lt_cv_prog_cc_shlib='-belf' + ;; + + solaris*) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + lt_cv_prog_cc_wl='-Wl,' + ;; + + sunos4*) + lt_cv_prog_cc_pic='-PIC' + lt_cv_prog_cc_static='-Bstatic' + lt_cv_prog_cc_wl='-Qoption ld ' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_cv_prog_cc_pic='-KPIC' + lt_cv_prog_cc_static='-Bstatic' + if test "x$host_vendor" = xsni; then + lt_cv_prog_cc_wl='-LD' + else + lt_cv_prog_cc_wl='-Wl,' + fi + ;; + + uts4*) + lt_cv_prog_cc_pic='-pic' + lt_cv_prog_cc_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_cv_prog_cc_pic='-Kconform_pic' + lt_cv_prog_cc_static='-Bstatic' + fi + ;; + + *) + lt_cv_prog_cc_can_build_shared=no + ;; + esac + fi +]) +if test -z "$lt_cv_prog_cc_pic"; then + AC_MSG_RESULT([none]) +else + AC_MSG_RESULT([$lt_cv_prog_cc_pic]) + + # Check to make sure the pic_flag actually works. + AC_MSG_CHECKING([if $compiler PIC flag $lt_cv_prog_cc_pic works]) + AC_CACHE_VAL(lt_cv_prog_cc_pic_works, [dnl + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" + AC_TRY_COMPILE([], [], [dnl + case $host_os in + hpux9* | hpux10* | hpux11*) + # On HP-UX, both CC and GCC only warn that PIC is supported... then + # they create non-PIC objects. So, if there were any warnings, we + # assume that PIC is not supported. + if test -s conftest.err; then + lt_cv_prog_cc_pic_works=no + else + lt_cv_prog_cc_pic_works=yes + fi + ;; + *) + lt_cv_prog_cc_pic_works=yes + ;; + esac + ], [dnl + lt_cv_prog_cc_pic_works=no + ]) + CFLAGS="$save_CFLAGS" + ]) + + if test "X$lt_cv_prog_cc_pic_works" = Xno; then + lt_cv_prog_cc_pic= + lt_cv_prog_cc_can_build_shared=no + else + lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" + fi + + AC_MSG_RESULT([$lt_cv_prog_cc_pic_works]) +fi +## +## END FIXME + +# Check for any special shared library compilation flags. +if test -n "$lt_cv_prog_cc_shlib"; then + AC_MSG_WARN([\`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries]) + if echo "$old_CC $old_CFLAGS " | egrep -e "[[ ]]$lt_cv_prog_cc_shlib[[ ]]" >/dev/null; then : + else + AC_MSG_WARN([add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure]) + lt_cv_prog_cc_can_build_shared=no + fi +fi + +## FIXME: this should be a separate macro +## +AC_MSG_CHECKING([if $compiler static flag $lt_cv_prog_cc_static works]) +AC_CACHE_VAL([lt_cv_prog_cc_static_works], [dnl + lt_cv_prog_cc_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" + AC_TRY_LINK([], [], [lt_cv_prog_cc_static_works=yes]) + LDFLAGS="$save_LDFLAGS" +]) + +# Belt *and* braces to stop my trousers falling down: +test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= +AC_MSG_RESULT([$lt_cv_prog_cc_static_works]) + +pic_flag="$lt_cv_prog_cc_pic" +special_shlib_compile_flags="$lt_cv_prog_cc_shlib" +wl="$lt_cv_prog_cc_wl" +link_static_flag="$lt_cv_prog_cc_static" +no_builtin_flag="$lt_cv_prog_cc_no_builtin" +can_build_shared="$lt_cv_prog_cc_can_build_shared" +## +## END FIXME + + +## FIXME: this should be a separate macro +## +# Check to see if options -o and -c are simultaneously supported by compiler +AC_MSG_CHECKING([if $compiler supports -c -o file.$ac_objext]) +AC_CACHE_VAL([lt_cv_compiler_c_o], [ +$rm -r conftest 2>/dev/null +mkdir conftest +cd conftest +echo "int some_variable = 0;" > conftest.$ac_ext +mkdir out +# According to Tom Tromey, Ian Lance Taylor reported there are C compilers +# that will create temporary files in the current directory regardless of +# the output directory. Thus, making CWD read-only will cause this test +# to fail, enabling locking or at least warning the user not to do parallel +# builds. +# PDFlib GmbH: we don't do this it wows on AIX +#chmod -w . +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" +compiler_c_o=no +if { (eval echo configure:__oline__: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s out/conftest.err; then + lt_cv_compiler_c_o=no + else + lt_cv_compiler_c_o=yes + fi +else + # Append any errors to the config.log. + cat out/conftest.err 1>&AC_FD_CC + lt_cv_compiler_c_o=no +fi +CFLAGS="$save_CFLAGS" +chmod u+w . +$rm conftest* out/* +rmdir out +cd .. +rmdir conftest +$rm -r conftest 2>/dev/null +]) +compiler_c_o=$lt_cv_compiler_c_o +AC_MSG_RESULT([$compiler_c_o]) + +if test x"$compiler_c_o" = x"yes"; then + # Check to see if we can write to a .lo + AC_MSG_CHECKING([if $compiler supports -c -o file.lo]) + AC_CACHE_VAL([lt_cv_compiler_o_lo], [ + lt_cv_compiler_o_lo=no + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -c -o conftest.lo" + save_objext="$ac_objext" + ac_objext=lo + AC_TRY_COMPILE([], [int some_variable = 0;], [dnl + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + lt_cv_compiler_o_lo=no + else + lt_cv_compiler_o_lo=yes + fi + ]) + ac_objext="$save_objext" + CFLAGS="$save_CFLAGS" + ]) + compiler_o_lo=$lt_cv_compiler_o_lo + AC_MSG_RESULT([$compiler_o_lo]) +else + compiler_o_lo=no +fi +## +## END FIXME + +## FIXME: this should be a separate macro +## +# Check to see if we can do hard links to lock some files if needed +hard_links="nottested" +if test "$compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([\`$CC' does not support \`-c -o', so \`make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +## +## END FIXME + +## FIXME: this should be a separate macro +## +if test "$GCC" = yes; then + # Check to see if options -fno-rtti -fno-exceptions are supported by compiler + AC_MSG_CHECKING([if $compiler supports -fno-rtti -fno-exceptions]) + echo "int some_variable = 0;" > conftest.$ac_ext + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" + compiler_rtti_exceptions=no + AC_TRY_COMPILE([], [int some_variable = 0;], [dnl + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + compiler_rtti_exceptions=no + else + compiler_rtti_exceptions=yes + fi + ]) + CFLAGS="$save_CFLAGS" + AC_MSG_RESULT([$compiler_rtti_exceptions]) + + if test "$compiler_rtti_exceptions" = "yes"; then + no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' + else + no_builtin_flag=' -fno-builtin' + fi +fi +## +## END FIXME + +## FIXME: this should be a separate macro +## +# See if the linker supports building shared libraries. +AC_MSG_CHECKING([whether the linker ($LD) supports shared libraries]) + +allow_undefined_flag= +no_undefined_flag= +need_lib_prefix=unknown +need_version=unknown +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +archive_cmds= +archive_expsym_cmds= +old_archive_from_new_cmds= +old_archive_from_expsyms_cmds= +export_dynamic_flag_spec= +whole_archive_flag_spec= +thread_safe_flag_spec= +hardcode_into_libs=no +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_shlibpath_var=unsupported +runpath_var= +link_all_deplibs=unknown +always_export_symbols=no +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' +# include_expsyms should be a list of space-separated symbols to be *always* +# included in the symbol list +include_expsyms= +# exclude_expsyms can be an egrep regular expression of symbols to exclude +# it will be wrapped by ` (' and `)$', so one must not match beginning or +# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', +# as well as any symbol that contains `d'. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_" +# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out +# platforms (ab)use it in PIC code, but their linkers get confused if +# the symbol is explicitly referenced. Since portable code cannot +# rely on this symbol name, it's probably fine to never include it in +# preloaded symbol tables. +extract_expsyms_cmds= + +case $host_os in +cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; +openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX, the GNU linker is very broken + # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=yes + + extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ + sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ + test -f $output_objdir/impgen.exe || (cd $output_objdir && \ + if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ + else $CC -o impgen impgen.c ; fi)~ + $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' + + old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' + + # cygwin and mingw dlls have different entry points and sets of symbols + # to exclude. + # FIXME: what about values for MSVC? + dll_entry=__cygwin_dll_entry@12 + dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ + case $host_os in + mingw*) + # mingw values + dll_entry=_DllMainCRTStartup@12 + dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ + ;; + esac + + # mingw and cygwin differ, and it's simplest to just exclude the union + # of the two symbol sets. + dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 + + # recent cygwin and mingw systems supply a stub DllMain which the user + # can override, but on older systems we have to supply one (in ltdll.c) + if test "x$lt_cv_need_dllmain" = "xyes"; then + ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " + ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ + test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' + else + ltdll_obj= + ltdll_cmds= + fi + + # Extract the symbol export list from an `--export-all' def file, + # then regenerate the def file from the symbol export list, so that + # the compiled dll only exports the symbol export list. + # Be careful not to strip the DATA tag left be newer dlltools. + export_symbols_cmds="$ltdll_cmds"' + $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ + sed -e "1,/EXPORTS/d" -e "s/ @ [[0-9]]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' + + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is. + # If DATA tags from a recent dlltool are present, honour them! + archive_expsym_cmds='if test "x`head -1 $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname-def; + else + echo EXPORTS > $output_objdir/$soname-def; + _lt_hint=1; + cat $export_symbols | while read symbol; do + set dummy \$symbol; + case \[$]# in + 2) echo " \[$]2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; + *) echo " \[$]2 @ \$_lt_hint \[$]3 ; " >> $output_objdir/$soname-def;; + esac; + _lt_hint=`expr 1 + \$_lt_hint`; + done; + fi~ + '"$ltdll_cmds"' + $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ + $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ + $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + case $host_os in + cygwin* | mingw* | pw32*) + # dlltool doesn't understand --whole-archive et. al. + whole_archive_flag_spec= + ;; + *) + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + ;; + esac + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + hardcode_direct=yes + archive_cmds='' + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + esac + + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + shared_flag='${wl}-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall can do strange things, so it is better to + # generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='${wl}-berok' + # This is a bit strange, but is similar to how AIX traditionally builds + # it's shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + ;; + + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[[012]]) + allow_undefined_flag='-undefined suppress' + ;; + *) # Darwin 1.3 on + allow_undefined_flag='-flat_namespace -undefined suppress' + ;; + esac + # FIXME: Relying on posixy $() will cause problems for + # cross-compilation, but unfortunately the echo tests do not + # yet detect zsh echo's removal of \ escapes. + archive_cmds='$nonopt $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags $(test .$module = .yes || echo -install_name $rpath/$soname $verstring)' + # We need to add '_' to the symbols in $export_symbols first + #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' + hardcode_direct=yes + hardcode_shlibpath_var=no + whole_archive_flag_spec='-all_load $convenience' + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9* | hpux10* | hpux11*) + case $host_os in + hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; + *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; + esac + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_minus_L=yes # Not in the search PATH, but as the default + # location of the library. + export_dynamic_flag_spec='${wl}-E' + ;; + + irix5* | irix6*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + openbsd*) + hardcode_direct=yes + hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case "$host_os" in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + #Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + export_dynamic_flag_spec='${wl}-Bexport' + ;; + + solaris*) + # gcc --version < 3.0 without binutils cannot create self contained + # shared libraries reliably, requiring libgcc.a to resolve some of + # the object symbols generated in some cases. Libraries that use + # assert need libgcc.a to resolve __eprintf, for example. Linking + # a copy of libgcc.a into every shared library to guarantee resolving + # such symbols causes other problems: According to Tim Van Holder + # , C++ libraries end up with a separate + # (to the application) exception stack for one thing. + no_undefined_flag=' -z defs' + if test "$GCC" = yes; then + case `$CC --version 2>/dev/null` in + [[12]].*) + cat <&2 + +*** Warning: Releases of GCC earlier than version 3.0 cannot reliably +*** create self contained shared libraries on Solaris systems, without +*** introducing a dependency on libgcc.a. Therefore, libtool is disabling +*** -no-undefined support, which will at least allow you to build shared +*** libraries. However, you may find that when you link such libraries +*** into an application without using GCC, you have to manually add +*** \`gcc --print-libgcc-file-name\` to the link command. We urge you to +*** upgrade to a newer version of GCC. Another option is to rebuild your +*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. + +EOF + no_undefined_flag= + ;; + esac + fi + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + if test "x$host_vendor" = xsno; then + archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + else + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5uw7* | unixware7*) + no_undefined_flag='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac +fi +AC_MSG_RESULT([$ld_shlibs]) +test "$ld_shlibs" = no && can_build_shared=no +## +## END FIXME + +## FIXME: this should be a separate macro +## +# Check hardcoding attributes. +AC_MSG_CHECKING([how to hardcode library paths into programs]) +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$hardcode_shlibpath_var" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +AC_MSG_RESULT([$hardcode_action]) +## +## END FIXME + +## FIXME: this should be a separate macro +## +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi +## +## END FIXME + +reload_cmds='$LD$reload_flag -o $output$reload_objs' +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +## FIXME: this should be a separate macro +## +# PORTME Fill in your ld.so characteristics +AC_MSG_CHECKING([dynamic linker characteristics]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}.so$major' + ;; + +aix4* | aix5*) + version_type=linux + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can + # not hardcode correct soname into executable. Probably we can + # add versioning support to collect2, so additional links can + # be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}.so$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}.so' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + export_dynamic_flag_spec=-rdynamic + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + need_version=no + need_lib_prefix=no + case $GCC,$host_os in + yes,cygwin*) + library_names_spec='$libname.dll.a' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' + postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog .libs/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + ;; + yes,mingw*) + library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"` + ;; + yes,pw32*) + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' + ;; + *) + library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + # FIXME: Relying on posixy $() will cause problems for + # cross-compilation, but unfortunately the echo tests do not + # yet detect zsh echo's removal of \ escapes. + + #PDFlib changed: we need .dylib even with -module + #library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' + #soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' + library_names_spec='${libname}${release}${versuffix}.dylib ${libname}${release}${major}.dylib ${libname}.dylib' + soname_spec='${libname}${release}${major}.dylib' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + *) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + need_lib_prefix=no + need_version=no + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' + soname_spec='${libname}${release}.sl$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6*) + version_type=irix + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' + case $host_os in + irix5*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' + soname_spec='${libname}${release}.so$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case "$host_os" in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +os2*) + libname_spec='$name' + need_lib_prefix=no + library_names_spec='$libname.dll $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_version=no + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no +## +## END FIXME + +## FIXME: this should be a separate macro +## +# Report the final consequences. +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) +## +## END FIXME + +## FIXME: this should be a separate macro +## +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) +## +## END FIXME + +## FIXME: this should be a separate macro +## +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) +## +## END FIXME + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +AC_LIBTOOL_DLOPEN_SELF + +## FIXME: this should be a separate macro +## +if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + AC_CACHE_VAL([lt_cv_archive_cmds_need_lc], + [$rm conftest* + echo 'static int dummy;' > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile); then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_cv_prog_cc_wl + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if AC_TRY_EVAL(archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi]) + AC_MSG_RESULT([$lt_cv_archive_cmds_need_lc]) + ;; + esac +fi +need_lc=${lt_cv_archive_cmds_need_lc-yes} +## +## END FIXME + +## FIXME: this should be a separate macro +## +# The second clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + : +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + test -f Makefile && make "$ltmain" +fi + +if test -f "$ltmain"; then + trap "$rm \"${ofile}T\"; exit 1" 1 2 15 + $rm -f "${ofile}T" + + echo creating $ofile + + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS \ + AR AR_FLAGS CC LD LN_S NM SHELL \ + reload_flag reload_cmds wl \ + pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ + thread_safe_flag_spec whole_archive_flag_spec libname_spec \ + library_names_spec soname_spec \ + RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ + old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ + postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ + old_striplib striplib file_magic_cmd export_symbols_cmds \ + deplibs_check_method allow_undefined_flag no_undefined_flag \ + finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ + global_symbol_to_c_name_address \ + hardcode_libdir_flag_spec hardcode_libdir_separator \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do + + case $var in + reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ + extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + cat <<__EOF__ > "${ofile}T" +#! $SHELL + +# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996-2000 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="sed -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +# ### BEGIN LIBTOOL CONFIG + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$need_lc + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# The default C compiler. +CC=$lt_CC + +# Is the compiler the GNU C compiler? +with_gcc=$GCC + +# The linker used to build libraries. +LD=$lt_LD + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_wl + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_pic_flag +pic_mode=$pic_mode + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_compiler_c_o + +# Can we write directly to a .lo ? +compiler_o_lo=$lt_compiler_o_lo + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_link_static_flag + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# ### END LIBTOOL CONFIG + +__EOF__ + + case $host_os in + aix3*) + cat <<\EOF >> "${ofile}T" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + case $host_os in + cygwin* | mingw* | pw32* | os2*) + cat <<'EOF' >> "${ofile}T" + # This is a source program that is used to create dlls on Windows + # Don't remove nor modify the starting and closing comments +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ + # This is a source program that is used to create import libraries + # on Windows for dlls which lack them. Don't remove nor modify the + # starting and closing comments +# /* impgen.c starts here */ +# /* Copyright (C) 1999-2000 Free Software Foundation, Inc. +# +# This file is part of GNU libtool. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# */ +# +# #include /* for printf() */ +# #include /* for open(), lseek(), read() */ +# #include /* for O_RDONLY, O_BINARY */ +# #include /* for strdup() */ +# +# /* O_BINARY isn't required (or even defined sometimes) under Unix */ +# #ifndef O_BINARY +# #define O_BINARY 0 +# #endif +# +# static unsigned int +# pe_get16 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[2]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 2); +# return b[0] + (b[1]<<8); +# } +# +# static unsigned int +# pe_get32 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[4]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 4); +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# static unsigned int +# pe_as32 (ptr) +# void *ptr; +# { +# unsigned char *b = ptr; +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# int +# main (argc, argv) +# int argc; +# char *argv[]; +# { +# int dll; +# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; +# unsigned long export_rva, export_size, nsections, secptr, expptr; +# unsigned long name_rvas, nexp; +# unsigned char *expdata, *erva; +# char *filename, *dll_name; +# +# filename = argv[1]; +# +# dll = open(filename, O_RDONLY|O_BINARY); +# if (dll < 1) +# return 1; +# +# dll_name = filename; +# +# for (i=0; filename[i]; i++) +# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') +# dll_name = filename + i +1; +# +# pe_header_offset = pe_get32 (dll, 0x3c); +# opthdr_ofs = pe_header_offset + 4 + 20; +# num_entries = pe_get32 (dll, opthdr_ofs + 92); +# +# if (num_entries < 1) /* no exports */ +# return 1; +# +# export_rva = pe_get32 (dll, opthdr_ofs + 96); +# export_size = pe_get32 (dll, opthdr_ofs + 100); +# nsections = pe_get16 (dll, pe_header_offset + 4 +2); +# secptr = (pe_header_offset + 4 + 20 + +# pe_get16 (dll, pe_header_offset + 4 + 16)); +# +# expptr = 0; +# for (i = 0; i < nsections; i++) +# { +# char sname[8]; +# unsigned long secptr1 = secptr + 40 * i; +# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); +# unsigned long vsize = pe_get32 (dll, secptr1 + 16); +# unsigned long fptr = pe_get32 (dll, secptr1 + 20); +# lseek(dll, secptr1, SEEK_SET); +# read(dll, sname, 8); +# if (vaddr <= export_rva && vaddr+vsize > export_rva) +# { +# expptr = fptr + (export_rva - vaddr); +# if (export_rva + export_size > vaddr + vsize) +# export_size = vsize - (export_rva - vaddr); +# break; +# } +# } +# +# expdata = (unsigned char*)malloc(export_size); +# lseek (dll, expptr, SEEK_SET); +# read (dll, expdata, export_size); +# erva = expdata - export_rva; +# +# nexp = pe_as32 (expdata+24); +# name_rvas = pe_as32 (expdata+32); +# +# printf ("EXPORTS\n"); +# for (i = 0; i> "${ofile}T" || (rm -f "${ofile}T"; exit 1) + + mv -f "${ofile}T" "$ofile" || \ + (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") + chmod +x "$ofile" +fi +## +## END FIXME + +])# _LT_AC_LTCONFIG_HACK + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN([AC_ENABLE_SHARED], +[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case $enableval in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN([AC_DISABLE_SHARED], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN([AC_ENABLE_STATIC], +[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case $enableval in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN([AC_DISABLE_STATIC], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN([AC_ENABLE_FAST_INSTALL], +[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case $enableval in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN([AC_DISABLE_FAST_INSTALL], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_LIBTOOL_PICMODE - implement the --with-pic flag +# Usage: AC_LIBTOOL_PICMODE[(MODE)] +# Where MODE is either `yes' or `no'. If omitted, it defaults to +# `both'. +AC_DEFUN([AC_LIBTOOL_PICMODE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +pic_mode=ifelse($#,1,$1,default)]) + + +# AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library +AC_DEFUN([AC_PATH_TOOL_PREFIX], +[AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in + /*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; + ?:/*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. + ;; + *) + ac_save_MAGIC_CMD="$MAGIC_CMD" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="ifelse([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + egrep "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$ac_save_ifs" + MAGIC_CMD="$ac_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +]) + + +# AC_PATH_MAGIC - find a file program which can recognise a shared library +AC_DEFUN([AC_PATH_MAGIC], +[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl +AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin:$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + AC_PATH_TOOL_PREFIX(file, /usr/bin:$PATH) + else + MAGIC_CMD=: + fi +fi +]) + + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN([AC_PROG_LD], +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | [[A-Za-z]]:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + lt_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$lt_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +]) + +# AC_PROG_LD_GNU - +AC_DEFUN([AC_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + lt_cv_prog_gnu_ld=yes +else + lt_cv_prog_gnu_ld=no +fi]) +with_gnu_ld=$lt_cv_prog_gnu_ld +]) + +# AC_PROG_LD_RELOAD_FLAG - find reload flag for linker +# -- PORTME Some linkers may need a different reload flag. +AC_DEFUN([AC_PROG_LD_RELOAD_FLAG], +[AC_CACHE_CHECK([for $LD option to reload object files], lt_cv_ld_reload_flag, +[lt_cv_ld_reload_flag='-r']) +reload_flag=$lt_cv_ld_reload_flag +test -n "$reload_flag" && reload_flag=" $reload_flag" +]) + +# AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics +AC_DEFUN([AC_DEPLIBS_CHECK_METHOD], +[AC_CACHE_CHECK([how to recognise dependant libraries], +lt_cv_deplibs_check_method, +[lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given egrep regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix4* | aix5*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi4*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin* | mingw* | pw32*) + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' + lt_cv_file_magic_cmd='/usr/bin/file -L' + case "$host_os" in + rhapsody* | darwin1.[[012]]) + lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` + ;; + *) # Darwin 1.3 on + lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' + ;; + esac + ;; + +freebsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20*|hpux11*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + +irix5* | irix6*) + case $host_os in + irix5*) + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + ;; + *) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[[1234]] dynamic lib MIPS - version 1" + ;; + esac + lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux-gnu*) + case $host_cpu in + alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* ) + lt_cv_deplibs_check_method=pass_all ;; + *) + # glibc up to 2.1.1 does not perform some relocations on ARM + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; + esac + lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so\.[[0-9]]+\.[[0-9]]+$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +openbsd*) + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' + else + lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' + fi + ;; + +osf3* | osf4* | osf5*) + # this will be overridden with pass_all, but let us keep it just in case + lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' + lt_cv_file_magic_test_file=/shlib/libc.so + lt_cv_deplibs_check_method=pass_all + ;; + +sco3.2v5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + lt_cv_file_magic_test_file=/lib/libc.so + ;; + +sysv5uw[[78]]* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + esac + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +]) + + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN([AC_PROG_NM], +[AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl +AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/${ac_tool_prefix}nm + if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then + lt_cv_path_NM="$tmp_nm -B" + break + elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + lt_cv_path_NM="$tmp_nm -p" + break + else + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi]) +NM="$lt_cv_path_NM" +AC_MSG_RESULT([$NM]) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN([AC_CHECK_LIBM], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-convenience to the +# configure arguments. Note that LIBLTDL and INCLTDL are not +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not +# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed +# with '${top_builddir}/' and INCLTDL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN([AC_LIBLTDL_CONVENIENCE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-install to the configure +# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is +# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed +# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed +# with '${top_srcdir}/' (note the single quotes!). If your package is +# not flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN([AC_LIBLTDL_INSTALLABLE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +# old names +AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) +AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) +AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) +AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) +AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) + +# This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL]) diff --git a/src/libs/pdflib/config/config.guess b/src/libs/pdflib/config/config.guess new file mode 100755 index 0000000000..dff9e481b7 --- /dev/null +++ b/src/libs/pdflib/config/config.guess @@ -0,0 +1,1317 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-09-04' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# Please send patches to . +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int dummy(){}" > $dummy.c ; + for c in cc gcc c89 ; do + ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; + if test $? = 0 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + rm -f $dummy.c $dummy.o $dummy.rel ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-unknown ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE}" in + i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + 2-1307) + UNAME_MACHINE="alphaev68" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + sparc*:NetBSD:*) + echo `uname -p`-unknown-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + case "${HPUX_REV}" in + 11.[0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + esac ;; + esac + fi ;; + esac + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy + fi ;; + esac + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in + big) echo mips-unknown-linux-gnu && exit 0 ;; + little) echo mipsel-unknown-linux-gnu && exit 0 ;; + esac + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_supported_targets=`cd /; ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + cat >$dummy.c < +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-pc-linux-gnu\n", argv[1]); +# else + printf ("%s-pc-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-pc-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-pc-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[KW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/libs/pdflib/config/config.sub b/src/libs/pdflib/config/config.sub new file mode 100755 index 0000000000..393f13d373 --- /dev/null +++ b/src/libs/pdflib/config/config.sub @@ -0,0 +1,1411 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-09-07' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | c4x | clipper \ + | d10v | d30v | dsp16xx \ + | fr30 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el | mips64vr4300 \ + | mips64vr4300el | mips64vr5000 | mips64vr5000el \ + | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \ + | mipsisa32 \ + | mn10200 | mn10300 \ + | ns16k | ns32k \ + | openrisc \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | s390 | s390x \ + | sh | sh[34] | sh[34]eb | shbe | shle \ + | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ + | stormy16 | strongarm \ + | tahoe | thumb | tic80 | tron \ + | v850 \ + | we32k \ + | x86 | xscale \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alphapca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armv*-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c54x-* \ + | clipper-* | cray2-* | cydra-* \ + | d10v-* | d30v-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | m32r-* \ + | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ + | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \ + | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | s390-* | s390x-* \ + | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | stormy16-* | strongarm-* | sv1-* \ + | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ + | v850-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [cjt]90) + basic_machine=${basic_machine}-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + windows32) + basic_machine=i386-pc + os=-windows32-msvcrt + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh3eb | sh4eb) + basic_machine=sh-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/libs/pdflib/config/install-sh b/src/libs/pdflib/config/install-sh new file mode 100755 index 0000000000..e9de23842d --- /dev/null +++ b/src/libs/pdflib/config/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/src/libs/pdflib/config/ltmain.sh b/src/libs/pdflib/config/ltmain.sh new file mode 100644 index 0000000000..b6d6777766 --- /dev/null +++ b/src/libs/pdflib/config/ltmain.sh @@ -0,0 +1,5031 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun configure. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +# Parse our command line options once, thoroughly. +while test $# -gt 0 +do + arg="$1" + shift + + case $arg in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + execute_dlfiles) + execute_dlfiles="$execute_dlfiles $arg" + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case $arg in + --help) + show_help=yes + ;; + + --version) + echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + exit 0 + ;; + + --config) + sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 + exit 0 + ;; + + --debug) + echo "$progname: enabling shell trace mode" + set -x + ;; + + --dry-run | -n) + run=: + ;; + + --features) + echo "host: $host" + if test "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + exit 0 + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --quiet | --silent) + show=: + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 +fi + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + case $nonopt in + *cc | *++ | gcc* | *-gcc*) + mode=link + for arg + do + case $arg in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case $mode in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + prev= + lastarg= + srcfile="$nonopt" + suppress_output= + + user_target=no + for arg + do + case $prev in + "") ;; + xcompiler) + # Aesthetically quote the previous argument. + prev= + lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + + case $arg in + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + + # Add the previous argument to base_compile. + if test -z "$base_compile"; then + base_compile="$lastarg" + else + base_compile="$base_compile $lastarg" + fi + continue + ;; + esac + + # Accept any command-line options. + case $arg in + -o) + if test "$user_target" != "no"; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit 1 + fi + user_target=next + ;; + + -static) + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` + lastarg= + save_ifs="$IFS"; IFS=',' + for arg in $args; do + IFS="$save_ifs" + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + lastarg="$lastarg $arg" + done + IFS="$save_ifs" + lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` + + # Add the arguments to base_compile. + if test -z "$base_compile"; then + base_compile="$lastarg" + else + base_compile="$base_compile $lastarg" + fi + continue + ;; + esac + + case $user_target in + next) + # The next one is the -o target name + user_target=yes + continue + ;; + yes) + # We got the output file + user_target=set + libobj="$arg" + continue + ;; + esac + + # Accept the current argument as the source file. + lastarg="$srcfile" + srcfile="$arg" + + # Aesthetically quote the previous argument. + + # Backslashify any backslashes, double quotes, and dollar signs. + # These are the only characters that are still specially + # interpreted inside of double-quoted scrings. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $lastarg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + lastarg="\"$lastarg\"" + ;; + esac + + # Add the previous argument to base_compile. + if test -z "$base_compile"; then + base_compile="$lastarg" + else + base_compile="$base_compile $lastarg" + fi + done + + case $user_target in + set) + ;; + no) + # Get the name of the library object. + libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + *) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit 1 + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSfmso]' + case $libobj in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case $libobj in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit 1 + ;; + esac + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $libobj" + else + removelist="$libobj" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit 1" 1 2 15 + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2*) + pic_mode=default + ;; + esac + if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit 1" 1 2 15 + else + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $run ln "$0" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + echo $srcfile > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + # PDFlib add $srcfile as last argument + if test "$pic_mode" != no; then + # All platforms use -DPIC, to notify preprocessed assembler code. + command="$base_compile $pic_flag -DPIC" + else + # Don't build PIC code + command="$base_compile" + fi + if test "$build_old_libs" = yes; then + lo_libobj="$libobj" + dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$libobj"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + + if test -d "$dir"; then + $show "$rm $libobj" + $run $rm $libobj + else + $show "$mkdir $dir" + $run $mkdir $dir + status=$? + if test $status -ne 0 && test ! -d $dir; then + exit $status + fi + fi + fi + if test "$compiler_o_lo" = yes; then + output_obj="$libobj" + command="$command -o $output_obj $srcfile" + elif test "$compiler_c_o" = yes; then + output_obj="$obj" + command="$command -o $output_obj $srcfile" + fi + + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + test -n "$output_obj" && $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed, then go on to compile the next one + if test x"$output_obj" != x"$libobj"; then + $show "$mv $output_obj $libobj" + if $run $mv $output_obj $libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # If we have no pic_flag, then copy the object into place and finish. + if (test -z "$pic_flag" || test "$pic_mode" != default) && + test "$build_old_libs" = yes; then + # Rename the .lo from within objdir to obj + if test -f $obj; then + $show $rm $obj + $run $rm $obj + fi + + $show "$mv $libobj $obj" + if $run $mv $libobj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` + libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + # Now arrange that obj and lo_libobj become the same file + $show "(cd $xdir && $LN_S $baseobj $libobj)" + if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + $run $rm "$lockfile" + fi + exit 0 + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Allow error messages only from the first compilation. + suppress_output=' >/dev/null 2>&1' + fi + + # PDFlib add $srcfile as last argument + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile" + else + # All platforms use -DPIC, to notify preprocessed assembler code. + command="$base_compile $pic_flag -DPIC" + fi + if test "$compiler_c_o" = yes; then + command="$command -o $obj $srcfile" + output_obj="$obj" + else + command="$command $srcfile" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed + if test x"$output_obj" != x"$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Create an invalid libtool object if no PIC, so that we do not + # accidentally link it into a program. + if test "$build_libtool_libs" != yes; then + $show "echo timestamp > $libobj" + $run eval "echo timestamp > \$libobj" || exit $? + else + # Move the .lo from within objdir + $show "$mv $libobj $lo_libobj" + if $run $mv $libobj $lo_libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + fi + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + $run $rm "$lockfile" + fi + + exit 0 + ;; + + # libtool link mode + link | relink) + modename="$modename: link" + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invokation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args="$nonopt" + compile_command="$nonopt" + finalize_command="$nonopt" + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + + avoid_version=no + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + prefer_static_libs=no + preload=no + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + # PDFlib added + linkopts= + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -all-static | -static) + if test "X$arg" = "X-all-static"; then + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + fi + build_libtool_libs=no + build_old_libs=yes + prefer_static_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test $# -gt 0; do + arg="$1" + shift + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test + ;; + *) qarg=$arg ;; + esac + libtool_args="$libtool_args $qarg" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit 1 + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + compile_command="$compile_command $wl$qarg" + finalize_command="$finalize_command $wl$qarg" + continue + ;; + # PDFlib added + framework) + linkopts="$linkopts -framework $arg" + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n $prev + + prevarg="$arg" + + case $arg in + # PDFlib added + -framework) + prev=framework + continue + ;; + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: more than one -exported-symbols argument is not allowed" + exit 1 + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix*) + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + ;; + esac + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + exit 1 + fi + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + case :$dllsearchpath: in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-pw32* | *-*-beos*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-mingw* | *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # The PATH hackery in wrapper scripts is required on Windows + # in order for the loader to find any dlls it needs. + $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 + $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -o) prev=output ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Wl,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $wl$flag" + linker_flags="$linker_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + + *.lo | *.$objext) + # A library or standard object. + if test "$prev" = dlfiles; then + # This file was specified with -dlopen. + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $arg" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` + prev= + else + case $arg in + *.lo) libobjs="$libobjs $arg" ;; + *) objs="$objs $arg" ;; + esac + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done # argument parsing loop + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + # Create the object directory. + if test ! -d $output_objdir; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi + + # Determine the type of output + case $output in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + libs="$libs $deplib" + done + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + case $linkmode in + lib) + passes="conv link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 + exit 1 + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + for pass in $passes; do + if test $linkmode = prog; then + # Determine which files to process + case $pass in + dlopen) + libs="$dlfiles" + save_deplibs="$deplibs" # Collect dlpreopened libraries + deplibs= + ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + for deplib in $libs; do + lib= + found=no + case $deplib in + -l*) + if test $linkmode = oldlib && test $linkmode = obj; then + $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 + continue + fi + if test $pass = conv; then + deplibs="$deplib $deplibs" + continue + fi + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do + # Search the libtool library + lib="$searchdir/lib${name}.la" + if test -f "$lib"; then + found=yes + break + fi + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + ;; # -l + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test $pass = conv && continue + newdependency_libs="$deplib $newdependency_libs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + prog) + if test $pass = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test $pass = scan; then + deplibs="$deplib $deplibs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + ;; + *) + $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test $pass = link; then + dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test $pass = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + if test "$deplibs_check_method" != pass_all; then + echo + echo "*** Warning: This library needs some functionality provided by $deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + else + echo + echo "*** Warning: Linking the shared library $output against the" + echo "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + continue + ;; + prog) + if test $pass != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + if test $found = yes || test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib'" 1>&2 + exit 1 + fi + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + # If the library was installed with an old release of libtool, + # it will not redefine variable installed. + installed=yes + + # Read the .la file + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test $linkmode = oldlib && test $linkmode = obj; }; then + # Add dl[pre]opened files of deplib + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test $pass = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit 1 + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + tmp_libs="$tmp_libs $deplib" + done + elif test $linkmode != prog && test $linkmode != lib; then + $echo "$modename: \`$lib' is not a convenience library" 1>&2 + exit 1 + fi + continue + fi # $pass = conv + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit 1 + fi + + # This library was specified with -dlopen. + if test $pass = dlopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 + exit 1 + fi + if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. + dlprefiles="$dlprefiles $lib" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi # $installed = yes + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + + # This library was specified with -dlpreopen. + if test $pass = dlpreopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 + exit 1 + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test $linkmode = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" + fi + continue + fi + + if test $linkmode = prog && test $pass != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test + esac + # Need to link against all dependency_libs? + if test $linkalldeplibs = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + link_static=no # Whether the deplib will be linked statically + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + # Link against this shared library + + if test "$linkmode,$pass" = "prog,link" || + { test $linkmode = lib && test $hardcode_into_libs = yes; }; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + if test $linkmode = prog; then + # We need to hardcode the library path + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + fi + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + realname="$2" + shift; shift + libname=`eval \\$echo \"$libname_spec\"` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin*) + major=`expr $current - $age` + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + soname=`echo $soroot | sed -e 's/^.*\///'` + newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + save_ifs="$IFS"; IFS='~' + eval cmds=\"$extract_expsyms_cmds\" + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + save_ifs="$IFS"; IFS='~' + eval cmds=\"$old_archive_from_expsyms_cmds\" + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n $old_archive_from_expsyms_cmds + + if test $linkmode = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit 1 + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test $linkmode = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test $linkmode = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + add="-l$name" + fi + + if test $linkmode = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test $linkmode = prog; then + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + + # Try to link the static library + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + echo + echo "*** Warning: This library needs some functionality provided by $lib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + echo "*** Therefore, libtool will create a static module, that should work " + echo "*** as long as the dlopening application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test $linkmode = lib; then + if test -n "$dependency_libs" && + { test $hardcode_into_libs != yes || test $build_old_libs = yes || + test $link_static = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + tmp_libs="$tmp_libs $deplib" + done + + if test $link_all_deplibs != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$deplib" && dir="." + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + fi + ;; + esac + if grep "^installed=no" $deplib > /dev/null; then + path="-L$absdir/$objdir" + else + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit 1 + fi + if test "$absdir" != "$libdir"; then + $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 + fi + path="-L$absdir" + fi + ;; + *) continue ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$deplibs $path" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test $pass = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test $pass != dlopen; then + test $pass != scan && dependency_libs="$newdependency_libs" + if test $pass != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + *) + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + if test "$pass" = "conv" && + { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then + libs="$deplibs" # reset libs + deplibs= + fi + done # for pass + if test $linkmode = prog; then + dlfiles="$newdlfiles" + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 + exit 1 + else + echo + echo "*** Warning: Linking the shared library $output against the non-libtool" + echo "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + if test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test $# -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + libext=al + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + current="$2" + revision="$3" + age="$4" + + # Check that each of the things are valid numbers. + case $current in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case $revision in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case $age in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + if test $age -gt $current; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + minor_current=`expr $current + 1` + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + irix) + major=`expr $current - $age + 1` + verstring="sgi$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test $loop != 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="sgi$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test $loop != 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + major=`expr $current - $age` + versuffix="-$major" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + verstring="0.0" + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring="" + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + fi + + if test "$mode" != relink; then + # Remove our outputs. + $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" + $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + for path in $notinst_path; do + lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'` + deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'` + dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'` + done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test $hardcode_into_libs != yes || test $build_old_libs = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs -framework System" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd*) + # Do not include libc due to us having libc/libc_r. + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test $build_libtool_need_lc = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behaviour. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | sed 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | sed 10q \ + | egrep "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + if test -n "$a_deplib" ; then + droppeddeps=yes + echo + echo "*** Warning: This library needs some functionality provided by $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name="`expr $a_deplib : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test -n "$name" && test "$name" != "0"; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + if eval echo \"$potent_lib\" 2>/dev/null \ + | sed 10q \ + | egrep "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + if test -n "$a_deplib" ; then + droppeddeps=yes + echo + echo "*** Warning: This library needs some functionality provided by $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | + grep . >/dev/null; then + echo + if test "X$deplibs_check_method" = "Xnone"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + echo "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + + if test $allow_undefined = no; then + echo + echo "*** Since this library must not contain undefined symbols," + echo "*** because either the platform does not support them or" + echo "*** it was explicitly requested with -no-undefined," + echo "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test $hardcode_into_libs = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + test -z "$dlname" && dlname=$soname + + lib="$output_objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Ensure that we have .o objects for linkers which dislike .lo + # (e.g. aix) in case we are running --disable-static + for obj in $libobjs; do + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + if test ! -f $xdir/$oldobj; then + $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" + $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? + fi + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + eval cmds=\"$export_symbols_cmds\" + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval cmds=\"$archive_expsym_cmds\" + else + # PDFlib GmbH: remove duplicate libraries here + case $host in + *-*-rhapsody* | *-*-darwin*) + # On Rhapsody avoid duplicate libs + for i in $deplibs; do + case $i in + *.al) ;; + *) temp_deplibs="$temp_deplibs $i";; + esac + done + deplibs=$temp_deplibs + ;; + esac + eval cmds=\"$archive_cmds $linkopts\" + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? + exit 0 + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case $output in + *.lo) + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit 1 + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${obj}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + eval cmds=\"$reload_cmds\" + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + $show "echo timestamp > $libobj" + $run eval "echo timestamp > $libobj" || exit $? + exit 0 + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + eval cmds=\"$reload_cmds\" + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + else + # Just create a symlink. + $show $rm $libobj + $run $rm $libobj + xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$libobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + $show "(cd $xdir && $LN_S $oldobj $baseobj)" + $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + ;; + + prog) + case $host in + *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;; + esac + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + case :$dllsearchpath: in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case $dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$output.exp" + $run $rm $export_symbols + $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + else + $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`echo "$arg" | sed -e 's%^.*/%%'` + $run eval 'echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[] = +{\ +" + + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test $need_relink = no || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # PDFlib added $linkopts + link_command="$compile_command$linkopts$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + # PDFlib added $linkopts + link_command="$compile_var$compile_command$linkopts$compile_rpath" + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $run $rm $output + # Link the executable and exit + $show "$link_command" + $run eval "$link_command" || exit $? + exit 0 + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + # PDFlib added $linkopts + link_command="$compile_var$compile_command$linkopts$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + # PDFlib added $linkopts + link_command="$finalize_var$compile_command$linkopts$finalize_rpath" + if test "$fast_install" = yes; then + # PDFlib added $linkopts + relink_command=`$echo "X$compile_var$compile_command$linkopts$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + # PDFlib added $linkopts + link_command="$compile_var$compile_command$linkopts$compile_rpath" + relink_command="$finalize_var$finalize_command$linkopts$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + relink_command="cd `pwd`; $relink_command" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $0 --fallback-echo"; then + case $0 in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; + *) qecho="$SHELL `pwd`/$0 --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`echo $output|sed 's,.exe$,,'` ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) exeext=.exe ;; + *) exeext= ;; + esac + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + echo >> $output "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $echo \"\$relink_command_output\" >&2 + $rm \"\$progdir/\$file\" + exit 1 + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # win32 systems need to use the prog path for dll + # lookup to work + *-*-cygwin* | *-*-pw32*) + $echo >> $output "\ + exec \$progdir/\$program \${1+\"\$@\"} +" + ;; + + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + # Export the path to the program. + PATH=\"\$progdir:\$PATH\" + export PATH + + exec \$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case $xlib in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + eval cmds=\"$old_archive_from_new_cmds\" + else + # Ensure that we have .o objects in place in case we decided + # not to build a shared library, and have fallen back to building + # static libs even though --disable-static was passed! + for oldobj in $oldobjs; do + if test ! -f $oldobj; then + xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$oldobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` + obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + $show "(cd $xdir && ${LN_S} $obj $baseobj)" + $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? + fi + done + + eval cmds=\"$old_archive_cmds\" + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit 1 + fi + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + for lib in $dlfiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + newdlfiles="$newdlfiles $libdir/$name" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + newdlprefiles="$newdlprefiles $libdir/$name" + done + dlprefiles="$newdlprefiles" + fi + $rm $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test $need_relink = yes; then + $echo >> $output "\ +relink_command=\"$relink_command\"" + fi + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + relink_command= + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + if test -n "$relink_command"; then + $echo "$modename: warning: relinking \`$file'" 1>&2 + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + continue + fi + fi + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run eval "$striplib $destdir/$realname" || exit $? + fi + + if test $# -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + eval cmds=\"$postinstall_cmds\" + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + notinst_deplibs= + relink_command= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$notinst_deplibs"; then + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + relink_command= + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : + else + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyways + case $install_prog,$host in + /usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + destfile=`echo $destfile | sed -e 's,.exe$,,'` + ;; + esac + ;; + esac + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + if test -n "$stripme" && test -n "$striplib"; then + $show "$old_striplib $oldlib" + $run eval "$old_striplib $oldlib" || exit $? + fi + + # Do each command in the postinstall commands. + eval cmds=\"$old_postinstall_cmds\" + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $0 --finish$current_libdirs' + else + exit 0 + fi + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + eval cmds=\"$finish_cmds\" + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = ":" && exit 0 + + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "----------------------------------------------------------------------" + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved enviroment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now prepare to actually exec the command. + exec_cmd='"$cmd"$args' + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool clean and uninstall mode + clean | uninstall) + modename="$modename: $mode" + rm="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) rm="$rm $arg"; rmforce=yes ;; + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + rmdirs= + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$file"; then + dir=. + objdir="$objdir" + else + objdir="$dir/$objdir" + fi + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + test $mode = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test $mode = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if (test -L "$file") >/dev/null 2>&1 \ + || (test -h "$file") >/dev/null 2>&1 \ + || test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + test $mode = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + + if test $mode = uninstall; then + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + eval cmds=\"$postuninstall_cmds\" + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + if test $? != 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + eval cmds=\"$old_postuninstall_cmds\" + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + if test $? != 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + # FIXME: should reinstall the best remaining shared library. + fi + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" + fi + ;; + + *) + # Do a test to see if this is a libtool program. + if test $mode = clean && + (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$file + + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + fi + ;; + esac + $show "$rm $rmfiles" + $run $rm $rmfiles || exit_status=1 + done + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + $show "rmdir $dir" + $run rmdir $dir >/dev/null 2>&1 + fi + done + + exit $exit_status + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + if test -z "$exec_cmd"; then + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + fi +fi # test -z "$show_help" + +if test -n "$exec_cmd"; then + eval "exec \$cmd$args" + exit 1 +fi + +# We need to display help for each of the modes. +case $mode in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --version print version information + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE." + exit 0 + ;; + +clean) + $echo \ +"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/src/libs/pdflib/config/mkbind.inc.in b/src/libs/pdflib/config/mkbind.inc.in new file mode 100644 index 0000000000..4c5715b652 --- /dev/null +++ b/src/libs/pdflib/config/mkbind.inc.in @@ -0,0 +1,43 @@ +# Template to be included from every makefile that creates bindings +# $Id: mkbind.inc.in,v 1.1 2004/10/06 17:46:45 laplace Exp $ +# + +all:: $(BASEPROGS) $(LIBNAME) + +# The actual shared library for the language support +$(LIBNAME):: $(CONVENIENT) $(OBJ) + $(RM) $(LIBNAME) + $(LIBTOOL_LD) $(CC) -o $@ $(OBJ) -module -rpath $(LANG_LIBDIR) \ + $(CONVENIENT) $(BINDEXTERNALLIBS) $(EXTERNALLIBS) + @-if test -f .libs/libpdf_java.dylib; then \ + ln .libs/libpdf_java.dylib .libs/libpdf_java.jnilib; \ + fi + +clean:: + -$(RM) *.$(OBJ) *$(LO) *$(LA) $(LIBNAME) *.bak .libs *.pdf + +distclean:: clean + -$(RM) m.out ms.out + +depend:: .dummy + cp Makefile Makefile.bak + sed '/^# Automatically generated dependencies/q' Makefile.bak >Makefile + $(CC) $(CFLAGS) -MM $(SRC) | sed 's/\.o:/$$(LO):/g' >>Makefile + +ctags:: + +install:: + +uninstall:: + +.PHONY: clean + +.dummy: + +.SUFFIXES: .c .$(OBJ) $(LO) + +.c$(LO): + $(LIBTOOL_CC) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + +.c.$(OBJ): + $(LIBTOOL_CC) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< diff --git a/src/libs/pdflib/config/mkcommon.inc.in b/src/libs/pdflib/config/mkcommon.inc.in new file mode 100644 index 0000000000..5569da835b --- /dev/null +++ b/src/libs/pdflib/config/mkcommon.inc.in @@ -0,0 +1,120 @@ +# Template to be included from every makefile that creates libs/progs +# $Id: mkcommon.inc.in,v 1.1 2004/10/06 17:46:45 laplace Exp $ +# +# +# The Makefile that uses this template has to set +# top_builddir = ... +# before including $(top_builddir)/config/mkcommon.inc +# +# if PEDANTIC don't work in this Makefile use: +# CFLAGS = $(DEFS) $(DEFINES) $(INCLUDES) +# after including this template +# + +srcdir = . + +# general stuff (configure) +VPATH = $srcdir +VERSION = @VERSION@ +SHELL = @SHELL@ +INSTALL = $(top_builddir)/config/install-sh -c +INSTALL_DATA = ${INSTALL} -m 644 +EXE = @EXEEXT@ +OBJ = @OBJEXT@ +CC = @CC@ +CXX = @CXX@ +STDCPP = @STDCPP@ +RM = @RM@ +BINDINGS = @BINDINGS@ +PSPBINDINGS = @PSPBINDINGS@ +LIBTARGETS = @LIBTARGETS@ +BINDTARGETS = @BINDTARGETS@ +PROGTARGETS = @PROGTARGETS@ +PTFDIR = @PTFDIR@ + +# build related stuff (configure) +PDFPEDANTIC = @PDFPEDANTIC@ +DEFINES = @DEFINES@ +DEFS = @DEFS@ + +# libtool specific +LA = .la +LO = .lo +WITH_SHARED = @WITH_SHARED@ +RPATH = @RPATH@ + +LIBTOOL = $(top_builddir)/libtool --silent +LIBTOOL_CC = $(LIBTOOL) --mode=compile +LIBTOOL_LD = $(LIBTOOL) --mode=link +LIBTOOL_EXE = $(LIBTOOL) --mode=execute -dlopen $(LIBNAME) + + +# Perl +PERLLIBDIR = @PERLLIBDIR@ +PERLINCLUDE = @PERLINCLUDE@ +PERLLINK = @PERLLINK@ +PERL = @PERL@ +PERLBOOLDEF = @PERLBOOLDEF@ + +PYTHONLIBDIR = @PYTHONLIBDIR@ +PYINCLUDE = @PYINCLUDE@ + +RUBYINCLUDE = @RUBYINCLUDE@ + +TCLINCLUDE = @TCLINCLUDE@ +TCLPACKAGEDIR = @TCLPACKAGEDIR@ +TCLBIN = @TCLBIN@ + +CFLAGS = $(DEFS) $(DEFINES) $(INCLUDES) $(PDFPEDANTIC) $(MYCFLAGS) + +# PDFlib includes +PDFLIBINC = @PDFLIBINC@ +TIFFLIBINC = @TIFFLIBINC@ +JPEGLIBINC = @JPEGLIBINC@ +ZLIBINC = @FLATELIBINC@ +FLATELIBINC = @FLATELIBINC@ +PNGLIBINC = @PNGLIBINC@ +PDCORELIBINC = @PDCORELIBINC@ +PDILIBINC = @PDILIBINC@ +PDPAGELIBINC = @PDPAGELIBINC@ +PDULIBINC = @PDULIBINC@ +TETLIBINC = @TETLIBINC@ +PSPLIBINC = @PSPLIBINC@ +JAVAINCLUDE = @JAVAINCLUDE@ + +# libs stuff +MATHLIB = @MATHLIB@ +INTERNALLIBS = @INTERNALLIBS@ +EXTERNALLIBS = @EXTERNALLIBS@ +PDFLIBNAME = @PDFLIBNAME@ +LTVERSIONINFO = @LTVERSIONINFO@ +PDFLIBCONVENIENT= @PDFLIBCONVENIENT@ +CONVENIENT = $(PDFLIBCONVENIENT) + +# libs +PDFLIBLINK = @PDFLIBLINK@ +PDFLIB_LINK = @PDFLIB_LINK@ +TIFFLIBLINK = @TIFFLIBLINK@ +JPEGLIBLINK = @JPEGLIBLINK@ +FLATELIBLINK = @FLATELIBLINK@ +PNGLIBLINK = @PNGLIBLINK@ +PDCORELIBLINK = @PDCORELIBLINK@ +PDILIBLINK = @PDILIBLINK@ +PDPAGELIBLINK = @PDPAGELIBLINK@ + +# TET libs +TETLIBLINK = @TETLIBLINK@ +TETLIB_LINK = @TETLIB_LINK@ + +# PSP libs +PSPLIBLINK = @PSPLIBLINK@ +PSPLIB_LINK = @PSPLIB_LINK@ + +PDULIBLINK = @PDULIBLINK@ + +# installation directories (configure) +prefix = @prefix@ +exec_prefix = @exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ +bindir = @bindir@ diff --git a/src/libs/pdflib/config/mklibs.inc.in b/src/libs/pdflib/config/mklibs.inc.in new file mode 100644 index 0000000000..3060474ee2 --- /dev/null +++ b/src/libs/pdflib/config/mklibs.inc.in @@ -0,0 +1,40 @@ +# Template to be included from every makefile that creates libs +# $Id: mklibs.inc.in,v 1.1 2004/10/06 17:46:45 laplace Exp $ +# + +all:: $(LIBNAME) + +$(LIBNAME): $(OBJS) + $(LIBTOOL_LD) $(CC) -o $@ $(OBJS) $(LIBTOOL_LDOPT) + +clean:: + -$(RM) *.$(OBJ) *$(LO) *$(LA) *.bak .libs + +distclean:: clean + -$(RM) m.out ms.out + +depend:: .dummy + cp Makefile Makefile.bak + sed '/^# Automatically generated dependencies/q' Makefile.bak >Makefile + $(CC) $(CFLAGS) -MM $(SRC) | sed 's/\.o:/$$(LO):/g' >>Makefile + +install:: + +uninstall:: + +test:: + +smoke:: + +.PHONY: clean + +.dummy: + +# suffixes +.SUFFIXES: .c .$(OBJ) $(LO) + +.c$(LO): + $(LIBTOOL_CC) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + +.c.$(OBJ): + $(LIBTOOL_CC) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< diff --git a/src/libs/pdflib/config/mkmainlib.inc b/src/libs/pdflib/config/mkmainlib.inc new file mode 100644 index 0000000000..b2a13ce369 --- /dev/null +++ b/src/libs/pdflib/config/mkmainlib.inc @@ -0,0 +1,46 @@ +# Template to be included from every makefile that creates libs +# $Id: mkmainlib.inc,v 1.1 2004/10/06 17:46:45 laplace Exp $ +# + +LIBLINKSELF = $(RPATH) $(MAINOBJ) $(INTERNALLIBS) $(EXTERNALLIBS) + +all:: $(MAINLIBNAME) + +$(MAINLIBNAME): $(MAINOBJ) $(INTERNALLIBS) + $(LIBTOOL_LD) $(CC) $(LDFLAGS) -o $@ $(LIBLINKSELF) -export-dynamic + +clean:: + -$(RM) $(MAINLIBNAME) + +depend:: + $(CC) $(CFLAGS) -MM $(MAINSRC) | sed 's/\.o:/$$(LO):/g' >>Makefile + +install:: $(MAINLIBNAME) + if test ! -d $(libdir) ; then \ + mkdir -p $(libdir); \ + chmod 755 $(libdir); \ + fi + if test ! -d $(includedir) ; then \ + mkdir -p $(includedir); \ + chmod 755 $(includedir); \ + fi + $(INSTALL_DATA) $(MAININC) $(includedir) + @-if test "$(WITH_SHARED)" = "no"; then \ + cp .libs/$(MAINLIBNAME) .libs/$(MAINLIBNAME)i;\ + fi + $(LIBTOOL) $(INSTALL_DATA) $(MAINLIBNAME) $(libdir); + @-if test "$(WITH_SHARED)" = "yes"; then \ + $(LIBTOOL) -n --finish $(libdir);\ + else\ + rm -f .libs/$(MAINLIBNAME)i;\ + fi + +uninstall:: .dummy + $(RM) $(includedir)/$(MAININC) + -$(LIBTOOL) --mode=uninstall $(RM) $(libdir)/$(MAINLIBNAME) + +test:: + +smoke:: + +.PHONY: clean diff --git a/src/libs/pdflib/config/mkprogs.inc.in b/src/libs/pdflib/config/mkprogs.inc.in new file mode 100644 index 0000000000..1fe4761abd --- /dev/null +++ b/src/libs/pdflib/config/mkprogs.inc.in @@ -0,0 +1,47 @@ +# Template to be included from every makefile that creates progs +# $Id: mkprogs.inc.in,v 1.1 2004/10/06 17:46:45 laplace Exp $ +# + +PROGS_BUILD = $(LIBTOOL_LD) $(CC) -static $(FLAGS) -o $@ \ + $@.c $(EXTRA_SOURCES) $(LIBS) +CXXPROGS_BUILD = $(LIBTOOL_LD) $(CXX) -static $(CXXFLAGS) -o $@ \ + $@.cpp $(EXTRA_SOURCES) $(LIBS) + +all:: $(PROGS) + +clean:: + -$(RM) *.$(OBJ) *$(LO) *$(LA) $(PROGS) *.bak .libs + +distclean:: clean + -$(RM) m.out ms.out + +depend:: + +ctags:: + +install:: + +uninstall:: + +test:: + +smoke:: + +.PHONY: clean + +.dummy: + + +.SUFFIXES: .$(OBJ) $(LO) + +.c$(LO): + $(LIBTOOL_CC) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + +.c.$(OBJ): + $(LIBTOOL_CC) $(CC) -c $(CPPFLAGS) $(CFLAGS) $< + +.cpp$(LO): + $(LIBTOOL_CC) $(CXX) -c $(CXXFLAGS) $< + +.cpp.$(OBJ): + $(LIBTOOL_CC) $(CXX) -c $(CXXFLAGS) $< diff --git a/src/libs/pdflib/config/mksubdirs.inc.in b/src/libs/pdflib/config/mksubdirs.inc.in new file mode 100644 index 0000000000..084344e668 --- /dev/null +++ b/src/libs/pdflib/config/mksubdirs.inc.in @@ -0,0 +1,79 @@ +# Template to be included from every makefile that handles subdirs +# $Id: mksubdirs.inc.in,v 1.1 2004/10/06 17:46:45 laplace Exp $ +# +# +# The Makefile that uses this template has to set +# SUB_DIRS = ... +# +# additional actions may be done by using any of the makelabels with +# two colons. +# +# i.e. +# install:: .dummy +# $(INSTALL) pdflib-config $(bindir) + +# ------------------------- default target ------------------------------- +all:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) all);\ + done + +# --------------------------- test --------------------------------- +test:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) test);\ + done + +# --------------------------- pditest --------------------------------- +smoke:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) smoke);\ + done + +# --------------------------- install --------------------------------- +install:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) install);\ + done + +# --------------------------- uninstall --------------------------------- +uninstall:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) uninstall);\ + done + +# --------------------------- clean --------------------------------- +clean:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) clean);\ + done + +# ----------------------- distclean --------------------------------- +distclean:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) distclean);\ + done + rm -rf m.out ms.out + +# --------------------------- depend -------------------------------- +depend:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) depend);\ + done + +# --------------------------- ctags --------------------------------- +ctags:: .dummy + @for i in $(SUB_DIRS);\ + do\ + (cd $$i && $(MAKE) $(MAKEOPT) ctags);\ + done + +.dummy: diff --git a/src/libs/pdflib/doc/PDFlib-license.pdf b/src/libs/pdflib/doc/PDFlib-license.pdf new file mode 100644 index 0000000000..f7ec4a8c99 Binary files /dev/null and b/src/libs/pdflib/doc/PDFlib-license.pdf differ diff --git a/src/libs/pdflib/doc/PDFlib-license.rtf b/src/libs/pdflib/doc/PDFlib-license.rtf new file mode 100644 index 0000000000..a1ec416e66 --- /dev/null +++ b/src/libs/pdflib/doc/PDFlib-license.rtf @@ -0,0 +1,53 @@ +{\rtf1\ansi \deff0 \adeflang1033 {\fonttbl {\f0\froman Arial;} +{\f1\froman TheSans-Plain;}{\f2\fswiss Helvetica;}{\f3\fmodern MS LineDraw;}{\f4\fdecor Symbol;}} +{\colortbl;\red0\green0\blue0;\red0\green0\blue127;\red0\green127\blue0;\red0\green127\blue127;\red127\green0\blue0;\red127\green0\blue127;\red127\green127\blue0;\red127\green127\blue127;\red192\green192\blue192;\red0\green0\blue255;\red0\green255\blue0;\red0\green255\blue255;\red255\green0\blue0;\red255\green0\blue255;\red255\green255\blue0;\red255\green255\blue255;}\linex0 \sbknone +\paperh16842 \paperw11907 \margl1248 \margr1020 \margt1440 \margb1440 \plain {\stylesheet {\snext0 Normal;} +{\s2 \qc \fs36 \f0 \cf1 \b \sbasedon0 \snext2 1_Level;} +{\s3 \ql \tx681 \fs18 \f0 \cf1 \b \sbasedon0 \snext3 2_Level;} +{\s4 \ql \tx681 \fs18 \f0 \cf1 \b \sbasedon0 \snext4 3_Level;} +{\s5 \ql \tx1020 \fs22 \f1 \cf1 \sbasedon0 \snext5 Aufzaehlung;} +{\s6 \ql \tx4587 \fs18 \f0 \cf1 \sbasedon0 \snext6 Body;} +{\s7 \qc \tx963 \fs18 \f0 \cf1 \sbasedon0 \snext7 Body-centered;} +{\s8 \ql \tqdec \tx2439 \tx2778 \fs20 \f1 \cf1 \sbasedon0 \snext8 Fusszeile-links;} +{\s9 \ql \tx1020 \fs18 \f0 \cf1 \sbasedon0 \snext9 List;} +}\fs24 \f2 \fs36 \f0 \cf1 \b \lang1031 \b \linex0 \linemod0 \sbknone \pgnrestart \pgnstart1 \pgnstarts1 \pard \s2 \qc \sb280 \sa120 PDFlib License Agreement\lang1031 \plain \fs36 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s7 \qc \tx285 \sa80 PDFlib GmbH, Tal 40, 80331 Munich, Germany\lang1031 \line \lang1031 phone +49 89 29 16 46 87,\lang1031 fax +49 89 29 16 46 86\lang1031 \line \lang1031 sales@pdflib.com,\lang1031 support@pdflib.com,\lang1031 www.pdflib.com\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s3 \tx567 \sb100 \sa80 1\tab {\*\bkmkstart X92461}\lang1031 Definitions{\*\bkmkend X92461}\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 The effective date of this agreement is the date shown on the invoice. This agreement defines the licensing terms for the \lang1031 following software products:\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s9 \tx228 \sa60 (a) \lang1031 PDFlib \lang1031 5.0.3\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s9 \tx228 \sa60 (b) \lang1031 PDFlib+PDI \lang1031 5.0.3\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s9 \tx228 \sa60 (c) \lang1031 PDFlib Personalization Server (PPS) \lang1031 5.0.3\lang1031 and Block Plugin\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 These products, as well as all maintenance updates which are designated as such by PDFlib GmbH will be collectively re\-\lang1031 ferred to as "the program" in this agreement. The program is delivered with a digital manual which describes the program\-\lang1031 ming features and their usage ("the documentation").\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s3 \tx567 \sb120 \sa80 2\tab \lang1031 CPU-based License\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Licensee is granted the non-transferable, non-exclusive, and perpetual right to use the program on a number of comput\-\lang1031 ers. For the license fee the total number of CPUs (processors as reported by the operating system) is taken into account, \lang1031 while the number of users accessing the computer is irrelevant. The total number of computers is also irrelevant (e.g., two \lang1031 dual-processor machines plus a single-processor machine result in a total CPU count of five).\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 A purchased license may be transferred to another computer running under the same operating system if no two comput\-\lang1031 ers are driven concurrently under the same license.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Licensee may use the program on an unlimited number of development machines, provided these machines are not used \lang1031 for production purposes at the same time (for example, they cannot be accessed over a network except by developers \lang1031 working on products which incorporate a licensed copy of the program), and run under the same operating system for which a license was purchased.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s3 \tx567 \sb120 \sa80 3\tab \lang1031 Restrictions\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s4 \tx567 \sb40 \sa80 3.1\tab {\*\bkmkstart X62529}\lang1031 Intellectual Property{\*\bkmkend X62529}\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Licensee acknowledges that the program is copyrighted intellectual property of PDFlib GmbH, and that PDFlib GmbH re\-\lang1031 tains exclusive ownership of the program and documentation, subject however to all terms and conditions of this agree\-\lang1031 ment.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 It is expressly agreed that this license does not include ownership of the programs source code, but only the right-to-use \lang1031 as defined by this agreement.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s4 \tx567 \sb60 \sa80 3.2\tab \lang1031 Sublicensing\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Licensee may not resell, transfer, rent or lease the program. Licensee is not allowed to transfer the rights obtained under \lang1031 this license to any third party.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 This license applies to one incorporated unit, and does not extend to subsidiaries.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s4 \tx567 \sb60 \sa80 3.3\tab \lang1031 Reverse Engineering and Confidentiality\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Licensee agrees to not translate, disassemble, or reverse-engineer the program.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Licensee agrees to not redistribute or make publicly available any license key received from PDFlib \lang1031 GmbH.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s3 \tx567 \sb120 \sa80 4\tab {\*\bkmkstart X63085}\lang1031 Delivery{\*\bkmkend X63085}\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 The program and documentation are delivered in digital format only. Licensee agrees to retrieve the program and docu\-\lang1031 mentation, as well as any relevant maintenance updates from PDFlib GmbHs Web site at www.pdflib.com. N\lang1031 either digital \lang1031 storage media nor printed documentation will be delivered to licen\lang1031 see by PDFlib GmbH.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s3 \tx567 \sb120 \sa80 5\tab \lang1031 Warranty and {\*\bkmkstart X63838}\lang1031 Support{\*\bkmkend X63838}\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s4 \tx567 \sb40 \sa80 5.1\tab \lang1031 Performance of the Program\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 PDFlib GmbH warrants that the program will perform substantially in accordance with the documentation when used as di\-\lang1031 rected in the documentation. This warranty does not cover use of the program in ways which are not covered in the docu\-\lang1031 mentation (e.g., by calling undocumented functions, or by not obeying documented restrictions), or using modified copies \lang1031 of the program unless such modifications have been authorized by PDFlib GmbH.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 PDFlib GmbH warrants that it is owner of the program with authority to license the program to licensee, and that the pro\-\lang1031 gram does not infringe third party intellectual property rights. PDFlib GmbH agrees to indemnify, defend and hold harmless \lang1031 licensee from any claims either that PDFlib GmbH does not own the program, or that the program infringes a third partys \lang1031 intellectual property rights.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 In the event the unmodified program fails to satisfy this limited warranty during a warranty period of 30 days after the effec\-\lang1031 tive date of this agreement, PDFlib GmbH shall promptly, at its expense and in its discretion, (i) provide a correction or \lang1031 workaround for any reproducible errors which are reported by licensee, and deliver an updated version of the program, or \lang1031 (ii) return a refund of any license fees paid pursuant to this agreement. In this event licensee will immediately terminate \lang1031 any use and distribution of the program.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Technical support as described above is available by e-mail only. Maintenance updates of the program as indicated in \lang1031 section \lang1031 {\field \fldlock {\*\fldinst REF X92461 \\n }{\fldrslt 1}}\lang1031 do not extend the initial warranty period.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s4 \tx567 \sb60 \sa80 5.2\tab \lang1031 Warranty against Disablement\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 PDFlib GmbH expressly represents and warrants that, other than a disabling mechanism on the functional evaluation copy \lang1031 of the program which disabling mechanism is removed upon receipt by licensee of the license key for the full version of the \lang1031 program, the program will not intentionally cause or permit any portion of the program provided or developed by PDFlib \lang1031 GmbH hereunder to contain any protection feature designed to prevent its use. These protection features include, without \lang1031 limitation, any computer virus, worm, software lock, drop dead device, Trojan-horse routine, trap door, time bomb, or any \lang1031 other codes or instructions that may be used to access, modify, delete, damage or disable the program or any other com\-\lang1031 ponent of licensees computer systems. If PDFlib GmbH becomes aware of any such feature, PDFlib GmbH will promptly \lang1031 notify licensee thereof. PDFlib GmbH further represents and warrants that it will not impair the operation of the program in \lang1031 any way other than pursuant to an order of a court of law.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s4 \tx567 \sb60 \sa80 5.3\tab \lang1031 Limitations and Disclaimer\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Except for breach of PDFlib GmbHs warranties of ownership of the program and non-infringement of third party intellectual \lang1031 property, the foregoing states the sole and exclusive remedies for PDFlib \lang1031 GmbHs breach of warranty. The foregoing war\-\lang1031 ranties are in lieu of all other warranties or conditions, express or implied, and any implied warranty or condition of fitness \lang1031 for a particular purpose, merchantability, or merchantable quality. No person is authorized to make any other warranty or \lang1031 representation concerning the performance of the program other than according to this paragraph. Licensee shall make no \lang1031 other warranty, express or implied, on behalf of \lang1031 PDFlib GmbH.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s3 \tx567 \sb120 \sa80 6\tab \lang1031 Consequential Damages Waiver\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 Neither party will be liable for any loss of use, interruption of business, or any indirect, special, incidental, or consequential \lang1031 damages of any kind (including lost profits), regardless of the form of action whether in contract, tort (including negli\-\lang1031 gence), strict product liability or otherwise.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s3 \tx567 \sb120 \sa80 7\tab \lang1031 Applicable Law\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 This license is governed by the laws of Germany, excluding choice of law rules. If any part of this license is found to be in \lang1031 conflict with the law, that part shall be interpreted in its broadest meaning consistent with the law, and no other parts of the \lang1031 license shall be affected.\lang1031 \widowctrl +\par \fs18 \f0 \cf1 \b \lang1031 \b \pard \s3 \tx567 \sb120 \sa80 8\tab \lang1031 Final Agreement\lang1031 \plain \fs18 \cf1 \lang1031 +\par \fs18 \f0 \cf1 \lang1031 \pard \s6 \tx5835 \sa60 This agreement constitutes the complete, final and exclusive expression of the parties agreement, and supersedes all pro\-\lang1031 posals and other communications made between the parties concerning the subject matter hereof. This agreement cannot \lang1031 be modified except by written agreement signed by all the parties hereto.\lang1031 \widowctrl +\par } diff --git a/src/libs/pdflib/doc/grid.pdf b/src/libs/pdflib/doc/grid.pdf new file mode 100644 index 0000000000..f76b4d8363 Binary files /dev/null and b/src/libs/pdflib/doc/grid.pdf differ diff --git a/src/libs/pdflib/doc/pdflib/PDFlib-Lite-license.pdf b/src/libs/pdflib/doc/pdflib/PDFlib-Lite-license.pdf new file mode 100644 index 0000000000..418cb111b2 Binary files /dev/null and b/src/libs/pdflib/doc/pdflib/PDFlib-Lite-license.pdf differ diff --git a/src/libs/pdflib/doc/pdflib/PDFlib-manual.pdf b/src/libs/pdflib/doc/pdflib/PDFlib-manual.pdf new file mode 100644 index 0000000000..52c8b51138 Binary files /dev/null and b/src/libs/pdflib/doc/pdflib/PDFlib-manual.pdf differ diff --git a/src/libs/pdflib/doc/pdflib/PDFlib-purchase-order.pdf b/src/libs/pdflib/doc/pdflib/PDFlib-purchase-order.pdf new file mode 100644 index 0000000000..4a3f656fb3 Binary files /dev/null and b/src/libs/pdflib/doc/pdflib/PDFlib-purchase-order.pdf differ diff --git a/src/libs/pdflib/doc/pdflib/changes.txt b/src/libs/pdflib/doc/pdflib/changes.txt new file mode 100644 index 0000000000..4349691012 --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/changes.txt @@ -0,0 +1,779 @@ +=============================== +PDFlib 5.0.3 (January 21, 2004) +=============================== + +Bug fixes and minor improvements +================================ + +- Autmatically changes the encoding to "builtin" for the combination of + fontname=Symbol and encoding=winansi, since this combination cannot + reasonably be used. + +- Improves using the "page" option of PDF_load_image() for image formats + which do not support multiple images within a file. Instead of ignoring + the option we now expect page=1, and call will fail for larger numbers. + This facilitates common code for a mixture of single- and multi-page + image files in various formats. + +- Implements the "spotcolorlookup" parameter as a workaround for inaccurate + CMYK alternate colors in third-party software. + +- Ignores the "monospace" option if the font is embedded since Acrobat does + not apply modified metrics to embedded fonts. + +- No longer raises the warnings "OpenType font x does not contain glyph name y" + and "Encoding x was adapted to font y" for OpenType fonts since they are + not really relevant to users, but instead force them to disable font warnings + completely. + +- Added support for abbreviated PFMs for monospaced fonts which do not + contain any ExtentTable. + +- Issue a warning "codepage x not supported" if encoding or hypertextencoding + was set to "auto" on a Windows system, and the current system locale is a + multi-byte non-Unicode codepage (e.g. 932, Japanese). In order to resolve + this the user must explicitly set the encoding (e.g. "unicode"), and supply + text in the corresponding format to PDFlib. Only C, Perl, Python and PHP are + affected; Unicode-aware language bindings are not affected. + +- PDF_show_boxed() did not allow strings with more than 8191 characters + when called from Unicode capable language bindings (COM, Java, .NET, Tcl). + +- The checks for valid handles were not strict enough. Invalid handles for + fonts, PDI documents and pages, color spaces, images, patterns, and + shadings would be accepted if the value was one larger than the largest + valid handle. As a result, PDFlib would not complain about the client's + error, and generate invalid PDF instead. Clients which used only unmodified + handles as returned by PDFlib functions are not at all affected. Also, + the checks for valid handles in option lists were not affected. + +- PDF_fill_imageblock() and PDF_fill_pdfblock() could crash when called + with a block name that did not exist on the page. + +- Incorrect ToUnicode CMaps were generated under very specific conditions, + resulting in a message "Attempt to release an unlocked object" with the + find feature in Acrobat 5. In Acrobat 6 the message didn't appear, but + the find and text select features were unavailable. The problem appears + in the following two situations: + + - TrueType fonts with subsetting enabled, autocidfont=false, an encoding + which contains at least one glyph outside of Adobe's Standard Latin + list, and less than ca. 90 different characters are used in the document. + + - TrueType fonts with subsetting enabled, autocidfont=true (which is the + default), and the number of different characters used in the document + is less than one third of the number of glyph IDs in the font. + +- PDI didn't accept PDFs with the entry "/Count 0 /Kids []" in a /Pages + node, although these are generated by some PDF creators, and are not + explicitly prohibited by the PDF reference. Now such nodes are ignored. + +- Reject BMP, JPEG, PNG, and TIFF images with more than one color component + when the "mask" option is supplied (since masks must be 1-channel images), + and allow GIFs as soft masks for compatibility with PDF 1.4 and above. + +- Changing the "wordspacing" parameter didn't work correctly when the + "topdown" parameter was set to true. + +- The space glyph could be missing from a generated font subset if glyphs + which are not present in the font were substituted with a space, and + the subset didn't yet contain any space character. + +- Implements the "preserveoldpantonenames" parameter which preserves + old-style Pantone spot color names instead of converting them to the + equivalent new names. + +- Introduces a compile-time switch (PDF_WIN98) which allows building a + version for Windows systems without full Unicode support (Windows 95/98/ME). + This affects only the host font feature, and replaces the Unicode- + compatible font name scheme with an ASCII-only scheme. Therefore, + Japanese host font names are not supported with such a special build. + +- Images with wrong color spaces for PDF/X didn't obey the "imagewarning" + parameter or option, i.e. they always triggered an exception instead of + returning -1. + +- Ignoring embedded ICC profiles in JPEG images with the "nohonoriccprofile" + option didn't work, i.e. an ICCBased color space was generated nevertheless. + +- JPEG images with an APP2 marker other than ICC (e.g. FlashPix) could + result in damaged PDF output since JPEG markers of the embedded + thumbnail image could get confused with markers of the full image. In + particular, this affected the width and height entries, resulting in + bad pixel size entries in the generated PDF. + +- The "spot" color space for the fillcolor and strokecolor options of the + PDF_fill_*block() functions didn't work properly. + +- The PDF_fill_*block() functions didn't place the block border and background + correctly when "topdown" was true. + +- Exceptions thrown by functions which optionally return -1 in case of + failure would erroneously be logged as -1 (instead of the real exception + number) in the PDFlib trace. + +- Fixes a buglet in the pdfimage.c sample program. + +- Use internal printf() replacement for the trace feature to avoid problems + with NULL string arguments. Otherwise in rare cases the trace feature could + cause a crash in some environments, particularly with non-GCC compilers. + +- Modified generation of font name prefixes for subset fonts to ensure + identical behavior on all platforms (only relevant for comparing files, + but not relevant to users). + +- Removed inappropriate EBCDIC conversion of the Trapped DocInfo key. + +- On Windows PostScript Type 1 host fonts can be used with "iso8859-1" and + "unicode" encoding in addition to "winansi". + +- PostScript Type 1 host fonts couldn't be embedded on Windows. This situation + even resulted in an empty error message string and a bad -1 exception number. + The exception was issued within PDF_close(), and not within PDF_load_font(). + +- Works around an error message issued by Acrobat in a very rare font-related + situations. All of the following conditions must be true to trigger the + error message: + - Acrobat 6 (but not any earlier versions) + - OpenType font with PostScript outlines + - subsetting enabled + - 8-bit encoding + - character code maps to Unicode (via the font's cmap), but the CFF + table does not map the code to a glyph name, so that the font's .notdef + character (=glyph id 0) will be displayed + + To solve this PDFlib now always includes glyph id 0 for TrueType and + OpenType subsets. + +- On EBCDIC platforms the "userpassword" and "masterpassword" parameters and + option weren't properly converted to ASCII before applying them. + +- Fixed a glitch related to freeing TrueType font names on EBCDIC platforms. + + +Bindings +======== + +- C, Perl, Python, PHP + - Explicitly set the "hypertextencoding" parameter in the samples + in order to avoid problems with winansi-encoded text for PDF_set_info() + on Japanese systems. + +- C + - Changed the silent/verbose handling in the pdflibdl.c module so that + error messages can be disabled from the compiler command line by + supplying -DPDF_SILENT. + + - Reworked the DLL loading mechanism since it couldn't be used with + PDF_TRY/PDF_CATCH, and fixed a bug which went unnoticed (storing the + DLL handle in the read-only API structure). + +- C++ + - Changed the throw statements in pdflib.hpp to the stricter + PDFlib::Exception instead of Exception. + + - Added a version test to the C++ wrapper to check for the PDFlib version + loaded from an external library. This means that an external PDFlib + DLL/shared library must provide an exact match of major/minor/revision + number. Otherwise the C++ wrapper will refuse to work. + + - Fixed a wrong throw statement in the C++ wrapper. + +- COM + - Changed the GUID because functions have been removed. As a result, + applications should be re-compiled against the new version provided + early binding is used. + +- Java + - PDF_get_parameter() and PDF_get_pdi_parameter() didn't apply proper + EBCDIC processing to the returned strings. + +- Tcl + - Adds instructions on how to build a binary for Tcl 8.3 and above on + Mac OS X. This also involved a minor extension in the Tcl wrapper code. + +- Python + - The Python wrapper for PDF_create_pvf() incorrectly assumed simple strings + for the data argument instead of binary strings. + + +Build system, packaging and platforms +===================================== + +- The host encoding feature (pulling encoding via the iconv() facility + was disabled on MVS due to a glitch in the preprocessor statements. + +- Adds documentation on how to build PDFlib from source code with MS Visual + Studio .NET. This also involved a few changes in the structure of the + VS 6 project files on which the build process with VS .NET is based. + +- Minor changes for IA64/Itanium compatibility. + +- Minor tweaks for OpenVMS compatibility. + +- Fixed a few warning is libs/tiff and bind/pdflib/tcl for gcc 3.3 on + Mac OS X. + +- Reworked the build system to facilitate the use of makefiles on platforms + where the configure script is not available, such as OpenVMS, or Windows + with a command-line compiler. + +- Various minor bugfixes for EBCDIC systems. + +- "make install" didn't work with PDFlib Lite and PDFlib source code packages + on Unix systems due to a minor glitch in the main Makefile. + + + +================================= +PDFlib 5.0.2 (September 16, 2003) +================================= + +New features +============ + +- Font names can be supplied as Unicode to PDF_load_font() in the C, C++, + COM, Java, and .NET bindings. This is useful when access to localized + host fonts on Windows is required, such as on Japanese localized systems. + In the C interface the len parameter must be supplied to trigger this + new Unicode feature. + +- Extends the font machinery so that fonts with non-English names can be + found as host fonts on localized Windows systems, which is especially + useful for using Japanese host fonts on Japanese systems: Unicode font + names can be supplied in UTF-8 format with BOM to PDF_load_font() and + the second part of a HostFont configuration line. The font name will be + converted to UTF-16 LE, and host fonts with this name will be found. + This scheme also works for TTC font files. + +- Implements the "vdp/blockcount" key for PDF_get_pdi_value(). + +- Facilitates the detection of bad font options supplied by the client as + follows: when the fontstyle or monospace options in PDF_load_font() were + supplied for fonts which don't allow it, the function raised an exception + (if the fontwarning option or parameter was true), or silently ignored the + option (if fontwarning was false). In both cases it was impossible for the + client to find out the cause _and_ continue generating his PDF output, + possibly with a different font. Now PDF_load_font() returns with a -1 error + code in this situation when fontwarning is false. Thanks to the new support + for requesting message strings after a failed function call the client can + find out the reason of the failure. + +- When an API function fails with a -1 error return code the message string + containing the reason and the error number (which would be visible in an + exception if the various warning parameters are set) can now be retrieved + with PDF_get_errmsg(), PDF_get_errnum(), and PDF_get_apiname(). All + examples demonstrate how to use this feature, which results in much more + useful error messages. + +- Makes the trace feature public (parameters "trace", "tracefile", and + "tracemsg"). + +- Implements the "monospace" option for PDF_load_font() to facilitate + metrics calculations with CJK fonts for applications which do not + require sophisticated typography. + +- Re-implements "pdistrict" as a global parameter and option for PDF_open_pdi(), + PDF_open_pdi_callback(), PDF_open_pdi_page(), and PDF_process_pdi(). If + true, certain flavors of malformed PDF which may result in non-conforming + PDF output are rejected upon import. This affects only certain very rare + flavors of illegal PDF. Default is false. + + +Workarounds for Acrobat 6 problems +================================== + +- Link borders didn't display properly since optional keys in the border style + dictionary are apparently required by Acrobat 6. + + +Bug fixes and minor improvements +================================ + +- PDF_stringwidth() incorrectly took wordspacing into account even in + situations where it doesn't apply, such as unicode, glyphid, non-AGL + encodings, or subsetting. + +- The "colorize" feature didn't work for GIF images, palettized PNG, palettized + TIFF, and palettized BMP images (for images with a color palette it is only + reasonable for pure grayscale images anyway). + +- When using hypertext functions with PDFlib Lite on localized CJK Windows + systems in a non-Unicode capable language (including C, C++) resulted in + an exception "Unicode ... not supported in this configuration". + +- Allows "builtin" encoding for TrueType and OpenType fonts even if + the entries in the OS/2 table of the font are incompatible with its + cmap table. + +- Disables font subsetting for TrueType and OpenType fonts if the font has + been subset already, as determined by a "+" sign at byte 6 (zero-based) + in the font name. This is a precaution against problems with double- + subsetting fonts. + +- Fine-tuning and bugfixing in the Unicode handling: + + - UniJIS-UCS2-HW-H/V are now implemented as UCS-compatible CMaps which means + they can now be used in Unicode-capable bindings, and BOMs will be + properly processed. While PDF_stringwidth() still returns a width of 0, + the monospace, charspacing, and wordspacing options will be honored so + that the length of text can be calculated where all glyphs have a width + of 500 or 1000. + + - UTF-8 BOMs will be detected in text and hypertext strings if + [hyper]textformat = auto and hypertextencoding is not an 8-bit encoding. + + - Fixed an obscure bug in the UTF-8 string conversion code which resulted + in erroneous "illegal UTF-8 sequence" exceptions. + + - If hypertextformat = utf16* and hypertextencoding != 8-bit encoding + (i.e. empty or "unicode") hypertext strings were converted wrongly. + + - If hypertextformat = bytes and hypertextencoding = 8-bit encoding hypertext + strings were not converted into the supplied encoding at all. Hypertext + containing non-Latin-1 characters was converted wrongly. + + - In Unicode-capable bindings hypertext was converted wrongly for + hypertextencoding = 8-bit encoding if it contained Latin-1 characters. + +- The "fontname" parameter now returns the internal name of a TrueType + or OpenType host font, and not the font name supplied to PDF_load_font(). + +- The "font" and "fontsize" options of PDF_fill_textblock() could only + be provided in tandem. However, it also makes sense to provide only + a font handle in the option list, and take the fontsize property from + the block definition. + +- Improved PDF/X-3 generation for compatibility with validation tools: + - Creates the /Info key in the OutputIntents dictionary. This key is + optional according to the PDF reference, but PDF/X-3 Inspector and + Acrobat 6 Preflight apparently require it (possibly caused by the + older Adobe Technical Note 5413 which says it is required). + - The /RegistryName key was misspelled as /Registry. + +- Removed the check of the supplied PostScript font name against the one + found in the PFM or AFM file. This allows the client to use an arbitrary + alias name for a PostScript font instead of the exact internal font name, + which is often hard to determine. + +- The length of strings passed to PDF_stringwidth() is no longer limited. + +- Disallows "." and ".." as file names. + +- Fixes bugs in the coordinate handling when the "topdown" parameter was true: + + - Positive charspacing values moved characters to the left instead of to + the right. + + - PDF_fit_textline() and PDF_fit_image() could place text or images in + wrong positions for certain combinations of the "position" and "fitmethod" + options. + +- EBCDIC-conversion and sorting of destination names was carried out + in the wrong order, which may have resulted in an unsorted list on + EBCDIC platforms. + +- Silently ignore duplicate destination names supplied to PDF_add_nameddest() + instead of throwing an exception. + +- Detect and reject JPEG images with multiple scans per frame since these + are not supported in Acrobat ("missing data for an image" in Acrobat 6, + wrong colors in earlier versions). + +- Added a validity check to detect malformed UTF-16 strings, and throws an + exception for UTF-16 strings containing an odd number of characters. + +- PDFlib Lite crashed when a UCS2 CMap was supplied for one of the standard + CJK fonts. + +- PDFlib could crash when invalid syntax was supplied for a color option + in one of the PDF_fill_*block() functions. + +- PDF_arc() and PDF_arcn() generated incorrect output for certain angles + when the topdown parameter was set to true. + +- Ignores leading @ character (Windows notation for vertical fonts) when + searching for host fonts on Windows. + +- Disallows applying the "fontstyle" option to PDF core fonts. + +- Improves PDF_add_nameddest(): + - Parameter checking for the "name" parameter was missing. + + - Due to a typo writing the /Limits entry for destination names could result + in a crash, depending on the length of the first and last (alphabetically) + destination names. + +- PDI erroneously converted Unicode document info strings on EBCDIC platforms, + which could result in wrong strings returned by PDF_get_pdi_parameter(). + +- PDF_open_pdi_callback() couldn't open encrypted documents even if the + proper master password was supplied. + +- Fixed a crash which could happen in very rare situations: a TrueType or + OpenType font was loaded as a virtual file, but didn't contain the + requested font. In this case PDFlib would crash while trying to raise + an exception. This is highly unlikely to occur in real-world applications, + though. + +- On Mac OS the Carbon build of PDFlib Lite didn't link because of a missing + helper function (FSPathMakeFSSpec). + +- Improves the logic for finding the "proper" internal name of TrueType and + OpenType fonts. Previously certain Japanese fonts (like those contained in + dfjhsmw3.ttc) couldn't be processed because PDFlib expected the internal + PostScript name which is usually not known to the user. For OpenType fonts + this also fixed the bug that the /FontName key in the PDF name didn't + contain the font's PostScript name, but rather its TrueType name. However, + Acrobat accepted these font dictionaries nevertheless. + +- Using textformat utf8 could potentially result in a crash. + +- Due to a missing initialization palette entries for PNG, TIFF, or BMP images + could be wrong in rare circumstances when many similar palettes were used. + +- On Windows unknown encoding names with more than four characters have + not been rejected, but instead interpreted as the system code page. + +- Added code for detecting EFAX TIFF files (*.jfx) which have a directory + count of 0. + +- PDF_load_image() could crash with the option "reftype url" and parameter + imagetype = raw. + +- Using CID fonts on EBCDIC platforms resulted in bad PDF output because + the /Registry and /Ordering strings haven't been converted to ASCII. + +- In rare cases PDI would seek one byte beyond EOF when using the + PDF_open_pdi_callback() interface. + +- The "filename" option in "bookmarkdest" parameters and option lists didn't + get proper EBCDIC treatment. + +- The "scale" option for PDF_fit_image() and PDF_fit_pdi_page() didn't allow + negative scaling factors. + +- The left margin for PDF_continue_text() has been reset by underlined text. + +- Text positioning could be wrong (text placed at (0, 0)) when a text output + sequence was interrupted by save/restore. + +- PDI could not read PDFs with indirect objects in the OutputIntents array. + Ironically, this affected PDF/X files generated with PDFlib. + +- Some glyphs in a TrueType or OpenType font could get missing or wrong widths + in a PDF output, resulting in overlapping text or bad character spacing. + This occurred only in a very rare combination of conditions including + active font subsetting, several contiguous glyphs having a width of 0, and + some interaction with parameters of the space-saving algorithm for generating + the glyph widths array. + +- The timezone entry in the document info could be off by one minute in + some cases due to a rounding/truncation problem. + +- Kerning pairs and values were wrong for encoding "glyphid" in TrueType + and OpenType fonts. + +- Some kerning pairs in TrueType and OpenType fonts could get lost. This + happened when at least one of the kerned characters used a glyph id + which was mapped to multiple Unicode values in the font. Most importantly, + a glyph which was mapped both to space and no-break space characters + wouldn't kern. + + +Bindings +======== + +- All + - Added wrappers for the PDF_get_errmsg(), PDF_get_errnum(), and + PDF_get_apiname() functions. + +- C++ + - A systematic bug in the C++ wrapper resulted in excessive memory usage. + Although the memory was not leaked, memory requirements could be + considerably higher than in other bindings. + +- Cobol + - Adds the PDF_get_buffer() wrapper function. + +- COM + - Removed the wrappers for the deprecated functions PDF_setgray*() and + PDF_setrgbcolor*() in order to reduce the total number of API functions + in the COM wrapper. + +- .NET + - Adds an alternate DLL edition of the PDFlib .NET binding in order to + work around the .NET framework bug which thwarts use of the standard + PDFlib .NET edition with ASP.NET. + + - The reason for failed file operations (access denied, file not found, + etc.) could be wrong in an unpredictable manner due to different + implementations of the Windows GetLastError() function in managed vs. + unmanaged code. + + +Samples +======= + +- All samples in all language bindings: + Use new method of retrieving detailed error information after a PDFlib + function call failed even when no exception was thrown. + +- C samples: + - removes a few stray references to stderr. + +- C clients: pdfimpose + - Added the -v option for specifying the PDF output version number + +- C++ + - Replaced the deprecated overloaded PDFlib method open() with the standard + open_file() in the samples. + +- COM + Added exception handling to the VBS/ASP and VB samples. + + +Build system, packaging and platforms +===================================== + +- Introduces disk images (.dmg) for Mac OS. + +- Adds a configure option for building xplinked binaries on zSeries. + +- The C++ binding is enabled for PDFlib Lite by default in the configure + script. It can still be disabled by using "configure --disable-cpp" in + case of problems with the local C++ compiler. + +- Always uses config/install-sh for installing files instead of a system- + supplied install tool which may be present. + +- Adds a version for OpenVMS. + +- Adds a workaround for an incompatibility between older and newer versions + of glibc. Most prominently, the problem was present on RedHat 9 systems + which was the first Linux distribution to use the newer glibc version + by default. + +- Switches the iSeries build to Terraspace malloc to work around the 16MB + restriction of the standard malloc (requires V4R5 or above). + +- Updated the project files to CodeWarrior 8. + +- Mac OS X + Added code for dynamically loading the PDFlib shared library at runtime. + +- The grid.pdf helper file was missing from all packages. + + +=========================== +PDFlib 5.0.1 (May 27, 2003) +=========================== + +New features +============ + +- Special handling for ZapfDingbats font in block definitions: for this + font encoding "builtin" is always used. + +- Support for EUDC fonts created with Microsoft's eudcedit.exe tool (*.tte + fonts). This involved minor modifications to the TrueType name table + entry selection logic. + +- Implements the "glyphwarning" parameter which controls PDFlib's behavior + for characters which are missing from a font. + +- Additions to block processing: + - Implements block property overrides through the option lists of + all PDF_fill_*block() functions. In addition "font" can be used + to supply a font handle instead of a font name via "fontname". + + - Implements the "auto" keyword for the "fitmethod" property. + + - Implements the "fontstyle" property in PDF_fill_textblock(). + + - Implements the "fontwarning" option in PDF_fill_textblock(). + + - Implements the "imagewarning" option in PDF_fill_imageblock(). + +- Implements the new keyword "auto" for the "fitmethod" option + of PDF_fit_image(), PDF_fit_textline(), and PDF_fit_pdi_page(). + +- Implements the "color", "fontstyle", and "filename" options for the + bookmarkdest parameter. + +- Implements the "fontstyle" option in PDF_load_font() for artificial + bold and italic styles with TrueType and OpenType fonts. + +- Accepts the following spot color name suffixes in Pantone color names + for compatibility with previous versions of the Pantone libraries: + CV, CVC, CVP, CVU, CVV. + This allows for better spot color name compatibility with old applications + which implement the old Pantone names, such as Adobe Illustrator 8. + + +Bug fixes +========= + +- Two glyph IDs from the MingLiu TrueType font cannot be used. Instead of + complaining about "corrupt TrueType font" PDFlib now issues a warning, + and replaces the problematic glyphs with glyph ID 0. + +- Type 1 text fonts with a PFM file cannot be used with "builtin" encoding, + so this encoding is changed to "winansi". However, if the same font/encoding + combination is requested again later it won't be found in the cache due to + the adjusted encoding. This behavior has been changed so that the font will + now be found, instead of allocating a new font and (potentially) embedding + the same font multiply. + +- Jumping out of a page description sequence could result in a wrong error + message "Compression error (deflateEnd) ". This could be provoked in C, + but mainly affected Java clients when a Java exception was thrown by + the client, and PDF_delete() called upon cleanup. + +- Encryption didn't work properly on 64-bit architectures with 32-bit integers. + +- Due to a triple error working with default gray/RGB/CMYK color spaces + was not possible in PDF/X-3 mode: PDFlib wrongly complained about missing + default color spaces even if they were set. + +- Fixed a memory leak in PDI when a page was used multiply. + +- CID fonts (including the standard CJK fonts) generated corrupt PDF output + when encryption was used. + +- Fixed a typo in the CJK metrics data array which had nasty consequences: + + - PDF output for MSungStd-Light-Acro had two /W arrays, which may result + in wrong glyph widths. + + - PDF output for STSongStd-Light-Acro didn't include any /W array, resulting + in wrong glyph widths. + +- The "kerning" property didn't work in PDF_fill_textblock(). + +- The option list parser could erroneously complain "option Y not supported + for PDF version 1.X" although the option actually should be supported. + +- Fixed a scaling bug with multi-strip TIFF images: the scaling factors + of the first and last strip were exchanged. As a result the height of + the top-most strip was reduced, and the height of the bottom-most strip + was increased, which in turn shifted all image strips to the top. + +- Fonts contained in TrueType collection (.ttc) files didn't work as host + fonts on Windows due to a bug in a Windows GDI function (confirmed by + Microsoft). A workaround suggested by Microsoft technical support now + allows proper access of TTC fonts as host fonts. Previously these triggered + a message "Corrupt font file". + +- Fine-tuned the TrueType cmap selection logic in order to properly + process some unusual barcode fonts, and fix an obscure bug: + + - Fonts which only contained a (1, 0) (= Mac) cmap could not be used with + "glyphid" or "unicode" encoding. + + - Fonts with an empty (3, 1) (=Windows) cmap and a (1, 0) (=Mac) cmap + could not be used with "macroman" encoding. + +- The encoding entries for Type 3 fonts used the names of predefined + encodings (such as WinAnsi), which triggers a bug in Acrobat. We now + always write the encoding vector explicitly to work around the Acrobat bug. + +- The sample upr file distributed with all packages didn't list all + possible resource categories at the beginning, leading to problems + when it was extended for more category sections. + +- An incorrect exception "Corrupt TrueType font file" was thrown when + all of the following conditions were true: + - A TrueType font had a certain format 4 cmap property (idRangeOffset = 65535) + - Encoding "unicode" or "glyphid" was requested + - Character code 65535 was supplied. + +- The positioning of contents placed with any of the PDF_fill*() functions + was wrong for block PDFs with either a /Rotate key other than 0, or a + CropBox or MediaBox with an origin other than (0, 0); + +- The "pdiusebox" parameter and option were not implemented (PDI). + +- The font names for TTC fonts can be specified with space characters as + well as with hyphen characters as separators for the name parts + (e.g., "MS-Mincho" as well as "MS Mincho"). + +- PDF_stringwidth() returned the wrong widths (i.e., not the width of the + space character) for characters in a Type 1 font when both of the following + conditions were true: + + - Encoding "unicode" has been supplied to PDF_load_font(). + + - The glyph name resulting from mapping the Unicode value via AGL is + not contained in the font, or AGL does not contain any entry for this + Unicode value. + +- Fixed a bug in the timezone generation for the ModDate and CreationDate + entries which occured for rare combinations of time zone and date. + + +Bindings +======== + +- All Unicode-capable bindings: COM, Java, .NET, Tcl + + - Setting the "Trapped" document info key didn't work because of a + wrong check for allowed values. + + - Using the UniJIS-UCS2-HW-H/V CMaps resulted in a wrong error message + "Using 'UCS-2' encoding instead of 'UniJIS-UCS2-HW-V' for font" + although these CMaps are actually UCS-2 compatible. + + - Characters outside of Latin-1 did not work with show_boxed(), but were + replaced with space or .notdef characters. Since show_boxed() does not + support Unicode strings this has been cured by a new Unicode-capable + function PDF_show_boxed2() in the core. All Unicode-capable wrappers + use this new function. + + - Carriage return and linefeed characters did not work in show_boxed(). + + +- .NET + + - The "SearchPath" feature didn't work due to a dysfunctional Windows + .NET API method. + + +- PHP + - Exception strings included the error number and API name twice. + + - Synchronized ext/pdf/pdf.c with the current PHP CVS version (1.112.2.5). + + - PDF_get_value(p, "font", 0) returned an incorrect value for the font + handle because the handle adjustment code was missing. + + +Packaging +========= + +- COM and .NET installer + - Added the registry template pdflib.reg. + + +Samples +======= + +- businesscard: changed the value of the "fitmethod" option to "auto" + wich is more appropriate for this kind of application. + +- businesscard: added the "pdiwarning" option to facilitate problem analysis + when fonts are missing. + + +============================= +PDFlib 5.0.0 (March 31, 2003) +============================= + +New features, Changes, and Bug Fixes +==================================== + +- Too numerous to list here, see the manual for a list of new features + in PDFlib 5. + +- Major changes in the build environment, and a complete rework of the + source code tree. diff --git a/src/libs/pdflib/doc/pdflib/changes4.txt b/src/libs/pdflib/doc/pdflib/changes4.txt new file mode 100644 index 0000000000..abd392746d --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/changes4.txt @@ -0,0 +1,3589 @@ +This file documents changes up to PDFlib 4.0.3. +Changes in later versions are documented in a separate file. + + +V4.0.3 (June 20, 2002) +====================== + +Bug fixes and enhancements +========================== + +- PDF_show_boxed() erroneously applied user-defined wordspacing if + another show function had been called before PDF_show_boxed(). This + could result in text running beyond the right margin of the box + (p_text.c). + +- Annotations erroneously were colored black instead of the selected + color when PDF_set_border_color() was called with (0, 0, 0) arguments + near the end of a page; similarly with PDF_set_border_style() (p_annots.c.). + +- Implemented parameter checks for negative values of linejoin + or linecap (p_gstate.c). + +- Implements a workaround for bad entries in PFM metrics files which + otherwise would result in an Acrobat error message (p_pfm.c). + +- Additions to the parameter handling (p_params.c, p_params.h): + + - Implemented the "pagewidth" and "pageheight" parameters for PDF_get_value(). + + - Implemented the "scope" parameter for PDF_get_parameter(). + + - Relaxes the scope of the currentx/currenty parameters to also include + scope path (p_params.h). + +- Implements the "colorize" parameter for GIF images. Although this + works for all GIFs it is really only meaningful for grayscale GIFs + in which the palette index equals the gray value for all elements + of the colormap (p_gif.c, p_image.c). + +- Avoids problems with duplicate spot color definitions: PDFlib didn't + catch multiple definitions of the same spot color name with different + color definitions. Now the same handle is returned for any subsequent + attempt at defining the same color name with PDF_makespotcolor() + (p_color.c). + +- Added the Acrobat 5 CJK fonts to the list of known CJK fonts (p_cid.h). + +- Finetuning in the TrueType engine (p_truetype.c, p_truetype.h): + + - Detect and properly reject Apple bitmap TrueType fonts. + + - Accept TrueType fonts with a format 65535 name table. This format is not + documented in the specs but is nevertheless used by some Apple fonts. + + - Amends the TrueType parser so that the OS/2 table is no longer required. + If it is missing the required information is pulled from other tables. + This was necessary to accommodate some Apple fonts which do not contain + any OS/2 table. Fonts with an OS/2 table but zero entries in it are + now detected and correctly handled. + + - TrueType fonts with a format 6 cmap with more than 256 entries were + incorrectly rejected. This was caused by the new cmap 6 code introduced + in PDFlib 4.0.2 which incorrectly assumed that cmaps with format 6 + never contain more than 256 entries. Previously this kind of cmaps + wasn't read at all (p_truetype.c, p_truetype.h). + + - Fixed a memory leak in the TrueType handling. This bug has actually + already been fixed before the 4.0.2 release, but the entry was omitted + from the change log (p_truetype.c). + +- Avoids the Acrobat message "Unable to find or create the font. Some + characters may not display or print correctly" for fonts which are + not embedded and use macroman or ebcdic encoding (p_font.c). + +- 1-bit uncompressed TIFF images with PHOTOMETRIC_MINISWHITE + erroneously got inverted (bug introduced in PDFlib 4.0.2 with + the compression fix for uncompressed TIFF images). + +- TIFF images which didn't contain the required StripByteCounts Tag could + provoke an out-of-memory situation. This was caused by a bug in TIFFlib + which failed to calculate the proper file size in an attempt at + estimating the missing StripByteCounts value (tiff/tif_unix.c). + +- Fixed a few bugs on EBCDIC platforms: + - spot color names were treated incorrectly (p_color.c). + + - Added several EBCDIC conversions for hypertext items as a convenience + for EBCDIC developers (p_annots.c). + + - Added EBCDIC conversion of fileref and url for PDF_open_image() + (p_image.c). + +- Fixed a problem with spot colors: setting "both" colors or "stroke" + color to the same as the current "fill" color didn't actually + generate the required color values due to some bad optimization (p_color.c). + +- The value of the /Subtype key for embedded files (PDF_attach_file()) + had been written as a string instead of as a quoted name. This went + unnoticed because Acrobat doesn't actually use this value (p_annots.c). + +- Slightly modified the zlib sources to improve portability (flate/*). + +- Fixed a bug related to custom memory management functions in TIFFlib. + This bug resulted in a crash when PDFlib was used with PHP on OS X + and possibly other environments, too (tiff/tif_open.c). + +- The tests for the values of CropBox and the other *Box entries were + too strict, and allowed only positive values (p_params.c). + +- Rewrites the code for setting the Mac file type and creator to be Carbon- + compatible, and enables it under OS X (p_basic.c). + +- Adds support for Mac-style resource-based PostScript Type 1 fonts, + also known as LWFN fonts (p_font.c). + +- Adds host font support on the Mac using the Carbon API, currently + only for TrueType and OpenType fonts (p_font.c). + +- URLs and filenames used in PDF_add_weblink(), PDF_add_launchlink(), + PDF_add_pdflink(), and PDF_attach_file() didn't get quoted correctly. + This could result in bad PDF output in rare occassions, e.g., when + unbalanced parentheses occurred in an URL (p_annots.c). + +- 13 #defines for renaming PNG functions were missing, which resulted + in an incompatibility when PDFlib was linked against a program which + another instance of libpng, version 1.2.1 (png/pngconf.h). + +- PDF_add_pdflink() generated wrong output for the destination page + (a local object reference instead of a page number). This resulted + in incorrect PDF output (which Acrobat happily digested nevertheless), + and the target PDF always being opened on the first page (p_annots.c). + +- PDF_add_pdflink(), PDF_add_launchlink(), and PDF_attach_file() resulted + in a file specification with the wrong /FileSpec key instead of /Filespec. + This went undetected for a long time since Acrobat accepts both flavors, + although only /Filespec is correct according to the reference (p_annots.c). + + +Bindings +======== + +- C: + - Introduces auxiliary functions and modules for using PDFlib as a DLL, + and loading it dynamically at runtime (explicit linkage): + - PDF_get_api() function for retrieving function pointers (pdflib.h, + p_basic.c). + + - A module for loading the PDFlib DLL at runtime, and retrieving + API function pointers in a structure (bind/c/pdflibdl.c/h). + +- Java: + - Searches for JDK 1.4 (configure.in). + + - Removes the EBCDIC conversion of Unicode strings supplied by the + client (pdflib_java.c). + + - p.add_note with Unicode contents resulted in a core dump due to a + missing conditional in GetStringUnicodePDFChars() (pdflib_java.c). + + - No longer exit() if the PDFlib DLL cannot be loaded, but rethrow + the UnsatisfiedLinkError. In addition, the value of the java.library.path + property is printed (pdflib.java). + + - Finetunes the Java context pointer and cleanup machinery (pdflib.java, + pdflib_java.c): + + - Calling the delete() method multiply resulted in a crash. + + - Now it is allowed to call delete() multiply. + + - Attempting to call methods other than delete() after a call to delete() + will raise an exception. + + - Increased the supported maximum number of Java threads on the AS/400. + + - The wrapper functions for get_buffer() and setpolydash() crashed + on the AS/400 because a required macro was missing (pdflib_java.c). + + - The wrapper function for get_parameter() was missing a call to + ReleaseStringPDFChars() (pdflib_java.c). + +- PHP: + - PDF_open_image() didn't work with a "memory" parameter (pdf.c). + + - Minor modifications for PHP 4.2 (pdf.c). + + - PDF_get_value() and PDF_get_parameter() can be called without a PDF + object for the parameters minor/major/revision/version/pdi (pdf.c). + + +Build process and platform support +================================== + +- Fixes a bug which resulted in garbage data being read for certain + data files (fonts and images) (p_config.h, p_util.c). + +- Fixed a buglet related to installing pdflib-config to a non-existing + bin directory (Makefile.in). + +- Fine-tuned the #defines for MVS and OS390 (png/pngconf.h, p_intern.h, + p_config.h, p_util.c, p_font.c). + +- Renamed tiff/tif_aux.c for better compatibility with our internal + processes for MVS (tiff/tif_auxx.c). + +- Added support for building PDFlib as a shared library on the Mac (pdflib.h). + +- The configure script didn't work on Mac OS X (configure.in) + +- Added "all" targets to the CodeWarrior project files (*.mcp). + +- The CodeWarrior test project file contained a few wrong output paths for + the Mac projects (PDFlib-test.mcp). + +- Changed all CodeWarrior Mac targets to use the Carbon library. This + is mainly useful for the Mac host font feature, and will ease the + transition to CW 7 (*.mcp). + +- Reworked the handling of platform-specific preprocessor symbols on the Mac. + + +V4.0.2 (February 01, 2002) +========================== + +Bug fixes and enhancements +========================== + +- The color of attachment icons wasn't written to the output file. This + was especially evident in Acrobat 5 since the default color has been + changed from blue to gray (p_annots.c). + +- Long link targets with the functions PDF_add_pdflink, PDF_add_launchlink(), + PDF_add_weblink(), and PDF_attach_file() could result in a buffer overflow + due to incorrect use of pdf_printf() (p_annots.c). + +- Added special handling for the /Trapped info key (p_hyper.c). + +- Improves CMap support (p_cid.h): + + - Adds several new CMaps for use with Acrobat 5 (GBKp-EUC-H/V, GBK2K-H/V, + HKscs-B5-H/V). + + - Introduces PDF version checking for CMaps since not all CMaps + are supported in all Acrobat versions. + +- Adds an MD5 digest for the /ID string in the PDF output (p_md5.h, p_md5.c). + +- The resolution values returned for PNG images were wrong, since PDFlib + failed to convert the values returned by libpng from pixels per meter + to pixels per inch. Similarly, aspect ratios weren't returned correctly + for PNG images (p_png.c). + +- CCITT-compressed images could result in bad PDF output on big-endian + machines due to a missing cast. The problem did not affect page display + in Acrobat, but PostScript printing (p_image.c). + +- Resets all graphics state parameters to their default values before + placing templates if the new "inheritgstate" parameter is set to + "false". Note: this will be the dafault behavior in future versions + (p_image.c, p_gstate.c). + +- Optimizes content streams by eliminating redundant graphic state + parameters. Setting a parameter to its current value is now a no-op + (p_gstate.c, p_color.c). + +- Relaxes the scope of PDF_makespotcolor() and PDF_setcolor() to also + include document scope (p_color.c, p_basic.c). + +- Fine-tunes transparency and image masking support (p_image.c, p_tiff.c, + p_jpeg.c, p_png.c, p_color.c): + + - Implements the "colorize" parameter for images. + + - Supports the "mask" parameter for TIFF images. + + - Implements the placing of images which have been opened with the + "mask" parameter (as opposed to using them as a mask for another + image). The image will have the current fill color applied to it. + +- Add the /Type key for form XObjects. This key is optional according to + the PDF reference, but is actually required by some brain-damaged + PDF-capable RIPs (p_template.c). + +- PFM processing (p_pfm.c): + - The PFM reader accepts PFM files with a bad length entry in the + header since such files actually exist. + + - The name of the offending file is included in the error message when + a bad PFM file is rejected. + +- Removed a redundant comment line with a superfluous version number + which was written to the PDF output in PDF 1.4. compatibility mode + (p_basic.c). + +- Implements and documents strict scope checking for all parameters + (p_params.h). + +- In rare cases pdf_printf() could produce "-0" output for very small + negative values, which didn't cause any harm but was redundant (p_stream.c). + +- Enhancements in the code page tables (fonts/*): + + - Removed some garbage at the end of code page 1252. Accidentally winansi + encoding has been suffixed to the 1252 codepage file, but this data + has been ignored anyway (fonts/cp1252.cpg). + + - Adds code page definitions for ISO 8859-13, -14, and -16. Note that + ISO 8859-14 doesn't completely work in Acrobat since it uses characters + outside the Adobe Glyph List AGL (iso8859-13.cpg etc.). + + - Changes positions 0xA1 and 0xA2 in the ISO 8859-7 code page to the + correct left and right quotation characters (iso8859-7.cpg). + + - Changes position 0xF0 in ISO 8859-2 code page from U+00F0 = eth to + U+0111 = dcroat (iso8859-2.cpg, iso8859-2.enc). + + - Adds U+200E and U+200F at positions 0xFD and 0xFE in the ISO 8859-8 + code page (iso5589-8.cpg). + +- Reads resolution information from JPEG images generated by Adobe Photoshop + (p_jpeg.c). + +- Changes and improvements in TrueType/OpenType handling (p_truetype.c): + + - Accepts fonts where the names[6] entry in the name table is missing, + and substitutes names[4] instead. + + - Supports OpenType fonts with PostScript outlines (OTF, aka CFF fonts). + + - Supports cmap table format 6 which is used for the Mac encoding of + Adobe OpenType fonts. + + - The quoting functions for PDF names didn't correctly quote the special + characters (, ), /, <, >, [, ], {, }, %, and #, which may occur as part + of spot color names or (in rather obscure cases) as part of TrueType font + names (p_util.c). + +- Changes and bug fixes in the text engine (p_text.c): + + - Fine-tunes the behavior of PDF_stringwidth() (p_text.c): + + - Increased the number of encodings which can be used simultaneously + in PDFlib in order to facilitate testing (p_intern.h). + + - Extends the scope of PDF_stringwidth() to path and document. + + - Includes the last character's charspacing amount in the calculation + of the complete stringwidth. + + - Removes the projected text rise adjustment from the stringwidth + calculation, since it only affects the position of the rendered + text, not its length. + + - The textrise, horizscaling, charspacing, and wordspacing can now + be set in document scope, and will be reset at the end of pages. + + - PDF_show_xy(p, text, 0, 0) didn't work if the previous text position + was different from (0, 0). + + - PDF_show2() didn't correctly implement overline mode. + + - Fixed a bug in PDF_show_boxed() where initial characters could get + lost (p_text.c). + + - Fixed a bug in PDF_show_boxed() which could result in an exception + with the message "floating point value too large in pdf_ftoa" (p_text.c). + + - Implements an unsupported PDF_encoding_get_char() function for + querying glyph names from an encoding vector (p_font.c, pdflib.h). + +- Changes and improvements in the TIFF engine (p_tiff.c): + + - Uncompressed TIFF images have been passed through directly without any + compression applied, resulting in output file bloat. + + - Fixed a bug in the TIFF code which resulted in illegal memory access. + The bug was triggered by uncompressed CMYK TIFF images. + +- Eliminates some informational messages which zlib emitted in debug + mode (flate/zutil.h). + +- Allows PDF_get_parameter() and PDF_get_value() to be called with a NULL + argument for the PDF *. Affected parameters are "major", "minor", + "revision" (for PDF_get_value()) and "version", "pdi" (for + PDF_get_parameter()) (p_params.c). + + +Build process and platform support +================================== + +- Updates the CodeWarrior project files to CW 6 (*.mcp). + +- Minor configuration changes for Mac OS X 10.1 (config/aclocal.m4). + +- Switches to libtool 1.4 (config/*). + +- Modifies type names in the TIFF library in order to avoid non-ANSI C + problems on some platforms (tiff/*.c, tiff/*.h). + +- Improved support for building PDFlib on AIX. + +- More MVS modifications (*.c). + +- Changes for Windows CE compatibility. + + +Documentation +============= + +- Enhances the PDFlib manual with the help of the FrameMaker-to-Acrobat + TimeSavers (see www.microtype.com): + + - Fixes several broken links at the end of the manual. + + - Reduces file size be several hundred KB due to eliminated named dests. + + - Open document with first-level bookmarks expanded for better overview. + + - Highlight first-level bookmarks with bold text (visible only in Acrobat 5). + +- Introduces a separate manual edition for IBM eServer iSeries and + zSeries (PDFlib-manual-ibm.pdf). + + +Bindings +======== + +- C++: + - Renames the PDF class to PDFlib. This is transparent to clients since + a mapping is provided through preprocessor macros (pdflib.hpp). + + - Implements a new scheme for exception handling which is more suitable + for use with C++ than the previous scheme which was still based on a + user-supplied errorhandler callback function. For compatibility reasons + the old scheme is still the default, and the new one can be activated + by #defining PDF_THROWS_CPP_EXCEPTIONS (pdflib.cpp, pdflib.hpp, + except.h, except.c). + +- Java: + - Added "@deprecated" Javadoc comments to the the setgray* and setrgbcolor* + functions (pdflib.java). + + - Added JSP and servlet versions of all standard examples (jsp/*, + servlet/*). + + - Removed obsolete declarations for the following native functions from the + Java interface file (pdflib.java): + PDF_get_image_width, PDF_get_image_height + + - Removed the following functions from the C wrapper, and maps them to + the new PDF_color() interface in the Java interface file (pdflib.java, + pdflib_java.c): + + PDF_setgray_fill + PDF_setgray_stroke + PDF_setgray + PDF_setrgbcolor_fill + PDF_setrgbcolor_stroke + PDF_setrgbcolor + + - Out-of-memory situations in PDF_new() could result in a crash, caused + by a bug in the Java wrapper (pdflib_java.c). + + - Exposes the delete() method which may be useful to explicitly free + PDFlib resources in case the GC fails to call the supplied finalizer + (pdflib.java). + + - Fixes a bug in the Unicode handling of the Java wrapper which could + cause characters to get lost when native Chinese or Japanese + encodings were used for the Java source (pdflib_java.c). + +- Perl: + - Removed the "unknown" entry in the Perl version string since the + respective version #define is no longer available in Perl >= 5.6 + (pdflib_pl.c). + +- PHP: + - Supports PHP 4.1.x + + - Major rewrite of the PHP build and support machinery: + - new mega build script for PHP modules for internal use (buildphp.pl). + - added several support files (bind/php/ext/pdf/*) + - removed several unneeded files (*.mk, *.stub) + + - PDF_get_value() didn't work correctly for the capheight, ascender, and + descender parameters because the wrapper code failed to adjust the + supplied font handle by PDFLIB_FONT_OFFSET (pdf.c). + + - Synchronizes the wrapper code with the PHP CVS version (ext/pdf/pdf.c): + - added PDFlib 3 compatibility (imagewarning parameter) + - several enhancements for the PHP build process + - comments for vi folding + - added warning_undef_function for unsupported functions + +- RPG: + - Fine-tunes the RPG binding. + + +V4.0.1 (May 18, 2001) +===================== + +Bug fixes and enhancements +========================== + +- Removed the time-bomb feature of the beta versions which accidentally + was still present in the release version of PDFlib 4.0.0 (p_basic.c). + +- PDF_show_boxed() erroneously returned the value 1 if the text completely + fit in the box, and the last character was a newline (p_text.c). + +- Fixed a bug in the image mask handling which had some interaction with + the total number of images, and the fact whether or not images had + been closed and therefore image handles reused (p_image.c). + +- Non-interlaced PNG images were erroneously rejected when used as a + mask (p_image.c). + +- Individual strips of separate multi-strip TIFF images could get mixed + up under certain circumstances when the first image had already been + closed before placing subsequent images (p_image.c, p_image.h, p_intern.h, + p_basic.c). + +- The values of ascender and descender were wrong for TrueType fonts since + we picked tab_hhea->ascender instead of tab_OS_2->sTypoAscender + (p_truetype.c). + +- The scope check in PDF_stringwidth2() was too strict (p_text.c). + +- /FontName was garbled on EBCDIC platforms, but it's unused anyway (p_font.c). + +- Due to a bug in pdf_make_quoted_name() quoted characters in spot color names + could appear with wrong hex codes (p_util.c). + +- Creating and deleting a PDFlib object without any documents created + resulted in a wrong exception (p_stream.c) + +- Implements host encoding support for AS/400 and S/390 (p_util.c, p_font.c, + p_intern.h) + +- Using a CID font caused a crash due to inappropriately freeing static strings + (p_cid.h) + +- EBCDIC and CID encoding were rejected in PDF_show_boxed() even when no box + justification was requested (width=0 and height=0) (p_text.c). + + +Build process and platform support +================================== + +- Minor modifications for AIX compatibility (configure.in, tiff/tiff.h). + +- AS/400 fine-tuning (p_config.h, several *.c). + +- Fixed MVS-related macros (p_config.h) + +- Removed unnecessary PHP make targets which caused an error (Makefile.in, + configure.in) + + +Bindings +======== + +- C: + - Replaced the deprecated function setrgbcolor() with PDF_setcolor() + in the pdfclock sample. + +- C++: + - Replaced the deprecated function setrgbcolor() with PDF_setcolor() + in the pdfclock sample. + +- Java: + - Replaced the deprecated function setrgbcolor() with PDF_setcolor() + in the pdfclock sample. + + - A few mainframe-related fixes in the wrapper code (pdflib_java.c). + + - Clear pending exceptions if any of the JNI functions in the initialization + fails since JNI doesn't allow more than one pending exception. + (pdflib_java.c). + + - Makes the private functions PDF_new() and PDF_delete() in the PDFlib + Java object synchronized (pdflib.java). + + - Modified the internal version of the Java wrapper for use on the + AS/400 (pdflib_java.c). + +- Perl: + - Replaced the deprecated function PDF_setrgbcolor() with PDF_setcolor(). + in the pdfclock sample. + +- PHP: + - Replaced the deprecated function PDF_setrgbcolor() with PDF_setcolor(). + in the pdfclock sample. + + - A required image handle conversion was missing in the wrapper code for + PDF_open_image_file(), resulting in erroneous error messages when + trying to mask images (pdf.c). + +- Python: + - Replaced the deprecated function PDF_setrgbcolor() with PDF_setcolor(). + in the pdfclock sample. + +- Tcl: + - Replaced the deprecated function PDF_setrgbcolor() with PDF_setcolor(). + in the pdfclock sample. + +- RPG + - Introduced a new binding for ILE-RPG on the AS/400 (bind/rpg/*). + + +V4.0.0 (April 18, 2001) +======================= + +Bug fixes and enhancements +========================== + +- Implements a check in PDF_delete() in order to make sure that the caller + acutally fetched the last chunk of PDF data via PDF_get_buffer() + (p_intern.h, p_basic.c, p_stream.c). + +- Several modifications in the TrueType module (p_truetype.c): + - Allow TrueType symbol fonts (such as Webdings and Wingdings) to be used + with "builtin" encoding. + + - When font warnings are enabled (default) issue a concise error message + when a TrueType font file can't be opened or read, or is empty. + + - The TrueType module didn't always correctly distinguish between + exception and error return when a problem with a font was detected. + +- Fine-tuned the trace debug facility (several *.c). + +- Optimize the underline/overline/strikeout functions for empty text + strings (p_text.c). + +- PDF_continue_text2() didn't correctly deal with a NULL text argument + under certain conditions, and failed to enter a text block and set + the text parameters (p_text.c). + +- Throw an exception in PDF_show_boxed() if the current font uses CID + or EBCDIC encoding (p_text.c). + +- Change the scope back to object if fopen() fails in PDF_open_file(). + This guards against clients which fail to check the return value of + PDF_open_file() (p_basic.c). + +- PDF_open_image() didn't set the use_raw flag for JPEG- and CCITT- + compressed images, resulting in bad output filters (p_image.c). + +- Implements hooks for fetching encoding definitions from the host system + (p_font.c, p_util.c). + +- Modifies the error handling machinery so that the error handler is never + called with a NULL PDF pointer, even when the initial PDF allocation in + PDF_new2() goes wrong. This way error handlers installed by the client + are guaranteed to have access to thread- or object-specific data in all + cases (p_basic.c). + + +Build process and platform support +================================== + +- Adjusts more language bindings to Mac OS X (see below). + +- Disable the PHP binding if an external library was configured (configure.in). + +- Moves an inherited LDFLAGS variable to the front of EXTERNALLIBS in order + to make external -L paths work (configure.in). + +- Installs the pdflib-config script to make it more useful (Makefile.in). + +- Extends the pdflib-config script to include auxiliary information such + as PDFlib's install path, binding information, PDI existence, and a summary + (pdflib-config.in). + +- AS/400 portability mods and support for more compile-time code pages + (p_stream.c, p_config.h). + +- More MVS portability fixes (p_config.h tiff/port.h). + +- Change the libtool version number to 2:0:1 in order to somehow fix the bug + in 3.03 which incorrectly increased the age entry (configure.in). + + +Bindings +======== + +- Perl: + - Always call PDF_delete() in the error handler since the PDF pointer is now + guaranteed to be different from NULL (pdflib_pl.c). + + - Removed -lm for $PERLLINK on HP-UX (configure.in). + +- PHP: + - Cleans up the configure machinery which no longer must check for the + presence of any auxiliary library (config.m4). + +- Python: + - Always call PDF_delete() in the error handler since the PDF pointer is now + guaranteed to be different from NULL (pdflib_py.c). + + - Introduces a hack for renaming the Python wrapper library on Mac OS X from + libpdflib_py.dylib to pdflib_py.so(!), which apparently is what Python + expects (Makefile.in). + +- Tcl: + - Removed the pkgIndex.tcl Makefile target and rule because we no longer + must build the index file dynamically (Makefile.in). + + - Introduces a hack for renaming the Tcl wrapper library on Mac OS X from + libpdflib_tcl.dylib to pdflib_tcl.dylib (Makefile.in). + + + +V4.0.0beta3 quick fix (April 9, 2001) +===================================== + +Bug fixes and enhancements +========================== + +- Add /Matrix and /FormType entries to the form xobjects dictionary. + Although these are not required according to the PDF reference (new edition), + they _are_ required according to the PDF reference (old edition) and -- more + importantly -- by several PDF consumers such as Ghostscript, some + Adobe RIPs, and the PostScript output of Acrobat 4.0 (but not 4.05). + (p_template.c, pdi.c). + + + +V4.0.0beta3 (April 5, 2001) +=========================== + +Bug fixes and enhancements +========================== + +- Consistently use the Windows API name for TrueType fonts, regardless of + whether they have been read from file or retrieved from the host system + (p_truetype.c). + +- TrueType symbol fonts couldn't be used (p_truetype.c). + +- Implements support for flate-compressed TIFF images (p_tiff.c, tiff/*.c). + +- Start a new text block when a font set if we are not currently in a text + block. This seems to be required by some Adobe RIPs and some third-party + PDF consumers, although explicitly allowed in the PDF reference (p_font.c). + +- Throws an exception when the PDF document is empty (p_basic.c). + +- Fixed a memory overwrite in XObjects handling (p_image.c). + +- Fixed several memory leaks in the PNG module, and dropped support + for libpng versions older than 0.88 (p_png.c). + +- Changes the PNG handler so that we can process simple PNG images even + without libpng attached (p_png.c). + +- Resources were dropped between documents, meaning that for example + fonts had to be configured again and again for multiple output documents + with the same PDFlib instance (p_basic.c). + +- Reworked parameter handling, and introduced a new table for important + parameter properties such as the scope (p_params.c, p_params.h). + +- Updated the utility for converting font metrics to a C header file + (util/compile_metrics.c). + +- Regenerated the built-in metrics for the core fonts with the following + changes (p_metrics.h): + - Uses the new Adobe AFMs as input which have minor changes. + - Correctly use the width of the space character for all undefined + characters instead of the fixed value 250. + - Uses the current encoding definitions, which had a few updates. + - Generate more tense output. + +- Modified the getopt() stuff for easier building the demo clients on + Windows (clients/*.c). + +- Fixed a memory leak in the GIF reader when the requested file couldn't + be opened (p_gif.c). + +- Fixed memory leaks in the font engine, related to TrueType fonts and + the builtin core fonts (p_font.c, p_truetype.c). + +- The default for floating point output accuracy (3) was too small, + as evidenced by the pdfclock example. Increased to 4 (p_basic.c). + +- Fixed a nasty bug in pdf_compress_init(): due to missing initialization + importing PDF pages on an otherwise empty page could result in a crash + on some platforms (p_stream.c). + + +Build process and platform support +================================== + +- Changes a few details for better MVS support. + +- Updates the Mac project files including support for the language + bindings (*.mcp). + +- Updated the project files for Borland C++ Builder (*.brp, *.bpf). + +- Consolidated the predefined encodings into a single header file + (p_encoding.h). + +- Improved portability in code and build process for a number of Unix + platforms. + +- Replaced the GIF test image with a new one (test/machine.gif). + +- Statically links all C samples and demo programs (*/Makefile.in, + configure.in). + + +Bindings +======== + +- C: + - Changes all clients to return 0 from the main program (*.c). + + - Runs the tests without libtool since we link statically (Makefile.in). + +- C++: + - Adds typedefs to support the notion that all functions which are + passed to PDFlib must be pure C (as opposed to C++) functions (pdflib.h, + pdflib.hpp, pdflib.cpp). + + - Runs the tests without libtool since we link statically (Makefile.in). + + - Drops support for the Watcom compiler (pdflib.hpp, pdflib.cpp). + + - Changes namespace handling for non-gcc compilers (configure.in). + + - Adds casts to pacify the Sun compiler (image.cpp, personalize.cpp). + +- Java: + - Adds a hack for Mac OS X to help the test and install process run even + though OS X has its own idea of JNI library naming conventions + (Makefile.in). + +- Perl: + - Runs the tests without libtool since we supply -I options (Makefile.in). + + - Adds -lm (or equivalent) to the list of libraries against which the + Perl wrapper is linked. This is required, for example, for some builds + of Perl on Solaris (configure.in). + +- PHP: + - Fixed a crash which was caused by a typo in the PDI memory functions. + + - Adds documentation on the PHP/PDFlib build process (readme.txt). + +- Python: + - Fixes a systematic bug in all wrappers for the new 4.0 functions + (pdflib_py.c, pdflib/pdflib.i). + + - Adds PDI examples (personalize.py, quickreference.py). + +- Tcl: + - Renames the Tcl/PDFlib wrapper library on the Mac to pdflib_tcl.shlb, + which is the name returned by Tcl's [info sharedlibextension] command + (*.mcp). + + +V4.0.0 beta2 (March 23, 2001) +============================= + +Bug fixes and enhancements +========================== + +- Removes all attempts to "repair" the file if API calls are incomplete, + or in bad order. This greatly simplifies cleanup in case of errors. + +- Fully implements a scoping system which enforces the scoping rules + documented in the manual. This may break clients which do not adhere + to the scoping rules, but got away with the old implementation, + potentially producing bad PDF output (pdflib/*.c, p_intern.h). + +- The "imagewidth" and "imageheight" parameters are now supported for + templates, too (p_template.c). + +- Implements custom memory handlers for libpng and tifflib (png/pngmem.c, + pdflib/p_png.c, pdflib/p_tiff.c). + +- Relaxed the encoding check for AFM files since so many AFM files + out there are just plain wrong (mostly those generated by Fontographer + (p_afm.c). + +- Improves the Unicode bookmark samples so that they work correctly on + EBCDIC platforms (pdftest.c). + +- Implements pdf_vsprintf() which does the "right thing" for all kinds + of formatted PDF output. In addition, we finally get rid of cursed NLS + (pdflib/*.c, pdi/*.c). + +- Moved the PDI dummy functions to p_template.c, and removed p_pdi.c from + the distribution fileset. + +- Delays resource cleanup until PDF_delete() (instead of PDF_close()) in + order to keep configuration information across PDF output documents + (p_basic.c). + +- Implements a real tree structure for the /Pages tree instead of a linear + array. This greatly improves Acrobat's performance when navigating + _very_ large documents (p_basic.c, p_intern.h). + +- Fixes a problem related to TrueType font names which resulted in + bad font cache misses due to internal name mismatches. We cured this + by storing the PostScript name of a TrueType font separately (name + table entry 6. The fullName field is used for this since fullName was + unused anyway (p_font.h, p_font.c, p_truetype.c, p_afm.c, p_pfm.c, + p_metrics.h, util/compile_metrics.c). + +- pdflib.upr was loaded to early. This especially affected host fonts + where no upr file is required, but an exception was thrown nevertheless + (p_util.c). + +- Added "CharacterSet" to the list of recognized AFM keywords (p_afm.c). + +- Modifies the TrueType parser to gracefully deal with Unicode-based + Mac fonts, although these are not yet supported (p_truetype.c). + +- Replaces the core 14 AFM files with newer versions which cover the + ExtendedRoman character set (315 instead of 229 glyphs), and are therefore + better suited for PDFlib's powerful encoding machinery (fonts/*.afm). + +- Changed the accuracy of imagewidth and imageheight from int to float + to account for imported PDF pages and templates (p_image.h, p_tiff.c, + p_ccitt.c, p_jpeg.c, p_gif.c, p_image.c, p_template.c). + + +Build process and platform support +================================== + +- Supports local (uninstalled) static versions of the auxiliary libraries + via the LDFLAGS environment variable (configure.in). + +- A variety of portability fixes in the auxiliary libraries (tiff/*, + png/*, flate/*) plus a few more in PDFlib (pdflib/*). + +- Modifies the MSVC++ project files for the new library structure (*.dsw, + *.dsp). + +- Brings the CodeWarrior project file for Mac up to date (PDFlib.mcp). + +- Several bug fixes and improvements in the configure machinery + (configure.in, pdflib-config.in, */Makefile.in). + + +Bindings +======== + +Java: + - show_boxed didn't correctly retrieve its text argument as a + Unicode string, resulting in wrong output for non-Latin-1 characters + (pdflib_java.c). + + - stringwidth() didn't retrieve its text argument as a Unicode string + (pdflib_java.c). + +Tcl: + - Fully implements the use of Tcl's stub feature which allows us to + use a single library with different Tcl versions (pdflib_tcl.c). + + - Modifies the index file so that it no longer requires the library + name and the list of function names (pkgIndex.tcl). + + - PDF_show_boxed didn't correctly retrieve its text argument as a + Unicode string, resulting in wrong output for non-ASCII characters + (pdflib_tcl.c). + + - PDF_stringwidth() didn't retrieve its text argument as a Unicode string + (pdflib_tcl.c). + + +V4.0.0 beta1 (March 02, 2001) +============================= + +New features +============ + +- Implements support for the pattern color space (p_pattern.c, p_intern.h, + p_basic.c, pdflib.h). + +- Adds support for spot color (p_color.c, p_intern.h, pdflib.h). + +- Adds a hook for attaching the PDF import library PDI (p_pdi.c). + +- Adds Unicode handling for TrueType and PostScript fonts (p_unicode.c, + p_font.c, p_truetype.c). + +- Implements new parameters: + major/minor/revision/version + pdi + pdiwarning + CropBox/llx/lly/urx/ury + BleedBox/llx/lly/urx/ury + TrimBox/llx/lly/urx/ury + ArtBox/llx/lly/urx/ury + + +Bug fixes and enhancements +========================== + +- Major restructuring in order to better localize data types and + related functions (most *.c and *.h). + +- Fixed a bug in the MacRoman encoding table: guilsinglleft and guilsinglright + had a letter missing in their name. Since we never write MacRomanEncoding + explicitly, the characters were available, but their widths were retrieved + wrongly from an AFM file (e_macroman.h). + +- Added the missing Euro glyph to the cp1250 encoding table (cp1250.enc). + + +Build process and platform support +================================== + +- Changes the library file name suffix for Mac OS X server (Rhapsody) + from .so to .dylib (config/ltconfig). + +- Integrated zlib into the PDFlib distribution, configure, and make process, + including a libtool-based Makefile. Similarly for parts of libpng and + libtiff (configure.in, */Makefile.in, tiff/*, png/*, flate/*). + +- The search for Python's shared lib path could result in multi-line + output under certain circumstances. We work around this with more + sophisticated filtering of Python's sys.path, contributed by a user + (configure.in). + + +Distribution +============ + +- Adds the Lucidux Sans PostScript font as a sample (fonts/lcdxsr.*). + +- Adds code page definitions for all ISO 8859 flavors and Windows 125X + code pages (fonts/*.cpg). + +- Adds a PDI demo client in C (pdfimpose.c), and the quick reference + and personalize demos for all supported language bindings. + +- Adds a few user-contributed improvements to the image client (pdfimage.c). + +- Removes config/pdflib.m4 since it is no longer required. + + +Bindings +======== + +PHP: + - Adds a supported language binding for PHP (bind/php/*). + +Java: + - Introduces PDF_VOLATILE in order to prevent scores of compiler + warnings when building the wrapper (pdflib_java.c). + +Perl: + - Introduces PDF_VOLATILE in order to prevent scores of compiler + warnings when building the wrapper (pdflib_pl.c). + +Python: + - Introduces PDF_VOLATILE in order to prevent scores of compiler + warnings when building the wrapper (pdflib_py.c). + +Tcl: + - Implements an initialization function to make the PDFlib extension + work with safe builds of the Tcl interpreter (pdflib_tcl.c). + + - Introduces PDF_VOLATILE in order to prevent scores of compiler + warnings when building the wrapper (pdflib_tcl.c). + + +V3.5.0 (February 01, 2001) +========================== + +This version has only been released to a few customers. + + +New features +============ + +- Makes the CMYK functions supported API members (p_color.c). + +- Makes PDF_arcn() a supported API function (p_draw.c). + +- Makes PDF_add_thumbnail() a supported API function (p_draw.c). + +- Implements the template feature (p_image.c, p_template.c, p_intern.h, + p_basic.c, p_text.c, pdflib.h, Makefile.in). + +- Implements TrueType font support (p_font.c, p_afm.c, p_pfm.c, p_font.h, + p_util.c, p_basic.c, p_truetype.c, p_truetype.h, p_intern.h, p_cid.h, + p_metrics.h, Makefile.in). + + +Bug fixes and enhancements +========================== + +- PDF_open_mem() didn't work due to a typo (p_basic.c). + +- PDF_set_parameter(p, "flush", "none") didn't work due to a typo (p_basic.c). + + +Build process, distribution, and platform support +================================================= + +- Improvements for Mac OS X: + - Makes libtool generate shared libraries (.dylib) on Mac OS X (ltconfig, + ltmain.sh). + + +Distribution +============ + +- Introduces the new major.minor.revision version numbering scheme + (many files). + + +Bindings +======== + +Java: + - Makes the Java wrapper compatible with Mac OS X (pdflib_java.c). + + +Tcl: + - Configure now finds the Tcl header on Mac OS X (configure.in). + + +V3.03 (December 22, 2000) +========================= + +Bug fixes and enhancements +========================== + +- Contrary to the documentation, a == sequence in the UPR file didn't + guarantee absolute file names (no directory prefix applied) if a + prefix has been set using PDF_set_parameter(). This especially affected + the ActiveX edition where the wrapper always set a prefix, and + absolute resource names couldn't effecitvely be used. Similarly, + the "==" syntax now works with when resources are set dynamically via + PDF_set_parameter(). (p_util.c, p_basic.c). + +- Makes the JPEG reader more robust against damaged files (p_jpeg.c). + +- Implements an option in the image converter for printing details + for damaged image files (clients/pdfimage.c). + +- Implements PDF_get_value() for the following parameters: + leading, textrise, horizscaling, textrendering, charspacing, wordspacing. + Implements PDF_get_parameter() for the following parameters: + overline, underline, strikeout. + +- Reworks implementation and documentation of PDF_arc(), and fine-tunes + several other graphics functions in the process (p_draw.c): + - Re-implements the algorithm for cutting down arcs into smaller + segments. This fixes a number of subtle bugs with certain parameter + combinations, and introduces clearer documentation for all cases, + including degenerate ones. + + - Defines the magic arc variable for the PDF_circle() algorithm + with 8 instead of 4 decimal places in order to increase the + accuracy (p_draw.c). + + - Introduces clear semantics for the behaviour of PDF_arc() and + other functions when a current point is available, and when no + current point has previously been set. + + - Introduces a (currently unsupported) PDF_arcn() function for + drawing arcs in clockwise direction. + +- Removes the clearing loop for debug flags in PDF_new2() since the + memset() for the PDF structure clears those anyway (p_basic.c). + +- Fixes subtle bugs in the text handling (p_text.c): + - The combination of word or character spacing != 0 and underline/ + overline/strikeout text resulted in wrong text positioning. + + - After PDF_show_boxed() the call PDF_get_value("texty",0) returned + a vertical position which was one line too high under the same + circumstances as above. + +- Allows the external and internal data types for floating point + calculations to be redefined via a #define. This is intended for + applications which require improved accuracy, and not supported in the + general case due to platform and binary compatibility issues (pdflib.h). + +- Implements a check to make sure that PDF_save() and PDF_restore() calls + are balanced at the end of a page (p_basic.). + +- Removed the SWIG preprocessor conditionals since we don't use SWIG + any more (pdflib.h). + +- Fixes a bug in PDFlib's object machinery, related to PDF page object + numbers. Fortunately, the bug occurred only under very rare and subtle + circumstances, but was severe nevertheless because it resulted in + damaged PDF output, and erroneous "allocated but not used" messages + (p_basic.c). + +- Changes the output accuracy of floating point numbers from four to + six decimal places. This slightly affects output file size, but was + necessary to defeat some accuracy problems. For example, stitching + individual stripes of striped TIFF images could lead to visual + artifacts in Acrobat (p_util.c). + +- Corrected a typo in the error message for bad page sizes with Acrobat + 4 compatibility (p_basic.c). + +- Implements support for setting the document's base URI (p_intern.h, + p_basic.c). + +- Changes the PNG error handling in order to make it source- and binary- + compatible with libpng 1.08. and 1.1 (p_png.c). + +- Fixes two problems in PDF_show_boxed() (p_text.c): + - Certain forced line breaks could cause a single character to disappear. + - Forced line breaks could cause the preceding line to be ragged even + in "justify" or "fulljustify" mode. + +- Improves TIFF handling: + - Does no longer throw an exception if the imagewarning parameter is + set to true, and the requested image number in a multi-page TIFF can + not be retrieved (p_tiff.c). + + - Moves an increment operator outside a function call because the + variable has been used as function parameter twice. This is not + portable because the order of parameter evaluation is platform- + dependent. The Compaq True64 compiler correctly spotted this (p_tiff.c). + + - Rejects TIFF images with a color depth other than 1, 2, 4, or 8 bits + per sample since other values are not supported by PDF (p_tiff.c). + + - Changed the parameter handling for CCITT G3-compressed TIFF images, + preventing "Read less image data than expected" messages in Acrobat + (p_tiff.c). + + - Failure of the TIFF library to read an image file could result in a + crash (p_tiff.c). + +- Made the AFM parser stricter in checking the 'StartCharMetrics' entry + against the actual number of character entries in the file. This + makes PDFlib more robust in case of bad AFMs, but may result in + AFMs being rejected which previously have been accepted (p_afm.c). + +- Implements support for an arbitrary number of user-defined document + information fields (p_hyper.c, p_intern.h). + +- The allowed range in the encoding parser was wrong, and must be 0-255 + instead of 1-256 (p_util.c). + +- Changed two entries in the Latin 2 encoding file since Adobe fonts + use the character names T/tcommaaccent instead of T/tcedilla + (fonts/iso8859-2.enc). + +- Adds unsupported code for generating the Crop, Bleed, Trim, and + Art boxes in addition to the MediaBox. Later these will be adjustable + by the client (p_intern.h, p_basic.c). + +- Prevents multiple PDF_open_*() calls without a matching PDF_close() + (p_basic.c). + +- Referenced images were lacking an endobj token at the end of their + (empty) data section (p_image.c). + +- Prevents the use of flush points from language bindings other than + C or C++ (p_basic.c). + +- Two format strings for error messages were wrong in PDF_get_parameter() + (p_basic.c). + +- Issue a NonfatalError when the obsolete function PDF_endpath() is + called (p_draw.c). + +- Calling PDF_get_parameter(p, "resy", image) with an invalid image + parameter resulted in a crash. Ironically, the crash occurred due to + a malformed argument when the error message was formatted (p_basic.c). + +- The test program accidentally set the embedding parameter in several + samples to 1 instead of 0 (pdftest.c). + +- Implements the "fontwarning" parameter. The default value is "true"; + setting it to "false" makes PDF_findfont() return -1 instead of throwing + an exception (p_basic.c, p_font.c, p_util.c, p_intern.h). + +- Using PDF_findfont() before a document has been opened now results + in a RuntimeError (p_font.c). + +- Implements a thumbnail hook for a customer. However, this hook is + not available in the general version, and not yet supported in + language bindings other than C (p_image.c). + +- Allows the base 14 fonts to be embedded (p_fonts.c). + +- Documents and implements the fact that /Producer and /CreationDate + are not allowed as user-defined info keys (p_hyper.c). + +- Ensures that PDF_setfont() and PDF_stringwidth()/PDF_stringwidth2() + cannot be called outside of page descriptions (p_text.c, p_font.c). + +- Safeguards against internal attempts at malloc()'ing 0 bytes (p_basic.c). + +- Fixes a number of EBCDIC-related bugs: + - The description and author fields in PDF_attach_file() haven't been + properly converted to PDFDocEncoding (p_annots.c). + + - PFA font files were treated wrongly (p_font.c). + + - PFM metrics file handling didn't work (p_pfm.c). + + - The "ebcdic" value of the encoding enum was wrong. This resulted in the + compiled-in metrics not being found on native EBCDIC platforms + (p_intern.h). + + - The debug array in the PDF struct was too small for use with + control characters from the EBCDIC character set (p_intern.h). + + - The test for compilation on EBCDIC platforms didn't work reliably + (p_config.h). + + - Introduces a flavor of the poem text where German special characters + are encoded for EBCDIC (pdftest.c). + + - The Unicode sample for document info entries was defined too ASCII- + centric in the demo program, and produced bad results (pdftest.c). + +- Fixes a typo in the unsupported CMYK functions (p_color.c). + +- Fixes the compile_metrics utility which was broken (util/compile_metrics.c). + +- Font metrics read in from a PFM file caused a memory leak. The function + pdf_cleanup_font_struct() now works with all types of fonts, and is + also called for fonts read in from PFM files (p_font.c, p_afm.c, p_intern.h). + + +Build process, distribution, and platform support +================================================= + +- Fixes a few configure buglets, and adds a new option (configure.in): + - The --disable-cxx and --enable-cxx=no options didn't work; + + - The --disable-shared-pdflib and --enable-shared-pdflib=no options + didn't work; + + - Implements --enable-profile. + +- Modifies "make install" in the pdflib subdirectory to do different + things with the static vs. shared library (pdflib/Makefile.in). + +- Added an encoding file for Windows code page 1250 (central european) + (fonts/cp1250.enc, fonts/pdflib.upr), and changes T/tcedilla to + T/tcommaaccent in order to match Adobe conventions (fonts/iso8859-2.enc). + +- Enhancements for MacOS X server/Rhapsody 5.6/Darwin (configure.in). + Set with_gnu_ld=yes which is required for GNU libtool (not to be + confused with Apple's libtool). + +- S/390 enhancements: + - Adds a new branch for shared library/DLL options on the S/390 in + the libtool database (ltconfig). + + - Patches the libtool input for EBCDIC compatibility, and moves the + source file names in compiler commands to the end for c89 (ltmain.sh). + + - Introduces a dedicated distribution kit for S/390, which has all + text files converted to EBCDIC already (Makefile.in). + + - Uses compress instead of gzip for the S/390 distribution (Makefile.in). + + - Removes the PDF_PLATFORM since it is now supplied by the configure + script (p_config.h). + + - Adds -DOS390 to the compiler options if appropriate, and sets the CC + and LD variables (configure.in). + + - Changes a test for OS/2 in order to not catch S/390 (pdflib.h). + + - Introduces a compile-time switch to distinguish between Unix System + Services and MVS on the S/390 (p_config.h, p_util.c). + +- Installing the static C library didn't work due to a typo + (pdflib/Makefile.in). + + +Bindings +======== + +- Added a call to PDF_close_image() in the image samples for all language + bindings (bind/*/image.*). + +- C++: + - Implements unsupported wrapper functions for the CMYK functions + (pdflib.hpp, pdflib.cpp). + +- Java: + - Adds information on building the Java wrapper on S/390 (readme.txt). + + - Adds information about Apple WebObjects (readme.txt). + + - Adds information about J2EE and Apache JServ deployment (readme.txt). + + - Adds the JNI header path for MacOS X server (configure.in). + + - Adds the JNI header path for S/390 (configure.in). + + - Searches $JAVAINCLUDE/mvs for machine-dependent JNI headers (configure.in). + + - Makes the Java wrapper EBCDIC-safe, and implements changes required + for the JNI on S/390 (pdflib_java.c). + +- Perl: + - Searches for Perl 5.7.0 (configure.in). + + - Sets the standard output to binary mode in the CGI sample + (pdfclock.pl.cgi). + +- Python: + - Includes an "oldpython" configuration to build the PDFlib extension + for Python < 2.0 on Windows (Python.dsp). PDFlib binaries for Python + 1.x and 2.0 are included in the Windows binary distribution. + + - Updates the configure script for Python 2.0 (configure.in). + +- Tcl: + - Searches for Tcl 8.4 (configure.in). + + +Documentation +============= + +- Splits the manual in an ActiveX edition and another one for all + other language bindings (doc/PDFlib-manual.pdf). + +- Improved the form fields in the PDFlib order form (PDFlib-purchase-order.pdf). + +- Documents a workaround for problems when viewing the PDFlib purchase + order form with Acrobat Reader on Unix/Linux (doc/readme_unix.txt). + +- Adds ColdFusion examples and documentation to the ActiveX edition. + + + +V3.02 (August 22, 2000) +======================= + + +Bug fixes and enhancements +========================== + +- Added state checks to the text functions (p_text.c). + +- Refined the error handling in PDF_open_image (p_basic.c, p_image.c). + +- Deactivated the default prefix entry in the UPR file because it could + cause confusion with the ActiveX edition (pdflib.upr). + +- Multi-strip TIFF images didn't work correctly when placed with a scaling + factor != 1 (p_image.c). + +- Implements a macro which aids in overcoming differences in libpng + versions when it comes to accessing the setjmp buffer (p_png.c). + +- Fine-tuned the OS/2 test in p_config.h. + +- Allow negative box width and height in PDF_show_boxed() (p_text.c). + +- Added the debug version of the C runtime library to the debug configuration + of the MSVC test and pdflib projects (test/test.dsp, pdflib/pdflib.dsp). + +- Under certain circumstances the GIF reader didn't work correctly due to + missing variable initialization (p_gif.c). + +- pdftest.c couldn't be compiled in strict ANSI mode by some compilers due to + two misplaced statements (which actually only serve as warning preventers) + (pdftest.c). + +- Added an #if conditional because the Intel version of the Metrowerks compiler + doesn't have setmode() (p_basic.c). + +- PDF_open_fp() resulted in a crash or PDFlib exception because the file pointer + got overwritten due to wrong initialization order (p_basic.c). + + +Build process, distribution, and platform support +================================================= + +- Adds more AS/400 relevant information (doc/readme_ebcdic.txt). + +- Includes the files in the fonts directory in the binary distributions. + +- Extended the CodeWarrior project file for dual use on both Mac and + Windows, and updated to CodeWarrior Pro 5 (PDFlib.mcp). + +- Fine-tuned support for S/390 (p_config.h, p_util.c). + +- Removed an obsolete file (pdflib/makefile.bcc). + + +Bindings +======== + +- C: + - PDF_delete() was missing from two C samples (hello.c, image.c) and + a demo client (clients/text2pdf.c); + +- Java: + - No longer calls PDF_delete() in the Java exception generating mechanism + since this may lead to multiple calls due to interference with PDFlib's + finalize() method. This should fix long-standing problems with + exceptions in some Java environments, especially Servlet engines + (pdflib_java.c). + + - Adds a classFinalize() method (pdflib.java). + + - Adds throws clauses to all PDFlib Java and native methods. This change + required the addition of an import statement (pdflib.java). + + - Adds throws clauses to all examples. + + - Renames the Java servlet example to PDFlibServlet.java. + + - Adds notes on using PDFlib with IBM WebSphere Application server + and Allaire JRun (bind/java/readme.txt). + + +Documentation +============= + +- Marks PDF_endpath() as deprecated (pdflib.h). + +- Replaced the order form with an interactive version + (doc/PDFlib-purchase-order.pdf). + + +V3.01 (July 1, 2000) +===================== + +New features and API +==================== + +This release is binary-compatible to 3.0, but adds a few new features +which are accessible through additional parameters to existing functions: + +- Implements the "fontencoding" parameter for retrieving the encoding of the + current font (p_basic.c, p_font.c). + +- Implements "blind" mode in PDF_show_boxed() in order to check whether or not a + string fits in a given box (p_text.c). + +- Adds support for multipage TIFF images via the "page" parameter + of PDF_open_image_file() (p_tiff.c). + +- Implements pass-through mode for a variety of TIFF compression schemes. + Compressed image data is no longer decompressed and recompressed, resulting + in much faster TIFF procecessing. Correctly dealing with multi-strip images + required rewriting parts of the image machinery (p_tiff.c, p_image.c, + p_intern.h). + +- Adds support for CMYK TIFF images (p_tiff.c). + +- Implements pass-through mode in the GIF handler. This results in much faster + GIF processing, but unfortunately restricts the number of supported GIF flavors + to 8-bit, non-interlaced. As a side effect, this decreases the memory footprint + of each PDF instance by more than 64 KB (p_gif.c, p_intern.h). + +- Implements the "openmode" parameter for setting the initial + display of bookmarks, thumbnails, or fullscreen mode (p_intern.h, + p_basic.c, p_hyper.c). + +- Implements the "bookmarkdest" parameter which allows changing the + destination view of individual bookmarks (p_intern.h, p_hyper.c, + p_basic.c). + +- Implements the "imagewarning" parameter which allows the client to get more + detailed information about why PDF_open_image_file() or PDF_open_CCITT() failed + (p_basic.c, p_jpeg.c, p_gif.c, p_tiff.c, p_png.c, p_ccitt.c). + + +Bug fixes and enhancements +========================== + +- Outputs \r and \n in strings with a preceding backslash which seems to be + required for proper handling of linebreaks in annotations (p_text.c). + +- Eliminate the exception caused by unknown category entries in the resource + files. + This behavior caused unnecessary exception when UPR files were created with the + makepsres utility (p_util.c). + +- Implements an unsupported "memory32" mode for 32-bit aligned memory images in + PDF_open_image() (p_image.c). + +- Negative horizontal scaling was taken into account for the underline/overline/ + strikeout distance from the baseline including its sign, which is wrong + (p_text.c). + +- Increased several of the initial allocation chunk sizes since we saved 64K by + the rewrite of the GIF module (p_intern.h). + +- Uses pdf_end_path() more efficiently in PDF_endpath() (p_draw.c). + +- After an image was rejected the next image could suffer from left-over + information from the rejected image since proper initialization was missing + (p_image.c). + +- Allows the compression level to be changed within a page description + (p_basic.c). + +- Removed the warning about page sizes which are incompatible to Acrobat 3 + which was issued by default when a page was too large or too small. Now + a RuntimeError is generated only in Acrobat 3 compatibility mode (p_basic.c). + +- PDF_close() closed the file handle even if it was provided by the client + through PDF_open_fp() which is a bad attitude towards clients (p_basic.c). + +- PDF_open_mem() was broken: it provoked a wrong error message due to missing + initialization (p_basic.). + +- Removed a number of obsolete functions which were no longer supported in + PDFlib 3.0 but still available (p_jpeg.c, p_gif.c, p_tiff.c, p_gstate.c, + p_text.c, p_hyper.c, pdflib.h, p_intern.h, p_basic.c, + bind/[perl|tcl|python]/pdflib_*.c). + +- PDF_add_note interprets an empty icon parameter equivalent to a NULL value + (p_annots.c). + +- Setting the transition parameter to an empty string is now equivalent to + a NULL string value, and resets the transition to default (p_hyper.c). + +- Replaces the GIF test image with a non-interlaced version (test/pdflib.gif). + +- Eliminates a superfluous moveto in PDF_arc() when the current point and the + starting point of the arc coincide. The redundant moveto broke subsequent + closepath and fill behaviors (p_draw.c). + +- Changed several hex characters in strings to octal notation (pdftest.c). + +- Added a few casts to satisfy C++ compilers (p_font.c, p_pfm.c). + +- Re-implements PDF_set_text_matrix(), which is currently neither documented in + the manual nor supported (p_text.c, pdflib.h). + +- Adds the "nativeunicode" parameter to Unicode-aware language wrappers in order + to disable native Unicode processing. The default value is false (p_basic.c). + +- The "defined" preprocessor instruction was missing for the __BORLANDC__ + identifier (p_config.h). + +- Safeguards the interpretation of encoding and UPR files on Unix from + Windows-style lineends (p_util.c). + +- An infinite loop could result when trying to attach a non-existent + file with PDF_attach_file (p_basic.c). + +- The return type of PDF_get_buffer() was missing a const qualifier + (pdflib.h, p_basic.c). + +- Separates the generation of a multi-threaded test program from the + WIN32 environment in order to simplify building non-threaded tests + with non-MS compilers (test/pdftest.c). + +- Removes several warnings about redundant variable assignments which + were uncovered by the Borland compiler (p_afm.c, p_basic.c, p_draw.c, + p_filter.c, p_font.c, p_jpeg.c, p_pfm.c, p_util.c, test/pdftest.c). + +- PDF_get_value() could crash when called with bad parameters. Ironically, + the crash was not caused by the bad parameters but by a bug in the + error message complaining about the bad parameters (p_basic.c). + +- PDF_setfont() and PDF_stringwidth2() now accept negative font sizes. + The horizontal scaling factor may now also be negative. + The underline/overline/strikeout functions use the absolute value + of the calculated line width to ensure that the line width will be + positive (p_font.c, p_text.c). + +- Changed the name of the "byte" typedef to "pdf_byte" (p_intern.h, many *.c). + +- Changed the default encoding in text2pdf.c from "winansi" to "host", + and adds a command line option for the text encoding (pdftest.c). + +- The formula for calculating Bezier control points for the arc + approximation gave wrong results due to a missing cast (!) in the + C expression, resulting in ugly circle segments for certain parameter + combinations (p_draw.c). + +- The vertical start position of the text line could be reset to 0 if graphics + operators were issued between the PDF_show_xy and PDF_continue_text() + calls (p_text.c). + +- Text output could be positioned one line too high if the character + or word spacing was set != 0 because the leading value was not + set correctly in PDF_show() and PDF_show_xy(). This bug also affected + the horizontal positioning of PDF_show_boxed() (p_text.c). + +- PDF_continue_text now honors empty strings, i.e., moves to the start + of the next line if the supplied string is empty (p_text.c). + +- The ISO 8859-2 encoding file had typos in the Zacute and Racute + entries (iso8859-2.enc). + +- CMYK JPEG images resulted in corrupt PDF output due to a typo (p_image.c). + +- Fixed a non-portable construct involving the increment operator which + resulted in wrong code when optimizing on True64 Unix (test/pdftest.c). + + +Build process, distribution, and platform support +================================================= + +- Introduced a new configuration "no auxiliary libs" for MSVC for building + PDFlib without any auxiliary library present (*.dsp). + +- Changes the sample projects for MSVC++ from pdfclock to hello because this + is better suited as the first example (c.dsp, cpp.dsp). + +- Makes the math library linker option (usually -lm) configurable via an option. + This is only rarely required. The option is empty on MacOS X/Darwin + (configure.in). + +- On Windows, switches to static versions of libpng, tifflib, and libz, and + renamed libpng_static.lib to libpng.lib (*.dsp). + +- Adds support files for Borland C++ Builder 5.0 (*.bpf, *.bpr). + +- Adds -pthreads to the compiler options on OSF1 (configure.in). + +- Libtool output was sent to /dev/null in the bind Makefiles, which is + a bad idea, and was changed (bind/*/Makefile.in). + +- By default the C++ binding is no longer enabled, since few people seem to + actually use it and inconsistent handling of the standard C++ library causes + frequent configuration trouble on several systems. It can be enabled with the + --enable-cxx configure option (configure.in). + +- Changed the name of the C++ configure option from --with-cxx to the more + appropriate --enable-cxx (configure.in). + +- Removes -ljpeg and -lz from the TIFFlib tests in the configure script, since + these are't always required for libtiff, and missing additional libraries may + cause linker error messages on some platforms if not installed. Platforms + which require auxiliary libraries for TIFFlib can configure those with the + new --with-tiffauxlib option (configure.in). + +- Changes the shared library mechanism in order to avoid problems with + multiple dependent shared libs on platforms which don't support inter- + library dependencies, or when the user doesn't have root privilege for + installing the PDFlib shared library, for example on an ISP's server + (configure.in, pdflib-config.in, all Makefile.in): + + - PDFlib is built as a libtool convenience library by default. + + - C/C++ language clients which prefer a shared PDFlib can request this via + the --enable-shared-pdflib configure option. Other language bindings + will not be available when this option is used. + + - Using non-installed versions of the auxiliary libraries now works as + expected, but requires them to be built as static libs. Problems may + arise if a local library directory contains a shared version of some + auxiliary lib. The configure script will warn about this situation. + + - The PDFlib library will only be installed if it was built as a shared + object. "make install" will install pdflib.h always, however. + + - All language wrapper libraries are still shared, but pull in the PDFlib core + into the respective shared library. + +- Removes the dependencies from the client Makefile (clients/Makefile.in, configure.in). + +- The client and util Makefiles didn't use the configure-supplied macro for the + name of the PDFlib core library (clients/Makefile.in, util/Makefile.in). + +- Switches to libtool 1.3.5 (config/*). + +- Removed all space characters after the -I compiler options since some + compilers don't like this (configure.in). + +- Includes an encoding definition file for ISO 8859-9/Turkish, also + known as Latin Alphabet No 5 (!) with additional character entries + for Windows codepage 1254, and includes a corresponding + entry in the UPR file (fonts/iso8859-9.enc, fonts/pdflib.upr). + +- Removes an obsolete file (test/graphdata). + +- The "clean" target didn't check whether or not a certain language + binding actually had been built, resulting in errors for a global + "make clean" (configure.in, Makefile.in). + +- Sets the LANG variable to empty string before calling the date + command. Otherwise %p depends on the LANG setting, and may not + work (Makefile.in). + +- Adds the list of dependent libraries (PDFLIBLINK) when linking the + PDFlib shared library via libtool. Some platforms such as AIX require + the names of all dependent libraries to be coded into the shared library + file (pdflib/Makefile.in). + +- Fixed a number of EBCDIC-related bugs: + - Bookmarks and annotation text didn't get converted to ASCII (p_hyper.c). + - User-defined document information field names got converted to + ASCII just one time too often, resulting in bad output (p_hyper.c). + - The open mode for fopen() must be set to binary ("rb" and "wb"), + otherwise PDF output will be screwed up, and images don't work + (p_config.h). + +- Removed all occurrences of "-lc" in configure.in. + +- When searching for the TIFF library configure didn't check the lib + subdirectory of any directory supplied via the --with-tifflib= option, + contrary to the search applied for zlib and libpng, and the TIFFlib + header files (configure.in). + +- Implements config/pdflib.m4 for use with the configure process of other + packages which need to test for the availability of PDFlib. + +- Includes pdflib-config as an aid in configuring other packages which + want to use PDFlib (configure.in, pdflib-config.in). + +- Fixed a typo in the SUFFIXES line which adversely affected some + non-GNU makes (pdflib/Makefile.in). + +- Added a precompiler test for the EMX compiler on OS/2 (p_config.h). + + +Bindings +======== + +- C: + - Includes an image sample (image.c). + + - The improved libtool scheme revealed a bug in the ordering of + object files in the Makefile (Makefile.in). + +- C++: + - Changed the name of the preprocessor define BROKEN_BOOL to PDF_BROKEN_BOOL + (pdflib.hpp, pdflib.cpp). + + - Changed the C++ test files to return 0 (hello.cpp, image.cpp, pdfclock.cpp). + + - Added several casts to properly deal with the size method of C++ + strings (pdflib.cpp). + + - get_parameter() was accidentally missing from the wrapper code + (pdflib.hpp, pdflib.cpp). + + - Adjusted the return type of PDF_get_buffer() (pdflib.hpp, pdflib.cpp). + + - Includes an image sample (image.cpp). + + - The improved libtool scheme revealed a bug in the ordering of + objects in the Makefile (Makefile.in). + + - Changed the preprocessor conditionals for name space handling (pdflib.hpp). + + - Separates out the name of the standard C++ library, and sets it from + the configure script. Determining whether it is required is however + not yet finally implemented (configure.in, Makefile.in). + +- Java: + - Adds /jdk1.2.[123] to the list of directories to be searched for the Java + header files for the benefit of Cygwin users (configure.in). + + - Adds /usr/local/java and /usr/local/java/alpha to the list of + directories to be searched for the Java header files (configure.in). + + - Implements the "nativeunicode" parameter (pdflib_java.c). + + - Includes a servlet sample (hello_servlet.java). + + - Makes the exception handling in the Java wrapper thread-safe, which was + the last step to a completely thread-safe Java binding (pdflib_java.c). + + - Adds some notes on using PDFLib with Borland/Inprise JBuilder (readme.txt). + + - The error message for a bad PDFlib version used only a single significant + digit (pdflib_java.c). + + - PDF_concat() had accidentally been declared public instead of private + (pdflib.java). + + - Includes an image sample (image.java). + + - Implements several changes which are necessary for the AS/400 JNI + implementation where jlong is a struct (pdflib_java.c): + + - Removes an unneccesary jlong initializer in the wrapper code of + PDF_new(). + + - Casts NULL to jbyteArray in the wrapper of PDF_get_buffer(). + + - Adds a cast to the (jbyte *) argument of ReleaseByteArrayElements(). + + - Conditionally uses a JNI-supplied macro for the assignment of + jlong to long. + + - Made changes to the configure script in order to support the Kaffe + VM which doesn't use the common jni_md.h in its JNI implementation + (configure.in). + + - Relaxed javadoc generation since Kaffe doesn't have a javadoc + implementation (Makefile.in). + + - The Unicode converter didn't report back the correct string length + if the string was empty (pdflib_java.c). + + - libtool versioning information was missing (Makefile.in). + +- Perl: + - Links the Perl wrapper against the Perl library on AIX, Cygwin, and + OSF/1 (configure.in). + + - Removed a number of obsolete functions which were no longer supported in + PDFlib 3.0 but still available (see doc/compatibility.txt for details). + + - PDF_concat still didn't work due to a glitch in the module file and a + missing newXS entry (pdflib_pl.pm, pdflib_pl.c). + + - Adds a CGI variant of the pdfclock sample (pdfclock.pl.cgi). + + - Adjusted the return type of PDF_get_buffer() (pdflib_perl.c). + + - Includes an image sample (image.pl). + + - Cleaned up a few of the many warnings produced by the SWIG-generated + wrapper code (pdflib_pl.c). + + - Implements a number of changes to make the wrapper compatible with + Perl 5.6, mostly required by the discontinued use of PERL_OBJECT in + the ActivePerl build: + + - Introduced another configuration called "oldperl" for building the + wrapper for older ActivePerl versions (perl.dsp). + + - Added the XS macro to the export declaration of boot_pdflib_pl + (pdflib_pl.c). + + - Searches for perl5.6.0 in the configure script (configure.in). + + - Changed the include and lib paths for Perl 5.6.0 on Windows (Perl.dsp). + + - Changed the include path in the VC project file to the Perl/lib/CORE + directory (Perl.dsp). + + - Removed the /Tp option in the VC project file (no longer use C++ mode). + (Perl.dsp). + + - Removed the PERL_OBJECT #define on Windows (pdflib_pl.c). + + - Changed all occurrences of CPerl to CPerlObj, and removed the respective + macro definition (pdflib_pl.c). + + - Changed a preprocessor directive to make the wrapper code compatible + with Perl 5.6 on Unix (pdflib_pl.c). + + - libtool versioning information was missing (Makefile.in). + +- Python: + - Includes an image sample (image.py). + + - Changed the include and lib paths for Python 1.5.2 on Windows (Python.dsp). + + - Removed some dead code from the wrapper code (pdflib_py.c). + + - "make test" tried to make a hard link to a symbolic link, which + doesn't work on all platforms (bind/python/Makefile.in). + + - libtool versioning information was missing (Makefile.in). + +- Tcl: + - Implements the "nativeunicode" parameter (pdflib_tcl.c). + + - Removed a number of obsolete functions which were no longer supported in + PDFlib 3.0 but still available (see doc/compatibility.txt for details). + + - Makes the exception handling in the Tcl wrapper thread-safe, which was + the last step to a completely thread-safe Tcl binding (pdflib_tcl.c). + + - Adjusted the return type of PDF_get_buffer() (pdflib_tcl.c). + + - Includes an image sample (image.tcl). + + - Changed the include and lib paths for Tcl 8.3.1 on Windows (Tcl.dsp). + + - The wrapper now requires Tcl 8.2 or higher. + + - If appropriate, calls Tcl_InitStubs() for Tcl Stubs support + (pdflib_tcl.c). + + - Queries the version number of the Tcl interpreter instead of + relying on the static version number in the Tcl header used + for compiling the wrapper (pdflib_tcl.c). + + - Added some preprocessor directives necessary for the mingw + environment under Windows (pdflib_tcl.c). + + - Removed the DllMain function from the wrapper since it wasn't actually + required but could cause trouble with some wrong precompiler settings + (pdflib_tcl.c). + + - PDF_get_value and PDF_set_value were not properly reported to the + Tcl interpreter, and were therefore unavailable (pdflib_tcl.c). + + - The Unicode converter didn't report back the correct string length + if the string was empty (pdflib_tcl.c). + + +Documentation +============= + +- Adds many clarifications to the manual, as well as some basic text and + graphics handling algorithms (PDFlib-manual.pdf). + +- Includes a PDF with point grid measures for common page sizes (grid.pdf). + +- Updated the Web locations of the png and zlib libraries (readme.txt, + PDFlib-manual.pdf). + +- Added some information on forcing a certain compiler, or certain compiler + flags (doc/readme_unix.txt). + +- Updated the PDFlib license (PDFlib-license.pdf). + +- Included the PDFlib order form (PDFlib-purchase-order.pdf). + + +V3.0 (March 1, 2000) +==================== + +New features and API +==================== + +- Implements the "invert" parameter for PDF_open_image() in order to + work around problems with certain 1-bit TIFF images (p_tiff.c). + +- Implements ascender, descender, and capheight parameters for get_value() + (p_basic.c). + + +Bug fixes and enhancements +========================== + +- Fixed a bad memory leak for all TIFFs which couldn't be handled + in pass-through mode (p_tiff.c). + +- Track the text position even if the supplied string is NULL or + empty (p_text.c). + +- PDFlib attempted to load the UPR resource file too early, even if + the resource query could have been satisfied with dynamically loaded + resources (p_util.c). + +- Empty resource file names (e.g. produced by an empty, but existing + environment variable) were not handled correctly (p_util.c). + +- The y position calculations for PDF_show, PDF_show_xy, and + PDF_continue_text were wrong for nonzero word spacing values. + This also affected PDF_show_boxed (p_text.c). + +- Re-enabled the #ifdef'ed /EncodedByteAlign code (p_tiff.c). + +- Change the cleanup_...() functions in order to make them multiply + callable. This was not the case for certain rare situations when an + exception occured during cleanup (p_annots.c, p_basic.c, p_font.c, + p_hyper.c, p_util.c, p_image.c). + +- The handling of font files with DOS line ends was broken on Unix + systems (p_font.c). + +- The error machinery didn't recognize a certain recursive error situation + related to the handling of corrupt font files (p_basic.c). + +- The font machinery now treats the AFM entry "StandardEncoding" like + "AdobeStandardEncoding" since some AFMs use the former (wrong) + variation (p_font.c). + +- The UPR resource names didn't work in PDF_set_parameter() due to + a typo (p_basic.c). + +- CCITT-compressed TIFFs with multiple strips haven't been handled + properly, and resulted in corrupt output. As a quick fix we revert + to uncompressing and recompressing with Flate (p_tiff.c). + +- The PDF properties sheet in Windows explorer doesn't work when the + Info dictionary keys are not followed by space characters. (This + should be considered an Acrobat bug!) We therefore removed this + optimization in order to work around this misfeature (p_hyper.c). + +- PDF_stringwidth2() didn't take the length argument into account (p_text.c). + + +Build process, distribution, and platform support +================================================= + +- configure improvements (configure.in): + - configure failed to include -I in the include paths for the auxiliary libs. + - configure failed to accept library paths supplied on the command line. + - Unified the handling of the -I option for the various language + include directories. + - Adds -lm to the libpng tests. + - The --disable-shared option didn't work. + +- Changed the install target so that it creates the install directories + for library and header files if they don't exist. This was a problem + especially on RedHat systems where /usr/local/include doesn't exist + (pdflib/Makefile.in). + +- Removed the FORCE: target in the main Makefile (Makefile.in). + +- Added some preprocessor lines for Cygwin support (p_config.h, p_basic.c). + +- Switched to a static version of the PNG library due to problems with + libpng.dll when used with static C runtime (*.dsp). + + +Bindings +======== + +- Java: + - get_value didn't work because of a missing comment terminator (pdflib.java). + + - An exception in get_parameter could result in an access violation in + Windows due to a bug in the wrapper code (pdflib_java.c). + + - Relaxed the compiler setting "strict ANSI" in the CodeWarrior project + for the Java binding on the Mac, since the Apple-supplied Java + headers for MRJ 2.2 do no longer compile in strict mode (pdflib.mcp). + +- Perl: + - PDF_concat didn't work due to a glitch in pdflib_pm.pl. + +- Python: + - PDF_open_image_file() was missing from the set of registered functions, + and was therefore unavailable (pdflib_py.c). + +- Tcl: + - Changed the Windows project file for Tcl 8.3 paths (tcl.dsp). + + - The Tcl install target didn't check whether the install directory + already existed (Makefile.in). + + +Documentation +============= + +- Switched to version 8 of the Aladdin license (aladdin-license.txt). + + +V2.30 (February 15, 2000) +========================= + +New features and API +==================== + +- Implements the ignoremask parameter for PDF_open_image_file() to + allow the user to disable PDFlib's automatic transparency support. + +- Reactivates the disabled PDF_open_mem/writeproc interface for installing + a callback to fetch the PDF data (p_basic.c, p_annots.c, p_image.c, + p_font.c, p_stream.c, pdflib.h, p_intern.h). + +- Removes PDF_set_text_matrix() which has bad interactions with + internal functions and properties of PDF, and doesn't offer any + advantage to the client (p_text.c). + +- Path segment functions no longer reset the text position and matrix + (p_text.c). + +- Implements PDF_get_value() and PDF_set_value() which (along with + PDF_set_parameter()) replace the following functions (p_basic.c): + + get_font + get_fontsize + get_image_height + get_image_width + + set_fillrule + set_leading + set_text_rise + set_horiz_scaling + set_text_rendering + set_char_spacing + set_word_spacing + set_duration + set_transition + + In bindings other than Java and ActiveX these are still available, however. + +- Interprets the image resolution in the image converter client, and + adjusts both page size and scaling factors accordingly (pdfimage.c). + +- Reads the resolution or aspect ratio values from all image formats + which support it, and passes the values to the client (p_jpeg.c, p_png.c, + p_tiff.c, p_gif.c); + +- Implements and documents PDF_concat() (p_gstate.c). + +- Makes the default zoom factor (open action for the first page) user- + settable through PDF_set_parameter() (p_basic.c). + + +Bug fixes and enhancements +========================== + +- PDF_delete() didn't PDF_close() if called from the error handler (p_basic.c). + +- PDF_arc() didn't handle movetos correctly (p_draw.c). + +- Due to a subtle bug in the exception handling machinery non-fatal + errors could cause recursive errors (p_basic.c). + +- PDF_show_boxed() didn't fully justify the second but last line under + certain circumstances, and didn't get forced newlines right + sometimes (p_text.c). + +- PDF_show_boxed() didn't take the text matrix into account correctly + (p_text.c). + +- End the text object if the text render mode is set to one of the + clipping modes (p_text.c). + +- Added an endpath operator to the clip operators to save the client from + doing so (p_draw.c). + +- PDF_open_image() didn't check for a valid params pointer for one- + component images (p_image.c). + +- Non-fatal errors could result in corrupt output due to a glitch + in the error handling machinery (p_basic.c). + +- Implements data pass-through for CCITT-compressed TIFF images. This + decreases the PDF output, and accelerates image processing (p_tiff.c, + p_image.c, p_intern.h). + +- Changed the key of the duration setting from /D to /Dur. The former + is only correct within a transition dictionary (p_basic.c). + +- Implements a complete text and graphics state tracking machinery, + including save/restore (p_intern.h, p_gstate.c, p_draw.c, p_text.c, + p_basic.c). + +- Disallows the use of the null character in user-defined encodings + (p_util.c), and documents the fact. + +- Implemented a stricter state checking machinery for switching + between path objects, text objects, image objects, and the general + page description state (p_text.c, p_draw.c, p_gstate.c, p_image.c, + p_intern.h). + +- The parameter checks in the text output functions were too strict, + and erroneously rejected strings starting with a character code < 256 + in Unicode mode (p_text.c). + +- Removed several remains of an obsolete filename in comments + and a project file (p_intern.h, pdflib_static.dsp). + +- Checks for a degenerate matrix in PDF_set_text_matrix() (p_text.c). + +- Renamed pdf_concat() to pdf_concat_raw() (p_gstate.c). + +- Simplifies the old and new stringwidth/show/show_xy/continue_text + functions pairs such that the old simply relay to the new functions. + A zero length parameter for the new functions is interpreted to + mean C-style text (p_text.c). + +- Fixes the underline/overline/strikeout handling (p_text.c). + +- Made the prefix parameter public (p_basic.c.). + +- Relaxed the handling of metrics files where the font name has been + changed, and doesn't match the user-supplied font name (p_afm.c, + p_pfm.c). + +- The AFM and PFM modules threw NonfatalErrors even in severe cases + (p_afm.c, p_pfm.c). + +- Added an omitted pdf_begin_text() call which resulted in bad PostScript + output when the PDF was printed (p_text.c, p_font.c, p_intern.h). + +- An erroneous byte was output in the header section (p_basic.c). + + +Build process, distribution, and platform support +================================================= + +- Puts double quotes around all variables used in test statements + in the configure script. This will make the script more resistant + against test complaining when a variable happens to be empty (configure.in). + +- Moves the test for EBCDIC from configure to p_config.h. + +- Switches the language bindings on Windows to static C runtime + libraries in order to avoid the dreaded problems with multiple + versions of msvcrt.dll (*.dsp). + +- Added solaris as a subdirectory name in looking for jni_md.h, since + it doesn't seem to be picked up via $ac_md_system (configure.in). + +- Added -lm -lc at a few places in order to help configure find the + auxiliary libraries (configure.in). + +- Changed the handling of the PDF magic number to protect it from + EBCDIC compilers (p_basic.c). + +- Introduces a binary distribution for Windows, generated with a + JScript program run in Windows Script Host (shell programming a la + Microsoft, oh my...). + +- Added "-ljpeg" to TIFFLIBLINK (configure.in). + +- Added "-lz -lm" to the TIFF library check (configure.in). + + +Bindings +======== + +- C++: + - The C++ Makefile failed to set the CXX variable correctly (Makefile.in). + + - Implemented concat() (pdflib.hpp, pdflib.cpp). + + - show_boxed() didn't return a value (pdflib.cpp). + +- Java: + - Reworked and fixed the exception handling (pdflib_java.c). + + - Changed the string extraction routines so that they handle empty + strings gracefully (pdflib_java.c). + + - Implemented concat() (pdflib_java.c, pdflib.java). + + - Calls java and javadoc after compiling the Windows DLL (Java.dsp). + +- Perl: + - Removed the export-dynamic option for libtool (Makefile.in). + + - Implemented PDF_concat() (pdflib_pl.c, pdflib_pl.pm). + +- Python: + - Removed the export-dynamic option for libtool (Makefile.in). + + - Implemented PDF_concat() (pdflib_py.c). + +- Tcl: + - PDF_open_image_file() was missing from the set of exported functions + in the wrapper code (pdflib_tcl.c). + + - Conditionally compiles the wrapper in order to avoid the use of + binary strings when compiling against Tcl 8.0 (pdflib_tcl.c). + + - Implemented PDF_concat() (pdflib_tcl.c, pkgIndex.tcl). + + +Documentation +============= + +- Documents the libtool library versioning scheme (readme_unix.txt). + + + +V2.20 (January 24, 2000) +========================= + +New features and API +==================== + +- Implements PDF_concat(), currently only for the C binding + (pdflib.h, p_gstate.c). + +- Implements PDF_show_boxed(), the basis of which has been contributed + by Leonard Rosenthol (pdflib.h, p_text.c, bind/*/*.c, pdflib_pl.pm, + pkgIndex.tcl, pdflib.hpp, pdflib.cpp, pdflib.java). + +- Implements overline and strikethrough text, as suggested and contributed + by Leonard Rosenthol. API, implementation and behavior parallel underlined + text (p_intern.h, p_basic.c, p_text.c). + +- Implements PDF_get_buffer() for fetching the PDF output from memory + for all language bindings. + + +Bug fixes and enhancements +========================== + +- Fixed three bugs in the AS/400 codepage conversion table (p_stream.c). + +- Fixed a bug in the EBCDIC-safe handling of document info entries + (p_hyper.c). + +- #ifdef'ed all code for dealing with the now obsolete flush parameter. + +- pdf_ebcdic2ascii() didn't return the correct string. Changed the caller + such that the return isn't needed anyway (p_stream.c). + +- The binary PDF magic number was inadvertently written using pdf_puts() + instead of pdf_write() which is wrong on EBCDIC machines (p_basic.c). + +- The debug and nodebug parameters are no longer documented nor supported. + Nonfatal exceptions can be suppressed with the new warning parameter + (p_basic.c). + +- Changes the error handling and memory management such that one pair of + PDF_new()/PDF_delete() can accomodate multiple pairs of PDF_open_*()/ + PDF_close() without leaking memory (p_stream.c, p_basic.c). + +- Fixed a possible crash under rare circumstances, related to an + exception being thrown when no real work has been done (p_stream.c). + +- Changes the underline/overline/strikeout calculations such that the + width of the line is no longer taken into account for calculating + the distance from the baseline (p_text.c). + +- Fixes problems related to setting the current text position via + PDF_set_text_matrix() and PDF_set_text_position() (p_text.c). + +- Removes the transition settings from all clock samples since these + may significantly slow down PDF the screen presentation, especially + when served via the Web (bind/pdfclock.*). + +- Removes the dynamic TIFFlib attachment on Windows, and directly + links to TIFFlib. The TIFFlib DLL will also be included in the + binary distributions (p_basic.c, p_tiff.c, p_intern.h). + +- Changes the TIFF code to use the PDFlib-supplied malloc/free + routines instead of the TIFFlib-supplied ones. This makes the code + for attaching the TIFFlib Windows DLL at runtime compatible with + the generally available DLL (p_tiff.c, p_basic.c, p_intern.h). + +- Changes PDF_findfont() such that an exception is raised when the + requested font can't be set, instead of returning -1 (p_font.c, + bind/*/hello.*, test/pdftest.c). + +- An error message had a wrong printf format (p_state.c). + +- Accepts the image file type parameter of PDF_open_image_file() in + both lower and upper case, although this will not be documented + (p_image.c). + +- Removed the optimization which tried to keep track of redundant + font changes (p_font.c). + +- "builtin" encodings no longer worked after the great encoding rehaul, + but required only a simple fix (p_font.c). + +- Implements a safeguard against recursive I/O errors which may occur + in rare situations when flushing the output raises an exception while + being called from the exception handler already (p_intern.h, p_basic.c, + p_stream.c). + +- The stream machinery didn't get initialized in PDF_open_fp(), resulting + in an infinite recursion (well, a finite one...) when opening a PDF + with a preexisting FILE pointer (p_basic.c). + +- Changes several places where #includes had filenames in "..." instead + of <...>, resulting in bad dependencies in the Makefiles (pdflib/p_intern.h, + util/compile_metrics.c, pdflib_pl.c, pdflib_py.c, pdflib_tcl.c). + +- The compile_metrics utility was not yet adapted to the new encoding + include file logic (util/compile_metrics.c). + + +Build process, distribution, and platform support +================================================= + +- Under Windows switched all language bindings other than C and C++ + from a DLL to a static PDFlib library (bind/*/*.dsp). + +- Improves and simplifies the searching mechanism for Perl, Tcl, Python, + and Java in configure (configure.in). + +- Simplifies and streamlines the configure code for detecting the + TIFF, Zlib, and PNG libraries (configure.in). + +- Switches to libtool 1.3.4, and back to 1.3.c due to problems with + the former (config/*). + +- Fixes many glitches in the configure and build machinery. + +- Makes the name of the core PDFlib library file configurable via + the --with-libname configure option in order to work around a name + clash on Digital Unix 4. The bindings are set up such that changing + the core library name is transparent to the language binding + (configure.in, all Makefile.in). + +- Includes an encoding file for ISO 8859-15 in the distribution + (fonts/iso8859-15.enc), and changed the Latin 2 encoding file name + (fonts/iso8859-2.enc). + +- Changed the ordering of libpng and zlib when linking programs against + PDFlib since older linkers require this ordering (Makefile.in). + +- Moved the .PHONY targets in the Makefiles below the all target for + combatibility with non-GNU makes. + +- Implements a suitable mechanism for patching the version number into + numerous source files, and splits it from the distribution (version.pl). + +- Fixes a number of Makefile bugs which resulted in wrong dependencies + (*/Makefile.in). + + +Bindings +======== + +- C++: + - Changes the data parameter of open_image() from String to const char * + which is more appropriate (pdflib.hpp, pdflib.cpp). + +- Java: + - Implements Unicode support for page descriptions (pdflib_java.c). + + - Changes the data parameter of open_image() from String to byte[] + which is more appropriate (pdflib.java, pdflib_java.c). + + - Correctly implements setpolydash() (pdflib_java.c). + + - Includes javadoc comments and Makefile targets for generating Java + documentation in HTML (pdflib.java, Makefile.in). + + - Implements package support for PDFlib, and generates a .jar file + (*.java, *.c, Makefile.in). + + - Changes the version mechanism for the Java wrapper to use version + number querying instead of matching version numbers in the name of + the wrapper library (pdflib_java.c, Makefile.in, Java.dsp, pdflib.h). + +- Perl: + - Correctly implements PDF_setpolydash() (pdflib_pl.c). + +- Python: + - Correctly implements setpolydash() (pdflib_py.c). + +- Tcl: + - Implements Unicode support for page descriptions (pdflib_tcl.c). + + - Searches for tclsh8.3 in configure (configure.in). + + - Correctly implements PDF_open_image() (pdflib_tcl.c). + + - Correctly implements PDF_setpolydash() (pdflib_tcl.c). + + - Changed all occurrences of atol() in the wrapper code to Tcl_GetInt() + or Tcl_GetLongFromObj() with appropriate error handling (pdflib_tcl.c). + + - Implemented suitable conditionals to allow for compiling the Tcl + wrapper with different versions of Tcl. This was necessary because of + the Unicode support which is only available in Tcl 8.2 (pdflib_tcl.c). + + +Documentation +============= + +- Addes a description of the PDFlib commercial license to the distribution + (PDFlib-license.pdf). + +- Introduces javadoc comments. + + +V2.10 (December 13, 1999) +========================= + +New features and API +==================== + +- Makes the page dimensions adjustable after starting a page, using + PDF_set_parameter (p_basic.c). + +- Made a variety of changes to make PDFlib work when compiled on + EBCDIC-based systems (most *.c, p_intern.h). + +- Made the Zlib compression level configurable (p_basic.c, p_stream.c). + +- Switched to in-core PDF generation through the new pdf_streams + interface. This also allows us to compress page content streams + and to simplify handling of compressed data streams (all *.c, p_intern.h). + +- Implements transparency support (masking by position or color) (p_gif.c, + p_png.c, p_image.c, p_intern.h). + +- Implements a PNG handler (p_png.c, pdflib.h, p_intern.h). + +- Font handling: + + - Implemented support for null characters in text strings for all + language bindings (p_text.c, bind/*/*.c). + + - Implemented support for CID fonts and CMap encodings (p_font.c, p_cid.h). + + - Implemented underlined text (except for CID fonts) (p_text.c). + + - Implements support for user-defined encodings, and includes + a sample encoding file (p_fonts.c, fonts/pdflib.upr, fonts/latin-2.enc). + + - Implements EBCDIC encoding (p_font.c, e_ebcdic.h, p_intern.h, + p_metrics.h, util/compile_metrics.c). + + - Implements support for PFB PostScript font files (p_font.c). + + - Implements support for PFM PostScript font metrics files (p_pfm.c). + +- Updates to the AFM parser (p_afmparse.c, p_afmparse.h): + + - The FONTBBOX is read as float which is required by the 4.1 spec. + + - Recognizes Multiple Master fonts by FamilyName ending in " MM". + + - Allows the WEIGHT entry to contain more than one word. + +- Implements limited Multiple Master handling for an in-house + application (p_font.c): + + - As in PostScript, MM handling is transparent at the API level. All + MM handling is done by extracting the parameters from the font name. + + - All instances of an MM font are required to have the same metrics + (i.e., no support for /Width axis). + + - The required AFM file is that for the master. + +- Implements PDF_skew() in order to provide for a full set of coordinate + transformation functions (p_gstate.c). + +- Reactivates ASCII85 encoding which lay dormant in previous releases + (p_intern.h, p_filter.c). + + +Bug fixes and enhancements +========================== + +- Fixed a bug where PDF_moveto() wouldn't set the text position + correctly (p_text.c). + +- Corrects a small glitch where pdf_float() would return the + correct result string, but fails to use the supplied buffer (p_util.c). + +- Makes the PDF compatibility user-settable (again). The reasoning + behind this is not obvious, and discussed in the manual. If the + compatibility level is set to PDF 1.2, asking PDFlib to generate + any Acrobat 4 feature will result in a RuntimeError (*.c). + +- Adds a little PostScript utility for finding all glyph names in + a font (fonts/print_glyphs.ps). + +- Implements support for dynamically loading TIFFlib at + runtime (p_basic.c, p_tiff.c, p_intern.h). + +- Removed all references to PDFDocEncoding since it isn't required + for hypertext elements, and can't be used for text fonts (e_pdfdoc.h). + +- PDF_arc() implicitly moves to the beginning of the arc segment in + order to avoid unwanted connecting lines from the current point to + the beginning of the arc segment (p_draw.c). + +- All public PDFlib functions perform a simple sanity check on their + p argument before accessing any structure member. This reduces the + chances for a crash due to client-supplied NULL or rogue pointers (*.c). + +- Include the names of the language binding and the platform in the + /Producer entry (p_basic.c, p_intern.h, p_hyper.c, bind/*/*.c). + +- Added the width of the Euro character to the supplied internal and + external metrics tables (*.afm, p_metrics.h). + +- Replaced the AFM files with newer versions, and used the additional + data in the internal metrics tables. The kerning information + has been stripped for size and performance reasons (fonts/*.afm). + +- When user-requested encoding and font-supplied encoding didn't match, + PDFlib could try to reencode Symbol fonts with not adequate encodings + (like Symbol with Winansi) -- despite issuing a warning message + (p_font.c). + +- PDF_stringwidth() now takes the text state parameters into account, + and protects itself from empty strings (p_text.c). + +- Removed the pdf_begin_text() calls in all functions that set the + text state (p_font.c, p_text.c). + +- Do not set the leading parameter in PDF_setfont() since it may + override a leading value set by the user (p_font.c). + +- Changed the name of the pseudo encoding vector from "default" to + "host" (p_font.c, most bind/*/hello.*). + +- Checks the scale parameter of PDF_set_horiz_scaling() to be positive + (p_text.c). + +- Write the colormap for an image also in compressed or ASCII format + if requested (was previously the case only for the actual image + data, but not the colormap) (p_image.c). + +- The 'w' debug parameter for enabling or disabling warning messages + was erroneously implemented as 'e' instead. Now it works according + to the documentation (p_basic.c). + +- Adds (void) casts to several fputc() and fputs() calls. + +- Changes the PDF output to avoid unnecessary blanks aside self-delimiting + tokens in many places (most *.c). + +- Checks current font and font size in PDF_setfont() in order to eliminate + redundant setting. This requires initializing the current font to an + invalid value of -1 in PDF_begin_page() (p_font.c, p_basic.c). + +- Image handling: + + - When the error handler popped in for memory images with bad length it + would try to free not yet allocated memory. We guard against this by + prematurely setting the image file name to NULL (p_image.c). + + - The parameter checking code in PDF_open_image() and the documentation + didn't account for images with other than 8 bits per component + (p_image.c). + + - The test for the length of the image data in memory for PDF_open_image() + could still be wrong when bpc was smaller than 8 (p_image.c). + + - GIF images with a local colormap ended up with a colormap with all + black entries in the PDF because the local colormap was read when the + (wrong) global colormap was already written to the PDF (p_image.c). + + - Detect and correctly handle transparent colormap entries in GIF + images (p_image.c, p_gif.c, p_intern.h). + +- Changes the PATHSEP definition for VMS and moves HAVE_GETOPT to the + top of the include file (p_config.h). + +- The pdfgraph.c and pdfimage.c sample clients incorrectly advertised + a binary option in their usage messages although the option is no longer + available. + +- Check the parameters of PDF_scale() for zero values (p_gstate.c). + +- Introduce parenthesis in a set of critical macro definitions (p_gif.c). + +- Changed the text2pdf client to PDF_findfont/PDF_setfont instead of + the obsolete PDF_set_font(). + +- Unified the names of the encoding files to e_*.h (formerly *_e.h). + +- Removed the obsolete compatibility function PDF_set_font (p_font.c, + pdflib.h, bind/*/*.c, bind/perl/*.pm). + + +Build process, distribution, and platform support +================================================= + +- Removed the sample CGI script (bind/cgi). + +- Removed the pdfgraph demo program (clients directory). + +- Removed the optional getopt module (util directory, Makefile.in). + +- Adds support for the DJGPP compiler (p_config.h). + +- Adds support for libtool in order to cleanly deal with the gazillion + kinds of shared library support (configure.in, Makefile.in, test/Makefile.in, + pdflib/Makefile.in). + +- Introduces the new config directory for libtool and installation support + scripts. + +- Added the ANSI option for native HP compilers (configure.in). + +- Properly implements all configure switches for disabling the language + bindings (configure.in). + +- Starts adding support for OS/2 and VMS systems. + +- Adds support for EBCDIC-based systems, including source code changes + and an EBCDIC test in the configure script (configure.in). + + +Bindings +======== + +- SWIG: + - No longer automatically generates the wrapper file with SWIG due to + the necessary amount of manual changes in the wrapper files + (bind/*/Makefile.in). + +- C: + - The arguments to PDF_begin_page() were incorrectly cast to the wrong + type instead of float. Incidentally, a particular compiler incorrectly + produced zero values, thereby disclosing the bug in the source code by + a compiler bug (pdfclock.c). + +- C++: + - Implements support for strings containing null characters. + + - Added PDF_shutdown() to the PDF destructor (pdflib.cpp). + + - PDF_close_image() was missing from the C++ interface due to an + oversight (pdflib.hpp, pdflib.cpp). + + - Added -lstdc++ to the Makefile. + +- Java: + - On Windows separates the wrapper DLL from the PDFlib core DLL. + + - Implements support for strings containing null characters. + + - configure now looks in an additional subdirectory for the machine- + dependent JNI include file. Formerly it used $MACHDEP only, but + on some systems the subdirectory doesn't use the system version number + (configure.in). + + - Rewrote the wrapper code so that it does the right thing with Unicode + strings (pdflib_java.c). + + - Switched to a more object-oriented notation, and dropped the PDF_ + prefix from the names of the PDFlib Java methods (pdflib_java.c, *.java). + +- Perl: + - On Windows separates the wrapper DLL from the PDFlib core DLL. + + - Removed the unused and unsupported Makefile.PL. + + - Implements support for strings containing null characters. + + - Removed PDF_boot() and PDF_shutdown() which have accidentally been + included in the wrapper code (pdflib_pl.c, pdflib.pm). + + - Integrated wrapper code changes in order to make the PDFlib wrapper + compatible to versions of Perl newer thant 5.005_54 (pdflib_pl.c). + + - Added an export list to the pdflib Perl module. This makes it easier + to use our module along with other modules. Clients need no longer + write "package pdflib" at the beginning since all functions are + exported (pdflib.pm, hello.pl, pdfclock.pl). + +- Python: + - On Windows separates the wrapper DLL from the PDFlib core DLL. + + - Due to a necessary change in the name of the library, script must + now use "from pdflib_py import *" (instead of "pdflib"). + + - Implements support for strings containing null characters. + + - Removed PDF_boot() and PDF_shutdown() which have accidentally been + included in the wrapper code (pdflib_py.c). + + - Searches for the lib-dynload directory where to install the shared + library for Python (configure.in). + +- Tcl: + - On Windows separates the wrapper DLL from the PDFlib core DLL. + + - Changed the name of the wrapper library from pdflib.so to pdflib_tcl.so + (pkgIndex.tcl). + + - Rewrote the wrapper code so that it does the right thing with Unicode + strings (pdflib_tcl.c). + + - Implements support for strings containing null characters. + + - Tcl 8.0 is now required because of the support for binary strings + (configure.in). + + - Removed PDF_boot() and PDF_shutdown() which have accidentally been + included in the wrapper code (pdflib_tcl.c, pkgIndex.tcl). + +- Visual Basic: + - Removed the Visual Basic binding since VB is much better covered by the + new PDFlib ActiveX control (bind/vb/*). + + +Documentation +============= + +- Added platform-specific readme files (doc/readme_.txt). + +- Added an appendix dealing with shared libraries to the manual. + +- Removed the redundant list of configure options from doc/install.txt. + +- Changed all occurrences of PDFlib's WWW address to www.pdflib.com. + + +V2.01 (August 3, 1999) +===================== + +New features and API +==================== + +- Extends the JPEG reader to allow for progressive JPEG images which are + supported in PDF 1.3/Acrobat 4 (p_jpeg.c). +- Applies a workaround for Photoshop-generated CMYK JPEG images. The + algorithm is taken from my jpeg2ps utility: detect the Adobe marker, + and write a suitable /Decode array to invert the 4 color planes (p_image.c). +- Introduces the concept of a "default" encoding which evaluates to + macroman or winansi according to the current platform. This facilitates + writing identical test programs for all platforms. All samples except + those for Visual Basic (which is Windows-only) have been adjusted to use + the default encoding. +- Streamlines the image file interface in several ways: (pdflib.h, p_intern.h, + p_image.c, p_gif.c, p_tiff.c, p_jpeg.c, p_ccitt.c, p_basic.c, + bind/vb/pdflib_vb.idl, bind/vb/pdflib_vb.def, clients/pdfimage.c, + bind/cpp/pdflib.[h|c]pp, test/pdftest.c). + - Removes PDF_place_inline_image() since it doesn't seem to bring any + real advantage to PDFlib clients. + - Removes PDF_put_image() since the image data is "parked" in the ouput + immediately on PDF_open_*(). The /Name key is no longer in Xobjects + since it was only required by PDF 1.0. + - Removes PDF_execute_image(). Instead, PDF_place_image() can now be + called multiple times for re-using image data. + - Consolidates all pdf_close_*() functions in PDF_close_image. All + image-specific stuff is now done at the end of PDF_open_*(). + - PDF_open_*() (along with the newly implied pdf_put_image()) is now + allowed outside of page descriptions. This requires pdf_put_image() + to do a pdf_begin_contents_section() in some cases. +- Adds several symbolic names for new destination zoom values in + PDF_add_pdflink() and PDF_add_locallink() (p_annots.c). +- Added an undocumented hook for placing existing images as thumbnail + for the current page. This is for a specialized application and is + not supported at the scripting layer (p_image.c, p_image.c, p_intern.h). +- Changed PDF_open_memory_image() to PDF_open_image(). This makes memory + images accessible from the scripting languages, and adds support for + file and url references as placeholders for the actual image data + (pdflib.h, p_image.h, p_intern.h, bind/vb/pdflib_vb.idl, bind/cpp/pdflib.hpp, + bind/cpp/pdflib.cpp). + + +Bug fixes and enhancements +========================== + +- A static resource configuration file (pdflib.upr) was always opened + when the client dynamically added resources. We skipped the file open + step since it's well reasonable to work with dynamic configuration + exclusively (p_util.c). +- Fixes a crash due to an uninitialized member of the PDF struct + (resourcefile_loaded). The bug showed up when trying to use non-standard + fonts (p_basic.c). +- Added a number of casts to avoid assignments to variables which are + never used. This basically affected the contents of comment and notice + lines in AFM files, which are not being used (p_afmparse.c). +- Merged the metrics files for macroman and winansi core metrics + (p_metrics_win.h, p_metrics_mac.h) to a single file (p_metrics.h, + p_font.c, Makefile.in, pdflib/Makefile.in, PDFlib.hqx, *.dsp) +- Makes DLLMain only visible when PDFLIB_EXPORTS is defined (p_basic.c). +- Changed the default page transition duration to 0 in order to avoid + unnecessarily writing the duration key to all page dictionaries (p_hyper.c). +- Changes to example path prefix in pdflib.upr to make it clearer that + the upr file has to be adjusted before it can be used (fonts/pdflib.upr). +- The debug flags didn't work due to a typo (p_basic.c). +- Debug flag 'u' (don't unlink PDF file on error) was implemented the wrong + way, and didn't match the documentation (p_basic.c). +- Improves the memory management by avoiding "semi-allocated" aggregated + objects. This involves subtle changes around the realloc() calls, + and cleaner initialization of the reallocated data. The benefit of this + shows up in memory-out situations when the error handler pops in and tries + to free memory blocks which are not completely initialized. This may + especially happen in multi-threaded environments (p_intern.h, p_basic.c, + p_font.c, p_images.c, p_hyper.c). +- Fixes some inconsistencies related to link border style, color, and + destination zoom (p_annots.c). +- Removed the beveled, inset, and underlined link border styles since they + don't work as advertised in the PDF specification (p_annots.c, pdftest.c). +- Improves the handling of XObject resources: formerly all Xobjects used + in the document up to the current page had been placed in the page's + resource list, potentially cluttering up the print stream generated for + the PDF. Now we only list the XObjects which are actually used on the + current page. This change will not affect Acrobat's viewing behavior. +- The bpc and components values of TIFF image weren't always properly + reported by TIFFlib. We improved this by using TIFFGetFieldDefaulted() + instead of TIFFGetField() for retrieving these (p_tiff.c). + + +Build process, distribution, and platform support +================================================= + +- Several improvements in the configure machinery (configure.in, Makefile.in): + - Added a --without-cxx option to the configure script in order to make + life easier on systems where the C++ is not correctly recognized. + - The include and lib paths for perl/zlib/tifflib shown with + "configure --help" had some differences from the actual spelling of + the supported options. + - Included a number of changes to the configure script required to make + the shared library versioning work on NetBSD systems. + - The --with-perlincl option for configure didn't work. + - Added a number of conditionals for the Cygwin environment. + - Always puts the version number in the file names of the shared and + static PDFlib libraries. Previously the static library ended up without + a version number in its name, possibly leading to mismatches with later + versions. + - Introduces configure variables for the names of the shared and static + libraries. This allows us to easily build the "other" library (as opposed + to the one specified when configure was run) as well. +- Removes the -g option from all Makefiles (pdflib/Makefile.in, + clients/Makefile.in, util/Makefile.in, bind/c/Makefile.in, + bind/cpp/Makefile.in, test/Makefile.in) +- The util Makefile is no longer called by default since the utility programs + are currently not needed by ordinary library users (Makefile.in). +- Notes that the util Makefile needs an installed PDFlib library + (util/Makefile.in). +- Assorted changes suggested for supporting the Cygwin32 development + environment. These involved several Makefile.in files, configure.in, and + C source modules which make use of getopt(). Most of the changes enhanced + the configuration machinery for other systems, too. +- Removes the install targets for the C and C++ bindings in the main + Makefile since those targets weren't used anyway (Makefile.in). +- Changes the $@.$(OBJ) construct in all Makefiles to the actual name of + the object (we don't want to use $< since it doesn't work everywhere) + (*/Makefile.in, bind/Makefile.in). +- Removed a leftover text file (util/readme.txt). +- Cleaned up the configuration information in the MSVC project files. + Most projects now only support a "Release" configuration; only pdflib + and test have "Debug" configurations, too (pdflib.dsp, bind/*/*.dsp). +- Includes a separate project for building PDFlib as a static library + with MSVC. +- Better supports the Mac distribution (Makefile.in): + - Changes the CodeWarrior project file name suffix from the odd mu + character to the more Unix-friendly .mcp. Since the project file + doesn't contain a resource fork, there's no need to use binhex (.hqx) + encoding. + - Convert the lineends in all relevant text files to the Mac convention. + - Implements a procedure for setting the correct file types for all + relevant files (uses a utility program on the Mac). + - Makes a self-extracting distribution fileset for the Mac. + - Changes the Mac build of the shared library to link static C runtime + libraries (instead of the previously used DLLs). This avoids the need + for certain Metrowerks libraries at runtime (PDFlib.hqx). + - Expands the Macintosh project file with support for the Java/MRJ, Python, + Perl, and Tcl bindings. + + +Bindings +======== + +- C: + - One of the test programs didn't check the return value of PDF_open() + (pdfclock.c). + - Corrected a typo in the clean target of the makefile (Makefile.in). + +- C++ + - Changes the C++ wrapper such that setting the define BROKEN_STRINGS + reverts from ANSI C++ string handling to plain old C char pointers. + As it turned out, ANSI C++ strings are badly supported by many + compilers. Besides, there was a typo in the old construct (pdflib.hpp, + pdflib.cpp). + +- All SWIG bindings + - Introduces export pragma for exporting PDFlib routines for the SWIG + bindings on the Mac (pdflib/pdflib.i, bind/*/pdflib_*.c) + +- Java: + - Makes the Java binding work with the Macintosh Runtime for Java (MRJ) + 2.1 (PDFlib.mcp). + - The pdflib Java initialization sleeps some time if the shared library + cannot be loaded. This is a benefit on systems where the Java console + immediately disappears on exit. + - The MSVC project file for the Java binding used file names with the + path of a beta version for all source files (Java.dsp). + +- Perl: + - The DEFINES variable was missing in the definition of CFLAGS + (bind/perl/Makefile.in). + - Makes the Perl binding work on the Macintosh (PDFlib.mcp). + - Includes a first version of a MakeMaker-compatible Perl script for + generating a Makefile which more closely fits the Perl environment. + The Perl-generated Makefile can be used instead of the configure- + generated one in bind/perl. Note that the Perl script itself must be + generated by the configure script. + - Notes how to build the PDFlib Perl binding with recent versions of + Perl, e.g. 5.005_57 (bind/perl/readme.txt). + +- Python: + - The DEFINES variable was missing in the definition of CFLAGS + (bind/python/Makefile.in). + - Makes the Python binding work on the Macintosh (PDFlib.mcp). + - Makes the test programs exit cleanly in case of error (hello.py, + pdfclock.py). + +- Tcl: + - The Tcl package index file didn't get updated properly due to + the LD_LIBRARY_PATH variable not being properly exported + (bind/tcl/Makefile.in). + - Fixed a typo in the hello test program. Apparently it worked correctly + anyway because of some particular circumstances and missing type + checking in the SWIG-generated code (hello_tcl.pdf). + - Makes the Tcl binding work on the Macintosh (PDFlib.mcp). + +- Visual Basic: + - The return value of all image open functions was erroneously declared + void instead of int. We had to change the GUID after this correction, + but the 2.01 API lost some image functions anyway (pdflib_vb.idl). + + +Documentation: +- Slightly expands the comments in pdflib.upr. +- Adds several clarifications and minor additions to the manual, and cuts + down the size of the PDF manual by optimizing font and image handling. +- Adds information to the manual about configuring the shared libraries + for scripting under Unix, Windows, and Mac. +- Adds descriptions of the few new features to the manual. +- Removes the bind/*/pdflib_*.doc text files since they don't add any + real value to the big PDFlib manual which is supplied in PDF format. +- Brings the sections in pdflib.h in sync with the sections in the main + manual (although the SWIG-generated doc files are no longer distributed). + + +V2.0 (June 30, 1999) +===================== + +Bug fixes and enhancements: +- Implements a better scheme for making sure the ordering constraints + for PDF page descriptions are obeyed while not bothering library + clients with most of the details (p_gstate.c, p_draw.c, p_text.c). + The remaining constraints are documented in the manual. + + +Build process, distribution, and platform support: +- Further tweaks the support for shared libraries on OpenStep 4 (configure.in). + + +Bindings: +- All bindings: + - The shared libraries built for a specific language binding inadvertently + referred to a hard-coded path to the actual PDFlib library (../../pdflib). + In order to avoid this, the -L and -l options are used instead of + supplying the relative name of the library file for linking the + shared libraries or test programs (bind/*/Makefile.in, configure.in). + This means LD_LIBRARY_PATH has to be set for testing. + +- Java: + - Removes the pointless import statement from the Java samples + (hello.java, pdfclock.java). + +- Tcl: + - Added LD_LIBRARY_PATH when generating the Tcl package index file + in order to find the PDFlib shared library (bind/tcl/Makefile.in). + + +Documentation: +- Explains more of the PDF graphics model, and documents the + restrictions and interactions among graphics-related functions + (doc/PDFlib.pdf). + + +V1.92 (June 27, 1999) +===================== + +Bug fixes and enhancements: +- PDF_translate() erroneously used the same value for both coordinates + (p_gstate.c). +- A subtle "unreachable code" warning was issued by the Watcom + compiler, and he was right (p_util.c). +- Fixed a bug in the GIF code which caused a crash on the Mac due to + an improper variable initialization. The bug had been introduced + in the transition to thread-safe GIF handling in 1.91, and didn't + affect other platforms. +- Cleaned up several places which look like empty statements within + a conditional (p_gif.c). +- Slightly changes the PDF output. Although legal PDF, some properties + caused problems with PDFviewer, a non-Adobe PDF viewer for OpenStep + written by Detlev Droege: + - Don't count the newline character into the /Length key of colormap + objects because this leads to problems in the PostScript output + generated from the PDF (p_image.c). + - Don't compress inline images (p_image.c). +- A missing initialization caused a crash on Windows (p_hyper.c). + + +API: +- Implemented PDF_set_fillrule() for setting the area algorithm used + by PDF_fill(), PDF_fill_stroke(), PDF_closepath_fill_stroke(), and + PDF_clip() (pdflib.h, p_gstate.c, p_draw.c). This change was + requested and implemented by Evgeny Stambulchik + . +- Allows for dynamic font configuration by adding all UPR categories + to the list of supported parameters in PDF_set_parameter() (p_basic.c, + p_util.c). + + +Build process, distribution, and platform support: +- Added some compiler-dependent conditionals in order to make the + C++ binding work with non-ANSI compilers (bind/cpp/pdflib.hpp, pdflib.cpp). +- Improves compatibility with OpenStep 4.x: + - Added an include file required for getopt (util/compile_metrics.c). + - Enhanced configure for shared libraries on OpenStep 4.x (configure.in). + - Don't build the C++ binding (configure.in). +- Removed the additional Makefiles for MS VC++ and the complete port + subdirectory from the distribution (port/msvc/*). + + +Bindings: +- SWIG: + - Made PDF_boot() and PDF_shutdown public in order to avoid problems + with the SWIG wrapper files which may use them (pdflib.h). + - Made the exception jump buffers for the SWIG bindings static which + they should have been anyway (pdflib.i). + - Adds the define PDFLIB_STATIC to the project files for the SWIG + bindings on Windows because we don't want to export the core + PDFlib functions from the DLL in the SWIG case. + +- Java: + - Adds a MS VC++ project file for the Java binding (bind/java/Java.dsp). + +- Tcl + - Adds a MS VC++ project file for the Tcl binding (bind/tcl/Tcl.dsp). + +- Perl + - Adds a MS VC++ project file for the Perl binding (bind/perl/Perl.dsp). + - Introduces patches and quirks to support PDFlib with ActivePerl on + Win32. Although our configuration works for a certain software + combination, all issues are documented (pdflib/pdflib.i, perl/readme.txt). + - Changed the order in which Perl executable names are searched. The + more likely name "perl" now is searched first (configure.in). + - Don't map bool to char in the Perl module on NeXT, since the Perl + include files contain special handling for bool which breaks with our + usual defines (configure.in, bind/perl/Makefile.in). + +- Python + - Adds a MS VC++ project file for the Python binding (bind/python/Python.dsp). + + +Documentation: +- doc/compatibility.txt had some deprecated advice on the use of PDF_close(). +- Added several clarifications and corrections to the manual. +- Adds a table of tested version numbers for the language bindings to the + manual. +- Reduced the number of fonts used in the manual. +- Delivers the manual in PDF 1.2 format to avoid triggering a PostScript + error when printing PDF 1.3 files with color images from Acrobat 3. +- Changed the page size format of the manual in order to cut down the + total number of pages. + + +V1.91 (June 18, 1999) +===================== + +Bug fixes and enhancements: +- Fixed a typo involving a printf %s format in an error message (p_font.c). +- Fixed two NULL pointer accesses for AFMs without a Weight entry + (p_afmparse.c, p_font.c). +- Extends the AFM parser which was required for correctly processing certain + non-Adobe AFM files (p_afmparse.c): + - Added the new key "Characters" to the AFM parser. The value is ignored + since it is duplicated in "StartCharMetrics". + - Changes the handling of the "Version" key in AFMs such that arbitrary + strings are allowed after the keyword, not only single tokens. + - Changes the handling of the "Encoding" key in AFMs such that it is + optional, not required (p_afmparse.c). +- Allow blank lines and comment lines in upr files (p_util.c). +- Removed the remaining non-const globals in the GIF module, thus making + GIF processing thread-safe (p_gif.c, p_intern.h). +- Adds multithreading for Win32 to the test bed (test/pdftest.c). This + nicely demonstrates PDFlib's thread-safety. +- Changes the debug configuration and output machinery to a more flexible + system with control over individual debug facilities. +- Adds const to the PDF_set_font declaration and definition. +- Removed sys_errlist from makepsres in order to make it POSIX compliant. +- Added some cleanup code for places discovered with a purify session: + - The resource handling machinery didn't close the handle to the + resource file (p_util.c). + - The client-provided resource file name wasn't freed (p_basic.c). + - The base structure for ligatures in the AFM parser wasn't freed + (p_afmparse.c). +- Changed the cleanup routines to make sure the output file is closed + in case of error (p_basic.c). +- Two non-initalized members of the PDF struct caused a core dump at + clean-up time under rare circumstances (p_basic.c, p_image.c). +- Adjusted the output format of float values to the limits documented in + the PDF spec (p_util.c). +- The annotation border style and color were not correctly initialized + due to a typo (p_basic.c). +- The transition info didn't get properly initialized (p_hyper.c). + +API: +- (Again) bundles PDF_close_file() and PDF_close_fp() to PDF_close() since + clients should not be affected by the way in which the PDF had been + opened. +- Slightly rearranged some functions to other C modules in order to + make the API structure and manual clearer. +- Removed PDF_finalize() from the API and reworked PDF_delete() so + that it may be used for cleanup in case of error. +- Changed the error handler's signature to include PDF * to make it + easier for client-supplied handlers to do a PDF_delete(p) (p_basic.c, + p_intern.h, pdflib.i). +- Changed the first argument of the memory management procedures back + to PDF *, since the client can retrieve his own opaque pointer via + PDF_get_opaque(). + + +Build process, distribution, and platform support: +- Added several casts in order to pacify the CodeWarrior compiler. +- Added a Macintosh-encoded variant to the sample text in pdftest.c. +- The configure script set the TIFF include path even when no TIFF support + was installed/found (configure.in). +- Adds the AFM files to the distribution (again), and moves pdflib.upr to + the directory where the AFMs live (fonts/*.afm, fonts/*.upr). +- Adds a --with-debug option to the configure script which activates the + debugging facilities, and implies building PDFlib as a static library. +- Adds a test for the JPEG library to the configure script since the + JPEG library is needed by some versions of the TIFF library. +- Changes a couple of places for compilation with the Watcom compiler: + - Maps the __WATCOMC__ #define to WIN32 (p_config.h). + - Introduced a typedef for the first function argument of PDF_new2() + since the Watcom compiler issues a dubious warning otherwise (pdflib.h). + - Includes io.h for the unlink() declaration (p_basic.c). +- Changed the sample images included in the distribution (pdflib.gif, + tm.g3, acroweb_j.tif) +- Removed the makepsres program from the distribution. +- Adds compiler optimize flags by adding $CFLAGS to $DEFINES (configure.in). + + +Bindings: +- All SWIG bindings: + - The dist target in the main makefile called the version target, resulting + in updated access times for the SWIG-generated wrapper files. This in + turn resulted in SWIG being launched unnecessarily on the client system. + We now simply touch the wrapper files before preparing the tar file. + +- Java: + - PDF_boot() and PDF_shutdown need not be available to the Java API + since PDFlib booting is done automatically for the Java binding. + - The hello example didn't obey the new PDF_findfont() semantics + (bind/java/hello.java). + +- Perl: + - Fixed a typo (1 should be -1) in the font error handling line (hello.pl). + +- C: + - Moved hello.c and pdfclock.c to a separate directory bind/c. + - A bug in the configure.in script prevented the test rules for the C + and C++ bindings from being executed. + - The C hello example didn't obey the new/open_file semantics + (bind/c/hello.c). + +- C++: + - Renamed the bind/c++ directory to bind/cpp in order to avoid problems + with some older build environments (Makefile.in, PDFlib.dsw, configure.in). + - Reworks the C++ binding in order to make it work with the Watcom compiler: + - Don't use namespaces + - Special string handling, including conversion to chars. + - Adds a macro to change the conversion of C++ string to C chars since + Watcom doesn't support the ANSI conforming c_str() method. + - Removes the page loop and the sleep() call which had inadvertently + been left over. + - A bug in the configure.in script prevented the test rules for the C + and C++ bindings from being executed. + - Changed the PDF constructor in order to allow for client-supplied + error and memory management routines, and adds default NULL values for + these. + + +Documentation: +- Switches to version 7 of the Aladdin Free Public License, and includes + the license text as PDF (doc/license.pdf). +- Includes brief API documentation files for the SWIG-generated language + bindings (bind/*/*.doc). +- Includes the updated and reworked edition of the PDFlib manual + (doc/PDFlib.pdf). + + +V1.90 (June 2, 1999) +==================== + +New Features: +- Makes PDFlib thread-safe by removing the remaining few writable globals. +- Use magic numbers for image file formats (imagepdf.c) +- Supports Unix PostScript Resource files (*.upr) for describing the AFM + and font file names, and an environment variable pointing to the resource + file. +- User-defined document information field (in addition to Title, Author, etc.) +- Unicode-enables bookmarks, text annotations, and document info entries + (p_hyper.c, p_annots.c, p_text.c). +- Changed the encoding vectors according to PDF 1.3. The most relevant + change is the inclusion of /Euro in WinAnsi and PDFDoc encodings + (ansi_e.h, pdfdoc_e.h) +- File attachment, launch, link, weblink and text annotations (p_annots.c). +- Add file type and creator on the Mac (p_basic.c). +- Nested bookmarks (p_hyper.c). +- Changes the API name of the bookmark function from PDF_add_outline to + the more intuitive PDF_add_bookmark (p_hyper.c) +- Removes the limits on number of pages, page contents, and number of objects + and introduced dynamic reallocation (p_hyper.c, p_basic.c, p_annots.c). +- Generates a PDF-1.3 header (Acrobat 4 files). According to the PDF spec + this should work OK also for older viewers as long as no PDF 1.3 + specific feature is used in the PDF file. +- Introduces Zlib compression for images and file attachments. +- Completely reworked the font handling. Font metrics caching now avoids + many AFM lookups, which dramatically speeds up PDFlib (up to a factor of 20!). +- Implemented in-core font metrics data. This completely eliminates the + need for external AFM files. Using the supplied utility compile_metrics + arbitrary metrics files can be compiled into the PDFlib source code. +- Adjusted the page size validation to Acrobat 4's larger limits (p_basic.c). +- New functions to query current font name and size (p_font.c) +- Introduced version numbers for the shared library and versioning schemes + for the scripting API (except Python) +- Eliminated all enums at the API level and replaced them with string + arguments. +- Eliminated the individual PDF_close_[TIFF|GIF|JPEG|CCITT|memory_image] + since PDF_close_image handles it all. +- User-adjustable debug level. +- Introduced PDF_new(), PDF_new2(), and PDF_delete, as well as PDF_open_file() + and PDF_close_file() and PDF_open_fp() and PDF_close_fp(). +- Made the page size parameters float in order to accomodate PDF 1.3. + + +Bindings: +- Largely improved the Perl, Tcl, and Python bindings. +- Introduced the Java binding via JNI (bind/java). +- Introduced a C++ wrapper class for PDFlib (bind/cpp). +- Introduced versioning if the language supports it (currently + Perl and Tcl; the Java binding uses transparent shared library versioning). +- Binds the TIFFlib and zlib libraries into the shared library for + the PDFlib scripting bindings, thereby making the TIFF and compression + features available to all SWIG bindings. +- Improved the SWIG-generated documentation for the scripting APIs. +- Introduced language-specific exception handling as offered by SWIG. + Exception handling for Java is done outside of SWIG. +- Explicitly sets the "C" locale in order to avoid the Java VM messing up + our decimal separators by setting a bad locale. +- Introduced a Visual Basic binding with a specialized DLL and a type + library. + + +Other: + +- Restructured the distribution directory tree. +- Streamlined the API for better scripting support. +- Added a file which documents changes to the API. +- Introduced versioning also at the API level and in the shared object naming. +- Changed the error handler interface to a fixed string, as opposed to a + variable number of arguments. +- Introduced error/exception classes which replace the former + error types, and are passed through to the scripting API. +- Reworks and cuts down the AFM parser, and makes it re-entrant. +- Installs NULL error and warning handlers in TIFFlib in order to + avoid messages from opening corrupt TIFF files. The caller will be + notified via the return code. +- Introduced "const" for all char * arguments in the API. + + +V1.0 (February 1999) (not publicly released) +============================================ + +No new featues, only bug fixes and improved platform support. + +Platform support: + +- Changed all library clients so that main() is declared with return + type int. +- Many casts and other minor changes in order to get rid of + MS Visual C++ 6.0 warnings (*.c, *.h). +- Included project and workspace files for MS Visual C++ 6.0 in the fileset + (PDFlib.dsp, PDFlib.dsw). +- Removed Watcom makefile from the fileset (makefile.wat). +- Switch to autoconf support (configure, configure.in, Makefile.in) +- Added Mac build support and file type/creator entries (p_basic.c) + + +Bug fixes: + +- Extended close routine (p_gif.c, p_jpeg.c) +- Page height and width were exchanged in the interface of PDF_begin_page() + as well as in the manual. Funnily enough, the MediaBox was also written + with both in the wrong order, thereby correcting things. However, the + demo clients used the parameters in the intended order. This fix only + clarifies the meaning of width and height, but doesn't change the + behavior of clients. +- PDF output file is no longer closed in the library in order to + be consistent with the opening in the client. This INCOMPATIBLE + change means that all library clients now must close the PDF output + file themselves! +- Fixed a core dump bug in the TIFF handler (p_tiff.c) +- Fixes bug where a font could get written to the PDF with wrong + encoding information. + + +V0.7b2 (August 1998) (only for a single customer) +================================================= + +New features: + +- Added CCITT support for passing through G3 or G4 compressed + bitmap data (p_ccitt.c, pdf.h). +- Changes to the image interface (p_ccitt.c, p_jpeg.c, p_tiff.c, + p_gif.c, pdf.h) + +Bug fixes: + +- Changed the get_2bytes macro to a function since the macro + didn't guarantee the evaluation order, which lead to problems + when analyzing JPEGs on BeOS (p_jpeg.c). +- Added a check for Acrobat-compatible page size (1"-45", or + 72pt-3240pt) in PDF_begin_page(). This is necessary to work around + restrictions in Adobe's Acrobat implementation (p_basic.c). + +Minor enhancements: + +- Several makefile cleanups (makefile.gcc). + + +V0.6 (08 July 1998) +=================== + +New features: + +- Added SWIG support, as suggested and basically implemented by + Rainer Schaaf (Rainer.Schaaf@T-Online.de). SWIG support allows us + to use PDFlib routines from Tcl, Perl, and Python. + (makefile, pdflib.i, pdftcl_wrap.c pdfperl_wrap.c, pdfpython_wrap.c, + pdflib.pm). +- New directory structure: BINDINGS directory contains subdirectory + for several PDFlib language bindings. Currently these are + C, CGI, Perl, Tcl, Python (yes, I know that CGI is not a language). +- Included scripting samples (BINDINGS/*/pdfclock.[pl|tcl|py], + BINDINGS/*/hello.[pl|tcl|py]). +- Added new function PDF_setpolydash, suggested and implemented + by Evgeny Stambulchik + (p_gstate.c, pdf.h). + +Bug fixes and minor enhancements: + +- Fix trivial (but fatal) free/fclose bug (p_font.c) +- Slightly change syntax of pdfgraph sample program: fill and + stroke is denoted by 'F' instead of 'B' (pdfgraph.c) +- Shorten the version string (pdf.h) +- Add cast (p_basic.c) +- Conditionally typedef bool because of conflicts in VC++ (pdf.h and p_port.h) +- Add cast (p_font.c) +- Delete old BOOL typedef (pdf.h) +- Renamed function parseFile to pdf_parseFile in order to avoid name + clashes with other software packages. This change was requested + by Evgeny Stambulchik for the xmgr package. This package uses T1lib + which also includes a copy of Adobe's AFM parser. (afmparse.c, + afmparse.h, p_font.c). +- Fixed typo in the Goethe demo text (pdfdemo.c). +- Adjusted demo data to new setrgbcolor interface (test/graphdata). +- Add PDF_HAS_BOOL define. However, it doesn't really fix the multiple + boolean define/typedef/enum problem (p_port.h). +- Removed const from PDF_info struct members. This change is related + to SWIG support, although the necessity of the change is not yet + fully understood (pdf.h). +- Enhances the AFM parser to recognize AFM files according to the AFM 4.1 + specification, especially the "CharWidth" keyword. + + +V0.5 (25 February 98) +===================== +Portability aids, bug fixes and other improvements from several contributors: + +- JPEG images could be closed multiply (p_jpeg.c) +- Introduce Mac and Win32 porting defs (p_port.h) +- Use define for path separator which is needed for the Mac's ":" + (p_port.h, p_font.h) +- Rename structure member private to private_data for C++ compatibility + (pdf.h, p_font.c, p_gif.c, p_jpeg.c, p_tiff.c) +- NeXT portability: include libc.h (imagepdf.c, pdfclock.c, pdfgraph.c, + text2pdf.c) +- Don't use malloc.h (afmparse.c) +- Change variable handling in make build process (makefile) +- Fix bug in octal character representation (p_text.c) +- Introduce word and character spacing functions (p_text.c) +- Fix subtle bug in font embedding: fonts with additional data after + the zeros portion were not properly embedded (p_font.c) + +Environment bindings: +- Introduces BINDINGS directory which will collect several language and + environment bindings for PDFlib. +- Sample CGI script for the PDFclock example (BINDINGS/CGI/clock.cgi) + +Several bugfixes, due to Detlev Droege's comments after +testing with his PDFviewer: + +- Avoid empty /Filter arrays for uncompressed binary images (p_image.c). +- Change erroneous number of color components in demo page (pdfdemo.c). +- Implement consistency check for color components vs. color space + (p_image.c) +- Write binary magic number for all files (ASCII and binary) (p_basic.c). +- Change "Producer" to "Creator" in sample application (hello.c). +- AFM handler crashed in case the AFM parser gave up on certain AFMs (p_font.c). +- AFM parser didn't correctly handle newer version 4.0 AFMs (afmparse.c). +- Use AFM 4.0 key "StdVW" for a more accurate /StemV in font descriptor + (p_font.c). +- API CHANGE: Change RGB parameters from byte to float since + gray values are float parameters too (p_color.c). + + +V0.4 (8 September 97) +===================== +First public release. + +- Generating multiple PDFs with embedded images resulted in wrong + XObject numbers for the second and following PDFs. Use image_number + from the PDF structure instead of a static variable. + (p_image.c, p_basic.c) +- Makefile for Watcom C 10.6 included in the distribution, support + Windows build (makefile.wat). diff --git a/src/libs/pdflib/doc/pdflib/compatibility.txt b/src/libs/pdflib/doc/pdflib/compatibility.txt new file mode 100644 index 0000000000..c312739724 --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/compatibility.txt @@ -0,0 +1,444 @@ +API changes +=========== + +This file documents those API changes which affect +existing PDFlib client programs. Although we go to +some efforts in maintaining the existing API functions, +it is sometimes necessary to incorporate a few non-backward +compatible changes in order to streamline the API and +incorporate new or extended functions. + + +PDFlib 5.0.2 +============ +- COM: + - The functions PDF_setgray*() and PDF_setrgbcolor*() are no longer + available in the COM wrapper. These functions have been deprecated + since PDFlib 4. Workaround: use setcolor() instead. + + +PDFlib 5.0.1 +============ +- No changes which affect compatibility. + + +PDFlib 5.0.0 +============ + +- Several resource configuration mechanism are superseded by improved + mechanisms. However, the previous configuration scheme is still supported. + +- Introduced a dedicated PDFlibException class for Java. This may + require modifications to existing catch clauses. + +- The new C exception handling with PDF_TRY/PDF_CATCH makes old-style + error handlers obsolete. However, PDF_new2() will still accept error + handler callbacks. + +- The PDF_open_pdi_callback() has been slightly modified; this affects + only PDFlib customers who used this feature in a preliminary release. + +- Changed the default value of the "inheritgstate" parameter to false. + +- By default, PDFlib generates PDF 1.4 (Acrobat 5) output. This can be + modified with + + PDF_set_parameter(p, "compatibility", "1.3"); + +- The following features have been removed: + + PDF_set_parameter(p, "compatibility", "1.2"); + + Careful programming can still produce PDF 1.2 compatible documents, + albeit with a PDF 1.3 header entry. + +- The following functions have been removed: + + PDF_open_pdi_mem() (only implemented in custom versions of PDFlib+PDI) + Change existing calls to the following sequence: + + PDF_create_pvf(...); + PDF_open_pdi(...); + +- C++ binding: + Switches to new-style C++ exceptions by default (as opposed to installing + an old-style client-supplied error handler callback function). + +- PHP binding: + Those very old API functions have been removed from the wrapper which + stemmed from the prehistoric era before PDFlib GmbH officially supported + the PHP wrapper. These functions have never been documented in the PDFlib + manual, but have been kept in the PHP wrapper for compatibility reasons. + In order to facilitate maintenance we dropped these functions. + + The pdf_open_memory_image() API is not affected since it actually added + new functionality. Although PDFlib GmbH does not support this function it + still works. + + The virtual_dir support has also been dropped. This feature is rather + confusing since it is not supported on all platforms and configurations. + In addition, it conflicts with the new SearchPatch facility in PDFlib. + Finally, it didn't work when generating PDF files with PDF_open_file(). + + +PDFlib 4.0.2 and 4.0.3 +====================== + +- No new functions, but new features which do not affect the + binary interface (such as support for OpenType fonts). + + +PDFlib 4.0.1 +============ + +- No changes which affect compatibility. + + +PDFlib 4.0 +========== + +- The following functions have been added to the PDFlib API: + + PDF_open_pdi() + PDF_close_pdi() + PDF_open_pdi_page() + PDF_close_pdi_page() + PDF_get_pdi_parameter() + PDF_get_pdi_value() + + PDF_begin_pattern() + PDF_end_pattern() + + PDF_begin_template() + PDF_end_template() + + PDF_setcolor() + PDF_makespotcolor() + + PDF_arcn() + PDF_add_thumbnail() + + PDF_initgraphics() + PDF_setmatrix() + +- The following functions are now deprecated (use PDF_setcolor() instead): + PDF_setgray_fill + PDF_setgray_stroke + PDF_setgray + PDF_setrgbcolor_fill + PDF_setrgbcolor_stroke + PDF_setrgbcolor + +- PDF_endpath() has been re-implemented with slightly different semantics. + +- The FontTT resource category has been removed. TrueType fonts can now be + listed along with PostScript fonts in the FontOutline category. This + change affects only a few customers who had access to the TrueType + feature before PDFlib 4.0 was released. + + +PDFlib 3.03 +=========== + +- This release doesn't add nor remove any function, but introduces a + new parameter: "fontwarning" + +- The deprecated function PDF_endpath() raises a non-fatal exception + (which can be suppressed). + + +PDFlib 3.02 +=========== + +This release doesn't add nor remove any function. However, since PDFlib 3.01 +removed some obsolete and undocumented functions, 3.02 can be considered +incompatible to 3.0. For this reason, the libtool version number has +been increased such that PDFlib 3.02 is not binary compatible, although +for users of the documented PDFlib 3.0 API it is completely backward +compatible. + + +Changes in PDFlib 3.01 +====================== + +This is a maintenance release which is binary compatible with 3.0. +However, a few bug fixes may result in different behaviour when +compared to 3.0. These are not incompatibilities, rather 3.0 behaved +in the wrong way which is now fixed. See the change log for details. + +- The following functions, which were no longer supported nor documented in + PDFlib 3.0 (but were still available), have been removed from all language + bindings which still included them. Use the appropriate substitute functions + as outlined below: + + PDF_open_TIFF use PDF_open_image_file(p, "tiff", filename, "", 0) instead + PDF_open_JPEG use PDF_open_image_file(p, "jpeg", filename, "", 0) instead + PDF_open_GIF use PDF_open_image_file(p, "gif", filename, "", 0) instead + + PDF_get_font use PDF_get_value(p, "font", 0) instead + PDF_get_fontsize use PDF_get_value(p, "fontsize", 0) instead + PDF_get_fontname use PDF_get_parameter(p, "fontname", 0) instead + PDF_get_image_height use PDF_get_value(p, "imageheight", image) instead + PDF_get_image_width use PDF_get_value(p, "imagewidth", image) instead + + PDF_set_fillrule use PDF_set_parameter(p, "fillrule", fillrule) instead + PDF_set_leading use PDF_set_value(p, "leading", leading) instead + PDF_set_text_rise use PDF_set_value(p, "textrise", rise) instead + PDF_set_horiz_scaling use PDF_set_value(p, "horizscaling", scale) instead + PDF_set_text_rendering use PDF_set_value(p, "textrendering", mode) instead + PDF_set_char_spacing use PDF_set_value(p, "charspacing", spacing) instead + PDF_set_word_spacing use PDF_set_value(p, "wordspacing", spacing) instead + PDF_set_duration use PDF_set_value(p, "duration", t) instead + PDF_set_transition use PDF_set_value(p, "duration", t) instead + + +API changes for PDFlib 3.0 +========================== + +- PDF_set_text_matrix() is no longer supported. Use PDF_scale(), + PDF_translate(), PDF_rotate(), and PDF_skew() instead, or PDF_concat() + if you actually have to deal with matrices. + +- PDF_findfont() no longer returns -1 on error, but raises an exception + which seems more appropriate to font misconfigurations (or spelling + errors in the font or encoding names). Although existing code need + not necessarily be changed (assuming an error handler is already in + place), the following change is suggested: + Change + font = PDF_findfont(p, fontname, encoding, embed); + if (font == -1) { + ... + } + + -- to -- + + font = PDF_findfont(p, fontname, encoding, embed); + +- The name of the pseudo encoding for the platform character set changed: + Change + PDF_findfont(p, fontname, "default", embed); + -- to -- + PDF_findfont(p, fontname, "host", embed); + +- The image functions have been consolidated into a single API function; use + PDF_open_image_file() instead of PDF_open_*(): + Change + PDF_open_GIF(p, filename) + -- to -- + PDF_open_image_file(p, "gif", filename, "", 0) + + PDF_open_TIFF(p, filename) + -- to -- + PDF_open_image_file(p, "tiff", filename, "", 0) + + PDF_open_JPEG(p, filename) + -- to -- + PDF_open_image_file(p, "jpeg", filename, "", 0) + + The old image functions are still available, though. + + +Java binding: + +- In the course of reworking the Java API all functions marked as obsolete + in the manual have been removed. Use the appropriate substitutes instead: + + open_TIFF + open_JPEG + open_GIF + + get_font + get_fontsize + get_fontname + get_image_height + get_image_width + + set_fillrule + set_leading + set_text_rise + set_horiz_scaling + set_text_rendering + set_char_spacing + set_word_spacing + set_duration + set_transition + +- Implements package support. Add the following line at the beginning of + all PDFlib client programs: + + import com.PDFlib.pdflib; + +- Switch to an object-oriented approach, and dropped the PDF_ prefix + from all method names: Change + + long p; + int font; + p = pdflib.PDF_new(); + if (pdflib.PDF_open_file(p, "hello_java.pdf") == -1) { + + -- to -- + + pdflib p; + p = new pdflib(); + if (p.open_file("hello_java.pdf") == -1) { + +- PDF_boot() and PDF_shutdown are no longer available, but shouldn't + have been used anyway. + + +Perl binding: + +- The name of the shared library changed, requiring a small change in scripts: + Change + use pdflib 2.10 + -- to -- + use pdflib_pl 2.10 + +- "package pdflib" is no longer necessary at the beginning of the Perl script. + +- PDF_boot() and PDF_shutdown are no longer available, but shouldn't + have been used anyway. + + +Python binding: + +- The name of the shared library changed, requiring a small change in scripts: + Change + from pdflib import * + -- to -- + from pdflib_py import * + +- PDF_boot() and PDF_shutdown are no longer available, but shouldn't + have been used anyway. + + +Tcl binding: + +- PDF_boot() and PDF_shutdown are no longer available, but shouldn't + have been used anyway. + + +Visual Basic binding: + +- There is no longer a dedicated VB binding; it is replaced by the + much more versatile ActiveX binding. This requires VB clients to + adapt their syntax to the ActiveX component. + + +API changes in PDFlib V2.01 +=========================== +- PDF_place_inline_image() is no longer supported; use PDF_place_image() + instead (same interface): + Change + PDF_place_inline_image() + -- to -- + PDF_place_image() + +- PDF_put_image() is no longer required. Instead, the image data is + "parked" immediately on PDF_open_*(): + Delete + PDF_put_image() + +- PDF_execute_image() is no longer required. Instead, PDF_place_image() + can be called multiple times for a given PDF: + Change + PDF_execute_image() + -- to -- + PDF_place_image() + +- The interface and functionality of PDF_open_memory_image() changed: + Change + int PDF_open_memory_image(PDF *p, unsigned char *buffer, + int width, int height, int components, int bpc); + -- to -- + int PDF_open_image(PDF *p, "raw", "memory", const char *data, long len, + int width, int height, int components, int bpc, NULL); + + +API changes in PDFlib V2.0 +========================== + +- All API functions with parameters of type "char *" changed to "const char *". + +- change + PDF_data_source_from_buf() + -- to -- + int PDF_open_memory_image(PDF *p, unsigned char *buffer, + int width, int height, int components, int bpc) +- change + PDF_set_text_matrix(PDF *p, PDF_matrix m); + -- to -- + void PDF_set_text_matrix(PDF *p, + float a, float b, float c, float d, float e, float f); + +- change + PDF_add_outline(p, text); + -- to -- + PDF_add_bookmark(p, text, -1, 0); + +- change + PDF_info *PDF_get_info(void); + -- to -- + PDF_set_info(PDF *p, char *key, char *value); + (after PDF_new() and PDF_open_*()) + +- change + PDF_image->width and PDF_image->height + -- to -- + PDF_get_image_width(PDF *p, PDF_image *image) + -- and -- + PDF_get_image_height(PDF *p, PDF_image *image); + +- change + PDF_info->error_handler = handler; + -- to -- + PDF_new2(handler, ...); + Watch out for the changed signature of the error handler. + +- change + void PDF_data_source_from_buf(*p, *src, buffer, len); + -- to -- + PDF_image *PDF_open_memory_image(p, buffer, width, height, components, bpc); + void PDF_close_image(p, image); + +- change + a4.width to a4_width etc. + +- change + PDF_image image; /* for PDF_open_[GIF|JPEG|TIFF|memory_image] */ + -- to -- + int image; + +- change + PDF_close_[GIF|JPEG|TIFF|memory_image]; + -- to -- + PDF_close_image(); + +- change + PDF_transition(p, type); + -- to -- + PDF_transition(p, "type"); + +- change + PDF_set_font(p, fontname, size, encoding); + -- to -- + int PDF_findfont(p, fontname, encoding, embed); + if (font == -1) + /* handle unavailable font */ + PDF_setfont(p, font, size); + + Note: the old PDF_set_font() is still available for compatibility. + +- change + PDF_stringwidth(char *text); + -- to -- + PDF_stringwidth(text, PDF_get_font(p), PDF_get_fontsize(p)); + +- change + PDF_open(filename); + -- to -- + p = PDF_new(); + if (PDF_open_file(filename) == -1) { ... } + -- or -- + p = PDF_new(); + if (PDF_open_fp(fp) == -1) { ... } diff --git a/src/libs/pdflib/doc/pdflib/readme-binary.txt b/src/libs/pdflib/doc/pdflib/readme-binary.txt new file mode 100644 index 0000000000..8394b90597 --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/readme-binary.txt @@ -0,0 +1,43 @@ +========================== +PDFlib binary distribution +========================== + +This is a binary package containing PDFlib, PDFlib+PDI, and +PDFlib Personalization Server (PPS) in a single binary. +It requires a commercial license to use it. However, the +library is fully functional for evaluation purposes. + +Unless a valid license key has been applied the generated PDF +output will have a www.pdflib.com demo stamp across all pages. +See the PDFlib manual (chapter 0) to learn how to apply a +valid license key. + + +C and C++ language bindings +--------------------------- +The main PDFlib header file pdflib.h plus a PDFlib library +is contained in the distribution. + +- On Windows, the DLL pdflib.dll is supplied along with the + corresponding import library pdflib.lib. In order to build + and run the supplied C/C++ samples copy these files to the + bind/pdflib/c or bind/pdflib/cpp directories. + + If you are working with Borland C++ Builder you must first + generate a new import library pdflib.lib from pdflib.dll + since Borland tools don't work with the Microsoft .lib format. + To do so, use the following command: + coff2omf pdflib.lib pdflib.lib + +- On Unix systems a static library is supplied. + +The bind/c and bind/cpp directories contain sample applications +which you can use to test your installation. + + +Other language bindings +----------------------- +Additional files and sample code for various languages +can be found in the bind directory. Note that not all +binary libraries for all language bindings may be present; +see our Web site for additional packages. diff --git a/src/libs/pdflib/doc/pdflib/readme-source-as400.txt b/src/libs/pdflib/doc/pdflib/readme-source-as400.txt new file mode 100644 index 0000000000..df6ad00e86 --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/readme-source-as400.txt @@ -0,0 +1,42 @@ +========================================= +PDFlib and PDFlib Lite source for iSeries +========================================= + +How to compile PDFlib on iSeries (AS/400): + +1. Copy all source files and directories from the "../libs" + directory to a mapped network drive on your iSeries. + + +2. If you are running on an OS400 version < V5R0M0 the compiler + wouldn't allow you to compile C source code directly from the + IFS. In this case you need to copy all IFS source files into an + iSeries source file/member. Make sure that you create these + source files with CCSID 37 (US/Canada). + + CRTLIB LIB(PDFLIBSRC) + + CRTSRCPF FILE(PDFLIBSRC/QCSRC) RCDLEN(200) CCSID(37) + + CRTSRCPF FILE(PDFLIBSRC/H) RCDLEN(200) CCSID(37) + + CPYFRMSTMF FROMSTMF('/[SRCDIR]/libs/flate/adler32.c') + TOMBR('/qsys.lib/pdflibsrc.lib/qcsrc.file/adler32.mbr') + + +3. Compile all modules into one library. Use the following options + for the CRTCMOD command: + + CRTCMOD SYSIFCOPT(*IFSIO) TERASPACE(*YES *TSIFC) STGMDL(*TERASPACE) + + + Warning: if you compile PDFlib without Teraspace support, you + might get unpredictable results. + + +4. Create the PDFlib Service Program with the following command: + + CRTLIB LIB(PDFLIB) + + CRTSRVPGM SRVPGM(PDFLIB/PDFLIB) MODULE(PDFLIBSRC/*ALL) EXPORT(*ALL) + STGMDL(*SNGLVL) diff --git a/src/libs/pdflib/doc/pdflib/readme-source-mac.txt b/src/libs/pdflib/doc/pdflib/readme-source-mac.txt new file mode 100644 index 0000000000..983638c34e --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/readme-source-mac.txt @@ -0,0 +1,31 @@ +=============================== +PDFlib Lite Source for Mac OS 9 +=============================== + +Note: +please see readme-source-unix.txt for information on using PDFlib on Mac OS X. + +To compile PDFlib with Metrowerks CodeWarrior, open the supplied +project file PDFlib.mcp with the Metrowerks IDE. The project file +contains targets for building a static PPC library + +Separate project files for building various C and C++ sample programs +can be found in bind/pdflib/c/samples.mcp and bind/pdflib/cpp/samples.mcp. +These can be used to test the newly created library. The tests create simple +command-line programs without any fancy user interface. + +Note that not all tests will succeed because they +need features which require commercial PDFlib products. + +In order to build a shared PDFlib library you'll have to define the +PDFLIB_EXPORTS preprocessor symbol (preferably in a new prefix file). + +In order to make the C and C++ samples work on OS 9 you must change the +SearchPath to use a Mac volume name instead of a relative path name, e.g.: + +"../data" ==> "Classic:software:pdflib-5.0.x:bind:pdflib:data" + + +Note that on OS 9 only C and C++ are available; other language +wrappers are no longer supported. All language wrappers are fully +supported on Mac OS X, though. diff --git a/src/libs/pdflib/doc/pdflib/readme-source-unix.txt b/src/libs/pdflib/doc/pdflib/readme-source-unix.txt new file mode 100644 index 0000000000..976db4a63b --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/readme-source-unix.txt @@ -0,0 +1,203 @@ +=========================== +PDFlib Lite Source for Unix +=========================== + +Building PDFlib Lite +-------------------- + +To start the PDFlib Lite build process on Unix, type + +./configure +make + +Several options can be used with the configure script in order to +override some default configuration options, or to assist configure +in finding some software locations on your machine. Type + +./configure --help + +before the make command in order to see a list of available configure +options. + +IMPORTANT: make sure to use only absolute path names for all custom +directories. Also, wildcards should not be used. This requirement is +necessary because otherwise the paths won't work as include paths with +compiler calls. + +If you want to use PDFlib on another machine, do not simply copy +the PDFlib source tree over. Instead, copy the distribution fileset +and re-run the configure script. Otherwise compiler, shared library +and installation settings could erroneously be taken from the first +machine instead of from the actual one. + + +Testing and installing the library +---------------------------------- + +Optionally, to run sample PDFlib applications in several programming +environments (including the scripting languages which have been +detected by configure), type: + +make test + +Note that not all tests will succeed. The failing tests require features +which are only available in the binary PDFlib distributions. + +In order to install the library and the support files for all detected +scripting languages, type + +make install + +Note that installing will usually require root privileges. + +If you want to install only selected parts (e.g., only the PDFlib +C library or the Perl support), type "make install" in the +respective subdirectory (e.g, bind/pdflib/perl). + + +configure troubleshooting +------------------------- + +The configure script helps to keep PDFlib portable across a wide variety +of systems, and to keep track of many different configurations and +the availability of features. Generally the script does a good job. +Given the huge number of different systems, configure may occasionally +fail in one of several ways: + +- failing to detect installed software + +- failing to complete all tests due to errors during script execution + +In the first case, you can help configure by finding out the necessary +paths etc. yourself, and supplying any required --with-... option on +the configure command line. + +In the second case, you either also can try to supply --with-... options +in order to prevent the failing test from being called, or abandon +the feature if you don't need it by supplying the value "no" to the +respective configure option, e.g., --with-tcl=no. + +If you can determine the cause of a failing configure script, we will +be happy to hear from you. Please supply your system details, the +feature/option in question, and a workaround or improvement if possible. + +The configure script may fail under Cygwin when trying to probe for languages +if path names contain space characters. +It's safer to disable language probing using --with-perl=no etc. + + +Forcing a certain compiler or compiler flags +-------------------------------------------- + +You can set several environment variables before running the configure +script. These variables will be used in the generated Makefiles. The more +important ones are: + +CC The C compiler to use +CXX The C++ compiler to use +CFLAGS C compiler flags +LDFLAGS linker flags, such as additional libraries + +For example, the following works well on Solaris (in a csh environment): + +setenv CC /opt/SUNWspro/bin/cc +setenv CXX /opt/SUNWspro/bin/CC +setenv CFLAGS '-fast -xO3 -xtarget=generic' +./configure + + +Shared library support +---------------------- + +Language bindings other than C/C++ require shared library support for +PDFlib to work. By default, the PDFlib core library will be built as both +a static and a shared library if possible. + +C or C++ language clients must deploy libtool for using PDFlib, or install +the generated PDFlib library using "make install". + +PDFlib relies on GNU libtool for shared library support. libtool +shadows the object files and libraries with a layer of .lo and .la +files. The actual library files are placed in a subdirectory called +".libs". The PDFlib Makefiles and libtool will take care of correctly +building, testing, and installing these libraries. If anything goes +wrong on your system, read the manual section on shared libraries, +take a look at the contents of the .libs subdirectory, and observe +what the supplied Makefiles do for compiling, linking, testing, and +installing. + + +Auxiliary libraries +------------------- + +PDFlib includes portions of the libtiff, zlib, and libpng auxiliary +libraries as part of the source code package. These libraries have been +modified for use with PDFlib in several ways: + +- all function names are prefixed with a PDFlib-private tag +- code which is not required for PDFlib has been removed +- a number of portability changes have been applied + +Our build process directly links these libraries into the PDFlib binary, +regardless of whether a shared or static PDFlib is generated. +External versions of these libraries are not supported. + +Due to the prefixed function names an application can link against both +PDFlib (including all auxiliary libraries) and standard +versions of these libs without any name conflicts. + + +Querying PDFlib configuration info +---------------------------------- + +In order to find out details about PDFlib's version, configuration, +and use, the pdflib-config shell script can be used. It is built during +the configure run, and returns all information you'll need for PDFlib +deployment. Running the script without any options lists the supported +command line options. + + +Library version numbers +----------------------- + +Libtool-generated libraries such as PDFlib number their interfaces +with integer interface numbers (no subversions!). In addition to the +interface number, a revision number can be used. A particular library +supports a range of interface numbers, where the range can have a length +of one or more. In particular, libtool defines the following: + +CURRENT The most recent interface number that this library implements. +REVISION The implementation number of the CURRENT interface. +AGE The length of the range of supported interfaces (i.e., CURRENT + numbers). + +The following table relates PDFlib version numbers to the C:R:A library +versioning scheme used by libtool. Note that these numbers will not show +up in the PDFlib shared library file name directly, but in some modified form +which is system-dependent: + +PDFlib C:R:A comments +----------------------------------------------------------------------------- +3.00 0:0:0 first release based on libtool +3.01 0:1:0 maintenance release (bug: should have increased C since + undocumented functions were removed) +3.02 1:0:0 cleans up the non-incrementing glitch in 3.01 +3.03 1:1:1 maintenance release (bug: should not have increased A) +4.0.0b 2:0:2 new API functions (inherits the 3.03 bug) +4.0.0 2:0:1 cleanup for major release: repairs the 3.03 "age" bug +4.0.1 2:1:1 maintenance release +4.0.2 2:2:1 maintenance release +4.0.3 2:3:1 maintenance release +5.0.0 3:0:2 new API functions (bug: should have been 3:0:0 since + PDF 1.2 compatibility has been dropped) +5.0.1 3:1:1 maintenance release (trying to fix the 5.0.0 bug) +5.0.2 4:0:2 maintenance release, but also a few minor new features +5.0.3 4:1:2 maintenance release + +When the PDFlib core is built as a static library version numbers will not +be visible. However, since language bindings other than C and C++ are always +built as shared libraries, they will have version numbers visible on most +systems. + +Many thanks to Evgeny Stambulchik for leading me on the right track +with respect to libtool and library versioning schemes! diff --git a/src/libs/pdflib/doc/pdflib/readme-source-windows.txt b/src/libs/pdflib/doc/pdflib/readme-source-windows.txt new file mode 100644 index 0000000000..d294d9a6af --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/readme-source-windows.txt @@ -0,0 +1,89 @@ +============================== +PDFlib Lite Source for Windows +============================== + +Building PDFlib with MS Visual Studio 6 +--------------------------------------- + +To compile PDFlib with MS Visual Studio 6, open the supplied workspace +file PDFlib.dsw which contains several projects for the core library +and language bindings. Select the "pdflib" project to build a static library +pdflib.lib. + +The "pdflib_dll" project can be used to build a DLL version pdflib.dll. + +This will set the PDFLIB_EXPORTS #define. Client programs must define +PDFLIB_DLL before including pdflib.h in order to use the DLL. + + +The following configurations are supported: +- "Debug" +- "Release" will include a static version of the C runtime. +- "Release mtDLL" (only for target pdflib) builds a static library for + use with applications which use a multithreaded DLL version of the + C runtime (msvcrt.dll). + + +Sample applications: + +The examples_c.dsw and examples_cpp.dsw contain targets for a few +C/C++ sample applications. + +Note that not all tests will succeed because they +need features which require commercial PDFlib products. + + +Building PDFlib with MS Visual Studio .NET +------------------------------------------ + +Although the PDFlib packages do not contain dedicated project files for use +with Visual Studio .NET (aka VS 7), the project files and workspaces supplied +for use with Visual Studio 6 can be used. Proceed as follows to compile PDFlib +with Visual Studio .NET: + +- Open the workspace PDFlib.dsw with Visual Studio .NET +- A dialog box will pop up and ask + "The project 'Java.dsp' must be converted to the current Visual C++ project + format. ... Convert and open this project?" + In this dialog click "Yes to All". +- Proceed as described above for Visual Studio 6 +- Save the project files (will be done automatically upon exiting VS .NET) + + + +Building PDFlib with Metrowerks CodeWarrior +------------------------------------------- + +To compile PDFlib with Metrowerks CodeWarrior, open the supplied +project file PDFlib.mcp with the Metrowerks IDE. The project file +contains targets for building a static PPC library + +Separate project files for building various C and C++ sample programs +can be found in bind/pdflib/c/samples.mcp and bind/pdflib/cpp/samples.mcp. +These can be used to test the newly created library. The tests create simple +command-line programs without any fancy user interface. + +Note that not all tests will succeed because they +need features which require commercial PDFlib products. + +In order to build a shared PDFlib library you'll have to define +the PDFLIB_EXPORTS preprocessor symbol (preferably in a new prefix +file). + + +Building PDFlib with other Windows compilers +-------------------------------------------- + +In order to build PDFlib with other compilers, observe the above +notes and make sure to define the preprocessor symbol WIN32. + + +Compiling the language wrappers +------------------------------- + +In order to compile the C wrappers for the supported languages you +will have to install the relevant source code package +and adjust the include paths for these packages in the project files. +Since we supply prebuilt binaries for all supported languages this is +generally not required. Project files for the language wrappers are +only supplied for Microsoft Visual C++, but not any other compiler. diff --git a/src/libs/pdflib/doc/pdflib/readme.txt b/src/libs/pdflib/doc/pdflib/readme.txt new file mode 100644 index 0000000000..a8bb0981f7 --- /dev/null +++ b/src/libs/pdflib/doc/pdflib/readme.txt @@ -0,0 +1,189 @@ +================================================ +PDFlib - A library for generating PDF on the fly +================================================ + +Portable C library for dynamically generating PDF ("Adobe Acrobat") files, +with support for many other programming languages. + +The PDFlib distribution is available from http://www.pdflib.com + +PDFlib is a library for generating PDF files. It offers an API with +support for text, vector graphics, raster image, and hypertext. Call PDFlib +routines from within your client program and voila: dynamic PDF files! + +PDFlib is available on a wide variety of operating system platforms, +and supports many programming languages and development environments: + +- C +- C++ +- Cobol +- COM (Visual Basic, ASP, Windows Script Host, Delphi, and many others) +- Java via the JNI, including servlets and JSP (but not EJB) +- .NET framework (VB.NET, ASP.NET, C# and others). +- Perl +- PHP Hypertext Processor +- Python +- RPG +- Tcl + +An overview of PDFlib features can be found in the PDFlib reference manual +in the PDF file PDFlib-manual.pdf. Documentation for the COM and .NET +editions is available separately. + + +PDFlib flavors +============== +The PDFlib software is available in different flavors (see the PDFlib +manual for a detailed comparison): + +- PDFlib Lite + Open-source edition for basic PDF generation, free for personal use. + PDFlib Lite does not support all languages, and is not available on + EBCDIC platforms. + +- PDFlib + The commercial edition adds various features for advanced PDF generation. + +- PDFlib+PDI + Includes PDFlib plus the PDF Import library PDI which can be used to + integrate pages from existing PDF documents in the generated output + +- PDFlib Personalization Server (PPS) + Includes PDFlib+PDI, plus advanced block processing functions for + easily personalizing PDF documents. PPS also includes the Block + plugin for Adobe Acrobat which can be used to create PDFlib blocks + interactively. The Block plugin is distributed in a separate installer. + + +First Steps with a binary Package +================================= +PDFlib, PDFlib+PDI, and PPS are available in binary form, and require +a commercial license. All of these products are available in a single +library, and can be evaluated without any restrictions without any +license. However, unless a valid license key is applied a demo stamp +will be generated across all pages. +The binary packages support C plus various other language bindings. +Instructions for using these packages can be found in doc/readme-binary.txt. + + +First Steps with the PDFlib Lite Source Package +=============================================== +PDFlib Lite is available in source form, and can be used for free under +certain conditions. Source code is also available for selected language +wrappers. If you are working with a source code package you need an ANSI C +compiler. Detailed instructions for building PDFlib from source code +can be found in doc/readme-source-*.txt + + +Quick Start and Documentation +============================= +For a jump-start, take a look at the PDFlib samples which are available +for all supported languages: + +- The following examples work with all editions of PDFlib: + The hello, pdfclock, and image samples generate PDF output with simple text, + vector graphics, and images. The chartab examples contains a more advanced + sample for using fonts and encodings in PDFlib. It can also be used to + create handy character set reference tables. + +- The invoice and quickreference examples require PDFlib+PDI, and demonstrate + how to deal with existing PDF documents. + +- The businesscard example requires the PDFlib Personalization Server (PPS), + and contains a simple personalization example. + +After reviewing these samples you should take a look at the main PDFlib +documentation: the "PDFlib Reference Manual" is included as PDF in all packages. +It is the definite reference for using PDFlib. The majority of questions +will be answered in this manual. + + +Other PDFlib resources +====================== +In addition to the PDFlib reference manual the following resources +are available: + +- The PDFlib FAQ collects information about known bugs, patches, + and workarounds: http://www.pdflib.com + +- The PDFlib mailing list discusses PDFlib deployment in a variety of + environments. You can access the mailing list archives over the Web, + and don't need to subscribe in order to use it: + http://groups.yahoo.com/group/pdflib + +- Commercial PDFlib licensees are eligible for professional product + support from PDFlib GmbH. Please send your inquiry along with your + PDFlib license number to support@pdflib.com. + + +Submitting Bug Reports +====================== +In case of trouble you should always check the PDFlib Web site +in order to see whether your problem is already known, or a patch exists. +If not so, please observe the following: + +If you have trouble with running PDFlib, please send the following +information to support@pdflib.com + +- a description of your problem +- the platform in use +- the PDFlib version number you are using +- the language binding you are using, along with relevant version numbers +- relevant code snippets for reproducing the problem, or a small PDF file + exhibiting the problem if you can't construct a code snippet easily +- sample data files if necessary (image files, for example) +- details of the PDF viewer (if relevant) where the problem occurs + +If you have trouble compiling the PDFlib Lite source code, please send the +following information to support@pdflib.com: + +- a description of your problem and the platform in use +- the PDFlib version number you are using +- the output of "./libtool --config" (Unix systems only) +- most welcome: suggested patches or solutions, other helpful information + + +A Shameless Plug +================ +My book contains a lot of information on PostScript, Fonts, and PDF +(currently only available in German): + +Die PostScript- & PDF-Bibel +Thomas Merz, Olaf Druemmer +654 Seiten, ISBN 3-935320-01-9, Euro 25,- +Kopublikation PDFlib GmbH/dpunkt Verlag +PDF available at http://www.pdflib.com +e-mail orders for the printed book: books@pdflib.com + + +Licensing and Copyright +======================= +THIS IS NOT PUBLIC DOMAIN OR FREEWARE SOFTWARE! + +PDFlib Lite can freely be used for non-profit personal use. +The license text can be found in the file PDFlib-Lite-license.pdf. + +PDFlib, PDFlib+PDI, and PPS can only be used under the terms of +a commercial license, and always require a license fee. Details +of the license can be found in the file PDFlib-license.pdf. +Licensing information is available in the file PDFlib-purchase-order.pdf, +and on our Web site www.pdflib.com. + + + +Please contact us if you're interested in obtaining a commercial PDFlib license: + +PDFlib GmbH +Tal 40, 80331 Munich, Germany +fax +49/89/29 16 46 86 + +License inquiries: sales@pdflib.com + +Support for PDFlib licensees: support@pdflib.com + + +Technical inquiries if you have not licensed PDFlib: +mailing list and archives at http://groups.yahoo.com/group/pdflib + +Copyright (c) 1997-2004 PDFlib GmbH and Thomas Merz. All rights reserved. +PDFlib and the PDFlib logo are registered trademarks of PDFlib GmbH. diff --git a/src/libs/pdflib/fonts/pdflib.upr b/src/libs/pdflib/fonts/pdflib.upr new file mode 100644 index 0000000000..7e05429901 --- /dev/null +++ b/src/libs/pdflib/fonts/pdflib.upr @@ -0,0 +1,87 @@ +PS-Resources-1.0 + +% This is a sample UPR file for use with PDFlib. The complete description +% of the UPR file format can be found in the PDFlib manual. +% All resources can also be set at runtime via PDF_set_parameter(). +% Some resources will also be search in the Windows registry. + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% List of all resource categories which are specified in the file + +SearchPath +FontAFM +FontPFM +FontOutline +Encoding +ICCProfile +StandardOutputIntent +. + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The SearchPath section. +% PDFlib will search for any files (font, PDFs, ICC profiles, images) +% in all the directories listed here. Modify as appropriate. +% Do not mix SearchPath with the deprecated "prefix" feature. + +SearchPath +% /var/fonts +% C:/psfonts +% d:/myimagefolder +. + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The AFM font metrics section, one line per font in the format +% = +% Note that PostScript font names must not contain any blank character + +FontAFM +. + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The PFM font metrics section, one line per font in the format +% = +% Note that PostScript font names must not contain any blank character + +FontPFM +%Poetica-ChanceryI=Poetica-ChanceryI.pfm +. + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The PostScript, TrueType, and OpenType font outline section, one line per +% font in the format +% = +% Note that PostScript font names must not contain any blank character, +% but TrueType font names may contain blank characters (and often do). + +FontOutline +. + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The Encoding section, one line per encoding in the format +% = +% This will only rarely be required since PDFlib contains a lot of built-in +% encodings. + +Encoding +%cp0874=cp0874.cpg +. + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The ICCProfile section lists the names of known ICC color profiles in the +% format +% = + +ICCProfile +%highspeedprinter=cmykhighspeed.icc +. + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The StandardOutputIntent section lists the names of known standard output +% intents for PDF/X. This will only be used when standard intent names other +% than those known to PDFlib internally will be used. +% format +% = + +StandardOutputIntent +. diff --git a/src/libs/pdflib/fonts/print_glyphs.ps b/src/libs/pdflib/fonts/print_glyphs.ps new file mode 100644 index 0000000000..8bbf80e46a --- /dev/null +++ b/src/libs/pdflib/fonts/print_glyphs.ps @@ -0,0 +1,129 @@ +%!PS-Adobe +% print_glyphs.ps +% Copyright (C) Thomas Merz and PDFlib GmbH 1994-2004 +% +% This PostScript program prints all glyphs in a font along +% with their names in alphabetical ordering. +% It requires a PostScript Level 2 or PostScript 3 interpreter. +% It also works with Acrobat Distiller. +% +% Usage: +% - The font must either be resident in the printer, or be +% downloaded ahead of this program (as a single job). +% Alternatively, the font can be configure in Distiller. +% - At the end of this file, enter a line with the font name, e.g.: +% /Times-Roman ShowGlyphs +% (Omit the percent character, but leave the leading slash '/') + +/$sort 20 dict def + +/Insert { % node string ==> - + exch dup 0 get type (nulltype) eq { % ifelse + exch [ exch 1 array 1 array ] 0 exch put + }{ % else + aload pop aload pop 4 2 roll 2 copy gt { % ifelse + pop 3 -1 roll pop Insert + }{ %else + pop exch pop Insert + } ifelse + } ifelse +} def + +/PrefixWalk { + $sort begin + cvx /!bt exch def bpwalk + end +} def + +$sort begin +/bpwalk { + dup 0 get type /nulltype eq { pop }{ % ifelse + aload pop aload pop exch bpwalk exch !bt bpwalk + } ifelse +} bind def + +end % $sort + +/DictSort { % dict ==> array + dup length array /a exch def + $sort begin + /tree 1 array def + { pop 50 string cvs tree exch Insert } forall + /ndx 0 def + tree { a ndx 3 -1 roll put /ndx ndx 1 add def } PrefixWalk + a +} bind def + +/ShowGlyphs { % font name ==> - + /buffer 100 string def + /FontName 100 string def + /fs 20 def % font size + /ts 7 def % font size of caption + /ls fs 1.75 mul def % line spacing + + dup FontName cvs pop + findfont fs scalefont /F exch def + + clippath pathbbox + 20 sub /top exch def + 20 sub /right exch def + 20 add /bottom exch def + 40 add /left exch def + + /textfont /Helvetica-Narrow findfont ts scalefont def + /x left def + /y top fs sub def + + /Helvetica-Bold findfont fs scalefont setfont + x y moveto + /y y ls sub def + + % Check the interpreter's language level... + /languagelevel where { pop languagelevel }{ 1 } ifelse + + % ...and quit if Level 1 + 2 lt { + (Error: this program doesn't work on PostScript Level 1 printers!)show + showpage + stop +} if + + FontName show % print font name + + % Try to find the dictionary with the character names + F /CharStrings known { + F /CharStrings get + }{ + (: Couldn't find character names (CharStrings dictionary)!) show + showpage + quit + } ifelse + + DictSort % sort the character names + + { % forall + /GlyphName exch def % remember the character name + + x y moveto F setfont % the actual character... + GlyphName cvn glyphshow + + x y ts 2 mul sub moveto % ...and its glyph name + textfont setfont GlyphName buffer cvs show + + /x x fs 2 mul add def + x right gt { /x left def /y y fs 2 mul sub def } if + y bottom lt { + /y top fs sub def /x left def + showpage + x y moveto + /y y ls sub def + /Helvetica-Bold findfont fs scalefont setfont + FontName show % print font name + } if + } forall + y top ls sub ne x left ne or { showpage } if + +} bind def + +% Example: +%/Times-Roman ShowGlyphs diff --git a/src/libs/pdflib/libs/Jamfile b/src/libs/pdflib/libs/Jamfile new file mode 100644 index 0000000000..e9b12f50b3 --- /dev/null +++ b/src/libs/pdflib/libs/Jamfile @@ -0,0 +1,7 @@ +SubDir OBOS_TOP src libs pdflib libs ; + +SubInclude OBOS_TOP src libs pdflib libs flate ; +SubInclude OBOS_TOP src libs pdflib libs pdcore ; +SubInclude OBOS_TOP src libs pdflib libs pdflib ; +SubInclude OBOS_TOP src libs pdflib libs png ; +SubInclude OBOS_TOP src libs pdflib libs tiff ; diff --git a/src/libs/pdflib/libs/Makefile b/src/libs/pdflib/libs/Makefile new file mode 100644 index 0000000000..7bb1615c81 --- /dev/null +++ b/src/libs/pdflib/libs/Makefile @@ -0,0 +1,12 @@ +# Generated automatically from Makefile.in by configure. +# Main libs Makefile +# $Id: Makefile,v 1.1 2004/10/06 17:46:48 laplace Exp $ + +# keep the order, some libs have to be build before others +# PDU not yet working => MAKEOPT -i +include ../config/mkcommon.inc + +MAKEOPT = -i +SUB_DIRS = $(LIBTARGETS) + +include ../config/mksubdirs.inc diff --git a/src/libs/pdflib/libs/PDFlib.mcp b/src/libs/pdflib/libs/PDFlib.mcp new file mode 100644 index 0000000000..66a101ba57 Binary files /dev/null and b/src/libs/pdflib/libs/PDFlib.mcp differ diff --git a/src/libs/pdflib/libs/flate/Jamfile b/src/libs/pdflib/libs/flate/Jamfile new file mode 100644 index 0000000000..363429c5d2 --- /dev/null +++ b/src/libs/pdflib/libs/flate/Jamfile @@ -0,0 +1,23 @@ +SubDir OBOS_TOP src libs pdflib libs flate ; + +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs pdcore ] ; + +UseLibraryHeaders pdflib ; + +StaticLibrary pdf : + adler32.c + uncompr.c + infutil.c + compress.c + zutil.c + inffast.c + crc32.c + deflate.c + trees.c + inftrees.c + infblock.c + inflate.c + infcodes.c +: STATIC_LIBRARY_DIR +; + diff --git a/src/libs/pdflib/libs/flate/Makefile b/src/libs/pdflib/libs/flate/Makefile new file mode 100644 index 0000000000..57e3ea2c2a --- /dev/null +++ b/src/libs/pdflib/libs/flate/Makefile @@ -0,0 +1,45 @@ +# Makefile for zlib +# This generates a libtool convenience library +# $Id: Makefile,v 1.1 2004/10/06 17:46:48 laplace Exp $ + +top_builddir = ../.. + +INCLUDES = $(PDCORELIBINC) + +LIBNAME = $(FLATELIBLINK) + +include ../../config/mkcommon.inc + +SRC = \ + $(srcdir)/adler32.c \ + $(srcdir)/compress.c \ + $(srcdir)/crc32.c \ + $(srcdir)/deflate.c \ + $(srcdir)/infblock.c \ + $(srcdir)/infcodes.c \ + $(srcdir)/inffast.c \ + $(srcdir)/inflate.c \ + $(srcdir)/inftrees.c \ + $(srcdir)/infutil.c \ + $(srcdir)/trees.c \ + $(srcdir)/uncompr.c \ + $(srcdir)/zutil.c + +OBJS = \ + $(srcdir)/adler32$(LO) \ + $(srcdir)/compress$(LO) \ + $(srcdir)/crc32$(LO) \ + $(srcdir)/deflate$(LO) \ + $(srcdir)/infblock$(LO) \ + $(srcdir)/infcodes$(LO) \ + $(srcdir)/inffast$(LO) \ + $(srcdir)/inflate$(LO) \ + $(srcdir)/inftrees$(LO) \ + $(srcdir)/infutil$(LO) \ + $(srcdir)/trees$(LO) \ + $(srcdir)/uncompr$(LO) \ + $(srcdir)/zutil$(LO) + +include ../../config/mklibs.inc + +# Automatically generated dependencies diff --git a/src/libs/pdflib/libs/flate/adler32.c b/src/libs/pdflib/libs/flate/adler32.c new file mode 100644 index 0000000000..20d5657172 --- /dev/null +++ b/src/libs/pdflib/libs/flate/adler32.c @@ -0,0 +1,46 @@ +/* adler32.c -- compute the Adler-32 checksum of a data stream + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* $Id: adler32.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ +/* @(#) $Id: adler32.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zlib.h" + +#define BASE 65521L /* largest prime smaller than 65536 */ +#define NMAX 5552 +/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ + +#define DO1(buf,i) {s1 += buf[i]; s2 += s1;} +#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); +#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); +#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); +#define DO16(buf) DO8(buf,0); DO8(buf,8); + +/* ========================================================================= */ +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) +{ + unsigned long s1 = adler & 0xffff; + unsigned long s2 = (adler >> 16) & 0xffff; + int k; + + if (buf == Z_NULL) return 1L; + + while (len > 0) { + k = len < NMAX ? len : NMAX; + len -= k; + while (k >= 16) { + DO16(buf); + buf += 16; + k -= 16; + } + if (k != 0) do { + s1 += *buf++; + s2 += s1; + } while (--k); + s1 %= BASE; + s2 %= BASE; + } + return (s2 << 16) | s1; +} diff --git a/src/libs/pdflib/libs/flate/compress.c b/src/libs/pdflib/libs/flate/compress.c new file mode 100644 index 0000000000..b6e03731dd --- /dev/null +++ b/src/libs/pdflib/libs/flate/compress.c @@ -0,0 +1,69 @@ +/* compress.c -- compress a memory buffer + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* $Id: compress.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ +/* @(#) $Id: compress.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zlib.h" + +/* =========================================================================== + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ +int ZEXPORT compress2 ( + Bytef *dest, + uLongf *destLen, + const Bytef *source, + uLong sourceLen, + int level) +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; +#ifdef MAXSEG_64K + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; +#endif + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + stream.opaque = (voidpf)0; + + err = deflateInit(&stream, level); + if (err != Z_OK) return err; + + err = deflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + deflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = deflateEnd(&stream); + return err; +} + +/* =========================================================================== + */ +int ZEXPORT compress ( + Bytef *dest, + uLongf *destLen, + const Bytef *source, + uLong sourceLen) +{ + return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); +} diff --git a/src/libs/pdflib/libs/flate/crc32.c b/src/libs/pdflib/libs/flate/crc32.c new file mode 100644 index 0000000000..9c09f63c41 --- /dev/null +++ b/src/libs/pdflib/libs/flate/crc32.c @@ -0,0 +1,163 @@ +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* $Id: crc32.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ +/* @(#) $Id: crc32.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zlib.h" + +#define local static + +#ifdef DYNAMIC_CRC_TABLE + +local int crc_table_empty = 1; +local uLongf crc_table[256]; +local void make_crc_table OF((void)); + +/* + Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The table is simply the CRC of all possible eight bit values. This is all + the information needed to generate CRC's on data a byte at a time for all + combinations of CRC register values and incoming bytes. +*/ +local void make_crc_table() +{ + uLong c; + int n, k; + uLong poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* make exclusive-or pattern from polynomial (0xedb88320L) */ + poly = 0L; + for (n = 0; n < sizeof(p)/sizeof(Byte); n++) + poly |= 1L << (31 - p[n]); + + for (n = 0; n < 256; n++) + { + c = (uLong)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[n] = c; + } + crc_table_empty = 0; +} +#else +/* ======================================================================== + * Table of CRC-32's of all single-byte values (made by make_crc_table) + */ +local const uLongf crc_table[256] = { + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; +#endif + +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const uLongf * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) make_crc_table(); +#endif + return (const uLongf *)crc_table; +} + +/* ========================================================================= */ +#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define DO2(buf) DO1(buf); DO1(buf); +#define DO4(buf) DO2(buf); DO2(buf); +#define DO8(buf) DO4(buf); DO4(buf); + +/* ========================================================================= */ +uLong ZEXPORT crc32( + uLong crc, + const Bytef *buf, + uInt len) +{ + if (buf == Z_NULL) return 0L; +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif + crc = crc ^ 0xffffffffL; + while (len >= 8) + { + DO8(buf); + len -= 8; + } + if (len) do { + DO1(buf); + } while (--len); + return crc ^ 0xffffffffL; +} diff --git a/src/libs/pdflib/libs/flate/deflate.c b/src/libs/pdflib/libs/flate/deflate.c new file mode 100644 index 0000000000..2f356f30a6 --- /dev/null +++ b/src/libs/pdflib/libs/flate/deflate.c @@ -0,0 +1,1356 @@ +/* deflate.c -- compress data using the deflation algorithm + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process depends on being able to identify portions + * of the input text which are identical to earlier input (within a + * sliding window trailing behind the input currently being processed). + * + * The most straightforward technique turns out to be the fastest for + * most input files: try all possible matches and select the longest. + * The key feature of this algorithm is that insertions into the string + * dictionary are very simple and thus fast, and deletions are avoided + * completely. Insertions are performed at each input character, whereas + * string matches are performed only when the previous match ends. So it + * is preferable to spend more time in matches to allow very fast string + * insertions and avoid deletions. The matching algorithm for small + * strings is inspired from that of Rabin & Karp. A brute force approach + * is used to find longer strings when a small match has been found. + * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze + * (by Leonid Broukhis). + * A previous version of this file used a more sophisticated algorithm + * (by Fiala and Greene) which is guaranteed to run in linear amortized + * time, but has a larger average cost, uses more memory and is patented. + * However the F&G algorithm may be faster for some highly redundant + * files if the parameter max_chain_length (described below) is too large. + * + * ACKNOWLEDGEMENTS + * + * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and + * I found it in 'freeze' written by Leonid Broukhis. + * Thanks to many people for bug reports and testing. + * + * REFERENCES + * + * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". + * Available in ftp://ds.internic.net/rfc/rfc1951.txt + * + * A description of the Rabin and Karp algorithm is given in the book + * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. + * + * Fiala,E.R., and Greene,D.H. + * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 + * + */ + +/* $Id: deflate.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ +/* @(#) $Id: deflate.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "deflate.h" + +const char deflate_copyright[] = + " deflate 1.1.4 Copyright 1995-2002 Jean-loup Gailly "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ + +/* =========================================================================== + * Function prototypes. + */ +typedef enum { + need_more, /* block not completed, need more input or more output */ + block_done, /* block flush performed */ + finish_started, /* finish started, need only more output at next deflate */ + finish_done /* finish done, accept no more input or output */ +} block_state; + +typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +/* Compression function. Returns the block state after the call. */ + +local void fill_window OF((deflate_state *s)); +local block_state deflate_stored OF((deflate_state *s, int flush)); +local block_state deflate_fast OF((deflate_state *s, int flush)); +local block_state deflate_slow OF((deflate_state *s, int flush)); +local void lm_init OF((deflate_state *s)); +local void putShortMSB OF((deflate_state *s, uInt b)); +local void flush_pending OF((z_streamp strm)); +local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +#ifdef ASMV + void match_init OF((void)); /* asm code initialization */ + uInt longest_match OF((deflate_state *s, IPos cur_match)); +#else +local uInt longest_match OF((deflate_state *s, IPos cur_match)); +#endif + +#ifdef DEBUG +local void check_match OF((deflate_state *s, IPos start, IPos match, + int length)); +#endif + +/* =========================================================================== + * Local data + */ + +#define NIL 0 +/* Tail of hash chains */ + +#ifndef TOO_FAR +# define TOO_FAR 4096 +#endif +/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +/* Values for max_lazy_match, good_match and max_chain_length, depending on + * the desired pack level (0..9). The values given below have been tuned to + * exclude worst case performance for pathological files. Better values may be + * found for specific files. + */ +typedef struct config_s { + ush good_length; /* reduce lazy search above this match length */ + ush max_lazy; /* do not perform lazy search above this match length */ + ush nice_length; /* quit search above this match length */ + ush max_chain; + compress_func func; +} config; + +local const config configuration_table[10] = { +/* good lazy nice chain */ +/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ +/* 1 */ {4, 4, 8, 4, deflate_fast}, /* maximum speed, no lazy matches */ +/* 2 */ {4, 5, 16, 8, deflate_fast}, +/* 3 */ {4, 6, 32, 32, deflate_fast}, + +/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ +/* 5 */ {8, 16, 32, 32, deflate_slow}, +/* 6 */ {8, 16, 128, 128, deflate_slow}, +/* 7 */ {8, 32, 128, 256, deflate_slow}, +/* 8 */ {32, 128, 258, 1024, deflate_slow}, +/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* maximum compression */ + +/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 + * For deflate_fast() (levels <= 3) good is ignored and lazy has a different + * meaning. + */ + +#define EQUAL 0 +/* result of memcmp for equal strings */ + +/* PDFlib GmbH: conflicts with Visual Studio.NET +struct static_tree_desc_s {int dummy;}; */ /* for buggy compilers */ + +/* =========================================================================== + * Update a hash value with the given input byte + * IN assertion: all calls to to UPDATE_HASH are made with consecutive + * input characters, so that a running hash key can be computed from the + * previous key instead of complete recalculation each time. + */ +#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) + + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * If this file is compiled with -DFASTEST, the compression level is forced + * to 1, and no hash chains are maintained. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef FASTEST +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#else +#define INSERT_STRING(s, str, match_head) \ + (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ + s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \ + s->head[s->ins_h] = (Pos)(str)) +#endif + +/* =========================================================================== + * Initialize the hash table (avoiding 64K overflow for 16 bit systems). + * prev[] will be initialized on the fly. + */ +#define CLEAR_HASH(s) \ + s->head[s->hash_size-1] = NIL; \ + zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); + +/* ========================================================================= */ +int ZEXPORT deflateInit_( + z_streamp strm, + int level, + const char *version, + int stream_size) +{ + return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, version, stream_size); + /* To do: ignore strm->next_in if we use it as window */ +} + +/* ========================================================================= */ +int ZEXPORT deflateInit2_( + z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy, + const char *version, + int stream_size) +{ + deflate_state *s; + int noheader = 0; + static const char* my_version = ZLIB_VERSION; + + ushf *overlay; + /* We overlay pending_buf and d_buf+l_buf. This works since the average + * output size for (length,distance) codes is <= 24 bits. + */ + + if (version == Z_NULL || version[0] != my_version[0] || + stream_size != sizeof(z_stream)) { + return Z_VERSION_ERROR; + } + if (strm == Z_NULL) return Z_STREAM_ERROR; + + strm->msg = Z_NULL; + if (strm->zalloc == Z_NULL) { + strm->zalloc = zcalloc; + strm->opaque = (voidpf)0; + } + if (strm->zfree == Z_NULL) strm->zfree = zcfree; + + if (level == Z_DEFAULT_COMPRESSION) level = 6; +#ifdef FASTEST + level = 1; +#endif + + if (windowBits < 0) { /* undocumented feature: suppress zlib header */ + noheader = 1; + windowBits = -windowBits; + } + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || + windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || + strategy < 0 || strategy > Z_HUFFMAN_ONLY) { + return Z_STREAM_ERROR; + } + s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); + if (s == Z_NULL) return Z_MEM_ERROR; + strm->state = (struct internal_state FAR *)s; + s->data_type = Z_UNKNOWN; + s->strm = strm; + + s->noheader = noheader; + s->w_bits = windowBits; + s->w_size = 1 << s->w_bits; + s->w_mask = s->w_size - 1; + + s->hash_bits = memLevel + 7; + s->hash_size = 1 << s->hash_bits; + s->hash_mask = s->hash_size - 1; + s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); + + s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); + /* we don't use calloc -> to satisfy purify + * at least here memset is needed */ + memset((void *)s->window, 0, (size_t) s->w_size * 2*sizeof(Byte)); + + s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); + s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); + + s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ + + overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + s->pending_buf = (uchf *) overlay; + s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); + + if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || + s->pending_buf == Z_NULL) { + strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); + deflateEnd (strm); + return Z_MEM_ERROR; + } + s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; + + s->level = level; + s->strategy = strategy; + s->method = (Byte)method; + + return deflateReset(strm); +} + +/* ========================================================================= */ +int ZEXPORT deflateSetDictionary ( + z_streamp strm, + const Bytef *dictionary, + uInt dictLength) +{ + deflate_state *s; + uInt length = dictLength; + uInt n; + IPos hash_head = 0; + + if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || + strm->state->status != INIT_STATE) return Z_STREAM_ERROR; + + s = strm->state; + strm->adler = adler32(strm->adler, dictionary, dictLength); + + if (length < MIN_MATCH) return Z_OK; + if (length > MAX_DIST(s)) { + length = MAX_DIST(s); +#ifndef USE_DICT_HEAD + dictionary += dictLength - length; /* use the tail of the dictionary */ +#endif + } + zmemcpy(s->window, dictionary, length); + s->strstart = length; + s->block_start = (long)length; + + /* Insert all strings in the hash table (except for the last two bytes). + * s->lookahead stays null, so s->ins_h will be recomputed at the next + * call of fill_window. + */ + s->ins_h = s->window[0]; + UPDATE_HASH(s, s->ins_h, s->window[1]); + for (n = 0; n <= length - MIN_MATCH; n++) { + INSERT_STRING(s, n, hash_head); + } + if (hash_head) hash_head = 0; /* to make compiler happy */ + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateReset ( + z_streamp strm) +{ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR; + + strm->total_in = strm->total_out = 0; + strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ + strm->data_type = Z_UNKNOWN; + + s = (deflate_state *)strm->state; + s->pending = 0; + s->pending_out = s->pending_buf; + + if (s->noheader < 0) { + s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */ + } + s->status = s->noheader ? BUSY_STATE : INIT_STATE; + strm->adler = 1; + s->last_flush = Z_NO_FLUSH; + + _tr_init(s); + lm_init(s); + + return Z_OK; +} + +/* ========================================================================= */ +int ZEXPORT deflateParams( + z_streamp strm, + int level, + int strategy) +{ + deflate_state *s; + compress_func func; + int err = Z_OK; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + s = strm->state; + + if (level == Z_DEFAULT_COMPRESSION) { + level = 6; + } + if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) { + return Z_STREAM_ERROR; + } + func = configuration_table[s->level].func; + + if (func != configuration_table[level].func && strm->total_in != 0) { + /* Flush the last buffer: */ + err = deflate(strm, Z_PARTIAL_FLUSH); + } + if (s->level != level) { + s->level = level; + s->max_lazy_match = configuration_table[level].max_lazy; + s->good_match = configuration_table[level].good_length; + s->nice_match = configuration_table[level].nice_length; + s->max_chain_length = configuration_table[level].max_chain; + } + s->strategy = strategy; + return err; +} + +/* ========================================================================= + * Put a short in the pending buffer. The 16-bit value is put in MSB order. + * IN assertion: the stream state is correct and there is enough room in + * pending_buf. + */ +local void putShortMSB ( + deflate_state *s, + uInt b) +{ + put_byte(s, (Byte)(b >> 8)); + put_byte(s, (Byte)(b & 0xff)); +} + +/* ========================================================================= + * Flush as much pending output as possible. All deflate() output goes + * through this function so some applications may wish to modify it + * to avoid allocating a large strm->next_out buffer and copying into it. + * (See also read_buf()). + */ +local void flush_pending( + z_streamp strm) +{ + unsigned len = strm->state->pending; + + if (len > strm->avail_out) len = strm->avail_out; + if (len == 0) return; + + zmemcpy(strm->next_out, strm->state->pending_out, len); + strm->next_out += len; + strm->state->pending_out += len; + strm->total_out += len; + strm->avail_out -= len; + strm->state->pending -= len; + if (strm->state->pending == 0) { + strm->state->pending_out = strm->state->pending_buf; + } +} + +/* ========================================================================= */ +int ZEXPORT deflate ( + z_streamp strm, + int flush) +{ + int old_flush; /* value of flush param for previous deflate call */ + deflate_state *s; + + if (strm == Z_NULL || strm->state == Z_NULL || + flush > Z_FINISH || flush < 0) { + return Z_STREAM_ERROR; + } + s = strm->state; + + if (strm->next_out == Z_NULL || + (strm->next_in == Z_NULL && strm->avail_in != 0) || + (s->status == FINISH_STATE && flush != Z_FINISH)) { + ERR_RETURN(strm, Z_STREAM_ERROR); + } + if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); + + s->strm = strm; /* just in case */ + old_flush = s->last_flush; + s->last_flush = flush; + + /* Write the zlib header */ + if (s->status == INIT_STATE) { + + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags = (s->level-1) >> 1; + + if (level_flags > 3) level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + s->status = BUSY_STATE; + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = 1L; + } + + /* Flush as much pending output as possible */ + if (s->pending != 0) { + flush_pending(strm); + if (strm->avail_out == 0) { + /* Since avail_out is 0, deflate will be called again with + * more output space, but possibly with both pending and + * avail_in equal to zero. There won't be anything to do, + * but this is not an error situation so make sure we + * return OK instead of BUF_ERROR at next call of deflate: + */ + s->last_flush = -1; + return Z_OK; + } + + /* Make sure there is something to do and avoid duplicate consecutive + * flushes. For repeated and useless calls with Z_FINISH, we keep + * returning Z_STREAM_END instead of Z_BUFF_ERROR. + */ + } else if (strm->avail_in == 0 && flush <= old_flush && + flush != Z_FINISH) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* User must not provide more input after the first FINISH: */ + if (s->status == FINISH_STATE && strm->avail_in != 0) { + ERR_RETURN(strm, Z_BUF_ERROR); + } + + /* Start a new block or continue the current one. + */ + if (strm->avail_in != 0 || s->lookahead != 0 || + (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { + block_state bstate; + + bstate = (*(configuration_table[s->level].func))(s, flush); + + if (bstate == finish_started || bstate == finish_done) { + s->status = FINISH_STATE; + } + if (bstate == need_more || bstate == finish_started) { + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ + } + return Z_OK; + /* If flush != Z_NO_FLUSH && avail_out == 0, the next call + * of deflate should use the same flush parameter to make sure + * that the flush is complete. So we don't have to output an + * empty block here, this will be done at next call. This also + * ensures that for a very small output buffer, we emit at most + * one empty block. + */ + } + if (bstate == block_done) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(s); + } else { /* FULL_FLUSH or SYNC_FLUSH */ + _tr_stored_block(s, (char*)0, 0L, 0); + /* For a full flush, this empty block will be recognized + * as a special marker by inflate_sync(). + */ + if (flush == Z_FULL_FLUSH) { + CLEAR_HASH(s); /* forget history */ + } + } + flush_pending(strm); + if (strm->avail_out == 0) { + s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ + return Z_OK; + } + } + } + Assert(strm->avail_out > 0, "bug2"); + + if (flush != Z_FINISH) return Z_OK; + if (s->noheader) return Z_STREAM_END; + + /* Write the zlib trailer (adler32) */ + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + flush_pending(strm); + /* If avail_out is zero, the application will call deflate again + * to flush the rest. + */ + s->noheader = -1; /* write the trailer only once! */ + return s->pending != 0 ? Z_OK : Z_STREAM_END; +} + +/* ========================================================================= */ +int ZEXPORT deflateEnd ( + z_streamp strm) +{ + int status; + + if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + + status = strm->state->status; + if (status != INIT_STATE && status != BUSY_STATE && + status != FINISH_STATE) { + return Z_STREAM_ERROR; + } + + /* Deallocate in reverse order of allocations: */ + TRY_FREE(strm, strm->state->pending_buf); + TRY_FREE(strm, strm->state->head); + TRY_FREE(strm, strm->state->prev); + TRY_FREE(strm, strm->state->window); + + ZFREE(strm, strm->state); + strm->state = Z_NULL; + + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; +} + +/* ========================================================================= + * Copy the source state to the destination state. + * To simplify the source, this is not supported for 16-bit MSDOS (which + * doesn't have enough memory anyway to duplicate compression states). + */ +int ZEXPORT deflateCopy ( + z_streamp dest, + z_streamp source) +{ +#ifdef MAXSEG_64K + return Z_STREAM_ERROR; +#else + deflate_state *ds; + deflate_state *ss; + ushf *overlay; + + + if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + return Z_STREAM_ERROR; + } + + ss = source->state; + + *dest = *source; + + ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); + if (ds == Z_NULL) return Z_MEM_ERROR; + dest->state = (struct internal_state FAR *) ds; + *ds = *ss; + ds->strm = dest; + + ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); + ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); + ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); + overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); + ds->pending_buf = (uchf *) overlay; + + if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || + ds->pending_buf == Z_NULL) { + deflateEnd (dest); + return Z_MEM_ERROR; + } + /* following zmemcpy do not work for 16-bit MSDOS */ + zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); + zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); + zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); + zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + + ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); + ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); + ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; + + ds->l_desc.dyn_tree = ds->dyn_ltree; + ds->d_desc.dyn_tree = ds->dyn_dtree; + ds->bl_desc.dyn_tree = ds->bl_tree; + + return Z_OK; +#endif +} + +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local int read_buf( + z_streamp strm, + Bytef *buf, + unsigned size) +{ + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + if (!strm->state->noheader) { + strm->adler = adler32(strm->adler, strm->next_in, len); + } + zmemcpy(buf, strm->next_in, len); + strm->next_in += len; + strm->total_in += len; + + return (int)len; +} + +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init ( + deflate_state *s) +{ + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +#ifdef ASMV + match_init(); /* initialize the asm code */ +#endif +} + +/* =========================================================================== + * Set match_start to the longest match starting at the given string and + * return its length. Matches shorter or equal to prev_length are discarded, + * in which case the result is equal to prev_length and match_start is + * garbage. + * IN assertions: cur_match is the head of the hash chain for the current + * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 + * OUT assertion: the match length is not greater than s->lookahead. + */ +#ifndef ASMV +/* For 80x86 and 680x0, an optimized version will be provided in match.asm or + * match.S. The code will be functionally equivalent. + */ +#ifndef FASTEST +local uInt longest_match( + deflate_state *s, + IPos cur_match) /* current match */ +{ + unsigned chain_length = s->max_chain_length;/* max hash chain length */ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + int best_len = s->prev_length; /* best match length so far */ + int nice_match = s->nice_match; /* stop if match long enough */ + IPos limit = s->strstart > (IPos)MAX_DIST(s) ? + s->strstart - (IPos)MAX_DIST(s) : NIL; + /* Stop when cur_match becomes <= limit. To simplify the code, + * we prevent matches with the string of window index 0. + */ + Posf *prev = s->prev; + uInt wmask = s->w_mask; + +#ifdef UNALIGNED_OK + /* Compare two bytes at a time. Note: this is not always beneficial. + * Try with and without -DUNALIGNED_OK to check. + */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; + register ush scan_start = *(ushf*)scan; + register ush scan_end = *(ushf*)(scan+best_len-1); +#else + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + register Byte scan_end1 = scan[best_len-1]; + register Byte scan_end = scan[best_len]; +#endif + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + /* Do not waste too much time if we already have a good match: */ + if (s->prev_length >= s->good_match) { + chain_length >>= 2; + } + /* Do not look for matches beyond the end of the input. This is necessary + * to make deflate deterministic. + */ + if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + do { + Assert(cur_match < s->strstart, "no future"); + match = s->window + cur_match; + + /* Skip to next match if the match length cannot increase + * or if the match length is less than 2: + */ +#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) + /* This code assumes sizeof(unsigned short) == 2. Do not use + * UNALIGNED_OK if your compiler uses a different size. + */ + if (*(ushf*)(match+best_len-1) != scan_end || + *(ushf*)match != scan_start) continue; + + /* It is not necessary to compare scan[2] and match[2] since they are + * always equal when the other bytes match, given that the hash keys + * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at + * strstart+3, +5, ... up to strstart+257. We check for insufficient + * lookahead only every 4th comparison; the 128th check will be made + * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is + * necessary to put more guard bytes at the end of the window, or + * to check more often for insufficient lookahead. + */ + Assert(scan[2] == match[2], "scan[2]?"); + scan++, match++; + do { + } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + *(ushf*)(scan+=2) == *(ushf*)(match+=2) && + scan < strend); + /* The funny "do {}" generates better code on most compilers */ + + /* Here, scan <= window+strstart+257 */ + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + if (*scan == *match) scan++; + + len = (MAX_MATCH - 1) - (int)(strend-scan); + scan = strend - (MAX_MATCH-1); + +#else /* UNALIGNED_OK */ + + if (match[best_len] != scan_end || + match[best_len-1] != scan_end1 || + *match != *scan || + *++match != scan[1]) continue; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match++; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + scan = strend - MAX_MATCH; + +#endif /* UNALIGNED_OK */ + + if (len > best_len) { + s->match_start = cur_match; + best_len = len; + if (len >= nice_match) break; +#ifdef UNALIGNED_OK + scan_end = *(ushf*)(scan+best_len-1); +#else + scan_end1 = scan[best_len-1]; + scan_end = scan[best_len]; +#endif + } + } while ((cur_match = prev[cur_match & wmask]) > limit + && --chain_length != 0); + + if ((uInt)best_len <= s->lookahead) return (uInt)best_len; + return s->lookahead; +} + +#else /* FASTEST */ +/* --------------------------------------------------------------------------- + * Optimized version for level == 1 only + */ +local uInt longest_match( + deflate_state *s, + IPos cur_match) /* current match */ +{ + register Bytef *scan = s->window + s->strstart; /* current string */ + register Bytef *match; /* matched string */ + register int len; /* length of current match */ + register Bytef *strend = s->window + s->strstart + MAX_MATCH; + + /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. + * It is easy to get rid of this optimization if necessary. + */ + Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); + + Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); + + Assert(cur_match < s->strstart, "no future"); + + match = s->window + cur_match; + + /* Return failure if the match length is less than 2: + */ + if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; + + /* The check at best_len-1 can be removed because it will be made + * again later. (This heuristic is not always a win.) + * It is not necessary to compare scan[2] and match[2] since they + * are always equal when the other bytes match, given that + * the hash keys are equal and that HASH_BITS >= 8. + */ + scan += 2, match += 2; + Assert(*scan == *match, "match[2]?"); + + /* We check for insufficient lookahead only every 8th comparison; + * the 256th check will be made at strstart+258. + */ + do { + } while (*++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + *++scan == *++match && *++scan == *++match && + scan < strend); + + Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); + + len = MAX_MATCH - (int)(strend - scan); + + if (len < MIN_MATCH) return MIN_MATCH - 1; + + s->match_start = cur_match; + return len <= s->lookahead ? len : s->lookahead; +} +#endif /* FASTEST */ +#endif /* ASMV */ + +#ifdef DEBUG +/* =========================================================================== + * Check that the match at match_start is indeed a match. + */ +local void check_match( + deflate_state *s, + IPos start, IPos match, + int length) +{ + /* check that the match is indeed a match */ + if (zmemcmp(s->window + match, + s->window + start, length) != EQUAL) { + fprintf(stderr, " start %u, match %u, length %d\n", + start, match, length); + do { + fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); + } while (--length != 0); + z_error("invalid match"); + } + if (z_verbose > 1) { + fprintf(stderr,"\\[%d,%d]", start-match, length); + do { putc(s->window[start++], stderr); } while (--length != 0); + } +} +#else +# define check_match(s, start, match, length) +#endif + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window( + deflate_state *s) +{ + register unsigned n, m; + register Posf *p; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if strstart == 0 + * and lookahead == 1 (input done one byte at time) + */ + more--; + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + } else if (s->strstart >= wsize+MAX_DIST(s)) { + + zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + + /* Slide the hash table (could be avoided with 32 bit values + at the expense of memory usage). We slide even when level == 0 + to keep the hash table consistent if we switch back to level > 0 + later. (Using level 0 permanently is not an optimal usage of + zlib, so we don't care about this pathological case.) + */ + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + } while (--n); + + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m-wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif + more += wsize; + } + if (s->strm->avail_in == 0) return; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead >= MIN_MATCH) { + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); +} + +/* =========================================================================== + * Flush the current block, with given end-of-file flag. + * IN assertion: strstart is set to the end of the current match. + */ +#define FLUSH_BLOCK_ONLY(s, eof) { \ + _tr_flush_block(s, (s->block_start >= 0L ? \ + (charf *)&s->window[(unsigned)s->block_start] : \ + (charf *)Z_NULL), \ + (ulg)((long)s->strstart - s->block_start), \ + (eof)); \ + s->block_start = s->strstart; \ + flush_pending(s->strm); \ + Tracev((stderr,"[FLUSH]")); \ +} + +/* Same but force premature exit if necessary. */ +#define FLUSH_BLOCK(s, eof) { \ + FLUSH_BLOCK_ONLY(s, eof); \ + if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ +} + +/* =========================================================================== + * Copy without compression as much as possible from the input stream, return + * the current block state. + * This function does not insert new strings in the dictionary since + * uncompressible data is probably not useful. This function is used + * only for the level=0 compression option. + * NOTE: this function should be optimized to avoid extra copying from + * window to pending_buf. + */ +local block_state deflate_stored( + deflate_state *s, + int flush) +{ + /* Stored blocks are limited to 0xffff bytes, pending_buf is limited + * to pending_buf_size, and each stored block has a 5 byte header: + */ + ulg max_block_size = 0xffff; + ulg max_start; + + if (max_block_size > s->pending_buf_size - 5) { + max_block_size = s->pending_buf_size - 5; + } + + /* Copy as much as possible from input to output: */ + for (;;) { + /* Fill the window as much as possible: */ + if (s->lookahead <= 1) { + + Assert(s->strstart < s->w_size+MAX_DIST(s) || + s->block_start >= (long)s->w_size, "slide too late"); + + fill_window(s); + if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; + + if (s->lookahead == 0) break; /* flush the current block */ + } + Assert(s->block_start >= 0L, "block gone"); + + s->strstart += s->lookahead; + s->lookahead = 0; + + /* Emit a stored block if pending_buf will be full: */ + max_start = s->block_start + max_block_size; + if (s->strstart == 0 || (ulg)s->strstart >= max_start) { + /* strstart == 0 is possible when wraparound on 16-bit machine */ + s->lookahead = (uInt)(s->strstart - max_start); + s->strstart = (uInt)max_start; + FLUSH_BLOCK(s, 0); + } + /* Flush if we may have to slide, otherwise block_start may become + * negative and the data will be gone: + */ + if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { + FLUSH_BLOCK(s, 0); + } + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * Compress as much as possible from the input stream, return the current + * block state. + * This function does not perform lazy evaluation of matches and inserts + * new strings in the dictionary only for unmatched strings or for short + * matches. It is used only for the fast compression options. + */ +local block_state deflate_fast( + deflate_state *s, + int flush) +{ + IPos hash_head = NIL; /* head of the hash chain */ + int bflush; /* set if current block must be flushed */ + + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + * At this point we have always match_length < MIN_MATCH + */ + if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + if (s->strategy != Z_HUFFMAN_ONLY) { + s->match_length = longest_match (s, hash_head); + } + /* longest_match() sets match_start */ + } + if (s->match_length >= MIN_MATCH) { + check_match(s, s->strstart, s->match_start, s->match_length); + + _tr_tally_dist(s, s->strstart - s->match_start, + s->match_length - MIN_MATCH, bflush); + + s->lookahead -= s->match_length; + + /* Insert new strings in the hash table only if the match length + * is not too large. This saves time but degrades compression. + */ +#ifndef FASTEST + if (s->match_length <= s->max_insert_length && + s->lookahead >= MIN_MATCH) { + s->match_length--;/* string at strstart already in hash table */ + do { + s->strstart++; + INSERT_STRING(s, s->strstart, hash_head); + /* strstart never exceeds WSIZE-MAX_MATCH, so there are + * always MIN_MATCH bytes ahead. + */ + } while (--s->match_length != 0); + s->strstart++; + } else +#endif + { + s->strstart += s->match_length; + s->match_length = 0; + s->ins_h = s->window[s->strstart]; + UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not + * matter since it will be recomputed at next deflate call. + */ + } + } else { + /* No match, output a literal byte */ + Tracevv((stderr,"%c", s->window[s->strstart])); + _tr_tally_lit (s, s->window[s->strstart], bflush); + s->lookahead--; + s->strstart++; + } + if (bflush) FLUSH_BLOCK(s, 0); + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} + +/* =========================================================================== + * Same as above, but achieves better compression. We use a lazy + * evaluation for matches: a match is finally adopted only if there is + * no better match at the next window position. + */ +local block_state deflate_slow( + deflate_state *s, + int flush) +{ + IPos hash_head = NIL; /* head of hash chain */ + int bflush; /* set if current block must be flushed */ + + /* Process the input block. */ + for (;;) { + /* Make sure that we always have enough lookahead, except + * at the end of the input file. We need MAX_MATCH bytes + * for the next match, plus MIN_MATCH bytes to insert the + * string following the next match. + */ + if (s->lookahead < MIN_LOOKAHEAD) { + fill_window(s); + if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return need_more; + } + if (s->lookahead == 0) break; /* flush the current block */ + } + + /* Insert the string window[strstart .. strstart+2] in the + * dictionary, and set hash_head to the head of the hash chain: + */ + if (s->lookahead >= MIN_MATCH) { + INSERT_STRING(s, s->strstart, hash_head); + } + + /* Find the longest match, discarding those <= prev_length. + */ + s->prev_length = s->match_length, s->prev_match = s->match_start; + s->match_length = MIN_MATCH-1; + + if (hash_head != NIL && s->prev_length < s->max_lazy_match && + s->strstart - hash_head <= MAX_DIST(s)) { + /* To simplify the code, we prevent matches with the string + * of window index 0 (in particular we have to avoid a match + * of the string with itself at the start of the input file). + */ + if (s->strategy != Z_HUFFMAN_ONLY) { + s->match_length = longest_match (s, hash_head); + } + /* longest_match() sets match_start */ + + if (s->match_length <= 5 && (s->strategy == Z_FILTERED || + (s->match_length == MIN_MATCH && + s->strstart - s->match_start > TOO_FAR))) { + + /* If prev_match is also MIN_MATCH, match_start is garbage + * but we will ignore the current match anyway. + */ + s->match_length = MIN_MATCH-1; + } + } + /* If there was a match at the previous step and the current + * match is not better, output the previous match: + */ + if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { + uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; + /* Do not insert strings in hash table beyond this. */ + + check_match(s, s->strstart-1, s->prev_match, s->prev_length); + + _tr_tally_dist(s, s->strstart -1 - s->prev_match, + s->prev_length - MIN_MATCH, bflush); + + /* Insert in hash table all strings up to the end of the match. + * strstart-1 and strstart are already inserted. If there is not + * enough lookahead, the last two strings are not inserted in + * the hash table. + */ + s->lookahead -= s->prev_length-1; + s->prev_length -= 2; + do { + if (++s->strstart <= max_insert) { + INSERT_STRING(s, s->strstart, hash_head); + } + } while (--s->prev_length != 0); + s->match_available = 0; + s->match_length = MIN_MATCH-1; + s->strstart++; + + if (bflush) FLUSH_BLOCK(s, 0); + + } else if (s->match_available) { + /* If there was no match at the previous position, output a + * single literal. If there was a match but the current match + * is longer, truncate the previous match to a single literal. + */ + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + if (bflush) { + FLUSH_BLOCK_ONLY(s, 0); + } + s->strstart++; + s->lookahead--; + if (s->strm->avail_out == 0) return need_more; + } else { + /* There is no previous match to compare with, wait for + * the next step to decide. + */ + s->match_available = 1; + s->strstart++; + s->lookahead--; + } + } + Assert (flush != Z_NO_FLUSH, "no flush?"); + if (s->match_available) { + Tracevv((stderr,"%c", s->window[s->strstart-1])); + _tr_tally_lit(s, s->window[s->strstart-1], bflush); + s->match_available = 0; + } + FLUSH_BLOCK(s, flush == Z_FINISH); + return flush == Z_FINISH ? finish_done : block_done; +} diff --git a/src/libs/pdflib/libs/flate/deflate.h b/src/libs/pdflib/libs/flate/deflate.h new file mode 100644 index 0000000000..20ebc7743a --- /dev/null +++ b/src/libs/pdflib/libs/flate/deflate.h @@ -0,0 +1,321 @@ +/* deflate.h -- internal compression state + * Copyright (C) 1995-2002 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + +/* $Id: deflate.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +/* @(#) $Id: deflate.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#ifndef _DEFLATE_H +#define _DEFLATE_H + +#include "zutil.h" + +/* =========================================================================== + * Internal compression state. + */ + +#define LENGTH_CODES 29 +/* number of length codes, not counting the special END_BLOCK code */ + +#define LITERALS 256 +/* number of literal bytes 0..255 */ + +#define L_CODES (LITERALS+1+LENGTH_CODES) +/* number of Literal or Length codes, including the END_BLOCK code */ + +#define D_CODES 30 +/* number of distance codes */ + +#define BL_CODES 19 +/* number of codes used to transfer the bit lengths */ + +#define HEAP_SIZE (2*L_CODES+1) +/* maximum heap size */ + +#define MAX_BITS 15 +/* All codes must not exceed MAX_BITS bits */ + +#define INIT_STATE 42 +#define BUSY_STATE 113 +#define FINISH_STATE 666 +/* Stream status */ + + +/* Data structure describing a single value and its code string. */ +typedef struct ct_data_s { + union { + ush freq; /* frequency count */ + ush code; /* bit string */ + } fc; + union { + ush dad; /* father node in Huffman tree */ + ush len; /* length of bit string */ + } dl; +} FAR ct_data; + +#define Freq fc.freq +#define Code fc.code +#define Dad dl.dad +#define Len dl.len + +typedef struct static_tree_desc_s static_tree_desc; + +typedef struct tree_desc_s { + ct_data *dyn_tree; /* the dynamic tree */ + int max_code; /* largest code with non zero frequency */ + static_tree_desc *stat_desc; /* the corresponding static tree */ +} FAR tree_desc; + +typedef ush Pos; +typedef Pos FAR Posf; +typedef unsigned IPos; + +/* A Pos is an index in the character window. We use short instead of int to + * save space in the various tables. IPos is used only for parameter passing. + */ + +typedef struct internal_state { + z_streamp strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + Bytef *pending_buf; /* output still pending */ + ulg pending_buf_size; /* size of pending_buf */ + Bytef *pending_out; /* next pending byte to output to the stream */ + int pending; /* nb of bytes in the pending buffer */ + int noheader; /* suppress zlib header and adler32 */ + Byte data_type; /* UNKNOWN, BINARY or ASCII */ + Byte method; /* STORED (for zip only) or DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ + + /* used by deflate.c: */ + + uInt w_size; /* LZ77 window size (32K by default) */ + uInt w_bits; /* log2(w_size) (8..16) */ + uInt w_mask; /* w_size - 1 */ + + Bytef *window; + /* Sliding window. Input bytes are read into the second half of the window, + * and move to the first half later to keep a dictionary of at least wSize + * bytes. With this organization, matches are limited to a distance of + * wSize-MAX_MATCH bytes, but this ensures that IO is always + * performed with a length multiple of the block size. Also, it limits + * the window size to 64K, which is quite useful on MSDOS. + * To do: use the user input buffer as sliding window. + */ + + ulg window_size; + /* Actual size of window: 2*wSize, except when the user input buffer + * is directly used as sliding window. + */ + + Posf *prev; + /* Link to older string with same hash index. To limit the size of this + * array to 64K, this link is maintained only for the last 32K strings. + * An index in this array is thus a window index modulo 32K. + */ + + Posf *head; /* Heads of the hash chains or NIL. */ + + uInt ins_h; /* hash index of string to be inserted */ + uInt hash_size; /* number of elements in hash table */ + uInt hash_bits; /* log2(hash_size) */ + uInt hash_mask; /* hash_size-1 */ + + uInt hash_shift; + /* Number of bits by which ins_h must be shifted at each input + * step. It must be such that after MIN_MATCH steps, the oldest + * byte no longer takes part in the hash key, that is: + * hash_shift * MIN_MATCH >= hash_bits + */ + + long block_start; + /* Window position at the beginning of the current output block. Gets + * negative when the window is moved backwards. + */ + + uInt match_length; /* length of best match */ + IPos prev_match; /* previous match */ + int match_available; /* set if previous match exists */ + uInt strstart; /* start of string to insert */ + uInt match_start; /* start of matching string */ + uInt lookahead; /* number of valid bytes ahead in window */ + + uInt prev_length; + /* Length of the best match at previous step. Matches not greater than this + * are discarded. This is used in the lazy match evaluation. + */ + + uInt max_chain_length; + /* To speed up deflation, hash chains are never searched beyond this + * length. A higher limit improves compression ratio but degrades the + * speed. + */ + + uInt max_lazy_match; + /* Attempt to find a better match only when the current match is strictly + * smaller than this value. This mechanism is used only for compression + * levels >= 4. + */ +# define max_insert_length max_lazy_match + /* Insert new strings in the hash table only if the match length is not + * greater than this length. This saves time but degrades compression. + * max_insert_length is used only for compression levels <= 3. + */ + + int level; /* compression level (1..9) */ + int strategy; /* favor or force Huffman coding*/ + + uInt good_match; + /* Use a faster search when the previous match is longer than this */ + + int nice_match; /* Stop searching when current match exceeds this */ + + /* used by trees.c: */ + /* Didn't use ct_data typedef below to supress compiler warning */ + struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ + struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ + struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ + + struct tree_desc_s l_desc; /* desc. for literal tree */ + struct tree_desc_s d_desc; /* desc. for distance tree */ + struct tree_desc_s bl_desc; /* desc. for bit length tree */ + + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ + int heap_len; /* number of elements in the heap */ + int heap_max; /* element of largest frequency */ + /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + * The same heap array is used to build all trees. + */ + + uch depth[2*L_CODES+1]; + /* Depth of each subtree used as tie breaker for trees of equal frequency + */ + + uchf *l_buf; /* buffer for literals or lengths */ + + uInt lit_bufsize; + /* Size of match buffer for literals/lengths. There are 4 reasons for + * limiting lit_bufsize to 64K: + * - frequencies can be kept in 16 bit counters + * - if compression is not successful for the first block, all input + * data is still in the window so we can still emit a stored block even + * when input comes from standard input. (This can also be done for + * all blocks if lit_bufsize is not greater than 32K.) + * - if compression is not successful for a file smaller than 64K, we can + * even emit a stored file instead of a stored block (saving 5 bytes). + * This is applicable only for zip (not gzip or zlib). + * - creating new Huffman trees less frequently may not provide fast + * adaptation to changes in the input data statistics. (Take for + * example a binary file with poorly compressible code followed by + * a highly compressible string table.) Smaller buffer sizes give + * fast adaptation but have of course the overhead of transmitting + * trees more frequently. + * - I can't count above 4 + */ + + uInt last_lit; /* running index in l_buf */ + + ushf *d_buf; + /* Buffer for distances. To simplify the code, d_buf and l_buf have + * the same number of elements. To use different lengths, an extra flag + * array would be necessary. + */ + + ulg opt_len; /* bit length of current block with optimal trees */ + ulg static_len; /* bit length of current block with static trees */ + uInt matches; /* number of string matches in current block */ + int last_eob_len; /* bit length of EOB code for last block */ + +#ifdef DEBUG + ulg compressed_len; /* total bit length of compressed file mod 2^32 */ + ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ +#endif + + ush bi_buf; + /* Output buffer. bits are inserted starting at the bottom (least + * significant bits). + */ + int bi_valid; + /* Number of valid bits in bi_buf. All bits above the last valid bit + * are always zero. + */ + +} FAR deflate_state; + +/* Output a byte on the stream. + * IN assertion: there is enough room in pending_buf. + */ +#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} + + +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +/* Minimum amount of lookahead, except at the end of the input file. + * See deflate.c for comments about the MIN_MATCH+1. + */ + +#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) +/* In order to simplify the code, particularly on 16 bit machines, match + * distances are limited to MAX_DIST instead of WSIZE. + */ + + /* in trees.c */ +void _tr_init OF((deflate_state *s)); +int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); +void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, + int eof)); +void _tr_align OF((deflate_state *s)); +void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, + int eof)); + +#define d_code(dist) \ + ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) +/* Mapping from a distance to a distance code. dist is the distance - 1 and + * must not have side effects. _dist_code[256] and _dist_code[257] are never + * used. + */ + +#ifndef DEBUG +/* Inline versions of _tr_tally for speed: */ + +#if defined(GEN_TREES_H) || !defined(STDC) + extern uch _length_code[]; + extern uch _dist_code[]; +#else + extern const uch _length_code[]; + extern const uch _dist_code[]; +#endif + +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->last_lit] = 0; \ + s->l_buf[s->last_lit++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (length); \ + ush dist = (distance); \ + s->d_buf[s->last_lit] = dist; \ + s->l_buf[s->last_lit++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->last_lit == s->lit_bufsize-1); \ + } +#else +# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) +# define _tr_tally_dist(s, distance, length, flush) \ + flush = _tr_tally(s, distance, length) +#endif + +#endif diff --git a/src/libs/pdflib/libs/flate/flate.dsp b/src/libs/pdflib/libs/flate/flate.dsp new file mode 100644 index 0000000000..bb32645bab --- /dev/null +++ b/src/libs/pdflib/libs/flate/flate.dsp @@ -0,0 +1,340 @@ +# Microsoft Developer Studio Project File - Name="flate" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=flate - Win32 Debug PSP DLL +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "flate.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "flate.mak" CFG="flate - Win32 Debug PSP DLL" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "flate - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Release mtDLL" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Release PSP" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Release mtDLL PSP" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Debug PSP" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Release DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Debug DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Release PSP DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "flate - Win32 Debug PSP DLL" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "flate - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Release mtDLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL" +# PROP BASE Intermediate_Dir "Release_mtDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL" +# PROP Intermediate_Dir "Release_mtDLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "..\pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"zlib.lib" +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Release PSP" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_PSP" +# PROP BASE Intermediate_Dir "Release_PSP" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_PSP" +# PROP Intermediate_Dir "Release_PSP" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"zlib.lib" +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Release mtDLL PSP" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL_PSP" +# PROP BASE Intermediate_Dir "Release_mtDLL_PSP" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL_PSP" +# PROP Intermediate_Dir "Release_mtDLL_PSP" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"zlib.lib" +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Debug PSP" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_PSP" +# PROP BASE Intermediate_Dir "Debug_PSP" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_PSP" +# PROP Intermediate_Dir "Debug_PSP" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"zlib.lib" +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_DLL" +# PROP BASE Intermediate_Dir "Release_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_DLL" +# PROP Intermediate_Dir "Release_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"zlib.lib" +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_DLL" +# PROP BASE Intermediate_Dir "Debug_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_DLL" +# PROP Intermediate_Dir "Debug_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"zlib.lib" +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Release PSP DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_PSP_DLL" +# PROP BASE Intermediate_Dir "Release_PSP_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_PSP_DLL" +# PROP Intermediate_Dir "Release_PSP_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"zlib.lib" +# ADD LIB32 /nologo /out:"zlib.lib" + +!ELSEIF "$(CFG)" == "flate - Win32 Debug PSP DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_PSP_DLL" +# PROP BASE Intermediate_Dir "Debug_PSP_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_PSP_DLL" +# PROP Intermediate_Dir "Debug_PSP_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"zlib.lib" +# ADD LIB32 /nologo /out:"zlib.lib" + +!ENDIF + +# Begin Target + +# Name "flate - Win32 Release" +# Name "flate - Win32 Debug" +# Name "flate - Win32 Release mtDLL" +# Name "flate - Win32 Release PSP" +# Name "flate - Win32 Release mtDLL PSP" +# Name "flate - Win32 Debug PSP" +# Name "flate - Win32 Release DLL" +# Name "flate - Win32 Debug DLL" +# Name "flate - Win32 Release PSP DLL" +# Name "flate - Win32 Debug PSP DLL" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\adler32.c +# End Source File +# Begin Source File + +SOURCE=.\compress.c +# End Source File +# Begin Source File + +SOURCE=.\crc32.c +# End Source File +# Begin Source File + +SOURCE=.\deflate.c +# End Source File +# Begin Source File + +SOURCE=.\infblock.c +# End Source File +# Begin Source File + +SOURCE=.\infcodes.c +# End Source File +# Begin Source File + +SOURCE=.\inffast.c +# End Source File +# Begin Source File + +SOURCE=.\inflate.c +# End Source File +# Begin Source File + +SOURCE=.\inftrees.c +# End Source File +# Begin Source File + +SOURCE=.\infutil.c +# End Source File +# Begin Source File + +SOURCE=.\trees.c +# End Source File +# Begin Source File + +SOURCE=.\uncompr.c +# End Source File +# Begin Source File + +SOURCE=.\zutil.c +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/flate/infblock.c b/src/libs/pdflib/libs/flate/infblock.c new file mode 100644 index 0000000000..6765bd07c0 --- /dev/null +++ b/src/libs/pdflib/libs/flate/infblock.c @@ -0,0 +1,405 @@ +/* infblock.c -- interpret and process block types to last block + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ +/* $Id: infblock.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zutil.h" +#include "infblock.h" +#include "inftrees.h" +#include "infcodes.h" +#include "infutil.h" + +/* PDFlib GmbH: conflicts with Visual Studio.NET +struct inflate_codes_state {int dummy;}; *//* for buggy compilers */ + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + +/* Table for deflate from PKZIP's appnote.txt. */ +local const uInt border[] = { /* Order of the bit length code lengths */ + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; + +/* + Notes beyond the 1.93a appnote.txt: + + 1. Distance pointers never point before the beginning of the output + stream. + 2. Distance pointers can point back across blocks, up to 32k away. + 3. There is an implied maximum of 7 bits for the bit length table and + 15 bits for the actual data. + 4. If only one code exists, then it is encoded using one bit. (Zero + would be more efficient, but perhaps a little confusing.) If two + codes exist, they are coded using one bit each (0 and 1). + 5. There is no way of sending zero distance codes--a dummy must be + sent if there are none. (History: a pre 2.0 version of PKZIP would + store blocks with no distance codes, but this was discovered to be + too harsh a criterion.) Valid only for 1.93a. 2.04c does allow + zero distance codes, which is sent as one code of zero bits in + length. + 6. There are up to 286 literal/length codes. Code 256 represents the + end-of-block. Note however that the static length tree defines + 288 codes just to fill out the Huffman codes. Codes 286 and 287 + cannot be used though, since there is no length base or extra bits + defined for them. Similarily, there are up to 30 distance codes. + However, static trees define 32 codes (all 5 bits) to fill out the + Huffman codes, but the last two had better not show up in the data. + 7. Unzip can check dynamic Huffman blocks for complete code sets. + The exception is that a single code would not be complete (see #4). + 8. The five bits following the block type is really the number of + literal codes sent minus 257. + 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits + (1+6+6). Therefore, to output three times the length, you output + three codes (1+1+1), whereas to output four times the same length, + you only need two codes (1+3). Hmm. + 10. In the tree reconstruction algorithm, Code = Code + Increment + only if BitLength(i) is not zero. (Pretty obvious.) + 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) + 12. Note: length code 284 can represent 227-258, but length code 285 + really is 258. The last length deserves its own, short code + since it gets used a lot in very redundant files. The length + 258 is special since 258 - 3 (the min match length) is 255. + 13. The literal/length and distance code bit lengths are read as a + single stream of lengths. It is possible (and advantageous) for + a repeat code (16, 17, or 18) to go across the boundary between + the two sets of lengths. + */ + + +void inflate_blocks_reset( +inflate_blocks_statef *s, +z_streamp z, +uLongf *c) +{ + if (c != Z_NULL) + *c = s->check; + if (s->mode == BTREE || s->mode == DTREE) + ZFREE(z, s->sub.trees.blens); + if (s->mode == CODES) + inflate_codes_free(s->sub.decode.codes, z); + s->mode = TYPE; + s->bitk = 0; + s->bitb = 0; + s->read = s->write = s->window; + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0); + Tracev((stderr, "inflate: blocks reset\n")); +} + + +inflate_blocks_statef *inflate_blocks_new( +z_streamp z, +check_func c, +uInt w) +{ + inflate_blocks_statef *s; + + if ((s = (inflate_blocks_statef *)ZALLOC + (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) + return s; + if ((s->hufts = + (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL) + { + ZFREE(z, s); + return Z_NULL; + } + if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) + { + ZFREE(z, s->hufts); + ZFREE(z, s); + return Z_NULL; + } + s->end = s->window + w; + s->checkfn = c; + s->mode = TYPE; + Tracev((stderr, "inflate: blocks allocated\n")); + inflate_blocks_reset(s, z, Z_NULL); + return s; +} + + +int inflate_blocks( +inflate_blocks_statef *s, +z_streamp z, +int r) +{ + uInt t; /* temporary storage */ + uLong b; /* bit buffer */ + uInt k; /* bits in bit buffer */ + Bytef *p; /* input data pointer */ + uInt n; /* bytes available there */ + Bytef *q; /* output window write pointer */ + uInt m; /* bytes to end of window or read pointer */ + + /* copy input/output information to locals (UPDATE macro restores) */ + LOAD + + /* process input based on current state */ + while (1) switch (s->mode) + { + case TYPE: + NEEDBITS(3) + t = (uInt)b & 7; + s->last = t & 1; + switch (t >> 1) + { + case 0: /* stored */ + Tracev((stderr, "inflate: stored block%s\n", + s->last ? " (last)" : "")); + DUMPBITS(3) + t = k & 7; /* go to byte boundary */ + DUMPBITS(t) + s->mode = LENS; /* get length of stored block */ + break; + case 1: /* fixed */ + Tracev((stderr, "inflate: fixed codes block%s\n", + s->last ? " (last)" : "")); + { + uInt bl, bd; + inflate_huft *tl, *td; + + inflate_trees_fixed(&bl, &bd, &tl, &td, z); + s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); + if (s->sub.decode.codes == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + } + DUMPBITS(3) + s->mode = CODES; + break; + case 2: /* dynamic */ + Tracev((stderr, "inflate: dynamic codes block%s\n", + s->last ? " (last)" : "")); + DUMPBITS(3) + s->mode = TABLE; + break; + case 3: /* illegal */ + DUMPBITS(3) + s->mode = BAD; + z->msg = (char*)"invalid block type"; + r = Z_DATA_ERROR; + LEAVE + } + break; + case LENS: + NEEDBITS(32) + if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) + { + s->mode = BAD; + z->msg = (char*)"invalid stored block lengths"; + r = Z_DATA_ERROR; + LEAVE + } + s->sub.left = (uInt)b & 0xffff; + b = k = 0; /* dump bits */ + Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); + s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE); + break; + case STORED: + if (n == 0) + LEAVE + NEEDOUT + t = s->sub.left; + if (t > n) t = n; + if (t > m) t = m; + zmemcpy(q, p, t); + p += t; n -= t; + q += t; m -= t; + if ((s->sub.left -= t) != 0) + break; + Tracev((stderr, "inflate: stored end, %lu total out\n", + z->total_out + (q >= s->read ? q - s->read : + (s->end - s->read) + (q - s->window)))); + s->mode = s->last ? DRY : TYPE; + break; + case TABLE: + NEEDBITS(14) + s->sub.trees.table = t = (uInt)b & 0x3fff; +#ifndef PKZIP_BUG_WORKAROUND + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) + { + s->mode = BAD; + z->msg = (char*)"too many length or distance symbols"; + r = Z_DATA_ERROR; + LEAVE + } +#endif + t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); + if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + DUMPBITS(14) + s->sub.trees.index = 0; + Tracev((stderr, "inflate: table sizes ok\n")); + s->mode = BTREE; + case BTREE: + while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) + { + NEEDBITS(3) + s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; + DUMPBITS(3) + } + while (s->sub.trees.index < 19) + s->sub.trees.blens[border[s->sub.trees.index++]] = 0; + s->sub.trees.bb = 7; + t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, + &s->sub.trees.tb, s->hufts, z); + if (t != Z_OK) + { + r = t; + if (r == Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + } + LEAVE + } + s->sub.trees.index = 0; + Tracev((stderr, "inflate: bits tree ok\n")); + s->mode = DTREE; + case DTREE: + while (t = s->sub.trees.table, + s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) + { + inflate_huft *h; + uInt i, j, c; + + t = s->sub.trees.bb; + NEEDBITS(t) + h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); + t = h->bits; + c = h->base; + if (c < 16) + { + DUMPBITS(t) + s->sub.trees.blens[s->sub.trees.index++] = c; + } + else /* c == 16..18 */ + { + i = c == 18 ? 7 : c - 14; + j = c == 18 ? 11 : 3; + NEEDBITS(t + i) + DUMPBITS(t) + j += (uInt)b & inflate_mask[i]; + DUMPBITS(i) + i = s->sub.trees.index; + t = s->sub.trees.table; + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || + (c == 16 && i < 1)) + { + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + z->msg = (char*)"invalid bit length repeat"; + r = Z_DATA_ERROR; + LEAVE + } + c = c == 16 ? s->sub.trees.blens[i - 1] : 0; + do { + s->sub.trees.blens[i++] = c; + } while (--j); + s->sub.trees.index = i; + } + } + s->sub.trees.tb = Z_NULL; + { + uInt bl, bd; + inflate_huft *tl, *td; + inflate_codes_statef *c; + + bl = 9; /* must be <= 9 for lookahead assumptions */ + bd = 6; /* must be <= 9 for lookahead assumptions */ + t = s->sub.trees.table; + t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), + s->sub.trees.blens, &bl, &bd, &tl, &td, + s->hufts, z); + if (t != Z_OK) + { + if (t == (uInt)Z_DATA_ERROR) + { + ZFREE(z, s->sub.trees.blens); + s->mode = BAD; + } + r = t; + LEAVE + } + Tracev((stderr, "inflate: trees ok\n")); + if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) + { + r = Z_MEM_ERROR; + LEAVE + } + s->sub.decode.codes = c; + } + ZFREE(z, s->sub.trees.blens); + s->mode = CODES; + case CODES: + UPDATE + if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) + return inflate_flush(s, z, r); + r = Z_OK; + inflate_codes_free(s->sub.decode.codes, z); + LOAD + Tracev((stderr, "inflate: codes end, %lu total out\n", + z->total_out + (q >= s->read ? q - s->read : + (s->end - s->read) + (q - s->window)))); + if (!s->last) + { + s->mode = TYPE; + break; + } + s->mode = DRY; + case DRY: + FLUSH + if (s->read != s->write) + LEAVE + s->mode = DONE; + case DONE: + r = Z_STREAM_END; + LEAVE + case BAD: + r = Z_DATA_ERROR; + LEAVE + default: + r = Z_STREAM_ERROR; + LEAVE + } +} + + +int inflate_blocks_free( +inflate_blocks_statef *s, +z_streamp z) +{ + inflate_blocks_reset(s, z, Z_NULL); + ZFREE(z, s->window); + ZFREE(z, s->hufts); + ZFREE(z, s); + Tracev((stderr, "inflate: blocks freed\n")); + return Z_OK; +} + + +void inflate_set_dictionary( +inflate_blocks_statef *s, +const Bytef *d, +uInt n) +{ + zmemcpy(s->window, d, n); + s->read = s->write = s->window + n; +} + + +/* Returns true if inflate is currently at the end of a block generated + * by Z_SYNC_FLUSH or Z_FULL_FLUSH. + * IN assertion: s != Z_NULL + */ +int inflate_blocks_sync_point( +inflate_blocks_statef *s) +{ + return s->mode == LENS; +} diff --git a/src/libs/pdflib/libs/flate/infblock.h b/src/libs/pdflib/libs/flate/infblock.h new file mode 100644 index 0000000000..a4346a8e7c --- /dev/null +++ b/src/libs/pdflib/libs/flate/infblock.h @@ -0,0 +1,42 @@ +/* infblock.h -- header to use infblock.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + +/* $Id: infblock.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +/* struct inflate_blocks_state; */ +typedef struct inflate_blocks_state FAR inflate_blocks_statef; + +extern inflate_blocks_statef * inflate_blocks_new OF(( + z_streamp z, + check_func c, /* check function */ + uInt w)); /* window size */ + +extern int inflate_blocks OF(( + inflate_blocks_statef *, + z_streamp , + int)); /* initial return code */ + +extern void inflate_blocks_reset OF(( + inflate_blocks_statef *, + z_streamp , + uLongf *)); /* check value on output */ + +extern int inflate_blocks_free OF(( + inflate_blocks_statef *, + z_streamp)); + +extern void inflate_set_dictionary OF(( + inflate_blocks_statef *s, + const Bytef *d, /* dictionary */ + uInt n)); /* dictionary length */ + +extern int inflate_blocks_sync_point OF(( + inflate_blocks_statef *s)); diff --git a/src/libs/pdflib/libs/flate/infcodes.c b/src/libs/pdflib/libs/flate/infcodes.c new file mode 100644 index 0000000000..b8b5db9c7d --- /dev/null +++ b/src/libs/pdflib/libs/flate/infcodes.c @@ -0,0 +1,252 @@ +/* infcodes.c -- process literals and length/distance pairs + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ +/* $Id: infcodes.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zutil.h" +#include "inftrees.h" +#include "infblock.h" +#include "infcodes.h" +#include "infutil.h" +#include "inffast.h" + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + +typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ + START, /* x: set up for LEN */ + LEN, /* i: get length/literal/eob next */ + LENEXT, /* i: getting length extra (have base) */ + DIST, /* i: get distance next */ + DISTEXT, /* i: getting distance extra */ + COPY, /* o: copying bytes in window, waiting for space */ + LIT, /* o: got literal, waiting for output space */ + WASH, /* o: got eob, possibly still output waiting */ + END, /* x: got eob and all data flushed */ + BADCODE} /* x: got error */ +inflate_codes_mode; + +/* inflate codes private state */ +struct inflate_codes_state { + + /* mode */ + inflate_codes_mode mode; /* current inflate_codes mode */ + + /* mode dependent information */ + uInt len; + union { + struct { + inflate_huft *tree; /* pointer into tree */ + uInt need; /* bits needed */ + } code; /* if LEN or DIST, where in tree */ + uInt lit; /* if LIT, literal */ + struct { + uInt get; /* bits to get for extra */ + uInt dist; /* distance back to copy from */ + } copy; /* if EXT or COPY, where and how much */ + } sub; /* submode */ + + /* mode independent information */ + Byte lbits; /* ltree bits decoded per branch */ + Byte dbits; /* dtree bits decoder per branch */ + inflate_huft *ltree; /* literal/length/eob tree */ + inflate_huft *dtree; /* distance tree */ + +}; + + +inflate_codes_statef *inflate_codes_new( +uInt bl, uInt bd, +inflate_huft *tl, +inflate_huft *td, /* need separate declaration for Borland C++ */ +z_streamp z) +{ + inflate_codes_statef *c; + + if ((c = (inflate_codes_statef *) + ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) + { + c->mode = START; + c->lbits = (Byte)bl; + c->dbits = (Byte)bd; + c->ltree = tl; + c->dtree = td; + Tracev((stderr, "inflate: codes new\n")); + } + return c; +} + + +int inflate_codes( +inflate_blocks_statef *s, +z_streamp z, +int r) +{ + uInt j; /* temporary storage */ + inflate_huft *t; /* temporary pointer */ + uInt e; /* extra bits or operation */ + uLong b; /* bit buffer */ + uInt k; /* bits in bit buffer */ + Bytef *p; /* input data pointer */ + uInt n; /* bytes available there */ + Bytef *q; /* output window write pointer */ + uInt m; /* bytes to end of window or read pointer */ + Bytef *f; /* pointer to copy strings from */ + inflate_codes_statef *c = s->sub.decode.codes; /* codes state */ + + /* copy input/output information to locals (UPDATE macro restores) */ + LOAD + + /* process input and output based on current state */ + while (1) switch (c->mode) + { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ + case START: /* x: set up for LEN */ +#ifndef SLOW + if (m >= 258 && n >= 10) + { + UPDATE + r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); + LOAD + if (r != Z_OK) + { + c->mode = r == Z_STREAM_END ? WASH : BADCODE; + break; + } + } +#endif /* !SLOW */ + c->sub.code.need = c->lbits; + c->sub.code.tree = c->ltree; + c->mode = LEN; + case LEN: /* i: get length/literal/eob next */ + j = c->sub.code.need; + NEEDBITS(j) + t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); + DUMPBITS(t->bits) + e = (uInt)(t->exop); + if (e == 0) /* literal */ + { + c->sub.lit = t->base; + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: literal '%c'\n" : + "inflate: literal 0x%02x\n", t->base)); + c->mode = LIT; + break; + } + if (e & 16) /* length */ + { + c->sub.copy.get = e & 15; + c->len = t->base; + c->mode = LENEXT; + break; + } + if ((e & 64) == 0) /* next table */ + { + c->sub.code.need = e; + c->sub.code.tree = t + t->base; + break; + } + if (e & 32) /* end of block */ + { + Tracevv((stderr, "inflate: end of block\n")); + c->mode = WASH; + break; + } + c->mode = BADCODE; /* invalid code */ + z->msg = (char*)"invalid literal/length code"; + r = Z_DATA_ERROR; + LEAVE + case LENEXT: /* i: getting length extra (have base) */ + j = c->sub.copy.get; + NEEDBITS(j) + c->len += (uInt)b & inflate_mask[j]; + DUMPBITS(j) + c->sub.code.need = c->dbits; + c->sub.code.tree = c->dtree; + Tracevv((stderr, "inflate: length %u\n", c->len)); + c->mode = DIST; + case DIST: /* i: get distance next */ + j = c->sub.code.need; + NEEDBITS(j) + t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); + DUMPBITS(t->bits) + e = (uInt)(t->exop); + if (e & 16) /* distance */ + { + c->sub.copy.get = e & 15; + c->sub.copy.dist = t->base; + c->mode = DISTEXT; + break; + } + if ((e & 64) == 0) /* next table */ + { + c->sub.code.need = e; + c->sub.code.tree = t + t->base; + break; + } + c->mode = BADCODE; /* invalid code */ + z->msg = (char*)"invalid distance code"; + r = Z_DATA_ERROR; + LEAVE + case DISTEXT: /* i: getting distance extra */ + j = c->sub.copy.get; + NEEDBITS(j) + c->sub.copy.dist += (uInt)b & inflate_mask[j]; + DUMPBITS(j) + Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); + c->mode = COPY; + case COPY: /* o: copying bytes in window, waiting for space */ + f = q - c->sub.copy.dist; + while (f < s->window) /* modulo window size-"while" instead */ + f += s->end - s->window; /* of "if" handles invalid distances */ + while (c->len) + { + NEEDOUT + OUTBYTE(*f++) + if (f == s->end) + f = s->window; + c->len--; + } + c->mode = START; + break; + case LIT: /* o: got literal, waiting for output space */ + NEEDOUT + OUTBYTE(c->sub.lit) + c->mode = START; + break; + case WASH: /* o: got eob, possibly more output */ + if (k > 7) /* return unused byte, if any */ + { + Assert(k < 16, "inflate_codes grabbed too many bytes") + k -= 8; + n++; + p--; /* can always return one */ + } + FLUSH + if (s->read != s->write) + LEAVE + c->mode = END; + case END: + r = Z_STREAM_END; + LEAVE + case BADCODE: /* x: got error */ + r = Z_DATA_ERROR; + LEAVE + default: + r = Z_STREAM_ERROR; + LEAVE + } +#ifdef NEED_DUMMY_RETURN + return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ +#endif +} + + +void inflate_codes_free( +inflate_codes_statef *c, +z_streamp z) +{ + ZFREE(z, c); + Tracev((stderr, "inflate: codes free\n")); +} diff --git a/src/libs/pdflib/libs/flate/infcodes.h b/src/libs/pdflib/libs/flate/infcodes.h new file mode 100644 index 0000000000..dafdc3256c --- /dev/null +++ b/src/libs/pdflib/libs/flate/infcodes.h @@ -0,0 +1,30 @@ +/* infcodes.h -- header to use infcodes.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + +/* $Id: infcodes.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +struct inflate_codes_state; +typedef struct inflate_codes_state FAR inflate_codes_statef; + +extern inflate_codes_statef *inflate_codes_new OF(( + uInt, uInt, + inflate_huft *, inflate_huft *, + z_streamp )); + +extern int inflate_codes OF(( + inflate_blocks_statef *, + z_streamp , + int)); + +extern void inflate_codes_free OF(( + inflate_codes_statef *, + z_streamp )); + diff --git a/src/libs/pdflib/libs/flate/inffast.c b/src/libs/pdflib/libs/flate/inffast.c new file mode 100644 index 0000000000..cb4b100bea --- /dev/null +++ b/src/libs/pdflib/libs/flate/inffast.c @@ -0,0 +1,185 @@ +/* inffast.c -- process literals and length/distance pairs fast + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ +/* $Id: inffast.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zutil.h" +#include "inftrees.h" +#include "infblock.h" +#include "infcodes.h" +#include "infutil.h" +#include "inffast.h" + +/* PDFlib GmbH: conflicts with Visual Studio.NET +struct inflate_codes_state {int dummy;}; *//* for buggy compilers */ + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + +/* macros for bit input with no checking and for returning unused bytes */ +#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<avail_in-n;c=(k>>3)>3:c;n+=c;p-=c;k-=c<<3;} + +/* Called with number of bytes left to write in window at least 258 + (the maximum string length) and number of input bytes available + at least ten. The ten bytes are six bytes for the longest length/ + distance pair plus four bytes for overloading the bit buffer. */ + +int inflate_fast( +uInt bl, uInt bd, +inflate_huft *tl, +inflate_huft *td,/* need separate declaration for Borland C++ */ +inflate_blocks_statef *s, +z_streamp z) +{ + inflate_huft *t; /* temporary pointer */ + uInt e; /* extra bits or operation */ + uLong b; /* bit buffer */ + uInt k; /* bits in bit buffer */ + Bytef *p; /* input data pointer */ + uInt n; /* bytes available there */ + Bytef *q; /* output window write pointer */ + uInt m; /* bytes to end of window or read pointer */ + uInt ml; /* mask for literal/length tree */ + uInt md; /* mask for distance tree */ + uInt c; /* bytes to copy */ + uInt d; /* distance back to copy from */ + Bytef *r; /* copy source pointer */ + + /* load input, output, bit values */ + LOAD + + /* initialize masks */ + ml = inflate_mask[bl]; + md = inflate_mask[bd]; + + /* do until not enough input or output space for fast loop */ + do { /* assume called with m >= 258 && n >= 10 */ + /* get literal/length code */ + GRABBITS(20) /* max bits for literal/length code */ + if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) + { + DUMPBITS(t->bits) + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: * literal '%c'\n" : + "inflate: * literal 0x%02x\n", t->base)); + *q++ = (Byte)t->base; + m--; + continue; + } + do { + DUMPBITS(t->bits) + if (e & 16) + { + /* get extra bits for length */ + e &= 15; + c = t->base + ((uInt)b & inflate_mask[e]); + DUMPBITS(e) + Tracevv((stderr, "inflate: * length %u\n", c)); + + /* decode distance base of block to copy */ + GRABBITS(15); /* max bits for distance code */ + e = (t = td + ((uInt)b & md))->exop; + do { + DUMPBITS(t->bits) + if (e & 16) + { + /* get extra bits to add to distance base */ + e &= 15; + GRABBITS(e) /* get extra bits (up to 13) */ + d = t->base + ((uInt)b & inflate_mask[e]); + DUMPBITS(e) + Tracevv((stderr, "inflate: * distance %u\n", d)); + + /* do the copy */ + m -= c; + r = q - d; + if (r < s->window) /* wrap if needed */ + { + do { + r += s->end - s->window; /* force pointer in window */ + } while (r < s->window); /* covers invalid distances */ + e = s->end - r; + if (c > e) + { + c -= e; /* wrapped copy */ + do { + *q++ = *r++; + } while (--e); + r = s->window; + do { + *q++ = *r++; + } while (--c); + } + else /* normal copy */ + { + *q++ = *r++; c--; + *q++ = *r++; c--; + do { + *q++ = *r++; + } while (--c); + } + } + else /* normal copy */ + { + *q++ = *r++; c--; + *q++ = *r++; c--; + do { + *q++ = *r++; + } while (--c); + } + break; + } + else if ((e & 64) == 0) + { + t += t->base; + e = (t += ((uInt)b & inflate_mask[e]))->exop; + } + else + { + z->msg = (char*)"invalid distance code"; + UNGRAB + UPDATE + return Z_DATA_ERROR; + } + } while (1); + break; + } + if ((e & 64) == 0) + { + t += t->base; + if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) + { + DUMPBITS(t->bits) + Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? + "inflate: * literal '%c'\n" : + "inflate: * literal 0x%02x\n", t->base)); + *q++ = (Byte)t->base; + m--; + break; + } + } + else if (e & 32) + { + Tracevv((stderr, "inflate: * end of block\n")); + UNGRAB + UPDATE + return Z_STREAM_END; + } + else + { + z->msg = (char*)"invalid literal/length code"; + UNGRAB + UPDATE + return Z_DATA_ERROR; + } + } while (1); + } while (m >= 258 && n >= 10); + + /* not enough input or output--restore pointers and return */ + UNGRAB + UPDATE + return Z_OK; +} diff --git a/src/libs/pdflib/libs/flate/inffast.h b/src/libs/pdflib/libs/flate/inffast.h new file mode 100644 index 0000000000..fdcbb1bfbe --- /dev/null +++ b/src/libs/pdflib/libs/flate/inffast.h @@ -0,0 +1,20 @@ +/* inffast.h -- header to use inffast.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + +/* $Id: inffast.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +extern int inflate_fast OF(( + uInt, + uInt, + inflate_huft *, + inflate_huft *, + inflate_blocks_statef *, + z_streamp )); diff --git a/src/libs/pdflib/libs/flate/inffixed.h b/src/libs/pdflib/libs/flate/inffixed.h new file mode 100644 index 0000000000..e2012319e7 --- /dev/null +++ b/src/libs/pdflib/libs/flate/inffixed.h @@ -0,0 +1,154 @@ +/* inffixed.h -- table for decoding fixed codes + * Generated automatically by the maketree.c program + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + +/* $Id: inffixed.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +local uInt fixed_bl = 9; +local uInt fixed_bd = 5; +local inflate_huft fixed_tl[] = { + {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, + {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, + {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, + {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, + {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, + {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, + {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, + {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, + {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, + {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, + {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, + {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, + {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, + {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, + {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, + {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, + {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, + {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, + {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, + {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, + {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, + {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, + {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, + {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, + {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, + {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, + {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, + {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, + {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, + {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188}, + {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252}, + {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, + {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, + {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, + {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, + {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, + {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, + {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, + {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, + {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, + {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, + {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, + {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, + {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, + {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, + {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, + {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, + {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, + {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, + {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, + {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, + {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, + {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, + {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, + {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, + {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, + {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, + {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, + {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, + {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, + {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190}, + {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254}, + {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, + {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, + {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, + {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, + {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, + {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, + {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, + {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, + {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, + {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, + {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, + {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, + {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, + {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, + {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, + {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, + {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, + {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, + {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, + {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, + {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, + {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, + {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, + {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, + {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, + {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, + {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, + {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, + {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, + {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189}, + {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253}, + {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, + {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, + {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, + {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, + {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, + {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, + {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, + {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, + {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, + {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, + {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, + {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, + {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, + {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, + {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, + {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, + {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, + {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, + {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, + {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, + {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, + {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, + {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, + {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, + {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, + {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, + {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, + {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, + {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, + {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, + {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, + {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} + }; +local inflate_huft fixed_td[] = { + {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, + {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, + {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, + {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, + {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, + {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, + {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, + {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} + }; diff --git a/src/libs/pdflib/libs/flate/inflate.c b/src/libs/pdflib/libs/flate/inflate.c new file mode 100644 index 0000000000..bebc06ff1a --- /dev/null +++ b/src/libs/pdflib/libs/flate/inflate.c @@ -0,0 +1,368 @@ +/* inflate.c -- zlib interface to inflate modules + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ +/* $Id: inflate.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zutil.h" +#include "infblock.h" + +/* PDFlib GmbH: conflicts with Visual Studio.NET +struct inflate_blocks_state {int dummy;}; *//* for buggy compilers */ + +typedef enum { + METHOD, /* waiting for method byte */ + FLAG, /* waiting for flag byte */ + DICT4, /* four dictionary check bytes to go */ + DICT3, /* three dictionary check bytes to go */ + DICT2, /* two dictionary check bytes to go */ + DICT1, /* one dictionary check byte to go */ + DICT0, /* waiting for inflateSetDictionary */ + BLOCKS, /* decompressing blocks */ + CHECK4, /* four check bytes to go */ + CHECK3, /* three check bytes to go */ + CHECK2, /* two check bytes to go */ + CHECK1, /* one check byte to go */ + DONE, /* finished check, done */ + BAD} /* got an error--stay here */ +inflate_mode; + +/* inflate private state */ +struct internal_state { + + /* mode */ + inflate_mode mode; /* current inflate mode */ + + /* mode dependent information */ + union { + uInt method; /* if FLAGS, method byte */ + struct { + uLong was; /* computed check value */ + uLong need; /* stream check value */ + } check; /* if CHECK, check values to compare */ + uInt marker; /* if BAD, inflateSync's marker bytes count */ + } sub; /* submode */ + + /* mode independent information */ + int nowrap; /* flag for no wrapper */ + uInt wbits; /* log2(window size) (8..15, defaults to 15) */ + inflate_blocks_statef + *blocks; /* current inflate_blocks state */ + +}; + + +int ZEXPORT inflateReset( +z_streamp z) +{ + if (z == Z_NULL || z->state == Z_NULL) + return Z_STREAM_ERROR; + z->total_in = z->total_out = 0; + z->msg = Z_NULL; + z->state->mode = z->state->nowrap ? BLOCKS : METHOD; + inflate_blocks_reset(z->state->blocks, z, Z_NULL); + Tracev((stderr, "inflate: reset\n")); + return Z_OK; +} + + +int ZEXPORT inflateEnd( +z_streamp z) +{ + if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) + return Z_STREAM_ERROR; + if (z->state->blocks != Z_NULL) + inflate_blocks_free(z->state->blocks, z); + ZFREE(z, z->state); + z->state = Z_NULL; + Tracev((stderr, "inflate: end\n")); + return Z_OK; +} + + +int ZEXPORT inflateInit2_( +z_streamp z, +int w, +const char *version, +int stream_size) +{ + if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || + stream_size != sizeof(z_stream)) + return Z_VERSION_ERROR; + + /* initialize state */ + if (z == Z_NULL) + return Z_STREAM_ERROR; + z->msg = Z_NULL; + if (z->zalloc == Z_NULL) + { + z->zalloc = zcalloc; + z->opaque = (voidpf)0; + } + if (z->zfree == Z_NULL) z->zfree = zcfree; + if ((z->state = (struct internal_state FAR *) + ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) + return Z_MEM_ERROR; + z->state->blocks = Z_NULL; + + /* handle undocumented nowrap option (no zlib header or check) */ + z->state->nowrap = 0; + if (w < 0) + { + w = - w; + z->state->nowrap = 1; + } + + /* set window size */ + if (w < 8 || w > 15) + { + inflateEnd(z); + return Z_STREAM_ERROR; + } + z->state->wbits = (uInt)w; + + /* create inflate_blocks state */ + if ((z->state->blocks = + inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) + == Z_NULL) + { + inflateEnd(z); + return Z_MEM_ERROR; + } + Tracev((stderr, "inflate: allocated\n")); + + /* reset state */ + inflateReset(z); + return Z_OK; +} + + +int ZEXPORT inflateInit_( +z_streamp z, +const char *version, +int stream_size) +{ + return inflateInit2_(z, DEF_WBITS, version, stream_size); +} + + +#define NEEDBYTE {if(z->avail_in==0)return r;r=f;} +#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) + +int ZEXPORT inflate( +z_streamp z, +int f) +{ + int r; + uInt b; + + if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) + return Z_STREAM_ERROR; + f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; + r = Z_BUF_ERROR; + while (1) switch (z->state->mode) + { + case METHOD: + NEEDBYTE + if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED) + { + z->state->mode = BAD; + z->msg = (char*)"unknown compression method"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + if ((z->state->sub.method >> 4) + 8 > z->state->wbits) + { + z->state->mode = BAD; + z->msg = (char*)"invalid window size"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + z->state->mode = FLAG; + case FLAG: + NEEDBYTE + b = NEXTBYTE; + if (((z->state->sub.method << 8) + b) % 31) + { + z->state->mode = BAD; + z->msg = (char*)"incorrect header check"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + Tracev((stderr, "inflate: zlib header ok\n")); + if (!(b & PRESET_DICT)) + { + z->state->mode = BLOCKS; + break; + } + z->state->mode = DICT4; + case DICT4: + NEEDBYTE + z->state->sub.check.need = (uLong)NEXTBYTE << 24; + z->state->mode = DICT3; + case DICT3: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 16; + z->state->mode = DICT2; + case DICT2: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 8; + z->state->mode = DICT1; + case DICT1: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE; + z->adler = z->state->sub.check.need; + z->state->mode = DICT0; + return Z_NEED_DICT; + case DICT0: + z->state->mode = BAD; + z->msg = (char*)"need dictionary"; + z->state->sub.marker = 0; /* can try inflateSync */ + return Z_STREAM_ERROR; + case BLOCKS: + r = inflate_blocks(z->state->blocks, z, r); + if (r == Z_DATA_ERROR) + { + z->state->mode = BAD; + z->state->sub.marker = 0; /* can try inflateSync */ + break; + } + if (r == Z_OK) + r = f; + if (r != Z_STREAM_END) + return r; + r = f; + inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); + if (z->state->nowrap) + { + z->state->mode = DONE; + break; + } + z->state->mode = CHECK4; + case CHECK4: + NEEDBYTE + z->state->sub.check.need = (uLong)NEXTBYTE << 24; + z->state->mode = CHECK3; + case CHECK3: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 16; + z->state->mode = CHECK2; + case CHECK2: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE << 8; + z->state->mode = CHECK1; + case CHECK1: + NEEDBYTE + z->state->sub.check.need += (uLong)NEXTBYTE; + + if (z->state->sub.check.was != z->state->sub.check.need) + { + z->state->mode = BAD; + z->msg = (char*)"incorrect data check"; + z->state->sub.marker = 5; /* can't try inflateSync */ + break; + } + Tracev((stderr, "inflate: zlib check ok\n")); + z->state->mode = DONE; + case DONE: + return Z_STREAM_END; + case BAD: + return Z_DATA_ERROR; + default: + return Z_STREAM_ERROR; + } +#ifdef NEED_DUMMY_RETURN + return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ +#endif +} + + +int ZEXPORT inflateSetDictionary( +z_streamp z, +const Bytef *dictionary, +uInt dictLength) +{ + uInt length = dictLength; + + if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) + return Z_STREAM_ERROR; + + if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; + z->adler = 1L; + + if (length >= ((uInt)1<state->wbits)) + { + length = (1<state->wbits)-1; + dictionary += dictLength - length; + } + inflate_set_dictionary(z->state->blocks, dictionary, length); + z->state->mode = BLOCKS; + return Z_OK; +} + + +int ZEXPORT inflateSync( +z_streamp z) +{ + uInt n; /* number of bytes to look at */ + Bytef *p; /* pointer to bytes */ + uInt m; /* number of marker bytes found in a row */ + uLong r, w; /* temporaries to save total_in and total_out */ + + /* set up */ + if (z == Z_NULL || z->state == Z_NULL) + return Z_STREAM_ERROR; + if (z->state->mode != BAD) + { + z->state->mode = BAD; + z->state->sub.marker = 0; + } + if ((n = z->avail_in) == 0) + return Z_BUF_ERROR; + p = z->next_in; + m = z->state->sub.marker; + + /* search */ + while (n && m < 4) + { + static const Byte mark[4] = {0, 0, 0xff, 0xff}; + if (*p == mark[m]) + m++; + else if (*p) + m = 0; + else + m = 4 - m; + p++, n--; + } + + /* restore */ + z->total_in += p - z->next_in; + z->next_in = p; + z->avail_in = n; + z->state->sub.marker = m; + + /* return no joy or set up to restart on a new block */ + if (m != 4) + return Z_DATA_ERROR; + r = z->total_in; w = z->total_out; + inflateReset(z); + z->total_in = r; z->total_out = w; + z->state->mode = BLOCKS; + return Z_OK; +} + + +/* Returns true if inflate is currently at the end of a block generated + * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH + * but removes the length bytes of the resulting empty stored block. When + * decompressing, PPP checks that at the end of input packet, inflate is + * waiting for these length bytes. + */ +int ZEXPORT inflateSyncPoint( +z_streamp z) +{ + if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) + return Z_STREAM_ERROR; + return inflate_blocks_sync_point(z->state->blocks); +} diff --git a/src/libs/pdflib/libs/flate/inftrees.c b/src/libs/pdflib/libs/flate/inftrees.c new file mode 100644 index 0000000000..4fe362dde0 --- /dev/null +++ b/src/libs/pdflib/libs/flate/inftrees.c @@ -0,0 +1,456 @@ +/* inftrees.c -- generate Huffman trees for efficient decoding + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ +/* $Id: inftrees.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zutil.h" +#include "inftrees.h" + +#if !defined(BUILDFIXED) && !defined(STDC) +# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ +#endif + +const char inflate_copyright[] = + " inflate 1.1.4 Copyright 1995-2002 Mark Adler "; +/* + If you use the zlib library in a product, an acknowledgment is welcome + in the documentation of your product. If for some reason you cannot + include such an acknowledgment, I would appreciate that you keep this + copyright string in the executable of your product. + */ +/* PDFlib GmbH: conflicts with Visual Studio.NET +struct internal_state {int dummy;}; *//* for buggy compilers */ + +/* simplify the use of the inflate_huft type with some defines */ +#define exop word.what.Exop +#define bits word.what.Bits + + +local int huft_build OF(( + uIntf *, /* code lengths in bits */ + uInt, /* number of codes */ + uInt, /* number of "simple" codes */ + const uIntf *, /* list of base values for non-simple codes */ + const uIntf *, /* list of extra bits for non-simple codes */ + inflate_huft * FAR*,/* result: starting table */ + uIntf *, /* maximum lookup bits (returns actual) */ + inflate_huft *, /* space for trees */ + uInt *, /* hufts used in space */ + uIntf * )); /* space for values */ + +/* Tables for deflate from PKZIP's appnote.txt. */ +local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; + /* see note #13 above about 258 */ +local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */ +local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577}; +local const uInt cpdext[30] = { /* Extra bits for distance codes */ + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13}; + +/* + Huffman code decoding is performed using a multi-level table lookup. + The fastest way to decode is to simply build a lookup table whose + size is determined by the longest code. However, the time it takes + to build this table can also be a factor if the data being decoded + is not very long. The most common codes are necessarily the + shortest codes, so those codes dominate the decoding time, and hence + the speed. The idea is you can have a shorter table that decodes the + shorter, more probable codes, and then point to subsidiary tables for + the longer codes. The time it costs to decode the longer codes is + then traded against the time it takes to make longer tables. + + This results of this trade are in the variables lbits and dbits + below. lbits is the number of bits the first level table for literal/ + length codes can decode in one step, and dbits is the same thing for + the distance codes. Subsequent tables are also less than or equal to + those sizes. These values may be adjusted either when all of the + codes are shorter than that, in which case the longest code length in + bits is used, or when the shortest code is *longer* than the requested + table size, in which case the length of the shortest code in bits is + used. + + There are two different values for the two tables, since they code a + different number of possibilities each. The literal/length table + codes 286 possible values, or in a flat code, a little over eight + bits. The distance table codes 30 possible values, or a little less + than five bits, flat. The optimum values for speed end up being + about one bit more than those, so lbits is 8+1 and dbits is 5+1. + The optimum values may differ though from machine to machine, and + possibly even between compilers. Your mileage may vary. + */ + + +/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ +#define BMAX 15 /* maximum bit length of any code */ + +local int huft_build( +uIntf *b, /* code lengths in bits (all assumed <= BMAX) */ +uInt n, /* number of codes (assumed <= 288) */ +uInt s, /* number of simple-valued codes (0..s-1) */ +const uIntf *d, /* list of base values for non-simple codes */ +const uIntf *e, /* list of extra bits for non-simple codes */ +inflate_huft * FAR *t, /* result: starting table */ +uIntf *m, /* maximum lookup bits, returns actual */ +inflate_huft *hp, /* space for trees */ +uInt *hn, /* hufts used in space */ +uIntf *v) /* working area: values in order of bit length */ +/* Given a list of code lengths and a maximum table size, make a set of + tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR + if the given code set is incomplete (the tables are still built in this + case), or Z_DATA_ERROR if the input is invalid. */ +{ + + uInt a; /* counter for codes of length k */ + uInt c[BMAX+1]; /* bit length count table */ + uInt f; /* i repeats in table every f entries */ + int g; /* maximum code length */ + int h; /* table level */ + register uInt i; /* counter, current code */ + register uInt j; /* counter */ + register int k; /* number of bits in current code */ + int l; /* bits per table (returned in m) */ + uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */ + register uIntf *p; /* pointer into c[], b[], or v[] */ + inflate_huft *q; /* points to current table */ + struct inflate_huft_s r; /* table entry for structure assignment */ + inflate_huft *u[BMAX]; /* table stack */ + register int w; /* bits before this table == (l * h) */ + uInt x[BMAX+1]; /* bit offsets, then code stack */ + uIntf *xp; /* pointer into x */ + int y; /* number of dummy codes added */ + uInt z; /* number of entries in current table */ + + + /* Generate counts for each bit length */ + p = c; +#define C0 *p++ = 0; +#define C2 C0 C0 C0 C0 +#define C4 C2 C2 C2 C2 + C4 /* clear c[]--assume BMAX+1 is 16 */ + p = b; i = n; + do { + c[*p++]++; /* assume all entries <= BMAX */ + } while (--i); + if (c[0] == n) /* null input--all zero length codes */ + { + *t = (inflate_huft *)Z_NULL; + *m = 0; + return Z_OK; + } + + + /* Find minimum and maximum length, bound *m by those */ + l = *m; + for (j = 1; j <= BMAX; j++) + if (c[j]) + break; + k = j; /* minimum code length */ + if ((uInt)l < j) + l = j; + for (i = BMAX; i; i--) + if (c[i]) + break; + g = i; /* maximum code length */ + if ((uInt)l > i) + l = i; + *m = l; + + + /* Adjust last length count to fill out codes, if needed */ + for (y = 1 << j; j < i; j++, y <<= 1) + if ((y -= c[j]) < 0) + return Z_DATA_ERROR; + if ((y -= c[i]) < 0) + return Z_DATA_ERROR; + c[i] += y; + + + /* Generate starting offsets into the value table for each length */ + x[1] = j = 0; + p = c + 1; xp = x + 2; + while (--i) { /* note that i == g from above */ + *xp++ = (j += *p++); + } + + + /* Make a table of values in order of bit lengths */ + p = b; i = 0; + do { + if ((j = *p++) != 0) + v[x[j]++] = i; + } while (++i < n); + n = x[g]; /* set n to length of v */ + + + /* Generate the Huffman codes and for each, make the table entries */ + x[0] = i = 0; /* first Huffman code is zero */ + p = v; /* grab values in bit order */ + h = -1; /* no tables yet--level -1 */ + w = -l; /* bits decoded == (l * h) */ + u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ + q = (inflate_huft *)Z_NULL; /* ditto */ + z = 0; /* ditto */ + + /* go through the bit lengths (k already is bits in shortest code) */ + for (; k <= g; k++) + { + a = c[k]; + while (a--) + { + /* here i is the Huffman code of length k bits for value *p */ + /* make tables up to required level */ + while (k > w + l) + { + h++; + w += l; /* previous table always l bits */ + + /* compute minimum size table less than or equal to l bits */ + z = g - w; + z = z > (uInt)l ? l : z; /* table size upper limit */ + if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ + { /* too few codes for k-w bit table */ + f -= a + 1; /* deduct codes from patterns left */ + xp = c + k; + if (j < z) + while (++j < z) /* try smaller tables up to z bits */ + { + if ((f <<= 1) <= *++xp) + break; /* enough codes to use up j bits */ + f -= *xp; /* else deduct codes from patterns */ + } + } + z = 1 << j; /* table entries for j-bit table */ + + /* allocate new table */ + if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ + return Z_DATA_ERROR; /* overflow of MANY */ + u[h] = q = hp + *hn; + *hn += z; + + /* connect to last table, if there is one */ + if (h) + { + x[h] = i; /* save pattern for backing up */ + r.bits = (Byte)l; /* bits to dump before this table */ + r.exop = (Byte)j; /* bits in this table */ + j = i >> (w - l); + r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ + u[h-1][j] = r; /* connect to last table */ + } + else + *t = q; /* first table is returned result */ + } + + /* set up table entry in r */ + r.bits = (Byte)(k - w); + if (p >= v + n) + r.exop = 128 + 64; /* out of values--invalid code */ + else if (*p < s) + { + r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ + r.base = *p++; /* simple code is just the value */ + } + else + { + r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ + r.base = d[*p++ - s]; + } + + /* fill code-like entries with r */ + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) + q[j] = r; + + /* backwards increment the k-bit code i */ + for (j = 1 << (k - 1); i & j; j >>= 1) + i ^= j; + i ^= j; + + /* backup over finished tables */ + mask = (1 << w) - 1; /* needed on HP, cc -O bug */ + while ((i & mask) != x[h]) + { + h--; /* don't need to update q */ + w -= l; + mask = (1 << w) - 1; + } + } + } + + + /* Return Z_BUF_ERROR if we were given an incomplete table */ + return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; +} + + +int inflate_trees_bits( +uIntf *c, /* 19 code lengths */ +uIntf *bb, /* bits tree desired/actual depth */ +inflate_huft * FAR *tb, /* bits tree result */ +inflate_huft *hp, /* space for trees */ +z_streamp z) /* for messages */ +{ + int r; + uInt hn = 0; /* hufts used in space */ + uIntf *v; /* work area for huft_build */ + + if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, + tb, bb, hp, &hn, v); + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed dynamic bit lengths tree"; + else if (r == Z_BUF_ERROR || *bb == 0) + { + z->msg = (char*)"incomplete dynamic bit lengths tree"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; +} + + +int inflate_trees_dynamic( +uInt nl, /* number of literal/length codes */ +uInt nd, /* number of distance codes */ +uIntf *c, /* that many (total) code lengths */ +uIntf *bl, /* literal desired/actual bit depth */ +uIntf *bd, /* distance desired/actual bit depth */ +inflate_huft * FAR *tl, /* literal/length tree result */ +inflate_huft * FAR *td, /* distance tree result */ +inflate_huft *hp, /* space for trees */ +z_streamp z) /* for messages */ +{ + int r; + uInt hn = 0; /* hufts used in space */ + uIntf *v; /* work area for huft_build */ + + /* allocate work area */ + if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + + /* build literal/length tree */ + r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v); + if (r != Z_OK || *bl == 0) + { + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed literal/length tree"; + else if (r != Z_MEM_ERROR) + { + z->msg = (char*)"incomplete literal/length tree"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; + } + + /* build distance tree */ + r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v); + if (r != Z_OK || (*bd == 0 && nl > 257)) + { + if (r == Z_DATA_ERROR) + z->msg = (char*)"oversubscribed distance tree"; + else if (r == Z_BUF_ERROR) { +#ifdef PKZIP_BUG_WORKAROUND + r = Z_OK; + } +#else + z->msg = (char*)"incomplete distance tree"; + r = Z_DATA_ERROR; + } + else if (r != Z_MEM_ERROR) + { + z->msg = (char*)"empty distance tree with lengths"; + r = Z_DATA_ERROR; + } + ZFREE(z, v); + return r; +#endif + } + + /* done */ + ZFREE(z, v); + return Z_OK; +} + + +/* build fixed tables only once--keep them here */ +#ifdef BUILDFIXED +local int fixed_built = 0; +#define FIXEDH 544 /* number of hufts used by fixed tables */ +local inflate_huft fixed_mem[FIXEDH]; +local uInt fixed_bl; +local uInt fixed_bd; +local inflate_huft *fixed_tl; +local inflate_huft *fixed_td; +#else +#include "inffixed.h" +#endif + + +int inflate_trees_fixed( +uIntf *bl, /* literal desired/actual bit depth */ +uIntf *bd, /* distance desired/actual bit depth */ +inflate_huft * FAR *tl, /* literal/length tree result */ +inflate_huft * FAR *td, /* distance tree result */ +z_streamp z) /* for memory allocation */ +{ +#ifdef BUILDFIXED + /* build fixed tables if not already */ + if (!fixed_built) + { + int k; /* temporary variable */ + uInt f = 0; /* number of hufts used in fixed_mem */ + uIntf *c; /* length list for huft_build */ + uIntf *v; /* work area for huft_build */ + + /* allocate memory */ + if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + return Z_MEM_ERROR; + if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) + { + ZFREE(z, c); + return Z_MEM_ERROR; + } + + /* literal table */ + for (k = 0; k < 144; k++) + c[k] = 8; + for (; k < 256; k++) + c[k] = 9; + for (; k < 280; k++) + c[k] = 7; + for (; k < 288; k++) + c[k] = 8; + fixed_bl = 9; + huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, + fixed_mem, &f, v); + + /* distance table */ + for (k = 0; k < 30; k++) + c[k] = 5; + fixed_bd = 5; + huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, + fixed_mem, &f, v); + + /* done */ + ZFREE(z, v); + ZFREE(z, c); + fixed_built = 1; + } +#endif + *bl = fixed_bl; + *bd = fixed_bd; + *tl = fixed_tl; + *td = fixed_td; + return Z_OK; +} diff --git a/src/libs/pdflib/libs/flate/inftrees.h b/src/libs/pdflib/libs/flate/inftrees.h new file mode 100644 index 0000000000..316f08dddf --- /dev/null +++ b/src/libs/pdflib/libs/flate/inftrees.h @@ -0,0 +1,61 @@ +/* inftrees.h -- header to use inftrees.c + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* Huffman code lookup table entry--this entry is four bytes for machines + that have 16-bit pointers (e.g. PC's in the small or medium model). */ + + +/* $Id: inftrees.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +typedef struct inflate_huft_s FAR inflate_huft; + +struct inflate_huft_s { + union { + struct { + Byte Exop; /* number of extra bits or operation */ + Byte Bits; /* number of bits in this code or subcode */ + } what; + uInt pad; /* pad structure to a power of 2 (4 bytes for */ + } word; /* 16-bit, 8 bytes for 32-bit int's) */ + uInt base; /* literal, length base, distance base, + or table offset */ +}; + +/* Maximum size of dynamic tree. The maximum found in a long but non- + exhaustive search was 1004 huft structures (850 for length/literals + and 154 for distances, the latter actually the result of an + exhaustive search). The actual maximum is not known, but the + value below is more than safe. */ +#define MANY 1440 + +extern int inflate_trees_bits OF(( + uIntf *, /* 19 code lengths */ + uIntf *, /* bits tree desired/actual depth */ + inflate_huft * FAR *, /* bits tree result */ + inflate_huft *, /* space for trees */ + z_streamp)); /* for messages */ + +extern int inflate_trees_dynamic OF(( + uInt, /* number of literal/length codes */ + uInt, /* number of distance codes */ + uIntf *, /* that many (total) code lengths */ + uIntf *, /* literal desired/actual bit depth */ + uIntf *, /* distance desired/actual bit depth */ + inflate_huft * FAR *, /* literal/length tree result */ + inflate_huft * FAR *, /* distance tree result */ + inflate_huft *, /* space for trees */ + z_streamp)); /* for messages */ + +extern int inflate_trees_fixed OF(( + uIntf *, /* literal desired/actual bit depth */ + uIntf *, /* distance desired/actual bit depth */ + inflate_huft * FAR *, /* literal/length tree result */ + inflate_huft * FAR *, /* distance tree result */ + z_streamp)); /* for memory allocation */ diff --git a/src/libs/pdflib/libs/flate/infutil.c b/src/libs/pdflib/libs/flate/infutil.c new file mode 100644 index 0000000000..13ffa035e4 --- /dev/null +++ b/src/libs/pdflib/libs/flate/infutil.c @@ -0,0 +1,89 @@ +/* inflate_util.c -- data and routines common to blocks and codes + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ +/* $Id: infutil.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zutil.h" +#include "infblock.h" +#include "inftrees.h" +#include "infcodes.h" +#include "infutil.h" + +/* PDFlib GmbH: conflicts with Visual Studio.NET +struct inflate_codes_state {int dummy;}; *//* for buggy compilers */ + +/* And'ing with mask[n] masks the lower n bits */ +uInt inflate_mask[17] = { + 0x0000, + 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff +}; + + +/* copy as much as possible from the sliding window to the output area */ +int inflate_flush( +inflate_blocks_statef *s, +z_streamp z, +int r) +{ + uInt n; + Bytef *p; + Bytef *q; + + /* local copies of source and destination pointers */ + p = z->next_out; + q = s->read; + + /* compute number of bytes to copy as far as end of window */ + n = (uInt)((q <= s->write ? s->write : s->end) - q); + if (n > z->avail_out) n = z->avail_out; + if (n && r == Z_BUF_ERROR) r = Z_OK; + + /* update counters */ + z->avail_out -= n; + z->total_out += n; + + /* update check information */ + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(s->check, q, n); + + /* copy as far as end of window */ + zmemcpy(p, q, n); + p += n; + q += n; + + /* see if more to copy at beginning of window */ + if (q == s->end) + { + /* wrap pointers */ + q = s->window; + if (s->write == s->end) + s->write = s->window; + + /* compute bytes to copy */ + n = (uInt)(s->write - q); + if (n > z->avail_out) n = z->avail_out; + if (n && r == Z_BUF_ERROR) r = Z_OK; + + /* update counters */ + z->avail_out -= n; + z->total_out += n; + + /* update check information */ + if (s->checkfn != Z_NULL) + z->adler = s->check = (*s->checkfn)(s->check, q, n); + + /* copy */ + zmemcpy(p, q, n); + p += n; + q += n; + } + + /* update pointers */ + z->next_out = p; + s->read = q; + + /* done */ + return r; +} diff --git a/src/libs/pdflib/libs/flate/infutil.h b/src/libs/pdflib/libs/flate/infutil.h new file mode 100644 index 0000000000..d8626b5e59 --- /dev/null +++ b/src/libs/pdflib/libs/flate/infutil.h @@ -0,0 +1,102 @@ +/* infutil.h -- types and macros common to blocks and codes + * Copyright (C) 1995-2002 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + +/* $Id: infutil.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#ifndef _INFUTIL_H +#define _INFUTIL_H + +typedef enum { + TYPE, /* get type bits (3, including end bit) */ + LENS, /* get lengths for stored */ + STORED, /* processing stored block */ + TABLE, /* get table lengths */ + BTREE, /* get bit lengths tree for a dynamic block */ + DTREE, /* get length, distance trees for a dynamic block */ + CODES, /* processing fixed or dynamic block */ + DRY, /* output remaining window bytes */ + DONE, /* finished last block, done */ + BAD} /* got a data error--stuck here */ +inflate_block_mode; + +/* inflate blocks semi-private state */ +struct inflate_blocks_state { + + /* mode */ + inflate_block_mode mode; /* current inflate_block mode */ + + /* mode dependent information */ + union { + uInt left; /* if STORED, bytes left to copy */ + struct { + uInt table; /* table lengths (14 bits) */ + uInt index; /* index into blens (or border) */ + uIntf *blens; /* bit lengths of codes */ + uInt bb; /* bit length tree depth */ + inflate_huft *tb; /* bit length decoding tree */ + } trees; /* if DTREE, decoding info for trees */ + struct { + inflate_codes_statef + *codes; + } decode; /* if CODES, current state */ + } sub; /* submode */ + uInt last; /* true if this block is the last block */ + + /* mode independent information */ + uInt bitk; /* bits in bit buffer */ + uLong bitb; /* bit buffer */ + inflate_huft *hufts; /* single malloc for tree space */ + Bytef *window; /* sliding window */ + Bytef *end; /* one byte after sliding window */ + Bytef *read; /* window read pointer */ + Bytef *write; /* window write pointer */ + check_func checkfn; /* check function */ + uLong check; /* check on output */ + +}; + + +/* defines for inflate input/output */ +/* update pointers and return */ +#define UPDBITS {s->bitb=b;s->bitk=k;} +#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} +#define UPDOUT {s->write=q;} +#define UPDATE {UPDBITS UPDIN UPDOUT} +#define LEAVE {UPDATE return inflate_flush(s,z,r);} +/* get bytes and bits */ +#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} +#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} +#define NEXTBYTE (n--,*p++) +#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<>=(j);k-=(j);} +/* output bytes */ +#define WAVAIL (uInt)(qread?s->read-q-1:s->end-q) +#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} +#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} +#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} +#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} +#define OUTBYTE(a) {*q++=(Byte)(a);m--;} +/* load local pointers */ +#define LOAD {LOADIN LOADOUT} + +/* masks for lower bits (size given to avoid silly warnings with Visual C++) */ +extern uInt inflate_mask[17]; + +/* copy as much as possible from the sliding window to the output area */ +extern int inflate_flush OF(( + inflate_blocks_statef *, + z_streamp , + int)); + +/* PDFlib GmbH: conflicts with Visual Studio.NET +struct internal_state {int dummy;}; *//* for buggy compilers */ + +#endif diff --git a/src/libs/pdflib/libs/flate/trees.c b/src/libs/pdflib/libs/flate/trees.c new file mode 100644 index 0000000000..1a6ec45449 --- /dev/null +++ b/src/libs/pdflib/libs/flate/trees.c @@ -0,0 +1,1216 @@ +/* trees.c -- output deflated data using Huffman coding + * Copyright (C) 1995-2002 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * ALGORITHM + * + * The "deflation" process uses several Huffman trees. The more + * common source values are represented by shorter bit sequences. + * + * Each code tree is stored in a compressed form which is itself + * a Huffman encoding of the lengths of all the code strings (in + * ascending order by source values). The actual code strings are + * reconstructed from the lengths in the inflate process, as described + * in the deflate specification. + * + * REFERENCES + * + * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". + * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc + * + * Storer, James A. + * Data Compression: Methods and Theory, pp. 49-50. + * Computer Science Press, 1988. ISBN 0-7167-8156-5. + * + * Sedgewick, R. + * Algorithms, p290. + * Addison-Wesley, 1983. ISBN 0-201-06672-6. + */ + +/* $Id: trees.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ +/* @(#) $Id: trees.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +/* #define GEN_TREES_H */ + +#include "deflate.h" + +#ifdef DEBUG +# include +#endif + +/* =========================================================================== + * Constants + */ + +#define MAX_BL_BITS 7 +/* Bit length codes must not exceed MAX_BL_BITS bits */ + +#define END_BLOCK 256 +/* end of block literal code */ + +#define REP_3_6 16 +/* repeat previous bit length 3-6 times (2 bits of repeat count) */ + +#define REPZ_3_10 17 +/* repeat a zero length 3-10 times (3 bits of repeat count) */ + +#define REPZ_11_138 18 +/* repeat a zero length 11-138 times (7 bits of repeat count) */ + +local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ + = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; + +local const int extra_dbits[D_CODES] /* extra bits for each distance code */ + = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ + = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; + +local const uch bl_order[BL_CODES] + = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; +/* The lengths of the bit length codes are sent in order of decreasing + * probability, to avoid transmitting the lengths for unused bit length codes. + */ + +#define Buf_size (8 * 2*sizeof(char)) +/* Number of bits used within bi_buf. (bi_buf might be implemented on + * more than 16 bits on some systems.) + */ + +/* =========================================================================== + * Local data. These are initialized only once. + */ + +#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ + +#if defined(GEN_TREES_H) || !defined(STDC) +/* non ANSI compilers may not accept trees.h */ + +local ct_data static_ltree[L_CODES+2]; +/* The static literal tree. Since the bit lengths are imposed, there is no + * need for the L_CODES extra codes used during heap construction. However + * The codes 286 and 287 are needed to build a canonical tree (see _tr_init + * below). + */ + +local ct_data static_dtree[D_CODES]; +/* The static distance tree. (Actually a trivial tree since all codes use + * 5 bits.) + */ + +uch _dist_code[DIST_CODE_LEN]; +/* Distance codes. The first 256 values correspond to the distances + * 3 .. 258, the last 256 values correspond to the top 8 bits of + * the 15 bit distances. + */ + +uch _length_code[MAX_MATCH-MIN_MATCH+1]; +/* length code for each normalized match length (0 == MIN_MATCH) */ + +local int base_length[LENGTH_CODES]; +/* First normalized length for each code (0 = MIN_MATCH) */ + +local int base_dist[D_CODES]; +/* First normalized distance for each code (0 = distance of 1) */ + +#else +# include "trees.h" +#endif /* GEN_TREES_H */ + +struct static_tree_desc_s { + const ct_data *static_tree; /* static tree or NULL */ + const intf *extra_bits; /* extra bits for each code or NULL */ + int extra_base; /* base index for extra_bits */ + int elems; /* max number of elements in the tree */ + int max_length; /* max bit length for the codes */ +}; + +local static_tree_desc static_l_desc = +{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; + +local static_tree_desc static_d_desc = +{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; + +local static_tree_desc static_bl_desc = +{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; + +/* =========================================================================== + * Local (static) routines in this file. + */ + +local void tr_static_init OF((void)); +local void init_block OF((deflate_state *s)); +local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); +local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); +local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); +local void build_tree OF((deflate_state *s, tree_desc *desc)); +local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); +local int build_bl_tree OF((deflate_state *s)); +local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, + int blcodes)); +local void compress_block OF((deflate_state *s, ct_data *ltree, + ct_data *dtree)); +local void set_data_type OF((deflate_state *s)); +local unsigned bi_reverse OF((unsigned value, int length)); +local void bi_windup OF((deflate_state *s)); +local void bi_flush OF((deflate_state *s)); +local void copy_block OF((deflate_state *s, charf *buf, unsigned len, + int header)); + +#ifdef GEN_TREES_H +local void gen_trees_header OF((void)); +#endif + +#ifndef DEBUG +# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) + /* Send a code of the given tree. c and tree must not have side effects */ + +#else /* DEBUG */ +# define send_code(s, c, tree) \ + { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ + send_bits(s, tree[c].Code, tree[c].Len); } +#endif + +/* =========================================================================== + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Send a value on a given number of bits. + * IN assertion: length <= 16 and value fits in length bits. + */ +#ifdef DEBUG +local void send_bits OF((deflate_state *s, int value, int length)); + +local void send_bits( + deflate_state *s, + int value, /* value to send */ + int length) /* number of bits */ +{ + Tracevv((stderr," l %2d v %4x ", length, value)); + Assert(length > 0 && length <= 15, "invalid length"); + s->bits_sent += (ulg)length; + + /* If not enough room in bi_buf, use (valid) bits from bi_buf and + * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) + * unused bits in value. + */ + if (s->bi_valid > (int)Buf_size - length) { + s->bi_buf |= (value << s->bi_valid); + put_short(s, s->bi_buf); + s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); + s->bi_valid += length - Buf_size; + } else { + s->bi_buf |= value << s->bi_valid; + s->bi_valid += length; + } +} +#else /* !DEBUG */ + +#define send_bits(s, value, length) \ +{ int len = length;\ + if (s->bi_valid > (int)Buf_size - len) {\ + int val = value;\ + s->bi_buf |= (val << s->bi_valid);\ + put_short(s, s->bi_buf);\ + s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ + s->bi_valid += len - Buf_size;\ + } else {\ + s->bi_buf |= (value) << s->bi_valid;\ + s->bi_valid += len;\ + }\ +} +#endif /* DEBUG */ + + +#define MAX(a,b) (a >= b ? a : b) +/* the arguments must not have side effects */ + +/* =========================================================================== + * Initialize the various 'constant' tables. + */ +local void tr_static_init() +{ +#if defined(GEN_TREES_H) || !defined(STDC) + static int static_init_done = 0; + int n; /* iterates over tree elements */ + int bits; /* bit counter */ + int length; /* length value */ + int code; /* code value */ + int dist; /* distance index */ + ush bl_count[MAX_BITS+1]; + /* number of codes at each bit length for an optimal tree */ + + if (static_init_done) return; + + /* For some embedded targets, global variables are not initialized: */ + static_l_desc.static_tree = static_ltree; + static_l_desc.extra_bits = extra_lbits; + static_d_desc.static_tree = static_dtree; + static_d_desc.extra_bits = extra_dbits; + static_bl_desc.extra_bits = extra_blbits; + + /* Initialize the mapping length (0..255) -> length code (0..28) */ + length = 0; + for (code = 0; code < LENGTH_CODES-1; code++) { + base_length[code] = length; + for (n = 0; n < (1< dist code (0..29) */ + dist = 0; + for (code = 0 ; code < 16; code++) { + base_dist[code] = dist; + for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ + for ( ; code < D_CODES; code++) { + base_dist[code] = dist << 7; + for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { + _dist_code[256 + dist++] = (uch)code; + } + } + Assert (dist == 256, "tr_static_init: 256+dist != 512"); + + /* Construct the codes of the static literal tree */ + for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; + n = 0; + while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; + while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; + while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; + while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; + /* Codes 286 and 287 do not exist, but we must include them in the + * tree construction to get a canonical Huffman tree (longest code + * all ones) + */ + gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); + + /* The static distance tree is trivial: */ + for (n = 0; n < D_CODES; n++) { + static_dtree[n].Len = 5; + static_dtree[n].Code = bi_reverse((unsigned)n, 5); + } + static_init_done = 1; + +# ifdef GEN_TREES_H + gen_trees_header(); +# endif +#endif /* defined(GEN_TREES_H) || !defined(STDC) */ +} + +/* =========================================================================== + * Genererate the file trees.h describing the static trees. + */ +#ifdef GEN_TREES_H +# ifndef DEBUG +# include +# endif + +# define SEPARATOR(i, last, width) \ + ((i) == (last)? "\n};\n\n" : \ + ((i) % (width) == (width)-1 ? ",\n" : ", ")) + +void gen_trees_header() +{ + FILE *header = fopen("trees.h", "w"); + int i; + + Assert (header != NULL, "Can't open trees.h"); + fprintf(header, + "/* header created automatically with -DGEN_TREES_H */\n\n"); + + fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + for (i = 0; i < L_CODES+2; i++) { + fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, + static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); + } + + fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, + static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); + } + + fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); + for (i = 0; i < DIST_CODE_LEN; i++) { + fprintf(header, "%2u%s", _dist_code[i], + SEPARATOR(i, DIST_CODE_LEN-1, 20)); + } + + fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); + for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { + fprintf(header, "%2u%s", _length_code[i], + SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); + } + + fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); + for (i = 0; i < LENGTH_CODES; i++) { + fprintf(header, "%1u%s", base_length[i], + SEPARATOR(i, LENGTH_CODES-1, 20)); + } + + fprintf(header, "local const int base_dist[D_CODES] = {\n"); + for (i = 0; i < D_CODES; i++) { + fprintf(header, "%5u%s", base_dist[i], + SEPARATOR(i, D_CODES-1, 10)); + } + + fclose(header); +} +#endif /* GEN_TREES_H */ + +/* =========================================================================== + * Initialize the tree data structures for a new zlib stream. + */ +void _tr_init( + deflate_state *s) +{ + tr_static_init(); + + s->l_desc.dyn_tree = s->dyn_ltree; + s->l_desc.stat_desc = &static_l_desc; + + s->d_desc.dyn_tree = s->dyn_dtree; + s->d_desc.stat_desc = &static_d_desc; + + s->bl_desc.dyn_tree = s->bl_tree; + s->bl_desc.stat_desc = &static_bl_desc; + + s->bi_buf = 0; + s->bi_valid = 0; + s->last_eob_len = 8; /* enough lookahead for inflate */ +#ifdef DEBUG + s->compressed_len = 0L; + s->bits_sent = 0L; +#endif + + /* Initialize the first block of the first file: */ + init_block(s); +} + +/* =========================================================================== + * Initialize a new block. + */ +local void init_block( + deflate_state *s) +{ + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->last_lit = s->matches = 0; +} + +#define SMALLEST 1 +/* Index within the heap array of least frequent node in the Huffman tree */ + + +/* =========================================================================== + * Remove the smallest element from the heap and recreate the heap with + * one less element. Updates heap and heap_len. + */ +#define pqremove(s, tree, top) \ +{\ + top = s->heap[SMALLEST]; \ + s->heap[SMALLEST] = s->heap[s->heap_len--]; \ + pqdownheap(s, tree, SMALLEST); \ +} + +/* =========================================================================== + * Compares to subtrees, using the tree depth as tie breaker when + * the subtrees have equal frequency. This minimizes the worst case length. + */ +#define smaller(tree, n, m, depth) \ + (tree[n].Freq < tree[m].Freq || \ + (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) + +/* =========================================================================== + * Restore the heap property by moving down the tree starting at node k, + * exchanging a node with the smallest of its two sons if necessary, stopping + * when the heap property is re-established (each father smaller than its + * two sons). + */ +local void pqdownheap( + deflate_state *s, + ct_data *tree, /* the tree to restore */ + int k) /* node to move down */ +{ + int v = s->heap[k]; + int j = k << 1; /* left son of k */ + while (j <= s->heap_len) { + /* Set j to the smallest of the two sons: */ + if (j < s->heap_len && + smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { + j++; + } + /* Exit if v is smaller than both sons */ + if (smaller(tree, v, s->heap[j], s->depth)) break; + + /* Exchange v with the smallest son */ + s->heap[k] = s->heap[j]; k = j; + + /* And continue down the tree, setting j to the left son of k */ + j <<= 1; + } + s->heap[k] = v; +} + +/* =========================================================================== + * Compute the optimal bit lengths for a tree and update the total bit length + * for the current block. + * IN assertion: the fields freq and dad are set, heap[heap_max] and + * above are the tree nodes sorted by increasing frequency. + * OUT assertions: the field len is set to the optimal bit length, the + * array bl_count contains the frequencies for each bit length. + * The length opt_len is updated; static_len is also updated if stree is + * not null. + */ +local void gen_bitlen( + deflate_state *s, + tree_desc *desc) /* the tree descriptor */ +{ + ct_data *tree = desc->dyn_tree; + int max_code = desc->max_code; + const ct_data *stree = desc->stat_desc->static_tree; + const intf *extra = desc->stat_desc->extra_bits; + int base = desc->stat_desc->extra_base; + int max_length = desc->stat_desc->max_length; + int h; /* heap index */ + int n, m; /* iterate over the tree elements */ + int bits; /* bit length */ + int xbits; /* extra bits */ + ush f; /* frequency */ + int overflow = 0; /* number of elements with bit length too large */ + + for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; + + /* In a first pass, compute the optimal bit lengths (which may + * overflow in the case of the bit length tree). + */ + tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ + + for (h = s->heap_max+1; h < HEAP_SIZE; h++) { + n = s->heap[h]; + bits = tree[tree[n].Dad].Len + 1; + if (bits > max_length) bits = max_length, overflow++; + tree[n].Len = (ush)bits; + /* We overwrite tree[n].Dad which is no longer needed */ + + if (n > max_code) continue; /* not a leaf node */ + + s->bl_count[bits]++; + xbits = 0; + if (n >= base) xbits = extra[n-base]; + f = tree[n].Freq; + s->opt_len += (ulg)f * (bits + xbits); + if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); + } + if (overflow == 0) return; + + Trace((stderr,"\nbit length overflow\n")); + /* This happens for example on obj2 and pic of the Calgary corpus */ + + /* Find the first bit length which could increase: */ + do { + bits = max_length-1; + while (s->bl_count[bits] == 0) bits--; + s->bl_count[bits]--; /* move one leaf down the tree */ + s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ + s->bl_count[max_length]--; + /* The brother of the overflow item also moves one step up, + * but this does not affect bl_count[max_length] + */ + overflow -= 2; + } while (overflow > 0); + + /* Now recompute all bit lengths, scanning in increasing frequency. + * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all + * lengths instead of fixing only the wrong ones. This idea is taken + * from 'ar' written by Haruhiko Okumura.) + */ + for (bits = max_length; bits != 0; bits--) { + n = s->bl_count[bits]; + while (n != 0) { + m = s->heap[--h]; + if (m > max_code) continue; + if (tree[m].Len != (unsigned) bits) { + Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); + s->opt_len += ((long)bits - (long)tree[m].Len) + *(long)tree[m].Freq; + tree[m].Len = (ush)bits; + } + n--; + } + } +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes ( + ct_data *tree, /* the tree to decorate */ + int max_code, /* largest code with non zero frequency */ + ushf *bl_count) /* number of codes at each bit length */ +{ + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + ush code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = (code + bl_count[bits-1]) << 1; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; + const ct_data *stree = desc->stat_desc->static_tree; + int elems = desc->stat_desc->elems; + int n, m; /* iterate over heap elements */ + int max_code = -1; /* largest code with non zero frequency */ + int node; /* new node being created */ + + /* Construct the initial heap, with least frequent element in + * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. + * heap[0] is not used. + */ + s->heap_len = 0, s->heap_max = HEAP_SIZE; + + for (n = 0; n < elems; n++) { + if (tree[n].Freq != 0) { + s->heap[++(s->heap_len)] = max_code = n; + s->depth[n] = 0; + } else { + tree[n].Len = 0; + } + } + + /* The pkzip format requires that at least one distance code exists, + * and that at least one bit should be sent even if there is only one + * possible code. So to avoid special checks later on we force at least + * two codes of non zero frequency. + */ + while (s->heap_len < 2) { + node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); + tree[node].Freq = 1; + s->depth[node] = 0; + s->opt_len--; if (stree) s->static_len -= stree[node].Len; + /* node is 0 or 1 so it does not have extra bits */ + } + desc->max_code = max_code; + + /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, + * establish sub-heaps of increasing lengths: + */ + for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); + + /* Construct the Huffman tree by repeatedly combining the least two + * frequent nodes. + */ + node = elems; /* next internal node of the tree */ + do { + pqremove(s, tree, n); /* n = node of least frequency */ + m = s->heap[SMALLEST]; /* m = node of next least frequency */ + + s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ + s->heap[--(s->heap_max)] = m; + + /* Create a new node father of n and m */ + tree[node].Freq = tree[n].Freq + tree[m].Freq; + s->depth[node] = (uch) (MAX(s->depth[n], s->depth[m]) + 1); + tree[n].Dad = tree[m].Dad = (ush)node; +#ifdef DUMP_BL_TREE + if (tree == s->bl_tree) { + fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", + node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); + } +#endif + /* and insert the new node in the heap */ + s->heap[SMALLEST] = node++; + pqdownheap(s, tree, SMALLEST); + + } while (s->heap_len >= 2); + + s->heap[--(s->heap_max)] = s->heap[SMALLEST]; + + /* At this point, the fields freq and dad are set. We can now + * generate the bit lengths. + */ + gen_bitlen(s, (tree_desc *)desc); + + /* The field len is now set, we can generate the bit codes */ + gen_codes ((ct_data *)tree, max_code, s->bl_count); +} + +/* =========================================================================== + * Scan a literal or distance tree to determine the frequencies of the codes + * in the bit length tree. + */ +local void scan_tree ( + deflate_state *s, + ct_data *tree, /* the tree to be scanned */ + int max_code) /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + if (nextlen == 0) max_count = 138, min_count = 3; + tree[max_code+1].Len = (ush)0xffff; /* guard */ + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + s->bl_tree[curlen].Freq += count; + } else if (curlen != 0) { + if (curlen != prevlen) s->bl_tree[curlen].Freq++; + s->bl_tree[REP_3_6].Freq++; + } else if (count <= 10) { + s->bl_tree[REPZ_3_10].Freq++; + } else { + s->bl_tree[REPZ_11_138].Freq++; + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Send a literal or distance tree in compressed form, using the codes in + * bl_tree. + */ +local void send_tree ( + deflate_state *s, + ct_data *tree, /* the tree to be scanned */ + int max_code) /* and its largest code of non zero frequency */ +{ + int n; /* iterates over all tree elements */ + int prevlen = -1; /* last emitted length */ + int curlen; /* length of current code */ + int nextlen = tree[0].Len; /* length of next code */ + int count = 0; /* repeat count of the current code */ + int max_count = 7; /* max repeat count */ + int min_count = 4; /* min repeat count */ + + /* tree[max_code+1].Len = -1; */ /* guard already set */ + if (nextlen == 0) max_count = 138, min_count = 3; + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; nextlen = tree[n+1].Len; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { send_code(s, curlen, s->bl_tree); } while (--count != 0); + + } else if (curlen != 0) { + if (curlen != prevlen) { + send_code(s, curlen, s->bl_tree); count--; + } + Assert(count >= 3 && count <= 6, " 3_6?"); + send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); + + } else if (count <= 10) { + send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); + + } else { + send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); + } + count = 0; prevlen = curlen; + if (nextlen == 0) { + max_count = 138, min_count = 3; + } else if (curlen == nextlen) { + max_count = 6, min_count = 3; + } else { + max_count = 7, min_count = 4; + } + } +} + +/* =========================================================================== + * Construct the Huffman tree for the bit lengths and return the index in + * bl_order of the last bit length code to send. + */ +local int build_bl_tree( + deflate_state *s) +{ + int max_blindex; /* index of last bit length code of non zero freq */ + + /* Determine the bit length frequencies for literal and distance trees */ + scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); + scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); + + /* Build the bit length tree: */ + build_tree(s, (tree_desc *)(&(s->bl_desc))); + /* opt_len now includes the length of the tree representations, except + * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. + */ + + /* Determine the number of bit length codes to send. The pkzip format + * requires that at least 4 bit length codes be sent. (appnote.txt says + * 3 but the actual value used is 4.) + */ + for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { + if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; + } + /* Update opt_len to include the bit length tree and counts */ + s->opt_len += 3*(max_blindex+1) + 5+5+4; + Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", + s->opt_len, s->static_len)); + + return max_blindex; +} + +/* =========================================================================== + * Send the header for a block using dynamic Huffman trees: the counts, the + * lengths of the bit length codes, the literal tree and the distance tree. + * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + */ +local void send_all_trees( + deflate_state *s, + int lcodes, int dcodes, int blcodes) /* number of codes for each tree */ +{ + int rank; /* index in bl_order */ + + Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); + Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, + "too many codes"); + Tracev((stderr, "\nbl counts: ")); + send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ + send_bits(s, dcodes-1, 5); + send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ + for (rank = 0; rank < blcodes; rank++) { + Tracev((stderr, "\nbl code %2d ", bl_order[rank])); + send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); + } + Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ + Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); + + send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ + Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); +} + +/* =========================================================================== + * Send a stored block + */ +void _tr_stored_block( + deflate_state *s, + charf *buf, /* input block */ + ulg stored_len, /* length of input block */ + int eof) /* true if this is the last block for a file */ +{ + send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ +#ifdef DEBUG + s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; + s->compressed_len += (stored_len + 4) << 3; +#endif + copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ +} + +/* =========================================================================== + * Send one empty static block to give enough lookahead for inflate. + * This takes 10 bits, of which 7 may remain in the bit buffer. + * The current inflate code requires 9 bits of lookahead. If the + * last two codes for the previous block (real code plus EOB) were coded + * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode + * the last real code. In this case we send two empty static blocks instead + * of one. (There are no problems if the previous block is stored or fixed.) + * To simplify the code, we assume the worst case of last real code encoded + * on one bit only. + */ +void _tr_align( + deflate_state *s) +{ + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ +#endif + bi_flush(s); + /* Of the 10 bits for the empty block, we have already sent + * (10 - bi_valid) bits. The lookahead for the last real code (before + * the EOB of the previous block) was thus at least one plus the length + * of the EOB plus what we have just sent of the empty static block. + */ + if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { + send_bits(s, STATIC_TREES<<1, 3); + send_code(s, END_BLOCK, static_ltree); +#ifdef DEBUG + s->compressed_len += 10L; +#endif + bi_flush(s); + } + s->last_eob_len = 7; +} + +/* =========================================================================== + * Determine the best encoding for the current block: dynamic trees, static + * trees or store, and output the encoded block to the zip file. + */ +void _tr_flush_block( + deflate_state *s, + charf *buf, /* input block, or NULL if too old */ + ulg stored_len, /* length of input block */ + int eof) /* true if this is the last block for a file */ +{ + ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ + int max_blindex = 0; /* index of last bit length code of non zero freq */ + + /* Build the Huffman trees unless a stored block is forced */ + if (s->level > 0) { + + /* Check if the file is ascii or binary */ + if (s->data_type == Z_UNKNOWN) set_data_type(s); + + /* Construct the literal and distance trees */ + build_tree(s, (tree_desc *)(&(s->l_desc))); + Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + + build_tree(s, (tree_desc *)(&(s->d_desc))); + Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, + s->static_len)); + /* At this point, opt_len and static_len are the total bit lengths of + * the compressed block data, excluding the tree representations. + */ + + /* Build the bit length tree for the above two trees, and get the index + * in bl_order of the last bit length code to send. + */ + max_blindex = build_bl_tree(s); + + /*Determine the best encoding. Compute first the block length in bytes*/ + opt_lenb = (s->opt_len+3+7)>>3; + static_lenb = (s->static_len+3+7)>>3; + + Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", + opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, + s->last_lit)); + + if (static_lenb <= opt_lenb) opt_lenb = static_lenb; + + } else { + Assert(buf != (char*)0, "lost buf"); + opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ + } + +#ifdef FORCE_STORED + if (buf != (char*)0) { /* force stored block */ +#else + if (stored_len+4 <= opt_lenb && buf != (char*)0) { + /* 4: two words for the lengths */ +#endif + /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + * Otherwise we can't have processed more than WSIZE input bytes since + * the last block flush, because compression would have been + * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + * transform a block into a stored block. + */ + _tr_stored_block(s, buf, stored_len, eof); + +#ifdef FORCE_STATIC + } else if (static_lenb >= 0) { /* force static trees */ +#else + } else if (static_lenb == opt_lenb) { +#endif + send_bits(s, (STATIC_TREES<<1)+eof, 3); + compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->static_len; +#endif + } else { + send_bits(s, (DYN_TREES<<1)+eof, 3); + send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, + max_blindex+1); + compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); +#ifdef DEBUG + s->compressed_len += 3 + s->opt_len; +#endif + } + Assert (s->compressed_len == s->bits_sent, "bad compressed size"); + /* The above check is made mod 2^32, for files larger than 512 MB + * and uLong implemented on 32 bits. + */ + init_block(s); + + if (eof) { + bi_windup(s); +#ifdef DEBUG + s->compressed_len += 7; /* align on byte boundary */ +#endif + } + Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, + s->compressed_len-7*eof)); +} + +/* =========================================================================== + * Save the match info and tally the frequency counts. Return true if + * the current block must be flushed. + */ +int _tr_tally ( + deflate_state *s, + unsigned dist, /* distance of matched string */ + unsigned lc) /* match length-MIN_MATCH or unmatched char (if dist==0) */ +{ + s->d_buf[s->last_lit] = (ush)dist; + s->l_buf[s->last_lit++] = (uch)lc; + if (dist == 0) { + /* lc is the unmatched char */ + s->dyn_ltree[lc].Freq++; + } else { + s->matches++; + /* Here, lc is the match length - MIN_MATCH */ + dist--; /* dist = match distance - 1 */ + Assert((ush)dist < (ush)MAX_DIST(s) && + (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && + (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); + + s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; + s->dyn_dtree[d_code(dist)].Freq++; + } + +#ifdef TRUNCATE_BLOCK + /* Try to guess if it is profitable to stop the current block here */ + if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { + /* Compute an upper bound for the compressed length */ + ulg out_length = (ulg)s->last_lit*8L; + ulg in_length = (ulg)((long)s->strstart - s->block_start); + int dcode; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += (ulg)s->dyn_dtree[dcode].Freq * + (5L+extra_dbits[dcode]); + } + out_length >>= 3; + Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", + s->last_lit, in_length, out_length, + 100L - out_length*100L/in_length)); + if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; + } +#endif + return (s->last_lit == s->lit_bufsize-1); + /* We avoid equality with lit_bufsize because of wraparound at 64K + * on 16 bit machines and because stored blocks are restricted to + * 64K-1 bytes. + */ +} + +/* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block( + deflate_state *s, + ct_data *ltree, /* literal tree */ + ct_data *dtree) /* distance tree */ +{ + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned lx = 0; /* running index in l_buf */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->last_lit != 0) do { + dist = s->d_buf[lx]; + lc = s->l_buf[lx++]; + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code+LITERALS+1, ltree); /* send the length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ + Assert(s->pending < (int) (s->lit_bufsize + 2*lx), + "pendingBuf overflow"); + + } while (lx < s->last_lit); + + send_code(s, END_BLOCK, ltree); + s->last_eob_len = ltree[END_BLOCK].Len; +} + +/* =========================================================================== + * Set the data type to ASCII or BINARY, using a crude approximation: + * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. + * IN assertion: the fields freq of dyn_ltree are set and the total of all + * frequencies does not exceed 64K (to fit in an int on 16 bit machines). + */ +local void set_data_type( + deflate_state *s) +{ + int n = 0; + unsigned ascii_freq = 0; + unsigned bin_freq = 0; + while (n < 7) bin_freq += s->dyn_ltree[n++].Freq; + while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq; + while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq; + s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII); +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 + */ +local unsigned bi_reverse( + unsigned code, /* the value to invert */ + int len) /* its bit length */ +{ + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} + +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush( + deflate_state *s) +{ + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup( + deflate_state *s) +{ + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef DEBUG + s->bits_sent = (s->bits_sent+7) & ~7; +#endif +} + +/* =========================================================================== + * Copy a stored block, storing first the length and its + * one's complement if requested. + */ +local void copy_block( + deflate_state *s, + charf *buf, /* the input data */ + unsigned len, /* its length */ + int header) /* true if block header must be written */ +{ + bi_windup(s); /* align on byte boundary */ + s->last_eob_len = 8; /* enough lookahead for inflate */ + + if (header) { + put_short(s, (ush)len); + put_short(s, (ush)~len); +#ifdef DEBUG + s->bits_sent += 2*16; +#endif + } +#ifdef DEBUG + s->bits_sent += (ulg)len<<3; +#endif + while (len--) { + put_byte(s, *buf++); + } +} diff --git a/src/libs/pdflib/libs/flate/trees.h b/src/libs/pdflib/libs/flate/trees.h new file mode 100644 index 0000000000..db482d3f64 --- /dev/null +++ b/src/libs/pdflib/libs/flate/trees.h @@ -0,0 +1,131 @@ +/* header created automatically with -DGEN_TREES_H */ + + +/* $Id: trees.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +local const ct_data static_ltree[L_CODES+2] = { +{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, +{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, +{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, +{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, +{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, +{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, +{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, +{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, +{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, +{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, +{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, +{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, +{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, +{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, +{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, +{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, +{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, +{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, +{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, +{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, +{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, +{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, +{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, +{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, +{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, +{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, +{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, +{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, +{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, +{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, +{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, +{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, +{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, +{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, +{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, +{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, +{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, +{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, +{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, +{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, +{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, +{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, +{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, +{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, +{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, +{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, +{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, +{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, +{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, +{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, +{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, +{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, +{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, +{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, +{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, +{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, +{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, +{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} +}; + +local const ct_data static_dtree[D_CODES] = { +{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, +{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, +{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, +{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, +{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, +{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} +}; + +const uch _dist_code[DIST_CODE_LEN] = { + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, + 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, +10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, +11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, +12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, +13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, +14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, +15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, +18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, +28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, +29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 +}; + +const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, +13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, +17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, +19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, +21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, +22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, +23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, +25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, +26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, +27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 +}; + +local const int base_length[LENGTH_CODES] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, +64, 80, 96, 112, 128, 160, 192, 224, 0 +}; + +local const int base_dist[D_CODES] = { + 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, + 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, + 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 +}; + diff --git a/src/libs/pdflib/libs/flate/uncompr.c b/src/libs/pdflib/libs/flate/uncompr.c new file mode 100644 index 0000000000..fbc562999e --- /dev/null +++ b/src/libs/pdflib/libs/flate/uncompr.c @@ -0,0 +1,59 @@ +/* uncompr.c -- decompress a memory buffer + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* $Id: uncompr.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ +/* @(#) $Id: uncompr.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zlib.h" + +/* =========================================================================== + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ +int ZEXPORT uncompress ( + Bytef *dest, + uLongf *destLen, + const Bytef *source, + uLong sourceLen) +{ + z_stream stream; + int err; + + stream.next_in = (Bytef*)source; + stream.avail_in = (uInt)sourceLen; + /* Check for source > 64K on 16-bit machine: */ + if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; + + stream.next_out = dest; + stream.avail_out = (uInt)*destLen; + if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; + + stream.zalloc = (alloc_func)0; + stream.zfree = (free_func)0; + + err = inflateInit(&stream); + if (err != Z_OK) return err; + + err = inflate(&stream, Z_FINISH); + if (err != Z_STREAM_END) { + inflateEnd(&stream); + return err == Z_OK ? Z_BUF_ERROR : err; + } + *destLen = stream.total_out; + + err = inflateEnd(&stream); + return err; +} diff --git a/src/libs/pdflib/libs/flate/zconf.h b/src/libs/pdflib/libs/flate/zconf.h new file mode 100644 index 0000000000..2892a65760 --- /dev/null +++ b/src/libs/pdflib/libs/flate/zconf.h @@ -0,0 +1,389 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + + +/* $Id: zconf.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +/* @(#) $Id: zconf.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +#include "pc_config.h" + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +/* PDFlib GmbH: We use "pdf_z_". +** The original list was incomplete, by the way. +*/ +#define Z_PREFIX +#ifdef Z_PREFIX + +#ifdef PDFLIB_PSP_BUILD +/* redefine names of all functions for integrating into + * psp library, to avoid name clashes if used together with + * pdflib */ +#define PREFIX(x) psp_z_##x +# define adler32 psp_z_adler32 +# define compress psp_z_compress +# define compress2 psp_z_compress2 +# define crc32 psp_z_crc32 +# define get_crc_table psp_z_get_crc_table +# define deflate psp_z_deflate +# define deflateCopy psp_z_deflateCopy +# define deflateEnd psp_z_deflateEnd +# define deflateInit2_ psp_z_deflateInit2_ +# define deflateInit_ psp_z_deflateInit_ +# define deflateParams psp_z_deflateParams +# define deflateReset psp_z_deflateReset +# define deflateSetDictionary psp_z_deflateSetDictionary +# define deflate_copyright psp_z_deflate_copyright +# define inflate_blocks psp_z_inflate_blocks +# define inflate_blocks_free psp_z_inflate_blocks_free +# define inflate_blocks_new psp_z_inflate_blocks_new +# define inflate_blocks_reset psp_z_inflate_blocks_reset +# define inflate_blocks_sync_point psp_z_inflate_blocks_sync_point +# define inflate_set_dictionary psp_z_inflate_set_dictionary +# define inflate_codes psp_z_inflate_codes +# define inflate_codes_free psp_z_inflate_codes_free +# define inflate_codes_new psp_z_inflate_codes_new +# define inflate_fast psp_z_inflate_fast +# define inflate psp_z_inflate +# define inflateEnd psp_z_inflateEnd +# define inflateInit2_ psp_z_inflateInit2_ +# define inflateInit_ psp_z_inflateInit_ +# define inflateReset psp_z_inflateReset +# define inflateSetDictionary psp_z_inflateSetDictionary +# define inflateSync psp_z_inflateSync +# define inflateSyncPoint psp_z_inflateSyncPoint +# define inflate_copyright psp_z_inflate_copyright +# define inflate_trees_bits psp_z_inflate_trees_bits +# define inflate_trees_dynamic psp_z_inflate_trees_dynamic +# define inflate_trees_fixed psp_z_inflate_trees_fixed +# define inflate_flush psp_z_inflate_flush +# define inflate_mask psp_z_inflate_mask +# define _dist_code psp_z__dist_code +# define _length_code psp_z__length_code +# define _tr_align psp_z__tr_align +# define _tr_flush_block psp_z__tr_flush_block +# define _tr_init psp_z__tr_init +# define _tr_stored_block psp_z__tr_stored_block +# define _tr_tally psp_z__tr_tally +# define uncompress psp_z_uncompress +# define zError psp_z_zError +# define z_errmsg psp_z_z_errmsg +# define z_error psp_z_z_error +# define z_verbose psp_z_z_verbose +# define zcalloc psp_z_zcalloc +# define zcfree psp_z_zcfree +# define zlibVersion psp_z_zlibVersion + +#else +#define PREFIX(x) pdf_z_##x +# define adler32 pdf_z_adler32 +# define compress pdf_z_compress +# define compress2 pdf_z_compress2 +# define crc32 pdf_z_crc32 +# define get_crc_table pdf_z_get_crc_table +# define deflate pdf_z_deflate +# define deflateCopy pdf_z_deflateCopy +# define deflateEnd pdf_z_deflateEnd +# define deflateInit2_ pdf_z_deflateInit2_ +# define deflateInit_ pdf_z_deflateInit_ +# define deflateParams pdf_z_deflateParams +# define deflateReset pdf_z_deflateReset +# define deflateSetDictionary pdf_z_deflateSetDictionary +# define deflate_copyright pdf_z_deflate_copyright +# define inflate_blocks pdf_z_inflate_blocks +# define inflate_blocks_free pdf_z_inflate_blocks_free +# define inflate_blocks_new pdf_z_inflate_blocks_new +# define inflate_blocks_reset pdf_z_inflate_blocks_reset +# define inflate_blocks_sync_point pdf_z_inflate_blocks_sync_point +# define inflate_set_dictionary pdf_z_inflate_set_dictionary +# define inflate_codes pdf_z_inflate_codes +# define inflate_codes_free pdf_z_inflate_codes_free +# define inflate_codes_new pdf_z_inflate_codes_new +# define inflate_fast pdf_z_inflate_fast +# define inflate pdf_z_inflate +# define inflateEnd pdf_z_inflateEnd +# define inflateInit2_ pdf_z_inflateInit2_ +# define inflateInit_ pdf_z_inflateInit_ +# define inflateReset pdf_z_inflateReset +# define inflateSetDictionary pdf_z_inflateSetDictionary +# define inflateSync pdf_z_inflateSync +# define inflateSyncPoint pdf_z_inflateSyncPoint +# define inflate_copyright pdf_z_inflate_copyright +# define inflate_trees_bits pdf_z_inflate_trees_bits +# define inflate_trees_dynamic pdf_z_inflate_trees_dynamic +# define inflate_trees_fixed pdf_z_inflate_trees_fixed +# define inflate_flush pdf_z_inflate_flush +# define inflate_mask pdf_z_inflate_mask +# define _dist_code pdf_z__dist_code +# define _length_code pdf_z__length_code +# define _tr_align pdf_z__tr_align +# define _tr_flush_block pdf_z__tr_flush_block +# define _tr_init pdf_z__tr_init +# define _tr_stored_block pdf_z__tr_stored_block +# define _tr_tally pdf_z__tr_tally +# define uncompress pdf_z_uncompress +# define zError pdf_z_zError +# define z_errmsg pdf_z_z_errmsg +# define z_error pdf_z_z_error +# define z_verbose pdf_z_z_verbose +# define zcalloc pdf_z_zcalloc +# define zcfree pdf_z_zcfree +# define zlibVersion pdf_z_zlibVersion + +#endif /* PDFLIB_PSP_BUILD */ + +#undef PREFIX + +/* special handling required on the Mac where Byte is alread defined */ +#if !(defined(MAC) || defined(MACOSX)) +# define Byte z_Byte +#endif + +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* PDFlib GmbH: Windows CE portability */ +#ifdef _WIN32_WCE +#define NO_ERRNO_H +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifndef STDC /* PDFlib GmbH: we require ANSI C anyway */ +#define STDC +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTRVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +/* PDFlib GmbH: also do the typedef on the Mac */ +#if defined(MAC) || defined(MACOSX) +#include +#else +typedef unsigned char Byte; /* 8 bits */ +#endif + +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +/* PDFlib GmbH: Windows portability */ +#if !defined(WIN32) && !defined(OS2) && !defined(MAC) +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif + +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/src/libs/pdflib/libs/flate/zlib.h b/src/libs/pdflib/libs/flate/zlib.h new file mode 100644 index 0000000000..a607fdf258 --- /dev/null +++ b/src/libs/pdflib/libs/flate/zlib.h @@ -0,0 +1,897 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.4, March 11th, 2002 + + Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + + +/* $Id: zlib.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.4" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) +/* PDFlib GmbH: conflicts with Visual Studio.NET + struct internal_state {int dummy;}; *//* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/src/libs/pdflib/libs/flate/zutil.c b/src/libs/pdflib/libs/flate/zutil.c new file mode 100644 index 0000000000..595d6504bb --- /dev/null +++ b/src/libs/pdflib/libs/flate/zutil.c @@ -0,0 +1,227 @@ +/* zutil.c -- target dependent utility functions for the compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* $Id: zutil.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ +/* @(#) $Id: zutil.c,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#include "zutil.h" + +/* PDFlib GmbH: conflicts with Visual Studio.NET +struct internal_state {int dummy;}; *//* for buggy compilers */ + +#ifndef STDC +extern void exit OF((int)); +#endif + +const char *z_errmsg[10] = { +"need dictionary", /* Z_NEED_DICT 2 */ +"stream end", /* Z_STREAM_END 1 */ +"", /* Z_OK 0 */ +"file error", /* Z_ERRNO (-1) */ +"stream error", /* Z_STREAM_ERROR (-2) */ +"data error", /* Z_DATA_ERROR (-3) */ +"insufficient memory", /* Z_MEM_ERROR (-4) */ +"buffer error", /* Z_BUF_ERROR (-5) */ +"incompatible version",/* Z_VERSION_ERROR (-6) */ +""}; + + +const char * ZEXPORT zlibVersion() +{ + return ZLIB_VERSION; +} + +#ifdef DEBUG + +# ifndef verbose +# define verbose 0 +# endif +int z_verbose = verbose; + +void z_error ( + char *m) +{ + fprintf(stderr, "%s\n", m); + exit(1); +} +#endif + +/* exported to allow conversion of error code to string for compress() and + * uncompress() + */ +const char * ZEXPORT zError( + int err) +{ + return ERR_MSG(err); +} + + +#ifndef HAVE_MEMCPY + +void zmemcpy( + Bytef* dest, + const Bytef* source, + uInt len) +{ + if (len == 0) return; + do { + *dest++ = *source++; /* ??? to be unrolled */ + } while (--len != 0); +} + +int zmemcmp( + const Bytef* s1, + const Bytef* s2, + uInt len) +{ + uInt j; + + for (j = 0; j < len; j++) { + if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; + } + return 0; +} + +void zmemzero( + Bytef* dest, + uInt len) +{ + if (len == 0) return; + do { + *dest++ = 0; /* ??? to be unrolled */ + } while (--len != 0); +} +#endif + +#ifdef __TURBOC__ +#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) +/* Small and medium model in Turbo C are for now limited to near allocation + * with reduced MAX_WBITS and MAX_MEM_LEVEL + */ +# define MY_ZCALLOC + +/* Turbo C malloc() does not allow dynamic allocation of 64K bytes + * and farmalloc(64K) returns a pointer with an offset of 8, so we + * must fix the pointer. Warning: the pointer must be put back to its + * original form in order to free it, use zcfree(). + */ + +#define MAX_PTR 10 +/* 10*64K = 640K */ + +local int next_ptr = 0; + +typedef struct ptr_table_s { + voidpf org_ptr; + voidpf new_ptr; +} ptr_table; + +local ptr_table table[MAX_PTR]; +/* This table is used to remember the original form of pointers + * to large buffers (64K). Such pointers are normalized with a zero offset. + * Since MSDOS is not a preemptive multitasking OS, this table is not + * protected from concurrent access. This hack doesn't work anyway on + * a protected system like OS/2. Use Microsoft C instead. + */ + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + voidpf buf = opaque; /* just to make some compilers happy */ + ulg bsize = (ulg)items*size; + + /* If we allocate less than 65520 bytes, we assume that farmalloc + * will return a usable pointer which doesn't have to be normalized. + */ + if (bsize < 65520L) { + buf = farmalloc(bsize); + if (*(ush*)&buf != 0) return buf; + } else { + buf = farmalloc(bsize + 16L); + } + if (buf == NULL || next_ptr >= MAX_PTR) return NULL; + table[next_ptr].org_ptr = buf; + + /* Normalize the pointer to seg:0 */ + *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; + *(ush*)&buf = 0; + table[next_ptr++].new_ptr = buf; + return buf; +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + int n; + if (*(ush*)&ptr != 0) { /* object < 64K */ + farfree(ptr); + return; + } + /* Find the original pointer */ + for (n = 0; n < next_ptr; n++) { + if (ptr != table[n].new_ptr) continue; + + farfree(table[n].org_ptr); + while (++n < next_ptr) { + table[n-1] = table[n]; + } + next_ptr--; + return; + } + ptr = opaque; /* just to make some compilers happy */ + Assert(0, "zcfree: ptr not found"); +} +#endif +#endif /* __TURBOC__ */ + + +#if defined(M_I86) && !defined(__32BIT__) +/* Microsoft C in 16-bit mode */ + +# define MY_ZCALLOC + +#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) +# define _halloc halloc +# define _hfree hfree +#endif + +voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + return _halloc((long)items, size); +} + +void zcfree (voidpf opaque, voidpf ptr) +{ + if (opaque) opaque = 0; /* to make compiler happy */ + _hfree(ptr); +} + +#endif /* MSC */ + + +#ifndef MY_ZCALLOC /* Any system without a special alloc function */ + +#ifndef STDC +extern voidp calloc OF((uInt items, uInt size)); +extern void free OF((voidpf ptr)); +#endif + +voidpf zcalloc ( + voidpf opaque, + unsigned items, + unsigned size) +{ + if (opaque) items += size - size; /* make compiler happy */ + return (voidpf)calloc(items, size); +} + +void zcfree ( + voidpf opaque, + voidpf ptr) +{ + free(ptr); + if (opaque) return; /* make compiler happy */ +} + +#endif /* MY_ZCALLOC */ diff --git a/src/libs/pdflib/libs/flate/zutil.h b/src/libs/pdflib/libs/flate/zutil.h new file mode 100644 index 0000000000..668a4229c6 --- /dev/null +++ b/src/libs/pdflib/libs/flate/zutil.h @@ -0,0 +1,228 @@ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2002 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + + +/* $Id: zutil.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +/* @(#) $Id: zutil.h,v 1.1 2004/10/06 17:46:48 laplace Exp $ */ + +#ifndef _Z_UTIL_H +#define _Z_UTIL_H + +#include "zlib.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else +# include +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#ifdef MSDOS +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +#endif + +#ifdef WIN32 /* Window 95 & Windows NT */ +# define OS_CODE 0x0b +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#if defined(MAC) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0F +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) +# define fdopen(fd,type) _fdopen(fd,type) +#endif + + + /* Common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#ifdef HAVE_STRERROR + extern char *strerror OF((int)); +# define zstrerror(errnum) strerror(errnum) +#else +# define zstrerror(errnum) "" +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int z_verbose; + extern void z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +#else +# define Assert(cond,msg) +#endif + +/* PDFlib GmbH: we don't like trace messages from here. */ +#if 0 +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, + uInt len)); +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); +void zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* _Z_UTIL_H */ diff --git a/src/libs/pdflib/libs/pdcore/Jamfile b/src/libs/pdflib/libs/pdcore/Jamfile new file mode 100644 index 0000000000..fcca5e7f59 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/Jamfile @@ -0,0 +1,26 @@ +SubDir OBOS_TOP src libs pdflib libs pdcore ; + +UseLibraryHeaders pdflib ; + +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs flate ] ; + +StaticLibrary pdf : + pc_arc4.c + pc_core.c + pc_corefont.c + pc_crypt.c + pc_ebcdic.c + pc_encoding.c + pc_file.c + pc_font.c + pc_util.c + pc_unicode.c + pc_scope.c + pc_sbuf.c + pc_output.c + pc_optparse.c + pc_md5.c + pc_geom.c +: STATIC_LIBRARY_DIR +; + diff --git a/src/libs/pdflib/libs/pdcore/Makefile b/src/libs/pdflib/libs/pdcore/Makefile new file mode 100644 index 0000000000..2640b185a1 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/Makefile @@ -0,0 +1,51 @@ +# Makefile for libpdcore +# This generates a libtool convenience library +# $Id: Makefile,v 1.1 2004/10/06 17:51:27 laplace Exp $ + +top_builddir = ../.. + +include ../../config/mkcommon.inc + +LIBNAME = $(PDCORELIBLINK) +INCLUDES = $(PDCORELIBINC) $(PDFLIBINC) $(PDILIBINC) $(FLATELIBINC) + +SRC = \ + $(srcdir)/pc_core.c \ + $(srcdir)/pc_corefont.c \ + $(srcdir)/pc_crypt.c \ + $(srcdir)/pc_ebcdic.c \ + $(srcdir)/pc_encoding.c \ + $(srcdir)/pc_file.c \ + $(srcdir)/pc_font.c \ + $(srcdir)/pc_geom.c \ + $(srcdir)/pc_md5.c \ + $(srcdir)/pc_optparse.c \ + $(srcdir)/pc_output.c \ + $(srcdir)/pc_arc4.c \ + $(srcdir)/pc_sbuf.c \ + $(srcdir)/pc_scope.c \ + $(srcdir)/pc_unicode.c \ + $(srcdir)/pc_util.c + +OBJS = \ + $(srcdir)/pc_core$(LO) \ + $(srcdir)/pc_corefont$(LO)\ + $(srcdir)/pc_crypt$(LO) \ + $(srcdir)/pc_ebcdic$(LO) \ + $(srcdir)/pc_encoding$(LO)\ + $(srcdir)/pc_file$(LO) \ + $(srcdir)/pc_font$(LO) \ + $(srcdir)/pc_geom$(LO) \ + $(srcdir)/pc_md5$(LO) \ + $(srcdir)/pc_optparse$(LO)\ + $(srcdir)/pc_output$(LO) \ + $(srcdir)/pc_arc4$(LO) \ + $(srcdir)/pc_sbuf$(LO) \ + $(srcdir)/pc_scope$(LO) \ + $(srcdir)/pc_unicode$(LO) \ + $(srcdir)/pc_util$(LO) + + +include ../../config/mklibs.inc + +# Automatically generated dependencies diff --git a/src/libs/pdflib/libs/pdcore/pc_arc4.c b/src/libs/pdflib/libs/pdcore/pc_arc4.c new file mode 100644 index 0000000000..b48659e197 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_arc4.c @@ -0,0 +1,61 @@ +/* crypto/arc4/arc4_enc.c */ +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the ARC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include "pc_util.h" +#include "pc_arc4.h" + diff --git a/src/libs/pdflib/libs/pdcore/pc_arc4.h b/src/libs/pdflib/libs/pdcore/pc_arc4.h new file mode 100644 index 0000000000..9a474a78fe --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_arc4.h @@ -0,0 +1,60 @@ +/* crypto/arc4/arc4.h */ +/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the ARC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + +#include "pc_core.h" + diff --git a/src/libs/pdflib/libs/pdcore/pc_chartabs.h b/src/libs/pdflib/libs/pdcore/pc_chartabs.h new file mode 100644 index 0000000000..bf90b6de51 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_chartabs.h @@ -0,0 +1,3590 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_chartabs.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * This file contains all Adobe Glyph Names and Unicode tables. + * + */ + +#ifndef PC_CHARTABS_H +#define PC_CHARTABS_H + +/* + * The glyph name table is based on the Adobe Glyph List (AGL) version 1.2 + * which can be found at + * http://partners.adobe.com/asn/developer/type/glyphlist.txt + */ + +static const char glyph__notdef[] = ".notdef"; + +static const char glyph_A[] = "A"; +static const char glyph_AE[] = "AE"; +static const char glyph_AEacute[] = "AEacute"; +static const char glyph_AEsmall[] = "AEsmall"; +static const char glyph_Aacute[] = "Aacute"; +static const char glyph_Aacutesmall[] = "Aacutesmall"; +static const char glyph_Abreve[] = "Abreve"; +static const char glyph_Acircumflex[] = "Acircumflex"; +static const char glyph_Acircumflexsmall[] = "Acircumflexsmall"; +static const char glyph_Acute[] = "Acute"; +static const char glyph_Acutesmall[] = "Acutesmall"; +static const char glyph_Adieresis[] = "Adieresis"; +static const char glyph_Adieresissmall[] = "Adieresissmall"; +static const char glyph_Agrave[] = "Agrave"; +static const char glyph_Agravesmall[] = "Agravesmall"; +static const char glyph_Alpha[] = "Alpha"; +static const char glyph_Alphatonos[] = "Alphatonos"; +static const char glyph_Amacron[] = "Amacron"; +static const char glyph_Aogonek[] = "Aogonek"; +static const char glyph_Aring[] = "Aring"; +static const char glyph_Aringacute[] = "Aringacute"; +static const char glyph_Aringsmall[] = "Aringsmall"; +static const char glyph_Asmall[] = "Asmall"; +static const char glyph_Atilde[] = "Atilde"; +static const char glyph_Atildesmall[] = "Atildesmall"; +static const char glyph_B[] = "B"; +static const char glyph_Beta[] = "Beta"; +static const char glyph_Brevesmall[] = "Brevesmall"; +static const char glyph_Bsmall[] = "Bsmall"; +static const char glyph_C[] = "C"; +static const char glyph_Cacute[] = "Cacute"; +static const char glyph_Caron[] = "Caron"; +static const char glyph_Caronsmall[] = "Caronsmall"; +static const char glyph_Ccaron[] = "Ccaron"; +static const char glyph_Ccedilla[] = "Ccedilla"; +static const char glyph_Ccedillasmall[] = "Ccedillasmall"; +static const char glyph_Ccircumflex[] = "Ccircumflex"; +static const char glyph_Cdotaccent[] = "Cdotaccent"; +static const char glyph_Cedillasmall[] = "Cedillasmall"; +static const char glyph_Chi[] = "Chi"; +static const char glyph_Circumflexsmall[] = "Circumflexsmall"; +static const char glyph_Csmall[] = "Csmall"; +static const char glyph_D[] = "D"; +static const char glyph_Dcaron[] = "Dcaron"; +static const char glyph_Dcroat[] = "Dcroat"; +static const char glyph_Delta[] = "Delta"; +static const char glyph_Dieresis[] = "Dieresis"; +static const char glyph_DieresisAcute[] = "DieresisAcute"; +static const char glyph_DieresisGrave[] = "DieresisGrave"; +static const char glyph_Dieresissmall[] = "Dieresissmall"; +static const char glyph_Dotaccentsmall[] = "Dotaccentsmall"; +static const char glyph_Dsmall[] = "Dsmall"; +static const char glyph_E[] = "E"; +static const char glyph_Eacute[] = "Eacute"; +static const char glyph_Eacutesmall[] = "Eacutesmall"; +static const char glyph_Ebreve[] = "Ebreve"; +static const char glyph_Ecaron[] = "Ecaron"; +static const char glyph_Ecircumflex[] = "Ecircumflex"; +static const char glyph_Ecircumflexsmall[] = "Ecircumflexsmall"; +static const char glyph_Edieresis[] = "Edieresis"; +static const char glyph_Edieresissmall[] = "Edieresissmall"; +static const char glyph_Edotaccent[] = "Edotaccent"; +static const char glyph_Egrave[] = "Egrave"; +static const char glyph_Egravesmall[] = "Egravesmall"; +static const char glyph_Emacron[] = "Emacron"; +static const char glyph_Eng[] = "Eng"; +static const char glyph_Eogonek[] = "Eogonek"; +static const char glyph_Epsilon[] = "Epsilon"; +static const char glyph_Epsilontonos[] = "Epsilontonos"; +static const char glyph_Esmall[] = "Esmall"; +static const char glyph_Eta[] = "Eta"; +static const char glyph_Etatonos[] = "Etatonos"; +static const char glyph_Eth[] = "Eth"; +static const char glyph_Ethsmall[] = "Ethsmall"; +static const char glyph_Euro[] = "Euro"; +static const char glyph_F[] = "F"; +static const char glyph_Fsmall[] = "Fsmall"; +static const char glyph_G[] = "G"; +static const char glyph_Gamma[] = "Gamma"; +static const char glyph_Gbreve[] = "Gbreve"; +static const char glyph_Gcaron[] = "Gcaron"; +static const char glyph_Gcircumflex[] = "Gcircumflex"; +static const char glyph_Gcommaaccent[] = "Gcommaaccent"; +static const char glyph_Gdotaccent[] = "Gdotaccent"; +static const char glyph_Grave[] = "Grave"; +static const char glyph_Gravesmall[] = "Gravesmall"; +static const char glyph_Gsmall[] = "Gsmall"; +static const char glyph_H[] = "H"; +static const char glyph_H18533[] = "H18533"; +static const char glyph_H18543[] = "H18543"; +static const char glyph_H18551[] = "H18551"; +static const char glyph_H22073[] = "H22073"; +static const char glyph_Hbar[] = "Hbar"; +static const char glyph_Hcircumflex[] = "Hcircumflex"; +static const char glyph_Hsmall[] = "Hsmall"; +static const char glyph_Hungarumlaut[] = "Hungarumlaut"; +static const char glyph_Hungarumlautsmall[] = "Hungarumlautsmall"; +static const char glyph_I[] = "I"; +static const char glyph_IJ[] = "IJ"; +static const char glyph_Iacute[] = "Iacute"; +static const char glyph_Iacutesmall[] = "Iacutesmall"; +static const char glyph_Ibreve[] = "Ibreve"; +static const char glyph_Icircumflex[] = "Icircumflex"; +static const char glyph_Icircumflexsmall[] = "Icircumflexsmall"; +static const char glyph_Idieresis[] = "Idieresis"; +static const char glyph_Idieresissmall[] = "Idieresissmall"; +static const char glyph_Idotaccent[] = "Idotaccent"; +static const char glyph_Ifraktur[] = "Ifraktur"; +static const char glyph_Igrave[] = "Igrave"; +static const char glyph_Igravesmall[] = "Igravesmall"; +static const char glyph_Imacron[] = "Imacron"; +static const char glyph_Iogonek[] = "Iogonek"; +static const char glyph_Iota[] = "Iota"; +static const char glyph_Iotadieresis[] = "Iotadieresis"; +static const char glyph_Iotatonos[] = "Iotatonos"; +static const char glyph_Ismall[] = "Ismall"; +static const char glyph_Itilde[] = "Itilde"; +static const char glyph_J[] = "J"; +static const char glyph_Jcircumflex[] = "Jcircumflex"; +static const char glyph_Jsmall[] = "Jsmall"; +static const char glyph_K[] = "K"; +static const char glyph_Kappa[] = "Kappa"; +static const char glyph_Kcommaaccent[] = "Kcommaaccent"; +static const char glyph_Ksmall[] = "Ksmall"; +static const char glyph_L[] = "L"; +static const char glyph_LL[] = "LL"; +static const char glyph_Lacute[] = "Lacute"; +static const char glyph_Lambda[] = "Lambda"; +static const char glyph_Lcaron[] = "Lcaron"; +static const char glyph_Lcommaaccent[] = "Lcommaaccent"; +static const char glyph_Ldot[] = "Ldot"; +static const char glyph_Lslash[] = "Lslash"; +static const char glyph_Lslashsmall[] = "Lslashsmall"; +static const char glyph_Lsmall[] = "Lsmall"; +static const char glyph_M[] = "M"; +static const char glyph_Macron[] = "Macron"; +static const char glyph_Macronsmall[] = "Macronsmall"; +static const char glyph_Msmall[] = "Msmall"; +static const char glyph_Mu[] = "Mu"; +static const char glyph_N[] = "N"; +static const char glyph_Nacute[] = "Nacute"; +static const char glyph_Ncaron[] = "Ncaron"; +static const char glyph_Ncommaaccent[] = "Ncommaaccent"; +static const char glyph_Nsmall[] = "Nsmall"; +static const char glyph_Ntilde[] = "Ntilde"; +static const char glyph_Ntildesmall[] = "Ntildesmall"; +static const char glyph_Nu[] = "Nu"; +static const char glyph_O[] = "O"; +static const char glyph_OE[] = "OE"; +static const char glyph_OEsmall[] = "OEsmall"; +static const char glyph_Oacute[] = "Oacute"; +static const char glyph_Oacutesmall[] = "Oacutesmall"; +static const char glyph_Obreve[] = "Obreve"; +static const char glyph_Ocircumflex[] = "Ocircumflex"; +static const char glyph_Ocircumflexsmall[] = "Ocircumflexsmall"; +static const char glyph_Odieresis[] = "Odieresis"; +static const char glyph_Odieresissmall[] = "Odieresissmall"; +static const char glyph_Ogoneksmall[] = "Ogoneksmall"; +static const char glyph_Ograve[] = "Ograve"; +static const char glyph_Ogravesmall[] = "Ogravesmall"; +static const char glyph_Ohorn[] = "Ohorn"; +static const char glyph_Ohungarumlaut[] = "Ohungarumlaut"; +static const char glyph_Omacron[] = "Omacron"; +static const char glyph_Omega[] = "Omega"; +static const char glyph_Omegatonos[] = "Omegatonos"; +static const char glyph_Omicron[] = "Omicron"; +static const char glyph_Omicrontonos[] = "Omicrontonos"; +static const char glyph_Oslash[] = "Oslash"; +static const char glyph_Oslashacute[] = "Oslashacute"; +static const char glyph_Oslashsmall[] = "Oslashsmall"; +static const char glyph_Osmall[] = "Osmall"; +static const char glyph_Otilde[] = "Otilde"; +static const char glyph_Otildesmall[] = "Otildesmall"; +static const char glyph_P[] = "P"; +static const char glyph_Phi[] = "Phi"; +static const char glyph_Pi[] = "Pi"; +static const char glyph_Psi[] = "Psi"; +static const char glyph_Psmall[] = "Psmall"; +static const char glyph_Q[] = "Q"; +static const char glyph_Qsmall[] = "Qsmall"; +static const char glyph_R[] = "R"; +static const char glyph_Racute[] = "Racute"; +static const char glyph_Rcaron[] = "Rcaron"; +static const char glyph_Rcommaaccent[] = "Rcommaaccent"; +static const char glyph_Rfraktur[] = "Rfraktur"; +static const char glyph_Rho[] = "Rho"; +static const char glyph_Ringsmall[] = "Ringsmall"; +static const char glyph_Rsmall[] = "Rsmall"; +static const char glyph_S[] = "S"; +static const char glyph_SF010000[] = "SF010000"; +static const char glyph_SF020000[] = "SF020000"; +static const char glyph_SF030000[] = "SF030000"; +static const char glyph_SF040000[] = "SF040000"; +static const char glyph_SF050000[] = "SF050000"; +static const char glyph_SF060000[] = "SF060000"; +static const char glyph_SF070000[] = "SF070000"; +static const char glyph_SF080000[] = "SF080000"; +static const char glyph_SF090000[] = "SF090000"; +static const char glyph_SF100000[] = "SF100000"; +static const char glyph_SF110000[] = "SF110000"; +static const char glyph_SF190000[] = "SF190000"; +static const char glyph_SF200000[] = "SF200000"; +static const char glyph_SF210000[] = "SF210000"; +static const char glyph_SF220000[] = "SF220000"; +static const char glyph_SF230000[] = "SF230000"; +static const char glyph_SF240000[] = "SF240000"; +static const char glyph_SF250000[] = "SF250000"; +static const char glyph_SF260000[] = "SF260000"; +static const char glyph_SF270000[] = "SF270000"; +static const char glyph_SF280000[] = "SF280000"; +static const char glyph_SF360000[] = "SF360000"; +static const char glyph_SF370000[] = "SF370000"; +static const char glyph_SF380000[] = "SF380000"; +static const char glyph_SF390000[] = "SF390000"; +static const char glyph_SF400000[] = "SF400000"; +static const char glyph_SF410000[] = "SF410000"; +static const char glyph_SF420000[] = "SF420000"; +static const char glyph_SF430000[] = "SF430000"; +static const char glyph_SF440000[] = "SF440000"; +static const char glyph_SF450000[] = "SF450000"; +static const char glyph_SF460000[] = "SF460000"; +static const char glyph_SF470000[] = "SF470000"; +static const char glyph_SF480000[] = "SF480000"; +static const char glyph_SF490000[] = "SF490000"; +static const char glyph_SF500000[] = "SF500000"; +static const char glyph_SF510000[] = "SF510000"; +static const char glyph_SF520000[] = "SF520000"; +static const char glyph_SF530000[] = "SF530000"; +static const char glyph_SF540000[] = "SF540000"; +static const char glyph_Sacute[] = "Sacute"; +static const char glyph_Scaron[] = "Scaron"; +static const char glyph_Scaronsmall[] = "Scaronsmall"; +static const char glyph_Scedilla[] = "Scedilla"; +static const char glyph_Scircumflex[] = "Scircumflex"; +static const char glyph_Scommaaccent[] = "Scommaaccent"; +static const char glyph_Sigma[] = "Sigma"; +static const char glyph_Ssmall[] = "Ssmall"; +static const char glyph_T[] = "T"; +static const char glyph_Tau[] = "Tau"; +static const char glyph_Tbar[] = "Tbar"; +static const char glyph_Tcaron[] = "Tcaron"; +static const char glyph_Tcommaaccent[] = "Tcommaaccent"; +static const char glyph_Theta[] = "Theta"; +static const char glyph_Thorn[] = "Thorn"; +static const char glyph_Thornsmall[] = "Thornsmall"; +static const char glyph_Tildesmall[] = "Tildesmall"; +static const char glyph_Tsmall[] = "Tsmall"; +static const char glyph_U[] = "U"; +static const char glyph_Uacute[] = "Uacute"; +static const char glyph_Uacutesmall[] = "Uacutesmall"; +static const char glyph_Ubreve[] = "Ubreve"; +static const char glyph_Ucircumflex[] = "Ucircumflex"; +static const char glyph_Ucircumflexsmall[] = "Ucircumflexsmall"; +static const char glyph_Udieresis[] = "Udieresis"; +static const char glyph_Udieresissmall[] = "Udieresissmall"; +static const char glyph_Ugrave[] = "Ugrave"; +static const char glyph_Ugravesmall[] = "Ugravesmall"; +static const char glyph_Uhorn[] = "Uhorn"; +static const char glyph_Uhungarumlaut[] = "Uhungarumlaut"; +static const char glyph_Umacron[] = "Umacron"; +static const char glyph_Uogonek[] = "Uogonek"; +static const char glyph_Upsilon[] = "Upsilon"; +static const char glyph_Upsilon1[] = "Upsilon1"; +static const char glyph_Upsilondieresis[] = "Upsilondieresis"; +static const char glyph_Upsilontonos[] = "Upsilontonos"; +static const char glyph_Uring[] = "Uring"; +static const char glyph_Usmall[] = "Usmall"; +static const char glyph_Utilde[] = "Utilde"; +static const char glyph_V[] = "V"; +static const char glyph_Vsmall[] = "Vsmall"; +static const char glyph_W[] = "W"; +static const char glyph_Wacute[] = "Wacute"; +static const char glyph_Wcircumflex[] = "Wcircumflex"; +static const char glyph_Wdieresis[] = "Wdieresis"; +static const char glyph_Wgrave[] = "Wgrave"; +static const char glyph_Wsmall[] = "Wsmall"; +static const char glyph_X[] = "X"; +static const char glyph_Xi[] = "Xi"; +static const char glyph_Xsmall[] = "Xsmall"; +static const char glyph_Y[] = "Y"; +static const char glyph_Yacute[] = "Yacute"; +static const char glyph_Yacutesmall[] = "Yacutesmall"; +static const char glyph_Ycircumflex[] = "Ycircumflex"; +static const char glyph_Ydieresis[] = "Ydieresis"; +static const char glyph_Ydieresissmall[] = "Ydieresissmall"; +static const char glyph_Ygrave[] = "Ygrave"; +static const char glyph_Ysmall[] = "Ysmall"; +static const char glyph_Z[] = "Z"; +static const char glyph_Zacute[] = "Zacute"; +static const char glyph_Zcaron[] = "Zcaron"; +static const char glyph_Zcaronsmall[] = "Zcaronsmall"; +static const char glyph_Zdotaccent[] = "Zdotaccent"; +static const char glyph_Zeta[] = "Zeta"; +static const char glyph_Zsmall[] = "Zsmall"; +static const char glyph_a[] = "a"; +static const char glyph_aacute[] = "aacute"; +static const char glyph_abreve[] = "abreve"; +static const char glyph_acircumflex[] = "acircumflex"; +static const char glyph_acute[] = "acute"; +static const char glyph_acutecomb[] = "acutecomb"; +static const char glyph_adieresis[] = "adieresis"; +static const char glyph_ae[] = "ae"; +static const char glyph_aeacute[] = "aeacute"; +static const char glyph_afii00208[] = "afii00208"; +static const char glyph_afii10017[] = "afii10017"; +static const char glyph_afii10018[] = "afii10018"; +static const char glyph_afii10019[] = "afii10019"; +static const char glyph_afii10020[] = "afii10020"; +static const char glyph_afii10021[] = "afii10021"; +static const char glyph_afii10022[] = "afii10022"; +static const char glyph_afii10023[] = "afii10023"; +static const char glyph_afii10024[] = "afii10024"; +static const char glyph_afii10025[] = "afii10025"; +static const char glyph_afii10026[] = "afii10026"; +static const char glyph_afii10027[] = "afii10027"; +static const char glyph_afii10028[] = "afii10028"; +static const char glyph_afii10029[] = "afii10029"; +static const char glyph_afii10030[] = "afii10030"; +static const char glyph_afii10031[] = "afii10031"; +static const char glyph_afii10032[] = "afii10032"; +static const char glyph_afii10033[] = "afii10033"; +static const char glyph_afii10034[] = "afii10034"; +static const char glyph_afii10035[] = "afii10035"; +static const char glyph_afii10036[] = "afii10036"; +static const char glyph_afii10037[] = "afii10037"; +static const char glyph_afii10038[] = "afii10038"; +static const char glyph_afii10039[] = "afii10039"; +static const char glyph_afii10040[] = "afii10040"; +static const char glyph_afii10041[] = "afii10041"; +static const char glyph_afii10042[] = "afii10042"; +static const char glyph_afii10043[] = "afii10043"; +static const char glyph_afii10044[] = "afii10044"; +static const char glyph_afii10045[] = "afii10045"; +static const char glyph_afii10046[] = "afii10046"; +static const char glyph_afii10047[] = "afii10047"; +static const char glyph_afii10048[] = "afii10048"; +static const char glyph_afii10049[] = "afii10049"; +static const char glyph_afii10050[] = "afii10050"; +static const char glyph_afii10051[] = "afii10051"; +static const char glyph_afii10052[] = "afii10052"; +static const char glyph_afii10053[] = "afii10053"; +static const char glyph_afii10054[] = "afii10054"; +static const char glyph_afii10055[] = "afii10055"; +static const char glyph_afii10056[] = "afii10056"; +static const char glyph_afii10057[] = "afii10057"; +static const char glyph_afii10058[] = "afii10058"; +static const char glyph_afii10059[] = "afii10059"; +static const char glyph_afii10060[] = "afii10060"; +static const char glyph_afii10061[] = "afii10061"; +static const char glyph_afii10062[] = "afii10062"; +static const char glyph_afii10063[] = "afii10063"; +static const char glyph_afii10064[] = "afii10064"; +static const char glyph_afii10065[] = "afii10065"; +static const char glyph_afii10066[] = "afii10066"; +static const char glyph_afii10067[] = "afii10067"; +static const char glyph_afii10068[] = "afii10068"; +static const char glyph_afii10069[] = "afii10069"; +static const char glyph_afii10070[] = "afii10070"; +static const char glyph_afii10071[] = "afii10071"; +static const char glyph_afii10072[] = "afii10072"; +static const char glyph_afii10073[] = "afii10073"; +static const char glyph_afii10074[] = "afii10074"; +static const char glyph_afii10075[] = "afii10075"; +static const char glyph_afii10076[] = "afii10076"; +static const char glyph_afii10077[] = "afii10077"; +static const char glyph_afii10078[] = "afii10078"; +static const char glyph_afii10079[] = "afii10079"; +static const char glyph_afii10080[] = "afii10080"; +static const char glyph_afii10081[] = "afii10081"; +static const char glyph_afii10082[] = "afii10082"; +static const char glyph_afii10083[] = "afii10083"; +static const char glyph_afii10084[] = "afii10084"; +static const char glyph_afii10085[] = "afii10085"; +static const char glyph_afii10086[] = "afii10086"; +static const char glyph_afii10087[] = "afii10087"; +static const char glyph_afii10088[] = "afii10088"; +static const char glyph_afii10089[] = "afii10089"; +static const char glyph_afii10090[] = "afii10090"; +static const char glyph_afii10091[] = "afii10091"; +static const char glyph_afii10092[] = "afii10092"; +static const char glyph_afii10093[] = "afii10093"; +static const char glyph_afii10094[] = "afii10094"; +static const char glyph_afii10095[] = "afii10095"; +static const char glyph_afii10096[] = "afii10096"; +static const char glyph_afii10097[] = "afii10097"; +static const char glyph_afii10098[] = "afii10098"; +static const char glyph_afii10099[] = "afii10099"; +static const char glyph_afii10100[] = "afii10100"; +static const char glyph_afii10101[] = "afii10101"; +static const char glyph_afii10102[] = "afii10102"; +static const char glyph_afii10103[] = "afii10103"; +static const char glyph_afii10104[] = "afii10104"; +static const char glyph_afii10105[] = "afii10105"; +static const char glyph_afii10106[] = "afii10106"; +static const char glyph_afii10107[] = "afii10107"; +static const char glyph_afii10108[] = "afii10108"; +static const char glyph_afii10109[] = "afii10109"; +static const char glyph_afii10110[] = "afii10110"; +static const char glyph_afii10145[] = "afii10145"; +static const char glyph_afii10146[] = "afii10146"; +static const char glyph_afii10147[] = "afii10147"; +static const char glyph_afii10148[] = "afii10148"; +static const char glyph_afii10192[] = "afii10192"; +static const char glyph_afii10193[] = "afii10193"; +static const char glyph_afii10194[] = "afii10194"; +static const char glyph_afii10195[] = "afii10195"; +static const char glyph_afii10196[] = "afii10196"; +static const char glyph_afii10831[] = "afii10831"; +static const char glyph_afii10832[] = "afii10832"; +static const char glyph_afii10846[] = "afii10846"; +static const char glyph_afii299[] = "afii299"; +static const char glyph_afii300[] = "afii300"; +static const char glyph_afii301[] = "afii301"; +static const char glyph_afii57381[] = "afii57381"; +static const char glyph_afii57388[] = "afii57388"; +static const char glyph_afii57392[] = "afii57392"; +static const char glyph_afii57393[] = "afii57393"; +static const char glyph_afii57394[] = "afii57394"; +static const char glyph_afii57395[] = "afii57395"; +static const char glyph_afii57396[] = "afii57396"; +static const char glyph_afii57397[] = "afii57397"; +static const char glyph_afii57398[] = "afii57398"; +static const char glyph_afii57399[] = "afii57399"; +static const char glyph_afii57400[] = "afii57400"; +static const char glyph_afii57401[] = "afii57401"; +static const char glyph_afii57403[] = "afii57403"; +static const char glyph_afii57407[] = "afii57407"; +static const char glyph_afii57409[] = "afii57409"; +static const char glyph_afii57410[] = "afii57410"; +static const char glyph_afii57411[] = "afii57411"; +static const char glyph_afii57412[] = "afii57412"; +static const char glyph_afii57413[] = "afii57413"; +static const char glyph_afii57414[] = "afii57414"; +static const char glyph_afii57415[] = "afii57415"; +static const char glyph_afii57416[] = "afii57416"; +static const char glyph_afii57417[] = "afii57417"; +static const char glyph_afii57418[] = "afii57418"; +static const char glyph_afii57419[] = "afii57419"; +static const char glyph_afii57420[] = "afii57420"; +static const char glyph_afii57421[] = "afii57421"; +static const char glyph_afii57422[] = "afii57422"; +static const char glyph_afii57423[] = "afii57423"; +static const char glyph_afii57424[] = "afii57424"; +static const char glyph_afii57425[] = "afii57425"; +static const char glyph_afii57426[] = "afii57426"; +static const char glyph_afii57427[] = "afii57427"; +static const char glyph_afii57428[] = "afii57428"; +static const char glyph_afii57429[] = "afii57429"; +static const char glyph_afii57430[] = "afii57430"; +static const char glyph_afii57431[] = "afii57431"; +static const char glyph_afii57432[] = "afii57432"; +static const char glyph_afii57433[] = "afii57433"; +static const char glyph_afii57434[] = "afii57434"; +static const char glyph_afii57440[] = "afii57440"; +static const char glyph_afii57441[] = "afii57441"; +static const char glyph_afii57442[] = "afii57442"; +static const char glyph_afii57443[] = "afii57443"; +static const char glyph_afii57444[] = "afii57444"; +static const char glyph_afii57445[] = "afii57445"; +static const char glyph_afii57446[] = "afii57446"; +static const char glyph_afii57448[] = "afii57448"; +static const char glyph_afii57449[] = "afii57449"; +static const char glyph_afii57450[] = "afii57450"; +static const char glyph_afii57451[] = "afii57451"; +static const char glyph_afii57452[] = "afii57452"; +static const char glyph_afii57453[] = "afii57453"; +static const char glyph_afii57454[] = "afii57454"; +static const char glyph_afii57455[] = "afii57455"; +static const char glyph_afii57456[] = "afii57456"; +static const char glyph_afii57457[] = "afii57457"; +static const char glyph_afii57458[] = "afii57458"; +static const char glyph_afii57470[] = "afii57470"; +static const char glyph_afii57505[] = "afii57505"; +static const char glyph_afii57506[] = "afii57506"; +static const char glyph_afii57507[] = "afii57507"; +static const char glyph_afii57508[] = "afii57508"; +static const char glyph_afii57509[] = "afii57509"; +static const char glyph_afii57511[] = "afii57511"; +static const char glyph_afii57512[] = "afii57512"; +static const char glyph_afii57513[] = "afii57513"; +static const char glyph_afii57514[] = "afii57514"; +static const char glyph_afii57519[] = "afii57519"; +static const char glyph_afii57534[] = "afii57534"; +static const char glyph_afii57636[] = "afii57636"; +static const char glyph_afii57645[] = "afii57645"; +static const char glyph_afii57658[] = "afii57658"; +static const char glyph_afii57664[] = "afii57664"; +static const char glyph_afii57665[] = "afii57665"; +static const char glyph_afii57666[] = "afii57666"; +static const char glyph_afii57667[] = "afii57667"; +static const char glyph_afii57668[] = "afii57668"; +static const char glyph_afii57669[] = "afii57669"; +static const char glyph_afii57670[] = "afii57670"; +static const char glyph_afii57671[] = "afii57671"; +static const char glyph_afii57672[] = "afii57672"; +static const char glyph_afii57673[] = "afii57673"; +static const char glyph_afii57674[] = "afii57674"; +static const char glyph_afii57675[] = "afii57675"; +static const char glyph_afii57676[] = "afii57676"; +static const char glyph_afii57677[] = "afii57677"; +static const char glyph_afii57678[] = "afii57678"; +static const char glyph_afii57679[] = "afii57679"; +static const char glyph_afii57680[] = "afii57680"; +static const char glyph_afii57681[] = "afii57681"; +static const char glyph_afii57682[] = "afii57682"; +static const char glyph_afii57683[] = "afii57683"; +static const char glyph_afii57684[] = "afii57684"; +static const char glyph_afii57685[] = "afii57685"; +static const char glyph_afii57686[] = "afii57686"; +static const char glyph_afii57687[] = "afii57687"; +static const char glyph_afii57688[] = "afii57688"; +static const char glyph_afii57689[] = "afii57689"; +static const char glyph_afii57690[] = "afii57690"; +static const char glyph_afii57694[] = "afii57694"; +static const char glyph_afii57695[] = "afii57695"; +static const char glyph_afii57700[] = "afii57700"; +static const char glyph_afii57705[] = "afii57705"; +static const char glyph_afii57716[] = "afii57716"; +static const char glyph_afii57717[] = "afii57717"; +static const char glyph_afii57718[] = "afii57718"; +static const char glyph_afii57723[] = "afii57723"; +static const char glyph_afii57793[] = "afii57793"; +static const char glyph_afii57794[] = "afii57794"; +static const char glyph_afii57795[] = "afii57795"; +static const char glyph_afii57796[] = "afii57796"; +static const char glyph_afii57797[] = "afii57797"; +static const char glyph_afii57798[] = "afii57798"; +static const char glyph_afii57799[] = "afii57799"; +static const char glyph_afii57800[] = "afii57800"; +static const char glyph_afii57801[] = "afii57801"; +static const char glyph_afii57802[] = "afii57802"; +static const char glyph_afii57803[] = "afii57803"; +static const char glyph_afii57804[] = "afii57804"; +static const char glyph_afii57806[] = "afii57806"; +static const char glyph_afii57807[] = "afii57807"; +static const char glyph_afii57839[] = "afii57839"; +static const char glyph_afii57841[] = "afii57841"; +static const char glyph_afii57842[] = "afii57842"; +static const char glyph_afii57929[] = "afii57929"; +static const char glyph_afii61248[] = "afii61248"; +static const char glyph_afii61289[] = "afii61289"; +static const char glyph_afii61352[] = "afii61352"; +static const char glyph_afii61573[] = "afii61573"; +static const char glyph_afii61574[] = "afii61574"; +static const char glyph_afii61575[] = "afii61575"; +static const char glyph_afii61664[] = "afii61664"; +static const char glyph_afii63167[] = "afii63167"; +static const char glyph_afii64937[] = "afii64937"; +static const char glyph_agrave[] = "agrave"; +static const char glyph_aleph[] = "aleph"; +static const char glyph_alpha[] = "alpha"; +static const char glyph_alphatonos[] = "alphatonos"; +static const char glyph_amacron[] = "amacron"; +static const char glyph_ampersand[] = "ampersand"; +static const char glyph_ampersandsmall[] = "ampersandsmall"; +static const char glyph_angle[] = "angle"; +static const char glyph_angleleft[] = "angleleft"; +static const char glyph_angleright[] = "angleright"; +static const char glyph_anoteleia[] = "anoteleia"; +static const char glyph_aogonek[] = "aogonek"; +static const char glyph_approxequal[] = "approxequal"; +static const char glyph_aring[] = "aring"; +static const char glyph_aringacute[] = "aringacute"; +static const char glyph_arrowboth[] = "arrowboth"; +static const char glyph_arrowdblboth[] = "arrowdblboth"; +static const char glyph_arrowdbldown[] = "arrowdbldown"; +static const char glyph_arrowdblleft[] = "arrowdblleft"; +static const char glyph_arrowdblright[] = "arrowdblright"; +static const char glyph_arrowdblup[] = "arrowdblup"; +static const char glyph_arrowdown[] = "arrowdown"; +static const char glyph_arrowhorizex[] = "arrowhorizex"; +static const char glyph_arrowleft[] = "arrowleft"; +static const char glyph_arrowright[] = "arrowright"; +static const char glyph_arrowup[] = "arrowup"; +static const char glyph_arrowupdn[] = "arrowupdn"; +static const char glyph_arrowupdnbse[] = "arrowupdnbse"; +static const char glyph_arrowvertex[] = "arrowvertex"; +static const char glyph_asciicircum[] = "asciicircum"; +static const char glyph_asciitilde[] = "asciitilde"; +static const char glyph_asterisk[] = "asterisk"; +static const char glyph_asteriskmath[] = "asteriskmath"; +static const char glyph_asuperior[] = "asuperior"; +static const char glyph_at[] = "at"; +static const char glyph_atilde[] = "atilde"; +static const char glyph_b[] = "b"; +static const char glyph_backslash[] = "backslash"; +static const char glyph_bar[] = "bar"; +static const char glyph_beta[] = "beta"; +static const char glyph_block[] = "block"; +static const char glyph_braceex[] = "braceex"; +static const char glyph_braceleft[] = "braceleft"; +static const char glyph_braceleftbt[] = "braceleftbt"; +static const char glyph_braceleftmid[] = "braceleftmid"; +static const char glyph_bracelefttp[] = "bracelefttp"; +static const char glyph_braceright[] = "braceright"; +static const char glyph_bracerightbt[] = "bracerightbt"; +static const char glyph_bracerightmid[] = "bracerightmid"; +static const char glyph_bracerighttp[] = "bracerighttp"; +static const char glyph_bracketleft[] = "bracketleft"; +static const char glyph_bracketleftbt[] = "bracketleftbt"; +static const char glyph_bracketleftex[] = "bracketleftex"; +static const char glyph_bracketlefttp[] = "bracketlefttp"; +static const char glyph_bracketright[] = "bracketright"; +static const char glyph_bracketrightbt[] = "bracketrightbt"; +static const char glyph_bracketrightex[] = "bracketrightex"; +static const char glyph_bracketrighttp[] = "bracketrighttp"; +static const char glyph_breve[] = "breve"; +static const char glyph_brokenbar[] = "brokenbar"; +static const char glyph_bsuperior[] = "bsuperior"; +static const char glyph_bullet[] = "bullet"; +static const char glyph_c[] = "c"; +static const char glyph_cacute[] = "cacute"; +static const char glyph_caron[] = "caron"; +static const char glyph_carriagereturn[] = "carriagereturn"; +static const char glyph_ccaron[] = "ccaron"; +static const char glyph_ccedilla[] = "ccedilla"; +static const char glyph_ccircumflex[] = "ccircumflex"; +static const char glyph_cdotaccent[] = "cdotaccent"; +static const char glyph_cedilla[] = "cedilla"; +static const char glyph_cent[] = "cent"; +static const char glyph_centinferior[] = "centinferior"; +static const char glyph_centoldstyle[] = "centoldstyle"; +static const char glyph_centsuperior[] = "centsuperior"; +static const char glyph_chi[] = "chi"; +static const char glyph_circle[] = "circle"; +static const char glyph_circlemultiply[] = "circlemultiply"; +static const char glyph_circleplus[] = "circleplus"; +static const char glyph_circumflex[] = "circumflex"; +static const char glyph_club[] = "club"; +static const char glyph_colon[] = "colon"; +static const char glyph_colonmonetary[] = "colonmonetary"; +static const char glyph_comma[] = "comma"; +static const char glyph_commaaccent[] = "commaaccent"; +static const char glyph_commainferior[] = "commainferior"; +static const char glyph_commasuperior[] = "commasuperior"; +static const char glyph_congruent[] = "congruent"; +static const char glyph_copyright[] = "copyright"; +static const char glyph_copyrightsans[] = "copyrightsans"; +static const char glyph_copyrightserif[] = "copyrightserif"; +static const char glyph_currency[] = "currency"; +static const char glyph_cyrBreve[] = "cyrBreve"; +static const char glyph_cyrFlex[] = "cyrFlex"; +static const char glyph_cyrbreve[] = "cyrbreve"; +static const char glyph_cyrflex[] = "cyrflex"; +static const char glyph_d[] = "d"; +static const char glyph_dagger[] = "dagger"; +static const char glyph_daggerdbl[] = "daggerdbl"; +static const char glyph_dblGrave[] = "dblGrave"; +static const char glyph_dblgrave[] = "dblgrave"; +static const char glyph_dcaron[] = "dcaron"; +static const char glyph_dcroat[] = "dcroat"; +static const char glyph_degree[] = "degree"; +static const char glyph_delta[] = "delta"; +static const char glyph_diamond[] = "diamond"; +static const char glyph_dieresis[] = "dieresis"; +static const char glyph_dieresisacute[] = "dieresisacute"; +static const char glyph_dieresisgrave[] = "dieresisgrave"; +static const char glyph_dieresistonos[] = "dieresistonos"; +static const char glyph_divide[] = "divide"; +static const char glyph_dkshade[] = "dkshade"; +static const char glyph_dnblock[] = "dnblock"; +static const char glyph_dollar[] = "dollar"; +static const char glyph_dollarinferior[] = "dollarinferior"; +static const char glyph_dollaroldstyle[] = "dollaroldstyle"; +static const char glyph_dollarsuperior[] = "dollarsuperior"; +static const char glyph_dong[] = "dong"; +static const char glyph_dotaccent[] = "dotaccent"; +static const char glyph_dotbelowcomb[] = "dotbelowcomb"; +static const char glyph_dotlessi[] = "dotlessi"; +static const char glyph_dotlessj[] = "dotlessj"; +static const char glyph_dotmath[] = "dotmath"; +static const char glyph_dsuperior[] = "dsuperior"; +static const char glyph_e[] = "e"; +static const char glyph_eacute[] = "eacute"; +static const char glyph_ebreve[] = "ebreve"; +static const char glyph_ecaron[] = "ecaron"; +static const char glyph_ecircumflex[] = "ecircumflex"; +static const char glyph_edieresis[] = "edieresis"; +static const char glyph_edotaccent[] = "edotaccent"; +static const char glyph_egrave[] = "egrave"; +static const char glyph_eight[] = "eight"; +static const char glyph_eightinferior[] = "eightinferior"; +static const char glyph_eightoldstyle[] = "eightoldstyle"; +static const char glyph_eightsuperior[] = "eightsuperior"; +static const char glyph_element[] = "element"; +static const char glyph_ellipsis[] = "ellipsis"; +static const char glyph_emacron[] = "emacron"; +static const char glyph_emdash[] = "emdash"; +static const char glyph_emptyset[] = "emptyset"; +static const char glyph_endash[] = "endash"; +static const char glyph_eng[] = "eng"; +static const char glyph_eogonek[] = "eogonek"; +static const char glyph_epsilon[] = "epsilon"; +static const char glyph_epsilontonos[] = "epsilontonos"; +static const char glyph_equal[] = "equal"; +static const char glyph_equivalence[] = "equivalence"; +static const char glyph_estimated[] = "estimated"; +static const char glyph_esuperior[] = "esuperior"; +static const char glyph_eta[] = "eta"; +static const char glyph_etatonos[] = "etatonos"; +static const char glyph_eth[] = "eth"; +static const char glyph_exclam[] = "exclam"; +static const char glyph_exclamdbl[] = "exclamdbl"; +static const char glyph_exclamdown[] = "exclamdown"; +static const char glyph_exclamdownsmall[] = "exclamdownsmall"; +static const char glyph_exclamsmall[] = "exclamsmall"; +static const char glyph_existential[] = "existential"; +static const char glyph_f[] = "f"; +static const char glyph_female[] = "female"; +static const char glyph_ff[] = "ff"; +static const char glyph_ffi[] = "ffi"; +static const char glyph_ffl[] = "ffl"; +static const char glyph_fi[] = "fi"; +static const char glyph_figuredash[] = "figuredash"; +static const char glyph_filledbox[] = "filledbox"; +static const char glyph_filledrect[] = "filledrect"; +static const char glyph_five[] = "five"; +static const char glyph_fiveeighths[] = "fiveeighths"; +static const char glyph_fiveinferior[] = "fiveinferior"; +static const char glyph_fiveoldstyle[] = "fiveoldstyle"; +static const char glyph_fivesuperior[] = "fivesuperior"; +static const char glyph_fl[] = "fl"; +static const char glyph_florin[] = "florin"; +static const char glyph_four[] = "four"; +static const char glyph_fourinferior[] = "fourinferior"; +static const char glyph_fouroldstyle[] = "fouroldstyle"; +static const char glyph_foursuperior[] = "foursuperior"; +static const char glyph_fraction[] = "fraction"; +static const char glyph_franc[] = "franc"; +static const char glyph_g[] = "g"; +static const char glyph_gamma[] = "gamma"; +static const char glyph_gbreve[] = "gbreve"; +static const char glyph_gcaron[] = "gcaron"; +static const char glyph_gcircumflex[] = "gcircumflex"; +static const char glyph_gcommaaccent[] = "gcommaaccent"; +static const char glyph_gdotaccent[] = "gdotaccent"; +static const char glyph_germandbls[] = "germandbls"; +static const char glyph_gradient[] = "gradient"; +static const char glyph_grave[] = "grave"; +static const char glyph_gravecomb[] = "gravecomb"; +static const char glyph_greater[] = "greater"; +static const char glyph_greaterequal[] = "greaterequal"; +static const char glyph_guillemotleft[] = "guillemotleft"; +static const char glyph_guillemotright[] = "guillemotright"; +static const char glyph_guilsinglleft[] = "guilsinglleft"; +static const char glyph_guilsinglright[] = "guilsinglright"; +static const char glyph_h[] = "h"; +static const char glyph_hbar[] = "hbar"; +static const char glyph_hcircumflex[] = "hcircumflex"; +static const char glyph_heart[] = "heart"; +static const char glyph_hookabovecomb[] = "hookabovecomb"; +static const char glyph_house[] = "house"; +static const char glyph_hungarumlaut[] = "hungarumlaut"; +static const char glyph_hyphen[] = "hyphen"; +static const char glyph_hypheninferior[] = "hypheninferior"; +static const char glyph_hyphensuperior[] = "hyphensuperior"; +static const char glyph_i[] = "i"; +static const char glyph_iacute[] = "iacute"; +static const char glyph_ibreve[] = "ibreve"; +static const char glyph_icircumflex[] = "icircumflex"; +static const char glyph_idieresis[] = "idieresis"; +static const char glyph_igrave[] = "igrave"; +static const char glyph_ij[] = "ij"; +static const char glyph_imacron[] = "imacron"; +static const char glyph_infinity[] = "infinity"; +static const char glyph_integral[] = "integral"; +static const char glyph_integralbt[] = "integralbt"; +static const char glyph_integralex[] = "integralex"; +static const char glyph_integraltp[] = "integraltp"; +static const char glyph_intersection[] = "intersection"; +static const char glyph_invbullet[] = "invbullet"; +static const char glyph_invcircle[] = "invcircle"; +static const char glyph_invsmileface[] = "invsmileface"; +static const char glyph_iogonek[] = "iogonek"; +static const char glyph_iota[] = "iota"; +static const char glyph_iotadieresis[] = "iotadieresis"; +static const char glyph_iotadieresistonos[] = "iotadieresistonos"; +static const char glyph_iotatonos[] = "iotatonos"; +static const char glyph_isuperior[] = "isuperior"; +static const char glyph_itilde[] = "itilde"; +static const char glyph_j[] = "j"; +static const char glyph_jcircumflex[] = "jcircumflex"; +static const char glyph_k[] = "k"; +static const char glyph_kappa[] = "kappa"; +static const char glyph_kcommaaccent[] = "kcommaaccent"; +static const char glyph_kgreenlandic[] = "kgreenlandic"; +static const char glyph_l[] = "l"; +static const char glyph_lacute[] = "lacute"; +static const char glyph_lambda[] = "lambda"; +static const char glyph_lcaron[] = "lcaron"; +static const char glyph_lcommaaccent[] = "lcommaaccent"; +static const char glyph_ldot[] = "ldot"; +static const char glyph_less[] = "less"; +static const char glyph_lessequal[] = "lessequal"; +static const char glyph_lfblock[] = "lfblock"; +static const char glyph_lira[] = "lira"; +static const char glyph_ll[] = "ll"; +static const char glyph_logicaland[] = "logicaland"; +static const char glyph_logicalnot[] = "logicalnot"; +static const char glyph_logicalor[] = "logicalor"; +static const char glyph_longs[] = "longs"; +static const char glyph_lozenge[] = "lozenge"; +static const char glyph_lslash[] = "lslash"; +static const char glyph_lsuperior[] = "lsuperior"; +static const char glyph_ltshade[] = "ltshade"; +static const char glyph_m[] = "m"; +static const char glyph_macron[] = "macron"; +static const char glyph_male[] = "male"; +static const char glyph_minus[] = "minus"; +static const char glyph_minute[] = "minute"; +static const char glyph_msuperior[] = "msuperior"; +static const char glyph_mu[] = "mu"; +static const char glyph_multiply[] = "multiply"; +static const char glyph_musicalnote[] = "musicalnote"; +static const char glyph_musicalnotedbl[] = "musicalnotedbl"; +static const char glyph_n[] = "n"; +static const char glyph_nacute[] = "nacute"; +static const char glyph_napostrophe[] = "napostrophe"; +static const char glyph_ncaron[] = "ncaron"; +static const char glyph_ncommaaccent[] = "ncommaaccent"; +static const char glyph_nine[] = "nine"; +static const char glyph_nineinferior[] = "nineinferior"; +static const char glyph_nineoldstyle[] = "nineoldstyle"; +static const char glyph_ninesuperior[] = "ninesuperior"; +static const char glyph_notelement[] = "notelement"; +static const char glyph_notequal[] = "notequal"; +static const char glyph_notsubset[] = "notsubset"; +static const char glyph_nsuperior[] = "nsuperior"; +static const char glyph_ntilde[] = "ntilde"; +static const char glyph_nu[] = "nu"; +static const char glyph_numbersign[] = "numbersign"; +static const char glyph_o[] = "o"; +static const char glyph_oacute[] = "oacute"; +static const char glyph_obreve[] = "obreve"; +static const char glyph_ocircumflex[] = "ocircumflex"; +static const char glyph_odieresis[] = "odieresis"; +static const char glyph_oe[] = "oe"; +static const char glyph_ogonek[] = "ogonek"; +static const char glyph_ograve[] = "ograve"; +static const char glyph_ohorn[] = "ohorn"; +static const char glyph_ohungarumlaut[] = "ohungarumlaut"; +static const char glyph_omacron[] = "omacron"; +static const char glyph_omega[] = "omega"; +static const char glyph_omega1[] = "omega1"; +static const char glyph_omegatonos[] = "omegatonos"; +static const char glyph_omicron[] = "omicron"; +static const char glyph_omicrontonos[] = "omicrontonos"; +static const char glyph_one[] = "one"; +static const char glyph_onedotenleader[] = "onedotenleader"; +static const char glyph_oneeighth[] = "oneeighth"; +static const char glyph_onefitted[] = "onefitted"; +static const char glyph_onehalf[] = "onehalf"; +static const char glyph_oneinferior[] = "oneinferior"; +static const char glyph_oneoldstyle[] = "oneoldstyle"; +static const char glyph_onequarter[] = "onequarter"; +static const char glyph_onesuperior[] = "onesuperior"; +static const char glyph_onethird[] = "onethird"; +static const char glyph_openbullet[] = "openbullet"; +static const char glyph_ordfeminine[] = "ordfeminine"; +static const char glyph_ordmasculine[] = "ordmasculine"; +static const char glyph_orthogonal[] = "orthogonal"; +static const char glyph_oslash[] = "oslash"; +static const char glyph_oslashacute[] = "oslashacute"; +static const char glyph_osuperior[] = "osuperior"; +static const char glyph_otilde[] = "otilde"; +static const char glyph_p[] = "p"; +static const char glyph_paragraph[] = "paragraph"; +static const char glyph_parenleft[] = "parenleft"; +static const char glyph_parenleftbt[] = "parenleftbt"; +static const char glyph_parenleftex[] = "parenleftex"; +static const char glyph_parenleftinferior[] = "parenleftinferior"; +static const char glyph_parenleftsuperior[] = "parenleftsuperior"; +static const char glyph_parenlefttp[] = "parenlefttp"; +static const char glyph_parenright[] = "parenright"; +static const char glyph_parenrightbt[] = "parenrightbt"; +static const char glyph_parenrightex[] = "parenrightex"; +static const char glyph_parenrightinferior[] = "parenrightinferior"; +static const char glyph_parenrightsuperior[] = "parenrightsuperior"; +static const char glyph_parenrighttp[] = "parenrighttp"; +static const char glyph_partialdiff[] = "partialdiff"; +static const char glyph_percent[] = "percent"; +static const char glyph_period[] = "period"; +static const char glyph_periodcentered[] = "periodcentered"; +static const char glyph_periodinferior[] = "periodinferior"; +static const char glyph_periodsuperior[] = "periodsuperior"; +static const char glyph_perpendicular[] = "perpendicular"; +static const char glyph_perthousand[] = "perthousand"; +static const char glyph_peseta[] = "peseta"; +static const char glyph_phi[] = "phi"; +static const char glyph_phi1[] = "phi1"; +static const char glyph_pi[] = "pi"; +static const char glyph_plus[] = "plus"; +static const char glyph_plusminus[] = "plusminus"; +static const char glyph_prescription[] = "prescription"; +static const char glyph_product[] = "product"; +static const char glyph_propersubset[] = "propersubset"; +static const char glyph_propersuperset[] = "propersuperset"; +static const char glyph_proportional[] = "proportional"; +static const char glyph_psi[] = "psi"; +static const char glyph_q[] = "q"; +static const char glyph_question[] = "question"; +static const char glyph_questiondown[] = "questiondown"; +static const char glyph_questiondownsmall[] = "questiondownsmall"; +static const char glyph_questionsmall[] = "questionsmall"; +static const char glyph_quotedbl[] = "quotedbl"; +static const char glyph_quotedblbase[] = "quotedblbase"; +static const char glyph_quotedblleft[] = "quotedblleft"; +static const char glyph_quotedblright[] = "quotedblright"; +static const char glyph_quoteleft[] = "quoteleft"; +static const char glyph_quotereversed[] = "quotereversed"; +static const char glyph_quoteright[] = "quoteright"; +static const char glyph_quotesinglbase[] = "quotesinglbase"; +static const char glyph_quotesingle[] = "quotesingle"; +static const char glyph_r[] = "r"; +static const char glyph_racute[] = "racute"; +static const char glyph_radical[] = "radical"; +static const char glyph_radicalex[] = "radicalex"; +static const char glyph_rcaron[] = "rcaron"; +static const char glyph_rcommaaccent[] = "rcommaaccent"; +static const char glyph_reflexsubset[] = "reflexsubset"; +static const char glyph_reflexsuperset[] = "reflexsuperset"; +static const char glyph_registered[] = "registered"; +static const char glyph_registersans[] = "registersans"; +static const char glyph_registerserif[] = "registerserif"; +static const char glyph_revlogicalnot[] = "revlogicalnot"; +static const char glyph_rho[] = "rho"; +static const char glyph_ring[] = "ring"; +static const char glyph_rsuperior[] = "rsuperior"; +static const char glyph_rtblock[] = "rtblock"; +static const char glyph_rupiah[] = "rupiah"; +static const char glyph_s[] = "s"; +static const char glyph_sacute[] = "sacute"; +static const char glyph_scaron[] = "scaron"; +static const char glyph_scedilla[] = "scedilla"; +static const char glyph_scircumflex[] = "scircumflex"; +static const char glyph_scommaaccent[] = "scommaaccent"; +static const char glyph_second[] = "second"; +static const char glyph_section[] = "section"; +static const char glyph_semicolon[] = "semicolon"; +static const char glyph_seven[] = "seven"; +static const char glyph_seveneighths[] = "seveneighths"; +static const char glyph_seveninferior[] = "seveninferior"; +static const char glyph_sevenoldstyle[] = "sevenoldstyle"; +static const char glyph_sevensuperior[] = "sevensuperior"; +static const char glyph_shade[] = "shade"; +static const char glyph_sigma[] = "sigma"; +static const char glyph_sigma1[] = "sigma1"; +/* static const char glyph_uni03C2[] = "uni03C2"; */ +static const char glyph_similar[] = "similar"; +static const char glyph_six[] = "six"; +static const char glyph_sixinferior[] = "sixinferior"; +static const char glyph_sixoldstyle[] = "sixoldstyle"; +static const char glyph_sixsuperior[] = "sixsuperior"; +static const char glyph_slash[] = "slash"; +static const char glyph_smileface[] = "smileface"; +static const char glyph_space[] = "space"; +static const char glyph_spade[] = "spade"; +static const char glyph_ssuperior[] = "ssuperior"; +static const char glyph_sterling[] = "sterling"; +static const char glyph_suchthat[] = "suchthat"; +static const char glyph_summation[] = "summation"; +static const char glyph_sun[] = "sun"; +static const char glyph_t[] = "t"; +static const char glyph_tau[] = "tau"; +static const char glyph_tbar[] = "tbar"; +static const char glyph_tcaron[] = "tcaron"; +static const char glyph_tcommaaccent[] = "tcommaaccent"; +static const char glyph_therefore[] = "therefore"; +static const char glyph_theta[] = "theta"; +static const char glyph_theta1[] = "theta1"; +static const char glyph_thorn[] = "thorn"; +static const char glyph_three[] = "three"; +static const char glyph_threeeighths[] = "threeeighths"; +static const char glyph_threeinferior[] = "threeinferior"; +static const char glyph_threeoldstyle[] = "threeoldstyle"; +static const char glyph_threequarters[] = "threequarters"; +static const char glyph_threequartersemdash[] = "threequartersemdash"; +static const char glyph_threesuperior[] = "threesuperior"; +static const char glyph_tilde[] = "tilde"; +static const char glyph_tildecomb[] = "tildecomb"; +static const char glyph_tonos[] = "tonos"; +static const char glyph_trademark[] = "trademark"; +static const char glyph_trademarksans[] = "trademarksans"; +static const char glyph_trademarkserif[] = "trademarkserif"; +static const char glyph_triagdn[] = "triagdn"; +static const char glyph_triaglf[] = "triaglf"; +static const char glyph_triagrt[] = "triagrt"; +static const char glyph_triagup[] = "triagup"; +static const char glyph_tsuperior[] = "tsuperior"; +static const char glyph_two[] = "two"; +static const char glyph_twodotenleader[] = "twodotenleader"; +static const char glyph_twoinferior[] = "twoinferior"; +static const char glyph_twooldstyle[] = "twooldstyle"; +static const char glyph_twosuperior[] = "twosuperior"; +static const char glyph_twothirds[] = "twothirds"; +static const char glyph_u[] = "u"; +static const char glyph_uacute[] = "uacute"; +static const char glyph_ubreve[] = "ubreve"; +static const char glyph_ucircumflex[] = "ucircumflex"; +static const char glyph_udieresis[] = "udieresis"; +static const char glyph_ugrave[] = "ugrave"; +static const char glyph_uhorn[] = "uhorn"; +static const char glyph_uhungarumlaut[] = "uhungarumlaut"; +static const char glyph_umacron[] = "umacron"; +static const char glyph_underscore[] = "underscore"; +static const char glyph_underscoredbl[] = "underscoredbl"; +static const char glyph_union[] = "union"; +static const char glyph_universal[] = "universal"; +static const char glyph_uogonek[] = "uogonek"; +static const char glyph_upblock[] = "upblock"; +static const char glyph_upsilon[] = "upsilon"; +static const char glyph_upsilondieresis[] = "upsilondieresis"; +static const char glyph_upsilondieresistonos[] = "upsilondieresistonos"; +static const char glyph_upsilontonos[] = "upsilontonos"; +static const char glyph_uring[] = "uring"; +static const char glyph_utilde[] = "utilde"; +static const char glyph_v[] = "v"; +static const char glyph_w[] = "w"; +static const char glyph_wacute[] = "wacute"; +static const char glyph_wcircumflex[] = "wcircumflex"; +static const char glyph_wdieresis[] = "wdieresis"; +static const char glyph_weierstrass[] = "weierstrass"; +static const char glyph_wgrave[] = "wgrave"; +static const char glyph_x[] = "x"; +static const char glyph_xi[] = "xi"; +static const char glyph_y[] = "y"; +static const char glyph_yacute[] = "yacute"; +static const char glyph_ycircumflex[] = "ycircumflex"; +static const char glyph_ydieresis[] = "ydieresis"; +static const char glyph_yen[] = "yen"; +static const char glyph_ygrave[] = "ygrave"; +static const char glyph_z[] = "z"; +static const char glyph_zacute[] = "zacute"; +static const char glyph_zcaron[] = "zcaron"; +static const char glyph_zdotaccent[] = "zdotaccent"; +static const char glyph_zero[] = "zero"; +static const char glyph_zeroinferior[] = "zeroinferior"; +static const char glyph_zerooldstyle[] = "zerooldstyle"; +static const char glyph_zerosuperior[] = "zerosuperior"; +static const char glyph_zeta[] = "zeta"; + +/* Glyph names without Unicode values */ +static const char glyph_001_000[] = "001.000"; +static const char glyph_001_001[] = "001.001"; +static const char glyph_001_002[] = "001.002"; +static const char glyph_001_003[] = "001.003"; +static const char glyph_Black[] = "Black"; +static const char glyph_Bold[] = "Bold"; +static const char glyph_Book[] = "Book"; +static const char glyph_Light[] = "Light"; +static const char glyph_Medium[] = "Medium"; +static const char glyph_Regular[] = "Regular"; +static const char glyph_Roman[] = "Roman"; +static const char glyph_Semibold[] = "Semibold"; + +/* table sorted by names */ +static pdc_glyph_tab tab_agl2uni[] = +{ +#ifndef PDFLIB_EBCDIC + { 0x0000, glyph__notdef }, + { 0x0041, glyph_A }, + { 0x00C6, glyph_AE }, + { 0x01FC, glyph_AEacute }, + { 0xF7E6, glyph_AEsmall }, + { 0x00C1, glyph_Aacute }, + { 0xF7E1, glyph_Aacutesmall }, + { 0x0102, glyph_Abreve }, + { 0x00C2, glyph_Acircumflex }, + { 0xF7E2, glyph_Acircumflexsmall }, + { 0xF6C9, glyph_Acute }, + { 0xF7B4, glyph_Acutesmall }, + { 0x00C4, glyph_Adieresis }, + { 0xF7E4, glyph_Adieresissmall }, + { 0x00C0, glyph_Agrave }, + { 0xF7E0, glyph_Agravesmall }, + { 0x0391, glyph_Alpha }, + { 0x0386, glyph_Alphatonos }, + { 0x0100, glyph_Amacron }, + { 0x0104, glyph_Aogonek }, + { 0x00C5, glyph_Aring }, + { 0x01FA, glyph_Aringacute }, + { 0xF7E5, glyph_Aringsmall }, + { 0xF761, glyph_Asmall }, + { 0x00C3, glyph_Atilde }, + { 0xF7E3, glyph_Atildesmall }, + { 0x0042, glyph_B }, + { 0x0392, glyph_Beta }, + { 0xF6F4, glyph_Brevesmall }, + { 0xF762, glyph_Bsmall }, + { 0x0043, glyph_C }, + { 0x0106, glyph_Cacute }, + { 0xF6CA, glyph_Caron }, + { 0xF6F5, glyph_Caronsmall }, + { 0x010C, glyph_Ccaron }, + { 0x00C7, glyph_Ccedilla }, + { 0xF7E7, glyph_Ccedillasmall }, + { 0x0108, glyph_Ccircumflex }, + { 0x010A, glyph_Cdotaccent }, + { 0xF7B8, glyph_Cedillasmall }, + { 0x03A7, glyph_Chi }, + { 0xF6F6, glyph_Circumflexsmall }, + { 0xF763, glyph_Csmall }, + { 0x0044, glyph_D }, + { 0x010E, glyph_Dcaron }, + { 0x0110, glyph_Dcroat }, +/* { 0x2206, glyph_Delta }, duplicate code */ + { 0x0394, glyph_Delta }, + { 0xF6CB, glyph_Dieresis }, + { 0xF6CC, glyph_DieresisAcute }, + { 0xF6CD, glyph_DieresisGrave }, + { 0xF7A8, glyph_Dieresissmall }, + { 0xF6F7, glyph_Dotaccentsmall }, + { 0xF764, glyph_Dsmall }, + { 0x0045, glyph_E }, + { 0x00C9, glyph_Eacute }, + { 0xF7E9, glyph_Eacutesmall }, + { 0x0114, glyph_Ebreve }, + { 0x011A, glyph_Ecaron }, + { 0x00CA, glyph_Ecircumflex }, + { 0xF7EA, glyph_Ecircumflexsmall }, + { 0x00CB, glyph_Edieresis }, + { 0xF7EB, glyph_Edieresissmall }, + { 0x0116, glyph_Edotaccent }, + { 0x00C8, glyph_Egrave }, + { 0xF7E8, glyph_Egravesmall }, + { 0x0112, glyph_Emacron }, + { 0x014A, glyph_Eng }, + { 0x0118, glyph_Eogonek }, + { 0x0395, glyph_Epsilon }, + { 0x0388, glyph_Epsilontonos }, + { 0xF765, glyph_Esmall }, + { 0x0397, glyph_Eta }, + { 0x0389, glyph_Etatonos }, + { 0x00D0, glyph_Eth }, + { 0xF7F0, glyph_Ethsmall }, + { 0x20AC, glyph_Euro }, + { 0x0046, glyph_F }, + { 0xF766, glyph_Fsmall }, + { 0x0047, glyph_G }, + { 0x0393, glyph_Gamma }, + { 0x011E, glyph_Gbreve }, + { 0x01E6, glyph_Gcaron }, + { 0x011C, glyph_Gcircumflex }, + { 0x0122, glyph_Gcommaaccent }, + { 0x0120, glyph_Gdotaccent }, + { 0xF6CE, glyph_Grave }, + { 0xF760, glyph_Gravesmall }, + { 0xF767, glyph_Gsmall }, + { 0x0048, glyph_H }, + { 0x25CF, glyph_H18533 }, + { 0x25AA, glyph_H18543 }, + { 0x25AB, glyph_H18551 }, + { 0x25A1, glyph_H22073 }, + { 0x0126, glyph_Hbar }, + { 0x0124, glyph_Hcircumflex }, + { 0xF768, glyph_Hsmall }, + { 0xF6CF, glyph_Hungarumlaut }, + { 0xF6F8, glyph_Hungarumlautsmall }, + { 0x0049, glyph_I }, + { 0x0132, glyph_IJ }, + { 0x00CD, glyph_Iacute }, + { 0xF7ED, glyph_Iacutesmall }, + { 0x012C, glyph_Ibreve }, + { 0x00CE, glyph_Icircumflex }, + { 0xF7EE, glyph_Icircumflexsmall }, + { 0x00CF, glyph_Idieresis }, + { 0xF7EF, glyph_Idieresissmall }, + { 0x0130, glyph_Idotaccent }, + { 0x2111, glyph_Ifraktur }, + { 0x00CC, glyph_Igrave }, + { 0xF7EC, glyph_Igravesmall }, + { 0x012A, glyph_Imacron }, + { 0x012E, glyph_Iogonek }, + { 0x0399, glyph_Iota }, + { 0x03AA, glyph_Iotadieresis }, + { 0x038A, glyph_Iotatonos }, + { 0xF769, glyph_Ismall }, + { 0x0128, glyph_Itilde }, + { 0x004A, glyph_J }, + { 0x0134, glyph_Jcircumflex }, + { 0xF76A, glyph_Jsmall }, + { 0x004B, glyph_K }, + { 0x039A, glyph_Kappa }, + { 0x0136, glyph_Kcommaaccent }, + { 0xF76B, glyph_Ksmall }, + { 0x004C, glyph_L }, + { 0xF6BF, glyph_LL }, + { 0x0139, glyph_Lacute }, + { 0x039B, glyph_Lambda }, + { 0x013D, glyph_Lcaron }, + { 0x013B, glyph_Lcommaaccent }, + { 0x013F, glyph_Ldot }, + { 0x0141, glyph_Lslash }, + { 0xF6F9, glyph_Lslashsmall }, + { 0xF76C, glyph_Lsmall }, + { 0x004D, glyph_M }, + { 0xF6D0, glyph_Macron }, + { 0xF7AF, glyph_Macronsmall }, + { 0xF76D, glyph_Msmall }, + { 0x039C, glyph_Mu }, + { 0x004E, glyph_N }, + { 0x0143, glyph_Nacute }, + { 0x0147, glyph_Ncaron }, + { 0x0145, glyph_Ncommaaccent }, + { 0xF76E, glyph_Nsmall }, + { 0x00D1, glyph_Ntilde }, + { 0xF7F1, glyph_Ntildesmall }, + { 0x039D, glyph_Nu }, + { 0x004F, glyph_O }, + { 0x0152, glyph_OE }, + { 0xF6FA, glyph_OEsmall }, + { 0x00D3, glyph_Oacute }, + { 0xF7F3, glyph_Oacutesmall }, + { 0x014E, glyph_Obreve }, + { 0x00D4, glyph_Ocircumflex }, + { 0xF7F4, glyph_Ocircumflexsmall }, + { 0x00D6, glyph_Odieresis }, + { 0xF7F6, glyph_Odieresissmall }, + { 0xF6FB, glyph_Ogoneksmall }, + { 0x00D2, glyph_Ograve }, + { 0xF7F2, glyph_Ogravesmall }, + { 0x01A0, glyph_Ohorn }, + { 0x0150, glyph_Ohungarumlaut }, + { 0x014C, glyph_Omacron }, +/* { 0x2126, glyph_Omega }, duplicate code */ + { 0x03A9, glyph_Omega }, + { 0x038F, glyph_Omegatonos }, + { 0x039F, glyph_Omicron }, + { 0x038C, glyph_Omicrontonos }, + { 0x00D8, glyph_Oslash }, + { 0x01FE, glyph_Oslashacute }, + { 0xF7F8, glyph_Oslashsmall }, + { 0xF76F, glyph_Osmall }, + { 0x00D5, glyph_Otilde }, + { 0xF7F5, glyph_Otildesmall }, + { 0x0050, glyph_P }, + { 0x03A6, glyph_Phi }, + { 0x03A0, glyph_Pi }, + { 0x03A8, glyph_Psi }, + { 0xF770, glyph_Psmall }, + { 0x0051, glyph_Q }, + { 0xF771, glyph_Qsmall }, + { 0x0052, glyph_R }, + { 0x0154, glyph_Racute }, + { 0x0158, glyph_Rcaron }, + { 0x0156, glyph_Rcommaaccent }, + { 0x211C, glyph_Rfraktur }, + { 0x03A1, glyph_Rho }, + { 0xF6FC, glyph_Ringsmall }, + { 0xF772, glyph_Rsmall }, + { 0x0053, glyph_S }, + { 0x250C, glyph_SF010000 }, + { 0x2514, glyph_SF020000 }, + { 0x2510, glyph_SF030000 }, + { 0x2518, glyph_SF040000 }, + { 0x253C, glyph_SF050000 }, + { 0x252C, glyph_SF060000 }, + { 0x2534, glyph_SF070000 }, + { 0x251C, glyph_SF080000 }, + { 0x2524, glyph_SF090000 }, + { 0x2500, glyph_SF100000 }, + { 0x2502, glyph_SF110000 }, + { 0x2561, glyph_SF190000 }, + { 0x2562, glyph_SF200000 }, + { 0x2556, glyph_SF210000 }, + { 0x2555, glyph_SF220000 }, + { 0x2563, glyph_SF230000 }, + { 0x2551, glyph_SF240000 }, + { 0x2557, glyph_SF250000 }, + { 0x255D, glyph_SF260000 }, + { 0x255C, glyph_SF270000 }, + { 0x255B, glyph_SF280000 }, + { 0x255E, glyph_SF360000 }, + { 0x255F, glyph_SF370000 }, + { 0x255A, glyph_SF380000 }, + { 0x2554, glyph_SF390000 }, + { 0x2569, glyph_SF400000 }, + { 0x2566, glyph_SF410000 }, + { 0x2560, glyph_SF420000 }, + { 0x2550, glyph_SF430000 }, + { 0x256C, glyph_SF440000 }, + { 0x2567, glyph_SF450000 }, + { 0x2568, glyph_SF460000 }, + { 0x2564, glyph_SF470000 }, + { 0x2565, glyph_SF480000 }, + { 0x2559, glyph_SF490000 }, + { 0x2558, glyph_SF500000 }, + { 0x2552, glyph_SF510000 }, + { 0x2553, glyph_SF520000 }, + { 0x256B, glyph_SF530000 }, + { 0x256A, glyph_SF540000 }, + { 0x015A, glyph_Sacute }, + { 0x0160, glyph_Scaron }, + { 0xF6FD, glyph_Scaronsmall }, + { 0x015E, glyph_Scedilla }, +/* { 0xF6C1, glyph_Scedilla }, duplicate code */ + { 0x015C, glyph_Scircumflex }, + { 0x0218, glyph_Scommaaccent }, + { 0x03A3, glyph_Sigma }, + { 0xF773, glyph_Ssmall }, + { 0x0054, glyph_T }, + { 0x03A4, glyph_Tau }, + { 0x0166, glyph_Tbar }, + { 0x0164, glyph_Tcaron }, + { 0x0162, glyph_Tcommaaccent }, +/* { 0x021A, glyph_Tcommaaccent }, duplicate code */ + { 0x0398, glyph_Theta }, + { 0x00DE, glyph_Thorn }, + { 0xF7FE, glyph_Thornsmall }, + { 0xF6FE, glyph_Tildesmall }, + { 0xF774, glyph_Tsmall }, + { 0x0055, glyph_U }, + { 0x00DA, glyph_Uacute }, + { 0xF7FA, glyph_Uacutesmall }, + { 0x016C, glyph_Ubreve }, + { 0x00DB, glyph_Ucircumflex }, + { 0xF7FB, glyph_Ucircumflexsmall }, + { 0x00DC, glyph_Udieresis }, + { 0xF7FC, glyph_Udieresissmall }, + { 0x00D9, glyph_Ugrave }, + { 0xF7F9, glyph_Ugravesmall }, + { 0x01AF, glyph_Uhorn }, + { 0x0170, glyph_Uhungarumlaut }, + { 0x016A, glyph_Umacron }, + { 0x0172, glyph_Uogonek }, + { 0x03A5, glyph_Upsilon }, + { 0x03D2, glyph_Upsilon1 }, + { 0x03AB, glyph_Upsilondieresis }, + { 0x038E, glyph_Upsilontonos }, + { 0x016E, glyph_Uring }, + { 0xF775, glyph_Usmall }, + { 0x0168, glyph_Utilde }, + { 0x0056, glyph_V }, + { 0xF776, glyph_Vsmall }, + { 0x0057, glyph_W }, + { 0x1E82, glyph_Wacute }, + { 0x0174, glyph_Wcircumflex }, + { 0x1E84, glyph_Wdieresis }, + { 0x1E80, glyph_Wgrave }, + { 0xF777, glyph_Wsmall }, + { 0x0058, glyph_X }, + { 0x039E, glyph_Xi }, + { 0xF778, glyph_Xsmall }, + { 0x0059, glyph_Y }, + { 0x00DD, glyph_Yacute }, + { 0xF7FD, glyph_Yacutesmall }, + { 0x0176, glyph_Ycircumflex }, + { 0x0178, glyph_Ydieresis }, + { 0xF7FF, glyph_Ydieresissmall }, + { 0x1EF2, glyph_Ygrave }, + { 0xF779, glyph_Ysmall }, + { 0x005A, glyph_Z }, + { 0x0179, glyph_Zacute }, + { 0x017D, glyph_Zcaron }, + { 0xF6FF, glyph_Zcaronsmall }, + { 0x017B, glyph_Zdotaccent }, + { 0x0396, glyph_Zeta }, + { 0xF77A, glyph_Zsmall }, + { 0x0061, glyph_a }, + { 0x00E1, glyph_aacute }, + { 0x0103, glyph_abreve }, + { 0x00E2, glyph_acircumflex }, + { 0x00B4, glyph_acute }, + { 0x0301, glyph_acutecomb }, + { 0x00E4, glyph_adieresis }, + { 0x00E6, glyph_ae }, + { 0x01FD, glyph_aeacute }, + { 0x2015, glyph_afii00208 }, + { 0x0410, glyph_afii10017 }, + { 0x0411, glyph_afii10018 }, + { 0x0412, glyph_afii10019 }, + { 0x0413, glyph_afii10020 }, + { 0x0414, glyph_afii10021 }, + { 0x0415, glyph_afii10022 }, + { 0x0401, glyph_afii10023 }, + { 0x0416, glyph_afii10024 }, + { 0x0417, glyph_afii10025 }, + { 0x0418, glyph_afii10026 }, + { 0x0419, glyph_afii10027 }, + { 0x041A, glyph_afii10028 }, + { 0x041B, glyph_afii10029 }, + { 0x041C, glyph_afii10030 }, + { 0x041D, glyph_afii10031 }, + { 0x041E, glyph_afii10032 }, + { 0x041F, glyph_afii10033 }, + { 0x0420, glyph_afii10034 }, + { 0x0421, glyph_afii10035 }, + { 0x0422, glyph_afii10036 }, + { 0x0423, glyph_afii10037 }, + { 0x0424, glyph_afii10038 }, + { 0x0425, glyph_afii10039 }, + { 0x0426, glyph_afii10040 }, + { 0x0427, glyph_afii10041 }, + { 0x0428, glyph_afii10042 }, + { 0x0429, glyph_afii10043 }, + { 0x042A, glyph_afii10044 }, + { 0x042B, glyph_afii10045 }, + { 0x042C, glyph_afii10046 }, + { 0x042D, glyph_afii10047 }, + { 0x042E, glyph_afii10048 }, + { 0x042F, glyph_afii10049 }, + { 0x0490, glyph_afii10050 }, + { 0x0402, glyph_afii10051 }, + { 0x0403, glyph_afii10052 }, + { 0x0404, glyph_afii10053 }, + { 0x0405, glyph_afii10054 }, + { 0x0406, glyph_afii10055 }, + { 0x0407, glyph_afii10056 }, + { 0x0408, glyph_afii10057 }, + { 0x0409, glyph_afii10058 }, + { 0x040A, glyph_afii10059 }, + { 0x040B, glyph_afii10060 }, + { 0x040C, glyph_afii10061 }, + { 0x040E, glyph_afii10062 }, + { 0xF6C4, glyph_afii10063 }, + { 0xF6C5, glyph_afii10064 }, + { 0x0430, glyph_afii10065 }, + { 0x0431, glyph_afii10066 }, + { 0x0432, glyph_afii10067 }, + { 0x0433, glyph_afii10068 }, + { 0x0434, glyph_afii10069 }, + { 0x0435, glyph_afii10070 }, + { 0x0451, glyph_afii10071 }, + { 0x0436, glyph_afii10072 }, + { 0x0437, glyph_afii10073 }, + { 0x0438, glyph_afii10074 }, + { 0x0439, glyph_afii10075 }, + { 0x043A, glyph_afii10076 }, + { 0x043B, glyph_afii10077 }, + { 0x043C, glyph_afii10078 }, + { 0x043D, glyph_afii10079 }, + { 0x043E, glyph_afii10080 }, + { 0x043F, glyph_afii10081 }, + { 0x0440, glyph_afii10082 }, + { 0x0441, glyph_afii10083 }, + { 0x0442, glyph_afii10084 }, + { 0x0443, glyph_afii10085 }, + { 0x0444, glyph_afii10086 }, + { 0x0445, glyph_afii10087 }, + { 0x0446, glyph_afii10088 }, + { 0x0447, glyph_afii10089 }, + { 0x0448, glyph_afii10090 }, + { 0x0449, glyph_afii10091 }, + { 0x044A, glyph_afii10092 }, + { 0x044B, glyph_afii10093 }, + { 0x044C, glyph_afii10094 }, + { 0x044D, glyph_afii10095 }, + { 0x044E, glyph_afii10096 }, + { 0x044F, glyph_afii10097 }, + { 0x0491, glyph_afii10098 }, + { 0x0452, glyph_afii10099 }, + { 0x0453, glyph_afii10100 }, + { 0x0454, glyph_afii10101 }, + { 0x0455, glyph_afii10102 }, + { 0x0456, glyph_afii10103 }, + { 0x0457, glyph_afii10104 }, + { 0x0458, glyph_afii10105 }, + { 0x0459, glyph_afii10106 }, + { 0x045A, glyph_afii10107 }, + { 0x045B, glyph_afii10108 }, + { 0x045C, glyph_afii10109 }, + { 0x045E, glyph_afii10110 }, + { 0x040F, glyph_afii10145 }, + { 0x0462, glyph_afii10146 }, + { 0x0472, glyph_afii10147 }, + { 0x0474, glyph_afii10148 }, + { 0xF6C6, glyph_afii10192 }, + { 0x045F, glyph_afii10193 }, + { 0x0463, glyph_afii10194 }, + { 0x0473, glyph_afii10195 }, + { 0x0475, glyph_afii10196 }, + { 0xF6C7, glyph_afii10831 }, + { 0xF6C8, glyph_afii10832 }, + { 0x04D9, glyph_afii10846 }, + { 0x200E, glyph_afii299 }, + { 0x200F, glyph_afii300 }, + { 0x200D, glyph_afii301 }, + { 0x066A, glyph_afii57381 }, + { 0x060C, glyph_afii57388 }, + { 0x0660, glyph_afii57392 }, + { 0x0661, glyph_afii57393 }, + { 0x0662, glyph_afii57394 }, + { 0x0663, glyph_afii57395 }, + { 0x0664, glyph_afii57396 }, + { 0x0665, glyph_afii57397 }, + { 0x0666, glyph_afii57398 }, + { 0x0667, glyph_afii57399 }, + { 0x0668, glyph_afii57400 }, + { 0x0669, glyph_afii57401 }, + { 0x061B, glyph_afii57403 }, + { 0x061F, glyph_afii57407 }, + { 0x0621, glyph_afii57409 }, + { 0x0622, glyph_afii57410 }, + { 0x0623, glyph_afii57411 }, + { 0x0624, glyph_afii57412 }, + { 0x0625, glyph_afii57413 }, + { 0x0626, glyph_afii57414 }, + { 0x0627, glyph_afii57415 }, + { 0x0628, glyph_afii57416 }, + { 0x0629, glyph_afii57417 }, + { 0x062A, glyph_afii57418 }, + { 0x062B, glyph_afii57419 }, + { 0x062C, glyph_afii57420 }, + { 0x062D, glyph_afii57421 }, + { 0x062E, glyph_afii57422 }, + { 0x062F, glyph_afii57423 }, + { 0x0630, glyph_afii57424 }, + { 0x0631, glyph_afii57425 }, + { 0x0632, glyph_afii57426 }, + { 0x0633, glyph_afii57427 }, + { 0x0634, glyph_afii57428 }, + { 0x0635, glyph_afii57429 }, + { 0x0636, glyph_afii57430 }, + { 0x0637, glyph_afii57431 }, + { 0x0638, glyph_afii57432 }, + { 0x0639, glyph_afii57433 }, + { 0x063A, glyph_afii57434 }, + { 0x0640, glyph_afii57440 }, + { 0x0641, glyph_afii57441 }, + { 0x0642, glyph_afii57442 }, + { 0x0643, glyph_afii57443 }, + { 0x0644, glyph_afii57444 }, + { 0x0645, glyph_afii57445 }, + { 0x0646, glyph_afii57446 }, + { 0x0648, glyph_afii57448 }, + { 0x0649, glyph_afii57449 }, + { 0x064A, glyph_afii57450 }, + { 0x064B, glyph_afii57451 }, + { 0x064C, glyph_afii57452 }, + { 0x064D, glyph_afii57453 }, + { 0x064E, glyph_afii57454 }, + { 0x064F, glyph_afii57455 }, + { 0x0650, glyph_afii57456 }, + { 0x0651, glyph_afii57457 }, + { 0x0652, glyph_afii57458 }, + { 0x0647, glyph_afii57470 }, + { 0x06A4, glyph_afii57505 }, + { 0x067E, glyph_afii57506 }, + { 0x0686, glyph_afii57507 }, + { 0x0698, glyph_afii57508 }, + { 0x06AF, glyph_afii57509 }, + { 0x0679, glyph_afii57511 }, + { 0x0688, glyph_afii57512 }, + { 0x0691, glyph_afii57513 }, + { 0x06BA, glyph_afii57514 }, + { 0x06D2, glyph_afii57519 }, + { 0x06D5, glyph_afii57534 }, + { 0x20AA, glyph_afii57636 }, + { 0x05BE, glyph_afii57645 }, + { 0x05C3, glyph_afii57658 }, + { 0x05D0, glyph_afii57664 }, + { 0x05D1, glyph_afii57665 }, + { 0x05D2, glyph_afii57666 }, + { 0x05D3, glyph_afii57667 }, + { 0x05D4, glyph_afii57668 }, + { 0x05D5, glyph_afii57669 }, + { 0x05D6, glyph_afii57670 }, + { 0x05D7, glyph_afii57671 }, + { 0x05D8, glyph_afii57672 }, + { 0x05D9, glyph_afii57673 }, + { 0x05DA, glyph_afii57674 }, + { 0x05DB, glyph_afii57675 }, + { 0x05DC, glyph_afii57676 }, + { 0x05DD, glyph_afii57677 }, + { 0x05DE, glyph_afii57678 }, + { 0x05DF, glyph_afii57679 }, + { 0x05E0, glyph_afii57680 }, + { 0x05E1, glyph_afii57681 }, + { 0x05E2, glyph_afii57682 }, + { 0x05E3, glyph_afii57683 }, + { 0x05E4, glyph_afii57684 }, + { 0x05E5, glyph_afii57685 }, + { 0x05E6, glyph_afii57686 }, + { 0x05E7, glyph_afii57687 }, + { 0x05E8, glyph_afii57688 }, + { 0x05E9, glyph_afii57689 }, + { 0x05EA, glyph_afii57690 }, + { 0xFB2A, glyph_afii57694 }, + { 0xFB2B, glyph_afii57695 }, + { 0xFB4B, glyph_afii57700 }, + { 0xFB1F, glyph_afii57705 }, + { 0x05F0, glyph_afii57716 }, + { 0x05F1, glyph_afii57717 }, + { 0x05F2, glyph_afii57718 }, + { 0xFB35, glyph_afii57723 }, + { 0x05B4, glyph_afii57793 }, + { 0x05B5, glyph_afii57794 }, + { 0x05B6, glyph_afii57795 }, + { 0x05BB, glyph_afii57796 }, + { 0x05B8, glyph_afii57797 }, + { 0x05B7, glyph_afii57798 }, + { 0x05B0, glyph_afii57799 }, + { 0x05B2, glyph_afii57800 }, + { 0x05B1, glyph_afii57801 }, + { 0x05B3, glyph_afii57802 }, + { 0x05C2, glyph_afii57803 }, + { 0x05C1, glyph_afii57804 }, + { 0x05B9, glyph_afii57806 }, + { 0x05BC, glyph_afii57807 }, + { 0x05BD, glyph_afii57839 }, + { 0x05BF, glyph_afii57841 }, + { 0x05C0, glyph_afii57842 }, + { 0x02BC, glyph_afii57929 }, + { 0x2105, glyph_afii61248 }, + { 0x2113, glyph_afii61289 }, + { 0x2116, glyph_afii61352 }, + { 0x202C, glyph_afii61573 }, + { 0x202D, glyph_afii61574 }, + { 0x202E, glyph_afii61575 }, + { 0x200C, glyph_afii61664 }, + { 0x066D, glyph_afii63167 }, + { 0x02BD, glyph_afii64937 }, + { 0x00E0, glyph_agrave }, + { 0x2135, glyph_aleph }, + { 0x03B1, glyph_alpha }, + { 0x03AC, glyph_alphatonos }, + { 0x0101, glyph_amacron }, + { 0x0026, glyph_ampersand }, + { 0xF726, glyph_ampersandsmall }, + { 0x2220, glyph_angle }, + { 0x2329, glyph_angleleft }, + { 0x232A, glyph_angleright }, + { 0x0387, glyph_anoteleia }, + { 0x0105, glyph_aogonek }, + { 0x2248, glyph_approxequal }, + { 0x00E5, glyph_aring }, + { 0x01FB, glyph_aringacute }, + { 0x2194, glyph_arrowboth }, + { 0x21D4, glyph_arrowdblboth }, + { 0x21D3, glyph_arrowdbldown }, + { 0x21D0, glyph_arrowdblleft }, + { 0x21D2, glyph_arrowdblright }, + { 0x21D1, glyph_arrowdblup }, + { 0x2193, glyph_arrowdown }, + { 0xF8E7, glyph_arrowhorizex }, + { 0x2190, glyph_arrowleft }, + { 0x2192, glyph_arrowright }, + { 0x2191, glyph_arrowup }, + { 0x2195, glyph_arrowupdn }, + { 0x21A8, glyph_arrowupdnbse }, + { 0xF8E6, glyph_arrowvertex }, + { 0x005E, glyph_asciicircum }, + { 0x007E, glyph_asciitilde }, + { 0x002A, glyph_asterisk }, + { 0x2217, glyph_asteriskmath }, + { 0xF6E9, glyph_asuperior }, + { 0x0040, glyph_at }, + { 0x00E3, glyph_atilde }, + { 0x0062, glyph_b }, + { 0x005C, glyph_backslash }, + { 0x007C, glyph_bar }, + { 0x03B2, glyph_beta }, + { 0x2588, glyph_block }, + { 0xF8F4, glyph_braceex }, + { 0x007B, glyph_braceleft }, + { 0xF8F3, glyph_braceleftbt }, + { 0xF8F2, glyph_braceleftmid }, + { 0xF8F1, glyph_bracelefttp }, + { 0x007D, glyph_braceright }, + { 0xF8FE, glyph_bracerightbt }, + { 0xF8FD, glyph_bracerightmid }, + { 0xF8FC, glyph_bracerighttp }, + { 0x005B, glyph_bracketleft }, + { 0xF8F0, glyph_bracketleftbt }, + { 0xF8EF, glyph_bracketleftex }, + { 0xF8EE, glyph_bracketlefttp }, + { 0x005D, glyph_bracketright }, + { 0xF8FB, glyph_bracketrightbt }, + { 0xF8FA, glyph_bracketrightex }, + { 0xF8F9, glyph_bracketrighttp }, + { 0x02D8, glyph_breve }, + { 0x00A6, glyph_brokenbar }, + { 0xF6EA, glyph_bsuperior }, + { 0x2022, glyph_bullet }, + { 0x0063, glyph_c }, + { 0x0107, glyph_cacute }, + { 0x02C7, glyph_caron }, + { 0x21B5, glyph_carriagereturn }, + { 0x010D, glyph_ccaron }, + { 0x00E7, glyph_ccedilla }, + { 0x0109, glyph_ccircumflex }, + { 0x010B, glyph_cdotaccent }, + { 0x00B8, glyph_cedilla }, + { 0x00A2, glyph_cent }, + { 0xF6DF, glyph_centinferior }, + { 0xF7A2, glyph_centoldstyle }, + { 0xF6E0, glyph_centsuperior }, + { 0x03C7, glyph_chi }, + { 0x25CB, glyph_circle }, + { 0x2297, glyph_circlemultiply }, + { 0x2295, glyph_circleplus }, + { 0x02C6, glyph_circumflex }, + { 0x2663, glyph_club }, + { 0x003A, glyph_colon }, + { 0x20A1, glyph_colonmonetary }, + { 0x002C, glyph_comma }, + { 0xF6C3, glyph_commaaccent }, + { 0xF6E1, glyph_commainferior }, + { 0xF6E2, glyph_commasuperior }, + { 0x2245, glyph_congruent }, + { 0x00A9, glyph_copyright }, + { 0xF8E9, glyph_copyrightsans }, + { 0xF6D9, glyph_copyrightserif }, + { 0x00A4, glyph_currency }, + { 0xF6D1, glyph_cyrBreve }, + { 0xF6D2, glyph_cyrFlex }, + { 0xF6D4, glyph_cyrbreve }, + { 0xF6D5, glyph_cyrflex }, + { 0x0064, glyph_d }, + { 0x2020, glyph_dagger }, + { 0x2021, glyph_daggerdbl }, + { 0xF6D3, glyph_dblGrave }, + { 0xF6D6, glyph_dblgrave }, + { 0x010F, glyph_dcaron }, + { 0x0111, glyph_dcroat }, + { 0x00B0, glyph_degree }, + { 0x03B4, glyph_delta }, + { 0x2666, glyph_diamond }, + { 0x00A8, glyph_dieresis }, + { 0xF6D7, glyph_dieresisacute }, + { 0xF6D8, glyph_dieresisgrave }, + { 0x0385, glyph_dieresistonos }, + { 0x00F7, glyph_divide }, + { 0x2593, glyph_dkshade }, + { 0x2584, glyph_dnblock }, + { 0x0024, glyph_dollar }, + { 0xF6E3, glyph_dollarinferior }, + { 0xF724, glyph_dollaroldstyle }, + { 0xF6E4, glyph_dollarsuperior }, + { 0x20AB, glyph_dong }, + { 0x02D9, glyph_dotaccent }, + { 0x0323, glyph_dotbelowcomb }, + { 0x0131, glyph_dotlessi }, + { 0xF6BE, glyph_dotlessj }, + { 0x22C5, glyph_dotmath }, + { 0xF6EB, glyph_dsuperior }, + { 0x0065, glyph_e }, + { 0x00E9, glyph_eacute }, + { 0x0115, glyph_ebreve }, + { 0x011B, glyph_ecaron }, + { 0x00EA, glyph_ecircumflex }, + { 0x00EB, glyph_edieresis }, + { 0x0117, glyph_edotaccent }, + { 0x00E8, glyph_egrave }, + { 0x0038, glyph_eight }, + { 0x2088, glyph_eightinferior }, + { 0xF738, glyph_eightoldstyle }, + { 0x2078, glyph_eightsuperior }, + { 0x2208, glyph_element }, + { 0x2026, glyph_ellipsis }, + { 0x0113, glyph_emacron }, + { 0x2014, glyph_emdash }, + { 0x2205, glyph_emptyset }, + { 0x2013, glyph_endash }, + { 0x014B, glyph_eng }, + { 0x0119, glyph_eogonek }, + { 0x03B5, glyph_epsilon }, + { 0x03AD, glyph_epsilontonos }, + { 0x003D, glyph_equal }, + { 0x2261, glyph_equivalence }, + { 0x212E, glyph_estimated }, + { 0xF6EC, glyph_esuperior }, + { 0x03B7, glyph_eta }, + { 0x03AE, glyph_etatonos }, + { 0x00F0, glyph_eth }, + { 0x0021, glyph_exclam }, + { 0x203C, glyph_exclamdbl }, + { 0x00A1, glyph_exclamdown }, + { 0xF7A1, glyph_exclamdownsmall }, + { 0xF721, glyph_exclamsmall }, + { 0x2203, glyph_existential }, + { 0x0066, glyph_f }, + { 0x2640, glyph_female }, + { 0xFB00, glyph_ff }, + { 0xFB03, glyph_ffi }, + { 0xFB04, glyph_ffl }, + { 0xFB01, glyph_fi }, + { 0x2012, glyph_figuredash }, + { 0x25A0, glyph_filledbox }, + { 0x25AC, glyph_filledrect }, + { 0x0035, glyph_five }, + { 0x215D, glyph_fiveeighths }, + { 0x2085, glyph_fiveinferior }, + { 0xF735, glyph_fiveoldstyle }, + { 0x2075, glyph_fivesuperior }, + { 0xFB02, glyph_fl }, + { 0x0192, glyph_florin }, + { 0x0034, glyph_four }, + { 0x2084, glyph_fourinferior }, + { 0xF734, glyph_fouroldstyle }, + { 0x2074, glyph_foursuperior }, + { 0x2044, glyph_fraction }, +/* { 0x2215, glyph_fraction }, duplicate name */ + { 0x20A3, glyph_franc }, + { 0x0067, glyph_g }, + { 0x03B3, glyph_gamma }, + { 0x011F, glyph_gbreve }, + { 0x01E7, glyph_gcaron }, + { 0x011D, glyph_gcircumflex }, + { 0x0123, glyph_gcommaaccent }, + { 0x0121, glyph_gdotaccent }, + { 0x00DF, glyph_germandbls }, + { 0x2207, glyph_gradient }, + { 0x0060, glyph_grave }, + { 0x0300, glyph_gravecomb }, + { 0x003E, glyph_greater }, + { 0x2265, glyph_greaterequal }, + { 0x00AB, glyph_guillemotleft }, + { 0x00BB, glyph_guillemotright }, + { 0x2039, glyph_guilsinglleft }, + { 0x203A, glyph_guilsinglright }, + { 0x0068, glyph_h }, + { 0x0127, glyph_hbar }, + { 0x0125, glyph_hcircumflex }, + { 0x2665, glyph_heart }, + { 0x0309, glyph_hookabovecomb }, + { 0x2302, glyph_house }, + { 0x02DD, glyph_hungarumlaut }, + { 0x002D, glyph_hyphen }, +/* { 0x00AD, glyph_hyphen }, duplicate code */ + { 0xF6E5, glyph_hypheninferior }, + { 0xF6E6, glyph_hyphensuperior }, + { 0x0069, glyph_i }, + { 0x00ED, glyph_iacute }, + { 0x012D, glyph_ibreve }, + { 0x00EE, glyph_icircumflex }, + { 0x00EF, glyph_idieresis }, + { 0x00EC, glyph_igrave }, + { 0x0133, glyph_ij }, + { 0x012B, glyph_imacron }, + { 0x221E, glyph_infinity }, + { 0x222B, glyph_integral }, + { 0x2321, glyph_integralbt }, + { 0xF8F5, glyph_integralex }, + { 0x2320, glyph_integraltp }, + { 0x2229, glyph_intersection }, + { 0x25D8, glyph_invbullet }, + { 0x25D9, glyph_invcircle }, + { 0x263B, glyph_invsmileface }, + { 0x012F, glyph_iogonek }, + { 0x03B9, glyph_iota }, + { 0x03CA, glyph_iotadieresis }, + { 0x0390, glyph_iotadieresistonos }, + { 0x03AF, glyph_iotatonos }, + { 0xF6ED, glyph_isuperior }, + { 0x0129, glyph_itilde }, + { 0x006A, glyph_j }, + { 0x0135, glyph_jcircumflex }, + { 0x006B, glyph_k }, + { 0x03BA, glyph_kappa }, + { 0x0137, glyph_kcommaaccent }, + { 0x0138, glyph_kgreenlandic }, + { 0x006C, glyph_l }, + { 0x013A, glyph_lacute }, + { 0x03BB, glyph_lambda }, + { 0x013E, glyph_lcaron }, + { 0x013C, glyph_lcommaaccent }, + { 0x0140, glyph_ldot }, + { 0x003C, glyph_less }, + { 0x2264, glyph_lessequal }, + { 0x258C, glyph_lfblock }, + { 0x20A4, glyph_lira }, + { 0xF6C0, glyph_ll }, + { 0x2227, glyph_logicaland }, + { 0x00AC, glyph_logicalnot }, + { 0x2228, glyph_logicalor }, + { 0x017F, glyph_longs }, + { 0x25CA, glyph_lozenge }, + { 0x0142, glyph_lslash }, + { 0xF6EE, glyph_lsuperior }, + { 0x2591, glyph_ltshade }, + { 0x006D, glyph_m }, + { 0x00AF, glyph_macron }, +/* { 0x02C9, glyph_macron }, duplicate code */ + { 0x2642, glyph_male }, + { 0x2212, glyph_minus }, + { 0x2032, glyph_minute }, + { 0xF6EF, glyph_msuperior }, +/* { 0x00B5, glyph_mu }, duplicate code */ + { 0x03BC, glyph_mu }, + { 0x00D7, glyph_multiply }, + { 0x266A, glyph_musicalnote }, + { 0x266B, glyph_musicalnotedbl }, + { 0x006E, glyph_n }, + { 0x0144, glyph_nacute }, + { 0x0149, glyph_napostrophe }, + { 0x0148, glyph_ncaron }, + { 0x0146, glyph_ncommaaccent }, + { 0x0039, glyph_nine }, + { 0x2089, glyph_nineinferior }, + { 0xF739, glyph_nineoldstyle }, + { 0x2079, glyph_ninesuperior }, + { 0x2209, glyph_notelement }, + { 0x2260, glyph_notequal }, + { 0x2284, glyph_notsubset }, + { 0x207F, glyph_nsuperior }, + { 0x00F1, glyph_ntilde }, + { 0x03BD, glyph_nu }, + { 0x0023, glyph_numbersign }, + { 0x006F, glyph_o }, + { 0x00F3, glyph_oacute }, + { 0x014F, glyph_obreve }, + { 0x00F4, glyph_ocircumflex }, + { 0x00F6, glyph_odieresis }, + { 0x0153, glyph_oe }, + { 0x02DB, glyph_ogonek }, + { 0x00F2, glyph_ograve }, + { 0x01A1, glyph_ohorn }, + { 0x0151, glyph_ohungarumlaut }, + { 0x014D, glyph_omacron }, + { 0x03C9, glyph_omega }, + { 0x03D6, glyph_omega1 }, + { 0x03CE, glyph_omegatonos }, + { 0x03BF, glyph_omicron }, + { 0x03CC, glyph_omicrontonos }, + { 0x0031, glyph_one }, + { 0x2024, glyph_onedotenleader }, + { 0x215B, glyph_oneeighth }, + { 0xF6DC, glyph_onefitted }, + { 0x00BD, glyph_onehalf }, + { 0x2081, glyph_oneinferior }, + { 0xF731, glyph_oneoldstyle }, + { 0x00BC, glyph_onequarter }, + { 0x00B9, glyph_onesuperior }, + { 0x2153, glyph_onethird }, + { 0x25E6, glyph_openbullet }, + { 0x00AA, glyph_ordfeminine }, + { 0x00BA, glyph_ordmasculine }, + { 0x221F, glyph_orthogonal }, + { 0x00F8, glyph_oslash }, + { 0x01FF, glyph_oslashacute }, + { 0xF6F0, glyph_osuperior }, + { 0x00F5, glyph_otilde }, + { 0x0070, glyph_p }, + { 0x00B6, glyph_paragraph }, + { 0x0028, glyph_parenleft }, + { 0xF8ED, glyph_parenleftbt }, + { 0xF8EC, glyph_parenleftex }, + { 0x208D, glyph_parenleftinferior }, + { 0x207D, glyph_parenleftsuperior }, + { 0xF8EB, glyph_parenlefttp }, + { 0x0029, glyph_parenright }, + { 0xF8F8, glyph_parenrightbt }, + { 0xF8F7, glyph_parenrightex }, + { 0x208E, glyph_parenrightinferior }, + { 0x207E, glyph_parenrightsuperior }, + { 0xF8F6, glyph_parenrighttp }, + { 0x2202, glyph_partialdiff }, + { 0x0025, glyph_percent }, + { 0x002E, glyph_period }, + { 0x00B7, glyph_periodcentered }, +/* { 0x2219, glyph_periodcentered }, duplicate code */ + { 0xF6E7, glyph_periodinferior }, + { 0xF6E8, glyph_periodsuperior }, + { 0x22A5, glyph_perpendicular }, + { 0x2030, glyph_perthousand }, + { 0x20A7, glyph_peseta }, + { 0x03C6, glyph_phi }, + { 0x03D5, glyph_phi1 }, + { 0x03C0, glyph_pi }, + { 0x002B, glyph_plus }, + { 0x00B1, glyph_plusminus }, + { 0x211E, glyph_prescription }, + { 0x220F, glyph_product }, + { 0x2282, glyph_propersubset }, + { 0x2283, glyph_propersuperset }, + { 0x221D, glyph_proportional }, + { 0x03C8, glyph_psi }, + { 0x0071, glyph_q }, + { 0x003F, glyph_question }, + { 0x00BF, glyph_questiondown }, + { 0xF7BF, glyph_questiondownsmall }, + { 0xF73F, glyph_questionsmall }, + { 0x0022, glyph_quotedbl }, + { 0x201E, glyph_quotedblbase }, + { 0x201C, glyph_quotedblleft }, + { 0x201D, glyph_quotedblright }, + { 0x2018, glyph_quoteleft }, + { 0x201B, glyph_quotereversed }, + { 0x2019, glyph_quoteright }, + { 0x201A, glyph_quotesinglbase }, + { 0x0027, glyph_quotesingle }, + { 0x0072, glyph_r }, + { 0x0155, glyph_racute }, + { 0x221A, glyph_radical }, + { 0xF8E5, glyph_radicalex }, + { 0x0159, glyph_rcaron }, + { 0x0157, glyph_rcommaaccent }, + { 0x2286, glyph_reflexsubset }, + { 0x2287, glyph_reflexsuperset }, + { 0x00AE, glyph_registered }, + { 0xF8E8, glyph_registersans }, + { 0xF6DA, glyph_registerserif }, + { 0x2310, glyph_revlogicalnot }, + { 0x03C1, glyph_rho }, + { 0x02DA, glyph_ring }, + { 0xF6F1, glyph_rsuperior }, + { 0x2590, glyph_rtblock }, + { 0xF6DD, glyph_rupiah }, + { 0x0073, glyph_s }, + { 0x015B, glyph_sacute }, + { 0x0161, glyph_scaron }, + { 0x015F, glyph_scedilla }, +/* { 0xF6C2, glyph_scedilla }, duplicate code */ + { 0x015D, glyph_scircumflex }, + { 0x0219, glyph_scommaaccent }, + { 0x2033, glyph_second }, + { 0x00A7, glyph_section }, + { 0x003B, glyph_semicolon }, + { 0x0037, glyph_seven }, + { 0x215E, glyph_seveneighths }, + { 0x2087, glyph_seveninferior }, + { 0xF737, glyph_sevenoldstyle }, + { 0x2077, glyph_sevensuperior }, + { 0x2592, glyph_shade }, + { 0x03C3, glyph_sigma }, + { 0x03C2, glyph_sigma1 }, + { 0x223C, glyph_similar }, + { 0x0036, glyph_six }, + { 0x2086, glyph_sixinferior }, + { 0xF736, glyph_sixoldstyle }, + { 0x2076, glyph_sixsuperior }, + { 0x002F, glyph_slash }, + { 0x263A, glyph_smileface }, + { 0x0020, glyph_space }, +/* { 0x00A0, glyph_space }, duplicate code */ + { 0x2660, glyph_spade }, + { 0xF6F2, glyph_ssuperior }, + { 0x00A3, glyph_sterling }, + { 0x220B, glyph_suchthat }, + { 0x2211, glyph_summation }, + { 0x263C, glyph_sun }, + { 0x0074, glyph_t }, + { 0x03C4, glyph_tau }, + { 0x0167, glyph_tbar }, + { 0x0165, glyph_tcaron }, + { 0x0163, glyph_tcommaaccent }, +/* { 0x021B, glyph_tcommaaccent }, duplicate code */ + { 0x2234, glyph_therefore }, + { 0x03B8, glyph_theta }, + { 0x03D1, glyph_theta1 }, + { 0x00FE, glyph_thorn }, + { 0x0033, glyph_three }, + { 0x215C, glyph_threeeighths }, + { 0x2083, glyph_threeinferior }, + { 0xF733, glyph_threeoldstyle }, + { 0x00BE, glyph_threequarters }, + { 0xF6DE, glyph_threequartersemdash }, + { 0x00B3, glyph_threesuperior }, + { 0x02DC, glyph_tilde }, + { 0x0303, glyph_tildecomb }, + { 0x0384, glyph_tonos }, + { 0x2122, glyph_trademark }, + { 0xF8EA, glyph_trademarksans }, + { 0xF6DB, glyph_trademarkserif }, + { 0x25BC, glyph_triagdn }, + { 0x25C4, glyph_triaglf }, + { 0x25BA, glyph_triagrt }, + { 0x25B2, glyph_triagup }, + { 0xF6F3, glyph_tsuperior }, + { 0x0032, glyph_two }, + { 0x2025, glyph_twodotenleader }, + { 0x2082, glyph_twoinferior }, + { 0xF732, glyph_twooldstyle }, + { 0x00B2, glyph_twosuperior }, + { 0x2154, glyph_twothirds }, + { 0x0075, glyph_u }, + { 0x00FA, glyph_uacute }, + { 0x016D, glyph_ubreve }, + { 0x00FB, glyph_ucircumflex }, + { 0x00FC, glyph_udieresis }, + { 0x00F9, glyph_ugrave }, + { 0x01B0, glyph_uhorn }, + { 0x0171, glyph_uhungarumlaut }, + { 0x016B, glyph_umacron }, + { 0x005F, glyph_underscore }, + { 0x2017, glyph_underscoredbl }, + { 0x222A, glyph_union }, + { 0x2200, glyph_universal }, + { 0x0173, glyph_uogonek }, + { 0x2580, glyph_upblock }, + { 0x03C5, glyph_upsilon }, + { 0x03CB, glyph_upsilondieresis }, + { 0x03B0, glyph_upsilondieresistonos }, + { 0x03CD, glyph_upsilontonos }, + { 0x016F, glyph_uring }, + { 0x0169, glyph_utilde }, + { 0x0076, glyph_v }, + { 0x0077, glyph_w }, + { 0x1E83, glyph_wacute }, + { 0x0175, glyph_wcircumflex }, + { 0x1E85, glyph_wdieresis }, + { 0x2118, glyph_weierstrass }, + { 0x1E81, glyph_wgrave }, + { 0x0078, glyph_x }, + { 0x03BE, glyph_xi }, + { 0x0079, glyph_y }, + { 0x00FD, glyph_yacute }, + { 0x0177, glyph_ycircumflex }, + { 0x00FF, glyph_ydieresis }, + { 0x00A5, glyph_yen }, + { 0x1EF3, glyph_ygrave }, + { 0x007A, glyph_z }, + { 0x017A, glyph_zacute }, + { 0x017E, glyph_zcaron }, + { 0x017C, glyph_zdotaccent }, + { 0x0030, glyph_zero }, + { 0x2080, glyph_zeroinferior }, + { 0xF730, glyph_zerooldstyle }, + { 0x2070, glyph_zerosuperior }, + { 0x03B6, glyph_zeta }, +#else +#endif +}; /* tab_agl2uni */ + +/* table sorted by unicode values */ +static pdc_glyph_tab tab_uni2agl[] = +{ + { 0x0020, glyph_space }, + { 0x0021, glyph_exclam }, + { 0x0022, glyph_quotedbl }, + { 0x0023, glyph_numbersign }, + { 0x0024, glyph_dollar }, + { 0x0025, glyph_percent }, + { 0x0026, glyph_ampersand }, + { 0x0027, glyph_quotesingle }, + { 0x0028, glyph_parenleft }, + { 0x0029, glyph_parenright }, + { 0x002A, glyph_asterisk }, + { 0x002B, glyph_plus }, + { 0x002C, glyph_comma }, + { 0x002D, glyph_hyphen }, + { 0x002E, glyph_period }, + { 0x002F, glyph_slash }, + { 0x0030, glyph_zero }, + { 0x0031, glyph_one }, + { 0x0032, glyph_two }, + { 0x0033, glyph_three }, + { 0x0034, glyph_four }, + { 0x0035, glyph_five }, + { 0x0036, glyph_six }, + { 0x0037, glyph_seven }, + { 0x0038, glyph_eight }, + { 0x0039, glyph_nine }, + { 0x003A, glyph_colon }, + { 0x003B, glyph_semicolon }, + { 0x003C, glyph_less }, + { 0x003D, glyph_equal }, + { 0x003E, glyph_greater }, + { 0x003F, glyph_question }, + { 0x0040, glyph_at }, + { 0x0041, glyph_A }, + { 0x0042, glyph_B }, + { 0x0043, glyph_C }, + { 0x0044, glyph_D }, + { 0x0045, glyph_E }, + { 0x0046, glyph_F }, + { 0x0047, glyph_G }, + { 0x0048, glyph_H }, + { 0x0049, glyph_I }, + { 0x004A, glyph_J }, + { 0x004B, glyph_K }, + { 0x004C, glyph_L }, + { 0x004D, glyph_M }, + { 0x004E, glyph_N }, + { 0x004F, glyph_O }, + { 0x0050, glyph_P }, + { 0x0051, glyph_Q }, + { 0x0052, glyph_R }, + { 0x0053, glyph_S }, + { 0x0054, glyph_T }, + { 0x0055, glyph_U }, + { 0x0056, glyph_V }, + { 0x0057, glyph_W }, + { 0x0058, glyph_X }, + { 0x0059, glyph_Y }, + { 0x005A, glyph_Z }, + { 0x005B, glyph_bracketleft }, + { 0x005C, glyph_backslash }, + { 0x005D, glyph_bracketright }, + { 0x005E, glyph_asciicircum }, + { 0x005F, glyph_underscore }, + { 0x0060, glyph_grave }, + { 0x0061, glyph_a }, + { 0x0062, glyph_b }, + { 0x0063, glyph_c }, + { 0x0064, glyph_d }, + { 0x0065, glyph_e }, + { 0x0066, glyph_f }, + { 0x0067, glyph_g }, + { 0x0068, glyph_h }, + { 0x0069, glyph_i }, + { 0x006A, glyph_j }, + { 0x006B, glyph_k }, + { 0x006C, glyph_l }, + { 0x006D, glyph_m }, + { 0x006E, glyph_n }, + { 0x006F, glyph_o }, + { 0x0070, glyph_p }, + { 0x0071, glyph_q }, + { 0x0072, glyph_r }, + { 0x0073, glyph_s }, + { 0x0074, glyph_t }, + { 0x0075, glyph_u }, + { 0x0076, glyph_v }, + { 0x0077, glyph_w }, + { 0x0078, glyph_x }, + { 0x0079, glyph_y }, + { 0x007A, glyph_z }, + { 0x007B, glyph_braceleft }, + { 0x007C, glyph_bar }, + { 0x007D, glyph_braceright }, + { 0x007E, glyph_asciitilde }, + { 0x00A0, glyph_space }, + { 0x00A1, glyph_exclamdown }, + { 0x00A2, glyph_cent }, + { 0x00A3, glyph_sterling }, + { 0x00A4, glyph_currency }, + { 0x00A5, glyph_yen }, + { 0x00A6, glyph_brokenbar }, + { 0x00A7, glyph_section }, + { 0x00A8, glyph_dieresis }, + { 0x00A9, glyph_copyright }, + { 0x00AA, glyph_ordfeminine }, + { 0x00AB, glyph_guillemotleft }, + { 0x00AC, glyph_logicalnot }, + { 0x00AD, glyph_hyphen }, + { 0x00AE, glyph_registered }, + { 0x00AF, glyph_macron }, + { 0x00B0, glyph_degree }, + { 0x00B1, glyph_plusminus }, + { 0x00B2, glyph_twosuperior }, + { 0x00B3, glyph_threesuperior }, + { 0x00B4, glyph_acute }, + { 0x00B5, glyph_mu }, + { 0x00B6, glyph_paragraph }, + { 0x00B7, glyph_periodcentered }, + { 0x00B8, glyph_cedilla }, + { 0x00B9, glyph_onesuperior }, + { 0x00BA, glyph_ordmasculine }, + { 0x00BB, glyph_guillemotright }, + { 0x00BC, glyph_onequarter }, + { 0x00BD, glyph_onehalf }, + { 0x00BE, glyph_threequarters }, + { 0x00BF, glyph_questiondown }, + { 0x00C0, glyph_Agrave }, + { 0x00C1, glyph_Aacute }, + { 0x00C2, glyph_Acircumflex }, + { 0x00C3, glyph_Atilde }, + { 0x00C4, glyph_Adieresis }, + { 0x00C5, glyph_Aring }, + { 0x00C6, glyph_AE }, + { 0x00C7, glyph_Ccedilla }, + { 0x00C8, glyph_Egrave }, + { 0x00C9, glyph_Eacute }, + { 0x00CA, glyph_Ecircumflex }, + { 0x00CB, glyph_Edieresis }, + { 0x00CC, glyph_Igrave }, + { 0x00CD, glyph_Iacute }, + { 0x00CE, glyph_Icircumflex }, + { 0x00CF, glyph_Idieresis }, + { 0x00D0, glyph_Eth }, + { 0x00D1, glyph_Ntilde }, + { 0x00D2, glyph_Ograve }, + { 0x00D3, glyph_Oacute }, + { 0x00D4, glyph_Ocircumflex }, + { 0x00D5, glyph_Otilde }, + { 0x00D6, glyph_Odieresis }, + { 0x00D7, glyph_multiply }, + { 0x00D8, glyph_Oslash }, + { 0x00D9, glyph_Ugrave }, + { 0x00DA, glyph_Uacute }, + { 0x00DB, glyph_Ucircumflex }, + { 0x00DC, glyph_Udieresis }, + { 0x00DD, glyph_Yacute }, + { 0x00DE, glyph_Thorn }, + { 0x00DF, glyph_germandbls }, + { 0x00E0, glyph_agrave }, + { 0x00E1, glyph_aacute }, + { 0x00E2, glyph_acircumflex }, + { 0x00E3, glyph_atilde }, + { 0x00E4, glyph_adieresis }, + { 0x00E5, glyph_aring }, + { 0x00E6, glyph_ae }, + { 0x00E7, glyph_ccedilla }, + { 0x00E8, glyph_egrave }, + { 0x00E9, glyph_eacute }, + { 0x00EA, glyph_ecircumflex }, + { 0x00EB, glyph_edieresis }, + { 0x00EC, glyph_igrave }, + { 0x00ED, glyph_iacute }, + { 0x00EE, glyph_icircumflex }, + { 0x00EF, glyph_idieresis }, + { 0x00F0, glyph_eth }, + { 0x00F1, glyph_ntilde }, + { 0x00F2, glyph_ograve }, + { 0x00F3, glyph_oacute }, + { 0x00F4, glyph_ocircumflex }, + { 0x00F5, glyph_otilde }, + { 0x00F6, glyph_odieresis }, + { 0x00F7, glyph_divide }, + { 0x00F8, glyph_oslash }, + { 0x00F9, glyph_ugrave }, + { 0x00FA, glyph_uacute }, + { 0x00FB, glyph_ucircumflex }, + { 0x00FC, glyph_udieresis }, + { 0x00FD, glyph_yacute }, + { 0x00FE, glyph_thorn }, + { 0x00FF, glyph_ydieresis }, + { 0x0100, glyph_Amacron }, + { 0x0101, glyph_amacron }, + { 0x0102, glyph_Abreve }, + { 0x0103, glyph_abreve }, + { 0x0104, glyph_Aogonek }, + { 0x0105, glyph_aogonek }, + { 0x0106, glyph_Cacute }, + { 0x0107, glyph_cacute }, + { 0x0108, glyph_Ccircumflex }, + { 0x0109, glyph_ccircumflex }, + { 0x010A, glyph_Cdotaccent }, + { 0x010B, glyph_cdotaccent }, + { 0x010C, glyph_Ccaron }, + { 0x010D, glyph_ccaron }, + { 0x010E, glyph_Dcaron }, + { 0x010F, glyph_dcaron }, + { 0x0110, glyph_Dcroat }, + { 0x0111, glyph_dcroat }, + { 0x0112, glyph_Emacron }, + { 0x0113, glyph_emacron }, + { 0x0114, glyph_Ebreve }, + { 0x0115, glyph_ebreve }, + { 0x0116, glyph_Edotaccent }, + { 0x0117, glyph_edotaccent }, + { 0x0118, glyph_Eogonek }, + { 0x0119, glyph_eogonek }, + { 0x011A, glyph_Ecaron }, + { 0x011B, glyph_ecaron }, + { 0x011C, glyph_Gcircumflex }, + { 0x011D, glyph_gcircumflex }, + { 0x011E, glyph_Gbreve }, + { 0x011F, glyph_gbreve }, + { 0x0120, glyph_Gdotaccent }, + { 0x0121, glyph_gdotaccent }, + { 0x0122, glyph_Gcommaaccent }, + { 0x0123, glyph_gcommaaccent }, + { 0x0124, glyph_Hcircumflex }, + { 0x0125, glyph_hcircumflex }, + { 0x0126, glyph_Hbar }, + { 0x0127, glyph_hbar }, + { 0x0128, glyph_Itilde }, + { 0x0129, glyph_itilde }, + { 0x012A, glyph_Imacron }, + { 0x012B, glyph_imacron }, + { 0x012C, glyph_Ibreve }, + { 0x012D, glyph_ibreve }, + { 0x012E, glyph_Iogonek }, + { 0x012F, glyph_iogonek }, + { 0x0130, glyph_Idotaccent }, + { 0x0131, glyph_dotlessi }, + { 0x0132, glyph_IJ }, + { 0x0133, glyph_ij }, + { 0x0134, glyph_Jcircumflex }, + { 0x0135, glyph_jcircumflex }, + { 0x0136, glyph_Kcommaaccent }, + { 0x0137, glyph_kcommaaccent }, + { 0x0138, glyph_kgreenlandic }, + { 0x0139, glyph_Lacute }, + { 0x013A, glyph_lacute }, + { 0x013B, glyph_Lcommaaccent }, + { 0x013C, glyph_lcommaaccent }, + { 0x013D, glyph_Lcaron }, + { 0x013E, glyph_lcaron }, + { 0x013F, glyph_Ldot }, + { 0x0140, glyph_ldot }, + { 0x0141, glyph_Lslash }, + { 0x0142, glyph_lslash }, + { 0x0143, glyph_Nacute }, + { 0x0144, glyph_nacute }, + { 0x0145, glyph_Ncommaaccent }, + { 0x0146, glyph_ncommaaccent }, + { 0x0147, glyph_Ncaron }, + { 0x0148, glyph_ncaron }, + { 0x0149, glyph_napostrophe }, + { 0x014A, glyph_Eng }, + { 0x014B, glyph_eng }, + { 0x014C, glyph_Omacron }, + { 0x014D, glyph_omacron }, + { 0x014E, glyph_Obreve }, + { 0x014F, glyph_obreve }, + { 0x0150, glyph_Ohungarumlaut }, + { 0x0151, glyph_ohungarumlaut }, + { 0x0152, glyph_OE }, + { 0x0153, glyph_oe }, + { 0x0154, glyph_Racute }, + { 0x0155, glyph_racute }, + { 0x0156, glyph_Rcommaaccent }, + { 0x0157, glyph_rcommaaccent }, + { 0x0158, glyph_Rcaron }, + { 0x0159, glyph_rcaron }, + { 0x015A, glyph_Sacute }, + { 0x015B, glyph_sacute }, + { 0x015C, glyph_Scircumflex }, + { 0x015D, glyph_scircumflex }, + { 0x015E, glyph_Scedilla }, + { 0x015F, glyph_scedilla }, + { 0x0160, glyph_Scaron }, + { 0x0161, glyph_scaron }, + { 0x0162, glyph_Tcommaaccent }, + { 0x0163, glyph_tcommaaccent }, + { 0x0164, glyph_Tcaron }, + { 0x0165, glyph_tcaron }, + { 0x0166, glyph_Tbar }, + { 0x0167, glyph_tbar }, + { 0x0168, glyph_Utilde }, + { 0x0169, glyph_utilde }, + { 0x016A, glyph_Umacron }, + { 0x016B, glyph_umacron }, + { 0x016C, glyph_Ubreve }, + { 0x016D, glyph_ubreve }, + { 0x016E, glyph_Uring }, + { 0x016F, glyph_uring }, + { 0x0170, glyph_Uhungarumlaut }, + { 0x0171, glyph_uhungarumlaut }, + { 0x0172, glyph_Uogonek }, + { 0x0173, glyph_uogonek }, + { 0x0174, glyph_Wcircumflex }, + { 0x0175, glyph_wcircumflex }, + { 0x0176, glyph_Ycircumflex }, + { 0x0177, glyph_ycircumflex }, + { 0x0178, glyph_Ydieresis }, + { 0x0179, glyph_Zacute }, + { 0x017A, glyph_zacute }, + { 0x017B, glyph_Zdotaccent }, + { 0x017C, glyph_zdotaccent }, + { 0x017D, glyph_Zcaron }, + { 0x017E, glyph_zcaron }, + { 0x017F, glyph_longs }, + { 0x0192, glyph_florin }, + { 0x01A0, glyph_Ohorn }, + { 0x01A1, glyph_ohorn }, + { 0x01AF, glyph_Uhorn }, + { 0x01B0, glyph_uhorn }, + { 0x01E6, glyph_Gcaron }, + { 0x01E7, glyph_gcaron }, + { 0x01FA, glyph_Aringacute }, + { 0x01FB, glyph_aringacute }, + { 0x01FC, glyph_AEacute }, + { 0x01FD, glyph_aeacute }, + { 0x01FE, glyph_Oslashacute }, + { 0x01FF, glyph_oslashacute }, + { 0x0218, glyph_Scommaaccent }, + { 0x0219, glyph_scommaaccent }, + { 0x021A, glyph_Tcommaaccent }, + { 0x021B, glyph_tcommaaccent }, + { 0x02BC, glyph_afii57929 }, + { 0x02BD, glyph_afii64937 }, + { 0x02C6, glyph_circumflex }, + { 0x02C7, glyph_caron }, + { 0x02C9, glyph_macron }, + { 0x02D8, glyph_breve }, + { 0x02D9, glyph_dotaccent }, + { 0x02DA, glyph_ring }, + { 0x02DB, glyph_ogonek }, + { 0x02DC, glyph_tilde }, + { 0x02DD, glyph_hungarumlaut }, + { 0x0300, glyph_gravecomb }, + { 0x0301, glyph_acutecomb }, + { 0x0303, glyph_tildecomb }, + { 0x0309, glyph_hookabovecomb }, + { 0x0323, glyph_dotbelowcomb }, + { 0x0384, glyph_tonos }, + { 0x0385, glyph_dieresistonos }, + { 0x0386, glyph_Alphatonos }, + { 0x0387, glyph_anoteleia }, + { 0x0388, glyph_Epsilontonos }, + { 0x0389, glyph_Etatonos }, + { 0x038A, glyph_Iotatonos }, + { 0x038C, glyph_Omicrontonos }, + { 0x038E, glyph_Upsilontonos }, + { 0x038F, glyph_Omegatonos }, + { 0x0390, glyph_iotadieresistonos }, + { 0x0391, glyph_Alpha }, + { 0x0392, glyph_Beta }, + { 0x0393, glyph_Gamma }, + { 0x0394, glyph_Delta }, + { 0x0395, glyph_Epsilon }, + { 0x0396, glyph_Zeta }, + { 0x0397, glyph_Eta }, + { 0x0398, glyph_Theta }, + { 0x0399, glyph_Iota }, + { 0x039A, glyph_Kappa }, + { 0x039B, glyph_Lambda }, + { 0x039C, glyph_Mu }, + { 0x039D, glyph_Nu }, + { 0x039E, glyph_Xi }, + { 0x039F, glyph_Omicron }, + { 0x03A0, glyph_Pi }, + { 0x03A1, glyph_Rho }, + { 0x03A3, glyph_Sigma }, + { 0x03A4, glyph_Tau }, + { 0x03A5, glyph_Upsilon }, + { 0x03A6, glyph_Phi }, + { 0x03A7, glyph_Chi }, + { 0x03A8, glyph_Psi }, + { 0x03A9, glyph_Omega }, + { 0x03AA, glyph_Iotadieresis }, + { 0x03AB, glyph_Upsilondieresis }, + { 0x03AC, glyph_alphatonos }, + { 0x03AD, glyph_epsilontonos }, + { 0x03AE, glyph_etatonos }, + { 0x03AF, glyph_iotatonos }, + { 0x03B0, glyph_upsilondieresistonos }, + { 0x03B1, glyph_alpha }, + { 0x03B2, glyph_beta }, + { 0x03B3, glyph_gamma }, + { 0x03B4, glyph_delta }, + { 0x03B5, glyph_epsilon }, + { 0x03B6, glyph_zeta }, + { 0x03B7, glyph_eta }, + { 0x03B8, glyph_theta }, + { 0x03B9, glyph_iota }, + { 0x03BA, glyph_kappa }, + { 0x03BB, glyph_lambda }, + { 0x03BC, glyph_mu }, + { 0x03BD, glyph_nu }, + { 0x03BE, glyph_xi }, + { 0x03BF, glyph_omicron }, + { 0x03C0, glyph_pi }, + { 0x03C1, glyph_rho }, + { 0x03C2, glyph_sigma1 }, + { 0x03C3, glyph_sigma }, + { 0x03C4, glyph_tau }, + { 0x03C5, glyph_upsilon }, + { 0x03C6, glyph_phi }, + { 0x03C7, glyph_chi }, + { 0x03C8, glyph_psi }, + { 0x03C9, glyph_omega }, + { 0x03CA, glyph_iotadieresis }, + { 0x03CB, glyph_upsilondieresis }, + { 0x03CC, glyph_omicrontonos }, + { 0x03CD, glyph_upsilontonos }, + { 0x03CE, glyph_omegatonos }, + { 0x03D1, glyph_theta1 }, + { 0x03D2, glyph_Upsilon1 }, + { 0x03D5, glyph_phi1 }, + { 0x03D6, glyph_omega1 }, + { 0x0401, glyph_afii10023 }, + { 0x0402, glyph_afii10051 }, + { 0x0403, glyph_afii10052 }, + { 0x0404, glyph_afii10053 }, + { 0x0405, glyph_afii10054 }, + { 0x0406, glyph_afii10055 }, + { 0x0407, glyph_afii10056 }, + { 0x0408, glyph_afii10057 }, + { 0x0409, glyph_afii10058 }, + { 0x040A, glyph_afii10059 }, + { 0x040B, glyph_afii10060 }, + { 0x040C, glyph_afii10061 }, + { 0x040E, glyph_afii10062 }, + { 0x040F, glyph_afii10145 }, + { 0x0410, glyph_afii10017 }, + { 0x0411, glyph_afii10018 }, + { 0x0412, glyph_afii10019 }, + { 0x0413, glyph_afii10020 }, + { 0x0414, glyph_afii10021 }, + { 0x0415, glyph_afii10022 }, + { 0x0416, glyph_afii10024 }, + { 0x0417, glyph_afii10025 }, + { 0x0418, glyph_afii10026 }, + { 0x0419, glyph_afii10027 }, + { 0x041A, glyph_afii10028 }, + { 0x041B, glyph_afii10029 }, + { 0x041C, glyph_afii10030 }, + { 0x041D, glyph_afii10031 }, + { 0x041E, glyph_afii10032 }, + { 0x041F, glyph_afii10033 }, + { 0x0420, glyph_afii10034 }, + { 0x0421, glyph_afii10035 }, + { 0x0422, glyph_afii10036 }, + { 0x0423, glyph_afii10037 }, + { 0x0424, glyph_afii10038 }, + { 0x0425, glyph_afii10039 }, + { 0x0426, glyph_afii10040 }, + { 0x0427, glyph_afii10041 }, + { 0x0428, glyph_afii10042 }, + { 0x0429, glyph_afii10043 }, + { 0x042A, glyph_afii10044 }, + { 0x042B, glyph_afii10045 }, + { 0x042C, glyph_afii10046 }, + { 0x042D, glyph_afii10047 }, + { 0x042E, glyph_afii10048 }, + { 0x042F, glyph_afii10049 }, + { 0x0430, glyph_afii10065 }, + { 0x0431, glyph_afii10066 }, + { 0x0432, glyph_afii10067 }, + { 0x0433, glyph_afii10068 }, + { 0x0434, glyph_afii10069 }, + { 0x0435, glyph_afii10070 }, + { 0x0436, glyph_afii10072 }, + { 0x0437, glyph_afii10073 }, + { 0x0438, glyph_afii10074 }, + { 0x0439, glyph_afii10075 }, + { 0x043A, glyph_afii10076 }, + { 0x043B, glyph_afii10077 }, + { 0x043C, glyph_afii10078 }, + { 0x043D, glyph_afii10079 }, + { 0x043E, glyph_afii10080 }, + { 0x043F, glyph_afii10081 }, + { 0x0440, glyph_afii10082 }, + { 0x0441, glyph_afii10083 }, + { 0x0442, glyph_afii10084 }, + { 0x0443, glyph_afii10085 }, + { 0x0444, glyph_afii10086 }, + { 0x0445, glyph_afii10087 }, + { 0x0446, glyph_afii10088 }, + { 0x0447, glyph_afii10089 }, + { 0x0448, glyph_afii10090 }, + { 0x0449, glyph_afii10091 }, + { 0x044A, glyph_afii10092 }, + { 0x044B, glyph_afii10093 }, + { 0x044C, glyph_afii10094 }, + { 0x044D, glyph_afii10095 }, + { 0x044E, glyph_afii10096 }, + { 0x044F, glyph_afii10097 }, + { 0x0451, glyph_afii10071 }, + { 0x0452, glyph_afii10099 }, + { 0x0453, glyph_afii10100 }, + { 0x0454, glyph_afii10101 }, + { 0x0455, glyph_afii10102 }, + { 0x0456, glyph_afii10103 }, + { 0x0457, glyph_afii10104 }, + { 0x0458, glyph_afii10105 }, + { 0x0459, glyph_afii10106 }, + { 0x045A, glyph_afii10107 }, + { 0x045B, glyph_afii10108 }, + { 0x045C, glyph_afii10109 }, + { 0x045E, glyph_afii10110 }, + { 0x045F, glyph_afii10193 }, + { 0x0462, glyph_afii10146 }, + { 0x0463, glyph_afii10194 }, + { 0x0472, glyph_afii10147 }, + { 0x0473, glyph_afii10195 }, + { 0x0474, glyph_afii10148 }, + { 0x0475, glyph_afii10196 }, + { 0x0490, glyph_afii10050 }, + { 0x0491, glyph_afii10098 }, + { 0x04D9, glyph_afii10846 }, + { 0x05B0, glyph_afii57799 }, + { 0x05B1, glyph_afii57801 }, + { 0x05B2, glyph_afii57800 }, + { 0x05B3, glyph_afii57802 }, + { 0x05B4, glyph_afii57793 }, + { 0x05B5, glyph_afii57794 }, + { 0x05B6, glyph_afii57795 }, + { 0x05B7, glyph_afii57798 }, + { 0x05B8, glyph_afii57797 }, + { 0x05B9, glyph_afii57806 }, + { 0x05BB, glyph_afii57796 }, + { 0x05BC, glyph_afii57807 }, + { 0x05BD, glyph_afii57839 }, + { 0x05BE, glyph_afii57645 }, + { 0x05BF, glyph_afii57841 }, + { 0x05C0, glyph_afii57842 }, + { 0x05C1, glyph_afii57804 }, + { 0x05C2, glyph_afii57803 }, + { 0x05C3, glyph_afii57658 }, + { 0x05D0, glyph_afii57664 }, + { 0x05D1, glyph_afii57665 }, + { 0x05D2, glyph_afii57666 }, + { 0x05D3, glyph_afii57667 }, + { 0x05D4, glyph_afii57668 }, + { 0x05D5, glyph_afii57669 }, + { 0x05D6, glyph_afii57670 }, + { 0x05D7, glyph_afii57671 }, + { 0x05D8, glyph_afii57672 }, + { 0x05D9, glyph_afii57673 }, + { 0x05DA, glyph_afii57674 }, + { 0x05DB, glyph_afii57675 }, + { 0x05DC, glyph_afii57676 }, + { 0x05DD, glyph_afii57677 }, + { 0x05DE, glyph_afii57678 }, + { 0x05DF, glyph_afii57679 }, + { 0x05E0, glyph_afii57680 }, + { 0x05E1, glyph_afii57681 }, + { 0x05E2, glyph_afii57682 }, + { 0x05E3, glyph_afii57683 }, + { 0x05E4, glyph_afii57684 }, + { 0x05E5, glyph_afii57685 }, + { 0x05E6, glyph_afii57686 }, + { 0x05E7, glyph_afii57687 }, + { 0x05E8, glyph_afii57688 }, + { 0x05E9, glyph_afii57689 }, + { 0x05EA, glyph_afii57690 }, + { 0x05F0, glyph_afii57716 }, + { 0x05F1, glyph_afii57717 }, + { 0x05F2, glyph_afii57718 }, + { 0x060C, glyph_afii57388 }, + { 0x061B, glyph_afii57403 }, + { 0x061F, glyph_afii57407 }, + { 0x0621, glyph_afii57409 }, + { 0x0622, glyph_afii57410 }, + { 0x0623, glyph_afii57411 }, + { 0x0624, glyph_afii57412 }, + { 0x0625, glyph_afii57413 }, + { 0x0626, glyph_afii57414 }, + { 0x0627, glyph_afii57415 }, + { 0x0628, glyph_afii57416 }, + { 0x0629, glyph_afii57417 }, + { 0x062A, glyph_afii57418 }, + { 0x062B, glyph_afii57419 }, + { 0x062C, glyph_afii57420 }, + { 0x062D, glyph_afii57421 }, + { 0x062E, glyph_afii57422 }, + { 0x062F, glyph_afii57423 }, + { 0x0630, glyph_afii57424 }, + { 0x0631, glyph_afii57425 }, + { 0x0632, glyph_afii57426 }, + { 0x0633, glyph_afii57427 }, + { 0x0634, glyph_afii57428 }, + { 0x0635, glyph_afii57429 }, + { 0x0636, glyph_afii57430 }, + { 0x0637, glyph_afii57431 }, + { 0x0638, glyph_afii57432 }, + { 0x0639, glyph_afii57433 }, + { 0x063A, glyph_afii57434 }, + { 0x0640, glyph_afii57440 }, + { 0x0641, glyph_afii57441 }, + { 0x0642, glyph_afii57442 }, + { 0x0643, glyph_afii57443 }, + { 0x0644, glyph_afii57444 }, + { 0x0645, glyph_afii57445 }, + { 0x0646, glyph_afii57446 }, + { 0x0647, glyph_afii57470 }, + { 0x0648, glyph_afii57448 }, + { 0x0649, glyph_afii57449 }, + { 0x064A, glyph_afii57450 }, + { 0x064B, glyph_afii57451 }, + { 0x064C, glyph_afii57452 }, + { 0x064D, glyph_afii57453 }, + { 0x064E, glyph_afii57454 }, + { 0x064F, glyph_afii57455 }, + { 0x0650, glyph_afii57456 }, + { 0x0651, glyph_afii57457 }, + { 0x0652, glyph_afii57458 }, + { 0x0660, glyph_afii57392 }, + { 0x0661, glyph_afii57393 }, + { 0x0662, glyph_afii57394 }, + { 0x0663, glyph_afii57395 }, + { 0x0664, glyph_afii57396 }, + { 0x0665, glyph_afii57397 }, + { 0x0666, glyph_afii57398 }, + { 0x0667, glyph_afii57399 }, + { 0x0668, glyph_afii57400 }, + { 0x0669, glyph_afii57401 }, + { 0x066A, glyph_afii57381 }, + { 0x066D, glyph_afii63167 }, + { 0x0679, glyph_afii57511 }, + { 0x067E, glyph_afii57506 }, + { 0x0686, glyph_afii57507 }, + { 0x0688, glyph_afii57512 }, + { 0x0691, glyph_afii57513 }, + { 0x0698, glyph_afii57508 }, + { 0x06A4, glyph_afii57505 }, + { 0x06AF, glyph_afii57509 }, + { 0x06BA, glyph_afii57514 }, + { 0x06D2, glyph_afii57519 }, + { 0x06D5, glyph_afii57534 }, + { 0x1E80, glyph_Wgrave }, + { 0x1E81, glyph_wgrave }, + { 0x1E82, glyph_Wacute }, + { 0x1E83, glyph_wacute }, + { 0x1E84, glyph_Wdieresis }, + { 0x1E85, glyph_wdieresis }, + { 0x1EF2, glyph_Ygrave }, + { 0x1EF3, glyph_ygrave }, + { 0x200C, glyph_afii61664 }, + { 0x200D, glyph_afii301 }, + { 0x200E, glyph_afii299 }, + { 0x200F, glyph_afii300 }, + { 0x2012, glyph_figuredash }, + { 0x2013, glyph_endash }, + { 0x2014, glyph_emdash }, + { 0x2015, glyph_afii00208 }, + { 0x2017, glyph_underscoredbl }, + { 0x2018, glyph_quoteleft }, + { 0x2019, glyph_quoteright }, + { 0x201A, glyph_quotesinglbase }, + { 0x201B, glyph_quotereversed }, + { 0x201C, glyph_quotedblleft }, + { 0x201D, glyph_quotedblright }, + { 0x201E, glyph_quotedblbase }, + { 0x2020, glyph_dagger }, + { 0x2021, glyph_daggerdbl }, + { 0x2022, glyph_bullet }, + { 0x2024, glyph_onedotenleader }, + { 0x2025, glyph_twodotenleader }, + { 0x2026, glyph_ellipsis }, + { 0x202C, glyph_afii61573 }, + { 0x202D, glyph_afii61574 }, + { 0x202E, glyph_afii61575 }, + { 0x2030, glyph_perthousand }, + { 0x2032, glyph_minute }, + { 0x2033, glyph_second }, + { 0x2039, glyph_guilsinglleft }, + { 0x203A, glyph_guilsinglright }, + { 0x203C, glyph_exclamdbl }, + { 0x2044, glyph_fraction }, + { 0x2070, glyph_zerosuperior }, + { 0x2074, glyph_foursuperior }, + { 0x2075, glyph_fivesuperior }, + { 0x2076, glyph_sixsuperior }, + { 0x2077, glyph_sevensuperior }, + { 0x2078, glyph_eightsuperior }, + { 0x2079, glyph_ninesuperior }, + { 0x207D, glyph_parenleftsuperior }, + { 0x207E, glyph_parenrightsuperior }, + { 0x207F, glyph_nsuperior }, + { 0x2080, glyph_zeroinferior }, + { 0x2081, glyph_oneinferior }, + { 0x2082, glyph_twoinferior }, + { 0x2083, glyph_threeinferior }, + { 0x2084, glyph_fourinferior }, + { 0x2085, glyph_fiveinferior }, + { 0x2086, glyph_sixinferior }, + { 0x2087, glyph_seveninferior }, + { 0x2088, glyph_eightinferior }, + { 0x2089, glyph_nineinferior }, + { 0x208D, glyph_parenleftinferior }, + { 0x208E, glyph_parenrightinferior }, + { 0x20A1, glyph_colonmonetary }, + { 0x20A3, glyph_franc }, + { 0x20A4, glyph_lira }, + { 0x20A7, glyph_peseta }, + { 0x20AA, glyph_afii57636 }, + { 0x20AB, glyph_dong }, + { 0x20AC, glyph_Euro }, + { 0x2105, glyph_afii61248 }, + { 0x2111, glyph_Ifraktur }, + { 0x2113, glyph_afii61289 }, + { 0x2116, glyph_afii61352 }, + { 0x2118, glyph_weierstrass }, + { 0x211C, glyph_Rfraktur }, + { 0x211E, glyph_prescription }, + { 0x2122, glyph_trademark }, + { 0x2126, glyph_Omega }, + { 0x212E, glyph_estimated }, + { 0x2135, glyph_aleph }, + { 0x2153, glyph_onethird }, + { 0x2154, glyph_twothirds }, + { 0x215B, glyph_oneeighth }, + { 0x215C, glyph_threeeighths }, + { 0x215D, glyph_fiveeighths }, + { 0x215E, glyph_seveneighths }, + { 0x2190, glyph_arrowleft }, + { 0x2191, glyph_arrowup }, + { 0x2192, glyph_arrowright }, + { 0x2193, glyph_arrowdown }, + { 0x2194, glyph_arrowboth }, + { 0x2195, glyph_arrowupdn }, + { 0x21A8, glyph_arrowupdnbse }, + { 0x21B5, glyph_carriagereturn }, + { 0x21D0, glyph_arrowdblleft }, + { 0x21D1, glyph_arrowdblup }, + { 0x21D2, glyph_arrowdblright }, + { 0x21D3, glyph_arrowdbldown }, + { 0x21D4, glyph_arrowdblboth }, + { 0x2200, glyph_universal }, + { 0x2202, glyph_partialdiff }, + { 0x2203, glyph_existential }, + { 0x2205, glyph_emptyset }, + { 0x2206, glyph_Delta }, + { 0x2207, glyph_gradient }, + { 0x2208, glyph_element }, + { 0x2209, glyph_notelement }, + { 0x220B, glyph_suchthat }, + { 0x220F, glyph_product }, + { 0x2211, glyph_summation }, + { 0x2212, glyph_minus }, + { 0x2215, glyph_fraction }, + { 0x2217, glyph_asteriskmath }, + { 0x2219, glyph_periodcentered }, + { 0x221A, glyph_radical }, + { 0x221D, glyph_proportional }, + { 0x221E, glyph_infinity }, + { 0x221F, glyph_orthogonal }, + { 0x2220, glyph_angle }, + { 0x2227, glyph_logicaland }, + { 0x2228, glyph_logicalor }, + { 0x2229, glyph_intersection }, + { 0x222A, glyph_union }, + { 0x222B, glyph_integral }, + { 0x2234, glyph_therefore }, + { 0x223C, glyph_similar }, + { 0x2245, glyph_congruent }, + { 0x2248, glyph_approxequal }, + { 0x2260, glyph_notequal }, + { 0x2261, glyph_equivalence }, + { 0x2264, glyph_lessequal }, + { 0x2265, glyph_greaterequal }, + { 0x2282, glyph_propersubset }, + { 0x2283, glyph_propersuperset }, + { 0x2284, glyph_notsubset }, + { 0x2286, glyph_reflexsubset }, + { 0x2287, glyph_reflexsuperset }, + { 0x2295, glyph_circleplus }, + { 0x2297, glyph_circlemultiply }, + { 0x22A5, glyph_perpendicular }, + { 0x22C5, glyph_dotmath }, + { 0x2302, glyph_house }, + { 0x2310, glyph_revlogicalnot }, + { 0x2320, glyph_integraltp }, + { 0x2321, glyph_integralbt }, + { 0x2329, glyph_angleleft }, + { 0x232A, glyph_angleright }, + { 0x2500, glyph_SF100000 }, + { 0x2502, glyph_SF110000 }, + { 0x250C, glyph_SF010000 }, + { 0x2510, glyph_SF030000 }, + { 0x2514, glyph_SF020000 }, + { 0x2518, glyph_SF040000 }, + { 0x251C, glyph_SF080000 }, + { 0x2524, glyph_SF090000 }, + { 0x252C, glyph_SF060000 }, + { 0x2534, glyph_SF070000 }, + { 0x253C, glyph_SF050000 }, + { 0x2550, glyph_SF430000 }, + { 0x2551, glyph_SF240000 }, + { 0x2552, glyph_SF510000 }, + { 0x2553, glyph_SF520000 }, + { 0x2554, glyph_SF390000 }, + { 0x2555, glyph_SF220000 }, + { 0x2556, glyph_SF210000 }, + { 0x2557, glyph_SF250000 }, + { 0x2558, glyph_SF500000 }, + { 0x2559, glyph_SF490000 }, + { 0x255A, glyph_SF380000 }, + { 0x255B, glyph_SF280000 }, + { 0x255C, glyph_SF270000 }, + { 0x255D, glyph_SF260000 }, + { 0x255E, glyph_SF360000 }, + { 0x255F, glyph_SF370000 }, + { 0x2560, glyph_SF420000 }, + { 0x2561, glyph_SF190000 }, + { 0x2562, glyph_SF200000 }, + { 0x2563, glyph_SF230000 }, + { 0x2564, glyph_SF470000 }, + { 0x2565, glyph_SF480000 }, + { 0x2566, glyph_SF410000 }, + { 0x2567, glyph_SF450000 }, + { 0x2568, glyph_SF460000 }, + { 0x2569, glyph_SF400000 }, + { 0x256A, glyph_SF540000 }, + { 0x256B, glyph_SF530000 }, + { 0x256C, glyph_SF440000 }, + { 0x2580, glyph_upblock }, + { 0x2584, glyph_dnblock }, + { 0x2588, glyph_block }, + { 0x258C, glyph_lfblock }, + { 0x2590, glyph_rtblock }, + { 0x2591, glyph_ltshade }, + { 0x2592, glyph_shade }, + { 0x2593, glyph_dkshade }, + { 0x25A0, glyph_filledbox }, + { 0x25A1, glyph_H22073 }, + { 0x25AA, glyph_H18543 }, + { 0x25AB, glyph_H18551 }, + { 0x25AC, glyph_filledrect }, + { 0x25B2, glyph_triagup }, + { 0x25BA, glyph_triagrt }, + { 0x25BC, glyph_triagdn }, + { 0x25C4, glyph_triaglf }, + { 0x25CA, glyph_lozenge }, + { 0x25CB, glyph_circle }, + { 0x25CF, glyph_H18533 }, + { 0x25D8, glyph_invbullet }, + { 0x25D9, glyph_invcircle }, + { 0x25E6, glyph_openbullet }, + { 0x263A, glyph_smileface }, + { 0x263B, glyph_invsmileface }, + { 0x263C, glyph_sun }, + { 0x2640, glyph_female }, + { 0x2642, glyph_male }, + { 0x2660, glyph_spade }, + { 0x2663, glyph_club }, + { 0x2665, glyph_heart }, + { 0x2666, glyph_diamond }, + { 0x266A, glyph_musicalnote }, + { 0x266B, glyph_musicalnotedbl }, + { 0xF6BE, glyph_dotlessj }, + { 0xF6BF, glyph_LL }, + { 0xF6C0, glyph_ll }, + { 0xF6C1, glyph_Scedilla }, + { 0xF6C2, glyph_scedilla }, + { 0xF6C3, glyph_commaaccent }, + { 0xF6C4, glyph_afii10063 }, + { 0xF6C5, glyph_afii10064 }, + { 0xF6C6, glyph_afii10192 }, + { 0xF6C7, glyph_afii10831 }, + { 0xF6C8, glyph_afii10832 }, + { 0xF6C9, glyph_Acute }, + { 0xF6CA, glyph_Caron }, + { 0xF6CB, glyph_Dieresis }, + { 0xF6CC, glyph_DieresisAcute }, + { 0xF6CD, glyph_DieresisGrave }, + { 0xF6CE, glyph_Grave }, + { 0xF6CF, glyph_Hungarumlaut }, + { 0xF6D0, glyph_Macron }, + { 0xF6D1, glyph_cyrBreve }, + { 0xF6D2, glyph_cyrFlex }, + { 0xF6D3, glyph_dblGrave }, + { 0xF6D4, glyph_cyrbreve }, + { 0xF6D5, glyph_cyrflex }, + { 0xF6D6, glyph_dblgrave }, + { 0xF6D7, glyph_dieresisacute }, + { 0xF6D8, glyph_dieresisgrave }, + { 0xF6D9, glyph_copyrightserif }, + { 0xF6DA, glyph_registerserif }, + { 0xF6DB, glyph_trademarkserif }, + { 0xF6DC, glyph_onefitted }, + { 0xF6DD, glyph_rupiah }, + { 0xF6DE, glyph_threequartersemdash }, + { 0xF6DF, glyph_centinferior }, + { 0xF6E0, glyph_centsuperior }, + { 0xF6E1, glyph_commainferior }, + { 0xF6E2, glyph_commasuperior }, + { 0xF6E3, glyph_dollarinferior }, + { 0xF6E4, glyph_dollarsuperior }, + { 0xF6E5, glyph_hypheninferior }, + { 0xF6E6, glyph_hyphensuperior }, + { 0xF6E7, glyph_periodinferior }, + { 0xF6E8, glyph_periodsuperior }, + { 0xF6E9, glyph_asuperior }, + { 0xF6EA, glyph_bsuperior }, + { 0xF6EB, glyph_dsuperior }, + { 0xF6EC, glyph_esuperior }, + { 0xF6ED, glyph_isuperior }, + { 0xF6EE, glyph_lsuperior }, + { 0xF6EF, glyph_msuperior }, + { 0xF6F0, glyph_osuperior }, + { 0xF6F1, glyph_rsuperior }, + { 0xF6F2, glyph_ssuperior }, + { 0xF6F3, glyph_tsuperior }, + { 0xF6F4, glyph_Brevesmall }, + { 0xF6F5, glyph_Caronsmall }, + { 0xF6F6, glyph_Circumflexsmall }, + { 0xF6F7, glyph_Dotaccentsmall }, + { 0xF6F8, glyph_Hungarumlautsmall }, + { 0xF6F9, glyph_Lslashsmall }, + { 0xF6FA, glyph_OEsmall }, + { 0xF6FB, glyph_Ogoneksmall }, + { 0xF6FC, glyph_Ringsmall }, + { 0xF6FD, glyph_Scaronsmall }, + { 0xF6FE, glyph_Tildesmall }, + { 0xF6FF, glyph_Zcaronsmall }, + { 0xF721, glyph_exclamsmall }, + { 0xF724, glyph_dollaroldstyle }, + { 0xF726, glyph_ampersandsmall }, + { 0xF730, glyph_zerooldstyle }, + { 0xF731, glyph_oneoldstyle }, + { 0xF732, glyph_twooldstyle }, + { 0xF733, glyph_threeoldstyle }, + { 0xF734, glyph_fouroldstyle }, + { 0xF735, glyph_fiveoldstyle }, + { 0xF736, glyph_sixoldstyle }, + { 0xF737, glyph_sevenoldstyle }, + { 0xF738, glyph_eightoldstyle }, + { 0xF739, glyph_nineoldstyle }, + { 0xF73F, glyph_questionsmall }, + { 0xF760, glyph_Gravesmall }, + { 0xF761, glyph_Asmall }, + { 0xF762, glyph_Bsmall }, + { 0xF763, glyph_Csmall }, + { 0xF764, glyph_Dsmall }, + { 0xF765, glyph_Esmall }, + { 0xF766, glyph_Fsmall }, + { 0xF767, glyph_Gsmall }, + { 0xF768, glyph_Hsmall }, + { 0xF769, glyph_Ismall }, + { 0xF76A, glyph_Jsmall }, + { 0xF76B, glyph_Ksmall }, + { 0xF76C, glyph_Lsmall }, + { 0xF76D, glyph_Msmall }, + { 0xF76E, glyph_Nsmall }, + { 0xF76F, glyph_Osmall }, + { 0xF770, glyph_Psmall }, + { 0xF771, glyph_Qsmall }, + { 0xF772, glyph_Rsmall }, + { 0xF773, glyph_Ssmall }, + { 0xF774, glyph_Tsmall }, + { 0xF775, glyph_Usmall }, + { 0xF776, glyph_Vsmall }, + { 0xF777, glyph_Wsmall }, + { 0xF778, glyph_Xsmall }, + { 0xF779, glyph_Ysmall }, + { 0xF77A, glyph_Zsmall }, + { 0xF7A1, glyph_exclamdownsmall }, + { 0xF7A2, glyph_centoldstyle }, + { 0xF7A8, glyph_Dieresissmall }, + { 0xF7AF, glyph_Macronsmall }, + { 0xF7B4, glyph_Acutesmall }, + { 0xF7B8, glyph_Cedillasmall }, + { 0xF7BF, glyph_questiondownsmall }, + { 0xF7E0, glyph_Agravesmall }, + { 0xF7E1, glyph_Aacutesmall }, + { 0xF7E2, glyph_Acircumflexsmall }, + { 0xF7E3, glyph_Atildesmall }, + { 0xF7E4, glyph_Adieresissmall }, + { 0xF7E5, glyph_Aringsmall }, + { 0xF7E6, glyph_AEsmall }, + { 0xF7E7, glyph_Ccedillasmall }, + { 0xF7E8, glyph_Egravesmall }, + { 0xF7E9, glyph_Eacutesmall }, + { 0xF7EA, glyph_Ecircumflexsmall }, + { 0xF7EB, glyph_Edieresissmall }, + { 0xF7EC, glyph_Igravesmall }, + { 0xF7ED, glyph_Iacutesmall }, + { 0xF7EE, glyph_Icircumflexsmall }, + { 0xF7EF, glyph_Idieresissmall }, + { 0xF7F0, glyph_Ethsmall }, + { 0xF7F1, glyph_Ntildesmall }, + { 0xF7F2, glyph_Ogravesmall }, + { 0xF7F3, glyph_Oacutesmall }, + { 0xF7F4, glyph_Ocircumflexsmall }, + { 0xF7F5, glyph_Otildesmall }, + { 0xF7F6, glyph_Odieresissmall }, + { 0xF7F8, glyph_Oslashsmall }, + { 0xF7F9, glyph_Ugravesmall }, + { 0xF7FA, glyph_Uacutesmall }, + { 0xF7FB, glyph_Ucircumflexsmall }, + { 0xF7FC, glyph_Udieresissmall }, + { 0xF7FD, glyph_Yacutesmall }, + { 0xF7FE, glyph_Thornsmall }, + { 0xF7FF, glyph_Ydieresissmall }, + { 0xF8E5, glyph_radicalex }, + { 0xF8E6, glyph_arrowvertex }, + { 0xF8E7, glyph_arrowhorizex }, + { 0xF8E8, glyph_registersans }, + { 0xF8E9, glyph_copyrightsans }, + { 0xF8EA, glyph_trademarksans }, + { 0xF8EB, glyph_parenlefttp }, + { 0xF8EC, glyph_parenleftex }, + { 0xF8ED, glyph_parenleftbt }, + { 0xF8EE, glyph_bracketlefttp }, + { 0xF8EF, glyph_bracketleftex }, + { 0xF8F0, glyph_bracketleftbt }, + { 0xF8F1, glyph_bracelefttp }, + { 0xF8F2, glyph_braceleftmid }, + { 0xF8F3, glyph_braceleftbt }, + { 0xF8F4, glyph_braceex }, + { 0xF8F5, glyph_integralex }, + { 0xF8F6, glyph_parenrighttp }, + { 0xF8F7, glyph_parenrightex }, + { 0xF8F8, glyph_parenrightbt }, + { 0xF8F9, glyph_bracketrighttp }, + { 0xF8FA, glyph_bracketrightex }, + { 0xF8FB, glyph_bracketrightbt }, + { 0xF8FC, glyph_bracerighttp }, + { 0xF8FD, glyph_bracerightmid }, + { 0xF8FE, glyph_bracerightbt }, + { 0xFB00, glyph_ff }, + { 0xFB01, glyph_fi }, + { 0xFB02, glyph_fl }, + { 0xFB03, glyph_ffi }, + { 0xFB04, glyph_ffl }, + { 0xFB1F, glyph_afii57705 }, + { 0xFB2A, glyph_afii57694 }, + { 0xFB2B, glyph_afii57695 }, + { 0xFB35, glyph_afii57723 }, + { 0xFB4B, glyph_afii57700 }, +}; /* tab_uni2agl */ + + + + +/* This is the list of all character names of the Adobe + * standard Latin character set and the set of named characters + * in the Symbol font, documented in Appendix D of PDF Reference. + */ + +static const char *pc_standard_latin_charset[] = +{ +#ifndef PDFLIB_EBCDIC + glyph_A, + glyph_AE, + glyph_Aacute, + glyph_Acircumflex, + glyph_Adieresis, + glyph_Agrave, + glyph_Alpha, + glyph_Aring, + glyph_Atilde, + glyph_B, + glyph_Beta, + glyph_C, + glyph_Ccedilla, + glyph_Chi, + glyph_D, + glyph_Delta, + glyph_E, + glyph_Eacute, + glyph_Ecircumflex, + glyph_Edieresis, + glyph_Egrave, + glyph_Epsilon, + glyph_Eta, + glyph_Eth, + glyph_Euro, + glyph_F, + glyph_G, + glyph_Gamma, + glyph_H, + glyph_I, + glyph_Iacute, + glyph_Icircumflex, + glyph_Idieresis, + glyph_Ifraktur, + glyph_Igrave, + glyph_Iota, + glyph_J, + glyph_K, + glyph_Kappa, + glyph_L, + glyph_Lambda, + glyph_Lslash, + glyph_M, + glyph_Mu, + glyph_N, + glyph_Ntilde, + glyph_Nu, + glyph_O, + glyph_OE, + glyph_Oacute, + glyph_Ocircumflex, + glyph_Odieresis, + glyph_Ograve, + glyph_Omega, + glyph_Omicron, + glyph_Oslash, + glyph_Otilde, + glyph_P, + glyph_Phi, + glyph_Pi, + glyph_Psi, + glyph_Q, + glyph_R, + glyph_Rfraktur, + glyph_Rho, + glyph_S, + glyph_Scaron, + glyph_Sigma, + glyph_T, + glyph_Tau, + glyph_Theta, + glyph_Thorn, + glyph_U, + glyph_Uacute, + glyph_Ucircumflex, + glyph_Udieresis, + glyph_Ugrave, + glyph_Upsilon, + glyph_Upsilon1, + glyph_V, + glyph_W, + glyph_X, + glyph_Xi, + glyph_Y, + glyph_Yacute, + glyph_Ydieresis, + glyph_Z, + glyph_Zcaron, + glyph_Zeta, + glyph_a, + glyph_aacute, + glyph_acircumflex, + glyph_acute, + glyph_adieresis, + glyph_ae, + glyph_agrave, + glyph_aleph, + glyph_alpha, + glyph_ampersand, + glyph_angle, + glyph_angleleft, + glyph_angleright, + glyph_approxequal, + glyph_aring, + glyph_arrowboth, + glyph_arrowdblboth, + glyph_arrowdbldown, + glyph_arrowdblleft, + glyph_arrowdblright, + glyph_arrowdblup, + glyph_arrowdown, + glyph_arrowhorizex, + glyph_arrowleft, + glyph_arrowright, + glyph_arrowup, + glyph_arrowvertex, + glyph_asciicircum, + glyph_asciitilde, + glyph_asterisk, + glyph_asteriskmath, + glyph_at, + glyph_atilde, + glyph_b, + glyph_backslash, + glyph_bar, + glyph_beta, + glyph_braceex, + glyph_braceleft, + glyph_braceleftbt, + glyph_braceleftmid, + glyph_bracelefttp, + glyph_braceright, + glyph_bracerightbt, + glyph_bracerightmid, + glyph_bracerighttp, + glyph_bracketleft, + glyph_bracketleftbt, + glyph_bracketleftex, + glyph_bracketlefttp, + glyph_bracketright, + glyph_bracketrightbt, + glyph_bracketrightex, + glyph_bracketrighttp, + glyph_breve, + glyph_brokenbar, + glyph_bullet, + glyph_c, + glyph_caron, + glyph_carriagereturn, + glyph_ccedilla, + glyph_cedilla, + glyph_cent, + glyph_chi, + glyph_circlemultiply, + glyph_circleplus, + glyph_circumflex, + glyph_club, + glyph_colon, + glyph_comma, + glyph_congruent, + glyph_copyright, + glyph_copyrightsans, + glyph_copyrightserif, + glyph_currency, + glyph_d, + glyph_dagger, + glyph_daggerdbl, + glyph_degree, + glyph_delta, + glyph_diamond, + glyph_dieresis, + glyph_divide, + glyph_dollar, + glyph_dotaccent, + glyph_dotlessi, + glyph_dotmath, + glyph_e, + glyph_eacute, + glyph_ecircumflex, + glyph_edieresis, + glyph_egrave, + glyph_eight, + glyph_element, + glyph_ellipsis, + glyph_emdash, + glyph_emptyset, + glyph_endash, + glyph_epsilon, + glyph_equal, + glyph_equivalence, + glyph_eta, + glyph_eth, + glyph_exclam, + glyph_exclamdown, + glyph_existential, + glyph_f, + glyph_fi, + glyph_five, + glyph_fl, + glyph_florin, + glyph_four, + glyph_fraction, + glyph_g, + glyph_gamma, + glyph_germandbls, + glyph_gradient, + glyph_grave, + glyph_greater, + glyph_greaterequal, + glyph_guillemotleft, + glyph_guillemotright, + glyph_guilsinglleft, + glyph_guilsinglright, + glyph_h, + glyph_heart, + glyph_hungarumlaut, + glyph_hyphen, + glyph_i, + glyph_iacute, + glyph_icircumflex, + glyph_idieresis, + glyph_igrave, + glyph_infinity, + glyph_integral, + glyph_integralbt, + glyph_integralex, + glyph_integraltp, + glyph_intersection, + glyph_iota, + glyph_j, + glyph_k, + glyph_kappa, + glyph_l, + glyph_lambda, + glyph_less, + glyph_lessequal, + glyph_logicaland, + glyph_logicalnot, + glyph_logicalor, + glyph_lozenge, + glyph_lslash, + glyph_m, + glyph_macron, + glyph_minus, + glyph_minute, + glyph_mu, + glyph_multiply, + glyph_n, + glyph_nine, + glyph_notelement, + glyph_notequal, + glyph_notsubset, + glyph_ntilde, + glyph_nu, + glyph_numbersign, + glyph_o, + glyph_oacute, + glyph_ocircumflex, + glyph_odieresis, + glyph_oe, + glyph_ogonek, + glyph_ograve, + glyph_omega, + glyph_omega1, + glyph_omicron, + glyph_one, + glyph_onehalf, + glyph_onequarter, + glyph_onesuperior, + glyph_ordfeminine, + glyph_ordmasculine, + glyph_oslash, + glyph_otilde, + glyph_p, + glyph_paragraph, + glyph_parenleft, + glyph_parenleftbt, + glyph_parenleftex, + glyph_parenlefttp, + glyph_parenright, + glyph_parenrightbt, + glyph_parenrightex, + glyph_parenrighttp, + glyph_partialdiff, + glyph_percent, + glyph_period, + glyph_periodcentered, + glyph_perpendicular, + glyph_perthousand, + glyph_phi, + glyph_phi1, + glyph_pi, + glyph_plus, + glyph_plusminus, + glyph_product, + glyph_propersubset, + glyph_propersuperset, + glyph_proportional, + glyph_psi, + glyph_q, + glyph_question, + glyph_questiondown, + glyph_quotedbl, + glyph_quotedblbase, + glyph_quotedblleft, + glyph_quotedblright, + glyph_quoteleft, + glyph_quoteright, + glyph_quotesinglbase, + glyph_quotesingle, + glyph_r, + glyph_radical, + glyph_radicalex, + glyph_reflexsubset, + glyph_reflexsuperset, + glyph_registered, + glyph_registersans, + glyph_registerserif, + glyph_rho, + glyph_ring, + glyph_s, + glyph_scaron, + glyph_second, + glyph_section, + glyph_semicolon, + glyph_seven, + glyph_sigma, + glyph_sigma1, + glyph_similar, + glyph_six, + glyph_slash, + glyph_space, + glyph_spade, + glyph_sterling, + glyph_suchthat, + glyph_summation, + glyph_t, + glyph_tau, + glyph_therefore, + glyph_theta, + glyph_theta1, + glyph_thorn, + glyph_three, + glyph_threequarters, + glyph_threesuperior, + glyph_tilde, + glyph_trademark, + glyph_trademarksans, + glyph_trademarkserif, + glyph_two, + glyph_twosuperior, + glyph_u, + glyph_uacute, + glyph_ucircumflex, + glyph_udieresis, + glyph_ugrave, + glyph_underscore, + glyph_union, + glyph_universal, + glyph_upsilon, + glyph_v, + glyph_w, + glyph_weierstrass, + glyph_x, + glyph_xi, + glyph_y, + glyph_yacute, + glyph_ydieresis, + glyph_yen, + glyph_z, + glyph_zcaron, + glyph_zero, + glyph_zeta, +#else +#endif +}; + + +#endif /* PC_CHARTABS_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_config.h b/src/libs/pdflib/libs/pdcore/pc_config.h new file mode 100644 index 0000000000..d58d299dc4 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_config.h @@ -0,0 +1,289 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_config.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib portability and configuration definitions + * + */ + +#ifndef PC_CONFIG_H +#define PC_CONFIG_H + +/* ------------------------ feature configuration ------------------- */ + +/* zlib compression support */ +#define HAVE_LIBZ + +/* ---------------------------- platform definitions ------------------------ */ + +/* #undef this if your platform doesn't support environment variables */ +#define HAVE_ENVVARS + +/* Compilers which are not strictly ANSI conforming can set PDF_VOLATILE + * to an empty value. + */ +#ifndef PDF_VOLATILE +#define PDF_VOLATILE volatile +#endif + +/* byte order */ +#undef PDC_ISBIGENDIAN +#ifdef WORDS_BIGENDIAN +#define PDC_ISBIGENDIAN 1 +#else +#define PDC_ISBIGENDIAN 0 +#endif + +/* ---------------------------------- WIN32 -------------------------------- */ + +/* try to identify Windows compilers */ + +#if (defined _WIN32 || defined __WATCOMC__ || defined __BORLANDC__ || \ + (defined(__MWERKS__) && defined(__INTEL__))) && !defined WIN32 +#define WIN32 +#endif /* && !defined WIN32 */ + +#ifdef WIN32 +#define READBMODE "rb" +#define WRITEMODE "wb" +#define APPENDMODE "ab" + +#undef PDC_PATHSEP +#define PDC_PATHSEP "\\" + +#if defined(_WIN32_WCE) && (_WIN32_WCE >= 300) +#define PDF_PLATFORM "Windows CE" +#define WINCE +#undef HAVE_SETLOCALE +#undef HAVE_ENVVARS +#else +#if defined(WIN64) +#define PDF_PLATFORM "Win64" +#else +#define PDF_PLATFORM "Win32" +#endif +#endif + +#endif /* WIN32 */ + +/* --------------------------------- Cygnus -------------------------------- */ + +#ifdef __CYGWIN__ +#define READBMODE "rb" +#define WRITEMODE "wb" +#define APPENDMODE "ab" +#ifdef DLL_EXPORT + #define PDFLIB_EXPORTS +#endif + +#endif /* __CYGWIN__ */ + +/* ---------------------------------- DJGPP -------------------------------- */ + +#ifdef __DJGPP__ +#define READBMODE "rb" +#define WRITEMODE "wb" +#define APPENDMODE "ab" +#define PDF_PLATFORM "Win32/DJGPP" +#endif /* __DJGPP__ */ + +/* ----------------------------------- OS/2 -------------------------------- */ + +/* + * Try to identify OS/2 compilers. + */ + +#if (defined __OS2__ || defined __EMX__) && !defined OS2 +#define OS2 +#endif + +#ifdef OS2 +#define READBMODE "rb" +#define WRITEMODE "wb" +#define APPENDMODE "ab" +#define PDF_PLATFORM "OS/2" +#endif /* OS2 */ + +/* --------------------------------- Mac OS X ------------------------------- */ + +/* try to identify the Mac OS X command line compiler */ + +#if defined(__ppc__) && defined(__APPLE__) + +#define MACOSX + +/* + * By default we always build a carbonized version of the library, + * but allow non-Carbon builds to be triggered by setting the + * PDF_TARGET_API_MAC_OS8 symbol externally. + */ + +#ifndef PDF_TARGET_API_MAC_OS8 +#define PDF_TARGET_API_MAC_CARBON +#endif + +#if defined(PDF_TARGET_API_MAC_CARBON) && !defined(TARGET_API_MAC_CARBON) +#define TARGET_API_MAC_CARBON 1 +#endif + +/* Mac OS X 10.2 (Jaguar) defines this, but we use it for Mac OS 9 below */ +#undef MAC + +#endif /* Mac OS X */ + +/* --------------------------------- Mac OS 9 ------------------------------- */ + +/* try to identify Mac OS 9 compilers */ + +#if (defined macintosh || defined __POWERPC__ || defined __CFM68K__) && \ + !defined MAC && !defined MACOSX && !defined __BEOS__ +#define MAC +#endif + +#ifdef MAC +#define READBMODE "rb" +#define WRITEMODE "wb" +#define APPENDMODE "ab" +#define PDC_PATHSEP ":" + +#undef HAVE_ENVVARS + +#define PDF_PLATFORM "Mac OS" +#endif /* MAC */ + +/* ----------------------------------- BeOS --------------------------------- */ + +#ifdef __BEOS__ +#define PDF_PLATFORM "BeOS" + +#ifdef __POWERPC__ +#define WORDS_BIGENDIAN +#undef PDC_ISBIGENDIAN +#define PDC_ISBIGENDIAN 1 +#endif /* __POWERPC__ */ + +#endif /* __BEOS__ */ + +/* --------------------------------- AS/400 --------------------------------- */ + +/* try to identify the AS/400 compiler */ + +#if defined __ILEC400__ && !defined AS400 +#define AS400 +#endif + +#ifdef AS400 + +#pragma comment(copyright, \ + "(C) PDFlib GmbH, Muenchen, Germany (www.pdflib.com)") + +#define READTMODE "rb" +#define READBMODE "rb" +#define WRITEMODE "wb" +#define APPENDMODE "ab" + +#define PDF_PLATFORM "iSeries" + +#define WORDS_BIGENDIAN +#undef PDC_ISBIGENDIAN +#define PDC_ISBIGENDIAN 1 + +#endif /* AS400 */ + +/* --------------------- S/390 with Unix System Services -------------------- */ + +#ifdef OS390 + +#define WRITEMODE "wb" +#define APPENDMODE "ab" + +#endif /* OS390 */ + +/* -------------------------------- S/390 with MVS -------------------------- */ + +/* try to identify MVS (__MVS__ is #defined on USS and MVS!) + * I370 is used by SAS C + */ + +#if !defined(OS390) && (defined __MVS__ || defined I370) && !defined MVS +#define MVS +#endif + +#ifdef MVS + +#if defined(MVS) && defined(I370) +#define READBMODE "rb" +#define PDC_FILEQUOT "" +#else +#define READBMODE "rb,byteseek" +#define PDC_FILEQUOT "'" +#endif +#define WRITEMODE "wb" +#define APPENDMODE "ab,recfm=v" + +#undef PDC_PATHSEP +#define PDC_PATHSEP "(" + +#undef PDC_PATHTERM +#define PDC_PATHTERM ")" + +#define PDF_PLATFORM "zSeries MVS" +#define PDF_OS390_MVS_RESOURCE + +#define WORDS_BIGENDIAN +#undef PDC_ISBIGENDIAN +#define PDC_ISBIGENDIAN 1 + +#endif /* MVS */ + +/* ------------------------------------ VMS --------------------------------- */ + +/* No special handling required */ + +#ifdef VMS +#define PDF_PLATFORM "VMS" +#endif /* VMS */ + +/* --------------------------------- Defaults ------------------------------- */ + +#ifndef READTMODE +#define READTMODE "r" +#endif /* !READTMODE */ + +#ifndef READBMODE +#define READBMODE "rb" +#endif /* !READBMODE */ + +#ifndef WRITEMODE +#define WRITEMODE "w" +#endif /* !WRITEMODE */ + +#ifndef APPENDMODE +#define APPENDMODE "a" +#endif /* !APPENDMODE */ + +#ifndef PDC_PATHSEP +#define PDC_PATHSEP "/" +#endif /* !PDC_PATHSEP */ + +#ifdef _DEBUG +#define DEBUG +#endif /* _DEBUG */ + +#define PDC_FLOAT_MAX ((double) 1e+37) +#define PDC_FLOAT_MIN ((double) -1e+37) +#define PDC_FLOAT_PREC ((double) 1e-6) + +#define PDC_OFFSET(type, field) ((unsigned int) &(((type *)NULL)->field)) + +#endif /* PC_CONFIG_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_core.c b/src/libs/pdflib/libs/pdcore/pc_core.c new file mode 100644 index 0000000000..46402114ea --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_core.c @@ -0,0 +1,1077 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_core.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib core services + * + */ + +#ifndef WINCE +#include +#else +#include +#endif + +#include "pc_util.h" + +#define PDF_NonfatalError 11 +#define PDF_UnknownError 12 + + +/* TODO: how to make this dynamic? +** exception during pdc_core_init(): +** - out of memory in pdc_sb_new() +** exception during exception: +** - out of memory in pdc_sb_vprintf() +** - format error in pdc_sb_vprintf() +*/ +#define PDC_ERRPARM_SIZE 2048 +#define PDC_ERRBUF_SIZE (5 * PDC_ERRPARM_SIZE) +#define PDC_XSTACK_INISIZE 10 + +#define N_ERRTABS (PDC_ET_LAST / 1000) + +/* exception handling frame. +*/ +typedef struct +{ + pdc_jmpbuf jbuf; + /* we could anchor a destructor list here. */ +} pdc_xframe; + +typedef struct +{ + pdc_error_info * ei; + int n_entries; +} error_table; + + +/* ------------------------ the core core structure ---------------------- */ + +struct pdc_core_s { + /* ------------ try/catch ------------ */ + pdc_xframe * x_stack; + int x_ssize; + int x_sp; /* exception stack pointer */ + + /* ------------ error handling ------------ */ + pdc_bool warnings_enabled; + pdc_bool in_error; + char errbuf[PDC_ERRBUF_SIZE]; + char errparms[4][PDC_ERRPARM_SIZE]; + int epcount; + int errnum; + pdc_bool x_thrown; /* exception thrown and not caught */ + const char * apiname; + pdc_error_fp errorhandler; /* client error handler */ + void * opaque; /* client specific, opaque data */ + + error_table err_tables[N_ERRTABS]; + + /* ------------------ tracing ---------------- */ + pdc_bool trace; /* trace feature enabled? */ + char * tracefilename; /* name of the trace file */ + int floatdigits; /* floating point output precision */ + + /* ------------ memory management ------------ */ + pdc_alloc_fp allocproc; + pdc_realloc_fp reallocproc; + pdc_free_fp freeproc; +}; + + + +/* ----------- default memory management & error handling ----------- */ + +static void * +default_malloc(void *opaque, size_t size, const char *caller) +{ + (void) opaque; + (void) caller; + + return malloc(size); +} + +static void * +default_realloc(void *opaque, void *mem, size_t size, const char *caller) +{ + (void) opaque; + (void) caller; + + return realloc(mem, size); +} + +static void +default_free(void *opaque, void *mem) +{ + (void) opaque; + + free(mem); +} + +static void +default_errorhandler(void *opaque, int errnum, const char *msg) +{ + (void) opaque; + + if (errnum == PDF_NonfatalError) + { + fprintf(stderr, "PDFlib warning (ignored): %s\n", msg); + } + else + { + fprintf(stderr, "PDFlib exception (fatal): %s\n", msg); + exit(99); + } +} + +pdc_bool +pdc_enter_api(pdc_core *pdc, const char *apiname) +{ + if (pdc->in_error) + return pdc_false; + + pdc->errnum = 0; + pdc->apiname = apiname; + return pdc_true; +} + +void +pdc_set_warnings(pdc_core *pdc, pdc_bool on) +{ + pdc->warnings_enabled = on; +} + +pdc_bool +pdc_in_error(pdc_core *pdc) +{ + return pdc->in_error; +} + + +/* --------------------- error table management --------------------- */ + +static pdc_error_info core_errors[] = +{ +#define pdc_genInfo 1 +#include "pc_generr.h" +}; + +#define N_CORE_ERRORS (sizeof core_errors / sizeof (pdc_error_info)) + + +static void +pdc_panic(pdc_core *pdc, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vsprintf(pdc->errbuf, fmt, ap); + va_end(ap); + + pdc->errnum = PDF_UnknownError; + (*pdc->errorhandler)(pdc->opaque, pdc->errnum, pdc->errbuf); +} /* pdc_panic */ + + +static void +check_parms(pdc_core *pdc, pdc_error_info *ei) +{ + const char *msg = ei->errmsg; + const char *dollar; + + while ((dollar = strchr(msg, '$')) != (char *) 0) + { + if (isdigit(dollar[1])) + { + int n = dollar[1] - '0'; + + if (ei->nparms < n || n < 1) + pdc_panic(pdc, "illegal parameter '$%d' in error message %d", + n, ei->errnum); + } + else if (dollar[1] != '$') + { + pdc_panic(pdc, + "illegal '$' in error message %d", ei->errnum); + } + + msg = dollar + 1; + } +} /* check_parms */ + + +void +pdc_register_errtab(pdc_core *pdc, int et, pdc_error_info *ei, int n_entries) +{ + int i; + int n = (et / 1000) - 1; + + if (n < 0 || N_ERRTABS <= n || et % 1000 != 0) + pdc_panic(pdc, "tried to register unknown error table %d", et); + + /* ignore multiple registrations of the same table. + */ + if (pdc->err_tables[n].ei != (pdc_error_info *) 0) + return; + + check_parms(pdc, &ei[0]); + + for (i = 1; i < n_entries; ++i) + { + if (ei[i].errnum <= ei[i-1].errnum) + { + pdc_panic(pdc, + "duplicate or misplaced error number %d", ei[i].errnum); + } + + check_parms(pdc, &ei[i]); + } + + pdc->err_tables[n].ei = ei; + pdc->err_tables[n].n_entries = n_entries; +} /* pdc_register_errtab */ + + +/* pdc_init_core() never throws exceptions. +** it returns NULL if there's not enough memory. +*/ +pdc_core * +pdc_init_core( + pdc_error_fp errorhandler, + pdc_alloc_fp allocproc, + pdc_realloc_fp reallocproc, + pdc_free_fp freeproc, + void *opaque) +{ + static const char fn[] = "pdc_init_core"; + + pdc_core *pdc; + int i; + + /* if allocproc is NULL, we use pdc's default memory handling. + */ + if (allocproc == (pdc_alloc_fp) 0) + { + allocproc = default_malloc; + reallocproc = default_realloc; + freeproc = default_free; + } + + if (errorhandler == (pdc_error_fp) 0) + errorhandler = default_errorhandler; + + pdc = (pdc_core *) (*allocproc)(opaque, sizeof (pdc_core), fn); + + if (pdc == (pdc_core *) 0) + return (pdc_core *) 0; + + pdc->errorhandler = errorhandler; + pdc->allocproc = allocproc; + pdc->reallocproc = reallocproc; + pdc->freeproc = freeproc; + pdc->opaque = opaque; + + pdc->trace = pdc_false; + pdc->tracefilename = NULL; + pdc->floatdigits = 4; + + /* initialize error & exception handling. + */ + pdc->warnings_enabled = pdc_true; + pdc->in_error = pdc_false; + pdc->x_thrown = pdc_false; + pdc->epcount = 0; + pdc->errnum = 0; + pdc->apiname = ""; + pdc->x_sp = -1; + pdc->x_ssize = PDC_XSTACK_INISIZE; + pdc->x_stack = (pdc_xframe *) + (*allocproc)(opaque, pdc->x_ssize * sizeof (pdc_xframe), fn); + + if (pdc->x_stack == (pdc_xframe *) 0) + { + (*freeproc)(opaque, pdc); + return (pdc_core *) 0; + } + + /* initialize error tables. + */ + for (i = 0; i < N_ERRTABS; ++i) + pdc->err_tables[i].ei = (pdc_error_info *) 0; + + pdc_register_errtab(pdc, PDC_ET_CORE, core_errors, N_CORE_ERRORS); + + return pdc; +} + +void +pdc_delete_core(pdc_core *pdc) +{ + int i; + + if (pdc->tracefilename) + pdc_free(pdc, pdc->tracefilename); + + pdc_free(pdc, pdc->x_stack); + + + pdc_free(pdc, pdc); +} + +/* --------------------------- memory management --------------------------- */ + +void * +pdc_malloc(pdc_core *pdc, size_t size, const char *caller) +{ + void *ret; + + /* the behavior of malloc(0) is undefined in ANSI C, and may + * result in a NULL pointer return value which makes PDFlib bail out. + */ + if (size == (size_t) 0 || (long) size < 0L) { + size = (size_t) 1; + pdc_warning(pdc, PDC_E_INT_ALLOC0, caller, 0, 0, 0); + } + + if ((ret = (*pdc->allocproc)(pdc->opaque, size, caller)) == (void *) 0) + { + pdc_error(pdc, PDC_E_MEM_OUT, caller, 0, 0, 0); + } + + return ret; +} + +/* We cook up our own calloc routine, using the caller-supplied + * malloc and memset. + */ +void * +pdc_calloc(pdc_core *pdc, size_t size, const char *caller) +{ + void *ret; + + if (size == (size_t) 0 || (long) size < 0L) { + size = (size_t) 1; + pdc_warning(pdc, PDC_E_INT_ALLOC0, caller, 0, 0, 0); + } + + if ((ret = (*pdc->allocproc)(pdc->opaque, size, caller)) == (void *) 0) + { + pdc_error(pdc, PDC_E_MEM_OUT, caller, 0, 0, 0); + } + + memset(ret, 0, size); + return ret; +} + +void * +pdc_realloc(pdc_core *pdc, void *mem, size_t size, const char *caller) +{ + void *ret; + + if (size == (size_t) 0 || (long) size < 0L) { + size = (size_t) 1; + pdc_warning(pdc, PDC_E_INT_ALLOC0, caller, 0, 0, 0); + } + + if ((ret = (*pdc->reallocproc)(pdc->opaque, mem, size, caller)) + == (void *) 0) + pdc_error(pdc, PDC_E_MEM_OUT, caller, 0, 0, 0); + + return ret; +} + +void +pdc_free(pdc_core *pdc, void *mem) +{ + /* just in case the freeproc() isn't that ANSI compatible... + */ + if (mem != NULL) + (*pdc->freeproc)(pdc->opaque, mem); +} + + +/* --------------------------- exception handling --------------------------- */ + +const char *pdc_errprintf(pdc_core *pdc, const char *fmt, ...) +{ + va_list ap; + + if (pdc->epcount < 0 || pdc->epcount > 3) + pdc->epcount = 0; + + va_start(ap, fmt); + vsprintf(pdc->errparms[pdc->epcount], fmt, ap); + va_end(ap); + + return pdc->errparms[pdc->epcount++]; +} + +static pdc_error_info * +get_error_info(pdc_core *pdc, int errnum) +{ + int n = (errnum / 1000) - 1; + + if (0 <= n && n < N_ERRTABS && pdc->err_tables[n].ei != 0) + { + error_table *etab = &pdc->err_tables[n]; + int i; + + /* LATER: binary search. */ + for (i = 0; i < etab->n_entries; ++i) + { + if (etab->ei[i].errnum == errnum) + return &etab->ei[i]; + } + } + + pdc_panic(pdc, "Internal error: unknown error number %d", errnum); + + return (pdc_error_info *) 0; /* for the compiler */ +} /* get_error_info */ + + +static void +make_errmsg( + pdc_core * pdc, + pdc_error_info * ei, + const char * parm1, + const char * parm2, + const char * parm3, + const char * parm4) +{ + const char *src = ei->ce_msg ? ei->ce_msg : ei->errmsg; + char * dst = pdc->errbuf; + const char *dollar; + + pdc->epcount = 0; + + /* copy *src to *dst, replacing "$N" with *parmN. + */ + while ((dollar = strchr(src, '$')) != (char *) 0) + { + const char *parm = (const char *) 0; + + memcpy(dst, src, (size_t) (dollar - src)); + dst += dollar - src; + src = dollar + 1; + + switch (*src) + { + case '1': parm = (parm1 ? parm1 : "?"); break; + case '2': parm = (parm2 ? parm2 : "?"); break; + case '3': parm = (parm3 ? parm3 : "?"); break; + case '4': parm = (parm4 ? parm4 : "?"); break; + + case 0: break; + + default: *(dst++) = *(src++); + break; + } + + if (parm != (const char *) 0) + { + ++src; + strcpy(dst, parm); + dst += strlen(parm); + } + } + + strcpy(dst, src); +} /* make_errmsg */ + + +void +pdc_set_errmsg( + pdc_core * pdc, + int errnum, + const char *parm1, + const char *parm2, + const char *parm3, + const char *parm4) +{ + pdc_error_info *ei = get_error_info(pdc, errnum); + + make_errmsg(pdc, ei, parm1, parm2, parm3, parm4); + pdc->errnum = errnum; +} /* pdc_set_errmsg */ + + +void +pdc_error( + pdc_core * pdc, + int errnum, + const char *parm1, + const char *parm2, + const char *parm3, + const char *parm4) +{ + if (pdc->in_error) /* avoid recursive errors. */ + return; + else + { + pdc->in_error = pdc_true; + pdc->x_thrown = pdc_true; + } + + if (errnum != -1) + { + pdc_error_info *ei = get_error_info(pdc, errnum); + + make_errmsg(pdc, ei, parm1, parm2, parm3, parm4); + pdc->errnum = errnum; + } + + pdc_trace(pdc, "\n[+++ exception %d in %s, %s +++]\n", + pdc->errnum, (pdc->errnum == 0) ? "" : pdc->apiname, + (pdc->x_sp == -1 ? "error handler active" : "try/catch active")); + pdc_trace(pdc, "[\"%s\"]\n\n", pdc->errbuf); + + if (pdc->x_sp == -1) { + char errbuf[PDC_ERRBUF_SIZE]; + + sprintf(errbuf, "[%d] %s: %s", + pdc->errnum, pdc_get_apiname(pdc), pdc->errbuf); + (*pdc->errorhandler)(pdc->opaque, PDF_UnknownError, errbuf); + + /* + * The error handler must never return. If it does, it is severely + * broken. We cannot remedy this, so we exit. + */ + exit(99); + + } else { + + longjmp(pdc->x_stack[pdc->x_sp].jbuf.jbuf, 1); + } + +} /* pdc_error */ + + +void +pdc_warning( + pdc_core * pdc, + int errnum, + const char *parm1, + const char *parm2, + const char *parm3, + const char *parm4) +{ + if (pdc->in_error || pdc->warnings_enabled == pdc_false) + return; + else + { + pdc->in_error = pdc_true; + pdc->x_thrown = pdc_true; + } + + if (errnum != -1) + { + pdc_error_info *ei = get_error_info(pdc, errnum); + + make_errmsg(pdc, ei, parm1, parm2, parm3, parm4); + pdc->errnum = errnum; + } + + pdc_trace(pdc, "\n[+++ warning %d in %s, %s +++]\n", + pdc->errnum, (pdc->errnum == 0) ? "" : pdc->apiname, + (pdc->x_sp == -1 ? "error handler active" : "try/catch active")); + pdc_trace(pdc, "[\"%s\"]\n\n", pdc->errbuf); + + if (pdc->x_sp == -1) { + char errbuf[PDC_ERRBUF_SIZE]; + + sprintf(errbuf, "[%d] %s: %s", + pdc->errnum, pdc_get_apiname(pdc), pdc->errbuf); + (*pdc->errorhandler)(pdc->opaque, PDF_NonfatalError, errbuf); + + } else { + + longjmp(pdc->x_stack[pdc->x_sp].jbuf.jbuf, 1); + } + + /* a client-supplied error handler may return after a warning */ + pdc->in_error = pdc_false; + +} /* pdc_warning */ + + +pdc_jmpbuf * +pdc_jbuf(pdc_core *pdc) +{ + static const char fn[] = "pdc_jbuf"; + + if (++pdc->x_sp == pdc->x_ssize) + { + /* TODO: test */ + pdc_xframe *aux = (pdc_xframe *) (*pdc->reallocproc)( + pdc->opaque, pdc->x_stack, + 2 * pdc->x_ssize * sizeof (pdc_xframe), fn); + + if (aux == (pdc_xframe *) 0) + { + --pdc->x_sp; + pdc->errnum = PDC_E_MEM_OUT; + pdc->x_thrown = pdc_true; + pdc->in_error = pdc_true; + strcpy(pdc->errbuf, "out of memory"); + longjmp(pdc->x_stack[pdc->x_sp].jbuf.jbuf, 1); + } + + pdc->x_stack = aux; + pdc->x_ssize *= 2; + } + + pdc->x_thrown = pdc_false; + return &pdc->x_stack[pdc->x_sp].jbuf; +} /* pdc_jbuf */ + +void +pdc_exit_try(pdc_core *pdc) +{ + if (pdc->x_sp == -1) + { + strcpy(pdc->errbuf, "exception stack underflow"); + pdc->errnum = PDC_E_INT_XSTACK; + (*pdc->errorhandler)(pdc->opaque, PDF_UnknownError, pdc->errbuf); + } + else + --pdc->x_sp; +} /* pdc_exit_try */ + +int +pdc_catch_intern(pdc_core *pdc) +{ + pdc_bool result; + + if (pdc->x_sp == -1) + { + strcpy(pdc->errbuf, "exception stack underflow"); + pdc->errnum = PDC_E_INT_XSTACK; + (*pdc->errorhandler)(pdc->opaque, PDF_UnknownError, pdc->errbuf); + } + else + --pdc->x_sp; + + result = pdc->x_thrown; + pdc->in_error = pdc_false; + pdc->x_thrown = pdc_false; + + return result; +} /* pdc_catch_intern */ + +int +pdc_catch_extern(pdc_core *pdc) +{ + pdc_bool result; + + if (pdc->x_sp == -1) + { + strcpy(pdc->errbuf, "exception stack underflow"); + pdc->errnum = PDC_E_INT_XSTACK; + (*pdc->errorhandler)(pdc->opaque, PDF_UnknownError, pdc->errbuf); + } + else + --pdc->x_sp; + + result = pdc->x_thrown; + pdc->x_thrown = pdc_false; + + return result; +} /* pdc_catch_extern */ + +void +pdc_rethrow(pdc_core *pdc) +{ + pdc_error(pdc, -1, 0, 0, 0, 0); +} /* pdc_rethrow */ + + +int +pdc_get_errnum(pdc_core *pdc) +{ + return pdc->errnum; +} + +const char * +pdc_get_errmsg(pdc_core *pdc) +{ + return (pdc->errnum == 0) ? "" : pdc->errbuf; +} + +const char * +pdc_get_apiname(pdc_core *pdc) +{ + return (pdc->errnum == 0) ? "" : pdc->apiname; +} + + +/* --------------------------- debug trace --------------------------- */ + +static const char digits[] = "0123456789ABCDEF"; + +static char * +pdc_ltoa(char *buf, long n, int width, char pad, int base) +{ + char aux[20]; + int k, i = sizeof aux; + char * dest = buf; + unsigned long ul = (unsigned long) n; + + if (n == 0) + { + if (width == 0) + width = 1; + + for (k = 0; k < width; ++k) + *(dest++) = '0'; + + return dest; + } + + if (n < 0 && base == 10) + { + ul = (unsigned long) -ul; /* safe against overflow, + while "n = -n" isn't! */ + *(dest++) = '-'; + } + + aux[--i] = digits[ul % base]; + n = (long) (ul / base); + + while (0 < n) + { + aux[--i] = digits[n % base]; + n = n / base; + } + + width -= (int) (sizeof aux) - i; + for (k = 0; k < width; ++k) + *(dest++) = pad; + + memcpy(dest, &aux[i], sizeof aux - i); + return dest + sizeof aux - i; +} /* pdc_ltoa */ + +/* Acrobat viewers have an upper limit on real and integer numbers */ +#define PDF_BIGREAL (32768.0) +#define PDF_BIGINT (2147483647.0) + +static char * +pdc_ftoa(pdc_core *pdc, char *buf, double x) +{ + static const long pow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000 }; + + char * dest = buf; + double integ, fract; + long f; + + if (fabs(x) < PDF_SMALLREAL) + { + *dest = '0'; + return dest + 1; + } + + if (x < 0) + { + x = -x; + *(dest++) = '-'; + } + + if (x >= PDF_BIGREAL) + { + if (x > PDF_BIGINT) + pdc_error(pdc, PDC_E_INT_FLOATTOOLARGE, 0, 0, 0, 0); + + return pdc_ltoa(dest, (long) floor(x + 0.5), 0, ' ', 10); + } + + fract = modf(x, &integ); + f = (long) floor(fract * pow10[pdc->floatdigits] + 0.5); + + if (f == pow10[pdc->floatdigits]) + { + integ += 1.0; + f = 0; + } + + if (integ == 0 && f == 0) /* avoid "-0" */ + dest = buf; + + dest = pdc_ltoa(dest, (long) integ, 0, ' ', 10); + + if (f != 0) + { + char * aux; + int i = pdc->floatdigits; + long rem; + + *(dest++) = '.'; + + do /* avoid trailing zeros */ + { + rem = f % 10; + f = f / 10; + --i; + } while (rem == 0); + + aux = dest + i + 1; + dest[i--] = digits[rem]; + + for (; 0 <= i; --i) + { + dest[i] = digits[f % 10]; + f = f / 10; + } + + return aux; + } + + return dest; +} /* pdc_ftoa */ + +int +pdc_vsprintf(pdc_core *pdc, char *buf, const char *format, va_list args) +{ + char *dest = buf; + + for (/* */ ; /* */ ; /* */) + { + int width = 0; + char pad = ' '; + + /* as long as there is no '%', just print. + */ + while (*format != 0 && *format != '%') + *(dest++) = *(format++); + + if (*format == 0) + { + *dest = 0; + return dest - buf; + } + + if (*(++format) == '0') + { + pad = '0'; + ++format; + } + + while (isdigit(*format)) + width = 10*width + *(format++) - '0'; + + switch (*format) + { + case 'X': + dest = pdc_ltoa(dest, va_arg(args, int), width, pad, 16); + break; + + case 'c': + *(dest++) = (char) va_arg(args, int); + break; + + case 'd': + dest = pdc_ltoa(dest, va_arg(args, int), width, pad, 10); + break; + + case 'g': /* for use in pdc_trace_api() */ + case 'f': + dest = pdc_ftoa(pdc, dest, va_arg(args, double)); + break; + + case 'l': + { + long n = va_arg(args, long); + + switch (*(++format)) + { + case 'X': + dest = pdc_ltoa(dest, n, width, pad, 16); + break; + + case 'd': + dest = pdc_ltoa(dest, n, width, pad, 10); + break; + + default: + pdc_error(pdc, PDC_E_INT_BADFORMAT, + pdc_errprintf(pdc, "l%c", + isprint(*format) ? *format : '?'), + pdc_errprintf(pdc, "0x%02X", *format), + 0, 0); + } + + break; + } + + case 'p': + { + void *ptr = va_arg(args, void *); + dest += sprintf(dest, "%p", ptr); + break; + } + + case 's': + { + char * str = va_arg(args, char *); + size_t len; + + if (str == 0) + str = "(NULL)"; + + if ((len = strlen(str)) != 0) + { + memcpy(dest, str, len); + dest += len; + } + break; + } + + case '%': + *(dest++) = '%'; + break; + + default: + pdc_error(pdc, PDC_E_INT_BADFORMAT, + pdc_errprintf(pdc, "%c", isprint(*format) ? *format : '?'), + pdc_errprintf(pdc, "0x%02X", *format), + 0, 0); + } /* switch */ + + ++format; + } /* loop */ +} /* pdc_vsprintf */ + +void +pdc_set_floatdigits(pdc_core *pdc, int val) +{ + pdc->floatdigits = val; +} + +void +pdc_set_tracefile(pdc_core *pdc, const char *filename) +{ + if (!filename || !*filename) + return; + + if (pdc->tracefilename) + pdc_free(pdc, pdc->tracefilename); + + pdc->tracefilename = pdc_strdup(pdc, filename); +} + +/* Include informational stuff in [] brackets, and use + %s/\[[^]]*\]//g and + %s/)$/);/ + * to make it compilable :-) + */ + +/* start or stop (client == NULL) a trace for the supplied client program */ +void +pdc_set_trace(pdc_core *pdc, const char *client) +{ +#ifndef WINCE + time_t timer; + struct tm ltime; + + time(&timer); + ltime = *localtime(&timer); +#else + SYSTEMTIME st; + + GetLocalTime (&st); +#endif + + pdc->trace = client ? pdc_true : pdc_false; + + if (pdc->trace) { + pdc_trace(pdc, + "[ ------------------------------------------------------ ]\n"); + pdc_trace(pdc, "[ %s on %s ] ", client, PDF_PLATFORM); + pdc_trace(pdc, "[%04d-%02d-%02d]\n", +#ifndef WINCE + ltime.tm_year + 1900, ltime.tm_mon + 1, ltime.tm_mday); +#else + st.wYear, st.wMonth, st.wDay); +#endif /* !WINCE */ + + pdc_trace(pdc, + "[ ------------------------------------------------------ ]\n"); + } +} + +/* trace function: version for pdf_enter_api() with + * time stamp and function name output. + */ +void +pdc_trace_api(pdc_core *pdc, const char *funame, const char *fmt, va_list args) +{ + FILE * fp; + const char *filename; + char buf[2000]; +#ifndef WINCE + time_t timer; + struct tm ltime; +#else + SYSTEMTIME st; +#endif + + if (!pdc || !pdc->trace) + return; + + filename = pdc->tracefilename ? pdc->tracefilename : DEBUG_TRACE_FILE; + + if ((fp = fopen(filename, APPENDMODE)) == NULL) + return; + +#ifndef WINCE + time(&timer); + ltime = *localtime(&timer); + fprintf(fp, "[%02d:%02d:%02d] ", ltime.tm_hour, ltime.tm_min, ltime.tm_sec); + +#else + + GetLocalTime (&st); + fprintf(fp, "[%02d:%02d:%02d] ", st.wHour, st.wMinute, st.wSecond); +#endif /* WINCE */ + + fprintf(fp, "%s\t", funame); + pdc_vsprintf(pdc, buf, fmt, args); + fprintf(fp, "%s", buf); + + fclose(fp); +} + +/* trace function: version without any decoration for return values etc.*/ +void +pdc_trace(pdc_core *pdc, const char *fmt, ...) +{ + FILE *fp; + const char *filename; + va_list ap; + + if (!pdc || !pdc->trace) + return; + + filename = pdc->tracefilename ? pdc->tracefilename : DEBUG_TRACE_FILE; + + if ((fp = fopen(filename, APPENDMODE)) == NULL) + return; + + va_start(ap, fmt); + vfprintf(fp, fmt, ap); + va_end(ap); + + fclose(fp); +} + diff --git a/src/libs/pdflib/libs/pdcore/pc_core.h b/src/libs/pdflib/libs/pdcore/pc_core.h new file mode 100644 index 0000000000..04a95fbc5e --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_core.h @@ -0,0 +1,205 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_core.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib core services: + * - memory management + * - exception handling + * - internal try/catch + * - debug tracing + */ + +#ifndef PC_CORE_H +#define PC_CORE_H + +/* Built-in metric support */ +#define PDF_BUILTINMETRIC_SUPPORTED + +/* Built-in encoding support */ +#define PDF_BUILTINENCODING_SUPPORTED + + +#define PDF_FEATURE_NOT_PUBLIC + + +/* ------------------------- general ------------------------- */ + +typedef struct pdc_core_s pdc_core; + +typedef int pdc_bool; +typedef long pdc_id; +typedef char pdc_char; +typedef unsigned char pdc_byte; +typedef short pdc_short; +typedef unsigned short pdc_ushort; +typedef int pdc_long; +typedef unsigned int pdc_ulong; + +typedef short pdc_sint16; +typedef unsigned short pdc_uint16; +typedef int pdc_sint32; +typedef unsigned int pdc_uint32; + +#define pdc_undef -1 +#define pdc_false 0 +#define pdc_true 1 + +#define PDC_BOOLSTR(a) (a != 0 ? "true" : "false") + +#ifndef MIN +#define MIN(a,b) (a <= b ? a : b) +#endif +#ifndef MAX +#define MAX(a,b) (a >= b ? a : b) +#endif + +#define PDC_1_3 13 /* PDF 1.3 = Acrobat 4 */ +#define PDC_1_4 14 /* PDF 1.4 = Acrobat 5 */ +#define PDC_1_5 15 /* PDF 1.5 = Acrobat 6 */ +#define PDC_X_X_LAST 15 + + +typedef void (*pdc_error_fp)(void *opaque, int type, const char *msg); +typedef void* (*pdc_alloc_fp)(void *opaque, size_t size, const char *caller); +typedef void* (*pdc_realloc_fp)(void *opaque, void *mem, size_t size, + const char *caller); +typedef void (*pdc_free_fp)(void *opaque, void *mem); + +pdc_core *pdc_init_core(pdc_error_fp errorhandler, pdc_alloc_fp allocproc, + pdc_realloc_fp reallocproc, pdc_free_fp freeproc, void *opaque); + +void pdc_delete_core(pdc_core *pdc); + +/* this is used by pdflib and pdi sources, so i put it here... +*/ +typedef enum { + use_none = 0, use_art, use_bleed, use_crop, use_media, use_trim +} pdc_usebox; + +/* ------------------------- memory management ------------------------- */ + +void *pdc_malloc(pdc_core *pdc, size_t size, const char *caller); +void *pdc_realloc(pdc_core *pdc, void *mem, size_t size, const char *caller); +void *pdc_calloc(pdc_core *pdc, size_t size, const char *caller); +void pdc_free(pdc_core *pdc, void *mem); + +/* --------------------------- exception handling --------------------------- */ + +/* per-library error table base numbers. +*/ +#define PDC_ET_CORE 1000 +#define PDC_ET_PDFLIB 2000 +#define PDC_ET_PDI 4000 +#define PDC_ET_PSP 5000 +#define PDC_ET_PDPAGE 6000 + +#define PDC_ET_LAST 6000 + +/* core error numbers. +*/ +enum +{ +#define pdc_genNames 1 +#include "pc_generr.h" + + PDC_E_dummy +}; + +typedef struct +{ + int nparms; /* number of error parameters */ + int errnum; /* error number */ + const char *errmsg; /* default error message */ + const char *ce_msg; /* custom error message */ +} pdc_error_info; + +void pdc_register_errtab(pdc_core *pdc, int et, pdc_error_info *ei, + int n_entries); + +pdc_bool pdc_enter_api(pdc_core *pdc, const char *apiname); +pdc_bool pdc_in_error(pdc_core *pdc); +void pdc_set_warnings(pdc_core *pdc, pdc_bool on); + +const char * pdc_errprintf(pdc_core *pdc, const char *format, ...); + +void pdc_set_errmsg(pdc_core *pdc, int errnum, const char *parm1, + const char *parm2, const char *parm3, const char *parm4); + +void pdc_error(pdc_core *pdc, int errnum, const char *parm1, + const char *parm2, const char *parm3, const char *parm4); + +void pdc_warning(pdc_core *pdc, int errnum, const char *parm1, + const char *parm2, const char *parm3, const char *parm4); + +int pdc_get_errnum(pdc_core *pdc); +const char * pdc_get_errmsg(pdc_core *pdc); +const char * pdc_get_apiname(pdc_core *pdc); + +/* ----------------------------- try/catch ---------------------------- */ + +#include + +typedef struct +{ + jmp_buf jbuf; +} pdc_jmpbuf; + +pdc_jmpbuf * pdc_jbuf(pdc_core *pdc); +void pdc_exit_try(pdc_core *pdc); +int pdc_catch_intern(pdc_core *pdc); +int pdc_catch_extern(pdc_core *pdc); +void pdc_rethrow(pdc_core *pdc); + +#define PDC_TRY(pdc) if (setjmp(pdc_jbuf(pdc)->jbuf) == 0) + +#define PDC_EXIT_TRY(pdc) pdc_exit_try(pdc) + +#define PDC_CATCH(pdc) if (pdc_catch_intern(pdc)) + +#define PDC_RETHROW(pdc) pdc_rethrow(pdc) + + +/* --------------------------- debug trace --------------------------- */ + +# ifndef DEBUG_TRACE_FILE +# if defined(MVS) +# define DEBUG_TRACE_FILE "pdftrace" +# elif defined(MAC) || defined(AS400) +# define DEBUG_TRACE_FILE "PDFlib.trace" +# elif defined(WIN32) +# define DEBUG_TRACE_FILE "/PDFlib.trace" +# else +# define DEBUG_TRACE_FILE "/tmp/PDFlib.trace" +# endif +# endif +# define PDF_TRACE(ARGS) pdc_trace ARGS + +int pdc_vsprintf(pdc_core *pdc, char *buf, const char *fmt, va_list args); +void pdc_set_floatdigits(pdc_core *pdc, int val); +void pdc_set_tracefile(pdc_core *pdc, const char *filename); +void pdc_set_trace(pdc_core *pdc, const char *client); +void pdc_trace(pdc_core *pdc, const char *fmt, ...); +void pdc_trace_api(pdc_core *pdc, const char *funame, + const char *fmt, va_list args); + +/* --------------------------- scope --------------------------- */ + +/* + * An arbitrary number used for sanity checks. + * Actually, we use the hex representation of pi in order to avoid + * the more common patterns. + */ + +#define PDC_MAGIC ((unsigned long) 0x126960A1) + +#endif /* PC_CORE_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_corefont.c b/src/libs/pdflib/libs/pdcore/pc_corefont.c new file mode 100644 index 0000000000..1ea30d4f6e --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_corefont.c @@ -0,0 +1,238 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_corefont.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib in-core font and basic font metric functions + * + */ + +#include "pc_util.h" +#include "pc_corefont.h" + +/* PDF basic font names */ +static const char *pdc_base14_names[] = +{ + "Courier", + "Courier-Bold", + "Courier-Oblique", + "Courier-BoldOblique", + "Helvetica", + "Helvetica-Bold", + "Helvetica-Oblique", + "Helvetica-BoldOblique", + "Symbol", + "Times-Roman", + "Times-Bold", + "Times-Italic", + "Times-BoldItalic", + "ZapfDingbats" +}; + +const char * +pdc_get_base14_name(int slot) +{ + if (slot < (int)(sizeof(pdc_base14_names) / sizeof(pdc_base14_names[0]))) + return(pdc_base14_names[slot]); + else + return(NULL); +} + +#ifdef PDF_BUILTINMETRIC_SUPPORTED + +/* Basic fonts core metrics */ +#include "pc_coremetr.h" +static const pdc_core_metric *pdc_core_metrics[] = +{ + &pdc_core_metric_01, + &pdc_core_metric_02, + &pdc_core_metric_03, + &pdc_core_metric_04, + &pdc_core_metric_05, + &pdc_core_metric_06, + &pdc_core_metric_07, + &pdc_core_metric_08, + &pdc_core_metric_09, + &pdc_core_metric_10, + &pdc_core_metric_11, + &pdc_core_metric_12, + &pdc_core_metric_13, + &pdc_core_metric_14 +}; + +#endif /* PDF_BUILTINMETRIC_SUPPORTED */ + +const pdc_core_metric * +pdc_get_core_metric(const char *fontname) +{ +#ifdef PDF_BUILTINMETRIC_SUPPORTED + const pdc_core_metric *metric = NULL; + int slot; + + for (slot = 0; + slot < (int)(sizeof(pdc_core_metrics) / sizeof(pdc_core_metrics[0])); + slot++) + { + metric = pdc_core_metrics[slot]; + if (!strcmp(metric->name, fontname)) + return metric; + } +#endif /* PDF_BUILTINMETRIC_SUPPORTED */ + return(NULL); +} + +void +pdc_init_core_metric(pdc_core *pdc, pdc_core_metric *metric) +{ + (void) pdc; + + metric->name = NULL; + metric->flags = 0L; + metric->type = pdc_Type1; + metric->charcoll = cc_none; + + metric->italicAngle = 0; + metric->isFixedPitch = pdc_false; + metric->llx = (float) -50; + metric->lly = (float) -200; + metric->urx = (float) 1000; + metric->ury = (float) 900; + metric->underlinePosition = -100; + metric->underlineThickness = 50; + metric->ascender = 800; + metric->descender = -200; + metric->capHeight = 700; + metric->xHeight = 0; + metric->StdHW = 0; + metric->StdVW = 0; + metric->numOfInter = 0; + metric->ciw = NULL; + metric->numOfGlyphs = 0; + metric->glw = NULL; + +} + +void +pdc_cleanup_core_metric(pdc_core *pdc, pdc_core_metric *metric) +{ + if (metric == NULL) + return; + + if (metric->name) + pdc_free(pdc, metric->name); + + if (metric->glw != NULL) { + pdc_free(pdc, metric->glw); + } + +} + + +/* + * Fill up core metric struct from font struct + */ +void +pdc_fill_core_metric(pdc_core *pdc, pdc_font *font, pdc_core_metric *metric) +{ + static const char fn[] = "pdc_fill_core_metric"; + + /* Fill up core metric struct */ + metric->name = pdc_strdup(pdc, font->name); + metric->flags = font->flags; + metric->type = font->type; + metric->charcoll = font->charcoll; + metric->italicAngle = font->italicAngle; + metric->isFixedPitch = font->isFixedPitch; + metric->llx = font->llx; + metric->lly = font->lly; + metric->urx = font->urx; + metric->ury = font->ury; + metric->underlinePosition = font->underlinePosition; + metric->underlineThickness = font->underlineThickness; + metric->capHeight = font->capHeight; + metric->xHeight = font->xHeight; + metric->ascender = font->ascender; + metric->descender = font->descender; + metric->StdVW = font->StdVW; + + /* Generate Glyph width array */ + metric->numOfGlyphs = font->numOfGlyphs; + if (metric->numOfGlyphs) + { + metric->glw = (pdc_glyphwidth *) pdc_calloc(pdc, + font->numOfGlyphs * sizeof(pdc_glyphwidth), fn); + memcpy(metric->glw, font->glw, + font->numOfGlyphs * sizeof(pdc_glyphwidth)); + } + +} + + +/* + * Fill up font metric struct from core metric struct + */ +void +pdc_fill_font_metric(pdc_core *pdc, pdc_font *font, + const pdc_core_metric *metric) +{ + static const char fn[] = "pdc_fill_font_metric"; + + /* Fill up font metric struct. Font struct must be initialized */ + font->name = pdc_strdup(pdc, metric->name); + font->flags = metric->flags; + font->type = metric->type; + font->charcoll = metric->charcoll; + font->italicAngle = metric->italicAngle; + font->isFixedPitch = metric->isFixedPitch; + font->llx = metric->llx; + font->lly = metric->lly; + font->urx = metric->urx; + font->ury = metric->ury; + font->underlinePosition = metric->underlinePosition; + font->underlineThickness = metric->underlineThickness; + font->capHeight = metric->capHeight; + font->xHeight = metric->xHeight; + font->ascender = metric->ascender; + font->descender = metric->descender; + font->StdVW = metric->StdVW; + font->StdHW = metric->StdHW; + + if (metric->numOfInter && font->codeSize > 1) + { + int i; + + /* Fill up the code intervals for glyph widths */ + font->numOfWidths = metric->numOfInter; + font->widthsTab = (pdc_widthdata *) pdc_calloc(pdc, + font->numOfWidths * sizeof(pdc_widthdata), fn); + for (i = 0; i < font->numOfWidths; i++) + { + font->widthsTab[i].startcode = metric->ciw[i].startcode; + font->widthsTab[i].width = (int) metric->ciw[i].width; + } + } + + /* Generate Glyph width array */ + font->numOfGlyphs = metric->numOfGlyphs; + if (font->numOfGlyphs) + { + font->glw = (pdc_glyphwidth *) pdc_calloc(pdc, + metric->numOfGlyphs * sizeof(pdc_glyphwidth), fn); + memcpy(font->glw, metric->glw, + metric->numOfGlyphs * sizeof(pdc_glyphwidth)); + } + +} + + + + diff --git a/src/libs/pdflib/libs/pdcore/pc_corefont.h b/src/libs/pdflib/libs/pdcore/pc_corefont.h new file mode 100644 index 0000000000..eddefd2b2f --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_corefont.h @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_corefont.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Core font data structures and routines + * + */ + +#include "pc_font.h" + +#ifndef PC_COREFONT_H +#define PC_COREFONT_H + +/* Code interval width data structure */ +struct pdc_interwidth_s +{ + pdc_ushort startcode; /* start code of interval */ + pdc_ushort width; /* width of glyphs in the code interval */ +}; + +/* The in-core PDFlib font metric structure */ +struct pdc_core_metric_s { + char *name; /* font name */ + unsigned long flags; /* font flags for font descriptor */ + pdc_fonttype type; /* type of font */ + pdc_charcoll charcoll; /* CID character collection supported */ + + float italicAngle; /* AFM key: ItalicAngle */ + int isFixedPitch; /* AFM key: IsFixedPitch */ + float llx; /* AFM key: FontBBox */ + float lly; /* AFM key: FontBBox */ + float urx; /* AFM key: FontBBox */ + float ury; /* AFM key: FontBBox */ + int underlinePosition; /* AFM key: UnderlinePosition */ + int underlineThickness; /* AFM key: UnderlineThickness */ + int capHeight; /* AFM key: CapHeight */ + int xHeight; /* AFM key: XHeight */ + int ascender; /* AFM key: Ascender */ + int descender; /* AFM key: Descender */ + int StdVW; /* AFM key: StdVW */ + int StdHW; /* AFM key: StdHW */ + int numOfInter; /* # of entries in code intervals */ + pdc_interwidth *ciw; /* ptr to code intervals array */ + int numOfGlyphs; /* # of entries in glyph widths */ + pdc_glyphwidth *glw; /* ptr to glyph widths array */ + +}; + +#endif /* PC_COREFONT_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_coremetr.h b/src/libs/pdflib/libs/pdcore/pc_coremetr.h new file mode 100644 index 0000000000..958b8200fc --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_coremetr.h @@ -0,0 +1,1892 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_coremetr.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * This file contains the metrics for the 14 base fonts independent + * of an encoding. This file can be generated by the utility program + * progs/compile_metric/compile_metrics. + * + * pc_coremetr.h will be included only in pc_corefont.c. + * + */ + +#ifndef PC_COREMETR_H +#define PC_COREMETR_H + +#ifdef PDF_BUILTINMETRIC_SUPPORTED + +/* -------- Generated from Courier.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_01[315] = +{ + {0x0020, 32, 600}, {0x0021, 33, 600}, {0x0022, 34, 600}, + {0x0023, 35, 600}, {0x0024, 36, 600}, {0x0025, 37, 600}, + {0x0026, 38, 600}, {0x2019, 39, 600}, {0x0028, 40, 600}, + {0x0029, 41, 600}, {0x002a, 42, 600}, {0x002b, 43, 600}, + {0x002c, 44, 600}, {0x002d, 45, 600}, {0x002e, 46, 600}, + {0x002f, 47, 600}, {0x0030, 48, 600}, {0x0031, 49, 600}, + {0x0032, 50, 600}, {0x0033, 51, 600}, {0x0034, 52, 600}, + {0x0035, 53, 600}, {0x0036, 54, 600}, {0x0037, 55, 600}, + {0x0038, 56, 600}, {0x0039, 57, 600}, {0x003a, 58, 600}, + {0x003b, 59, 600}, {0x003c, 60, 600}, {0x003d, 61, 600}, + {0x003e, 62, 600}, {0x003f, 63, 600}, {0x0040, 64, 600}, + {0x0041, 65, 600}, {0x0042, 66, 600}, {0x0043, 67, 600}, + {0x0044, 68, 600}, {0x0045, 69, 600}, {0x0046, 70, 600}, + {0x0047, 71, 600}, {0x0048, 72, 600}, {0x0049, 73, 600}, + {0x004a, 74, 600}, {0x004b, 75, 600}, {0x004c, 76, 600}, + {0x004d, 77, 600}, {0x004e, 78, 600}, {0x004f, 79, 600}, + {0x0050, 80, 600}, {0x0051, 81, 600}, {0x0052, 82, 600}, + {0x0053, 83, 600}, {0x0054, 84, 600}, {0x0055, 85, 600}, + {0x0056, 86, 600}, {0x0057, 87, 600}, {0x0058, 88, 600}, + {0x0059, 89, 600}, {0x005a, 90, 600}, {0x005b, 91, 600}, + {0x005c, 92, 600}, {0x005d, 93, 600}, {0x005e, 94, 600}, + {0x005f, 95, 600}, {0x2018, 96, 600}, {0x0061, 97, 600}, + {0x0062, 98, 600}, {0x0063, 99, 600}, {0x0064, 100, 600}, + {0x0065, 101, 600}, {0x0066, 102, 600}, {0x0067, 103, 600}, + {0x0068, 104, 600}, {0x0069, 105, 600}, {0x006a, 106, 600}, + {0x006b, 107, 600}, {0x006c, 108, 600}, {0x006d, 109, 600}, + {0x006e, 110, 600}, {0x006f, 111, 600}, {0x0070, 112, 600}, + {0x0071, 113, 600}, {0x0072, 114, 600}, {0x0073, 115, 600}, + {0x0074, 116, 600}, {0x0075, 117, 600}, {0x0076, 118, 600}, + {0x0077, 119, 600}, {0x0078, 120, 600}, {0x0079, 121, 600}, + {0x007a, 122, 600}, {0x007b, 123, 600}, {0x007c, 124, 600}, + {0x007d, 125, 600}, {0x007e, 126, 600}, {0x00a1, 161, 600}, + {0x00a2, 162, 600}, {0x00a3, 163, 600}, {0x2044, 164, 600}, + {0x00a5, 165, 600}, {0x0192, 166, 600}, {0x00a7, 167, 600}, + {0x00a4, 168, 600}, {0x0027, 169, 600}, {0x201c, 170, 600}, + {0x00ab, 171, 600}, {0x2039, 172, 600}, {0x203a, 173, 600}, + {0xfb01, 174, 600}, {0xfb02, 175, 600}, {0x2013, 177, 600}, + {0x2020, 178, 600}, {0x2021, 179, 600}, {0x00b7, 180, 600}, + {0x00b6, 182, 600}, {0x2022, 183, 600}, {0x201a, 184, 600}, + {0x201e, 185, 600}, {0x201d, 186, 600}, {0x00bb, 187, 600}, + {0x2026, 188, 600}, {0x2030, 189, 600}, {0x00bf, 191, 600}, + {0x0060, 193, 600}, {0x00b4, 194, 600}, {0x02c6, 195, 600}, + {0x02dc, 196, 600}, {0x00af, 197, 600}, {0x02d8, 198, 600}, + {0x02d9, 199, 600}, {0x00a8, 200, 600}, {0x02da, 202, 600}, + {0x00b8, 203, 600}, {0x02dd, 205, 600}, {0x02db, 206, 600}, + {0x02c7, 207, 600}, {0x2014, 208, 600}, {0x00c6, 225, 600}, + {0x00aa, 227, 600}, {0x0141, 232, 600}, {0x00d8, 233, 600}, + {0x0152, 234, 600}, {0x00ba, 235, 600}, {0x00e6, 241, 600}, + {0x0131, 245, 600}, {0x0142, 248, 600}, {0x00f8, 249, 600}, + {0x0153, 250, 600}, {0x00df, 251, 600}, {0x00cf, -1, 600}, + {0x00e9, -1, 600}, {0x0103, -1, 600}, {0x0171, -1, 600}, + {0x011b, -1, 600}, {0x0178, -1, 600}, {0x00f7, -1, 600}, + {0x00dd, -1, 600}, {0x00c2, -1, 600}, {0x00e1, -1, 600}, + {0x00db, -1, 600}, {0x00fd, -1, 600}, {0x0219, -1, 600}, + {0x00ea, -1, 600}, {0x016e, -1, 600}, {0x00dc, -1, 600}, + {0x0105, -1, 600}, {0x00da, -1, 600}, {0x0173, -1, 600}, + {0x00cb, -1, 600}, {0x0110, -1, 600}, {0xf6c3, -1, 600}, + {0x00a9, -1, 600}, {0x0112, -1, 600}, {0x010d, -1, 600}, + {0x00e5, -1, 600}, {0x0145, -1, 600}, {0x013a, -1, 600}, + {0x00e0, -1, 600}, {0x0162, -1, 600}, {0x0106, -1, 600}, + {0x00e3, -1, 600}, {0x0116, -1, 600}, {0x0161, -1, 600}, + {0x015f, -1, 600}, {0x00ed, -1, 600}, {0x25ca, -1, 600}, + {0x0158, -1, 600}, {0x0122, -1, 600}, {0x00fb, -1, 600}, + {0x00e2, -1, 600}, {0x0100, -1, 600}, {0x0159, -1, 600}, + {0x00e7, -1, 600}, {0x017b, -1, 600}, {0x00de, -1, 600}, + {0x014c, -1, 600}, {0x0154, -1, 600}, {0x015a, -1, 600}, + {0x010f, -1, 600}, {0x016a, -1, 600}, {0x016f, -1, 600}, + {0x00b3, -1, 600}, {0x00d2, -1, 600}, {0x00c0, -1, 600}, + {0x0102, -1, 600}, {0x00d7, -1, 600}, {0x00fa, -1, 600}, + {0x0164, -1, 600}, {0x2202, -1, 600}, {0x00ff, -1, 600}, + {0x0143, -1, 600}, {0x00ee, -1, 600}, {0x00ca, -1, 600}, + {0x00e4, -1, 600}, {0x00eb, -1, 600}, {0x0107, -1, 600}, + {0x0144, -1, 600}, {0x016b, -1, 600}, {0x0147, -1, 600}, + {0x00cd, -1, 600}, {0x00b1, -1, 600}, {0x00a6, -1, 600}, + {0x00ae, -1, 600}, {0x011e, -1, 600}, {0x0130, -1, 600}, + {0x2211, -1, 600}, {0x00c8, -1, 600}, {0x0155, -1, 600}, + {0x014d, -1, 600}, {0x0179, -1, 600}, {0x017d, -1, 600}, + {0x2265, -1, 600}, {0x00d0, -1, 600}, {0x00c7, -1, 600}, + {0x013c, -1, 600}, {0x0165, -1, 600}, {0x0119, -1, 600}, + {0x0172, -1, 600}, {0x00c1, -1, 600}, {0x00c4, -1, 600}, + {0x00e8, -1, 600}, {0x017a, -1, 600}, {0x012f, -1, 600}, + {0x00d3, -1, 600}, {0x00f3, -1, 600}, {0x0101, -1, 600}, + {0x015b, -1, 600}, {0x00ef, -1, 600}, {0x00d4, -1, 600}, + {0x00d9, -1, 600}, {0x0394, -1, 600}, {0x00fe, -1, 600}, + {0x00b2, -1, 600}, {0x00d6, -1, 600}, {0x03bc, -1, 600}, + {0x00ec, -1, 600}, {0x0151, -1, 600}, {0x0118, -1, 600}, + {0x0111, -1, 600}, {0x00be, -1, 600}, {0x015e, -1, 600}, + {0x013e, -1, 600}, {0x0136, -1, 600}, {0x0139, -1, 600}, + {0x2122, -1, 600}, {0x0117, -1, 600}, {0x00cc, -1, 600}, + {0x012a, -1, 600}, {0x013d, -1, 600}, {0x00bd, -1, 600}, + {0x2264, -1, 600}, {0x00f4, -1, 600}, {0x00f1, -1, 600}, + {0x0170, -1, 600}, {0x00c9, -1, 600}, {0x0113, -1, 600}, + {0x011f, -1, 600}, {0x00bc, -1, 600}, {0x0160, -1, 600}, + {0x0218, -1, 600}, {0x0150, -1, 600}, {0x00b0, -1, 600}, + {0x00f2, -1, 600}, {0x010c, -1, 600}, {0x00f9, -1, 600}, + {0x221a, -1, 600}, {0x010e, -1, 600}, {0x0157, -1, 600}, + {0x00d1, -1, 600}, {0x00f5, -1, 600}, {0x0156, -1, 600}, + {0x013b, -1, 600}, {0x00c3, -1, 600}, {0x0104, -1, 600}, + {0x00c5, -1, 600}, {0x00d5, -1, 600}, {0x017c, -1, 600}, + {0x011a, -1, 600}, {0x012e, -1, 600}, {0x0137, -1, 600}, + {0x2212, -1, 600}, {0x00ce, -1, 600}, {0x0148, -1, 600}, + {0x0163, -1, 600}, {0x00ac, -1, 600}, {0x00f6, -1, 600}, + {0x00fc, -1, 600}, {0x2260, -1, 600}, {0x0123, -1, 600}, + {0x00f0, -1, 600}, {0x017e, -1, 600}, {0x0146, -1, 600}, + {0x00b9, -1, 600}, {0x012b, -1, 600}, {0x20ac, -1, 600} +}; + +const static pdc_core_metric pdc_core_metric_01 = +{ + "Courier", /* FontName */ + 33L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + 1, /* isFixedPitch */ + -23, /* llx */ + -250, /* lly */ + 715, /* urx */ + 805, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 562, /* CapHeight */ + 426, /* xHeight */ + 629, /* Ascender */ + -157, /* Descender */ + 51, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_01, + +}; + +/* -------- Generated from Courier-Bold.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_02[315] = +{ + {0x0020, 32, 600}, {0x0021, 33, 600}, {0x0022, 34, 600}, + {0x0023, 35, 600}, {0x0024, 36, 600}, {0x0025, 37, 600}, + {0x0026, 38, 600}, {0x2019, 39, 600}, {0x0028, 40, 600}, + {0x0029, 41, 600}, {0x002a, 42, 600}, {0x002b, 43, 600}, + {0x002c, 44, 600}, {0x002d, 45, 600}, {0x002e, 46, 600}, + {0x002f, 47, 600}, {0x0030, 48, 600}, {0x0031, 49, 600}, + {0x0032, 50, 600}, {0x0033, 51, 600}, {0x0034, 52, 600}, + {0x0035, 53, 600}, {0x0036, 54, 600}, {0x0037, 55, 600}, + {0x0038, 56, 600}, {0x0039, 57, 600}, {0x003a, 58, 600}, + {0x003b, 59, 600}, {0x003c, 60, 600}, {0x003d, 61, 600}, + {0x003e, 62, 600}, {0x003f, 63, 600}, {0x0040, 64, 600}, + {0x0041, 65, 600}, {0x0042, 66, 600}, {0x0043, 67, 600}, + {0x0044, 68, 600}, {0x0045, 69, 600}, {0x0046, 70, 600}, + {0x0047, 71, 600}, {0x0048, 72, 600}, {0x0049, 73, 600}, + {0x004a, 74, 600}, {0x004b, 75, 600}, {0x004c, 76, 600}, + {0x004d, 77, 600}, {0x004e, 78, 600}, {0x004f, 79, 600}, + {0x0050, 80, 600}, {0x0051, 81, 600}, {0x0052, 82, 600}, + {0x0053, 83, 600}, {0x0054, 84, 600}, {0x0055, 85, 600}, + {0x0056, 86, 600}, {0x0057, 87, 600}, {0x0058, 88, 600}, + {0x0059, 89, 600}, {0x005a, 90, 600}, {0x005b, 91, 600}, + {0x005c, 92, 600}, {0x005d, 93, 600}, {0x005e, 94, 600}, + {0x005f, 95, 600}, {0x2018, 96, 600}, {0x0061, 97, 600}, + {0x0062, 98, 600}, {0x0063, 99, 600}, {0x0064, 100, 600}, + {0x0065, 101, 600}, {0x0066, 102, 600}, {0x0067, 103, 600}, + {0x0068, 104, 600}, {0x0069, 105, 600}, {0x006a, 106, 600}, + {0x006b, 107, 600}, {0x006c, 108, 600}, {0x006d, 109, 600}, + {0x006e, 110, 600}, {0x006f, 111, 600}, {0x0070, 112, 600}, + {0x0071, 113, 600}, {0x0072, 114, 600}, {0x0073, 115, 600}, + {0x0074, 116, 600}, {0x0075, 117, 600}, {0x0076, 118, 600}, + {0x0077, 119, 600}, {0x0078, 120, 600}, {0x0079, 121, 600}, + {0x007a, 122, 600}, {0x007b, 123, 600}, {0x007c, 124, 600}, + {0x007d, 125, 600}, {0x007e, 126, 600}, {0x00a1, 161, 600}, + {0x00a2, 162, 600}, {0x00a3, 163, 600}, {0x2044, 164, 600}, + {0x00a5, 165, 600}, {0x0192, 166, 600}, {0x00a7, 167, 600}, + {0x00a4, 168, 600}, {0x0027, 169, 600}, {0x201c, 170, 600}, + {0x00ab, 171, 600}, {0x2039, 172, 600}, {0x203a, 173, 600}, + {0xfb01, 174, 600}, {0xfb02, 175, 600}, {0x2013, 177, 600}, + {0x2020, 178, 600}, {0x2021, 179, 600}, {0x00b7, 180, 600}, + {0x00b6, 182, 600}, {0x2022, 183, 600}, {0x201a, 184, 600}, + {0x201e, 185, 600}, {0x201d, 186, 600}, {0x00bb, 187, 600}, + {0x2026, 188, 600}, {0x2030, 189, 600}, {0x00bf, 191, 600}, + {0x0060, 193, 600}, {0x00b4, 194, 600}, {0x02c6, 195, 600}, + {0x02dc, 196, 600}, {0x00af, 197, 600}, {0x02d8, 198, 600}, + {0x02d9, 199, 600}, {0x00a8, 200, 600}, {0x02da, 202, 600}, + {0x00b8, 203, 600}, {0x02dd, 205, 600}, {0x02db, 206, 600}, + {0x02c7, 207, 600}, {0x2014, 208, 600}, {0x00c6, 225, 600}, + {0x00aa, 227, 600}, {0x0141, 232, 600}, {0x00d8, 233, 600}, + {0x0152, 234, 600}, {0x00ba, 235, 600}, {0x00e6, 241, 600}, + {0x0131, 245, 600}, {0x0142, 248, 600}, {0x00f8, 249, 600}, + {0x0153, 250, 600}, {0x00df, 251, 600}, {0x00cf, -1, 600}, + {0x00e9, -1, 600}, {0x0103, -1, 600}, {0x0171, -1, 600}, + {0x011b, -1, 600}, {0x0178, -1, 600}, {0x00f7, -1, 600}, + {0x00dd, -1, 600}, {0x00c2, -1, 600}, {0x00e1, -1, 600}, + {0x00db, -1, 600}, {0x00fd, -1, 600}, {0x0219, -1, 600}, + {0x00ea, -1, 600}, {0x016e, -1, 600}, {0x00dc, -1, 600}, + {0x0105, -1, 600}, {0x00da, -1, 600}, {0x0173, -1, 600}, + {0x00cb, -1, 600}, {0x0110, -1, 600}, {0xf6c3, -1, 600}, + {0x00a9, -1, 600}, {0x0112, -1, 600}, {0x010d, -1, 600}, + {0x00e5, -1, 600}, {0x0145, -1, 600}, {0x013a, -1, 600}, + {0x00e0, -1, 600}, {0x0162, -1, 600}, {0x0106, -1, 600}, + {0x00e3, -1, 600}, {0x0116, -1, 600}, {0x0161, -1, 600}, + {0x015f, -1, 600}, {0x00ed, -1, 600}, {0x25ca, -1, 600}, + {0x0158, -1, 600}, {0x0122, -1, 600}, {0x00fb, -1, 600}, + {0x00e2, -1, 600}, {0x0100, -1, 600}, {0x0159, -1, 600}, + {0x00e7, -1, 600}, {0x017b, -1, 600}, {0x00de, -1, 600}, + {0x014c, -1, 600}, {0x0154, -1, 600}, {0x015a, -1, 600}, + {0x010f, -1, 600}, {0x016a, -1, 600}, {0x016f, -1, 600}, + {0x00b3, -1, 600}, {0x00d2, -1, 600}, {0x00c0, -1, 600}, + {0x0102, -1, 600}, {0x00d7, -1, 600}, {0x00fa, -1, 600}, + {0x0164, -1, 600}, {0x2202, -1, 600}, {0x00ff, -1, 600}, + {0x0143, -1, 600}, {0x00ee, -1, 600}, {0x00ca, -1, 600}, + {0x00e4, -1, 600}, {0x00eb, -1, 600}, {0x0107, -1, 600}, + {0x0144, -1, 600}, {0x016b, -1, 600}, {0x0147, -1, 600}, + {0x00cd, -1, 600}, {0x00b1, -1, 600}, {0x00a6, -1, 600}, + {0x00ae, -1, 600}, {0x011e, -1, 600}, {0x0130, -1, 600}, + {0x2211, -1, 600}, {0x00c8, -1, 600}, {0x0155, -1, 600}, + {0x014d, -1, 600}, {0x0179, -1, 600}, {0x017d, -1, 600}, + {0x2265, -1, 600}, {0x00d0, -1, 600}, {0x00c7, -1, 600}, + {0x013c, -1, 600}, {0x0165, -1, 600}, {0x0119, -1, 600}, + {0x0172, -1, 600}, {0x00c1, -1, 600}, {0x00c4, -1, 600}, + {0x00e8, -1, 600}, {0x017a, -1, 600}, {0x012f, -1, 600}, + {0x00d3, -1, 600}, {0x00f3, -1, 600}, {0x0101, -1, 600}, + {0x015b, -1, 600}, {0x00ef, -1, 600}, {0x00d4, -1, 600}, + {0x00d9, -1, 600}, {0x0394, -1, 600}, {0x00fe, -1, 600}, + {0x00b2, -1, 600}, {0x00d6, -1, 600}, {0x03bc, -1, 600}, + {0x00ec, -1, 600}, {0x0151, -1, 600}, {0x0118, -1, 600}, + {0x0111, -1, 600}, {0x00be, -1, 600}, {0x015e, -1, 600}, + {0x013e, -1, 600}, {0x0136, -1, 600}, {0x0139, -1, 600}, + {0x2122, -1, 600}, {0x0117, -1, 600}, {0x00cc, -1, 600}, + {0x012a, -1, 600}, {0x013d, -1, 600}, {0x00bd, -1, 600}, + {0x2264, -1, 600}, {0x00f4, -1, 600}, {0x00f1, -1, 600}, + {0x0170, -1, 600}, {0x00c9, -1, 600}, {0x0113, -1, 600}, + {0x011f, -1, 600}, {0x00bc, -1, 600}, {0x0160, -1, 600}, + {0x0218, -1, 600}, {0x0150, -1, 600}, {0x00b0, -1, 600}, + {0x00f2, -1, 600}, {0x010c, -1, 600}, {0x00f9, -1, 600}, + {0x221a, -1, 600}, {0x010e, -1, 600}, {0x0157, -1, 600}, + {0x00d1, -1, 600}, {0x00f5, -1, 600}, {0x0156, -1, 600}, + {0x013b, -1, 600}, {0x00c3, -1, 600}, {0x0104, -1, 600}, + {0x00c5, -1, 600}, {0x00d5, -1, 600}, {0x017c, -1, 600}, + {0x011a, -1, 600}, {0x012e, -1, 600}, {0x0137, -1, 600}, + {0x2212, -1, 600}, {0x00ce, -1, 600}, {0x0148, -1, 600}, + {0x0163, -1, 600}, {0x00ac, -1, 600}, {0x00f6, -1, 600}, + {0x00fc, -1, 600}, {0x2260, -1, 600}, {0x0123, -1, 600}, + {0x00f0, -1, 600}, {0x017e, -1, 600}, {0x0146, -1, 600}, + {0x00b9, -1, 600}, {0x012b, -1, 600}, {0x20ac, -1, 600} +}; + +const static pdc_core_metric pdc_core_metric_02 = +{ + "Courier-Bold", /* FontName */ + 262177L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + 1, /* isFixedPitch */ + -113, /* llx */ + -250, /* lly */ + 749, /* urx */ + 801, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 562, /* CapHeight */ + 439, /* xHeight */ + 629, /* Ascender */ + -157, /* Descender */ + 106, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_02, + +}; + +/* -------- Generated from Courier-Oblique.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_03[315] = +{ + {0x0020, 32, 600}, {0x0021, 33, 600}, {0x0022, 34, 600}, + {0x0023, 35, 600}, {0x0024, 36, 600}, {0x0025, 37, 600}, + {0x0026, 38, 600}, {0x2019, 39, 600}, {0x0028, 40, 600}, + {0x0029, 41, 600}, {0x002a, 42, 600}, {0x002b, 43, 600}, + {0x002c, 44, 600}, {0x002d, 45, 600}, {0x002e, 46, 600}, + {0x002f, 47, 600}, {0x0030, 48, 600}, {0x0031, 49, 600}, + {0x0032, 50, 600}, {0x0033, 51, 600}, {0x0034, 52, 600}, + {0x0035, 53, 600}, {0x0036, 54, 600}, {0x0037, 55, 600}, + {0x0038, 56, 600}, {0x0039, 57, 600}, {0x003a, 58, 600}, + {0x003b, 59, 600}, {0x003c, 60, 600}, {0x003d, 61, 600}, + {0x003e, 62, 600}, {0x003f, 63, 600}, {0x0040, 64, 600}, + {0x0041, 65, 600}, {0x0042, 66, 600}, {0x0043, 67, 600}, + {0x0044, 68, 600}, {0x0045, 69, 600}, {0x0046, 70, 600}, + {0x0047, 71, 600}, {0x0048, 72, 600}, {0x0049, 73, 600}, + {0x004a, 74, 600}, {0x004b, 75, 600}, {0x004c, 76, 600}, + {0x004d, 77, 600}, {0x004e, 78, 600}, {0x004f, 79, 600}, + {0x0050, 80, 600}, {0x0051, 81, 600}, {0x0052, 82, 600}, + {0x0053, 83, 600}, {0x0054, 84, 600}, {0x0055, 85, 600}, + {0x0056, 86, 600}, {0x0057, 87, 600}, {0x0058, 88, 600}, + {0x0059, 89, 600}, {0x005a, 90, 600}, {0x005b, 91, 600}, + {0x005c, 92, 600}, {0x005d, 93, 600}, {0x005e, 94, 600}, + {0x005f, 95, 600}, {0x2018, 96, 600}, {0x0061, 97, 600}, + {0x0062, 98, 600}, {0x0063, 99, 600}, {0x0064, 100, 600}, + {0x0065, 101, 600}, {0x0066, 102, 600}, {0x0067, 103, 600}, + {0x0068, 104, 600}, {0x0069, 105, 600}, {0x006a, 106, 600}, + {0x006b, 107, 600}, {0x006c, 108, 600}, {0x006d, 109, 600}, + {0x006e, 110, 600}, {0x006f, 111, 600}, {0x0070, 112, 600}, + {0x0071, 113, 600}, {0x0072, 114, 600}, {0x0073, 115, 600}, + {0x0074, 116, 600}, {0x0075, 117, 600}, {0x0076, 118, 600}, + {0x0077, 119, 600}, {0x0078, 120, 600}, {0x0079, 121, 600}, + {0x007a, 122, 600}, {0x007b, 123, 600}, {0x007c, 124, 600}, + {0x007d, 125, 600}, {0x007e, 126, 600}, {0x00a1, 161, 600}, + {0x00a2, 162, 600}, {0x00a3, 163, 600}, {0x2044, 164, 600}, + {0x00a5, 165, 600}, {0x0192, 166, 600}, {0x00a7, 167, 600}, + {0x00a4, 168, 600}, {0x0027, 169, 600}, {0x201c, 170, 600}, + {0x00ab, 171, 600}, {0x2039, 172, 600}, {0x203a, 173, 600}, + {0xfb01, 174, 600}, {0xfb02, 175, 600}, {0x2013, 177, 600}, + {0x2020, 178, 600}, {0x2021, 179, 600}, {0x00b7, 180, 600}, + {0x00b6, 182, 600}, {0x2022, 183, 600}, {0x201a, 184, 600}, + {0x201e, 185, 600}, {0x201d, 186, 600}, {0x00bb, 187, 600}, + {0x2026, 188, 600}, {0x2030, 189, 600}, {0x00bf, 191, 600}, + {0x0060, 193, 600}, {0x00b4, 194, 600}, {0x02c6, 195, 600}, + {0x02dc, 196, 600}, {0x00af, 197, 600}, {0x02d8, 198, 600}, + {0x02d9, 199, 600}, {0x00a8, 200, 600}, {0x02da, 202, 600}, + {0x00b8, 203, 600}, {0x02dd, 205, 600}, {0x02db, 206, 600}, + {0x02c7, 207, 600}, {0x2014, 208, 600}, {0x00c6, 225, 600}, + {0x00aa, 227, 600}, {0x0141, 232, 600}, {0x00d8, 233, 600}, + {0x0152, 234, 600}, {0x00ba, 235, 600}, {0x00e6, 241, 600}, + {0x0131, 245, 600}, {0x0142, 248, 600}, {0x00f8, 249, 600}, + {0x0153, 250, 600}, {0x00df, 251, 600}, {0x00cf, -1, 600}, + {0x00e9, -1, 600}, {0x0103, -1, 600}, {0x0171, -1, 600}, + {0x011b, -1, 600}, {0x0178, -1, 600}, {0x00f7, -1, 600}, + {0x00dd, -1, 600}, {0x00c2, -1, 600}, {0x00e1, -1, 600}, + {0x00db, -1, 600}, {0x00fd, -1, 600}, {0x0219, -1, 600}, + {0x00ea, -1, 600}, {0x016e, -1, 600}, {0x00dc, -1, 600}, + {0x0105, -1, 600}, {0x00da, -1, 600}, {0x0173, -1, 600}, + {0x00cb, -1, 600}, {0x0110, -1, 600}, {0xf6c3, -1, 600}, + {0x00a9, -1, 600}, {0x0112, -1, 600}, {0x010d, -1, 600}, + {0x00e5, -1, 600}, {0x0145, -1, 600}, {0x013a, -1, 600}, + {0x00e0, -1, 600}, {0x0162, -1, 600}, {0x0106, -1, 600}, + {0x00e3, -1, 600}, {0x0116, -1, 600}, {0x0161, -1, 600}, + {0x015f, -1, 600}, {0x00ed, -1, 600}, {0x25ca, -1, 600}, + {0x0158, -1, 600}, {0x0122, -1, 600}, {0x00fb, -1, 600}, + {0x00e2, -1, 600}, {0x0100, -1, 600}, {0x0159, -1, 600}, + {0x00e7, -1, 600}, {0x017b, -1, 600}, {0x00de, -1, 600}, + {0x014c, -1, 600}, {0x0154, -1, 600}, {0x015a, -1, 600}, + {0x010f, -1, 600}, {0x016a, -1, 600}, {0x016f, -1, 600}, + {0x00b3, -1, 600}, {0x00d2, -1, 600}, {0x00c0, -1, 600}, + {0x0102, -1, 600}, {0x00d7, -1, 600}, {0x00fa, -1, 600}, + {0x0164, -1, 600}, {0x2202, -1, 600}, {0x00ff, -1, 600}, + {0x0143, -1, 600}, {0x00ee, -1, 600}, {0x00ca, -1, 600}, + {0x00e4, -1, 600}, {0x00eb, -1, 600}, {0x0107, -1, 600}, + {0x0144, -1, 600}, {0x016b, -1, 600}, {0x0147, -1, 600}, + {0x00cd, -1, 600}, {0x00b1, -1, 600}, {0x00a6, -1, 600}, + {0x00ae, -1, 600}, {0x011e, -1, 600}, {0x0130, -1, 600}, + {0x2211, -1, 600}, {0x00c8, -1, 600}, {0x0155, -1, 600}, + {0x014d, -1, 600}, {0x0179, -1, 600}, {0x017d, -1, 600}, + {0x2265, -1, 600}, {0x00d0, -1, 600}, {0x00c7, -1, 600}, + {0x013c, -1, 600}, {0x0165, -1, 600}, {0x0119, -1, 600}, + {0x0172, -1, 600}, {0x00c1, -1, 600}, {0x00c4, -1, 600}, + {0x00e8, -1, 600}, {0x017a, -1, 600}, {0x012f, -1, 600}, + {0x00d3, -1, 600}, {0x00f3, -1, 600}, {0x0101, -1, 600}, + {0x015b, -1, 600}, {0x00ef, -1, 600}, {0x00d4, -1, 600}, + {0x00d9, -1, 600}, {0x0394, -1, 600}, {0x00fe, -1, 600}, + {0x00b2, -1, 600}, {0x00d6, -1, 600}, {0x03bc, -1, 600}, + {0x00ec, -1, 600}, {0x0151, -1, 600}, {0x0118, -1, 600}, + {0x0111, -1, 600}, {0x00be, -1, 600}, {0x015e, -1, 600}, + {0x013e, -1, 600}, {0x0136, -1, 600}, {0x0139, -1, 600}, + {0x2122, -1, 600}, {0x0117, -1, 600}, {0x00cc, -1, 600}, + {0x012a, -1, 600}, {0x013d, -1, 600}, {0x00bd, -1, 600}, + {0x2264, -1, 600}, {0x00f4, -1, 600}, {0x00f1, -1, 600}, + {0x0170, -1, 600}, {0x00c9, -1, 600}, {0x0113, -1, 600}, + {0x011f, -1, 600}, {0x00bc, -1, 600}, {0x0160, -1, 600}, + {0x0218, -1, 600}, {0x0150, -1, 600}, {0x00b0, -1, 600}, + {0x00f2, -1, 600}, {0x010c, -1, 600}, {0x00f9, -1, 600}, + {0x221a, -1, 600}, {0x010e, -1, 600}, {0x0157, -1, 600}, + {0x00d1, -1, 600}, {0x00f5, -1, 600}, {0x0156, -1, 600}, + {0x013b, -1, 600}, {0x00c3, -1, 600}, {0x0104, -1, 600}, + {0x00c5, -1, 600}, {0x00d5, -1, 600}, {0x017c, -1, 600}, + {0x011a, -1, 600}, {0x012e, -1, 600}, {0x0137, -1, 600}, + {0x2212, -1, 600}, {0x00ce, -1, 600}, {0x0148, -1, 600}, + {0x0163, -1, 600}, {0x00ac, -1, 600}, {0x00f6, -1, 600}, + {0x00fc, -1, 600}, {0x2260, -1, 600}, {0x0123, -1, 600}, + {0x00f0, -1, 600}, {0x017e, -1, 600}, {0x0146, -1, 600}, + {0x00b9, -1, 600}, {0x012b, -1, 600}, {0x20ac, -1, 600} +}; + +const static pdc_core_metric pdc_core_metric_03 = +{ + "Courier-Oblique", /* FontName */ + 97L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) -12.0, /* ItalicAngle */ + 1, /* isFixedPitch */ + -27, /* llx */ + -250, /* lly */ + 849, /* urx */ + 805, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 562, /* CapHeight */ + 426, /* xHeight */ + 629, /* Ascender */ + -157, /* Descender */ + 51, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_03, + +}; + +/* -------- Generated from Courier-BoldOblique.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_04[315] = +{ + {0x0020, 32, 600}, {0x0021, 33, 600}, {0x0022, 34, 600}, + {0x0023, 35, 600}, {0x0024, 36, 600}, {0x0025, 37, 600}, + {0x0026, 38, 600}, {0x2019, 39, 600}, {0x0028, 40, 600}, + {0x0029, 41, 600}, {0x002a, 42, 600}, {0x002b, 43, 600}, + {0x002c, 44, 600}, {0x002d, 45, 600}, {0x002e, 46, 600}, + {0x002f, 47, 600}, {0x0030, 48, 600}, {0x0031, 49, 600}, + {0x0032, 50, 600}, {0x0033, 51, 600}, {0x0034, 52, 600}, + {0x0035, 53, 600}, {0x0036, 54, 600}, {0x0037, 55, 600}, + {0x0038, 56, 600}, {0x0039, 57, 600}, {0x003a, 58, 600}, + {0x003b, 59, 600}, {0x003c, 60, 600}, {0x003d, 61, 600}, + {0x003e, 62, 600}, {0x003f, 63, 600}, {0x0040, 64, 600}, + {0x0041, 65, 600}, {0x0042, 66, 600}, {0x0043, 67, 600}, + {0x0044, 68, 600}, {0x0045, 69, 600}, {0x0046, 70, 600}, + {0x0047, 71, 600}, {0x0048, 72, 600}, {0x0049, 73, 600}, + {0x004a, 74, 600}, {0x004b, 75, 600}, {0x004c, 76, 600}, + {0x004d, 77, 600}, {0x004e, 78, 600}, {0x004f, 79, 600}, + {0x0050, 80, 600}, {0x0051, 81, 600}, {0x0052, 82, 600}, + {0x0053, 83, 600}, {0x0054, 84, 600}, {0x0055, 85, 600}, + {0x0056, 86, 600}, {0x0057, 87, 600}, {0x0058, 88, 600}, + {0x0059, 89, 600}, {0x005a, 90, 600}, {0x005b, 91, 600}, + {0x005c, 92, 600}, {0x005d, 93, 600}, {0x005e, 94, 600}, + {0x005f, 95, 600}, {0x2018, 96, 600}, {0x0061, 97, 600}, + {0x0062, 98, 600}, {0x0063, 99, 600}, {0x0064, 100, 600}, + {0x0065, 101, 600}, {0x0066, 102, 600}, {0x0067, 103, 600}, + {0x0068, 104, 600}, {0x0069, 105, 600}, {0x006a, 106, 600}, + {0x006b, 107, 600}, {0x006c, 108, 600}, {0x006d, 109, 600}, + {0x006e, 110, 600}, {0x006f, 111, 600}, {0x0070, 112, 600}, + {0x0071, 113, 600}, {0x0072, 114, 600}, {0x0073, 115, 600}, + {0x0074, 116, 600}, {0x0075, 117, 600}, {0x0076, 118, 600}, + {0x0077, 119, 600}, {0x0078, 120, 600}, {0x0079, 121, 600}, + {0x007a, 122, 600}, {0x007b, 123, 600}, {0x007c, 124, 600}, + {0x007d, 125, 600}, {0x007e, 126, 600}, {0x00a1, 161, 600}, + {0x00a2, 162, 600}, {0x00a3, 163, 600}, {0x2044, 164, 600}, + {0x00a5, 165, 600}, {0x0192, 166, 600}, {0x00a7, 167, 600}, + {0x00a4, 168, 600}, {0x0027, 169, 600}, {0x201c, 170, 600}, + {0x00ab, 171, 600}, {0x2039, 172, 600}, {0x203a, 173, 600}, + {0xfb01, 174, 600}, {0xfb02, 175, 600}, {0x2013, 177, 600}, + {0x2020, 178, 600}, {0x2021, 179, 600}, {0x00b7, 180, 600}, + {0x00b6, 182, 600}, {0x2022, 183, 600}, {0x201a, 184, 600}, + {0x201e, 185, 600}, {0x201d, 186, 600}, {0x00bb, 187, 600}, + {0x2026, 188, 600}, {0x2030, 189, 600}, {0x00bf, 191, 600}, + {0x0060, 193, 600}, {0x00b4, 194, 600}, {0x02c6, 195, 600}, + {0x02dc, 196, 600}, {0x00af, 197, 600}, {0x02d8, 198, 600}, + {0x02d9, 199, 600}, {0x00a8, 200, 600}, {0x02da, 202, 600}, + {0x00b8, 203, 600}, {0x02dd, 205, 600}, {0x02db, 206, 600}, + {0x02c7, 207, 600}, {0x2014, 208, 600}, {0x00c6, 225, 600}, + {0x00aa, 227, 600}, {0x0141, 232, 600}, {0x00d8, 233, 600}, + {0x0152, 234, 600}, {0x00ba, 235, 600}, {0x00e6, 241, 600}, + {0x0131, 245, 600}, {0x0142, 248, 600}, {0x00f8, 249, 600}, + {0x0153, 250, 600}, {0x00df, 251, 600}, {0x00cf, -1, 600}, + {0x00e9, -1, 600}, {0x0103, -1, 600}, {0x0171, -1, 600}, + {0x011b, -1, 600}, {0x0178, -1, 600}, {0x00f7, -1, 600}, + {0x00dd, -1, 600}, {0x00c2, -1, 600}, {0x00e1, -1, 600}, + {0x00db, -1, 600}, {0x00fd, -1, 600}, {0x0219, -1, 600}, + {0x00ea, -1, 600}, {0x016e, -1, 600}, {0x00dc, -1, 600}, + {0x0105, -1, 600}, {0x00da, -1, 600}, {0x0173, -1, 600}, + {0x00cb, -1, 600}, {0x0110, -1, 600}, {0xf6c3, -1, 600}, + {0x00a9, -1, 600}, {0x0112, -1, 600}, {0x010d, -1, 600}, + {0x00e5, -1, 600}, {0x0145, -1, 600}, {0x013a, -1, 600}, + {0x00e0, -1, 600}, {0x0162, -1, 600}, {0x0106, -1, 600}, + {0x00e3, -1, 600}, {0x0116, -1, 600}, {0x0161, -1, 600}, + {0x015f, -1, 600}, {0x00ed, -1, 600}, {0x25ca, -1, 600}, + {0x0158, -1, 600}, {0x0122, -1, 600}, {0x00fb, -1, 600}, + {0x00e2, -1, 600}, {0x0100, -1, 600}, {0x0159, -1, 600}, + {0x00e7, -1, 600}, {0x017b, -1, 600}, {0x00de, -1, 600}, + {0x014c, -1, 600}, {0x0154, -1, 600}, {0x015a, -1, 600}, + {0x010f, -1, 600}, {0x016a, -1, 600}, {0x016f, -1, 600}, + {0x00b3, -1, 600}, {0x00d2, -1, 600}, {0x00c0, -1, 600}, + {0x0102, -1, 600}, {0x00d7, -1, 600}, {0x00fa, -1, 600}, + {0x0164, -1, 600}, {0x2202, -1, 600}, {0x00ff, -1, 600}, + {0x0143, -1, 600}, {0x00ee, -1, 600}, {0x00ca, -1, 600}, + {0x00e4, -1, 600}, {0x00eb, -1, 600}, {0x0107, -1, 600}, + {0x0144, -1, 600}, {0x016b, -1, 600}, {0x0147, -1, 600}, + {0x00cd, -1, 600}, {0x00b1, -1, 600}, {0x00a6, -1, 600}, + {0x00ae, -1, 600}, {0x011e, -1, 600}, {0x0130, -1, 600}, + {0x2211, -1, 600}, {0x00c8, -1, 600}, {0x0155, -1, 600}, + {0x014d, -1, 600}, {0x0179, -1, 600}, {0x017d, -1, 600}, + {0x2265, -1, 600}, {0x00d0, -1, 600}, {0x00c7, -1, 600}, + {0x013c, -1, 600}, {0x0165, -1, 600}, {0x0119, -1, 600}, + {0x0172, -1, 600}, {0x00c1, -1, 600}, {0x00c4, -1, 600}, + {0x00e8, -1, 600}, {0x017a, -1, 600}, {0x012f, -1, 600}, + {0x00d3, -1, 600}, {0x00f3, -1, 600}, {0x0101, -1, 600}, + {0x015b, -1, 600}, {0x00ef, -1, 600}, {0x00d4, -1, 600}, + {0x00d9, -1, 600}, {0x0394, -1, 600}, {0x00fe, -1, 600}, + {0x00b2, -1, 600}, {0x00d6, -1, 600}, {0x03bc, -1, 600}, + {0x00ec, -1, 600}, {0x0151, -1, 600}, {0x0118, -1, 600}, + {0x0111, -1, 600}, {0x00be, -1, 600}, {0x015e, -1, 600}, + {0x013e, -1, 600}, {0x0136, -1, 600}, {0x0139, -1, 600}, + {0x2122, -1, 600}, {0x0117, -1, 600}, {0x00cc, -1, 600}, + {0x012a, -1, 600}, {0x013d, -1, 600}, {0x00bd, -1, 600}, + {0x2264, -1, 600}, {0x00f4, -1, 600}, {0x00f1, -1, 600}, + {0x0170, -1, 600}, {0x00c9, -1, 600}, {0x0113, -1, 600}, + {0x011f, -1, 600}, {0x00bc, -1, 600}, {0x0160, -1, 600}, + {0x0218, -1, 600}, {0x0150, -1, 600}, {0x00b0, -1, 600}, + {0x00f2, -1, 600}, {0x010c, -1, 600}, {0x00f9, -1, 600}, + {0x221a, -1, 600}, {0x010e, -1, 600}, {0x0157, -1, 600}, + {0x00d1, -1, 600}, {0x00f5, -1, 600}, {0x0156, -1, 600}, + {0x013b, -1, 600}, {0x00c3, -1, 600}, {0x0104, -1, 600}, + {0x00c5, -1, 600}, {0x00d5, -1, 600}, {0x017c, -1, 600}, + {0x011a, -1, 600}, {0x012e, -1, 600}, {0x0137, -1, 600}, + {0x2212, -1, 600}, {0x00ce, -1, 600}, {0x0148, -1, 600}, + {0x0163, -1, 600}, {0x00ac, -1, 600}, {0x00f6, -1, 600}, + {0x00fc, -1, 600}, {0x2260, -1, 600}, {0x0123, -1, 600}, + {0x00f0, -1, 600}, {0x017e, -1, 600}, {0x0146, -1, 600}, + {0x00b9, -1, 600}, {0x012b, -1, 600}, {0x20ac, -1, 600} +}; + +const static pdc_core_metric pdc_core_metric_04 = +{ + "Courier-BoldOblique", /* FontName */ + 262241L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) -12.0, /* ItalicAngle */ + 1, /* isFixedPitch */ + -57, /* llx */ + -250, /* lly */ + 869, /* urx */ + 801, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 562, /* CapHeight */ + 439, /* xHeight */ + 629, /* Ascender */ + -157, /* Descender */ + 106, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_04, + +}; + +/* -------- Generated from Helvetica.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_05[315] = +{ + {0x0020, 32, 278}, {0x0021, 33, 278}, {0x0022, 34, 355}, + {0x0023, 35, 556}, {0x0024, 36, 556}, {0x0025, 37, 889}, + {0x0026, 38, 667}, {0x2019, 39, 222}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x002a, 42, 389}, {0x002b, 43, 584}, + {0x002c, 44, 278}, {0x002d, 45, 333}, {0x002e, 46, 278}, + {0x002f, 47, 278}, {0x0030, 48, 556}, {0x0031, 49, 556}, + {0x0032, 50, 556}, {0x0033, 51, 556}, {0x0034, 52, 556}, + {0x0035, 53, 556}, {0x0036, 54, 556}, {0x0037, 55, 556}, + {0x0038, 56, 556}, {0x0039, 57, 556}, {0x003a, 58, 278}, + {0x003b, 59, 278}, {0x003c, 60, 584}, {0x003d, 61, 584}, + {0x003e, 62, 584}, {0x003f, 63, 556}, {0x0040, 64, 1015}, + {0x0041, 65, 667}, {0x0042, 66, 667}, {0x0043, 67, 722}, + {0x0044, 68, 722}, {0x0045, 69, 667}, {0x0046, 70, 611}, + {0x0047, 71, 778}, {0x0048, 72, 722}, {0x0049, 73, 278}, + {0x004a, 74, 500}, {0x004b, 75, 667}, {0x004c, 76, 556}, + {0x004d, 77, 833}, {0x004e, 78, 722}, {0x004f, 79, 778}, + {0x0050, 80, 667}, {0x0051, 81, 778}, {0x0052, 82, 722}, + {0x0053, 83, 667}, {0x0054, 84, 611}, {0x0055, 85, 722}, + {0x0056, 86, 667}, {0x0057, 87, 944}, {0x0058, 88, 667}, + {0x0059, 89, 667}, {0x005a, 90, 611}, {0x005b, 91, 278}, + {0x005c, 92, 278}, {0x005d, 93, 278}, {0x005e, 94, 469}, + {0x005f, 95, 556}, {0x2018, 96, 222}, {0x0061, 97, 556}, + {0x0062, 98, 556}, {0x0063, 99, 500}, {0x0064, 100, 556}, + {0x0065, 101, 556}, {0x0066, 102, 278}, {0x0067, 103, 556}, + {0x0068, 104, 556}, {0x0069, 105, 222}, {0x006a, 106, 222}, + {0x006b, 107, 500}, {0x006c, 108, 222}, {0x006d, 109, 833}, + {0x006e, 110, 556}, {0x006f, 111, 556}, {0x0070, 112, 556}, + {0x0071, 113, 556}, {0x0072, 114, 333}, {0x0073, 115, 500}, + {0x0074, 116, 278}, {0x0075, 117, 556}, {0x0076, 118, 500}, + {0x0077, 119, 722}, {0x0078, 120, 500}, {0x0079, 121, 500}, + {0x007a, 122, 500}, {0x007b, 123, 334}, {0x007c, 124, 260}, + {0x007d, 125, 334}, {0x007e, 126, 584}, {0x00a1, 161, 333}, + {0x00a2, 162, 556}, {0x00a3, 163, 556}, {0x2044, 164, 167}, + {0x00a5, 165, 556}, {0x0192, 166, 556}, {0x00a7, 167, 556}, + {0x00a4, 168, 556}, {0x0027, 169, 191}, {0x201c, 170, 333}, + {0x00ab, 171, 556}, {0x2039, 172, 333}, {0x203a, 173, 333}, + {0xfb01, 174, 500}, {0xfb02, 175, 500}, {0x2013, 177, 556}, + {0x2020, 178, 556}, {0x2021, 179, 556}, {0x00b7, 180, 278}, + {0x00b6, 182, 537}, {0x2022, 183, 350}, {0x201a, 184, 222}, + {0x201e, 185, 333}, {0x201d, 186, 333}, {0x00bb, 187, 556}, + {0x2026, 188, 1000}, {0x2030, 189, 1000}, {0x00bf, 191, 611}, + {0x0060, 193, 333}, {0x00b4, 194, 333}, {0x02c6, 195, 333}, + {0x02dc, 196, 333}, {0x00af, 197, 333}, {0x02d8, 198, 333}, + {0x02d9, 199, 333}, {0x00a8, 200, 333}, {0x02da, 202, 333}, + {0x00b8, 203, 333}, {0x02dd, 205, 333}, {0x02db, 206, 333}, + {0x02c7, 207, 333}, {0x2014, 208, 1000}, {0x00c6, 225, 1000}, + {0x00aa, 227, 370}, {0x0141, 232, 556}, {0x00d8, 233, 778}, + {0x0152, 234, 1000}, {0x00ba, 235, 365}, {0x00e6, 241, 889}, + {0x0131, 245, 278}, {0x0142, 248, 222}, {0x00f8, 249, 611}, + {0x0153, 250, 944}, {0x00df, 251, 611}, {0x00cf, -1, 278}, + {0x00e9, -1, 556}, {0x0103, -1, 556}, {0x0171, -1, 556}, + {0x011b, -1, 556}, {0x0178, -1, 667}, {0x00f7, -1, 584}, + {0x00dd, -1, 667}, {0x00c2, -1, 667}, {0x00e1, -1, 556}, + {0x00db, -1, 722}, {0x00fd, -1, 500}, {0x0219, -1, 500}, + {0x00ea, -1, 556}, {0x016e, -1, 722}, {0x00dc, -1, 722}, + {0x0105, -1, 556}, {0x00da, -1, 722}, {0x0173, -1, 556}, + {0x00cb, -1, 667}, {0x0110, -1, 722}, {0xf6c3, -1, 250}, + {0x00a9, -1, 737}, {0x0112, -1, 667}, {0x010d, -1, 500}, + {0x00e5, -1, 556}, {0x0145, -1, 722}, {0x013a, -1, 222}, + {0x00e0, -1, 556}, {0x0162, -1, 611}, {0x0106, -1, 722}, + {0x00e3, -1, 556}, {0x0116, -1, 667}, {0x0161, -1, 500}, + {0x015f, -1, 500}, {0x00ed, -1, 278}, {0x25ca, -1, 471}, + {0x0158, -1, 722}, {0x0122, -1, 778}, {0x00fb, -1, 556}, + {0x00e2, -1, 556}, {0x0100, -1, 667}, {0x0159, -1, 333}, + {0x00e7, -1, 500}, {0x017b, -1, 611}, {0x00de, -1, 667}, + {0x014c, -1, 778}, {0x0154, -1, 722}, {0x015a, -1, 667}, + {0x010f, -1, 643}, {0x016a, -1, 722}, {0x016f, -1, 556}, + {0x00b3, -1, 333}, {0x00d2, -1, 778}, {0x00c0, -1, 667}, + {0x0102, -1, 667}, {0x00d7, -1, 584}, {0x00fa, -1, 556}, + {0x0164, -1, 611}, {0x2202, -1, 476}, {0x00ff, -1, 500}, + {0x0143, -1, 722}, {0x00ee, -1, 278}, {0x00ca, -1, 667}, + {0x00e4, -1, 556}, {0x00eb, -1, 556}, {0x0107, -1, 500}, + {0x0144, -1, 556}, {0x016b, -1, 556}, {0x0147, -1, 722}, + {0x00cd, -1, 278}, {0x00b1, -1, 584}, {0x00a6, -1, 260}, + {0x00ae, -1, 737}, {0x011e, -1, 778}, {0x0130, -1, 278}, + {0x2211, -1, 600}, {0x00c8, -1, 667}, {0x0155, -1, 333}, + {0x014d, -1, 556}, {0x0179, -1, 611}, {0x017d, -1, 611}, + {0x2265, -1, 549}, {0x00d0, -1, 722}, {0x00c7, -1, 722}, + {0x013c, -1, 222}, {0x0165, -1, 317}, {0x0119, -1, 556}, + {0x0172, -1, 722}, {0x00c1, -1, 667}, {0x00c4, -1, 667}, + {0x00e8, -1, 556}, {0x017a, -1, 500}, {0x012f, -1, 222}, + {0x00d3, -1, 778}, {0x00f3, -1, 556}, {0x0101, -1, 556}, + {0x015b, -1, 500}, {0x00ef, -1, 278}, {0x00d4, -1, 778}, + {0x00d9, -1, 722}, {0x0394, -1, 612}, {0x00fe, -1, 556}, + {0x00b2, -1, 333}, {0x00d6, -1, 778}, {0x03bc, -1, 556}, + {0x00ec, -1, 278}, {0x0151, -1, 556}, {0x0118, -1, 667}, + {0x0111, -1, 556}, {0x00be, -1, 834}, {0x015e, -1, 667}, + {0x013e, -1, 299}, {0x0136, -1, 667}, {0x0139, -1, 556}, + {0x2122, -1, 1000}, {0x0117, -1, 556}, {0x00cc, -1, 278}, + {0x012a, -1, 278}, {0x013d, -1, 556}, {0x00bd, -1, 834}, + {0x2264, -1, 549}, {0x00f4, -1, 556}, {0x00f1, -1, 556}, + {0x0170, -1, 722}, {0x00c9, -1, 667}, {0x0113, -1, 556}, + {0x011f, -1, 556}, {0x00bc, -1, 834}, {0x0160, -1, 667}, + {0x0218, -1, 667}, {0x0150, -1, 778}, {0x00b0, -1, 400}, + {0x00f2, -1, 556}, {0x010c, -1, 722}, {0x00f9, -1, 556}, + {0x221a, -1, 453}, {0x010e, -1, 722}, {0x0157, -1, 333}, + {0x00d1, -1, 722}, {0x00f5, -1, 556}, {0x0156, -1, 722}, + {0x013b, -1, 556}, {0x00c3, -1, 667}, {0x0104, -1, 667}, + {0x00c5, -1, 667}, {0x00d5, -1, 778}, {0x017c, -1, 500}, + {0x011a, -1, 667}, {0x012e, -1, 278}, {0x0137, -1, 500}, + {0x2212, -1, 584}, {0x00ce, -1, 278}, {0x0148, -1, 556}, + {0x0163, -1, 278}, {0x00ac, -1, 584}, {0x00f6, -1, 556}, + {0x00fc, -1, 556}, {0x2260, -1, 549}, {0x0123, -1, 556}, + {0x00f0, -1, 556}, {0x017e, -1, 500}, {0x0146, -1, 556}, + {0x00b9, -1, 333}, {0x012b, -1, 278}, {0x20ac, -1, 556} +}; + + +const static pdc_core_metric pdc_core_metric_05 = +{ + "Helvetica", /* FontName */ + 32L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -166, /* llx */ + -225, /* lly */ + 1000, /* urx */ + 931, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 718, /* CapHeight */ + 523, /* xHeight */ + 718, /* Ascender */ + -207, /* Descender */ + 88, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_05, + +}; + +/* -------- Generated from Helvetica-Bold.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_06[315] = +{ + {0x0020, 32, 278}, {0x0021, 33, 333}, {0x0022, 34, 474}, + {0x0023, 35, 556}, {0x0024, 36, 556}, {0x0025, 37, 889}, + {0x0026, 38, 722}, {0x2019, 39, 278}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x002a, 42, 389}, {0x002b, 43, 584}, + {0x002c, 44, 278}, {0x002d, 45, 333}, {0x002e, 46, 278}, + {0x002f, 47, 278}, {0x0030, 48, 556}, {0x0031, 49, 556}, + {0x0032, 50, 556}, {0x0033, 51, 556}, {0x0034, 52, 556}, + {0x0035, 53, 556}, {0x0036, 54, 556}, {0x0037, 55, 556}, + {0x0038, 56, 556}, {0x0039, 57, 556}, {0x003a, 58, 333}, + {0x003b, 59, 333}, {0x003c, 60, 584}, {0x003d, 61, 584}, + {0x003e, 62, 584}, {0x003f, 63, 611}, {0x0040, 64, 975}, + {0x0041, 65, 722}, {0x0042, 66, 722}, {0x0043, 67, 722}, + {0x0044, 68, 722}, {0x0045, 69, 667}, {0x0046, 70, 611}, + {0x0047, 71, 778}, {0x0048, 72, 722}, {0x0049, 73, 278}, + {0x004a, 74, 556}, {0x004b, 75, 722}, {0x004c, 76, 611}, + {0x004d, 77, 833}, {0x004e, 78, 722}, {0x004f, 79, 778}, + {0x0050, 80, 667}, {0x0051, 81, 778}, {0x0052, 82, 722}, + {0x0053, 83, 667}, {0x0054, 84, 611}, {0x0055, 85, 722}, + {0x0056, 86, 667}, {0x0057, 87, 944}, {0x0058, 88, 667}, + {0x0059, 89, 667}, {0x005a, 90, 611}, {0x005b, 91, 333}, + {0x005c, 92, 278}, {0x005d, 93, 333}, {0x005e, 94, 584}, + {0x005f, 95, 556}, {0x2018, 96, 278}, {0x0061, 97, 556}, + {0x0062, 98, 611}, {0x0063, 99, 556}, {0x0064, 100, 611}, + {0x0065, 101, 556}, {0x0066, 102, 333}, {0x0067, 103, 611}, + {0x0068, 104, 611}, {0x0069, 105, 278}, {0x006a, 106, 278}, + {0x006b, 107, 556}, {0x006c, 108, 278}, {0x006d, 109, 889}, + {0x006e, 110, 611}, {0x006f, 111, 611}, {0x0070, 112, 611}, + {0x0071, 113, 611}, {0x0072, 114, 389}, {0x0073, 115, 556}, + {0x0074, 116, 333}, {0x0075, 117, 611}, {0x0076, 118, 556}, + {0x0077, 119, 778}, {0x0078, 120, 556}, {0x0079, 121, 556}, + {0x007a, 122, 500}, {0x007b, 123, 389}, {0x007c, 124, 280}, + {0x007d, 125, 389}, {0x007e, 126, 584}, {0x00a1, 161, 333}, + {0x00a2, 162, 556}, {0x00a3, 163, 556}, {0x2044, 164, 167}, + {0x00a5, 165, 556}, {0x0192, 166, 556}, {0x00a7, 167, 556}, + {0x00a4, 168, 556}, {0x0027, 169, 238}, {0x201c, 170, 500}, + {0x00ab, 171, 556}, {0x2039, 172, 333}, {0x203a, 173, 333}, + {0xfb01, 174, 611}, {0xfb02, 175, 611}, {0x2013, 177, 556}, + {0x2020, 178, 556}, {0x2021, 179, 556}, {0x00b7, 180, 278}, + {0x00b6, 182, 556}, {0x2022, 183, 350}, {0x201a, 184, 278}, + {0x201e, 185, 500}, {0x201d, 186, 500}, {0x00bb, 187, 556}, + {0x2026, 188, 1000}, {0x2030, 189, 1000}, {0x00bf, 191, 611}, + {0x0060, 193, 333}, {0x00b4, 194, 333}, {0x02c6, 195, 333}, + {0x02dc, 196, 333}, {0x00af, 197, 333}, {0x02d8, 198, 333}, + {0x02d9, 199, 333}, {0x00a8, 200, 333}, {0x02da, 202, 333}, + {0x00b8, 203, 333}, {0x02dd, 205, 333}, {0x02db, 206, 333}, + {0x02c7, 207, 333}, {0x2014, 208, 1000}, {0x00c6, 225, 1000}, + {0x00aa, 227, 370}, {0x0141, 232, 611}, {0x00d8, 233, 778}, + {0x0152, 234, 1000}, {0x00ba, 235, 365}, {0x00e6, 241, 889}, + {0x0131, 245, 278}, {0x0142, 248, 278}, {0x00f8, 249, 611}, + {0x0153, 250, 944}, {0x00df, 251, 611}, {0x00cf, -1, 278}, + {0x00e9, -1, 556}, {0x0103, -1, 556}, {0x0171, -1, 611}, + {0x011b, -1, 556}, {0x0178, -1, 667}, {0x00f7, -1, 584}, + {0x00dd, -1, 667}, {0x00c2, -1, 722}, {0x00e1, -1, 556}, + {0x00db, -1, 722}, {0x00fd, -1, 556}, {0x0219, -1, 556}, + {0x00ea, -1, 556}, {0x016e, -1, 722}, {0x00dc, -1, 722}, + {0x0105, -1, 556}, {0x00da, -1, 722}, {0x0173, -1, 611}, + {0x00cb, -1, 667}, {0x0110, -1, 722}, {0xf6c3, -1, 250}, + {0x00a9, -1, 737}, {0x0112, -1, 667}, {0x010d, -1, 556}, + {0x00e5, -1, 556}, {0x0145, -1, 722}, {0x013a, -1, 278}, + {0x00e0, -1, 556}, {0x0162, -1, 611}, {0x0106, -1, 722}, + {0x00e3, -1, 556}, {0x0116, -1, 667}, {0x0161, -1, 556}, + {0x015f, -1, 556}, {0x00ed, -1, 278}, {0x25ca, -1, 494}, + {0x0158, -1, 722}, {0x0122, -1, 778}, {0x00fb, -1, 611}, + {0x00e2, -1, 556}, {0x0100, -1, 722}, {0x0159, -1, 389}, + {0x00e7, -1, 556}, {0x017b, -1, 611}, {0x00de, -1, 667}, + {0x014c, -1, 778}, {0x0154, -1, 722}, {0x015a, -1, 667}, + {0x010f, -1, 743}, {0x016a, -1, 722}, {0x016f, -1, 611}, + {0x00b3, -1, 333}, {0x00d2, -1, 778}, {0x00c0, -1, 722}, + {0x0102, -1, 722}, {0x00d7, -1, 584}, {0x00fa, -1, 611}, + {0x0164, -1, 611}, {0x2202, -1, 494}, {0x00ff, -1, 556}, + {0x0143, -1, 722}, {0x00ee, -1, 278}, {0x00ca, -1, 667}, + {0x00e4, -1, 556}, {0x00eb, -1, 556}, {0x0107, -1, 556}, + {0x0144, -1, 611}, {0x016b, -1, 611}, {0x0147, -1, 722}, + {0x00cd, -1, 278}, {0x00b1, -1, 584}, {0x00a6, -1, 280}, + {0x00ae, -1, 737}, {0x011e, -1, 778}, {0x0130, -1, 278}, + {0x2211, -1, 600}, {0x00c8, -1, 667}, {0x0155, -1, 389}, + {0x014d, -1, 611}, {0x0179, -1, 611}, {0x017d, -1, 611}, + {0x2265, -1, 549}, {0x00d0, -1, 722}, {0x00c7, -1, 722}, + {0x013c, -1, 278}, {0x0165, -1, 389}, {0x0119, -1, 556}, + {0x0172, -1, 722}, {0x00c1, -1, 722}, {0x00c4, -1, 722}, + {0x00e8, -1, 556}, {0x017a, -1, 500}, {0x012f, -1, 278}, + {0x00d3, -1, 778}, {0x00f3, -1, 611}, {0x0101, -1, 556}, + {0x015b, -1, 556}, {0x00ef, -1, 278}, {0x00d4, -1, 778}, + {0x00d9, -1, 722}, {0x0394, -1, 612}, {0x00fe, -1, 611}, + {0x00b2, -1, 333}, {0x00d6, -1, 778}, {0x03bc, -1, 611}, + {0x00ec, -1, 278}, {0x0151, -1, 611}, {0x0118, -1, 667}, + {0x0111, -1, 611}, {0x00be, -1, 834}, {0x015e, -1, 667}, + {0x013e, -1, 400}, {0x0136, -1, 722}, {0x0139, -1, 611}, + {0x2122, -1, 1000}, {0x0117, -1, 556}, {0x00cc, -1, 278}, + {0x012a, -1, 278}, {0x013d, -1, 611}, {0x00bd, -1, 834}, + {0x2264, -1, 549}, {0x00f4, -1, 611}, {0x00f1, -1, 611}, + {0x0170, -1, 722}, {0x00c9, -1, 667}, {0x0113, -1, 556}, + {0x011f, -1, 611}, {0x00bc, -1, 834}, {0x0160, -1, 667}, + {0x0218, -1, 667}, {0x0150, -1, 778}, {0x00b0, -1, 400}, + {0x00f2, -1, 611}, {0x010c, -1, 722}, {0x00f9, -1, 611}, + {0x221a, -1, 549}, {0x010e, -1, 722}, {0x0157, -1, 389}, + {0x00d1, -1, 722}, {0x00f5, -1, 611}, {0x0156, -1, 722}, + {0x013b, -1, 611}, {0x00c3, -1, 722}, {0x0104, -1, 722}, + {0x00c5, -1, 722}, {0x00d5, -1, 778}, {0x017c, -1, 500}, + {0x011a, -1, 667}, {0x012e, -1, 278}, {0x0137, -1, 556}, + {0x2212, -1, 584}, {0x00ce, -1, 278}, {0x0148, -1, 611}, + {0x0163, -1, 333}, {0x00ac, -1, 584}, {0x00f6, -1, 611}, + {0x00fc, -1, 611}, {0x2260, -1, 549}, {0x0123, -1, 611}, + {0x00f0, -1, 611}, {0x017e, -1, 500}, {0x0146, -1, 611}, + {0x00b9, -1, 333}, {0x012b, -1, 278}, {0x20ac, -1, 556} +}; + + +const static pdc_core_metric pdc_core_metric_06 = +{ + "Helvetica-Bold", /* FontName */ + 262176L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -170, /* llx */ + -228, /* lly */ + 1003, /* urx */ + 962, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 718, /* CapHeight */ + 532, /* xHeight */ + 718, /* Ascender */ + -207, /* Descender */ + 140, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_06, + +}; + +/* -------- Generated from Helvetica-Oblique.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_07[315] = +{ + {0x0020, 32, 278}, {0x0021, 33, 278}, {0x0022, 34, 355}, + {0x0023, 35, 556}, {0x0024, 36, 556}, {0x0025, 37, 889}, + {0x0026, 38, 667}, {0x2019, 39, 222}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x002a, 42, 389}, {0x002b, 43, 584}, + {0x002c, 44, 278}, {0x002d, 45, 333}, {0x002e, 46, 278}, + {0x002f, 47, 278}, {0x0030, 48, 556}, {0x0031, 49, 556}, + {0x0032, 50, 556}, {0x0033, 51, 556}, {0x0034, 52, 556}, + {0x0035, 53, 556}, {0x0036, 54, 556}, {0x0037, 55, 556}, + {0x0038, 56, 556}, {0x0039, 57, 556}, {0x003a, 58, 278}, + {0x003b, 59, 278}, {0x003c, 60, 584}, {0x003d, 61, 584}, + {0x003e, 62, 584}, {0x003f, 63, 556}, {0x0040, 64, 1015}, + {0x0041, 65, 667}, {0x0042, 66, 667}, {0x0043, 67, 722}, + {0x0044, 68, 722}, {0x0045, 69, 667}, {0x0046, 70, 611}, + {0x0047, 71, 778}, {0x0048, 72, 722}, {0x0049, 73, 278}, + {0x004a, 74, 500}, {0x004b, 75, 667}, {0x004c, 76, 556}, + {0x004d, 77, 833}, {0x004e, 78, 722}, {0x004f, 79, 778}, + {0x0050, 80, 667}, {0x0051, 81, 778}, {0x0052, 82, 722}, + {0x0053, 83, 667}, {0x0054, 84, 611}, {0x0055, 85, 722}, + {0x0056, 86, 667}, {0x0057, 87, 944}, {0x0058, 88, 667}, + {0x0059, 89, 667}, {0x005a, 90, 611}, {0x005b, 91, 278}, + {0x005c, 92, 278}, {0x005d, 93, 278}, {0x005e, 94, 469}, + {0x005f, 95, 556}, {0x2018, 96, 222}, {0x0061, 97, 556}, + {0x0062, 98, 556}, {0x0063, 99, 500}, {0x0064, 100, 556}, + {0x0065, 101, 556}, {0x0066, 102, 278}, {0x0067, 103, 556}, + {0x0068, 104, 556}, {0x0069, 105, 222}, {0x006a, 106, 222}, + {0x006b, 107, 500}, {0x006c, 108, 222}, {0x006d, 109, 833}, + {0x006e, 110, 556}, {0x006f, 111, 556}, {0x0070, 112, 556}, + {0x0071, 113, 556}, {0x0072, 114, 333}, {0x0073, 115, 500}, + {0x0074, 116, 278}, {0x0075, 117, 556}, {0x0076, 118, 500}, + {0x0077, 119, 722}, {0x0078, 120, 500}, {0x0079, 121, 500}, + {0x007a, 122, 500}, {0x007b, 123, 334}, {0x007c, 124, 260}, + {0x007d, 125, 334}, {0x007e, 126, 584}, {0x00a1, 161, 333}, + {0x00a2, 162, 556}, {0x00a3, 163, 556}, {0x2044, 164, 167}, + {0x00a5, 165, 556}, {0x0192, 166, 556}, {0x00a7, 167, 556}, + {0x00a4, 168, 556}, {0x0027, 169, 191}, {0x201c, 170, 333}, + {0x00ab, 171, 556}, {0x2039, 172, 333}, {0x203a, 173, 333}, + {0xfb01, 174, 500}, {0xfb02, 175, 500}, {0x2013, 177, 556}, + {0x2020, 178, 556}, {0x2021, 179, 556}, {0x00b7, 180, 278}, + {0x00b6, 182, 537}, {0x2022, 183, 350}, {0x201a, 184, 222}, + {0x201e, 185, 333}, {0x201d, 186, 333}, {0x00bb, 187, 556}, + {0x2026, 188, 1000}, {0x2030, 189, 1000}, {0x00bf, 191, 611}, + {0x0060, 193, 333}, {0x00b4, 194, 333}, {0x02c6, 195, 333}, + {0x02dc, 196, 333}, {0x00af, 197, 333}, {0x02d8, 198, 333}, + {0x02d9, 199, 333}, {0x00a8, 200, 333}, {0x02da, 202, 333}, + {0x00b8, 203, 333}, {0x02dd, 205, 333}, {0x02db, 206, 333}, + {0x02c7, 207, 333}, {0x2014, 208, 1000}, {0x00c6, 225, 1000}, + {0x00aa, 227, 370}, {0x0141, 232, 556}, {0x00d8, 233, 778}, + {0x0152, 234, 1000}, {0x00ba, 235, 365}, {0x00e6, 241, 889}, + {0x0131, 245, 278}, {0x0142, 248, 222}, {0x00f8, 249, 611}, + {0x0153, 250, 944}, {0x00df, 251, 611}, {0x00cf, -1, 278}, + {0x00e9, -1, 556}, {0x0103, -1, 556}, {0x0171, -1, 556}, + {0x011b, -1, 556}, {0x0178, -1, 667}, {0x00f7, -1, 584}, + {0x00dd, -1, 667}, {0x00c2, -1, 667}, {0x00e1, -1, 556}, + {0x00db, -1, 722}, {0x00fd, -1, 500}, {0x0219, -1, 500}, + {0x00ea, -1, 556}, {0x016e, -1, 722}, {0x00dc, -1, 722}, + {0x0105, -1, 556}, {0x00da, -1, 722}, {0x0173, -1, 556}, + {0x00cb, -1, 667}, {0x0110, -1, 722}, {0xf6c3, -1, 250}, + {0x00a9, -1, 737}, {0x0112, -1, 667}, {0x010d, -1, 500}, + {0x00e5, -1, 556}, {0x0145, -1, 722}, {0x013a, -1, 222}, + {0x00e0, -1, 556}, {0x0162, -1, 611}, {0x0106, -1, 722}, + {0x00e3, -1, 556}, {0x0116, -1, 667}, {0x0161, -1, 500}, + {0x015f, -1, 500}, {0x00ed, -1, 278}, {0x25ca, -1, 471}, + {0x0158, -1, 722}, {0x0122, -1, 778}, {0x00fb, -1, 556}, + {0x00e2, -1, 556}, {0x0100, -1, 667}, {0x0159, -1, 333}, + {0x00e7, -1, 500}, {0x017b, -1, 611}, {0x00de, -1, 667}, + {0x014c, -1, 778}, {0x0154, -1, 722}, {0x015a, -1, 667}, + {0x010f, -1, 643}, {0x016a, -1, 722}, {0x016f, -1, 556}, + {0x00b3, -1, 333}, {0x00d2, -1, 778}, {0x00c0, -1, 667}, + {0x0102, -1, 667}, {0x00d7, -1, 584}, {0x00fa, -1, 556}, + {0x0164, -1, 611}, {0x2202, -1, 476}, {0x00ff, -1, 500}, + {0x0143, -1, 722}, {0x00ee, -1, 278}, {0x00ca, -1, 667}, + {0x00e4, -1, 556}, {0x00eb, -1, 556}, {0x0107, -1, 500}, + {0x0144, -1, 556}, {0x016b, -1, 556}, {0x0147, -1, 722}, + {0x00cd, -1, 278}, {0x00b1, -1, 584}, {0x00a6, -1, 260}, + {0x00ae, -1, 737}, {0x011e, -1, 778}, {0x0130, -1, 278}, + {0x2211, -1, 600}, {0x00c8, -1, 667}, {0x0155, -1, 333}, + {0x014d, -1, 556}, {0x0179, -1, 611}, {0x017d, -1, 611}, + {0x2265, -1, 549}, {0x00d0, -1, 722}, {0x00c7, -1, 722}, + {0x013c, -1, 222}, {0x0165, -1, 317}, {0x0119, -1, 556}, + {0x0172, -1, 722}, {0x00c1, -1, 667}, {0x00c4, -1, 667}, + {0x00e8, -1, 556}, {0x017a, -1, 500}, {0x012f, -1, 222}, + {0x00d3, -1, 778}, {0x00f3, -1, 556}, {0x0101, -1, 556}, + {0x015b, -1, 500}, {0x00ef, -1, 278}, {0x00d4, -1, 778}, + {0x00d9, -1, 722}, {0x0394, -1, 612}, {0x00fe, -1, 556}, + {0x00b2, -1, 333}, {0x00d6, -1, 778}, {0x03bc, -1, 556}, + {0x00ec, -1, 278}, {0x0151, -1, 556}, {0x0118, -1, 667}, + {0x0111, -1, 556}, {0x00be, -1, 834}, {0x015e, -1, 667}, + {0x013e, -1, 299}, {0x0136, -1, 667}, {0x0139, -1, 556}, + {0x2122, -1, 1000}, {0x0117, -1, 556}, {0x00cc, -1, 278}, + {0x012a, -1, 278}, {0x013d, -1, 556}, {0x00bd, -1, 834}, + {0x2264, -1, 549}, {0x00f4, -1, 556}, {0x00f1, -1, 556}, + {0x0170, -1, 722}, {0x00c9, -1, 667}, {0x0113, -1, 556}, + {0x011f, -1, 556}, {0x00bc, -1, 834}, {0x0160, -1, 667}, + {0x0218, -1, 667}, {0x0150, -1, 778}, {0x00b0, -1, 400}, + {0x00f2, -1, 556}, {0x010c, -1, 722}, {0x00f9, -1, 556}, + {0x221a, -1, 453}, {0x010e, -1, 722}, {0x0157, -1, 333}, + {0x00d1, -1, 722}, {0x00f5, -1, 556}, {0x0156, -1, 722}, + {0x013b, -1, 556}, {0x00c3, -1, 667}, {0x0104, -1, 667}, + {0x00c5, -1, 667}, {0x00d5, -1, 778}, {0x017c, -1, 500}, + {0x011a, -1, 667}, {0x012e, -1, 278}, {0x0137, -1, 500}, + {0x2212, -1, 584}, {0x00ce, -1, 278}, {0x0148, -1, 556}, + {0x0163, -1, 278}, {0x00ac, -1, 584}, {0x00f6, -1, 556}, + {0x00fc, -1, 556}, {0x2260, -1, 549}, {0x0123, -1, 556}, + {0x00f0, -1, 556}, {0x017e, -1, 500}, {0x0146, -1, 556}, + {0x00b9, -1, 333}, {0x012b, -1, 278}, {0x20ac, -1, 556} +}; + + +const static pdc_core_metric pdc_core_metric_07 = +{ + "Helvetica-Oblique", /* FontName */ + 96L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) -12.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -170, /* llx */ + -225, /* lly */ + 1116, /* urx */ + 931, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 718, /* CapHeight */ + 523, /* xHeight */ + 718, /* Ascender */ + -207, /* Descender */ + 88, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_07, + +}; + +/* -------- Generated from Helvetica-BoldOblique.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_08[315] = +{ + {0x0020, 32, 278}, {0x0021, 33, 333}, {0x0022, 34, 474}, + {0x0023, 35, 556}, {0x0024, 36, 556}, {0x0025, 37, 889}, + {0x0026, 38, 722}, {0x2019, 39, 278}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x002a, 42, 389}, {0x002b, 43, 584}, + {0x002c, 44, 278}, {0x002d, 45, 333}, {0x002e, 46, 278}, + {0x002f, 47, 278}, {0x0030, 48, 556}, {0x0031, 49, 556}, + {0x0032, 50, 556}, {0x0033, 51, 556}, {0x0034, 52, 556}, + {0x0035, 53, 556}, {0x0036, 54, 556}, {0x0037, 55, 556}, + {0x0038, 56, 556}, {0x0039, 57, 556}, {0x003a, 58, 333}, + {0x003b, 59, 333}, {0x003c, 60, 584}, {0x003d, 61, 584}, + {0x003e, 62, 584}, {0x003f, 63, 611}, {0x0040, 64, 975}, + {0x0041, 65, 722}, {0x0042, 66, 722}, {0x0043, 67, 722}, + {0x0044, 68, 722}, {0x0045, 69, 667}, {0x0046, 70, 611}, + {0x0047, 71, 778}, {0x0048, 72, 722}, {0x0049, 73, 278}, + {0x004a, 74, 556}, {0x004b, 75, 722}, {0x004c, 76, 611}, + {0x004d, 77, 833}, {0x004e, 78, 722}, {0x004f, 79, 778}, + {0x0050, 80, 667}, {0x0051, 81, 778}, {0x0052, 82, 722}, + {0x0053, 83, 667}, {0x0054, 84, 611}, {0x0055, 85, 722}, + {0x0056, 86, 667}, {0x0057, 87, 944}, {0x0058, 88, 667}, + {0x0059, 89, 667}, {0x005a, 90, 611}, {0x005b, 91, 333}, + {0x005c, 92, 278}, {0x005d, 93, 333}, {0x005e, 94, 584}, + {0x005f, 95, 556}, {0x2018, 96, 278}, {0x0061, 97, 556}, + {0x0062, 98, 611}, {0x0063, 99, 556}, {0x0064, 100, 611}, + {0x0065, 101, 556}, {0x0066, 102, 333}, {0x0067, 103, 611}, + {0x0068, 104, 611}, {0x0069, 105, 278}, {0x006a, 106, 278}, + {0x006b, 107, 556}, {0x006c, 108, 278}, {0x006d, 109, 889}, + {0x006e, 110, 611}, {0x006f, 111, 611}, {0x0070, 112, 611}, + {0x0071, 113, 611}, {0x0072, 114, 389}, {0x0073, 115, 556}, + {0x0074, 116, 333}, {0x0075, 117, 611}, {0x0076, 118, 556}, + {0x0077, 119, 778}, {0x0078, 120, 556}, {0x0079, 121, 556}, + {0x007a, 122, 500}, {0x007b, 123, 389}, {0x007c, 124, 280}, + {0x007d, 125, 389}, {0x007e, 126, 584}, {0x00a1, 161, 333}, + {0x00a2, 162, 556}, {0x00a3, 163, 556}, {0x2044, 164, 167}, + {0x00a5, 165, 556}, {0x0192, 166, 556}, {0x00a7, 167, 556}, + {0x00a4, 168, 556}, {0x0027, 169, 238}, {0x201c, 170, 500}, + {0x00ab, 171, 556}, {0x2039, 172, 333}, {0x203a, 173, 333}, + {0xfb01, 174, 611}, {0xfb02, 175, 611}, {0x2013, 177, 556}, + {0x2020, 178, 556}, {0x2021, 179, 556}, {0x00b7, 180, 278}, + {0x00b6, 182, 556}, {0x2022, 183, 350}, {0x201a, 184, 278}, + {0x201e, 185, 500}, {0x201d, 186, 500}, {0x00bb, 187, 556}, + {0x2026, 188, 1000}, {0x2030, 189, 1000}, {0x00bf, 191, 611}, + {0x0060, 193, 333}, {0x00b4, 194, 333}, {0x02c6, 195, 333}, + {0x02dc, 196, 333}, {0x00af, 197, 333}, {0x02d8, 198, 333}, + {0x02d9, 199, 333}, {0x00a8, 200, 333}, {0x02da, 202, 333}, + {0x00b8, 203, 333}, {0x02dd, 205, 333}, {0x02db, 206, 333}, + {0x02c7, 207, 333}, {0x2014, 208, 1000}, {0x00c6, 225, 1000}, + {0x00aa, 227, 370}, {0x0141, 232, 611}, {0x00d8, 233, 778}, + {0x0152, 234, 1000}, {0x00ba, 235, 365}, {0x00e6, 241, 889}, + {0x0131, 245, 278}, {0x0142, 248, 278}, {0x00f8, 249, 611}, + {0x0153, 250, 944}, {0x00df, 251, 611}, {0x00cf, -1, 278}, + {0x00e9, -1, 556}, {0x0103, -1, 556}, {0x0171, -1, 611}, + {0x011b, -1, 556}, {0x0178, -1, 667}, {0x00f7, -1, 584}, + {0x00dd, -1, 667}, {0x00c2, -1, 722}, {0x00e1, -1, 556}, + {0x00db, -1, 722}, {0x00fd, -1, 556}, {0x0219, -1, 556}, + {0x00ea, -1, 556}, {0x016e, -1, 722}, {0x00dc, -1, 722}, + {0x0105, -1, 556}, {0x00da, -1, 722}, {0x0173, -1, 611}, + {0x00cb, -1, 667}, {0x0110, -1, 722}, {0xf6c3, -1, 250}, + {0x00a9, -1, 737}, {0x0112, -1, 667}, {0x010d, -1, 556}, + {0x00e5, -1, 556}, {0x0145, -1, 722}, {0x013a, -1, 278}, + {0x00e0, -1, 556}, {0x0162, -1, 611}, {0x0106, -1, 722}, + {0x00e3, -1, 556}, {0x0116, -1, 667}, {0x0161, -1, 556}, + {0x015f, -1, 556}, {0x00ed, -1, 278}, {0x25ca, -1, 494}, + {0x0158, -1, 722}, {0x0122, -1, 778}, {0x00fb, -1, 611}, + {0x00e2, -1, 556}, {0x0100, -1, 722}, {0x0159, -1, 389}, + {0x00e7, -1, 556}, {0x017b, -1, 611}, {0x00de, -1, 667}, + {0x014c, -1, 778}, {0x0154, -1, 722}, {0x015a, -1, 667}, + {0x010f, -1, 743}, {0x016a, -1, 722}, {0x016f, -1, 611}, + {0x00b3, -1, 333}, {0x00d2, -1, 778}, {0x00c0, -1, 722}, + {0x0102, -1, 722}, {0x00d7, -1, 584}, {0x00fa, -1, 611}, + {0x0164, -1, 611}, {0x2202, -1, 494}, {0x00ff, -1, 556}, + {0x0143, -1, 722}, {0x00ee, -1, 278}, {0x00ca, -1, 667}, + {0x00e4, -1, 556}, {0x00eb, -1, 556}, {0x0107, -1, 556}, + {0x0144, -1, 611}, {0x016b, -1, 611}, {0x0147, -1, 722}, + {0x00cd, -1, 278}, {0x00b1, -1, 584}, {0x00a6, -1, 280}, + {0x00ae, -1, 737}, {0x011e, -1, 778}, {0x0130, -1, 278}, + {0x2211, -1, 600}, {0x00c8, -1, 667}, {0x0155, -1, 389}, + {0x014d, -1, 611}, {0x0179, -1, 611}, {0x017d, -1, 611}, + {0x2265, -1, 549}, {0x00d0, -1, 722}, {0x00c7, -1, 722}, + {0x013c, -1, 278}, {0x0165, -1, 389}, {0x0119, -1, 556}, + {0x0172, -1, 722}, {0x00c1, -1, 722}, {0x00c4, -1, 722}, + {0x00e8, -1, 556}, {0x017a, -1, 500}, {0x012f, -1, 278}, + {0x00d3, -1, 778}, {0x00f3, -1, 611}, {0x0101, -1, 556}, + {0x015b, -1, 556}, {0x00ef, -1, 278}, {0x00d4, -1, 778}, + {0x00d9, -1, 722}, {0x0394, -1, 612}, {0x00fe, -1, 611}, + {0x00b2, -1, 333}, {0x00d6, -1, 778}, {0x03bc, -1, 611}, + {0x00ec, -1, 278}, {0x0151, -1, 611}, {0x0118, -1, 667}, + {0x0111, -1, 611}, {0x00be, -1, 834}, {0x015e, -1, 667}, + {0x013e, -1, 400}, {0x0136, -1, 722}, {0x0139, -1, 611}, + {0x2122, -1, 1000}, {0x0117, -1, 556}, {0x00cc, -1, 278}, + {0x012a, -1, 278}, {0x013d, -1, 611}, {0x00bd, -1, 834}, + {0x2264, -1, 549}, {0x00f4, -1, 611}, {0x00f1, -1, 611}, + {0x0170, -1, 722}, {0x00c9, -1, 667}, {0x0113, -1, 556}, + {0x011f, -1, 611}, {0x00bc, -1, 834}, {0x0160, -1, 667}, + {0x0218, -1, 667}, {0x0150, -1, 778}, {0x00b0, -1, 400}, + {0x00f2, -1, 611}, {0x010c, -1, 722}, {0x00f9, -1, 611}, + {0x221a, -1, 549}, {0x010e, -1, 722}, {0x0157, -1, 389}, + {0x00d1, -1, 722}, {0x00f5, -1, 611}, {0x0156, -1, 722}, + {0x013b, -1, 611}, {0x00c3, -1, 722}, {0x0104, -1, 722}, + {0x00c5, -1, 722}, {0x00d5, -1, 778}, {0x017c, -1, 500}, + {0x011a, -1, 667}, {0x012e, -1, 278}, {0x0137, -1, 556}, + {0x2212, -1, 584}, {0x00ce, -1, 278}, {0x0148, -1, 611}, + {0x0163, -1, 333}, {0x00ac, -1, 584}, {0x00f6, -1, 611}, + {0x00fc, -1, 611}, {0x2260, -1, 549}, {0x0123, -1, 611}, + {0x00f0, -1, 611}, {0x017e, -1, 500}, {0x0146, -1, 611}, + {0x00b9, -1, 333}, {0x012b, -1, 278}, {0x20ac, -1, 556} +}; + + +const static pdc_core_metric pdc_core_metric_08 = +{ + "Helvetica-BoldOblique", /* FontName */ + 262240L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) -12.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -174, /* llx */ + -228, /* lly */ + 1114, /* urx */ + 962, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 718, /* CapHeight */ + 532, /* xHeight */ + 718, /* Ascender */ + -207, /* Descender */ + 140, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_08, + +}; + +/* -------- Generated from Symbol.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_09[190] = +{ + {0x0020, 32, 250}, {0x0021, 33, 333}, {0x2200, 34, 713}, + {0x0023, 35, 500}, {0x2203, 36, 549}, {0x0025, 37, 833}, + {0x0026, 38, 778}, {0x220b, 39, 439}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x2217, 42, 500}, {0x002b, 43, 549}, + {0x002c, 44, 250}, {0x2212, 45, 549}, {0x002e, 46, 250}, + {0x002f, 47, 278}, {0x0030, 48, 500}, {0x0031, 49, 500}, + {0x0032, 50, 500}, {0x0033, 51, 500}, {0x0034, 52, 500}, + {0x0035, 53, 500}, {0x0036, 54, 500}, {0x0037, 55, 500}, + {0x0038, 56, 500}, {0x0039, 57, 500}, {0x003a, 58, 278}, + {0x003b, 59, 278}, {0x003c, 60, 549}, {0x003d, 61, 549}, + {0x003e, 62, 549}, {0x003f, 63, 444}, {0x2245, 64, 549}, + {0x0391, 65, 722}, {0x0392, 66, 667}, {0x03a7, 67, 722}, + {0x0394, 68, 612}, {0x0395, 69, 611}, {0x03a6, 70, 763}, + {0x0393, 71, 603}, {0x0397, 72, 722}, {0x0399, 73, 333}, + {0x03d1, 74, 631}, {0x039a, 75, 722}, {0x039b, 76, 686}, + {0x039c, 77, 889}, {0x039d, 78, 722}, {0x039f, 79, 722}, + {0x03a0, 80, 768}, {0x0398, 81, 741}, {0x03a1, 82, 556}, + {0x03a3, 83, 592}, {0x03a4, 84, 611}, {0x03a5, 85, 690}, + {0x03c2, 86, 439}, {0x03a9, 87, 768}, {0x039e, 88, 645}, + {0x03a8, 89, 795}, {0x0396, 90, 611}, {0x005b, 91, 333}, + {0x2234, 92, 863}, {0x005d, 93, 333}, {0x22a5, 94, 658}, + {0x005f, 95, 500}, {0xf8e5, 96, 500}, {0x03b1, 97, 631}, + {0x03b2, 98, 549}, {0x03c7, 99, 549}, {0x03b4, 100, 494}, + {0x03b5, 101, 439}, {0x03c6, 102, 521}, {0x03b3, 103, 411}, + {0x03b7, 104, 603}, {0x03b9, 105, 329}, {0x03d5, 106, 603}, + {0x03ba, 107, 549}, {0x03bb, 108, 549}, {0x03bc, 109, 576}, + {0x03bd, 110, 521}, {0x03bf, 111, 549}, {0x03c0, 112, 549}, + {0x03b8, 113, 521}, {0x03c1, 114, 549}, {0x03c3, 115, 603}, + {0x03c4, 116, 439}, {0x03c5, 117, 576}, {0x03d6, 118, 713}, + {0x03c9, 119, 686}, {0x03be, 120, 493}, {0x03c8, 121, 686}, + {0x03b6, 122, 494}, {0x007b, 123, 480}, {0x007c, 124, 200}, + {0x007d, 125, 480}, {0x223c, 126, 549}, {0x20ac, 160, 750}, + {0x03d2, 161, 620}, {0x2032, 162, 247}, {0x2264, 163, 549}, + {0x2044, 164, 167}, {0x221e, 165, 713}, {0x0192, 166, 500}, + {0x2663, 167, 753}, {0x2666, 168, 753}, {0x2665, 169, 753}, + {0x2660, 170, 753}, {0x2194, 171, 1042}, {0x2190, 172, 987}, + {0x2191, 173, 603}, {0x2192, 174, 987}, {0x2193, 175, 603}, + {0x00b0, 176, 400}, {0x00b1, 177, 549}, {0x2033, 178, 411}, + {0x2265, 179, 549}, {0x00d7, 180, 549}, {0x221d, 181, 713}, + {0x2202, 182, 494}, {0x2022, 183, 460}, {0x00f7, 184, 549}, + {0x2260, 185, 549}, {0x2261, 186, 549}, {0x2248, 187, 549}, + {0x2026, 188, 1000}, {0xf8e6, 189, 603}, {0xf8e7, 190, 1000}, + {0x21b5, 191, 658}, {0x2135, 192, 823}, {0x2111, 193, 686}, + {0x211c, 194, 795}, {0x2118, 195, 987}, {0x2297, 196, 768}, + {0x2295, 197, 768}, {0x2205, 198, 823}, {0x2229, 199, 768}, + {0x222a, 200, 768}, {0x2283, 201, 713}, {0x2287, 202, 713}, + {0x2284, 203, 713}, {0x2282, 204, 713}, {0x2286, 205, 713}, + {0x2208, 206, 713}, {0x2209, 207, 713}, {0x2220, 208, 768}, + {0x2207, 209, 713}, {0xf6da, 210, 790}, {0xf6d9, 211, 790}, + {0xf6db, 212, 890}, {0x220f, 213, 823}, {0x221a, 214, 549}, + {0x22c5, 215, 250}, {0x00ac, 216, 713}, {0x2227, 217, 603}, + {0x2228, 218, 603}, {0x21d4, 219, 1042}, {0x21d0, 220, 987}, + {0x21d1, 221, 603}, {0x21d2, 222, 987}, {0x21d3, 223, 603}, + {0x25ca, 224, 494}, {0x2329, 225, 329}, {0xf8e8, 226, 790}, + {0xf8e9, 227, 790}, {0xf8ea, 228, 786}, {0x2211, 229, 713}, + {0xf8eb, 230, 384}, {0xf8ec, 231, 384}, {0xf8ed, 232, 384}, + {0xf8ee, 233, 384}, {0xf8ef, 234, 384}, {0xf8f0, 235, 384}, + {0xf8f1, 236, 494}, {0xf8f2, 237, 494}, {0xf8f3, 238, 494}, + {0xf8f4, 239, 494}, {0x232a, 241, 329}, {0x222b, 242, 274}, + {0x2320, 243, 686}, {0xf8f5, 244, 686}, {0x2321, 245, 686}, + {0xf8f6, 246, 384}, {0xf8f7, 247, 384}, {0xf8f8, 248, 384}, + {0xf8f9, 249, 384}, {0xf8fa, 250, 384}, {0xf8fb, 251, 384}, + {0xf8fc, 252, 494}, {0xf8fd, 253, 494}, {0xf8fe, 254, 494}, + {0x0000, -1, 790} +}; + +const static pdc_core_metric pdc_core_metric_09 = +{ + "Symbol", /* FontName */ + 4L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -180, /* llx */ + -293, /* lly */ + 1090, /* urx */ + 1010, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 700, /* CapHeight */ + 0, /* xHeight */ + 800, /* Ascender */ + -200, /* Descender */ + 85, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 190, + pdc_glyph_width_09, + +}; + +/* -------- Generated from Times-Roman.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_10[315] = +{ + {0x0020, 32, 250}, {0x0021, 33, 333}, {0x0022, 34, 408}, + {0x0023, 35, 500}, {0x0024, 36, 500}, {0x0025, 37, 833}, + {0x0026, 38, 778}, {0x2019, 39, 333}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x002a, 42, 500}, {0x002b, 43, 564}, + {0x002c, 44, 250}, {0x002d, 45, 333}, {0x002e, 46, 250}, + {0x002f, 47, 278}, {0x0030, 48, 500}, {0x0031, 49, 500}, + {0x0032, 50, 500}, {0x0033, 51, 500}, {0x0034, 52, 500}, + {0x0035, 53, 500}, {0x0036, 54, 500}, {0x0037, 55, 500}, + {0x0038, 56, 500}, {0x0039, 57, 500}, {0x003a, 58, 278}, + {0x003b, 59, 278}, {0x003c, 60, 564}, {0x003d, 61, 564}, + {0x003e, 62, 564}, {0x003f, 63, 444}, {0x0040, 64, 921}, + {0x0041, 65, 722}, {0x0042, 66, 667}, {0x0043, 67, 667}, + {0x0044, 68, 722}, {0x0045, 69, 611}, {0x0046, 70, 556}, + {0x0047, 71, 722}, {0x0048, 72, 722}, {0x0049, 73, 333}, + {0x004a, 74, 389}, {0x004b, 75, 722}, {0x004c, 76, 611}, + {0x004d, 77, 889}, {0x004e, 78, 722}, {0x004f, 79, 722}, + {0x0050, 80, 556}, {0x0051, 81, 722}, {0x0052, 82, 667}, + {0x0053, 83, 556}, {0x0054, 84, 611}, {0x0055, 85, 722}, + {0x0056, 86, 722}, {0x0057, 87, 944}, {0x0058, 88, 722}, + {0x0059, 89, 722}, {0x005a, 90, 611}, {0x005b, 91, 333}, + {0x005c, 92, 278}, {0x005d, 93, 333}, {0x005e, 94, 469}, + {0x005f, 95, 500}, {0x2018, 96, 333}, {0x0061, 97, 444}, + {0x0062, 98, 500}, {0x0063, 99, 444}, {0x0064, 100, 500}, + {0x0065, 101, 444}, {0x0066, 102, 333}, {0x0067, 103, 500}, + {0x0068, 104, 500}, {0x0069, 105, 278}, {0x006a, 106, 278}, + {0x006b, 107, 500}, {0x006c, 108, 278}, {0x006d, 109, 778}, + {0x006e, 110, 500}, {0x006f, 111, 500}, {0x0070, 112, 500}, + {0x0071, 113, 500}, {0x0072, 114, 333}, {0x0073, 115, 389}, + {0x0074, 116, 278}, {0x0075, 117, 500}, {0x0076, 118, 500}, + {0x0077, 119, 722}, {0x0078, 120, 500}, {0x0079, 121, 500}, + {0x007a, 122, 444}, {0x007b, 123, 480}, {0x007c, 124, 200}, + {0x007d, 125, 480}, {0x007e, 126, 541}, {0x00a1, 161, 333}, + {0x00a2, 162, 500}, {0x00a3, 163, 500}, {0x2044, 164, 167}, + {0x00a5, 165, 500}, {0x0192, 166, 500}, {0x00a7, 167, 500}, + {0x00a4, 168, 500}, {0x0027, 169, 180}, {0x201c, 170, 444}, + {0x00ab, 171, 500}, {0x2039, 172, 333}, {0x203a, 173, 333}, + {0xfb01, 174, 556}, {0xfb02, 175, 556}, {0x2013, 177, 500}, + {0x2020, 178, 500}, {0x2021, 179, 500}, {0x00b7, 180, 250}, + {0x00b6, 182, 453}, {0x2022, 183, 350}, {0x201a, 184, 333}, + {0x201e, 185, 444}, {0x201d, 186, 444}, {0x00bb, 187, 500}, + {0x2026, 188, 1000}, {0x2030, 189, 1000}, {0x00bf, 191, 444}, + {0x0060, 193, 333}, {0x00b4, 194, 333}, {0x02c6, 195, 333}, + {0x02dc, 196, 333}, {0x00af, 197, 333}, {0x02d8, 198, 333}, + {0x02d9, 199, 333}, {0x00a8, 200, 333}, {0x02da, 202, 333}, + {0x00b8, 203, 333}, {0x02dd, 205, 333}, {0x02db, 206, 333}, + {0x02c7, 207, 333}, {0x2014, 208, 1000}, {0x00c6, 225, 889}, + {0x00aa, 227, 276}, {0x0141, 232, 611}, {0x00d8, 233, 722}, + {0x0152, 234, 889}, {0x00ba, 235, 310}, {0x00e6, 241, 667}, + {0x0131, 245, 278}, {0x0142, 248, 278}, {0x00f8, 249, 500}, + {0x0153, 250, 722}, {0x00df, 251, 500}, {0x00cf, -1, 333}, + {0x00e9, -1, 444}, {0x0103, -1, 444}, {0x0171, -1, 500}, + {0x011b, -1, 444}, {0x0178, -1, 722}, {0x00f7, -1, 564}, + {0x00dd, -1, 722}, {0x00c2, -1, 722}, {0x00e1, -1, 444}, + {0x00db, -1, 722}, {0x00fd, -1, 500}, {0x0219, -1, 389}, + {0x00ea, -1, 444}, {0x016e, -1, 722}, {0x00dc, -1, 722}, + {0x0105, -1, 444}, {0x00da, -1, 722}, {0x0173, -1, 500}, + {0x00cb, -1, 611}, {0x0110, -1, 722}, {0xf6c3, -1, 250}, + {0x00a9, -1, 760}, {0x0112, -1, 611}, {0x010d, -1, 444}, + {0x00e5, -1, 444}, {0x0145, -1, 722}, {0x013a, -1, 278}, + {0x00e0, -1, 444}, {0x0162, -1, 611}, {0x0106, -1, 667}, + {0x00e3, -1, 444}, {0x0116, -1, 611}, {0x0161, -1, 389}, + {0x015f, -1, 389}, {0x00ed, -1, 278}, {0x25ca, -1, 471}, + {0x0158, -1, 667}, {0x0122, -1, 722}, {0x00fb, -1, 500}, + {0x00e2, -1, 444}, {0x0100, -1, 722}, {0x0159, -1, 333}, + {0x00e7, -1, 444}, {0x017b, -1, 611}, {0x00de, -1, 556}, + {0x014c, -1, 722}, {0x0154, -1, 667}, {0x015a, -1, 556}, + {0x010f, -1, 588}, {0x016a, -1, 722}, {0x016f, -1, 500}, + {0x00b3, -1, 300}, {0x00d2, -1, 722}, {0x00c0, -1, 722}, + {0x0102, -1, 722}, {0x00d7, -1, 564}, {0x00fa, -1, 500}, + {0x0164, -1, 611}, {0x2202, -1, 476}, {0x00ff, -1, 500}, + {0x0143, -1, 722}, {0x00ee, -1, 278}, {0x00ca, -1, 611}, + {0x00e4, -1, 444}, {0x00eb, -1, 444}, {0x0107, -1, 444}, + {0x0144, -1, 500}, {0x016b, -1, 500}, {0x0147, -1, 722}, + {0x00cd, -1, 333}, {0x00b1, -1, 564}, {0x00a6, -1, 200}, + {0x00ae, -1, 760}, {0x011e, -1, 722}, {0x0130, -1, 333}, + {0x2211, -1, 600}, {0x00c8, -1, 611}, {0x0155, -1, 333}, + {0x014d, -1, 500}, {0x0179, -1, 611}, {0x017d, -1, 611}, + {0x2265, -1, 549}, {0x00d0, -1, 722}, {0x00c7, -1, 667}, + {0x013c, -1, 278}, {0x0165, -1, 326}, {0x0119, -1, 444}, + {0x0172, -1, 722}, {0x00c1, -1, 722}, {0x00c4, -1, 722}, + {0x00e8, -1, 444}, {0x017a, -1, 444}, {0x012f, -1, 278}, + {0x00d3, -1, 722}, {0x00f3, -1, 500}, {0x0101, -1, 444}, + {0x015b, -1, 389}, {0x00ef, -1, 278}, {0x00d4, -1, 722}, + {0x00d9, -1, 722}, {0x0394, -1, 612}, {0x00fe, -1, 500}, + {0x00b2, -1, 300}, {0x00d6, -1, 722}, {0x03bc, -1, 500}, + {0x00ec, -1, 278}, {0x0151, -1, 500}, {0x0118, -1, 611}, + {0x0111, -1, 500}, {0x00be, -1, 750}, {0x015e, -1, 556}, + {0x013e, -1, 344}, {0x0136, -1, 722}, {0x0139, -1, 611}, + {0x2122, -1, 980}, {0x0117, -1, 444}, {0x00cc, -1, 333}, + {0x012a, -1, 333}, {0x013d, -1, 611}, {0x00bd, -1, 750}, + {0x2264, -1, 549}, {0x00f4, -1, 500}, {0x00f1, -1, 500}, + {0x0170, -1, 722}, {0x00c9, -1, 611}, {0x0113, -1, 444}, + {0x011f, -1, 500}, {0x00bc, -1, 750}, {0x0160, -1, 556}, + {0x0218, -1, 556}, {0x0150, -1, 722}, {0x00b0, -1, 400}, + {0x00f2, -1, 500}, {0x010c, -1, 667}, {0x00f9, -1, 500}, + {0x221a, -1, 453}, {0x010e, -1, 722}, {0x0157, -1, 333}, + {0x00d1, -1, 722}, {0x00f5, -1, 500}, {0x0156, -1, 667}, + {0x013b, -1, 611}, {0x00c3, -1, 722}, {0x0104, -1, 722}, + {0x00c5, -1, 722}, {0x00d5, -1, 722}, {0x017c, -1, 444}, + {0x011a, -1, 611}, {0x012e, -1, 333}, {0x0137, -1, 500}, + {0x2212, -1, 564}, {0x00ce, -1, 333}, {0x0148, -1, 500}, + {0x0163, -1, 278}, {0x00ac, -1, 564}, {0x00f6, -1, 500}, + {0x00fc, -1, 500}, {0x2260, -1, 549}, {0x0123, -1, 500}, + {0x00f0, -1, 500}, {0x017e, -1, 444}, {0x0146, -1, 500}, + {0x00b9, -1, 300}, {0x012b, -1, 278}, {0x20ac, -1, 500} +}; + + +const static pdc_core_metric pdc_core_metric_10 = +{ + "Times-Roman", /* FontName */ + 32L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -168, /* llx */ + -218, /* lly */ + 1000, /* urx */ + 898, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 662, /* CapHeight */ + 450, /* xHeight */ + 683, /* Ascender */ + -217, /* Descender */ + 84, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_10, + +}; + +/* -------- Generated from Times-Bold.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_11[315] = +{ + {0x0020, 32, 250}, {0x0021, 33, 333}, {0x0022, 34, 555}, + {0x0023, 35, 500}, {0x0024, 36, 500}, {0x0025, 37, 1000}, + {0x0026, 38, 833}, {0x2019, 39, 333}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x002a, 42, 500}, {0x002b, 43, 570}, + {0x002c, 44, 250}, {0x002d, 45, 333}, {0x002e, 46, 250}, + {0x002f, 47, 278}, {0x0030, 48, 500}, {0x0031, 49, 500}, + {0x0032, 50, 500}, {0x0033, 51, 500}, {0x0034, 52, 500}, + {0x0035, 53, 500}, {0x0036, 54, 500}, {0x0037, 55, 500}, + {0x0038, 56, 500}, {0x0039, 57, 500}, {0x003a, 58, 333}, + {0x003b, 59, 333}, {0x003c, 60, 570}, {0x003d, 61, 570}, + {0x003e, 62, 570}, {0x003f, 63, 500}, {0x0040, 64, 930}, + {0x0041, 65, 722}, {0x0042, 66, 667}, {0x0043, 67, 722}, + {0x0044, 68, 722}, {0x0045, 69, 667}, {0x0046, 70, 611}, + {0x0047, 71, 778}, {0x0048, 72, 778}, {0x0049, 73, 389}, + {0x004a, 74, 500}, {0x004b, 75, 778}, {0x004c, 76, 667}, + {0x004d, 77, 944}, {0x004e, 78, 722}, {0x004f, 79, 778}, + {0x0050, 80, 611}, {0x0051, 81, 778}, {0x0052, 82, 722}, + {0x0053, 83, 556}, {0x0054, 84, 667}, {0x0055, 85, 722}, + {0x0056, 86, 722}, {0x0057, 87, 1000}, {0x0058, 88, 722}, + {0x0059, 89, 722}, {0x005a, 90, 667}, {0x005b, 91, 333}, + {0x005c, 92, 278}, {0x005d, 93, 333}, {0x005e, 94, 581}, + {0x005f, 95, 500}, {0x2018, 96, 333}, {0x0061, 97, 500}, + {0x0062, 98, 556}, {0x0063, 99, 444}, {0x0064, 100, 556}, + {0x0065, 101, 444}, {0x0066, 102, 333}, {0x0067, 103, 500}, + {0x0068, 104, 556}, {0x0069, 105, 278}, {0x006a, 106, 333}, + {0x006b, 107, 556}, {0x006c, 108, 278}, {0x006d, 109, 833}, + {0x006e, 110, 556}, {0x006f, 111, 500}, {0x0070, 112, 556}, + {0x0071, 113, 556}, {0x0072, 114, 444}, {0x0073, 115, 389}, + {0x0074, 116, 333}, {0x0075, 117, 556}, {0x0076, 118, 500}, + {0x0077, 119, 722}, {0x0078, 120, 500}, {0x0079, 121, 500}, + {0x007a, 122, 444}, {0x007b, 123, 394}, {0x007c, 124, 220}, + {0x007d, 125, 394}, {0x007e, 126, 520}, {0x00a1, 161, 333}, + {0x00a2, 162, 500}, {0x00a3, 163, 500}, {0x2044, 164, 167}, + {0x00a5, 165, 500}, {0x0192, 166, 500}, {0x00a7, 167, 500}, + {0x00a4, 168, 500}, {0x0027, 169, 278}, {0x201c, 170, 500}, + {0x00ab, 171, 500}, {0x2039, 172, 333}, {0x203a, 173, 333}, + {0xfb01, 174, 556}, {0xfb02, 175, 556}, {0x2013, 177, 500}, + {0x2020, 178, 500}, {0x2021, 179, 500}, {0x00b7, 180, 250}, + {0x00b6, 182, 540}, {0x2022, 183, 350}, {0x201a, 184, 333}, + {0x201e, 185, 500}, {0x201d, 186, 500}, {0x00bb, 187, 500}, + {0x2026, 188, 1000}, {0x2030, 189, 1000}, {0x00bf, 191, 500}, + {0x0060, 193, 333}, {0x00b4, 194, 333}, {0x02c6, 195, 333}, + {0x02dc, 196, 333}, {0x00af, 197, 333}, {0x02d8, 198, 333}, + {0x02d9, 199, 333}, {0x00a8, 200, 333}, {0x02da, 202, 333}, + {0x00b8, 203, 333}, {0x02dd, 205, 333}, {0x02db, 206, 333}, + {0x02c7, 207, 333}, {0x2014, 208, 1000}, {0x00c6, 225, 1000}, + {0x00aa, 227, 300}, {0x0141, 232, 667}, {0x00d8, 233, 778}, + {0x0152, 234, 1000}, {0x00ba, 235, 330}, {0x00e6, 241, 722}, + {0x0131, 245, 278}, {0x0142, 248, 278}, {0x00f8, 249, 500}, + {0x0153, 250, 722}, {0x00df, 251, 556}, {0x00cf, -1, 389}, + {0x00e9, -1, 444}, {0x0103, -1, 500}, {0x0171, -1, 556}, + {0x011b, -1, 444}, {0x0178, -1, 722}, {0x00f7, -1, 570}, + {0x00dd, -1, 722}, {0x00c2, -1, 722}, {0x00e1, -1, 500}, + {0x00db, -1, 722}, {0x00fd, -1, 500}, {0x0219, -1, 389}, + {0x00ea, -1, 444}, {0x016e, -1, 722}, {0x00dc, -1, 722}, + {0x0105, -1, 500}, {0x00da, -1, 722}, {0x0173, -1, 556}, + {0x00cb, -1, 667}, {0x0110, -1, 722}, {0xf6c3, -1, 250}, + {0x00a9, -1, 747}, {0x0112, -1, 667}, {0x010d, -1, 444}, + {0x00e5, -1, 500}, {0x0145, -1, 722}, {0x013a, -1, 278}, + {0x00e0, -1, 500}, {0x0162, -1, 667}, {0x0106, -1, 722}, + {0x00e3, -1, 500}, {0x0116, -1, 667}, {0x0161, -1, 389}, + {0x015f, -1, 389}, {0x00ed, -1, 278}, {0x25ca, -1, 494}, + {0x0158, -1, 722}, {0x0122, -1, 778}, {0x00fb, -1, 556}, + {0x00e2, -1, 500}, {0x0100, -1, 722}, {0x0159, -1, 444}, + {0x00e7, -1, 444}, {0x017b, -1, 667}, {0x00de, -1, 611}, + {0x014c, -1, 778}, {0x0154, -1, 722}, {0x015a, -1, 556}, + {0x010f, -1, 672}, {0x016a, -1, 722}, {0x016f, -1, 556}, + {0x00b3, -1, 300}, {0x00d2, -1, 778}, {0x00c0, -1, 722}, + {0x0102, -1, 722}, {0x00d7, -1, 570}, {0x00fa, -1, 556}, + {0x0164, -1, 667}, {0x2202, -1, 494}, {0x00ff, -1, 500}, + {0x0143, -1, 722}, {0x00ee, -1, 278}, {0x00ca, -1, 667}, + {0x00e4, -1, 500}, {0x00eb, -1, 444}, {0x0107, -1, 444}, + {0x0144, -1, 556}, {0x016b, -1, 556}, {0x0147, -1, 722}, + {0x00cd, -1, 389}, {0x00b1, -1, 570}, {0x00a6, -1, 220}, + {0x00ae, -1, 747}, {0x011e, -1, 778}, {0x0130, -1, 389}, + {0x2211, -1, 600}, {0x00c8, -1, 667}, {0x0155, -1, 444}, + {0x014d, -1, 500}, {0x0179, -1, 667}, {0x017d, -1, 667}, + {0x2265, -1, 549}, {0x00d0, -1, 722}, {0x00c7, -1, 722}, + {0x013c, -1, 278}, {0x0165, -1, 416}, {0x0119, -1, 444}, + {0x0172, -1, 722}, {0x00c1, -1, 722}, {0x00c4, -1, 722}, + {0x00e8, -1, 444}, {0x017a, -1, 444}, {0x012f, -1, 278}, + {0x00d3, -1, 778}, {0x00f3, -1, 500}, {0x0101, -1, 500}, + {0x015b, -1, 389}, {0x00ef, -1, 278}, {0x00d4, -1, 778}, + {0x00d9, -1, 722}, {0x0394, -1, 612}, {0x00fe, -1, 556}, + {0x00b2, -1, 300}, {0x00d6, -1, 778}, {0x03bc, -1, 556}, + {0x00ec, -1, 278}, {0x0151, -1, 500}, {0x0118, -1, 667}, + {0x0111, -1, 556}, {0x00be, -1, 750}, {0x015e, -1, 556}, + {0x013e, -1, 394}, {0x0136, -1, 778}, {0x0139, -1, 667}, + {0x2122, -1, 1000}, {0x0117, -1, 444}, {0x00cc, -1, 389}, + {0x012a, -1, 389}, {0x013d, -1, 667}, {0x00bd, -1, 750}, + {0x2264, -1, 549}, {0x00f4, -1, 500}, {0x00f1, -1, 556}, + {0x0170, -1, 722}, {0x00c9, -1, 667}, {0x0113, -1, 444}, + {0x011f, -1, 500}, {0x00bc, -1, 750}, {0x0160, -1, 556}, + {0x0218, -1, 556}, {0x0150, -1, 778}, {0x00b0, -1, 400}, + {0x00f2, -1, 500}, {0x010c, -1, 722}, {0x00f9, -1, 556}, + {0x221a, -1, 549}, {0x010e, -1, 722}, {0x0157, -1, 444}, + {0x00d1, -1, 722}, {0x00f5, -1, 500}, {0x0156, -1, 722}, + {0x013b, -1, 667}, {0x00c3, -1, 722}, {0x0104, -1, 722}, + {0x00c5, -1, 722}, {0x00d5, -1, 778}, {0x017c, -1, 444}, + {0x011a, -1, 667}, {0x012e, -1, 389}, {0x0137, -1, 556}, + {0x2212, -1, 570}, {0x00ce, -1, 389}, {0x0148, -1, 556}, + {0x0163, -1, 333}, {0x00ac, -1, 570}, {0x00f6, -1, 500}, + {0x00fc, -1, 556}, {0x2260, -1, 549}, {0x0123, -1, 500}, + {0x00f0, -1, 500}, {0x017e, -1, 444}, {0x0146, -1, 556}, + {0x00b9, -1, 300}, {0x012b, -1, 278}, {0x20ac, -1, 500} +}; + + +const static pdc_core_metric pdc_core_metric_11 = +{ + "Times-Bold", /* FontName */ + 262176L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -168, /* llx */ + -218, /* lly */ + 1000, /* urx */ + 935, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 676, /* CapHeight */ + 461, /* xHeight */ + 683, /* Ascender */ + -217, /* Descender */ + 139, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_11, + +}; + +/* -------- Generated from Times-Italic.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_12[315] = +{ + {0x0020, 32, 250}, {0x0021, 33, 333}, {0x0022, 34, 420}, + {0x0023, 35, 500}, {0x0024, 36, 500}, {0x0025, 37, 833}, + {0x0026, 38, 778}, {0x2019, 39, 333}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x002a, 42, 500}, {0x002b, 43, 675}, + {0x002c, 44, 250}, {0x002d, 45, 333}, {0x002e, 46, 250}, + {0x002f, 47, 278}, {0x0030, 48, 500}, {0x0031, 49, 500}, + {0x0032, 50, 500}, {0x0033, 51, 500}, {0x0034, 52, 500}, + {0x0035, 53, 500}, {0x0036, 54, 500}, {0x0037, 55, 500}, + {0x0038, 56, 500}, {0x0039, 57, 500}, {0x003a, 58, 333}, + {0x003b, 59, 333}, {0x003c, 60, 675}, {0x003d, 61, 675}, + {0x003e, 62, 675}, {0x003f, 63, 500}, {0x0040, 64, 920}, + {0x0041, 65, 611}, {0x0042, 66, 611}, {0x0043, 67, 667}, + {0x0044, 68, 722}, {0x0045, 69, 611}, {0x0046, 70, 611}, + {0x0047, 71, 722}, {0x0048, 72, 722}, {0x0049, 73, 333}, + {0x004a, 74, 444}, {0x004b, 75, 667}, {0x004c, 76, 556}, + {0x004d, 77, 833}, {0x004e, 78, 667}, {0x004f, 79, 722}, + {0x0050, 80, 611}, {0x0051, 81, 722}, {0x0052, 82, 611}, + {0x0053, 83, 500}, {0x0054, 84, 556}, {0x0055, 85, 722}, + {0x0056, 86, 611}, {0x0057, 87, 833}, {0x0058, 88, 611}, + {0x0059, 89, 556}, {0x005a, 90, 556}, {0x005b, 91, 389}, + {0x005c, 92, 278}, {0x005d, 93, 389}, {0x005e, 94, 422}, + {0x005f, 95, 500}, {0x2018, 96, 333}, {0x0061, 97, 500}, + {0x0062, 98, 500}, {0x0063, 99, 444}, {0x0064, 100, 500}, + {0x0065, 101, 444}, {0x0066, 102, 278}, {0x0067, 103, 500}, + {0x0068, 104, 500}, {0x0069, 105, 278}, {0x006a, 106, 278}, + {0x006b, 107, 444}, {0x006c, 108, 278}, {0x006d, 109, 722}, + {0x006e, 110, 500}, {0x006f, 111, 500}, {0x0070, 112, 500}, + {0x0071, 113, 500}, {0x0072, 114, 389}, {0x0073, 115, 389}, + {0x0074, 116, 278}, {0x0075, 117, 500}, {0x0076, 118, 444}, + {0x0077, 119, 667}, {0x0078, 120, 444}, {0x0079, 121, 444}, + {0x007a, 122, 389}, {0x007b, 123, 400}, {0x007c, 124, 275}, + {0x007d, 125, 400}, {0x007e, 126, 541}, {0x00a1, 161, 389}, + {0x00a2, 162, 500}, {0x00a3, 163, 500}, {0x2044, 164, 167}, + {0x00a5, 165, 500}, {0x0192, 166, 500}, {0x00a7, 167, 500}, + {0x00a4, 168, 500}, {0x0027, 169, 214}, {0x201c, 170, 556}, + {0x00ab, 171, 500}, {0x2039, 172, 333}, {0x203a, 173, 333}, + {0xfb01, 174, 500}, {0xfb02, 175, 500}, {0x2013, 177, 500}, + {0x2020, 178, 500}, {0x2021, 179, 500}, {0x00b7, 180, 250}, + {0x00b6, 182, 523}, {0x2022, 183, 350}, {0x201a, 184, 333}, + {0x201e, 185, 556}, {0x201d, 186, 556}, {0x00bb, 187, 500}, + {0x2026, 188, 889}, {0x2030, 189, 1000}, {0x00bf, 191, 500}, + {0x0060, 193, 333}, {0x00b4, 194, 333}, {0x02c6, 195, 333}, + {0x02dc, 196, 333}, {0x00af, 197, 333}, {0x02d8, 198, 333}, + {0x02d9, 199, 333}, {0x00a8, 200, 333}, {0x02da, 202, 333}, + {0x00b8, 203, 333}, {0x02dd, 205, 333}, {0x02db, 206, 333}, + {0x02c7, 207, 333}, {0x2014, 208, 889}, {0x00c6, 225, 889}, + {0x00aa, 227, 276}, {0x0141, 232, 556}, {0x00d8, 233, 722}, + {0x0152, 234, 944}, {0x00ba, 235, 310}, {0x00e6, 241, 667}, + {0x0131, 245, 278}, {0x0142, 248, 278}, {0x00f8, 249, 500}, + {0x0153, 250, 667}, {0x00df, 251, 500}, {0x00cf, -1, 333}, + {0x00e9, -1, 444}, {0x0103, -1, 500}, {0x0171, -1, 500}, + {0x011b, -1, 444}, {0x0178, -1, 556}, {0x00f7, -1, 675}, + {0x00dd, -1, 556}, {0x00c2, -1, 611}, {0x00e1, -1, 500}, + {0x00db, -1, 722}, {0x00fd, -1, 444}, {0x0219, -1, 389}, + {0x00ea, -1, 444}, {0x016e, -1, 722}, {0x00dc, -1, 722}, + {0x0105, -1, 500}, {0x00da, -1, 722}, {0x0173, -1, 500}, + {0x00cb, -1, 611}, {0x0110, -1, 722}, {0xf6c3, -1, 250}, + {0x00a9, -1, 760}, {0x0112, -1, 611}, {0x010d, -1, 444}, + {0x00e5, -1, 500}, {0x0145, -1, 667}, {0x013a, -1, 278}, + {0x00e0, -1, 500}, {0x0162, -1, 556}, {0x0106, -1, 667}, + {0x00e3, -1, 500}, {0x0116, -1, 611}, {0x0161, -1, 389}, + {0x015f, -1, 389}, {0x00ed, -1, 278}, {0x25ca, -1, 471}, + {0x0158, -1, 611}, {0x0122, -1, 722}, {0x00fb, -1, 500}, + {0x00e2, -1, 500}, {0x0100, -1, 611}, {0x0159, -1, 389}, + {0x00e7, -1, 444}, {0x017b, -1, 556}, {0x00de, -1, 611}, + {0x014c, -1, 722}, {0x0154, -1, 611}, {0x015a, -1, 500}, + {0x010f, -1, 544}, {0x016a, -1, 722}, {0x016f, -1, 500}, + {0x00b3, -1, 300}, {0x00d2, -1, 722}, {0x00c0, -1, 611}, + {0x0102, -1, 611}, {0x00d7, -1, 675}, {0x00fa, -1, 500}, + {0x0164, -1, 556}, {0x2202, -1, 476}, {0x00ff, -1, 444}, + {0x0143, -1, 667}, {0x00ee, -1, 278}, {0x00ca, -1, 611}, + {0x00e4, -1, 500}, {0x00eb, -1, 444}, {0x0107, -1, 444}, + {0x0144, -1, 500}, {0x016b, -1, 500}, {0x0147, -1, 667}, + {0x00cd, -1, 333}, {0x00b1, -1, 675}, {0x00a6, -1, 275}, + {0x00ae, -1, 760}, {0x011e, -1, 722}, {0x0130, -1, 333}, + {0x2211, -1, 600}, {0x00c8, -1, 611}, {0x0155, -1, 389}, + {0x014d, -1, 500}, {0x0179, -1, 556}, {0x017d, -1, 556}, + {0x2265, -1, 549}, {0x00d0, -1, 722}, {0x00c7, -1, 667}, + {0x013c, -1, 278}, {0x0165, -1, 300}, {0x0119, -1, 444}, + {0x0172, -1, 722}, {0x00c1, -1, 611}, {0x00c4, -1, 611}, + {0x00e8, -1, 444}, {0x017a, -1, 389}, {0x012f, -1, 278}, + {0x00d3, -1, 722}, {0x00f3, -1, 500}, {0x0101, -1, 500}, + {0x015b, -1, 389}, {0x00ef, -1, 278}, {0x00d4, -1, 722}, + {0x00d9, -1, 722}, {0x0394, -1, 612}, {0x00fe, -1, 500}, + {0x00b2, -1, 300}, {0x00d6, -1, 722}, {0x03bc, -1, 500}, + {0x00ec, -1, 278}, {0x0151, -1, 500}, {0x0118, -1, 611}, + {0x0111, -1, 500}, {0x00be, -1, 750}, {0x015e, -1, 500}, + {0x013e, -1, 300}, {0x0136, -1, 667}, {0x0139, -1, 556}, + {0x2122, -1, 980}, {0x0117, -1, 444}, {0x00cc, -1, 333}, + {0x012a, -1, 333}, {0x013d, -1, 611}, {0x00bd, -1, 750}, + {0x2264, -1, 549}, {0x00f4, -1, 500}, {0x00f1, -1, 500}, + {0x0170, -1, 722}, {0x00c9, -1, 611}, {0x0113, -1, 444}, + {0x011f, -1, 500}, {0x00bc, -1, 750}, {0x0160, -1, 500}, + {0x0218, -1, 500}, {0x0150, -1, 722}, {0x00b0, -1, 400}, + {0x00f2, -1, 500}, {0x010c, -1, 667}, {0x00f9, -1, 500}, + {0x221a, -1, 453}, {0x010e, -1, 722}, {0x0157, -1, 389}, + {0x00d1, -1, 667}, {0x00f5, -1, 500}, {0x0156, -1, 611}, + {0x013b, -1, 556}, {0x00c3, -1, 611}, {0x0104, -1, 611}, + {0x00c5, -1, 611}, {0x00d5, -1, 722}, {0x017c, -1, 389}, + {0x011a, -1, 611}, {0x012e, -1, 333}, {0x0137, -1, 444}, + {0x2212, -1, 675}, {0x00ce, -1, 333}, {0x0148, -1, 500}, + {0x0163, -1, 278}, {0x00ac, -1, 675}, {0x00f6, -1, 500}, + {0x00fc, -1, 500}, {0x2260, -1, 549}, {0x0123, -1, 500}, + {0x00f0, -1, 500}, {0x017e, -1, 389}, {0x0146, -1, 500}, + {0x00b9, -1, 300}, {0x012b, -1, 278}, {0x20ac, -1, 500} +}; + + +const static pdc_core_metric pdc_core_metric_12 = +{ + "Times-Italic", /* FontName */ + 96L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) -15.5, /* ItalicAngle */ + 0, /* isFixedPitch */ + -169, /* llx */ + -217, /* lly */ + 1010, /* urx */ + 883, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 653, /* CapHeight */ + 441, /* xHeight */ + 683, /* Ascender */ + -217, /* Descender */ + 76, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_12, + +}; + +/* -------- Generated from Times-BoldItalic.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_13[315] = +{ + {0x0020, 32, 250}, {0x0021, 33, 389}, {0x0022, 34, 555}, + {0x0023, 35, 500}, {0x0024, 36, 500}, {0x0025, 37, 833}, + {0x0026, 38, 778}, {0x2019, 39, 333}, {0x0028, 40, 333}, + {0x0029, 41, 333}, {0x002a, 42, 500}, {0x002b, 43, 570}, + {0x002c, 44, 250}, {0x002d, 45, 333}, {0x002e, 46, 250}, + {0x002f, 47, 278}, {0x0030, 48, 500}, {0x0031, 49, 500}, + {0x0032, 50, 500}, {0x0033, 51, 500}, {0x0034, 52, 500}, + {0x0035, 53, 500}, {0x0036, 54, 500}, {0x0037, 55, 500}, + {0x0038, 56, 500}, {0x0039, 57, 500}, {0x003a, 58, 333}, + {0x003b, 59, 333}, {0x003c, 60, 570}, {0x003d, 61, 570}, + {0x003e, 62, 570}, {0x003f, 63, 500}, {0x0040, 64, 832}, + {0x0041, 65, 667}, {0x0042, 66, 667}, {0x0043, 67, 667}, + {0x0044, 68, 722}, {0x0045, 69, 667}, {0x0046, 70, 667}, + {0x0047, 71, 722}, {0x0048, 72, 778}, {0x0049, 73, 389}, + {0x004a, 74, 500}, {0x004b, 75, 667}, {0x004c, 76, 611}, + {0x004d, 77, 889}, {0x004e, 78, 722}, {0x004f, 79, 722}, + {0x0050, 80, 611}, {0x0051, 81, 722}, {0x0052, 82, 667}, + {0x0053, 83, 556}, {0x0054, 84, 611}, {0x0055, 85, 722}, + {0x0056, 86, 667}, {0x0057, 87, 889}, {0x0058, 88, 667}, + {0x0059, 89, 611}, {0x005a, 90, 611}, {0x005b, 91, 333}, + {0x005c, 92, 278}, {0x005d, 93, 333}, {0x005e, 94, 570}, + {0x005f, 95, 500}, {0x2018, 96, 333}, {0x0061, 97, 500}, + {0x0062, 98, 500}, {0x0063, 99, 444}, {0x0064, 100, 500}, + {0x0065, 101, 444}, {0x0066, 102, 333}, {0x0067, 103, 500}, + {0x0068, 104, 556}, {0x0069, 105, 278}, {0x006a, 106, 278}, + {0x006b, 107, 500}, {0x006c, 108, 278}, {0x006d, 109, 778}, + {0x006e, 110, 556}, {0x006f, 111, 500}, {0x0070, 112, 500}, + {0x0071, 113, 500}, {0x0072, 114, 389}, {0x0073, 115, 389}, + {0x0074, 116, 278}, {0x0075, 117, 556}, {0x0076, 118, 444}, + {0x0077, 119, 667}, {0x0078, 120, 500}, {0x0079, 121, 444}, + {0x007a, 122, 389}, {0x007b, 123, 348}, {0x007c, 124, 220}, + {0x007d, 125, 348}, {0x007e, 126, 570}, {0x00a1, 161, 389}, + {0x00a2, 162, 500}, {0x00a3, 163, 500}, {0x2044, 164, 167}, + {0x00a5, 165, 500}, {0x0192, 166, 500}, {0x00a7, 167, 500}, + {0x00a4, 168, 500}, {0x0027, 169, 278}, {0x201c, 170, 500}, + {0x00ab, 171, 500}, {0x2039, 172, 333}, {0x203a, 173, 333}, + {0xfb01, 174, 556}, {0xfb02, 175, 556}, {0x2013, 177, 500}, + {0x2020, 178, 500}, {0x2021, 179, 500}, {0x00b7, 180, 250}, + {0x00b6, 182, 500}, {0x2022, 183, 350}, {0x201a, 184, 333}, + {0x201e, 185, 500}, {0x201d, 186, 500}, {0x00bb, 187, 500}, + {0x2026, 188, 1000}, {0x2030, 189, 1000}, {0x00bf, 191, 500}, + {0x0060, 193, 333}, {0x00b4, 194, 333}, {0x02c6, 195, 333}, + {0x02dc, 196, 333}, {0x00af, 197, 333}, {0x02d8, 198, 333}, + {0x02d9, 199, 333}, {0x00a8, 200, 333}, {0x02da, 202, 333}, + {0x00b8, 203, 333}, {0x02dd, 205, 333}, {0x02db, 206, 333}, + {0x02c7, 207, 333}, {0x2014, 208, 1000}, {0x00c6, 225, 944}, + {0x00aa, 227, 266}, {0x0141, 232, 611}, {0x00d8, 233, 722}, + {0x0152, 234, 944}, {0x00ba, 235, 300}, {0x00e6, 241, 722}, + {0x0131, 245, 278}, {0x0142, 248, 278}, {0x00f8, 249, 500}, + {0x0153, 250, 722}, {0x00df, 251, 500}, {0x00cf, -1, 389}, + {0x00e9, -1, 444}, {0x0103, -1, 500}, {0x0171, -1, 556}, + {0x011b, -1, 444}, {0x0178, -1, 611}, {0x00f7, -1, 570}, + {0x00dd, -1, 611}, {0x00c2, -1, 667}, {0x00e1, -1, 500}, + {0x00db, -1, 722}, {0x00fd, -1, 444}, {0x0219, -1, 389}, + {0x00ea, -1, 444}, {0x016e, -1, 722}, {0x00dc, -1, 722}, + {0x0105, -1, 500}, {0x00da, -1, 722}, {0x0173, -1, 556}, + {0x00cb, -1, 667}, {0x0110, -1, 722}, {0xf6c3, -1, 250}, + {0x00a9, -1, 747}, {0x0112, -1, 667}, {0x010d, -1, 444}, + {0x00e5, -1, 500}, {0x0145, -1, 722}, {0x013a, -1, 278}, + {0x00e0, -1, 500}, {0x0162, -1, 611}, {0x0106, -1, 667}, + {0x00e3, -1, 500}, {0x0116, -1, 667}, {0x0161, -1, 389}, + {0x015f, -1, 389}, {0x00ed, -1, 278}, {0x25ca, -1, 494}, + {0x0158, -1, 667}, {0x0122, -1, 722}, {0x00fb, -1, 556}, + {0x00e2, -1, 500}, {0x0100, -1, 667}, {0x0159, -1, 389}, + {0x00e7, -1, 444}, {0x017b, -1, 611}, {0x00de, -1, 611}, + {0x014c, -1, 722}, {0x0154, -1, 667}, {0x015a, -1, 556}, + {0x010f, -1, 608}, {0x016a, -1, 722}, {0x016f, -1, 556}, + {0x00b3, -1, 300}, {0x00d2, -1, 722}, {0x00c0, -1, 667}, + {0x0102, -1, 667}, {0x00d7, -1, 570}, {0x00fa, -1, 556}, + {0x0164, -1, 611}, {0x2202, -1, 494}, {0x00ff, -1, 444}, + {0x0143, -1, 722}, {0x00ee, -1, 278}, {0x00ca, -1, 667}, + {0x00e4, -1, 500}, {0x00eb, -1, 444}, {0x0107, -1, 444}, + {0x0144, -1, 556}, {0x016b, -1, 556}, {0x0147, -1, 722}, + {0x00cd, -1, 389}, {0x00b1, -1, 570}, {0x00a6, -1, 220}, + {0x00ae, -1, 747}, {0x011e, -1, 722}, {0x0130, -1, 389}, + {0x2211, -1, 600}, {0x00c8, -1, 667}, {0x0155, -1, 389}, + {0x014d, -1, 500}, {0x0179, -1, 611}, {0x017d, -1, 611}, + {0x2265, -1, 549}, {0x00d0, -1, 722}, {0x00c7, -1, 667}, + {0x013c, -1, 278}, {0x0165, -1, 366}, {0x0119, -1, 444}, + {0x0172, -1, 722}, {0x00c1, -1, 667}, {0x00c4, -1, 667}, + {0x00e8, -1, 444}, {0x017a, -1, 389}, {0x012f, -1, 278}, + {0x00d3, -1, 722}, {0x00f3, -1, 500}, {0x0101, -1, 500}, + {0x015b, -1, 389}, {0x00ef, -1, 278}, {0x00d4, -1, 722}, + {0x00d9, -1, 722}, {0x0394, -1, 612}, {0x00fe, -1, 500}, + {0x00b2, -1, 300}, {0x00d6, -1, 722}, {0x03bc, -1, 576}, + {0x00ec, -1, 278}, {0x0151, -1, 500}, {0x0118, -1, 667}, + {0x0111, -1, 500}, {0x00be, -1, 750}, {0x015e, -1, 556}, + {0x013e, -1, 382}, {0x0136, -1, 667}, {0x0139, -1, 611}, + {0x2122, -1, 1000}, {0x0117, -1, 444}, {0x00cc, -1, 389}, + {0x012a, -1, 389}, {0x013d, -1, 611}, {0x00bd, -1, 750}, + {0x2264, -1, 549}, {0x00f4, -1, 500}, {0x00f1, -1, 556}, + {0x0170, -1, 722}, {0x00c9, -1, 667}, {0x0113, -1, 444}, + {0x011f, -1, 500}, {0x00bc, -1, 750}, {0x0160, -1, 556}, + {0x0218, -1, 556}, {0x0150, -1, 722}, {0x00b0, -1, 400}, + {0x00f2, -1, 500}, {0x010c, -1, 667}, {0x00f9, -1, 556}, + {0x221a, -1, 549}, {0x010e, -1, 722}, {0x0157, -1, 389}, + {0x00d1, -1, 722}, {0x00f5, -1, 500}, {0x0156, -1, 667}, + {0x013b, -1, 611}, {0x00c3, -1, 667}, {0x0104, -1, 667}, + {0x00c5, -1, 667}, {0x00d5, -1, 722}, {0x017c, -1, 389}, + {0x011a, -1, 667}, {0x012e, -1, 389}, {0x0137, -1, 500}, + {0x2212, -1, 606}, {0x00ce, -1, 389}, {0x0148, -1, 556}, + {0x0163, -1, 278}, {0x00ac, -1, 606}, {0x00f6, -1, 500}, + {0x00fc, -1, 556}, {0x2260, -1, 549}, {0x0123, -1, 500}, + {0x00f0, -1, 500}, {0x017e, -1, 389}, {0x0146, -1, 556}, + {0x00b9, -1, 300}, {0x012b, -1, 278}, {0x20ac, -1, 500} +}; + + +const static pdc_core_metric pdc_core_metric_13 = +{ + "Times-BoldItalic", /* FontName */ + 262240L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) -15.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -200, /* llx */ + -218, /* lly */ + 996, /* urx */ + 921, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 669, /* CapHeight */ + 462, /* xHeight */ + 683, /* Ascender */ + -217, /* Descender */ + 121, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 315, + pdc_glyph_width_13, + +}; + +/* -------- Generated from ZapfDingbats.afm -------- */ + +static pdc_glyphwidth pdc_glyph_width_14[202] = +{ + {0x0020, 32, 278}, {0x0000, 33, 974}, {0x0000, 34, 961}, + {0x0000, 35, 974}, {0x0000, 36, 980}, {0x0000, 37, 719}, + {0x0000, 38, 789}, {0x0000, 39, 790}, {0x0000, 40, 791}, + {0x0000, 41, 690}, {0x0000, 42, 960}, {0x0000, 43, 939}, + {0x0000, 44, 549}, {0x0000, 45, 855}, {0x0000, 46, 911}, + {0x0000, 47, 933}, {0x0000, 48, 911}, {0x0000, 49, 945}, + {0x0000, 50, 974}, {0x0000, 51, 755}, {0x0000, 52, 846}, + {0x0000, 53, 762}, {0x0000, 54, 761}, {0x0000, 55, 571}, + {0x0000, 56, 677}, {0x0000, 57, 763}, {0x0000, 58, 760}, + {0x0000, 59, 759}, {0x0000, 60, 754}, {0x0000, 61, 494}, + {0x0000, 62, 552}, {0x0000, 63, 537}, {0x0000, 64, 577}, + {0x0000, 65, 692}, {0x0000, 66, 786}, {0x0000, 67, 788}, + {0x0000, 68, 788}, {0x0000, 69, 790}, {0x0000, 70, 793}, + {0x0000, 71, 794}, {0x0000, 72, 816}, {0x0000, 73, 823}, + {0x0000, 74, 789}, {0x0000, 75, 841}, {0x0000, 76, 823}, + {0x0000, 77, 833}, {0x0000, 78, 816}, {0x0000, 79, 831}, + {0x0000, 80, 923}, {0x0000, 81, 744}, {0x0000, 82, 723}, + {0x0000, 83, 749}, {0x0000, 84, 790}, {0x0000, 85, 792}, + {0x0000, 86, 695}, {0x0000, 87, 776}, {0x0000, 88, 768}, + {0x0000, 89, 792}, {0x0000, 90, 759}, {0x0000, 91, 707}, + {0x0000, 92, 708}, {0x0000, 93, 682}, {0x0000, 94, 701}, + {0x0000, 95, 826}, {0x0000, 96, 815}, {0x0000, 97, 789}, + {0x0000, 98, 789}, {0x0000, 99, 707}, {0x0000, 100, 687}, + {0x0000, 101, 696}, {0x0000, 102, 689}, {0x0000, 103, 786}, + {0x0000, 104, 787}, {0x0000, 105, 713}, {0x0000, 106, 791}, + {0x0000, 107, 785}, {0x0000, 108, 791}, {0x0000, 109, 873}, + {0x0000, 110, 761}, {0x0000, 111, 762}, {0x0000, 112, 762}, + {0x0000, 113, 759}, {0x0000, 114, 759}, {0x0000, 115, 892}, + {0x0000, 116, 892}, {0x0000, 117, 788}, {0x0000, 118, 784}, + {0x0000, 119, 438}, {0x0000, 120, 138}, {0x0000, 121, 277}, + {0x0000, 122, 415}, {0x0000, 123, 392}, {0x0000, 124, 392}, + {0x0000, 125, 668}, {0x0000, 126, 668}, {0x0000, 128, 390}, + {0x0000, 129, 390}, {0x0000, 130, 317}, {0x0000, 131, 317}, + {0x0000, 132, 276}, {0x0000, 133, 276}, {0x0000, 134, 509}, + {0x0000, 135, 509}, {0x0000, 136, 410}, {0x0000, 137, 410}, + {0x0000, 138, 234}, {0x0000, 139, 234}, {0x0000, 140, 334}, + {0x0000, 141, 334}, {0x0000, 161, 732}, {0x0000, 162, 544}, + {0x0000, 163, 544}, {0x0000, 164, 910}, {0x0000, 165, 667}, + {0x0000, 166, 760}, {0x0000, 167, 760}, {0x0000, 168, 776}, + {0x0000, 169, 595}, {0x0000, 170, 694}, {0x0000, 171, 626}, + {0x0000, 172, 788}, {0x0000, 173, 788}, {0x0000, 174, 788}, + {0x0000, 175, 788}, {0x0000, 176, 788}, {0x0000, 177, 788}, + {0x0000, 178, 788}, {0x0000, 179, 788}, {0x0000, 180, 788}, + {0x0000, 181, 788}, {0x0000, 182, 788}, {0x0000, 183, 788}, + {0x0000, 184, 788}, {0x0000, 185, 788}, {0x0000, 186, 788}, + {0x0000, 187, 788}, {0x0000, 188, 788}, {0x0000, 189, 788}, + {0x0000, 190, 788}, {0x0000, 191, 788}, {0x0000, 192, 788}, + {0x0000, 193, 788}, {0x0000, 194, 788}, {0x0000, 195, 788}, + {0x0000, 196, 788}, {0x0000, 197, 788}, {0x0000, 198, 788}, + {0x0000, 199, 788}, {0x0000, 200, 788}, {0x0000, 201, 788}, + {0x0000, 202, 788}, {0x0000, 203, 788}, {0x0000, 204, 788}, + {0x0000, 205, 788}, {0x0000, 206, 788}, {0x0000, 207, 788}, + {0x0000, 208, 788}, {0x0000, 209, 788}, {0x0000, 210, 788}, + {0x0000, 211, 788}, {0x0000, 212, 894}, {0x0000, 213, 838}, + {0x0000, 214, 1016}, {0x0000, 215, 458}, {0x0000, 216, 748}, + {0x0000, 217, 924}, {0x0000, 218, 748}, {0x0000, 219, 918}, + {0x0000, 220, 927}, {0x0000, 221, 928}, {0x0000, 222, 928}, + {0x0000, 223, 834}, {0x0000, 224, 873}, {0x0000, 225, 828}, + {0x0000, 226, 924}, {0x0000, 227, 924}, {0x0000, 228, 917}, + {0x0000, 229, 930}, {0x0000, 230, 931}, {0x0000, 231, 463}, + {0x0000, 232, 883}, {0x0000, 233, 836}, {0x0000, 234, 836}, + {0x0000, 235, 867}, {0x0000, 236, 867}, {0x0000, 237, 696}, + {0x0000, 238, 696}, {0x0000, 239, 874}, {0x0000, 241, 874}, + {0x0000, 242, 760}, {0x0000, 243, 946}, {0x0000, 244, 771}, + {0x0000, 245, 865}, {0x0000, 246, 771}, {0x0000, 247, 888}, + {0x0000, 248, 967}, {0x0000, 249, 888}, {0x0000, 250, 831}, + {0x0000, 251, 873}, {0x0000, 252, 927}, {0x0000, 253, 970}, + {0x0000, 254, 918} +}; + +const static pdc_core_metric pdc_core_metric_14 = +{ + "ZapfDingbats", /* FontName */ + 4L, /* flags */ + pdc_Type1, /* font type */ + cc_none, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + 0, /* isFixedPitch */ + -1, /* llx */ + -143, /* lly */ + 981, /* urx */ + 820, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 700, /* CapHeight */ + 0, /* xHeight */ + 800, /* Ascender */ + -200, /* Descender */ + 90, /* StdVW */ + 0, /* StdHW */ + 0, + NULL, + 202, + pdc_glyph_width_14, + +}; + +#endif /* PDF_BUILTINMETRIC_SUPPORTED */ + +#endif /* PC_COREMETR_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_crypt.c b/src/libs/pdflib/libs/pdcore/pc_crypt.c new file mode 100644 index 0000000000..8a52860a3e --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_crypt.c @@ -0,0 +1,26 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_crypt.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Routines for PDF encryption and decryption + * + */ + +#include "pc_util.h" +#include "pc_md5.h" +#include "pc_arc4.h" +#include "pc_crypt.h" + + +static void pdc_pd_crypt_c(void) {} + diff --git a/src/libs/pdflib/libs/pdcore/pc_crypt.h b/src/libs/pdflib/libs/pdcore/pc_crypt.h new file mode 100644 index 0000000000..6c9ac2c1c8 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_crypt.h @@ -0,0 +1,26 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_crypt.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Crypto routines + * + */ + +#ifndef PC_CRYPT_H +#define PC_CRYPT_H + +#include "pc_core.h" +#include "pc_output.h" + + +#endif /* PC_CRYPT_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_ebcdic.c b/src/libs/pdflib/libs/pdcore/pc_ebcdic.c new file mode 100644 index 0000000000..138fb82aea --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_ebcdic.c @@ -0,0 +1,24 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_ebcdic.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * EBCDIC conversion routines + * + */ + +#include "pc_util.h" + +/* ANSI C forbids an empty source file */ +void pdc_dummy_ebcdic_c(void); +void pdc_dummy_ebcdic_c() {} + diff --git a/src/libs/pdflib/libs/pdcore/pc_ebcdic.h b/src/libs/pdflib/libs/pdcore/pc_ebcdic.h new file mode 100644 index 0000000000..513a96cac7 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_ebcdic.h @@ -0,0 +1,23 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_ebcdic.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * EBCDIC conversion routines + * + */ + +#ifndef PC_EBCDIC_H +#define PC_EBCDIC_H + + +#endif /* PC_EBCDIC_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_encoding.c b/src/libs/pdflib/libs/pdcore/pc_encoding.c new file mode 100644 index 0000000000..fe76fae652 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_encoding.c @@ -0,0 +1,1259 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_encoding.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib in-core encodings and basic encoding functions + * + */ + +#include "pc_util.h" +#include "pc_optparse.h" + +typedef struct pdc_unicodeslot_s +{ + pdc_ushort code; /* unicode value */ + pdc_ushort slot; /* slot for this value */ +} +pdc_unicodeslot; + +typedef struct pdc_core_encvector_s +{ + char *apiname; /* PDFlib's name of the encoding at the API */ + int isstdlatin; /* character names are all Adobe standard */ + pdc_ushort codes[256]; /* unicode values */ +} +pdc_core_encvector; + +static const pdc_core_encvector pdc_core_enc_winansi = +{ + "winansi", 1, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2022, + 0x20AC, 0x2022, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, + 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x2022, 0x017D, 0x2022, + 0x2022, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x2022, 0x017E, 0x0178, + 0x0020, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x002D, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x03BC, 0x00B6, 0x00B7, + 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, + 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, + 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, + 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF + } +}; + +static const pdc_core_encvector pdc_core_enc_macroman = +{ + "macroman", 1, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, + 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8, + 0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3, + 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC, + 0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF, + 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x0000, 0x00C6, 0x00D8, + 0x0000, 0x00B1, 0x0000, 0x0000, 0x00A5, 0x03BC, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x00AA, 0x00BA, 0x0000, 0x00E6, 0x00F8, + 0x00BF, 0x00A1, 0x00AC, 0x0000, 0x0192, 0x0000, 0x0000, 0x00AB, + 0x00BB, 0x2026, 0x0020, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153, + 0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x0000, + 0x00FF, 0x0178, 0x2044, 0x00A4, 0x2039, 0x203A, 0xFB01, 0xFB02, + 0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1, + 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4, + 0x0000, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC, + 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7 + } +}; + +static const pdc_core_encvector pdc_core_enc_ebcdic = +{ + "ebcdic", 1, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0020, 0x00E2, 0x00E4, 0x00E0, 0x00E1, 0x00E3, 0x00E5, + 0x00E7, 0x00F1, 0x00A2, 0x002E, 0x003C, 0x0028, 0x002B, 0x007C, + 0x0026, 0x00E9, 0x00EA, 0x00EB, 0x00E8, 0x00ED, 0x00EE, 0x00EF, + 0x00EC, 0x00DF, 0x0021, 0x0024, 0x002A, 0x0029, 0x003B, 0x005E, + 0x2212, 0x002F, 0x00C2, 0x00C4, 0x00C0, 0x00C1, 0x00C3, 0x00C5, + 0x00C7, 0x00D1, 0x00A6, 0x002C, 0x0025, 0x005F, 0x003E, 0x003F, + 0x00F8, 0x00C9, 0x00CA, 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, + 0x00CC, 0x0060, 0x003A, 0x0023, 0x0040, 0x0027, 0x003D, 0x0022, + 0x00D8, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x00AB, 0x00BB, 0x00F0, 0x00FD, 0x00FE, 0x00B1, + 0x00B0, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, + 0x0071, 0x0072, 0x00AA, 0x00BA, 0x00E6, 0x00B8, 0x00C6, 0x00A4, + 0x03BC, 0x007E, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, + 0x0079, 0x007A, 0x00A1, 0x00BF, 0x00D0, 0x005B, 0x00DE, 0x00AE, + 0x00AC, 0x00A3, 0x00A5, 0x02D9, 0x00A9, 0x00A7, 0x00B6, 0x00BC, + 0x00BD, 0x00BE, 0x00DD, 0x00A8, 0x00AF, 0x005D, 0x00B4, 0x00D7, + 0x007B, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x002D, 0x00F4, 0x00F6, 0x00F2, 0x00F3, 0x00F5, + 0x007D, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, + 0x0051, 0x0052, 0x00B9, 0x00FB, 0x00FC, 0x00F9, 0x00FA, 0x00FF, + 0x005C, 0x00F7, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, + 0x0059, 0x005A, 0x00B2, 0x00D4, 0x00D6, 0x00D2, 0x00D3, 0x00D5, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x00B3, 0x00DB, 0x00DC, 0x00D9, 0x00DA, 0x0000 + } +}; + +static const pdc_core_encvector pdc_core_enc_pdfdoc = +{ + "pdfdoc", 1, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x02D8, 0x02C7, 0x02C6, 0x02D9, 0x02DD, 0x02DB, 0x02DA, 0x02DC, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x0192, 0x2044, + 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, + 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x0141, 0x0152, 0x0160, + 0x0178, 0x017D, 0x0131, 0x0142, 0x0153, 0x0161, 0x017E, 0x0000, + 0x20AC, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x0000, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x03BC, 0x00B6, 0x00B7, + 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, + 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, + 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, + 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, + } +}; + + +#ifdef PDF_BUILTINENCODING_SUPPORTED + +static const pdc_core_encvector pdc_core_enc_iso8859_2 = +{ + "iso8859-2", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, + 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x002D, 0x017D, 0x017B, + 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, + 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, + 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, + 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, + 0x00D0, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, + 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, + 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, + 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, + 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, + 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_3 = +{ + "iso8859-3", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0x0000, 0x0124, 0x00A7, + 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0x0000, 0x017B, + 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7, + 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0x0000, 0x017C, + 0x00C0, 0x00C1, 0x00C2, 0x0000, 0x00C4, 0x010A, 0x0108, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x0000, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7, + 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x0000, 0x00E4, 0x010B, 0x0109, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x0000, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7, + 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_4 = +{ + "iso8859-4", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7, + 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF, + 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7, + 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B, + 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, + 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A, + 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7, + 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF, + 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, + 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B, + 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7, + 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_5 = +{ + "iso8859-5", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, + 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F, + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, + 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, + 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, + 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, + 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, + 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_6 = +{ + "iso8859-6", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, + 0x0668, 0x0669, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x0000, 0x0000, 0x0000, 0x00A4, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x060C, 0x00AD, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x061B, 0x0000, 0x0000, 0x0000, 0x061F, + 0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, + 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, + 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, + 0x0638, 0x0639, 0x063A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, + 0x0648, 0x0649, 0x064A, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, + 0x0650, 0x0651, 0x0652, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_7 = +{ + "iso8859-7", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x2018, 0x2019, 0x00A3, 0x0000, 0x0000, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x0000, 0x00AB, 0x00AC, 0x00AD, 0x0000, 0x2015, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x0385, 0x0386, 0x00B7, + 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F, + 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, + 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, + 0x03A0, 0x03A1, 0x0000, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, + 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, + 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, + 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, + 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, + 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x0000, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_8 = +{ + "iso8859-8", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x0000, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, + 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2017, + 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, + 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, + 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, + 0x05E8, 0x05E9, 0x05EA, 0x0000, 0x0000, 0x200E, 0x200F, 0x0000, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_9 = +{ + "iso8859-9", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, + 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000, + 0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178, + 0x0020, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x002D, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x03BC, 0x00B6, 0x00B7, + 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, + 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, + 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, + 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_10 = +{ + "iso8859-10", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7, + 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A, + 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7, + 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2015, 0x016B, 0x014B, + 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, + 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF, + 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168, + 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, + 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, + 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF, + 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169, + 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_13 = +{ + "iso8859-13", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x201D, 0x00A2, 0x00A3, 0x00A4, 0x201E, 0x00A6, 0x00A7, + 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x201C, 0x00B5, 0x00B6, 0x00B7, + 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6, + 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, + 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, + 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, + 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, + 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, + 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, + 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, + 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_14 = +{ + "iso8859-14", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x1E02, 0x1E03, 0x00A3, 0x010A, 0x010B, 0x1E0A, 0x00A7, + 0x1E80, 0x00A9, 0x1E82, 0x1E0B, 0x1EF2, 0x00AD, 0x00AE, 0x0178, + 0x1E1E, 0x1E1F, 0x0120, 0x0121, 0x1E40, 0x1E41, 0x00B6, 0x1E56, + 0x1E81, 0x1E57, 0x1E83, 0x1E60, 0x1EF3, 0x1E84, 0x1E85, 0x1E61, + 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x0174, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x1E6A, + 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x0176, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B, + 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_15 = +{ + "iso8859-15", 1, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x00A1, 0x00A2, 0x00A3, 0x20AC, 0x00A5, 0x0160, 0x00A7, + 0x0161, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x002D, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x017D, 0x03BC, 0x00B6, 0x2022, + 0x017E, 0x00B9, 0x00BA, 0x00BB, 0x0152, 0x0153, 0x0178, 0x00BF, + 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, + 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, + 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, + } +}; + +static const pdc_core_encvector pdc_core_enc_iso8859_16 = +{ + "iso8859-16", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x0104, 0x0105, 0x0141, 0x20AC, 0x201E, 0x0160, 0x00A7, + 0x0161, 0x00A9, 0x0218, 0x00AB, 0x0179, 0x00AD, 0x017A, 0x017B, + 0x00B0, 0x00B1, 0x010C, 0x0142, 0x017D, 0x201D, 0x00B6, 0x00B7, + 0x017E, 0x010D, 0x0219, 0x00BB, 0x0152, 0x0153, 0x0178, 0x017C, + 0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0106, 0x00C6, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x0110, 0x0143, 0x00D2, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x015A, + 0x0170, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0118, 0x021A, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x0107, 0x00E6, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x0111, 0x0144, 0x00F2, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x015B, + 0x0171, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0119, 0x021B, 0x00FF, + } +}; + +static const pdc_core_encvector pdc_core_enc_cp1250 = +{ + "cp1250", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021, + 0x0000, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179, + 0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x0000, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A, + 0x0020, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x002D, 0x00AE, 0x017B, + 0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x03BC, 0x00B6, 0x00B7, + 0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C, + 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, + 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, + 0x00D0, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, + 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, + 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, + 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, + 0x00F0, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, + 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9, + } +}; + +static const pdc_core_encvector pdc_core_enc_cp1251 = +{ + "cp1251", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, + 0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F, + 0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x0000, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F, + 0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7, + 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407, + 0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7, + 0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457, + 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, + 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F, + 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, + 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F, + 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, + 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, + 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F, + } +}; + +static const pdc_core_encvector pdc_core_enc_cp1253 = +{ + "cp1253", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, + 0x0000, 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x0000, 0x2122, 0x0000, 0x203A, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7, + 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F, + 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, + 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, + 0x03A0, 0x03A1, 0x0000, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, + 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF, + 0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, + 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, + 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, + 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x0000, + } +}; + +static const pdc_core_encvector pdc_core_enc_cp1254 = +{ + "cp1254", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, + 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000, + 0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178, + 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, + 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, + 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, + 0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, + 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, + 0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, + 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF, + } +}; + +static const pdc_core_encvector pdc_core_enc_cp1255 = +{ + "cp1255", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, + 0x02C6, 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x02DC, 0x2122, 0x0000, 0x203A, 0x0000, 0x0000, 0x0000, 0x0000, + 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AA, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, + 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, + 0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7, + 0x05B8, 0x05B9, 0x0000, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF, + 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3, + 0x05F4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, + 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF, + 0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, + 0x05E8, 0x05E9, 0x05EA, 0x0000, 0x0000, 0x200E, 0x200F, 0x0000, + } +}; + +static const pdc_core_encvector pdc_core_enc_cp1256 = +{ + "cp1256", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, + 0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688, + 0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA, + 0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, + 0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F, + 0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, + 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, + 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7, + 0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643, + 0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF, + 0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7, + 0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2, + } +}; + +static const pdc_core_encvector pdc_core_enc_cp1257 = +{ + "cp1257", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021, + 0x0000, 0x2030, 0x0000, 0x2039, 0x0000, 0x00A8, 0x02C7, 0x00B8, + 0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x0000, 0x2122, 0x0000, 0x203A, 0x0000, 0x00AF, 0x02DB, 0x0000, + 0x00A0, 0x0000, 0x00A2, 0x00A3, 0x00A4, 0x0000, 0x00A6, 0x00A7, + 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, + 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6, + 0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, + 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B, + 0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, + 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF, + 0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, + 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C, + 0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, + 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9, + } +}; + +static const pdc_core_encvector pdc_core_enc_cp1258 = +{ + "cp1258", 0, + { + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, + 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, + 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, + 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, + 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, + 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, + 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000, + 0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, + 0x02C6, 0x2030, 0x0000, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000, + 0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, + 0x02DC, 0x2122, 0x0000, 0x203A, 0x0153, 0x0000, 0x0000, 0x0178, + 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, + 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, + 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, + 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, + 0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7, + 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF, + 0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7, + 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF, + 0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7, + 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF, + 0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7, + 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF, + } +}; + +#endif /* PDF_BUILTINENCODING_SUPPORTED */ + +static const pdc_core_encvector *pdc_core_encodings[] = { + &pdc_core_enc_winansi, + &pdc_core_enc_macroman, + &pdc_core_enc_ebcdic, + &pdc_core_enc_pdfdoc, +#ifdef PDF_BUILTINENCODING_SUPPORTED + &pdc_core_enc_iso8859_2, + &pdc_core_enc_iso8859_3, + &pdc_core_enc_iso8859_4, + &pdc_core_enc_iso8859_5, + &pdc_core_enc_iso8859_6, + &pdc_core_enc_iso8859_7, + &pdc_core_enc_iso8859_8, + &pdc_core_enc_iso8859_9, + &pdc_core_enc_iso8859_10, + &pdc_core_enc_iso8859_13, + &pdc_core_enc_iso8859_14, + &pdc_core_enc_iso8859_15, + &pdc_core_enc_iso8859_16, + &pdc_core_enc_cp1250, + &pdc_core_enc_cp1251, + &pdc_core_enc_cp1253, + &pdc_core_enc_cp1254, + &pdc_core_enc_cp1255, + &pdc_core_enc_cp1256, + &pdc_core_enc_cp1257, + &pdc_core_enc_cp1258, +#endif /* PDF_BUILTINENCODING_SUPPORTED */ +}; + + +pdc_encodingvector * +pdc_copy_core_encoding(pdc_core *pdc, const char *name) +{ + static const char fn[] = "pdc_copy_core_encoding"; + const char *tmpname = name; + const pdc_core_encvector *ev_ic; + pdc_encodingvector *ev = NULL; + int i, slot; + + /* MacRoman encoding with euro sign */ + if (!strcmp(name, "macroman_euro")) + tmpname = "macroman"; + + /* iso8859-1 encoding */ + if (!strcmp(name, "iso8859-1")) + tmpname = "winansi"; + + for (slot = 0; + slot < (int)(sizeof(pdc_core_encodings)/sizeof(pdc_core_encodings[0])); + slot++) + { + ev_ic = pdc_core_encodings[slot]; + if (!strcmp(tmpname, ev_ic->apiname)) + { + ev = (pdc_encodingvector *) + pdc_malloc(pdc, sizeof(pdc_encodingvector), fn); + + ev->apiname = pdc_strdup(pdc, name); + + for (i = 0; i < 256; i++) + { + if (i == 0333 && !strcmp(name, "macroman_euro")) + ev->codes[i] = PDC_EURO_SIGN; + else + ev->codes[i] = ev_ic->codes[i]; + ev->chars[i] = (char *)pdc_unicode2adobe(ev->codes[i]); + ev->given[i] = 1; + } + + if (!strcmp(name, "iso8859-1")) + { + for (i = 127; i < 160; i++) + { + ev->codes[i] = 0; + ev->chars[i] = NULL; + } + } + + ev->sortedslots = NULL; + ev->nslots = 0; + ev->flags = PDC_ENC_INCORE; + ev->flags |= PDC_ENC_SETNAMES; + if (ev_ic->isstdlatin) + ev->flags |= PDC_ENC_STDNAMES; + break; + } + } + return ev; +} + + +void +pdc_init_encoding(pdc_core *pdc, pdc_encodingvector *ev, const char *name) +{ + int slot; + + ev->apiname = pdc_strdup(pdc, name); + for (slot = 0; slot < 256; slot++) + { + ev->codes[slot] = 0; + ev->chars[slot] = NULL; + ev->given[slot] = 0; + } + ev->sortedslots = NULL; + ev->nslots = 0; + ev->flags = 0; +} + + +pdc_encodingvector * +pdc_new_encoding(pdc_core *pdc, const char *name) +{ + static const char fn[] = "pdc_new_encoding"; + + pdc_encodingvector *ev = (pdc_encodingvector *) + pdc_malloc(pdc, sizeof(pdc_encodingvector), fn); + pdc_init_encoding(pdc, ev, name); + return(ev); +} + + +void +pdc_cleanup_encoding(pdc_core *pdc, pdc_encodingvector *ev) +{ + int slot; + + if (ev->apiname) + pdc_free(pdc, ev->apiname); + + if (ev->flags & PDC_ENC_ALLOCCHARS) + { + for (slot = 0; slot < 256; slot++) + if (ev->chars[slot]) + pdc_free(pdc, ev->chars[slot]); + } + + if (ev->sortedslots) + pdc_free(pdc, ev->sortedslots); + + pdc_free(pdc, ev); +} + +static int +pdc_unicode_compare(const void *a, const void *b) +{ + pdc_unicodeslot *sssa = (pdc_unicodeslot *) a; + pdc_unicodeslot *sssb = (pdc_unicodeslot *) b; + pdc_ushort uva = sssa->code; + pdc_ushort uvb = sssb->code; + return (uva < uvb ? -1 : (uva > uvb ? 1 : 0 )); +} + +int +pdc_get_encoding_bytecode(pdc_core *pdc, pdc_encodingvector *ev, pdc_ushort uv) +{ + static const char fn[] = "pdc_get_encoding_bytecode"; + pdc_ushort slot; + int i, j, lo, hi; + + if (uv) + { + if (!ev->sortedslots) + { + int nslots = 1; + pdc_unicodeslot sss[256]; + + sss[0].code = 0; + sss[0].slot = 0; + for (slot = 1; slot < 256; slot++) + { + if (ev->codes[slot]) + { + sss[nslots].code = ev->codes[slot]; + sss[nslots].slot = slot; + nslots++; + } + } + + /* sort unicode values */ + qsort((void *)sss, (size_t) nslots, sizeof(pdc_unicodeslot), + pdc_unicode_compare); + + /* copy slot values */ + ev->sortedslots = + (pdc_byte*)pdc_malloc(pdc, nslots * sizeof(char), fn); + j = 0; + for (i = 0; i < nslots; i++) + { + /* If pairs are identical in unicode values, + * we take the pair with the smaller 8-bit code */ + if (i && sss[i].code == sss[i-1].code) + { + if (sss[i].slot > sss[i-1].slot) + continue; + j--; + } + ev->sortedslots[j] = (pdc_byte) sss[i].slot; + j++; + } + ev->nslots = j; + } + + lo = 0; + hi = ev->nslots; + while (lo < hi) + { + i = (lo + hi) / 2; + slot = (pdc_ushort) ev->sortedslots[i]; + + if (uv == ev->codes[slot]) + return slot; + + if (uv < ev->codes[slot]) + hi = i; + else + lo = i + 1; + } + } + + return -1; +} + +static const pdc_keyconn pdc_encoding_keytable[] = +{ + {"glyphid", pdc_glyphid}, + {"unicode", pdc_unicode}, + {"builtin", pdc_builtin}, + {"winansi", pdc_winansi}, + {"macroman", pdc_macroman}, + {"ebcdic", pdc_ebcdic}, + {"pdfdoc", pdc_pdfdoc}, + {NULL, 0}, +}; + +const char * +pdc_get_fixed_encoding_name(pdc_encoding enc) +{ + const char *encname = pdc_get_keyword(enc, pdc_encoding_keytable); + if (encname) + return encname; + return ""; +} diff --git a/src/libs/pdflib/libs/pdcore/pc_encoding.h b/src/libs/pdflib/libs/pdcore/pc_encoding.h new file mode 100644 index 0000000000..65e73a68d3 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_encoding.h @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_encoding.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Encoding data structures and routines + * + */ + +#ifndef PC_ENCODING_H +#define PC_ENCODING_H + +/* + * Symbolic names for predefined font encodings. 0 and above are used + * as indices in the pdc_encodingvector array. The encodings above + * ebcdic have no enumeration name, because they are loaded dynamically. + * + * The predefined encodings must not be changed or rearranged. + * The order of encodings here must match that of pdc_core_encodings + * and pdc_fixed_encoding_names in pc_encoding.c. + */ +typedef enum +{ + pdc_invalidenc = -5, + pdc_glyphid = -4, + pdc_unicode = -3, + pdc_builtin = -2, + pdc_cid = -1, + pdc_winansi = 0, + pdc_macroman = 1, + pdc_ebcdic = 2, + pdc_pdfdoc = 3, + pdc_firstvarenc = 4 +} +pdc_encoding; + +typedef struct pdc_encodingvector_s pdc_encodingvector; + +struct pdc_encodingvector_s +{ + char *apiname; /* PDFlib's name of the encoding at the API */ + pdc_ushort codes[256]; /* unicode values */ + char *chars[256]; /* character names */ + char given[256]; /* flag whether character name is given */ + pdc_byte *sortedslots; /* slots for sorted unicode values */ + int nslots; /* number of sorted slots */ + unsigned long flags; /* flags, see PDC_ENC_... */ +}; + +#define PDC_ENC_INCORE (1L<<0) /* encoding from in-core */ +#define PDC_ENC_FILE (1L<<1) /* encoding from file */ +#define PDC_ENC_HOST (1L<<2) /* encoding from host system */ +#define PDC_ENC_USER (1L<<3) /* encoding from user */ +#define PDC_ENC_FONT (1L<<4) /* encoding from font */ +#define PDC_ENC_GENERATE (1L<<5) /* encoding generated from Unicode page */ +#define PDC_ENC_USED (1L<<6) /* encoding already used */ +#define PDC_ENC_SETNAMES (1L<<7) /* character names are set */ +#define PDC_ENC_ALLOCCHARS (1L<<8) /* character names are allocated */ +#define PDC_ENC_STDNAMES (1L<<9) /* character names are all Adobe standard*/ + +#define PDC_ENC_MODSEPAR "_" /* separator of modified encoding */ +#define PDC_ENC_MODWINANSI "winansi_" /* prefix of modified winansi enc */ +#define PDC_ENC_MODMACROMAN "macroman_" /* prefix of modified macroman enc */ + +/* pc_encoding.c */ +void pdc_init_encoding(pdc_core *pdc, pdc_encodingvector *ev, + const char *name); +pdc_encodingvector *pdc_new_encoding(pdc_core *pdc, const char *name); +void pdc_cleanup_encoding(pdc_core *pdc, pdc_encodingvector *ev); +int pdc_get_encoding_bytecode(pdc_core *pdc, pdc_encodingvector *ev, + pdc_ushort uv); +pdc_encodingvector *pdc_copy_core_encoding(pdc_core *pdc, const char *encoding); +const char *pdc_get_fixed_encoding_name(pdc_encoding enc); + +#endif /* PC_ENCODING_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_file.c b/src/libs/pdflib/libs/pdcore/pc_file.c new file mode 100644 index 0000000000..e5d53f6744 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_file.c @@ -0,0 +1,772 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_file.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Various file routines + * + */ + +#include + +#include "pc_config.h" +#include "pc_util.h" +#include "pc_md5.h" +#include "pc_file.h" + +/* headers for getpid() or _getpid(). +*/ +#if defined(WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#include +#else +#if !defined(MAC) + #include + #include +#endif +#endif + +#ifndef WINCE +#include +#else +#include +#endif + +struct pdc_file_s +{ + pdc_core *pdc; /* pdcore struct */ + char *filename; /* file name */ + FILE *fp; /* file struct or NULL. Then data != NULL: */ + const pdc_byte *data; /* file data or NULL. Then fp != NULL */ + const pdc_byte *end; /* first byte above data buffer */ + const pdc_byte *pos; /* current file position in data buffer */ + pdc_byte *tdata; /* temporary buffer filled up by ungetc */ + int number; /* next available entry in tdata buffer */ + int capacity; /* currently allocated size of tdata buffer */ +}; + +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma unmanaged +#endif +int +pdc_get_fopen_errnum(pdc_core *pdc, int errnum) +{ + int outnum = errnum, isread; + + (void) pdc; + + isread = (errnum == PDC_E_IO_RDOPEN); + +#if defined(MVS) + + switch (errno) + { + case 49: + outnum = isread ? PDC_E_IO_RDOPEN_NF : PDC_E_IO_WROPEN_NF; + } + return outnum; + +#elif defined(WIN32) + { + DWORD lasterror = GetLastError(); + switch (lasterror) + { + case ERROR_ACCESS_DENIED: + outnum = isread ? PDC_E_IO_RDOPEN_PD : PDC_E_IO_WROPEN_PD; + break; + + case ERROR_FILE_NOT_FOUND: + case ERROR_INVALID_DRIVE: + case ERROR_BAD_UNIT: + outnum = isread ? PDC_E_IO_RDOPEN_NF : PDC_E_IO_WROPEN_NF; + break; + + case ERROR_INVALID_NAME: + outnum = isread ? PDC_E_IO_RDOPEN_NF : PDC_E_IO_WROPEN_IS; + break; + + case ERROR_PATH_NOT_FOUND: + outnum = isread ? PDC_E_IO_RDOPEN_NF : PDC_E_IO_WROPEN_NP; + break; + + case ERROR_TOO_MANY_OPEN_FILES: + case ERROR_SHARING_BUFFER_EXCEEDED: + outnum = isread ? PDC_E_IO_RDOPEN_TM : PDC_E_IO_WROPEN_TM; + break; + + case ERROR_FILE_EXISTS: + outnum = PDC_E_IO_WROPEN_AE; + break; + + case ERROR_BUFFER_OVERFLOW: + outnum = PDC_E_IO_WROPEN_TL; + break; + + case ERROR_WRITE_FAULT: + case ERROR_CANNOT_MAKE: + outnum = PDC_E_IO_WROPEN_NC; + break; + + case ERROR_HANDLE_DISK_FULL: + outnum = PDC_E_IO_WROPEN_NS; + break; + } + + if (lasterror) + return outnum; + + /* if lasterror == 0 we must look for errno (see .NET) */ + } + +#endif /* WIN32 */ + + switch (errno) + { +#ifdef EACCES + case EACCES: + outnum = isread ? PDC_E_IO_RDOPEN_PD : PDC_E_IO_WROPEN_PD; + break; +#endif +#ifdef ENOENT + case ENOENT: + outnum = isread ? PDC_E_IO_RDOPEN_NF : PDC_E_IO_WROPEN_NF; + break; +#endif +#ifdef EMFILE + case EMFILE: + outnum = isread ? PDC_E_IO_RDOPEN_TM : PDC_E_IO_WROPEN_TM; + break; +#endif +#ifdef ENFILE + case ENFILE: + outnum = isread ? PDC_E_IO_RDOPEN_TM : PDC_E_IO_WROPEN_TM; + break; +#endif +#ifdef EISDIR + case EISDIR: + outnum = isread ? PDC_E_IO_RDOPEN_ID : PDC_E_IO_WROPEN_ID; + break; +#endif +#ifdef EEXIST + case EEXIST: + outnum = PDC_E_IO_WROPEN_AE; + break; +#endif +#ifdef ENAMETOOLONG + case ENAMETOOLONG: + outnum = PDC_E_IO_WROPEN_TL; + break; +#endif +#ifdef ENOSPC + case ENOSPC: + outnum = PDC_E_IO_WROPEN_NS; + break; +#endif + default: + outnum = errnum; + break; + } + + return outnum; +} +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma managed +#endif + +void * +pdc_read_file(pdc_core *pdc, FILE *fp, size_t *o_filelen, int incore) +{ + static const char *fn = "pdc_read_file"; + size_t filelen, len; + char *content = NULL; + +#if defined(MVS) && defined(I370) +#define PDC_READ_CHUNKSIZE 64000 + + while (!feof(fp)) + { + if (!content) + { + len = 0; + filelen = PDC_READ_CHUNKSIZE; + content = (char *) pdc_malloc(pdc, filelen + 1, fn); + } + else if (incore) + { + len = filelen; + filelen += PDC_READ_CHUNKSIZE; + content = (char *) pdc_realloc(pdc, content, filelen + 1, fn); + } + len = fread(&content[len], 1, PDC_READ_CHUNKSIZE, fp); + } + filelen += len - PDC_READ_CHUNKSIZE; + if (incore && filelen) + { + content = (char *) pdc_realloc(pdc, content, filelen + 1, fn); + } + else + { + pdc_free(pdc, content); + content = NULL; + } + +#else + + fseek(fp, 0L, SEEK_END); + filelen = (size_t) ftell(fp); + fseek(fp, 0L, SEEK_SET); + if (incore && filelen) + { + content = (char *) pdc_malloc(pdc, filelen + 1, fn); + len = fread(content, 1, filelen, fp); + if (len != filelen) + { + pdc_free(pdc, content); + filelen = 0; + content = NULL; + } + } + +#endif + + if (content) content[filelen] = 0; + *o_filelen = filelen; + return (void *) content; +} + +pdc_file * +pdc_fopen(pdc_core *pdc, const char *filename, const char *qualifier, + const pdc_byte *data, size_t size, int flags) +{ + static const char fn[] = "pdc_fopen"; + pdc_file *sfile; + + sfile = (pdc_file *) pdc_calloc(pdc, sizeof(pdc_file), fn); + if (data) + { + sfile->data = data; + sfile->pos = sfile->data; + sfile->end = sfile->data + size; + } + else + { + sfile->fp = fopen(filename, + (flags & PDC_FILE_BINARY) ? READBMODE : READTMODE); + if (sfile->fp == NULL) + { + pdc_free(pdc, sfile); + if (qualifier) + { + pdc_set_errmsg(pdc, pdc_get_fopen_errnum(pdc, PDC_E_IO_RDOPEN), + qualifier, filename, 0, 0); + } + return NULL; + } + } + + sfile->pdc = pdc; + sfile->filename = pdc_strdup(pdc, filename); + + + return sfile; +} + + +pdc_bool +pdc_file_isvirtual(pdc_file *sfp) +{ + return sfp->fp ? pdc_false : pdc_true; +} + +char * +pdc_file_name(pdc_file *sfp) +{ + return sfp->filename; +} + +pdc_core * +pdc_file_getpdc(pdc_file *sfp) +{ + return sfp->pdc; +} + +size_t +pdc_file_size(pdc_file *sfp) +{ + size_t filelen; + + if (sfp->fp) + { + long pos = ftell(sfp->fp); + pdc_read_file(sfp->pdc, sfp->fp, &filelen, 0); + fseek(sfp->fp, pos, SEEK_SET); + } + else + filelen = (size_t) (sfp->end - sfp->data); + return filelen; +} + +const void * +pdc_freadall(pdc_file *sfp, size_t *filelen, pdc_bool *ismem) +{ + if (sfp->fp) + { + if (ismem) *ismem = pdc_false; + return (const void *) pdc_read_file(sfp->pdc, sfp->fp, filelen, 1); + } + + if (ismem) *ismem = pdc_true; + *filelen = (size_t) (sfp->end - sfp->data); + return sfp->data; +} + +static int +pdc_fgetc_e(pdc_file *sfp) +{ + int c = pdc_fgetc(sfp); + return c; +} + +char * +pdc_fgets_comp(char *s, int size, pdc_file *sfp) +{ + int i, c; + + c = pdc_fgetc_e(sfp); + if (c == EOF) + return NULL; + + size--; + for (i = 0; i < size; i++) + { + if (c == '\n' || c == '\r' || c == EOF) break; + s[i] = (char) c; + c = pdc_fgetc_e(sfp); + } + s[i] = 0; + + /* Skip windows line end \r\n */ + if (c == '\r') + { + c = pdc_fgetc_e(sfp); + if (c != '\n') + { + pdc_ungetc(c, sfp); + } + } + return s; +} + +/* + * Emulation of C file functions - relevant for PDFlib + */ + +long +pdc_ftell(pdc_file *sfp) +{ + if (sfp->fp) + return ftell(sfp->fp); + + return (long) (sfp->pos - sfp->data); +} + +int +pdc_fseek(pdc_file *sfp, long offset, int whence) +{ + if (sfp->fp) + return fseek(sfp->fp, offset, whence); + + sfp->number = 0; + + switch (whence) + { + case SEEK_SET: + if (sfp->data + offset > sfp->end) + return -1; + sfp->pos = sfp->data + offset; + break; + + case SEEK_CUR: + if (sfp->pos + offset > sfp->end) + return -1; + sfp->pos += offset; + break; + + case SEEK_END: + if (sfp->end + offset > sfp->end) + return -1; + sfp->pos = sfp->end + offset; + break; + } + return 0; +} + +size_t +pdc_fread(void *ptr, size_t size, size_t nmemb, pdc_file *sfp) +{ + size_t nbytes = 0; + + if (sfp->fp) + return fread(ptr, size, nmemb, sfp->fp); + + nbytes = size * nmemb; + if (sfp->pos + nbytes > sfp->end) + { + nbytes = (size_t) (sfp->end - sfp->pos); + nmemb = nbytes / size; + nbytes = nmemb *size; + } + memcpy(ptr, sfp->pos, nbytes); + sfp->pos += nbytes; + + return nmemb; +} + +#define UNGETC_CHUNKSIZE 16 + +int +pdc_ungetc(int c, pdc_file *sfp) +{ + static const char fn[] = "pdc_ungetc"; + + if (sfp->fp) + return ungetc(c, sfp->fp); + + if (!sfp->capacity) + { + sfp->capacity = UNGETC_CHUNKSIZE; + sfp->tdata = (pdc_byte *) pdc_malloc(sfp->pdc, + sfp->capacity * sizeof(pdc_byte), fn); + } + else if (sfp->number == sfp->capacity) + { + sfp->capacity += UNGETC_CHUNKSIZE; + sfp->tdata = (pdc_byte *) pdc_realloc(sfp->pdc, sfp->tdata, + sfp->capacity * sizeof(pdc_byte), fn); + } + + sfp->tdata[sfp->number] = (pdc_byte) c; + sfp->number++; + return c; +} + +int +pdc_fgetc(pdc_file *sfp) +{ + int ch = 0; + + if (sfp->fp) + return fgetc(sfp->fp); + + if (sfp->tdata && sfp->number > 0) + { + sfp->number--; + ch = (int) sfp->tdata[sfp->number]; + } + else + { + if (sfp->pos < sfp->end) + { + ch = (int) *sfp->pos; + sfp->pos++; + } + else + { + ch = EOF; + } + } + return ch; +} + +char * +pdc_fgets(char *s, int size, pdc_file *sfp) +{ + int i; + int ch, chp; + + if (sfp->fp) + return fgets(s, size, sfp->fp); + + chp = 0; + for (i = 0; i < size ; i++) + { + ch = 0; + if (i < size - 1 && chp != '\n') + { + if (sfp->number > 0) + { + sfp->number--; + ch = (int) sfp->tdata[sfp->number]; + } + else if (sfp->pos < sfp->end) + { + ch = (int) *sfp->pos; + sfp->pos++; + } + if (ch == EOF) ch = 0; + } + s[i] = (char) ch; + if (!ch) + break; + chp = (int) s[i]; + } + + return (i > 1) ? s : NULL; +} + +int +pdc_feof(pdc_file *sfp) +{ + if (sfp->fp) + return feof(sfp->fp); + + return (sfp->pos >= sfp->end) ? 1 : 0; +} + +void +pdc_fclose(pdc_file *sfp) +{ + if (sfp) + { + if (sfp->fp) + { + fclose(sfp->fp); + sfp->fp = NULL; + } + if (sfp->tdata) + { + pdc_free(sfp->pdc, sfp->tdata); + sfp->tdata = NULL; + } + if (sfp->filename) + { + pdc_free(sfp->pdc, sfp->filename); + sfp->filename = NULL; + } + pdc_free(sfp->pdc, sfp); + } +} + +/* + * Concatenating a directory name with a file base name to a full valid + * file name. On MVS platforms an extension at the end of basename + * will be discarded. + */ +void +pdc_file_fullname(const char *dirname, const char *basename, char *fullname) +{ + int ib; + size_t len = strlen(basename); +#ifdef MVS + pdc_bool lastterm = pdc_false; +#endif + + for (ib = 0; ib < (int) len; ib++) + if (!isspace(basename[ib])) + break; + + if (!dirname || !dirname[0]) + { + strcpy(fullname, &basename[ib]); + } + else + { + fullname[0] = 0; +#ifdef MVS + if (strncmp(dirname, PDC_FILEQUOT, 1)) + strcat(fullname, PDC_FILEQUOT); +#endif + strcat(fullname, dirname); + strcat(fullname, PDC_PATHSEP); + strcat(fullname, &basename[ib]); +#ifdef MVS + lastterm = pdc_true; +#endif + } + +#ifdef MVS + { + int ie; + + len = strlen(fullname); + for (ie = len; ie >= 0; ie--) + { + if (!strncmp(&fullname[ie], PDC_PATHSEP, 1)) + break; + if (fullname[ie] == '.') + { + fullname[ie] = 0; + break; + } + } + if (lastterm) + { + strcat(fullname, PDC_PATHTERM); + strcat(fullname, PDC_FILEQUOT); + } + } +#endif +} + +/* + * Function reads a text file and creates a string list + * of all no-empty and no-comment lines. The strings are stripped + * by leading and trailing white space characters. + * + * The caller is responsible for freeing the resultated string list + * by calling the function pdc_cleanup_stringlist. + * + * Not for unicode strings. + * + * Return value: Number of strings + */ + +#define PDC_BUFSIZE 1024 +#define PDC_ARGV_CHUNKSIZE 256 + +int +pdc_read_textfile(pdc_core *pdc, pdc_file *sfp, char ***linelist) +{ + static const char *fn = "pdc_read_textfile"; + char buf[PDC_BUFSIZE]; + char *content = NULL; + char **argv = NULL; + int nlines = 0; + size_t filelen; + size_t len, maxl = 0; + int tocont, incont = 0; + int i, is = 0; + + /* Get file length and allocate content array */ + filelen = pdc_file_size(sfp); + content = (char *) pdc_malloc(pdc, filelen, fn); + + /* Read loop */ + while (pdc_fgets_comp(buf, PDC_BUFSIZE, sfp) != NULL) + { + /* Strip blank and comment lines */ + pdc_str2trim(buf); + if (buf[0] == 0 || buf[0] == '%') + continue; + + /* Strip inline comments */ + len = strlen(buf); + for (i = 1; i < (int) len; i++) + { + if (buf[i] == '%' && buf[i-1] != '\\') + { + buf[i] = 0; + pdc_strtrim(buf); + len = strlen(buf); + break; + } + } + + /* Continuation line */ + tocont = (buf[len-1] == '\\') ? 1:0; + if (tocont) + { + buf[len-1] = '\0'; + len--; + } + + /* Copy line */ + strcpy(&content[is], buf); + + /* Save whole line */ + if (!incont) + { + if (nlines >= (int) maxl) + { + maxl += PDC_ARGV_CHUNKSIZE; + argv = (argv == NULL) ? + (char **)pdc_malloc(pdc, maxl * sizeof(char *), fn): + (char **)pdc_realloc(pdc, argv, maxl * + sizeof(char *), fn); + } + argv[nlines] = &content[is]; + nlines++; + } + + /* Next index */ + incont = tocont; + is += (int) (len + 1 - incont); + } + + if (!argv) pdc_free(pdc, content); + *linelist = argv; + return nlines; +} + + +/* generate a temporary file name from the current time, pid, and the +** data in inbuf using MD5. +*/ +void +pdc_tempname(char *outbuf, int outlen, const char *inbuf, int inlen) +{ + MD5_CTX md5; + time_t timer; + unsigned char digest[MD5_DIGEST_LENGTH]; + int i; + +#if defined(WIN32) + int pid = _getpid(); +#else +#if !defined(MAC) + pid_t pid = getpid(); +#endif +#endif + + time(&timer); + + MD5_Init(&md5); +#if !defined(MAC) + MD5_Update(&md5, (unsigned char *) &pid, sizeof pid); +#endif + MD5_Update(&md5, (unsigned char *) &timer, sizeof timer); + MD5_Update(&md5, (unsigned char *) inbuf, (unsigned int) inlen); + MD5_Final(digest, &md5); + + for (i = 0; i < outlen - 1; ++i) + outbuf[i] = (char) ('A' + digest[i % MD5_DIGEST_LENGTH] % 26); + + outbuf[i] = 0; +} + +#ifdef PDF_TARGET_API_MAC_CARBON + +/* Construct an FSSpec from a Posix path name. Only required for + * Carbon (host font support and file type/creator). + */ + +OSStatus +FSPathMakeFSSpec(const UInt8 *path, FSSpec *spec) +{ + OSStatus result; + FSRef ref; + + /* convert the POSIX path to an FSRef */ + result = FSPathMakeRef(path, &ref, NULL); + + if (result != noErr) + return result; + + /* and then convert the FSRef to an FSSpec */ + result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL); + + return result; +} + +#endif /* PDF_TARGET_API_MAC_CARBON */ + diff --git a/src/libs/pdflib/libs/pdcore/pc_file.h b/src/libs/pdflib/libs/pdcore/pc_file.h new file mode 100644 index 0000000000..c94067f952 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_file.h @@ -0,0 +1,76 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_file.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Definitions for file routines + * + */ + +#ifndef PC_FILE_H +#define PC_FILE_H + +#if (defined(MAC) || defined(MACOSX)) + +#include + +#ifdef PDF_TARGET_API_MAC_CARBON + +OSStatus FSPathMakeFSSpec(const UInt8 *path, FSSpec *spec); + +#else + +#include + +OSErr FSpLocationFromFullPath(short fullPathLength, + const void *fullPath, FSSpec *spec); + +#endif /* !PDF_TARGET_API_MAC_CARBON */ +#endif /* (defined(MAC) || defined(MACOSX)) */ + +#define PDC_FILENAMELEN 1024 /* maximum file name length */ + +#define PDC_FILE_BINARY (1L<<0) /* open as binary file, + otherwise as text file */ + +#define PDC_OK_FREAD(file, buffer, len) \ + (pdc_fread(buffer, 1, len, file) == len) + +typedef struct pdc_file_s pdc_file; + +int pdc_get_fopen_errnum(pdc_core *pdc, int errnum); +void *pdc_read_file(pdc_core *pdc, FILE *fp, size_t *o_filelen, int incore); +int pdc_read_textfile(pdc_core *pdc, pdc_file *sfp, char ***linelist); +void pdc_tempname(char *outbuf, int outlen, const char *inbuf, int inlen); + +pdc_file *pdc_fopen(pdc_core *pdc, const char *filename, const char *qualifier, + const pdc_byte *data, size_t size, int flags); +pdc_core *pdc_file_getpdc(pdc_file *sfp); +char *pdc_file_name(pdc_file *sfp); +size_t pdc_file_size(pdc_file *sfp); +pdc_bool pdc_file_isvirtual(pdc_file *sfp); +char *pdc_fgets_comp(char *s, int size, pdc_file *sfp); +long pdc_ftell(pdc_file *sfp); +int pdc_fseek(pdc_file *sfp, long offset, int whence); +size_t pdc_fread(void *ptr, size_t size, size_t nmemb, pdc_file *sfp); +const void *pdc_freadall(pdc_file *sfp, size_t *filelen, pdc_bool *ismem); +int pdc_ungetc(int c, pdc_file *sfp); +int pdc_fgetc(pdc_file *sfp); +char *pdc_fgets(char *s, int size, pdc_file *sfp); +int pdc_feof(pdc_file *sfp); +void pdc_fclose(pdc_file *sfp); +void pdc_file_fullname(const char *dirname, const char *basename, + char *fullname); + + + +#endif /* PC_FILE_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_font.c b/src/libs/pdflib/libs/pdcore/pc_font.c new file mode 100644 index 0000000000..236e6d1d21 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_font.c @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_font.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Basic font functions + * + */ + +#include "pc_util.h" +#include "pc_font.h" + +void +pdc_init_font_struct(pdc_core *pdc, pdc_font *font) +{ + /* + * Fill in some reasonable default values in global font info in + * case they're missing from the metrics data. + */ + + (void) pdc; + + memset(font, 0, sizeof(pdc_font)); + + font->verbose = pdc_true; + font->verbose_open = pdc_true; + font->obj_id = PDC_BAD_ID; + font->type = pdc_Type1; + font->style = pdc_Normal; + font->encoding = pdc_builtin; + font->charcoll = cc_none; + + font->italicAngle = 0; + font->isFixedPitch = pdc_false; + font->llx = (float) -50; + font->lly = (float) -200; + font->urx = (float) 1000; + font->ury = (float) 900; + font->underlinePosition = -100; + font->underlineThickness = 50; + font->capHeight = 700; + font->xHeight = 0; + font->ascender = 800; + font->descender = -200; + font->StdVW = 0; + font->StdHW = 0; + font->monospace = 0; + + font->codeSize = 1; + font->numOfCodes = 256; + font->lastCode = -1; +} + +void +pdc_cleanup_font_struct(pdc_core *pdc, pdc_font *font) +{ + int i; + + if (font == NULL) + return; + + if (font->img != NULL && font->imgname == NULL) + pdc_free(pdc, font->img); + + if (font->imgname != NULL) + pdc_free(pdc, font->imgname); + + if (font->name != NULL) + pdc_free(pdc, font->name); + + if (font->apiname != NULL) + pdc_free(pdc, font->apiname); + + if (font->ttname != NULL) + pdc_free(pdc, font->ttname); + + if (font->fontfilename != NULL) + pdc_free(pdc, font->fontfilename); + + if (font->cmapname != NULL) { + pdc_free(pdc, font->cmapname); + } + + if (font->encapiname != NULL) { + pdc_free(pdc, font->encapiname); + } + + if (font->glw != NULL) { + pdc_free(pdc, font->glw); + } + + if (font->pkd != NULL) { + pdc_free(pdc, font->pkd); + } + + if (font->GID2Name != NULL) { + if (font->names_tbf) { + for (i = 0; i < font->numOfGlyphs; i++) { + if (font->GID2Name[i] != NULL) + pdc_free(pdc, font->GID2Name[i]); + } + } + pdc_free(pdc, font->GID2Name); + } + + if (font->GID2code != NULL) { + pdc_free(pdc, font->GID2code); + } + + if (font->code2GID != NULL) { + pdc_free(pdc, font->code2GID); + } + + if (font->usedGIDs != NULL) { + pdc_free(pdc, font->usedGIDs); + } + + if (font->widthsTab != NULL) { + pdc_free(pdc, font->widthsTab); + } + + if (font->widths != NULL) { + pdc_free(pdc, font->widths); + } + + if (font->usedChars != NULL) { + pdc_free(pdc, font->usedChars); + } + + if (font->t3font != NULL) { + pdc_cleanup_t3font_struct(pdc, font->t3font); + pdc_free(pdc, font->t3font); + } +} + +void +pdc_cleanup_t3font_struct(pdc_core *pdc, pdc_t3font *t3font) +{ + int i; + + if (t3font->fontname != NULL) + pdc_free(pdc, t3font->fontname); + + for (i = 0; i < t3font->next_glyph; i++) { + if (t3font->glyphs[i].name) + pdc_free(pdc, t3font->glyphs[i].name); + } + + pdc_free(pdc, t3font->glyphs); +} diff --git a/src/libs/pdflib/libs/pdcore/pc_font.h b/src/libs/pdflib/libs/pdcore/pc_font.h new file mode 100644 index 0000000000..2511a4fbe1 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_font.h @@ -0,0 +1,226 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_font.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Header file for font handling + * + */ + +#ifndef PC_FONT_H +#define PC_FONT_H + +#include "pc_core.h" +#include "pc_geom.h" +#include "pc_encoding.h" + +/* Predefined character collections */ +typedef enum { + cc_simplified_chinese, + cc_traditional_chinese, + cc_japanese, + cc_korean, + cc_identity, + cc_none +} pdc_charcoll; + +/* Font types */ +typedef enum { + pdc_Type1, /* Type1 fonts */ + pdc_MMType1, /* Multiple master fonts */ + pdc_TrueType, /* TrueType fonts for 1-byte encoding */ + pdc_CIDFontType2, /* TrueType fonts for 2-byte encoding */ + pdc_Type1C, /* OpenType fonts with CFF_ for 1-byte encoding */ + pdc_CIDFontType0, /* OpenType fonts with CFF_ for 2-byte encoding */ + pdc_Type3 /* Type3 fonts */ +} pdc_fonttype; + +/* Font styles */ +typedef enum { + pdc_Normal, + pdc_Bold, + pdc_Italic, + pdc_BoldItalic +} pdc_fontstyle; + +typedef struct pdc_interwidth_s pdc_interwidth; +typedef struct pdc_core_metric_s pdc_core_metric; +typedef struct pdc_glyphwidth_s pdc_glyphwidth; +typedef struct pdc_kerningpair_s pdc_kerningpair; +typedef struct pdc_widthdata_s pdc_widthdata; +typedef struct pdc_t3glyph_s pdc_t3glyph; +typedef struct pdc_t3font_s pdc_t3font; +typedef struct pdc_font_s pdc_font; + +/* Glyph width data structure */ +struct pdc_glyphwidth_s +{ + pdc_ushort unicode; /* unicode of glyph */ + short code; /* builtin 8-bit code */ + pdc_ushort width; /* glyph width */ +}; + +/* Kerning pair data */ +struct pdc_kerningpair_s +{ + pdc_ushort glyph1; /* either 8-bit code or unicode of glyph 1 */ + pdc_ushort glyph2; /* either 8-bit code or unicode of glyph 2 */ + short xamt; /* x amount of kerning */ + short dominant; /* = 1: kerning pair domimant */ +}; + +struct pdc_widthdata_s +{ + pdc_ushort startcode; /* start unicode value of interval */ + int width; /* width of characters in the code */ + /* interval */ +}; + +struct pdc_t3glyph_s +{ + char *name; + pdc_id charproc_id; + float width; +}; + +struct pdc_t3font_s +{ + pdc_t3glyph *glyphs; /* dynamically growing glyph table */ + int capacity; /* current number of slots */ + int next_glyph; /* next available slot */ + + char *fontname; /* fontname */ + pdc_id charprocs_id; /* id of /CharProcs dict */ + pdc_id res_id; /* id of /Resources dict */ + pdc_bool colorized; /* glyphs colorized */ + pdc_matrix matrix; /* font matrix */ + pdc_rectangle bbox; /* font bounding box */ +}; + +/* The core PDFlib font structure */ +struct pdc_font_s { + pdc_bool verbose; /* put out warning/error messages */ + pdc_bool verbose_open; /* after opening font file */ + char *name; /* fontname */ + char *apiname; /* fontname specified in API call */ + char *ttname; /* names[6] in the TT name table */ + char *fontfilename; /* name of external font file */ + + pdc_bool vertical; /* vertical writing mode */ + pdc_bool embedding; /* font embedding */ + pdc_bool kerning; /* font kerning */ + pdc_bool autocidfont; /* automatic convert to CID font */ + pdc_bool unicodemap; /* automatic creation of Unicode CMap */ + pdc_bool subsetting; /* font subsetting */ + pdc_bool autosubsetting; /* automatic font subsetting */ + float subsetminsize; /* minimal size for font subsetting */ + float subsetlimit; /* maximal percent for font subsetting*/ + + int used_on_current_page; /* this font is in use on current p. */ + pdc_id obj_id; /* object id of this font */ + + unsigned long flags; /* font flags for font descriptor */ + pdc_fonttype type; /* type of font */ + pdc_fontstyle style; /* TT: style of font */ + pdc_bool isstdlatin; /* is standard latin font */ + pdc_bool hasnomac; /* TT: has no macroman cmap (0,1) */ + + pdc_encoding encoding; /* PDFlib font encoding shortcut */ + pdc_charcoll charcoll; /* CID character collection supported */ + char *cmapname; /* CID CMap name */ + char *encapiname; /* Encoding name specified in API call*/ + + float italicAngle; /* AFM key: ItalicAngle */ + int isFixedPitch; /* AFM key: IsFixedPitch */ + float llx; /* AFM key: FontBBox */ + float lly; /* AFM key: FontBBox */ + float urx; /* AFM key: FontBBox */ + float ury; /* AFM key: FontBBox */ + int underlinePosition; /* AFM key: UnderlinePosition */ + int underlineThickness; /* AFM key: UnderlineThickness */ + int capHeight; /* AFM key: CapHeight */ + int xHeight; /* AFM key: XHeight */ + int ascender; /* AFM key: Ascender */ + int descender; /* AFM key: Descender */ + int StdVW; /* AFM key: StdVW */ + int StdHW; /* AFM key: StdHW */ + int monospace; /* monospace amount */ + + int numOfGlyphs; /* # of Glyph ID's */ + pdc_glyphwidth *glw; /* ptr to glyph metrics array */ + int numOfPairs; /* # of entries in pair kerning array */ + pdc_kerningpair *pkd; /* ptr to pair kerning array */ + + int codeSize; /* code size = 0 (unknown), -2,-1,1,2 */ + int numOfCodes; /* # of codes defined by encoding */ + int lastCode; /* last byte code */ + pdc_bool names_tbf; /* glyph names to be freed */ + char **GID2Name; /* mapping Glyph ID -> Glyph name */ + pdc_ushort *GID2code; /* mapping Glyph ID -> code */ + /* glyphid: code = unicode! */ + pdc_ushort *code2GID; /* mapping code -> Glyph ID */ + /* glyphid: code = glyphid! */ + pdc_ushort *usedGIDs; /* used Glyph IDs */ + int defWidth; /* default width */ + int numOfWidths; /* # of character width intervals */ + pdc_widthdata *widthsTab; /* ptr to character width intervals */ + /* or NULL - then consecutive */ + int *widths; /* characters widths [numOfCodes] */ + char *usedChars; /* bit field for used characters */ + /* in a document */ + + char *imgname; /* name of virtual file contains *img */ + size_t filelen; /* length of uncompressed font data */ + pdc_byte *img; /* font (or CFF table) data in memory */ + long cff_offset; /* start of CFF table in font */ + size_t cff_length; /* length of CFF table in font */ + pdc_t3font *t3font; /* type 3 font data */ +}; + +/* these defaults are used when the stem value must be derived from the name */ +#define PDF_STEMV_MIN 50 /* minimum StemV value */ +#define PDF_STEMV_LIGHT 71 /* light StemV value */ +#define PDF_STEMV_NORMAL 109 /* normal StemV value */ +#define PDF_STEMV_MEDIUM 125 /* mediumbold StemV value */ +#define PDF_STEMV_SEMIBOLD 135 /* semibold StemV value */ +#define PDF_STEMV_BOLD 165 /* bold StemV value */ +#define PDF_STEMV_EXTRABOLD 201 /* extrabold StemV value */ +#define PDF_STEMV_BLACK 241 /* black StemV value */ + +/* Bit positions for the font descriptor flag */ +#define FIXEDWIDTH (long) (1L<<0) +#define SERIF (long) (1L<<1) +#define SYMBOL (long) (1L<<2) +#define SCRIPT (long) (1L<<3) +#define ADOBESTANDARD (long) (1L<<5) +#define ITALIC (long) (1L<<6) +#define SMALLCAPS (long) (1L<<17) +#define FORCEBOLD (long) (1L<<18) + +#define PDC_DEF_ITALICANGLE -12 /* default italic angle */ + +/* pc_font.c */ +void pdc_init_font_struct(pdc_core *pdc, pdc_font *font); +void pdc_cleanup_font_struct(pdc_core *pdc, pdc_font *font); +void pdc_cleanup_t3font_struct(pdc_core *pdc, pdc_t3font *t3font); + +/* pc_corefont.c */ +const char *pdc_get_base14_name(int slot); +const pdc_core_metric *pdc_get_core_metric(const char *fontname); +void pdc_init_core_metric(pdc_core *pdc, pdc_core_metric *metric); +void pdc_cleanup_core_metric(pdc_core *pdc, pdc_core_metric *metric); +void pdc_fill_core_metric(pdc_core *pdc, + pdc_font *font, pdc_core_metric *metric); +void pdc_fill_font_metric(pdc_core *pdc, + pdc_font *font, const pdc_core_metric *metric); + +#endif /* PC_FONT_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_generr.h b/src/libs/pdflib/libs/pdcore/pc_generr.h new file mode 100644 index 0000000000..23af8d4614 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_generr.h @@ -0,0 +1,235 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_generr.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDCORE error messages + * + */ + +#if pdc_genNames +#define gen(n, num, nam, msg) PDC_E_##nam = num, +#elif pdc_genInfo +#define gen(n, num, nam, msg) { n, num, msg, (const char *) 0 }, + +#else +#error invalid inclusion of generator file +#endif + +/* -------------------------------------------------------------------- */ +/* Configuration, memory, and I/O (10xx) */ +/* -------------------------------------------------------------------- */ + +gen(1, 1000, MEM_OUT, "Out of memory in function $1") + +gen(1, 1008, IO_ILLFILENAME, "Bad file name '$1'") + +gen(2, 1010, IO_RDOPEN, "Couldn't open $1file '$2' for reading") + +gen(2, 1012, IO_WROPEN, "Couldn't open $1file '$2' for writing") + +gen(0, 1014, IO_NOWRITE, "Couldn't write output") + +gen(2, 1016, IO_RDOPEN_NF, + "Couldn't open $1file '$2' for reading (file not found)") + +gen(2, 1018, IO_WROPEN_NF, + "Couldn't open $1file '$2' for writing (no such directory)") + +gen(2, 1020, IO_RDOPEN_PD, + "Couldn't open $1file '$2' for reading (permission denied)") + +gen(2, 1022, IO_WROPEN_PD, + "Couldn't open $1file '$2' for writing (permission denied)") + +gen(2, 1024, IO_RDOPEN_TM, + "Couldn't open $1file '$2' for reading (too many open files)") + +gen(2, 1026, IO_WROPEN_TM, + "Couldn't open $1file '$2' for writing (too many open files)") + +gen(2, 1028, IO_RDOPEN_ID, + "Couldn't open $1file '$2' for reading (is a directory)") + +gen(2, 1030, IO_WROPEN_ID, + "Couldn't open $1file '$2' for writing (is a directory)") + +gen(2, 1032, IO_WROPEN_AE, + "Couldn't open $1file '$2' for writing (file already exists)") + +gen(2, 1034, IO_WROPEN_TL, + "Couldn't open $1file '$2' for writing (file name too long)") + +gen(2, 1036, IO_WROPEN_NS, + "Couldn't open $1file '$2' for writing (no space left on device)") + +gen(2, 1038, IO_WROPEN_IS, + "Couldn't open $1file '$2' for writing (file name syntax incorrect)") + +gen(2, 1040, IO_WROPEN_NC, + "Couldn't open $1file '$2' for writing (file cannot be created)") + +gen(2, 1042, IO_WROPEN_NP, + "Couldn't open $1file '$2' for writing (path not found)") + +gen(1, 1050, IO_COMPRESS, "Compression error ($1)") + +gen(0, 1052, IO_NOBUFFER, "Don't fetch buffer contents when writing to file") + +gen(2, 1054, IO_BADFORMAT, "'$1' does not appear to be a $2 file") + +gen(1, 1056, IO_NODATA, "Couldn't read data from file '$1'") + +gen(3, 1058, IO_ILLSYNTAX, "$1file '$2': Syntax error in line $3") + +gen(1, 1060, PVF_NAMEEXISTS, + "Couldn't create virtual file '$1' (name already exists)") + + +/* -------------------------------------------------------------------- */ +/* Invalid arguments (11xx) */ +/* -------------------------------------------------------------------- */ + +gen(1, 1100, ILLARG_EMPTY, "Parameter '$1' is empty") + +gen(1, 1102, ILLARG_POSITIVE, "Parameter '$1' must be positive") + +gen(2, 1104, ILLARG_BOOL, "Boolean parameter '$1' has bad value '$2'") + +gen(2, 1106, ILLARG_INT, "Integer parameter '$1' has bad value $2") + +gen(2, 1108, ILLARG_FLOAT, "Floating-point parameter '$1' has bad value $2") + +gen(2, 1110, ILLARG_STRING, "String parameter '$1' has bad value '$2'") + +/* Unused. See 1504 +gen(1, 1112, ILLARG_UTF, "Illegal UTF-$1 sequence in string") + */ + +gen(2, 1114, ILLARG_MATRIX, "Matrix [$1] is degenerate") + +gen(2, 1116, ILLARG_TOOLONG, + "String parameter '$1' is limited to max. $2 characters'") + +gen(2, 1118, ILLARG_HANDLE, "Handle parameter '$1' has bad value $2") + + +/* -------------------------------------------------------------------- */ +/* Parameters and values (12xx) */ +/* -------------------------------------------------------------------- */ + +gen(0, 1200, PAR_EMPTYKEY, "Empty key") + +gen(1, 1202, PAR_UNKNOWNKEY, "Unknown key '$1'") + +gen(0, 1204, PAR_EMPTYVALUE, "Empty parameter value") + +gen(2, 1206, PAR_ILLPARAM, "Bad parameter '$1' for key '$2'") + +gen(2, 1208, PAR_ILLVALUE, "Bad value $1 for key '$2'") + +gen(2, 1210, PAR_SCOPE_GET, "Can't get parameter '$1' in scope '$2'") + +gen(2, 1212, PAR_SCOPE_SET, "Can't set parameter '$1' in scope '$2'") + +gen(2, 1214, PAR_VERSION, "Parameter '$1' requires PDF $2 or above") + + + + +/* -------------------------------------------------------------------- */ +/* Options and values (14xx) */ +/* -------------------------------------------------------------------- */ + +gen(1, 1400, OPT_UNKNOWNKEY, "Unknown option '$1'") + +gen(2, 1402, OPT_TOOFEWVALUES, "Option '$1' has too few values (< $2)") + +gen(2, 1404, OPT_TOOMANYVALUES, "Option '$1' has too many values (> $2)") + +gen(1, 1406, OPT_NOVALUES, "Option '$1' has no value(s)") + +gen(2, 1408, OPT_ILLBOOLEAN, "Option '$1' has bad boolean value '$2'") + +gen(2, 1410, OPT_ILLINTEGER, "Option '$1' has bad integer value '$2'") + +gen(2, 1412, OPT_ILLNUMBER, "Option '$1' has bad number value '$2'") + +gen(2, 1414, OPT_ILLKEYWORD, "Option '$1' has bad keyword '$2'") + +gen(3, 1416, OPT_TOOSMALLVAL, "Option '$1' has too small value $2 (< $3)") + +gen(3, 1418, OPT_TOOBIGVAL, "Option '$1' has too large value $2 (> $3)") + +gen(2, 1420, OPT_ZEROVAL, "Option '$1' has bad zero value $2") + +gen(3, 1422, OPT_TOOSHORTSTR, "Option '$1' has too short string '$2' (< $3)") + +gen(3, 1424, OPT_TOOLONGSTR, "Option '$1' has too long string '$2' (> $3)") + +gen(2, 1426, OPT_ILLSPACES, + "Option '$1' has bad string value '$2' (contains whitespace)") + +gen(1, 1428, OPT_NOTFOUND, "Required option '$1' is missing") + +gen(1, 1430, OPT_IGNORED, "Option '$1' ignored") + +gen(2, 1432, OPT_VERSION, "Option '$1' is not supported in PDF $2") + +gen(3, 1434, OPT_ILLHANDLE, "Option '$1' has bad $3 handle $2") + +gen(2, 1436, OPT_IGNORE, + "Option '$1' will be ignored (specified option '$2' dominant)") + +gen(1, 1438, OPT_UNSUPP, "Option '$1' not supported in this configuration") + +gen(1, 1440, OPT_NOTBAL, "Braces aren't balanced in option list '$1'") + + +/* -------------------------------------------------------------------- */ +/* String conversion functions (15xx) */ +/* -------------------------------------------------------------------- */ + +gen(0, 1500, CONV_ILLUTF16, "Invalid UTF-16 string (odd byte count)") + +gen(0, 1502, CONV_MEMOVERFLOW, "Out of memory in UTF string conversion") + +gen(1, 1504, CONV_ILLUTF, "Invalid UTF-$1 string") + + +/* -------------------------------------------------------------------- */ +/* Internal (19xx) */ +/* -------------------------------------------------------------------- */ + +gen(1, 1900, INT_NULLARG, "Invalid NULL argument in function $1") + +gen(0, 1902, INT_XSTACK, "Exception stack underflow") + +gen(1, 1904, INT_UNUSEDOBJ, "Object $1 allocated but not used") + +gen(0, 1906, INT_FLOATTOOLARGE, "Floating point value too large") + +gen(2, 1908, INT_BADFORMAT, "Unknown vsprintf() format '$1' ($2)") + +gen(1, 1910, INT_ALLOC0, + "Tried to allocate 0 or negative number of bytes in function $1") + +/* Unused. See 1502 +gen(1, 1912, INT_UNICODEMEM, "Too few bytes allocated in Unicode function $1") + */ + +gen(1, 1914, INT_INVMATRIX, "Matrix [$1] not invertible") + + +#undef gen +#undef pdc_genNames +#undef pdc_genInfo diff --git a/src/libs/pdflib/libs/pdcore/pc_geom.c b/src/libs/pdflib/libs/pdcore/pc_geom.c new file mode 100644 index 0000000000..b3746fd1b5 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_geom.c @@ -0,0 +1,332 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_geom.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Various geometry routines + * + */ + +#include "pc_util.h" +#include "pc_geom.h" + + +/* ---------------------- matrix functions ----------------------------- */ + +pdc_bool +pdc_is_identity_matrix(pdc_matrix *m) +{ + return (m->a == (float) 1 && + m->b == (float) 0 && + m->c == (float) 0 && + m->d == (float) 1 && + m->e == (float) 0 && + m->f == (float) 0); +} + +/* translation matrix */ +void +pdc_translation_matrix(float tx, float ty, pdc_matrix *M) +{ + M->a = (float) 1; + M->b = (float) 0; + M->c = (float) 0; + M->d = (float) 1; + M->e = tx; + M->f = ty; +} + +/* scale matrix */ +void +pdc_scale_matrix(float sx, float sy, pdc_matrix *M) +{ + M->a = sx; + M->b = (float) 0; + M->c = (float) 0; + M->d = sy; + M->e = (float) 0; + M->f = (float) 0; +} + +/* rotation matrix */ +void +pdc_rotation_matrix(float alpha, pdc_matrix *M) +{ + double phi, c, s; + + phi = (alpha * PDC_M_PI) / 180.0; + c = cos(phi); + s = sin(phi); + + M->a = (float) c; + M->b = (float) s; + M->c = (float) -s; + M->d = (float) c; + M->e = (float) 0; + M->f = (float) 0; +} + +/* skew matrix */ +void +pdc_skew_matrix(float alpha, float beta, pdc_matrix *M) +{ + M->a = (float) 1; + M->b = (float) tan(alpha * PDC_M_PI / 180.0); + M->c = (float) tan(beta * PDC_M_PI / 180.0); + M->d = (float) 1; + M->e = (float) 0; + M->f = (float) 0; +} + +/* left-multiply M to N and store the result in N */ +void +pdc_multiply_matrix(const pdc_matrix *M, pdc_matrix *N) +{ + pdc_matrix result; + + result.a = M->a * N->a + M->b * N->c; + result.b = M->a * N->b + M->b * N->d; + result.c = M->c * N->a + M->d * N->c; + result.d = M->c * N->b + M->d * N->d; + + result.e = M->e * N->a + M->f * N->c + N->e; + result.f = M->e * N->b + M->f * N->d + N->f; + + N->a = result.a; + N->b = result.b; + N->c = result.c; + N->d = result.d; + N->e = result.e; + N->f = result.f; +} + +/* invert M and store the result in N */ +void +pdc_invert_matrix(pdc_core *pdc, pdc_matrix *N, pdc_matrix *M) +{ + float det = M->a * M->d - M->b * M->c; + + if (fabs(det) < (float) PDC_SMALLREAL) + pdc_error(pdc, PDC_E_INT_INVMATRIX, + pdc_errprintf(pdc, "%f %f %f %f %f %f", + M->a, M->b, M->c, M->d, M->e, M->f), + 0, 0, 0); + + N->a = M->d/det; + N->b = -M->b/det; + N->c = -M->c/det; + N->d = M->a/det; + N->e = -(M->e * N->a + M->f * N->c); + N->f = -(M->e * N->b + M->f * N->d); +} + +/* transform point */ +void +pdc_transform_point(const pdc_matrix *M, float x, float y, float *tx, float *ty) +{ + *tx = M->a * x + M->c * y + M->e; + *ty = M->b * x + M->d * y + M->f; +} + +/* ---------------------- utility functions ----------------------------- */ + +void +pdc_place_element(pdc_fitmethod method, pdc_scalar minfscale, + const pdc_box *fitbox, const pdc_vector *relpos, + const pdc_vector *elemsize, pdc_box *elembox, + pdc_vector *scale) +{ + pdc_vector refpos; + pdc_scalar width, height, det, fscale = 1.0; + pdc_bool xscaling = pdc_false; + + /* reference position in fitbox */ + width = fitbox->ur.x - fitbox->ll.x; + height = fitbox->ur.y - fitbox->ll.y; + refpos.x = fitbox->ll.x + relpos->x * width; + refpos.y = fitbox->ll.y + relpos->y * height; + + /* first check */ + switch (method) + { + case pdc_entire: + case pdc_slice: + case pdc_meet: + case pdc_tauto: + if (fabs(width) > PDC_FLOAT_PREC && fabs(height) > PDC_FLOAT_PREC) + { + if (method != pdc_entire) + { + det = elemsize->x * height - elemsize->y * width; + xscaling = (method == pdc_slice && det <= 0) || + ((method == pdc_meet || method == pdc_tauto) && + det > 0) ? pdc_true : pdc_false; + if (xscaling) + fscale = width / elemsize->x; + else + fscale = height / elemsize->y; + } + + if (method == pdc_tauto) + { + if(fscale >= 1.0) + { + method = pdc_nofit; + } + else if (fscale < minfscale) + { + method = pdc_meet; + } + } + } + else + { + method = pdc_nofit; + } + break; + + default: + break; + } + + /* calculation */ + switch (method) + { + /* entire box is covered by entire element */ + case pdc_entire: + *elembox = *fitbox; + scale->x = width / elemsize->x; + scale->y = height / elemsize->y; + return; + + /* fit into and preserve aspect ratio */ + case pdc_slice: + case pdc_meet: + if (xscaling) + height = fscale * elemsize->y; + else + width = fscale * elemsize->x; + scale->x = fscale; + scale->y = fscale; + break; + + /* fit into and doesn't preserve aspect ratio */ + case pdc_tauto: + if (xscaling) + { + height = elemsize->y; + scale->x = fscale; + scale->y = 1.0; + } + else + { + width = elemsize->x; + scale->x = 1.0; + scale->y = fscale; + } + break; + + /* only positioning */ + case pdc_nofit: + case pdc_clip: + width = elemsize->x; + height = elemsize->y; + scale->x = 1.0; + scale->y = 1.0; + break; + } + + /* placed element box */ + elembox->ll.x = refpos.x - relpos->x * width; + elembox->ll.y = refpos.y - relpos->y * height; + elembox->ur.x = refpos.x + (1.0 - relpos->x) * width; + elembox->ur.y = refpos.y + (1.0 - relpos->y) * height; +} + +void +pdc_box2polyline(const pdc_box *box, pdc_vector *polyline) +{ + /* counter clockwise */ + polyline[0].x = box->ll.x; + polyline[0].y = box->ll.y; + polyline[1].x = box->ur.x; + polyline[1].y = box->ll.y; + polyline[2].x = box->ur.x; + polyline[2].y = box->ur.y; + polyline[3].x = box->ll.x; + polyline[3].y = box->ur.y; + polyline[4] = polyline[0]; +} + +/* --------------------------- rectangles --------------------------- */ +pdc_bool +pdc_rect_isnull(pdc_rectangle *r) +{ + return + (r->llx == (float) 0 && r->lly == (float) 0 && + r->urx == (float) 0 && r->ury == (float) 0); +} + +pdc_bool +pdc_rect_contains(pdc_rectangle *r1, pdc_rectangle *r2) +{ + return + (r1->llx <= r2->llx && r1->lly <= r2->lly && + r1->urx >= r2->urx && r1->ury >= r2->ury); +} + +void +pdc_rect_copy(pdc_rectangle *r1, pdc_rectangle *r2) +{ + r1->llx = r2->llx; + r1->lly = r2->lly; + r1->urx = r2->urx; + r1->ury = r2->ury; +} + +void +pdc_rect_init(pdc_rectangle *r, float llx, float lly, float urx, float ury) +{ + r->llx = llx; + r->lly = lly; + r->urx = urx; + r->ury = ury; +} + +void +pdc_rect_transform(const pdc_matrix *M, pdc_rectangle *r1, pdc_rectangle *r2) +{ + float x[4], y[4]; + int i; + + pdc_transform_point(M, r1->llx, r1->lly, &x[0], &y[0]); + pdc_transform_point(M, r1->llx, r1->ury, &x[1], &y[1]); + pdc_transform_point(M, r1->urx, r1->ury, &x[2], &y[2]); + pdc_transform_point(M, r1->urx, r1->lly, &x[3], &y[3]); + + pdc_rect_init(r2, (float) PDC_FLOAT_MAX, (float) PDC_FLOAT_MAX, + (float) PDC_FLOAT_MIN, (float) PDC_FLOAT_MIN); + + for (i = 0; i < 4; i++) + { + if (x[i] < r2->llx) + r2->llx = x[i]; + if (y[i] < r2->lly) + r2->lly = y[i]; + + if (x[i] > r2->urx) + r2->urx = x[i]; + if (y[i] > r2->ury) + r2->ury = y[i]; + } +} + diff --git a/src/libs/pdflib/libs/pdcore/pc_geom.h b/src/libs/pdflib/libs/pdcore/pc_geom.h new file mode 100644 index 0000000000..2e52785862 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_geom.h @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_geom.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib core geometry utilities + * + */ + +#ifndef PC_GEOM_H +#define PC_GEOM_H + +/* Unfortunately M_PI causes porting woes, so we use a private name */ +#define PDC_M_PI 3.14159265358979323846 /* pi */ + +/* Conversion factors */ +#define PDC_INCH2METER 0.0254 +#define PDC_METER2INCH 39.3701 + +/* same as PDF_SMALLREAL */ +#define PDC_SMALLREAL (0.000015) + +typedef struct { float llx, lly, urx, ury; } pdc_rectangle; +typedef struct { float a, b, c, d, e, f; } pdc_matrix; + +typedef double pdc_scalar; +typedef struct { pdc_scalar x, y; } pdc_vector; +typedef struct { pdc_vector ll, ur; } pdc_box; + +/* methods for fitting rectangle elements into a box */ +typedef enum +{ + pdc_nofit = 0, /* no fit, only positioning */ + pdc_clip, /* no fit, only positioning with following condition: + * - the parts of element beyond the bounds of box + * are clipped */ + pdc_slice, /* fit into the box with following conditions: + * - aspect ratio of element is preserved + * - entire box is covered by the element + * - the parts of element beyond the bounds of box + * are clipped */ + pdc_meet, /* fit into the box with following conditions: + * - aspect ratio of element is preserved + * - entire element is visible in the box */ + pdc_entire, /* fit into the box with following conditions: + * - entire box is covered by the element + * - entire element is visible in the box */ + pdc_tauto /* automatic fitting. If element extends fit box in + * length, then element is shrinked, if shrink + * factor is greater than a specified value. Otherwise + * pdc_meet is applied. */ +} +pdc_fitmethod; + +pdc_bool pdc_is_identity_matrix(pdc_matrix *m); +void pdc_translation_matrix(float tx, float ty, pdc_matrix *M); +void pdc_scale_matrix(float sx, float sy, pdc_matrix *M); +void pdc_rotation_matrix(float angle, pdc_matrix *M); +void pdc_skew_matrix(float alpha, float beta, pdc_matrix *M); +void pdc_multiply_matrix(const pdc_matrix *M, pdc_matrix *N); +void pdc_invert_matrix(pdc_core *pdc, pdc_matrix *N, pdc_matrix *M); +void pdc_transform_point(const pdc_matrix *M, + float x, float y, float *tx, float *ty); + +void pdc_place_element(pdc_fitmethod method, + pdc_scalar minfscale, const pdc_box *fitbox, + const pdc_vector *relpos, const pdc_vector *elemsize, + pdc_box *elembox, pdc_vector *scale); +void pdc_box2polyline(const pdc_box *box, pdc_vector *polyline); + +pdc_bool pdc_rect_isnull(pdc_rectangle *r); +pdc_bool pdc_rect_contains(pdc_rectangle *r1, pdc_rectangle *r2); +void pdc_rect_copy(pdc_rectangle *r1, pdc_rectangle *r2); +void pdc_rect_init(pdc_rectangle *r, + float llx, float lly, float urx, float ury); +void pdc_rect_transform(const pdc_matrix *M, + pdc_rectangle *r1, pdc_rectangle *r2); + +#endif /* PC_GEOM_H */ + diff --git a/src/libs/pdflib/libs/pdcore/pc_md5.c b/src/libs/pdflib/libs/pdcore/pc_md5.c new file mode 100644 index 0000000000..6fd07bb599 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_md5.c @@ -0,0 +1,307 @@ +/* $Id: pc_md5.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib MD5 message digest routines + * + */ + +/* This is a slightly modified version of the RSA reference + * implementation for MD5, which originally contained + * the following copyright notice: + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. +*/ + +#include + +#include "pc_util.h" +#include "pc_md5.h" + +/* Constants for MD5_Transform routine. + */ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +static unsigned char PADDING[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G, H and I are basic MD5 functions. + */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* ROTATE_LEFT rotates x left n bits. + */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. + * Rotation is separate from addition to prevent recomputation. + */ +#define FF(a, b, c, d, x, s, ac) { \ + (a) += F ((b), (c), (d)) + (x) + (MD5_UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ +} +#define GG(a, b, c, d, x, s, ac) { \ + (a) += G ((b), (c), (d)) + (x) + (MD5_UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ +} +#define HH(a, b, c, d, x, s, ac) { \ + (a) += H ((b), (c), (d)) + (x) + (MD5_UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ +} +#define II(a, b, c, d, x, s, ac) { \ + (a) += I ((b), (c), (d)) + (x) + (MD5_UINT4)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ +} + + +/* Encodes input (MD5_UINT4) into output (unsigned char). Assumes len is + * a multiple of 4. + */ +static void Encode(unsigned char *output, MD5_UINT4 *input, unsigned int len) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j] = (unsigned char) (input[i] & 0xff); + output[j+1] = (unsigned char) ((input[i] >> 8) & 0xff); + output[j+2] = (unsigned char) ((input[i] >> 16) & 0xff); + output[j+3] = (unsigned char) ((input[i] >> 24) & 0xff); + } +} + +/* Decodes input (unsigned char) into output (MD5_UINT4). Assumes len is + * a multiple of 4. + */ +static void Decode( + MD5_UINT4 *output, + const unsigned char *input, + unsigned int len) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((MD5_UINT4) input[j]) | + (((MD5_UINT4) input[j+1]) << 8) | + (((MD5_UINT4) input[j+2]) << 16) | + (((MD5_UINT4) input[j+3]) << 24); +} + +/* MD5 basic transformation. Transforms state based on block. + */ +static void MD5_Transform(MD5_UINT4 state[4], const unsigned char block[64]) +{ + MD5_UINT4 a = state[0]; + MD5_UINT4 b = state[1]; + MD5_UINT4 c = state[2]; + MD5_UINT4 d = state[3]; + MD5_UINT4 x[16]; + + Decode(x, block, 64); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ + FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ + FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ + FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ + FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ + FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ + GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ + GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ + GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ + GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ + GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ + HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ + HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ + HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ + II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ + II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ + II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ + II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ + II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + /* Zeroize sensitive information. + */ + memset (x, 0, sizeof (x)); +} + +/* MD5 initialization. Begins an MD5 operation, writing a new context. + */ +void MD5_Init(MD5_CTX *context) +{ + context->count[0] = context->count[1] = 0; + + /* Load magic initialization constants. + */ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; +} + +/* MD5 block update operation. Continues an MD5 message-digest + * operation, processing another message block, and updating the + * context. + */ +void MD5_Update( + MD5_CTX *context, + const unsigned char *input, + unsigned int inputLen) +{ + unsigned int i, idx, partLen; + + /* Compute number of bytes mod 64 */ + idx = (unsigned int) ((context->count[0] >> 3) & 0x3F); + + /* Update number of bits */ + if ((context->count[0] += ((MD5_UINT4) inputLen << 3)) + < ((MD5_UINT4) inputLen << 3)) + context->count[1]++; + + context->count[1] += ((MD5_UINT4) inputLen >> 29); + + partLen = 64 - idx; + + /* Transform as many times as possible. + */ + if (inputLen >= partLen) { + memcpy(&context->buffer[idx], input, partLen); + MD5_Transform(context->state, context->buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) + MD5_Transform (context->state, &input[i]); + + idx = 0; + } + else + i = 0; + + /* Buffer remaining input */ + memcpy(&context->buffer[idx], &input[i], inputLen - i); +} + +/* MD5 finalization. Ends an MD5 message-digest operation, writing the + * the message digest and zeroizing the context. + */ +void MD5_Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *context) +{ + unsigned char bits[8]; + unsigned int idx, padLen; + + /* Save number of bits */ + Encode(bits, context->count, 8); + + /* Pad out to 56 mod 64. + */ + idx = (unsigned int) ((context->count[0] >> 3) & 0x3f); + padLen = (idx < 56) ? (56 - idx) : (120 - idx); + MD5_Update(context, PADDING, padLen); + + /* Append length (before padding) */ + MD5_Update(context, bits, 8); + + /* Store state in digest */ + Encode(digest, context->state, 16); + + /* Zeroize sensitive information. + */ + memset(context, 0, sizeof (*context)); +} diff --git a/src/libs/pdflib/libs/pdcore/pc_md5.h b/src/libs/pdflib/libs/pdcore/pc_md5.h new file mode 100644 index 0000000000..b868354eca --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_md5.h @@ -0,0 +1,57 @@ +/* $Id: pc_md5.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Header file for the PDFlib MD5 message digest routines + * + */ + +/* This is a slightly modified version of the RSA reference + * implementation for MD5, which originally contained + * the following copyright notice: + */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All + rights reserved. + + License to copy and use this software is granted provided that it + is identified as the "RSA Data Security, Inc. MD5 Message-Digest + Algorithm" in all material mentioning or referencing this software + or this function. + + License is also granted to make and use derivative works provided + that such works are identified as "derived from the RSA Data + Security, Inc. MD5 Message-Digest Algorithm" in all material + mentioning or referencing the derived work. + + RSA Data Security, Inc. makes no representations concerning either + the merchantability of this software or the suitability of this + software for any particular purpose. It is provided "as is" + without express or implied warranty of any kind. + + These notices must be retained in any copies of any part of this + documentation and/or software. + */ + + +/* we prefix our MD5 function names with "pdc_", so you can + * link your program with another MD5 lib without troubles. + */ +#define MD5_Init pdc_MD5_Init +#define MD5_Update pdc_MD5_Update +#define MD5_Final pdc_MD5_Final + +typedef unsigned int MD5_UINT4; + +#define MD5_DIGEST_LENGTH 16 + + +/* MD5 context. */ +typedef struct { + MD5_UINT4 state[4]; /* state (ABCD) */ + MD5_UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD5_CTX; + +void MD5_Init(MD5_CTX *context); +void MD5_Update( + MD5_CTX *context, const unsigned char *input, unsigned int inputLen); +void MD5_Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5_CTX *context); diff --git a/src/libs/pdflib/libs/pdcore/pc_nocarbon.h b/src/libs/pdflib/libs/pdcore/pc_nocarbon.h new file mode 100644 index 0000000000..0da4c5ce5f --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_nocarbon.h @@ -0,0 +1,24 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_nocarbon.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Header for CodeWarrior to activate non-Carbon builds. + * + */ + +/* + * This must only be set for non-Carbon builds. It is not used for the + * standard build. + */ + +#define PDF_TARGET_API_MAC_OS8 diff --git a/src/libs/pdflib/libs/pdcore/pc_optparse.c b/src/libs/pdflib/libs/pdcore/pc_optparse.c new file mode 100644 index 0000000000..8e8c1b0495 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_optparse.c @@ -0,0 +1,789 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_optparse.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Parser options routines + * + */ + +#include "pc_util.h" +#include "pc_optparse.h" + +#define PDC_OPT_LISTSEPS "\f\n\r\t\v =" + +/* result of an option */ +struct pdc_resopt_s +{ + int numdef; /* number of definitions */ + const pdc_defopt *defopt; /* pointer to option definition */ + int num; /* number of parsed values */ + void *val; /* list of parsed values */ +}; + +/* sizes of option types. must be parallel to pdc_opttype */ +static const size_t pdc_typesizes[] = +{ + sizeof (pdc_bool), + sizeof (char *), + sizeof (int), + sizeof (int), + sizeof (float), + sizeof (double), + sizeof (int), + sizeof (int), + sizeof (int), + sizeof (int), + sizeof (int), + sizeof (int), + sizeof (int), + sizeof (int), + sizeof (int), +}; + +static const pdc_keyconn pdc_handletypes[] = +{ + {"color", pdc_colorhandle}, + {"document", pdc_documenthandle}, + {"font", pdc_fonthandle}, + {"gstate", pdc_gstatehandle}, + {"iccprofile", pdc_iccprofilehandle}, + {"image", pdc_imagehandle}, + {"page", pdc_pagehandle}, + {"pattern", pdc_patternhandle}, + {"shading", pdc_shadinghandle}, +}; + +int +pdc_get_keycode(const char *keyword, const pdc_keyconn *keyconn) +{ + int i; + for (i = 0; keyconn[i].word != 0; i++) + { + if (!strcmp(keyword, keyconn[i].word)) + return keyconn[i].code; + } + return PDC_KEY_NOTFOUND; +} + +int +pdc_get_keycode_ci(const char *keyword, const pdc_keyconn *keyconn) +{ + int i; + for (i = 0; keyconn[i].word != 0; i++) + { + if (!pdc_stricmp(keyword, keyconn[i].word)) + return keyconn[i].code; + } + return PDC_KEY_NOTFOUND; +} + +const char * +pdc_get_keyword(int keycode, const pdc_keyconn *keyconn) +{ + int i; + for (i = 0; keyconn[i].word != 0; i++) + { + if (keycode == keyconn[i].code) + return keyconn[i].word; + } + return NULL; +} + +const char * +pdc_get_int_keyword(char *keyword, const pdc_keyconn *keyconn) +{ + int i; + for (i = 0; keyconn[i].word != 0; i++) + { + if (!pdc_stricmp(keyword, keyconn[i].word)) + return keyconn[i].word; + } + return NULL; +} + +void +pdc_cleanup_optstringlist(pdc_core *pdc, char **stringlist, int ns) +{ + int j; + + for (j = 0; j < ns; j++) + { + if (stringlist[j]) + pdc_free(pdc, stringlist[j]); + } + pdc_free(pdc, stringlist); +} + +static void +pdc_delete_optvalue(pdc_core *pdc, pdc_resopt *resopt) +{ + if (resopt->val) + { + if (resopt->defopt->type == pdc_stringlist) + { + int j; + char **s = (char **) resopt->val; + for (j = 0; j < resopt->num; j++) + if (s[j]) + pdc_free(pdc, s[j]); + } + pdc_free(pdc, resopt->val); + resopt->val = NULL; + } + resopt->num = 0; +} + +static int +pdc_optname_compare(const void *a, const void *b) +{ + return (strcmp(((pdc_resopt *)a)->defopt->name, + ((pdc_resopt *)b)->defopt->name)); +} + +pdc_resopt * +pdc_parse_optionlist(pdc_core *pdc, const char *optlist, + const pdc_defopt *defopt, + const pdc_clientdata *clientdata, pdc_bool verbose) +{ + static const char *fn = "pdc_parse_optionlist"; + const char *stemp1 = NULL, *stemp2 = NULL, *stemp3 = NULL; + char **items = NULL, *keyword = NULL; + char **values = NULL, *value = NULL, **strings = NULL; + int i, nd, is, iss, it, iv, numdef, nitems = 0, nvalues, errcode = 0; + void *resval; + double dz, maxval; + int iz; + size_t len; + const pdc_defopt *dopt = NULL; + pdc_resopt *resopt = NULL; + pdc_bool ignore = pdc_false; + pdc_bool boolval = pdc_false; + pdc_bool tocheck = pdc_false; + pdc_bool issorted = pdc_true; + pdc_bool ishandle = pdc_true; + pdc_bool hastobepos; + + /* decrement handles */ + hastobepos = clientdata && clientdata->hastobepos ? pdc_true : pdc_false; + + /* split option list */ + if (optlist) + nitems = pdc_split_stringlist(pdc, optlist, PDC_OPT_LISTSEPS, &items); + if (nitems < 0) + { + keyword = (char *) optlist; + errcode = PDC_E_OPT_NOTBAL; + goto PDC_OPT_SYNTAXERROR; + } + + /* initialize result list */ + for (numdef = 0; defopt[numdef].name != NULL; numdef++) { + /* */ ; + } + resopt = (pdc_resopt *) pdc_calloc(pdc, numdef * sizeof(pdc_resopt), fn); + for (i = 0; i < numdef; i++) + { + resopt[i].numdef = numdef; + resopt[i].defopt = &defopt[i]; + + if (defopt[i].flags & PDC_OPT_IGNOREIF1 || + defopt[i].flags & PDC_OPT_IGNOREIF2 || + defopt[i].flags & PDC_OPT_REQUIRIF1 || + defopt[i].flags & PDC_OPT_REQUIRIF2 || + defopt[i].flags & PDC_OPT_REQUIRED) + tocheck = pdc_true; + + if (i && issorted) + issorted = (strcmp(defopt[i-1].name, defopt[i].name) <= 0) ? + pdc_true : pdc_false; + } + + /* loop over all option list elements */ + for (is = 0; is < nitems; is++) + { + /* search keyword */ + boolval = pdc_undef; + keyword = items[is]; + for (it = 0; it < numdef; it++) + { + /* special handling for booleans */ + if (defopt[it].type == pdc_booleanlist) + { + if (!strcmp(keyword, defopt[it].name) || + (keyword[1] != 0 && !strcmp(&keyword[2], defopt[it].name))) + { + iss = is + 1; + if (iss == nitems || + (strcmp(items[iss], "true") && + strcmp(items[iss], "false"))) + { + if (!strncmp(keyword, "no", 2)) + { + boolval = pdc_false; + break; + } + else + { + boolval = pdc_true; + break; + } + } + } + } + + if (!strcmp(keyword, defopt[it].name)) break; + } + if (it == numdef) + { + errcode = PDC_E_OPT_UNKNOWNKEY; + goto PDC_OPT_SYNTAXERROR; + } + + /* initialize */ + dopt = &defopt[it]; + ignore = pdc_false; + nvalues = 1; + values = NULL; + ishandle = pdc_true; + + /* compatibility */ + if (clientdata && clientdata->compatibility) + { + int compatibility = clientdata->compatibility; + + for (iv = PDC_1_3; iv < PDC_X_X_LAST; iv++) + { + if ((dopt->flags & (1L<flags & PDC_OPT_UNSUPP) + { + ignore = pdc_true; + if (verbose) + pdc_warning(pdc, PDC_E_OPT_UNSUPP, dopt->name, 0, 0, 0); + } + + /* parse values */ + if (boolval == pdc_undef) + { + is++; + if (is == nitems) + { + errcode = PDC_E_OPT_NOVALUES; + goto PDC_OPT_SYNTAXERROR; + } + if (!ignore && + (dopt->type != pdc_stringlist || dopt->maxnum > 1)) + nvalues = pdc_split_stringlist(pdc, items[is], NULL, &values); + } + + /* ignore */ + if (ignore) continue; + + /* number of values check */ + if (nvalues < dopt->minnum) + { + stemp2 = pdc_errprintf(pdc, "%d", dopt->minnum); + errcode = PDC_E_OPT_TOOFEWVALUES; + goto PDC_OPT_SYNTAXERROR; + } + else if (nvalues > dopt->maxnum) + { + stemp2 = pdc_errprintf(pdc, "%d", dopt->maxnum); + errcode = PDC_E_OPT_TOOMANYVALUES; + goto PDC_OPT_SYNTAXERROR; + } + + /* option already exists */ + if (resopt[it].num) + { + pdc_delete_optvalue(pdc, &resopt[it]); + } + + /* no values */ + if (!nvalues ) continue; + + /* maximal value */ + switch (dopt->type) + { + case pdc_colorhandle: + maxval = clientdata->maxcolor; + break; + + case pdc_documenthandle: + maxval = clientdata->maxdocument; + break; + + case pdc_fonthandle: + maxval = clientdata->maxfont; + break; + + case pdc_iccprofilehandle: + maxval = clientdata->maxiccprofile; + break; + + case pdc_imagehandle: + maxval = clientdata->maximage; + break; + + case pdc_pagehandle: + maxval = clientdata->maxpage; + break; + + case pdc_patternhandle: + maxval = clientdata->maxpattern; + break; + + case pdc_shadinghandle: + maxval = clientdata->maxshading; + break; + + case pdc_gstatehandle: + maxval = clientdata->maxgstate; + break; + + default: + maxval = dopt->maxval; + ishandle = pdc_false; + break; + } + + /* allocate value array */ + resopt[it].val = pdc_calloc(pdc, + (size_t) (nvalues * pdc_typesizes[dopt->type]), fn); + resopt[it].num = nvalues; + + /* analyze type */ + resval = resopt[it].val; + for (iv = 0; iv < nvalues; iv++) + { + errcode = 0; + if (dopt->maxnum > 1 && nvalues) + value = values[iv]; + else + value = items[is]; + switch (dopt->type) + { + /* boolean list */ + case pdc_booleanlist: + if (boolval == pdc_true || !strcmp(value, "true")) + { + *(pdc_bool *) resval = pdc_true; + } + else if (boolval == pdc_false || !strcmp(value, "false")) + { + *(pdc_bool *) resval = pdc_false; + } + else + { + errcode = PDC_E_OPT_ILLBOOLEAN; + } + break; + + /* string list */ + case pdc_stringlist: + if (dopt->flags & PDC_OPT_NOSPACES) + { + if (pdc_split_stringlist(pdc, value, NULL, &strings) > 1) + errcode = PDC_E_OPT_ILLSPACES; + pdc_cleanup_stringlist(pdc, strings); + } + if (!errcode) + { + len = strlen(value); + dz = (double) len; + if (dz < dopt->minval) + { + stemp3 = pdc_errprintf(pdc, "%d", (int) dopt->minval); + errcode = PDC_E_OPT_TOOSHORTSTR; + } + else if (dz > maxval) + { + stemp3 = pdc_errprintf(pdc, "%d", (int) maxval); + errcode = PDC_E_OPT_TOOLONGSTR; + } + *((char **) resval) = pdc_strdup(pdc, value); + } + break; + + /* keyword list */ + case pdc_keywordlist: + iz = pdc_get_keycode(value, dopt->keylist); + if (iz == PDC_KEY_NOTFOUND) + { + errcode = PDC_E_OPT_ILLKEYWORD; + } + else + { + *(int *) resval = iz; + } + break; + + /* number list */ + case pdc_integerlist: + case pdc_floatlist: + case pdc_doublelist: + if (dopt->keylist) + { + /* optional keyword and/or allowed integer list */ + iz = pdc_get_keycode(value, dopt->keylist); + if (iz == PDC_KEY_NOTFOUND) + { + if (dopt->flags & PDC_OPT_INTLIST) + { + errcode = PDC_E_OPT_ILLINTEGER; + break; + } + } + else + { + switch (dopt->type) + { + default: + case pdc_integerlist: + *(int *) resval = iz; + break; + + case pdc_floatlist: + *(float *) resval = (float) iz; + break; + + case pdc_doublelist: + *(double *) resval = (double) iz; + break; + } + break; + } + } + case pdc_colorhandle: + case pdc_documenthandle: + case pdc_fonthandle: + case pdc_iccprofilehandle: + case pdc_imagehandle: + case pdc_pagehandle: + case pdc_patternhandle: + case pdc_shadinghandle: + case pdc_gstatehandle: + if (pdc_str2double(value, &dz) == pdc_false) + { + errcode = PDC_E_OPT_ILLNUMBER; + } + else + { + if (ishandle && hastobepos) dz -= 1; + if (dz < dopt->minval) + { + if (ishandle) + { + stemp3 = pdc_get_keyword(dopt->type, + pdc_handletypes); + errcode = PDC_E_OPT_ILLHANDLE; + } + else + { + stemp3 = pdc_errprintf(pdc, "%g", dopt->minval); + errcode = PDC_E_OPT_TOOSMALLVAL; + } + } + else if (dz > maxval) + { + if (ishandle) + { + stemp3 = pdc_get_keyword(dopt->type, + pdc_handletypes); + errcode = PDC_E_OPT_ILLHANDLE; + } + else + { + stemp3 = pdc_errprintf(pdc, "%g", maxval); + errcode = PDC_E_OPT_TOOBIGVAL; + } + } + else if (dopt->flags & PDC_OPT_NOZERO && + fabs(dz) < PDC_FLOAT_PREC) + { + errcode = PDC_E_OPT_ZEROVAL; + } + else if (dopt->type == pdc_doublelist) + { + *(double *) resval = dz; + } + else if (dopt->type == pdc_floatlist) + { + *(float *) resval = (float) dz; + } + else + { + iz = (int) dz; + if ((double) iz != dz) + { + errcode = PDC_E_OPT_ILLINTEGER; + } + else + { + *(int *) resval = iz; + } + } + } + break; + } + + if (errcode) + { + stemp2 = pdc_errprintf(pdc, "%s", value); + goto PDC_OPT_SYNTAXERROR; + } + + /* increment value pointer */ + resval = (void *) ((char *)(resval) + pdc_typesizes[dopt->type]); + } + pdc_cleanup_stringlist(pdc, values); + values = NULL; + + /* build OR bit pattern */ + if (dopt->flags & PDC_OPT_BUILDOR && nvalues > 1) + { + int *bcode = (int *) resopt[it].val; + for (iv = 1; iv < nvalues; iv++) + { + bcode[0] |= bcode[iv]; + } + resopt[it].num = 1; + } + } + pdc_cleanup_stringlist(pdc, items); + items = NULL; + + /* required and to be ignored options */ + for (is = 0; tocheck && is < numdef; is++) + { + /* to be ignored option */ + if (resopt[is].num) + { + nd = 0; + if (defopt[is].flags & PDC_OPT_IGNOREIF1) nd = 1; + if (defopt[is].flags & PDC_OPT_IGNOREIF2) nd = 2; + for (it = is - 1; it >= is - nd && it >= 0; it--) + { + if (resopt[it].num) + { + pdc_delete_optvalue(pdc, &resopt[is]); + if (verbose) + pdc_warning(pdc, PDC_E_OPT_IGNORE, defopt[is].name, + defopt[it].name, 0, 0); + } + } + } + + /* required option */ + if (!resopt[is].num && + ((defopt[is].flags & PDC_OPT_REQUIRED) || + (defopt[is].flags & PDC_OPT_REQUIRIF1 && resopt[is-1].num) || + (defopt[is].flags & PDC_OPT_REQUIRIF2 && + (resopt[is-1].num || resopt[is-2].num)))) + { + keyword = (char *) defopt[is].name; + errcode = PDC_E_OPT_NOTFOUND; + goto PDC_OPT_SYNTAXERROR; + } + } + + /* is no sorted */ + if (!issorted) + { + qsort((void *)resopt, (size_t) numdef, sizeof(pdc_resopt), + pdc_optname_compare); + } + +#undef PDC_OPTPARSE +#ifdef PDC_OPTPARSE + printf("\n"); + for (is = 0; is < numdef; is++) + { + printf("[%02d] %s (number = %d, pointer = %p):\n", is, + resopt[is].defopt->name, resopt[is].num, resopt[is].val); + for (iv = 0; iv < resopt[is].num; iv++) + { + switch (resopt[is].defopt->type) + { + case pdc_booleanlist: + case pdc_keywordlist: + case pdc_integerlist: + case pdc_colorhandle: + case pdc_documenthandle: + case pdc_fonthandle: + case pdc_gstatehandle: + case pdc_iccprofilehandle: + case pdc_imagehandle: + case pdc_pagehandle: + case pdc_patternhandle: + case pdc_shadinghandle: + printf(" [%d]: %d\n",iv, *((int *) resopt[is].val + iv)); + break; + + case pdc_stringlist: + printf(" [%d]: %s\n",iv, *((char **) resopt[is].val + iv)); + break; + + case pdc_floatlist: + printf(" [%d]: %f\n",iv, *((float *) resopt[is].val + iv)); + break; + + case pdc_doublelist: + printf(" [%d]: %f\n",iv, *((double *) resopt[is].val + iv)); + break; + } + } + } + printf("\n"); +#endif + + return resopt; + + PDC_OPT_SYNTAXERROR: + stemp1 = pdc_errprintf(pdc, "%s", keyword); + pdc_cleanup_stringlist(pdc, items); + pdc_cleanup_stringlist(pdc, values); + pdc_cleanup_optionlist(pdc, resopt); + + switch (errcode) + { + case PDC_E_OPT_UNKNOWNKEY: + case PDC_E_OPT_NOVALUES: + case PDC_E_OPT_NOTFOUND: + case PDC_E_OPT_NOTBAL: + pdc_set_errmsg(pdc, errcode, stemp1, 0, 0, 0); + break; + + case PDC_E_OPT_TOOFEWVALUES: + case PDC_E_OPT_TOOMANYVALUES: + case PDC_E_OPT_ILLBOOLEAN: + case PDC_E_OPT_ILLKEYWORD: + case PDC_E_OPT_ILLINTEGER: + case PDC_E_OPT_ILLNUMBER: + case PDC_E_OPT_ZEROVAL: + case PDC_E_OPT_ILLSPACES: + case PDC_E_OPT_VERSION: + pdc_set_errmsg(pdc, errcode, stemp1, stemp2, 0, 0); + break; + + case PDC_E_OPT_TOOSHORTSTR: + case PDC_E_OPT_TOOLONGSTR: + case PDC_E_OPT_TOOSMALLVAL: + case PDC_E_OPT_TOOBIGVAL: + case PDC_E_OPT_ILLHANDLE: + pdc_set_errmsg(pdc, errcode, stemp1, stemp2, stemp3, 0); + break; + } + + if (verbose) + pdc_error(pdc, -1, 0, 0, 0, 0); + + return NULL; +} + +int +pdc_get_optvalues(pdc_core *pdc, const char *keyword, pdc_resopt *resopt, + void *lvalues, void **mvalues) +{ + pdc_resopt *ropt = NULL; + void *values = NULL; + int nvalues = 0; + size_t nbytes; + if (mvalues) *mvalues = NULL; + + (void) pdc; + + if (resopt) + { + int i, cmp; + int lo = 0; + int hi = resopt[0].numdef; + + while (lo < hi) + { + i = (lo + hi) / 2; + cmp = strcmp(keyword, resopt[i].defopt->name); + + /* keyword found */ + if (cmp == 0) + { + ropt = &resopt[i]; + nvalues = ropt->num; + values = ropt->val; + break; + } + + if (cmp < 0) + hi = i; + else + lo = i + 1; + } + } + + if (nvalues) + { + /* copy values */ + if (lvalues) + { + if (ropt->defopt->type == pdc_stringlist && + ropt->defopt->maxnum == 1) + { + strcpy((char *)lvalues, *((char **) values)); + } + else + { + nbytes = (size_t) (nvalues * pdc_typesizes[ropt->defopt->type]); + memcpy(lvalues, values, nbytes); + } + } + + /* copy pointer */ + if (mvalues) + { + *mvalues = values; + ropt->val = NULL; + } + } + + return nvalues; +} + +void +pdc_cleanup_optionlist(pdc_core *pdc, pdc_resopt *resopt) +{ + if (resopt) + { + int i; + + for (i = 0; i < resopt[0].numdef; i++) + pdc_delete_optvalue(pdc, &resopt[i]); + + pdc_free(pdc, resopt); + } +} + +const char * +pdc_get_handletype(pdc_opttype type) +{ + return pdc_get_keyword(type, pdc_handletypes); +} + diff --git a/src/libs/pdflib/libs/pdcore/pc_optparse.h b/src/libs/pdflib/libs/pdcore/pc_optparse.h new file mode 100644 index 0000000000..0a6a0f0563 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_optparse.h @@ -0,0 +1,224 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_optparse.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Definitions for option parser routines + * + */ + +#ifndef PC_OPTPARSE_H +#define PC_OPTPARSE_H + +/* + * Optlist + * ------- + * An optlist is a string containing pairs of the form + * "optionname optionvalue(s)". The separator characters + * are "\f\n\r\t\v =". + * + * There are options of different types (see pdc_opttype): + * + * Boolean (pdc_booleanlist) + * Strings (pdc_stringlist) + * Keywords (pdc_keywordlist) + * Integers (pdc_integerlist) + * Floats (pdc_floatlist) + * Doubles (pdc_doublelist) + * Handles (pdc_colorhandle ...) + * + * An option can have one or more values. Boolean options can be + * provided without any value. If an option has more than one value, + * then these values have to be set in braces. Examples: + * + * dasharray {11 22 33} + * + * Strings with white spaces have to be set in braces too. + * Examples: + * + * fullname {Ludwig Wittgenstein} + * composers {{Gustav Mahler}} + * comment {} + * + * The allowed option names and the limitations of their values + * must be defined in an array of enumeration type pdc_defopt + * (see below). Such an option definition specifies (in brackets + * the member name in the pdc_defopt struct) + * + * - the name of the option (name) + * - the type of the option (type) + * - value restrictions by bit flags (flags) + * - the minimal and maximal permitted number of values + * (minnum, maxnum) + * - the minimal and maximal permitted value, or string + * length resp. (minval, maxval) + * - the permitted keywords in a keyword list (is required) or + * the permitted integer numbers in a integer list (is optional), + * resp. (keylist) + * - the number of default values and the default values + * themselves (defnum, defval) + * + * Remarks: + * + * - minnum = maxnum = 1: The program expects a single value, + * otherwise an array. If an array consists of only one value + * the braces can be omitted - but not in the case of strings + * with white spaces (see example above). + * - Boolean options have the values "true" or "false". A shorter + * equivalent notation is "+name" or "-name". for "name true" + * or "name false", resp. + * - White spaces in strings can be forbidden by the flag + * PDC_OPT_NOSPACES. + * - It's only possible to specify a single number interval (minval, + * maxval) which must contain the number. The flag PDC_OPT_NOZERO + * can forbid zero additionally. + * - Keywords will always be converted to integer numbers (keycodes) + * according to the specified pdc_keyconn array. + * - It is possible to specify keywords for integers, floats and + * doubles additionally by an optional keylist entry. For integers + * it is possible to specify the allowed integer values by an optional + * keylist and by the flag PDC_OPT_INTLIST. + * - If more than one keyword is permitted, then the flag + * PDC_OPT_BUILDOR decides, whether a bit pattern must be + * built by or-ing the single keycodes or not. + * + * Program run: + * + * An optlist will be parsed by the function pdc_parse_optionlist. + * After successfully parsing this function returns a pointer to the + * allocated pdc_resopt structures containing the option values. + * These structures must be freed by the function pdc_cleanup_optionlist. + * + * Values must be fetched by the function pdc_get_optvalues. This can + * be achieved by specifying a variable pointer (lvalues) or by a pointer + * to a pointer (mvalues). In the first case the variable must be large + * enough to hold the values. In the second case the pointer is the pointer + * to the allocated array with the option values. If such a pointer is + * specified in a call of pdc_get_optvalues the pointer will not be freed + * in pdc_cleanup_optionlist, but the caller has the responsibility to + * free it after use. + * + * pdc_stringlist: + * maxnum = 1: lvalues: char s[maxval+1] (defined char array) + * maxnum > 1: lvalues: char *s[maxnum] (defined char pointer rarray) + * mvalues: char **s (pointer to a char pointer array) + * + */ + +typedef struct pdc_keyconn_s pdc_keyconn; +typedef struct pdc_clientdata_s pdc_clientdata; +typedef struct pdc_defopt_s pdc_defopt; +typedef struct pdc_resopt_s pdc_resopt; + +/* types of option values */ +typedef enum +{ + pdc_booleanlist = 0, + pdc_stringlist, + pdc_keywordlist, + pdc_integerlist, + pdc_floatlist, + pdc_doublelist, + + /* correspondig member of pdc_clientdata_s must be specified */ + pdc_colorhandle, + pdc_documenthandle, + pdc_fonthandle, + pdc_gstatehandle, + pdc_iccprofilehandle, + pdc_imagehandle, + pdc_pagehandle, + pdc_patternhandle, + pdc_shadinghandle +} +pdc_opttype; + +/* keyword - keycode */ +struct pdc_keyconn_s +{ + char *word; + int code; +}; + +/* client data */ +struct pdc_clientdata_s +{ + int compatibility; + int maxcolor; + int maxdocument; + int maxfont; + int maxgstate; + int maxiccprofile; + int maximage; + int maxpage; + int maxpattern; + int maxshading; + pdc_bool hastobepos; +}; + +/* definition of an option */ +struct pdc_defopt_s +{ + const char *name; /* name of option keyword */ + pdc_opttype type; /* type of option */ + int flags; /* flags (see below) */ + int minnum; /* permitted minimal number of values */ + int maxnum; /* permitted maximal number of values */ + double minval; /* minimal permitted value / length of string */ + double maxval; /* maximal permitted value / length of string */ + const pdc_keyconn *keylist; /* list of permitted keywords - keycodes */ +}; + +#define PDC_OPT_TERMINATE \ + {NULL, pdc_booleanlist, 0L, 0, 0, 0.0, 0.0, NULL} + +#define PDC_OPT_NONE (0) /* no flag specified */ +#define PDC_OPT_NOZERO (1L<<0) /* zero value not allowed */ +#define PDC_OPT_NOSPACES (1L<<1) /* white spaces in strings not allowed */ +#define PDC_OPT_REQUIRED (1L<<2) /* option is required */ +#define PDC_OPT_BUILDOR (1L<<3) /* build an OR bit pattern by keycodes */ +#define PDC_OPT_INTLIST (1L<<4) /* keylist is list of allowed integers */ +#define PDC_OPT_IGNOREIF1 (1L<<5) /* option is ignored if previous option is + * specified */ +#define PDC_OPT_IGNOREIF2 (1L<<6) /* option is ignored if either of + * previous two options is specified */ +#define PDC_OPT_UNSUPP (1L<<8) /* option is not supported in this + * configuration */ +#define PDC_OPT_REQUIRIF1 (1L<<9) /* option is require if previous option is + * specified */ +#define PDC_OPT_REQUIRIF2 (1L<<10) /* option is require if either of + * previous two options is specified */ + +/* member "compatibility" of pdc_clientdata_s must be specified (1L<<12) ... */ +#define PDC_OPT_PDC_1_3 (1L< +#include +#endif + +#if defined(MAC) || defined (MACOSX) + +/* + * Setting the file type requires either Carbon or InterfaceLib/Classic. + * If we have neither (i.e. a Mach-O build without Carbon) we suppress + * the code for setting the file type and creator. + */ + +#if !defined(MACOSX) || defined(PDF_TARGET_API_MAC_CARBON) +#define PDF_FILETYPE_SUPPORTED +#endif + +#ifdef PDF_FILETYPE_SUPPORTED +#include +#endif + +#endif /* defined(MAC) || defined (MACOSX) */ + +#ifdef HAVE_LIBZ +#include "zlib.h" +#endif + +#ifdef HAVE_LIBZ +#define PDF_DEFAULT_COMPRESSION 6 /* default zlib level */ +#else +#define PDF_DEFAULT_COMPRESSION 0 /* no compression */ +#endif + +#define STREAM_CHUNKSIZE 65536 /* output buffer for in-core */ +#define ID_CHUNKSIZE 2048 /* object ids */ + +#define PDF_LINEBUFLEN 256 /* len of pdc_printf() buffer */ + +/* generic output stuff */ + +typedef struct pdc_stream_s { + pdc_byte *basepos; /* start of this chunk */ + pdc_byte *curpos; /* next write position */ + pdc_byte *maxpos; /* maximum position of chunk */ + size_t base_offset; /* base offset of this chunk */ + pdc_bool compressing; /* in compression state */ +#ifdef HAVE_LIBZ + z_stream z; /* zlib compression stream */ +#endif + + pdc_bool mustclose; /* must close output file at end */ + FILE *fp; /* output file stream */ + /* client-supplied data sink procedure */ + size_t (*writeproc)(pdc_output *out, void *data, size_t size); +} pdc_stream; + +/* PDF-related output stuff */ + +struct pdc_output_s { + pdc_core *pdc; /* core context */ + pdc_stream stream; /* output stream buffer */ + int compresslevel; /* zlib compression level */ + pdc_bool compr_changed; /* compress level has been changed */ + long length; /* length of stream */ + + long *file_offset; /* the objects' file offsets */ + int file_offset_capacity; + pdc_id lastobj; /* highest object id */ + + long start_pos; /* stream start position */ + + MD5_CTX md5; /* MD5 digest context for file ID */ + unsigned char id[2][MD5_DIGEST_LENGTH]; + void *opaque; /* this will be used to store PDF *p */ +}; + +/* --------------------- PDFlib stream handling ----------------------- */ + +void * +pdc_get_opaque(pdc_output *out) +{ + return out->opaque; +} + +#ifdef HAVE_LIBZ +/* wrapper for pdc_malloc for use in zlib */ +static voidpf +pdc_zlib_alloc(voidpf pdc, uInt items, uInt size) +{ + return (voidpf) pdc_malloc((pdc_core *) pdc, items * size, "zlib"); +} + +#endif /* HAVE_LIBZ */ + +pdc_bool +pdc_stream_not_empty(pdc_output *out) +{ + pdc_stream *stream = &out->stream; + + return(!stream->writeproc && stream->curpos != stream->basepos); +} + +const char * +pdc_get_stream_contents(pdc_output *out, long *size) +{ + pdc_stream *stream = &out->stream; + pdc_core *pdc = out->pdc; + + if (stream->writeproc) + pdc_error(pdc, PDC_E_IO_NOBUFFER, 0, 0, 0, 0); + + *size = (long) (stream->curpos - stream->basepos); + + stream->base_offset += (size_t) (stream->curpos - stream->basepos); + stream->curpos = stream->basepos; + + return (const char *) stream->basepos; +} + +static void +pdc_boot_stream(pdc_output *out) +{ + pdc_stream *stream = &out->stream; + + /* curpos must be initialized here so that the check for empty + * buffer in PDF_delete() also works in the degenerate case of + * no output produced. + */ + stream->basepos = stream->curpos = NULL; +} + +static size_t +pdc_writeproc_file(pdc_output *out, void *data, size_t size) +{ + pdc_stream *stream = &out->stream; + + return fwrite(data, 1, (size_t) size, stream->fp); +} + +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma managed +#endif +static pdc_bool +pdc_init_stream( + pdc_core *pdc, + pdc_output *out, + const char *filename, + FILE *fp, + size_t (*writeproc)(pdc_output *out, void *data, size_t size)) +{ + pdc_stream *stream = &out->stream; + +#if defined(MAC) || defined(MACOSX) +#if !defined(TARGET_API_MAC_CARBON) || defined(__MWERKS__) + FCBPBRec fcbInfo; + Str32 name; +#endif /* TARGET_API_MAC_CARBON */ + FInfo fInfo; + FSSpec fSpec; +#endif /* defined(MAC) || defined(MACOSX) */ + + /* + * This may be left over from the previous run. We deliberately + * don't reuse the previous buffer in order to avoid potentially + * unwanted growth of the allocated buffer due to a single large + * document in a longer series of documents. + */ + if (stream->basepos) + pdc_free(pdc, (void *) stream->basepos); + + stream->basepos = (pdc_byte *)pdc_malloc(pdc, STREAM_CHUNKSIZE, + "pdc_init_stream"); + stream->curpos = stream->basepos; + stream->maxpos = stream->basepos + STREAM_CHUNKSIZE; + stream->base_offset = 0L; + stream->compressing = pdc_false; + +#ifdef HAVE_LIBZ + /* zlib sometimes reads uninitialized memory where it shouldn't... */ + memset(&stream->z, 0, sizeof stream->z); + + stream->z.zalloc = (alloc_func) pdc_zlib_alloc; + stream->z.zfree = (free_func) pdc_free; + stream->z.opaque = (voidpf) pdc; + + if (deflateInit(&stream->z, pdc_get_compresslevel(out)) != Z_OK) + pdc_error(pdc, PDC_E_IO_COMPRESS, "deflateInit", 0, 0, 0); + + out->compr_changed = pdc_false; +#endif + + /* Defaults */ + stream->mustclose = pdc_false; + stream->fp = (FILE *) NULL; + stream->writeproc = pdc_writeproc_file; + + if (fp) { + /* PDF_open_fp */ + stream->fp = fp; + + } else if (writeproc) { + stream->writeproc = writeproc; /* PDF_open_mem */ + + } else if (filename == NULL || *filename == '\0') { + /* PDF_open_file with in-core output */ + stream->writeproc = NULL; + + } else { + /* PDF_open_file with file output */ +#if !((defined(MAC) || defined (MACOSX)) && defined(__MWERKS__)) + if (filename && !strcmp(filename, "-")) { + stream->fp = stdout; +#if !defined(__MWERKS__) && (defined(WIN32) || defined(OS2)) +#if defined WINCE + _setmode(fileno(stdout), _O_BINARY); +#else + setmode(fileno(stdout), O_BINARY); +#endif /* !WINCE */ +#endif + } else { +#endif /* !MAC */ + + stream->fp = fopen(filename, WRITEMODE); + + if (stream->fp == NULL) + return pdc_false; + + stream->mustclose = pdc_true; + +#ifdef PDF_FILETYPE_SUPPORTED + +#if defined(MAC) || defined(MACOSX) + /* set the proper type and creator for the output file */ +#if TARGET_API_MAC_CARBON && !defined(__MWERKS__) + + if (FSPathMakeFSSpec((const UInt8 *) filename, &fSpec) == noErr) { + FSpGetFInfo(&fSpec, &fInfo); + + fInfo.fdType = 'PDF '; + fInfo.fdCreator = 'CARO'; + FSpSetFInfo(&fSpec, &fInfo); + } + +#else + + memset(&fcbInfo, 0, sizeof(FCBPBRec)); + fcbInfo.ioRefNum = (short) stream->fp->handle; + fcbInfo.ioNamePtr = name; + + if (!PBGetFCBInfoSync(&fcbInfo) && + FSMakeFSSpec(fcbInfo.ioFCBVRefNum, fcbInfo.ioFCBParID, + name, &fSpec) == noErr) { + FSpGetFInfo(&fSpec, &fInfo); + fInfo.fdType = 'PDF '; + fInfo.fdCreator = 'CARO'; + FSpSetFInfo(&fSpec, &fInfo); + } +#endif /* !defined(TARGET_API_MAC_CARBON) || defined(__MWERKS__) */ +#endif /* defined(MAC) || defined(MACOSX) */ + +#endif /* PDF_FILETYPE_SUPPORTED */ + +#if !((defined(MAC) || defined (MACOSX)) && defined(__MWERKS__)) + } +#endif /* !MAC */ + } + + return pdc_true; +} +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma managed +#endif + +/* close the output file, if opened with PDF_open_file(); + * close the output stream if opened + */ + +static void +pdc_close_stream(pdc_output *out) +{ + pdc_stream *stream = &out->stream; + + pdc_flush_stream(out); + +#ifdef HAVE_LIBZ + /* + * This is delicate: we must ignore the return value because of the + * following reasoning: We are called in two situations: + * - end of document + * - exception + * In the first case compression is inactive, so deflateEnd() will + * fail only in the second case. However, when an exception occurs + * the document is definitely unusable, so we avoid recursive exceptions + * or an (unallowed) exception in PDF_delete(). + */ + + (void) deflateEnd(&stream->z); +#endif + + /* close the output file if writing to file, but do not close the + * in-core output stream since the caller will have to + * fetch the buffer after PDF_close(). + */ + if (stream->fp == NULL || !stream->writeproc) + return; + + if (stream->mustclose) + fclose(stream->fp); + + /* mark fp as dead in case the error handler jumps in later */ + stream->fp = NULL; +} + + +static void +pdc_check_stream(pdc_output *out, size_t len) +{ + size_t max; + int cur; + pdc_stream *stream = &out->stream; + pdc_core *pdc = out->pdc; + + if (stream->curpos + len <= stream->maxpos) + return; + + pdc_flush_stream(out); + + if (stream->curpos + len <= stream->maxpos) + return; + + max = (size_t) (2*(stream->maxpos - stream->basepos)); + cur = stream->curpos - stream->basepos; + + stream->basepos = (pdc_byte *) + pdc_realloc(pdc, (void *) stream->basepos, max, "pdc_check_stream"); + stream->maxpos = stream->basepos + max; + stream->curpos = stream->basepos + cur; + + pdc_check_stream(out, len); +} + +void +pdc_flush_stream(pdc_output *out) +{ + size_t size; + pdc_stream *stream = &out->stream; + pdc_core *pdc = out->pdc; + + if (!stream->writeproc || stream->compressing) + return; + + size = (size_t) (stream->curpos - stream->basepos); + + if (stream->writeproc(out, (void *) stream->basepos, size) != size) { + pdc_free(pdc, stream->basepos); + stream->basepos = NULL; + pdc_error(pdc, PDC_E_IO_NOWRITE, 0, 0, 0, 0); + } + + stream->base_offset += (size_t) (stream->curpos - stream->basepos); + stream->curpos = stream->basepos; +} + +void +pdc_cleanup_stream(pdc_output *out) +{ + pdc_stream *stream = &out->stream; + pdc_core *pdc = out->pdc; + + /* this may happen in rare cases */ + if (!stream->basepos) + return; + + if (stream->basepos) { + pdc_free(pdc, (void *) stream->basepos); + stream->basepos = NULL; + } +} + +long +pdc_tell_out(pdc_output *out) +{ + pdc_stream *stream = &out->stream; + + return(long)(stream->base_offset + (stream->curpos - stream->basepos)); +} + +/* --------------------- compression handling ----------------------- */ + +static void +pdc_begin_compress(pdc_output *out) +{ + pdc_stream *stream = &out->stream; + pdc_core *pdc = out->pdc; + + if (!pdc_get_compresslevel(out)) { + stream->compressing = pdc_false; + return; + } + +#ifdef HAVE_LIBZ + if (out->compr_changed) + { + if (deflateEnd(&stream->z) != Z_OK) + pdc_error(pdc, PDC_E_IO_COMPRESS, "deflateEnd", 0, 0, 0); + + if (deflateInit(&stream->z, pdc_get_compresslevel(out)) != Z_OK) + pdc_error(pdc, PDC_E_IO_COMPRESS, "deflateInit", 0, 0, 0); + + out->compr_changed = pdc_false; + } + else + { + if (deflateReset(&stream->z) != Z_OK) + pdc_error(pdc, PDC_E_IO_COMPRESS, "deflateReset", 0, 0, 0); + } + + stream->z.avail_in = 0; +#endif /* HAVE_LIBZ */ + + stream->compressing = pdc_true; +} + + +static void +pdc_end_compress(pdc_output *out) +{ + int status; + pdc_stream *stream = &out->stream; + pdc_core *pdc = out->pdc; + + /* this may happen during cleanup triggered by an exception handler */ + if (!stream->compressing) + return; + + if (!pdc_get_compresslevel(out)) { + stream->compressing = pdc_false; + return; + } + + +#ifdef HAVE_LIBZ + /* Finish the stream */ + do { + pdc_check_stream(out, 128); + stream->z.next_out = (Bytef *) stream->curpos; + stream->z.avail_out = (uInt) (stream->maxpos - stream->curpos); + + status = deflate(&(stream->z), Z_FINISH); + stream->curpos = stream->z.next_out; + + if (status != Z_STREAM_END && status != Z_OK) + pdc_error(pdc, PDC_E_IO_COMPRESS, "Z_FINISH", 0, 0, 0); + + } while (status != Z_STREAM_END); + + stream->compressing = pdc_false; +#endif /* HAVE_LIBZ */ +} + +/* ---------------------- Low-level output function ---------------------- */ +/* + * Write binary data to the output without any modification, + * and apply compression if we are currently in compression mode. + */ + + +void +pdc_write(pdc_output *out, const void *data, size_t size) +{ + pdc_stream *stream = &out->stream; + int estimate = 0; + pdc_core *pdc = out->pdc; + +#ifdef HAVE_LIBZ + if (stream->compressing) { + stream->z.avail_in = (uInt) size; + stream->z.next_in = (Bytef *) data; + stream->z.avail_out = 0; + + while (stream->z.avail_in > 0) { + if (stream->z.avail_out == 0) { + /* estimate output buffer size */ + estimate = (int) (stream->z.avail_in/4 + 16); + pdc_check_stream(out, (size_t) estimate); + stream->z.next_out = (Bytef *) stream->curpos; + stream->z.avail_out = (uInt) (stream->maxpos - stream->curpos); + } + + if (deflate(&(stream->z), Z_NO_FLUSH) != Z_OK) + pdc_error(pdc, PDC_E_IO_COMPRESS, "Z_NO_FLUSH", 0, 0, 0); + + stream->curpos = stream->z.next_out; + } + } else { +#endif /* HAVE_LIBZ */ + + pdc_check_stream(out, size); + memcpy(stream->curpos, data, size); + stream->curpos += size; + +#ifdef HAVE_LIBZ + } +#endif /* HAVE_LIBZ */ +} + +/* --------------------------- Setup --------------------------- */ + +void * +pdc_boot_output(pdc_core *pdc) +{ + static const char *fn = "pdc_boot_output"; + pdc_output *out; + + out = (pdc_output*)pdc_malloc(pdc, sizeof(pdc_output), fn); + out->pdc = pdc; + + out->file_offset = NULL; + + pdc_boot_stream(out); + + return (void *) out; +} + +/* + * Initialize the PDF output + * only one of filename, fp, writeproc must be supplied, + * the others must be NULL: + * filename use supplied file name to create a named output file + * filename == "" means generate output in-core + * fp use supplied FILE * to write to file + * writeproc use supplied procedure to write output data + * + * Note that the caller is responsible for supplying sensible arguments. + */ + +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma managed +#endif +pdc_bool +pdc_init_output( + void *opaque, + pdc_output *out, + const char *filename, + FILE *fp, + size_t (*writeproc)(pdc_output *out, void *data, size_t size), + int compatibility) +{ + static const char *fn = "pdc_init_output"; + pdc_core *pdc = out->pdc; + int i; + + out->lastobj = 0; + + if (out->file_offset == NULL) { + out->file_offset_capacity = + ID_CHUNKSIZE; + + out->file_offset = (long *) pdc_malloc(pdc, + sizeof(long) * out->file_offset_capacity, fn); + } + + for (i = 1; i < out->file_offset_capacity; ++i) + out->file_offset[i] = PDC_BAD_ID; + + out->compresslevel = PDF_DEFAULT_COMPRESSION; + out->compr_changed = pdc_false; + + out->opaque = opaque; + + memcpy(out->id[0], out->id[1], MD5_DIGEST_LENGTH); + + + if (!pdc_init_stream(pdc, out, filename, fp, writeproc)) + return pdc_false; + + /* Write the document header */ + if (compatibility == PDC_1_5) + pdc_puts(out, "%PDF-1.5\n"); + else if (compatibility == PDC_1_4) + pdc_puts(out, "%PDF-1.4\n"); + else + pdc_puts(out, "%PDF-1.3\n"); + + /* binary magic number */ +#define PDC_MAGIC_BINARY "\045\344\343\317\322\012" + pdc_write(out, PDC_MAGIC_BINARY, sizeof(PDC_MAGIC_BINARY) - 1); + + return pdc_true; +} +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma managed +#endif + +void +pdc_close_output(pdc_output *out) +{ + pdc_close_stream(out); + + if (out->file_offset) + { + pdc_free(out->pdc, out->file_offset); + out->file_offset = 0; + } + +} + +void +pdc_cleanup_output(pdc_output *out) +{ + pdc_core *pdc = out->pdc; + + if (out->file_offset) { + pdc_free(pdc, out->file_offset); + out->file_offset = NULL; + } + + + pdc_cleanup_stream(out); + +} + +/* --------------------------- Digest --------------------------- */ + +void +pdc_init_digest(pdc_output *out) +{ + MD5_Init(&out->md5); +} + +void +pdc_update_digest(pdc_output *out, unsigned char *input, + unsigned int len) +{ + MD5_Update(&out->md5, input, len); +} + +void +pdc_finish_digest(pdc_output *out) +{ + MD5_Final(out->id[1], &out->md5); +} + +/* --------------------------- Objects and ids --------------------------- */ + +pdc_id +pdc_begin_obj(pdc_output *out, pdc_id obj_id) +{ + if (obj_id == PDC_NEW_ID) + obj_id = pdc_alloc_id(out); + + out->file_offset[obj_id] = pdc_tell_out(out); + pdc_printf(out, "%ld 0 obj\n", obj_id); + + return obj_id; +} + +pdc_id +pdc_alloc_id(pdc_output *out) +{ + pdc_core *pdc = out->pdc; + + out->lastobj++; + + if (out->lastobj >= out->file_offset_capacity) { + out->file_offset_capacity *= 2; + out->file_offset = (long *) pdc_realloc(pdc, out->file_offset, + sizeof(long) * out->file_offset_capacity, "pdc_alloc_id"); + } + + /* only needed for verifying obj table in PDF_close() */ + out->file_offset[out->lastobj] = PDC_BAD_ID; + + return out->lastobj; +} + +/* --------------------------- Strings --------------------------- */ + +void +pdc_put_pdfstring(pdc_output *out, const char *text, int len) +{ + const unsigned char *goal, *s; + + pdc_putc(out, PDF_PARENLEFT); + + goal = (const unsigned char *) text + len; + + for (s = (const unsigned char *) text; s < goal; s++) { + switch (*s) { + case PDF_RETURN: + pdc_putc(out, PDF_BACKSLASH); + pdc_putc(out, PDF_r); + break; + + case PDF_NEWLINE: + pdc_putc(out, PDF_BACKSLASH); + pdc_putc(out, PDF_n); + break; + + default: + if (*s == PDF_PARENLEFT || *s == PDF_PARENRIGHT || + *s == PDF_BACKSLASH) + pdc_putc(out, PDF_BACKSLASH); + pdc_putc(out, (char) *s); + } + } + + pdc_putc(out, PDF_PARENRIGHT); +} + +void +pdc_put_pdfunistring(pdc_output *out, const char *text) +{ + int len; + + len = (int) pdc_strlen(text) - 1; /* subtract a null byte... */ + + /* ...and possibly another one */ + if (pdc_is_unicode(text)) + len--; + + pdc_put_pdfstring(out, text, len); +} + +/* --------------------------- Streams --------------------------- */ + +void +pdc_begin_pdfstream(pdc_output *out) +{ + pdc_puts(out, "stream\n"); + + out->start_pos = pdc_tell_out(out); + + if (out->compresslevel) + pdc_begin_compress(out); +} + +void +pdc_end_pdfstream(pdc_output *out) +{ + if (out->compresslevel) + pdc_end_compress(out); + + out->length = pdc_tell_out(out) - out->start_pos; + + /* some PDF consumers seem to need the additional "\n" before "endstream", + ** the PDF reference allows it, and Acrobat's "repair" feature relies on it. + */ + pdc_puts(out, "\nendstream\n"); +} + +void +pdc_put_pdfstreamlength(pdc_output *out, pdc_id length_id) +{ + + pdc_begin_obj(out, length_id); /* Length object */ + pdc_printf(out, "%ld\n", out->length); + pdc_end_obj(out); +} + +void +pdc_set_compresslevel(pdc_output *out, int compresslevel) +{ + out->compresslevel = compresslevel; + out->compr_changed = pdc_true; +} + +int +pdc_get_compresslevel(pdc_output *out) +{ + return out->compresslevel; +} + +/* --------------------------- Names --------------------------- */ + +/* characters illegal in PDF names: "()<>[]{}/%#" */ +#define PDF_ILL_IN_NAMES "\050\051\074\076\133\135\173\175\057\045\043" + +#define PDF_NEEDS_QUOTE(c) \ + ((c) < 33 || (c) > 126 || strchr(PDF_ILL_IN_NAMES, (c)) != (char *) 0) + +void +pdc_put_pdfname(pdc_output *out, const char *text, size_t len) +{ + const unsigned char *goal, *s; + static const char BinToHex[] = PDF_STRING_0123456789ABCDEF; + + goal = (const unsigned char *) text + len; + + pdc_putc(out, PDF_SLASH); + + for (s = (const unsigned char *) text; s < goal; s++) { + if (PDF_NEEDS_QUOTE(*s)) { + pdc_putc(out, PDF_HASH); + pdc_putc(out, BinToHex[*s >> 4]); /* first nibble */ + pdc_putc(out, BinToHex[*s & 0x0F]); /* second nibble */ + } else + pdc_putc(out, (char) *s); + } +} + + +char * +pdc_make_quoted_pdfname(pdc_output *out, const char *text, + size_t len, char *buf) +{ + const unsigned char *goal, *s; + unsigned char *cur = (unsigned char *) buf; + static const unsigned char BinToHex[] = PDF_STRING_0123456789ABCDEF; + + (void) out; + + goal = (const unsigned char *) text + len; + + for (s = (const unsigned char *) text; s < goal; s++) { + if (PDF_NEEDS_QUOTE(*s)) { + *cur++ = PDF_HASH; + *cur++ = BinToHex[*s >> 4]; /* first nibble */ + *cur++ = BinToHex[*s & 0x0F]; /* second nibble */ + } else + *cur++ = *s; + } + + *cur = 0; + + return buf; +} + +/* --------------------------- Document sections --------------------------- */ + +void +pdc_mark_free(pdc_output *out, pdc_id obj_id) +{ + out->file_offset[obj_id] = PDC_FREE_ID; +} + + +void +pdc_write_xref_and_trailer(pdc_output *out, pdc_id info_id, pdc_id root_id) +{ + static const char bin2hex[] = PDF_STRING_0123456789ABCDEF; + long pos; + pdc_id i; + pdc_id free_id; + pdc_core *pdc = out->pdc; + + + /* Don't write any object after this check! */ + + for (i = 1; i <= out->lastobj; i++) { + if (out->file_offset[i] == PDC_BAD_ID) { + pdc_warning(pdc, PDC_E_INT_UNUSEDOBJ, + pdc_errprintf(pdc, "%ld", i), 0, 0, 0); + /* write a dummy object */ + pdc_begin_obj(out, i); + pdc_printf(out, "null %% unused object\n"); + pdc_end_obj(out); + } + } + + pos = pdc_tell_out(out); /* xref table */ + pdc_puts(out, "xref\n"); + pdc_printf(out, "0 %ld\n", out->lastobj + 1); + + /* find the last free entry in the xref table. + */ + out->file_offset[0] = PDC_FREE_ID; + for (free_id = out->lastobj; + out->file_offset[free_id] != PDC_FREE_ID; + --free_id) + ; + + pdc_printf(out, "%010ld 65535 f \n", free_id); + free_id = 0; + +#define PDF_FLUSH_AFTER_MANY_OBJS 3000 /* ca. 60 KB */ + for (i = 1; i <= out->lastobj; i++) { + /* Avoid spike in memory usage at the end of the document */ + if (i % PDF_FLUSH_AFTER_MANY_OBJS) + pdc_flush_stream(out); + + if (out->file_offset[i] == PDC_FREE_ID) + { + pdc_printf(out, "%010ld 00001 f \n", free_id); + free_id = i; + } + else + { + pdc_printf(out, "%010ld 00000 n \n", out->file_offset[i]); + } + } + + pdc_puts(out, "trailer\n"); + + pdc_begin_dict(out); /* trailer */ + pdc_printf(out, "/Size %ld\n", out->lastobj + 1); + pdc_printf(out, "/Root %ld 0 R\n", root_id); + + if (info_id != PDC_BAD_ID) + pdc_printf(out, "/Info %ld 0 R\n", info_id); + + /* write the digest to the ID array */ + pdc_puts(out, "/ID[<"); + for (i = 0; i < MD5_DIGEST_LENGTH; ++i) + { + pdc_putc(out, bin2hex[out->id[0][i] >> 4]); + pdc_putc(out, bin2hex[out->id[0][i] & 0x0F]); + } + pdc_puts(out, "><"); + for (i = 0; i < MD5_DIGEST_LENGTH; ++i) + { + pdc_putc(out, bin2hex[out->id[1][i] >> 4]); + pdc_putc(out, bin2hex[out->id[1][i] & 0x0F]); + } + pdc_puts(out, ">]\n"); + + pdc_end_dict(out); /* trailer */ + + pdc_puts(out, "startxref\n"); + pdc_printf(out, "%ld\n", pos); + pdc_puts(out, "%%EOF\n"); +} + +/* ---------------------- High-level output functions ---------------------- */ + + +/* + * Write a string to the output. + */ + +void +pdc_puts(pdc_output *out, const char *s) +{ + pdc_write(out, (void *) s, strlen(s)); +} + + +/* Write a character to the output without any modification. */ + +void +pdc_putc(pdc_output *out, const char c) +{ + pdc_write(out, (void *) &c, (size_t) 1); +} + +/* + * Write a formatted string to the output, converting from native + * encoding to ASCII if necessary. + */ + +void +pdc_printf(pdc_output *out, const char *fmt, ...) +{ + char buf[PDF_LINEBUFLEN]; /* formatting buffer */ + va_list ap; + + va_start(ap, fmt); + + pdc_vsprintf(out->pdc, buf, fmt, ap); + pdc_puts(out, buf); + + va_end(ap); +} diff --git a/src/libs/pdflib/libs/pdcore/pc_output.h b/src/libs/pdflib/libs/pdcore/pc_output.h new file mode 100644 index 0000000000..05e157f309 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_output.h @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_output.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib output routines + * + */ + +#ifndef PC_OUTPUT_H +#define PC_OUTPUT_H + +/* --------------------------- General --------------------------- */ + +/* Acrobat viewers change absolute values < 1/65536 to zero */ +#define PDF_SMALLREAL (0.000015) + +/* maximum capacity of a dictionary, in entries */ +#define PDF_MAXDICTSIZE (4095) + +/* maximum capacity of aa array, in elements */ +#define PDF_MAXARRAYSIZE (8191) + +/* some ASCII characters and strings, deliberately defined as hex/oct codes */ + +#define PDF_NEWLINE ((char) 0x0a) /* ASCII '\n' */ +#define PDF_RETURN ((char) 0x0d) /* ASCII '\r' */ +#define PDF_SPACE ((char) 0x20) /* ASCII ' ' */ +#define PDF_HASH ((char) 0x23) /* ASCII '#' */ +#define PDF_PARENLEFT ((char) 0x28) /* ASCII '(' */ +#define PDF_PARENRIGHT ((char) 0x29) /* ASCII ')' */ +#define PDF_PLUS ((char) 0x2b) /* ASCII '+' */ +#define PDF_SLASH ((char) 0x2f) /* ASCII '/' */ +#define PDF_BACKSLASH ((char) 0x5c) /* ASCII '\\' */ +#define PDF_A ((char) 0x41) /* ASCII 'A' */ +#define PDF_n ((char) 0x6e) /* ASCII 'n' */ +#define PDF_r ((char) 0x72) /* ASCII 'r' */ + +#define PDF_STRING_0123456789ABCDEF \ + "\060\061\062\063\064\065\066\067\070\071\101\102\103\104\105\106" + +typedef struct pdc_output_s pdc_output; + +/* --------------------------- Setup --------------------------- */ +void *pdc_boot_output(pdc_core *pdc); +pdc_bool pdc_init_output(void *opaque, pdc_output *out, const char *filename, + FILE *fp, size_t (*writeproc)(pdc_output *out, void *data, size_t size), + int compatibility); +void pdc_cleanup_output(pdc_output *out); + +void *pdc_get_opaque(pdc_output *out); + +/* --------------------------- Digest --------------------------- */ + +void pdc_init_digest(pdc_output *out); +void pdc_update_digest(pdc_output *out, unsigned char *input, + unsigned int len); +void pdc_finish_digest(pdc_output *out); + + +/* --------------------------- Objects and ids --------------------------- */ + +pdc_id pdc_alloc_id(pdc_output *out); +void pdc_mark_free(pdc_output *out, pdc_id obj_id); + +pdc_id pdc_begin_obj(pdc_output *out, pdc_id obj_id); +#define pdc_end_obj(out) pdc_puts(out, "endobj\n") + +#define PDC_NEW_ID 0L +#define PDC_BAD_ID -1L +#define PDC_FREE_ID -2L + + +/* --------------------------- Strings --------------------------- */ +/* output a string (including parentheses) and quote all required characters */ +void pdc_put_pdfstring(pdc_output *out, const char *text, + int len); + +/* output a string (including parentheses) which may be Unicode string */ +void pdc_put_pdfunistring(pdc_output *out, const char *string); + +/* --------------------------- Names --------------------------- */ +/* output a PDF name (including leading slash) and quote all required chars */ +void pdc_put_pdfname(pdc_output *out, const char *text, size_t len); + +/* return a quoted version of a string */ +char *pdc_make_quoted_pdfname(pdc_output *out, + const char *text, size_t len,char *buf); + + +/* --------------------------- Dictionaries --------------------------- */ +#define pdc_begin_dict(out) pdc_puts(out, "<<") +#define pdc_end_dict(out) pdc_puts(out, ">>\n") + + +/* --------------------------- Streams --------------------------- */ +void pdc_begin_pdfstream(pdc_output *out); +void pdc_end_pdfstream(pdc_output *out); +void pdc_put_pdfstreamlength(pdc_output *out, pdc_id length_id); + +int pdc_get_compresslevel(pdc_output *out); +void pdc_set_compresslevel(pdc_output *out, int compresslevel); + + +/* --------------------------- Document sections --------------------------- */ +void pdc_write_xref_and_trailer(pdc_output *out, + pdc_id info_id, pdc_id root_id); + + +/* --------------------------- Low-level output --------------------------- */ +void pdc_flush_stream(pdc_output *out); +long pdc_tell_out(pdc_output *out); +void pdc_close_stream1(pdc_output *out); +void pdc_close_output(pdc_output *out); +void pdc_cleanup_stream(pdc_output *out); +const char *pdc_get_stream_contents(pdc_output *out, long *size); +int pdc_stream_not_empty(pdc_output *out); + +void pdc_write(pdc_output *out, const void *data,size_t size); +void pdc_puts(pdc_output *out, const char *s); +void pdc_putc(pdc_output *out, const char c); + + +/* ------------------------- High-level output ------------------------- */ +void pdc_printf(pdc_output *out, const char *fmt, ...); + +#endif /* PC_OUTPUT_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_sbuf.c b/src/libs/pdflib/libs/pdcore/pc_sbuf.c new file mode 100644 index 0000000000..5758f6e37a --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_sbuf.c @@ -0,0 +1,103 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_sbuf.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Dynamically growing string buffers. + * + */ + + +#include "pc_util.h" +#include "pc_sbuf.h" + + +/* TODO: initial size parameter for pdc_sb_new(). */ +#undef INIT_SIZE +#define INIT_SIZE 1000 + +pdc_sbuf * +pdc_sb_new(pdc_core *pdc) +{ + static const char fn[] = "pdc_sb_new"; + + pdc_sbuf *sb = (pdc_sbuf *)pdc_malloc(pdc, sizeof (pdc_sbuf), fn); + + sb->pdc = pdc; + sb->buf = (char *)pdc_malloc(pdc, INIT_SIZE, fn); /* TODO: potential leak */ + sb->scan = sb->buf; + sb->limit = sb->buf + INIT_SIZE; + + return sb; +} /* pdc_sb_new */ + + +void +pdc_sb_delete(pdc_sbuf *sb) +{ + pdc_free(sb->pdc, sb->buf); + pdc_free(sb->pdc, sb); +} /* pdc_sb_delete */ + + +void +pdc_sb_copy(pdc_sbuf *dst, const pdc_sbuf *src) +{ + static const char fn[] = "pdc_sb_copy"; + + int s_size = src->scan - src->buf; + int d_cap = dst->limit - dst->buf; + + if (d_cap < s_size) + { + do + { + d_cap *= 2; + } while (d_cap < s_size); + + pdc_free(dst->pdc, dst->buf); + dst->buf = (char *)pdc_malloc(dst->pdc, (size_t) d_cap, fn); + dst->limit = dst->buf + d_cap; + } + + memcpy(dst->buf, src->buf, (size_t) s_size); + dst->scan = dst->buf + s_size; +} /* pdc_sb_copy */ + + +void +pdc_sb_put_c(pdc_sbuf *sb, int ch) +{ + static const char fn[] = "pdc_sb_put_c"; + + int size = sb->limit - sb->buf; + + sb->buf = (char *)pdc_realloc(sb->pdc, sb->buf, (size_t) (2 * size), fn); + sb->scan = sb->buf + size; + sb->limit = sb->buf + 2 * size; + + *(sb->scan++) = (char) ch; +} /* pdc_sb_put_c */ + + +void +pdc_sb_write(pdc_sbuf *dst, const char *src, int len) +{ + int i; + + if (len == -1) + len = (int) strlen(src); + + /* TODO: optimize. */ + for (i = 0; i < len; ++i) + pdc_sb_putc(dst, src[i]); +} /* pdc_sb_write */ diff --git a/src/libs/pdflib/libs/pdcore/pc_sbuf.h b/src/libs/pdflib/libs/pdcore/pc_sbuf.h new file mode 100644 index 0000000000..02f2725365 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_sbuf.h @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_sbuf.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Dynamically growing string buffers. + * + */ + +#ifndef PC_SBUF_H +#define PC_SBUF_H + +#include "pc_core.h" + +typedef struct pdc_sbuf_s pdc_sbuf; + +/* TODO: init_len parameter */ +pdc_sbuf * pdc_sb_new(pdc_core *pdc); +void pdc_sb_delete(pdc_sbuf *sb); + +void pdc_sb_copy(pdc_sbuf *dst, const pdc_sbuf *src); +void pdc_sb_write(pdc_sbuf *dst, const char *src, int len); + +/* public macros. +*/ +#define pdc_sb_putc(b, c) \ + (((b)->scan < (b)->limit) \ + ? (void) (*(b)->scan++ = (char) (c)) \ + : pdc_sb_put_c((b), (c))) + +#define pdc_sb_get_cptr(b) \ + ((b)->buf) + +#define pdc_sb_get_size(b) \ + ((b)->scan - (b)->buf) + +#define pdc_sb_rewrite(b) \ + ((void) ((b)->scan = (b)->buf)) + + +/* the declarations below are strictly private to pc_sbuf.c! +** use the above macros only! +*/ +struct pdc_sbuf_s +{ + pdc_core * pdc; + + char * buf; + char * scan; + char * limit; +}; + +void pdc_sb_put_c(pdc_sbuf *sb, int ch); + +#endif /* PC_SBUF_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_scope.c b/src/libs/pdflib/libs/pdcore/pc_scope.c new file mode 100644 index 0000000000..d88f3df32c --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_scope.c @@ -0,0 +1,27 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_scope.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Scoping routines and macros + * + */ + +#include + +#include "pc_util.h" +#include "pc_scope.h" +#include "pc_file.h" + + +static void pdc_check_scope(void) {} + diff --git a/src/libs/pdflib/libs/pdcore/pc_scope.h b/src/libs/pdflib/libs/pdcore/pc_scope.h new file mode 100644 index 0000000000..41daebffd3 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_scope.h @@ -0,0 +1,23 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_scope.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Scoping routines and macros + * + */ + +#ifndef PC_SCOPE_H +#define PC_SCOPE_H + + +#endif /* PC_SCOPE_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_unicode.c b/src/libs/pdflib/libs/pdcore/pc_unicode.c new file mode 100644 index 0000000000..1b0994c4ac --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_unicode.c @@ -0,0 +1,1214 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_unicode.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * PDFlib routines for converting between Unicode values and Adobe glyph names + * + */ + +#include "pc_util.h" +#include "pc_chartabs.h" + + +/* + * Returns the Unicode value of a glyph name. If the name is not + * contained in the Adobe Glyph List (AGL) 0 will be returned. + */ + +pdc_ushort +pdc_adobe2unicode(const char *name) +{ + int lo = 0; + int hi = ((sizeof tab_agl2uni) / (sizeof (pdc_glyph_tab))); + + if (name) + { + while (lo < hi) + { + int i = (lo + hi) / 2; + int cmp = strcmp(name, tab_agl2uni[i].glyphname); + + if (cmp == 0) + return tab_agl2uni[i].code; + + if (cmp < 0) + hi = i; + else + lo = i + 1; + } + } + + return 0; +} + +/* + * Returns the name in the Adobe Glyph List which corresponds to + * the supplied Unicode value. If the value doesn't have a + * corresponding Unicode name NULL will be returned. + */ + +const char * +pdc_unicode2adobe(pdc_ushort uv) +{ + int lo = 0; + int hi = ((sizeof tab_uni2agl) / (sizeof (pdc_glyph_tab))); + + if (uv) + { + while (lo < hi) + { + int i = (lo + hi) / 2; + + if (uv == tab_uni2agl[i].code) + return tab_uni2agl[i].glyphname; + + if (uv < tab_uni2agl[i].code) + hi = i; + else + lo = i + 1; + } + } + + return (char *) 0; +} + + + +/* + * Returns true if a character name is contained in pc_standard_latin_charset. + * Otherwise false will be returned. + */ + +pdc_bool +pdc_is_std_charname(const char *name) +{ + int lo = 0; + int hi = ((sizeof pc_standard_latin_charset) / (sizeof (char *))); + + if (name) + { + while (lo < hi) + { + int i = (lo + hi) / 2; + int cmp = strcmp(name, pc_standard_latin_charset[i]); + + if (cmp == 0) + return pdc_true; + + if (cmp < 0) + hi = i; + else + lo = i + 1; + } + } + + return pdc_false; +} + +/* + * The following source is based on Unicode's original source + * code ConvertUTF.c. It has been adapted to PDFlib programming + * conventions. + * + * The original file had the following notice: + * + * Copyright 2001 Unicode, Inc. + * + * Limitations on Rights to Redistribute This Code + * + * Author: Mark E. Davis, 1994. + * Rev History: Rick McGowan, fixes & updates May 2001. + * + * + * Functions for conversions between UTF32, UTF-16, and UTF-8. + * These funtions forming a complete set of conversions between + * the three formats. UTF-7 is not included here. + * + * Each of these routines takes pointers to input buffers and output + * buffers. The input buffers are const. + * + * Each routine converts the text between *sourceStart and sourceEnd, + * putting the result into the buffer between *targetStart and + * targetEnd. Note: the end pointers are *after* the last item: e.g. + * *(sourceEnd - 1) is the last item. + * + * The return result indicates whether the conversion was successful, + * and if not, whether the problem was in the source or target buffers. + * (Only the first encountered problem is indicated.) + * + * After the conversion, *sourceStart and *targetStart are both + * updated to point to the end of last text successfully converted in + * the respective buffers. + * + * Input parameters: + * sourceStart - pointer to a pointer to the source buffer. + * The contents of this are modified on return so that + * it points at the next thing to be converted. + * targetStart - similarly, pointer to pointer to the target buffer. + * sourceEnd, targetEnd - respectively pointers to the ends of the + * two buffers, for overflow checking only. + * + * These conversion functions take a pdc_convers_flags argument. When this + * flag is set to strict, both irregular sequences and isolated surrogates + * will cause an error. When the flag is set to lenient, both irregular + * sequences and isolated surrogates are converted. + * + * Whether the flag is strict or lenient, all illegal sequences will cause + * an error return. This includes sequences such as: , , + * or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + * must check for illegal sequences. + * + * When the flag is set to lenient, characters over 0x10FFFF are converted + * to the replacement character; otherwise (when the flag is set to strict) + * they constitute an error. + * + * Output parameters: + * The value "sourceIllegal" is returned from some routines if the input + * sequence is malformed. When "sourceIllegal" is returned, the source + * value will point to the illegal value that caused the problem. E.g., + * in UTF-8 when a sequence is malformed, it points to the start of the + * malformed sequence. + * + * Author: Mark E. Davis, 1994. + * Rev History: Rick McGowan, fixes & updates May 2001. + * + */ + +/* + * The following 4 definitions are compiler-specific. + * The C standard does not guarantee that wchar_t has at least + * 16 bits, so wchar_t is no less portable than unsigned short! + * All should be unsigned values to avoid sign extension during + * bit mask & shift operations. + */ + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ + +/* Some fundamental constants */ +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + + +/* --------------------------------------------------------------------- */ + +#if 0 +static pdc_convers_result +pdc_convertUTF32toUTF16 ( + UTF32** sourceStart, const UTF32* sourceEnd, + UTF16** targetStart, const UTF16* targetEnd, + const pdc_convers_flags flags) { + pdc_convers_result result = conversionOK; + UTF32* source = *sourceStart; + UTF16* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + if (target >= targetEnd) { + result = targetExhausted; break; + } + ch = *source++; + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + if ((flags == strictConversion) && + (ch >= UNI_SUR_HIGH_START && + ch <= UNI_SUR_LOW_END)) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = (UTF16) ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16) ((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16) ((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +static pdc_convers_result +pdc_convertUTF16toUTF32 ( + UTF16** sourceStart, UTF16* sourceEnd, + UTF32** targetStart, const UTF32* targetEnd, + const pdc_convers_flags flags) { + pdc_convers_result result = conversionOK; + UTF16* source = *sourceStart; + UTF32* target = *targetStart; + UTF32 ch, ch2; + while (source < sourceEnd) { + ch = *source++; + if (ch >= UNI_SUR_HIGH_START && + ch <= UNI_SUR_HIGH_END && + source < sourceEnd) { + ch2 = *source; + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { + /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else if ((flags == strictConversion) && + (ch >= UNI_SUR_LOW_START && + ch <= UNI_SUR_LOW_END)) { + /* an unpaired low surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + if (target >= targetEnd) { + result = targetExhausted; + break; + } + *target++ = ch; + } + *sourceStart = source; + *targetStart = target; +#ifdef CVTUTF_DEBUG +if (result == sourceIllegal) { + fprintf(stderr, "pdc_convertUTF16toUTF32 illegal seq 0x%04x,%04x\n", + ch, ch2); + fflush(stderr); +} +#endif + return result; +} +#endif + +/* --------------------------------------------------------------------- */ + +/* + * Index into the table below with the first byte of a UTF-8 sequence to + * get the number of trailing bytes that are supposed to follow it. + */ +static const char trailingBytesForUTF8[256] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 +}; + +#if 0 +static const char +pdc_get_trailingBytesForUTF8(int i) { + return (trailingBytesForUTF8[i]); +} +#endif + +/* + * Magic values subtracted from a buffer value during UTF8 conversion. + * This table contains as many values as there might be trailing bytes + * in a UTF-8 sequence. + */ +static const UTF32 offsetsFromUTF8[6] = { + 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL +}; + +/* + * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed + * into the first byte, depending on how many bytes follow. There are + * as many entries in this table as there are UTF-8 sequence types. + * (I.e., one byte sequence, two byte... six byte sequence.) + */ +static const UTF8 firstByteMark[7] = { + 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC +}; + +/* --------------------------------------------------------------------- */ + +/* The interface converts a whole buffer to avoid function-call overhead. + * Constants have been gathered. Loops & conditionals have been removed as + * much as possible for efficiency, in favor of drop-through switches. + * (See "Note A" at the bottom of the file for equivalent code.) + * If your compiler supports it, the "pdc_islegalUTF8" call can be turned + * into an inline function. + */ + +/* --------------------------------------------------------------------- */ + +static pdc_convers_result +pdc_convertUTF16toUTF8 ( + UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, const UTF8* targetEnd, + const pdc_convers_flags flags) { + pdc_convers_result result = conversionOK; + UTF16* source = *sourceStart; + UTF8* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && + ch <= UNI_SUR_HIGH_END && + source < sourceEnd) { + UTF32 ch2 = *source; + if (ch2 >= UNI_SUR_LOW_START && + ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } else if (flags == strictConversion) { + /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } else if ((flags == strictConversion) && + (ch >= UNI_SUR_LOW_START && + ch <= UNI_SUR_LOW_END)) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; + } else if (ch < (UTF32)0x200000) { bytesToWrite = 4; + } else { bytesToWrite = 2; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + target -= bytesToWrite; result = targetExhausted; break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; + case 3: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; + case 2: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; + case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +/* + * Utility routine to tell whether a sequence of bytes is legal UTF-8. + * This must be called with the length pre-determined by the first byte. + * If not calling this from pdc_convertUTF8to*, then the length can be set by: + * length = trailingBytesForUTF8[*source]+1; + * and the sequence is illegal right away if there aren't that many bytes + * available. + * If presented with a length > 4, this returns pdc_false. The Unicode + * definition of UTF-8 goes up to 4-byte sequences. + */ + +static pdc_bool +pdc_islegalUTF8(UTF8 *source, int length) { + UTF8 a; + UTF8 *srcptr = source+length; + switch (length) { + default: return pdc_false; + /* Everything else falls through when "pdc_true"... */ + case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return pdc_false; + case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return pdc_false; + case 2: if ((a = (*--srcptr)) > 0xBF) return pdc_false; + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: if (a < 0xA0) return pdc_false; break; + case 0xF0: if (a < 0x90) return pdc_false; break; + case 0xF4: if (a > 0x8F) return pdc_false; break; + default: if (a < 0x80) return pdc_false; + } + case 1: if (*source >= 0x80 && *source < 0xC2) return pdc_false; + if (*source > 0xF4) return pdc_false; + } + return pdc_true; +} + +/* --------------------------------------------------------------------- */ + +#if 0 +/* + * Exported function to return whether a UTF-8 sequence is legal or not. + * This is not used here; it's just exported. + */ +static pdc_bool pdc_islegalUTF8sequence(UTF8 *source, UTF8 *sourceEnd) { + int length = trailingBytesForUTF8[*source]+1; + if (source+length > sourceEnd) { + return pdc_false; + } + return pdc_islegalUTF8(source, length); +} +#endif + +/* --------------------------------------------------------------------- */ + +static pdc_convers_result +pdc_convertUTF8toUTF16 ( + UTF8** sourceStart, UTF8* sourceEnd, + UTF16** targetStart, const UTF16* targetEnd, + const pdc_convers_flags flags) { + pdc_convers_result result = conversionOK; + UTF8* source = *sourceStart; + UTF16* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0L; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; + break; + } + /* Do this check whether lenient or strict */ + if (! pdc_islegalUTF8(source, extraBytesToRead+1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 3: ch += *source++; ch <<= 6; + case 2: ch += *source++; ch <<= 6; + case 1: ch += *source++; ch <<= 6; + case 0: ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + if ((flags == strictConversion) && + (ch >= UNI_SUR_HIGH_START && + ch <= UNI_SUR_LOW_END)) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } else { + *target++ = (UTF16) ch; /* normal case */ + } + } else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= extraBytesToRead; /* return to the start */ + } else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (UTF16) ((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16) ((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +#if 0 +static pdc_convers_result +pdc_convertUTF32toUTF8 ( + UTF32** sourceStart, const UTF32* sourceEnd, + UTF8** targetStart, const UTF8* targetEnd, + const pdc_convers_flags flags) { + pdc_convers_result result = conversionOK; + UTF32* source = *sourceStart; + UTF8* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0x000000BF; + const UTF32 byteMark = 0x00000080; + ch = *source++; + /* surrogates of any stripe are not legal UTF32 characters */ + if (flags == strictConversion ) { + if ((ch >= UNI_SUR_HIGH_START) && (ch <= UNI_SUR_LOW_END)) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { bytesToWrite = 1; + } else if (ch < (UTF32)0x800) { bytesToWrite = 2; + } else if (ch < (UTF32)0x10000) { bytesToWrite = 3; + } else if (ch < (UTF32)0x200000) { bytesToWrite = 4; + } else { bytesToWrite = 2; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + target -= bytesToWrite; result = targetExhausted; break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; + case 3: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; + case 2: *--target = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6; + case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]); + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- */ + +static pdc_convers_result +pdc_convertUTF8toUTF32 ( + UTF8** sourceStart, UTF8* sourceEnd, + UTF32** targetStart, const UTF32* targetEnd, + const pdc_convers_flags flags) { + pdc_convers_result result = conversionOK; + UTF8* source = *sourceStart; + UTF32* target = *targetStart; + + (void) flags; + + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; break; + } + /* Do this check whether lenient or strict */ + if (! pdc_islegalUTF8(source, extraBytesToRead+1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 3: ch += *source++; ch <<= 6; + case 2: ch += *source++; ch <<= 6; + case 1: ch += *source++; ch <<= 6; + case 0: ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (target >= targetEnd) { + result = targetExhausted; + break; + } + if (ch <= UNI_MAX_UTF32) { + *target++ = ch; + } else if (ch > UNI_MAX_UTF32) { + *target++ = UNI_REPLACEMENT_CHAR; + } else { + if (target + 1 >= targetEnd) { + result = targetExhausted; + break; + } + ch -= halfBase; + *target++ = (ch >> halfShift) + UNI_SUR_HIGH_START; + *target++ = (ch & halfMask) + UNI_SUR_LOW_START; + } + } + *sourceStart = source; + *targetStart = target; + return result; +} +#endif + +/* --------------------------------------------------------------------- + + Note A. + The fall-through switches in UTF-8 reading code save a + temp variable, some decrements & conditionals. The switches + are equivalent to the following loop: + { + int tmpBytesToRead = extraBytesToRead+1; + do { + ch += *source++; + --tmpBytesToRead; + if (tmpBytesToRead) ch <<= 6; + } while (tmpBytesToRead > 0); + } + In UTF-8 writing code, the switches on "bytesToWrite" are + similarly unrolled loops. + + --------------------------------------------------------------------- */ + +/* + * pdc_convert_string converts a arbitrary encoded string (maybe UTF) to + * another string. + * + * The new converted string is allocated and terminated by required zeros. + * The caller is responsible for freeing the string buffer. + * + * + * LBP: low byte picking + * + * Input-Parameter: + * + * inutf: input string format (see pc_unicode.h): + * + * pdc_auto: If a BOM is recognized: + * pdc_utf8 or pdc_utf16xx resp. + * Otherwise if input encoding is specified: + * pdc_bytes + * Otherwise: + * pdc_utf16 + * + * pdc_auto2: If input encoding is not specified: + * pdc_utf16 + * Otherwise after successfull LBP: + * pdc_auto + * Otherwise + * pdc_utf16 + * + * pdc_bytes: 8-bit string. Encoding is if specified. + * + * pdc_bytes2: After successfull LBP: + * pdc_bytes + * Otherwise + * pdc_utf16 + * + * pdc_utf8: UTF-8 formatted string. + * + * pdc_utf16: If a UTF16 BOM is recognized: + * pdc_utf16be or pdc_utf16le + * Otherwise UTF-16 machine byte ordered string. + * + * pdc_utf16be UTF-16 big endian formatted string. + * + * pdc_utf16le UTF-16 little endian formatted string. + * + * inev: Encoding vector for input pdc_bytes string. + * + * instring: Input string. + * + * inlen: Length of input string in byte. + * + * oututf: Target format for output string. + * pdc_auto, pdc_auto2 and pdc_bytes2 are not supported. + * + * outev: Encoding vector for output pdc_bytes string. + * + * flags: PDC_CONV_KEEPBYTES: + * Input pdc_bytes strings will be kept differing from oututf. + * *oututf: pdc_byte. + * + * PDC_CONV_TRY7BYTES: + * UTF-8 output strings will have no BOM if every byte + * is smaller than x80. + * *oututf: pdc_byte. + * + * PDC_CONV_TRYBYTES: + * UTF-UTF-16xx output strings will be converted by LBP + * if every character is smaller than x0100. + * *oututf: pdc_byte. + * + * PDC_CONV_WITHBOM: + * UTF-8 or UTF-UTF-16xx output strings will be armed + * with an appropriate BOM. + * + * PDC_CONV_NOBOM: + * In UTF-8 or UTF-UTF-16xx output strings any BOM sequence + * will be removed. + * + * verbose: Error messages are put out. Otherwise they are saved only. + * + * Output-Parameter: + * + * oututf: Reached format for output string. + * + * outstring: Pointer of allocated output string + * + * outlen: Length of output string. + * + */ + +int +pdc_convert_string(pdc_core *pdc, + pdc_text_format inutf, pdc_encodingvector *inev, + pdc_byte *instring, int inlen, + pdc_text_format *oututf_p, pdc_encodingvector *outev, + pdc_byte **outstring, int *outlen, int flags, + pdc_bool verbose) +{ + static const char *fn = "pdc_convert_string"; + pdc_text_format oututf = *oututf_p; + pdc_text_format oututf_s; + pdc_ushort *usinstr = (pdc_ushort *) instring; + pdc_ushort uv = 0; + pdc_byte *instr = (pdc_byte *) instring; + pdc_bool inalloc = pdc_false; + pdc_bool hasbom = pdc_false; + pdc_bool toswap = pdc_false; + int errcode = 0; + int i, j, len; + + /* analyzing 2 byte textformat */ + if (inutf == pdc_auto2 || inutf == pdc_bytes2) + { + if (inutf == pdc_auto2 && !inev) + { + inutf = pdc_utf16; + } + else + { + len = inlen / 2; + if (2 * len != inlen) + { + errcode = PDC_E_CONV_ILLUTF16; + goto PDC_CONV_ERROR; + } + for (i = 0; i < len; i++) + if (usinstr[i] > 0x00FF) + break; + + /* low byte picking */ + if (i == len) + { + instr = (pdc_byte *) pdc_malloc(pdc, (size_t) (len + 2), fn); + for (i = 0; i < len; i++) + instr[i] = (pdc_byte) usinstr[i]; + instr[len] = 0; + instr[len + 1] = 0; + + inalloc = pdc_true; + instring = instr; + inlen = len; + + if (inutf == pdc_bytes2) + inutf = pdc_bytes; + else + inutf = pdc_auto; + } + else + { + inutf = pdc_utf16; + } + } + } + + /* analyzing UTF-16 textformat */ + if (inutf == pdc_utf16) + { + if (pdc_is_utf16be_unicode(instring)) + inutf = pdc_utf16be; + else if (pdc_is_utf16le_unicode(instring)) + inutf = pdc_utf16le; + } + + /* analyzing auto textformat */ + else if (inutf == pdc_auto) + { + if (pdc_is_utf8_unicode(instring)) + inutf = pdc_utf8; + else if (pdc_is_utf16be_unicode(instring)) + inutf = pdc_utf16be; + else if (pdc_is_utf16le_unicode(instring)) + inutf = pdc_utf16le; + else if (inev) + inutf = pdc_bytes; + else + inutf = pdc_utf16; + } + + /* conversion to UTF-16 by swapping */ + if ((inutf == pdc_utf16be || inutf == pdc_utf16le) && + (inutf != oututf || flags & PDC_CONV_TRYBYTES)) + { + if (inlen && + ((inutf == pdc_utf16be && !PDC_ISBIGENDIAN) || + (inutf == pdc_utf16le && PDC_ISBIGENDIAN))) + { + if (inalloc) + pdc_swap_bytes((char *) instring, inlen, NULL); + else + { + instr = (pdc_byte *) pdc_malloc(pdc, (size_t) inlen, fn); + pdc_swap_bytes((char *) instring, inlen, (char *) instr); + + inalloc = pdc_true; + instring = instr; + } + } + inutf = pdc_utf16; + } + + /* conversion to UTF-16 by inflation or encoding vector */ + if (inutf == pdc_bytes) + { + if ((oututf != pdc_bytes && !(flags & PDC_CONV_KEEPBYTES)) || + inev != NULL || outev != NULL) + { + len = 2 * inlen; + instr = (pdc_byte *) pdc_malloc(pdc, (size_t) (len + 2), fn); + usinstr = (pdc_ushort *) instr; + + for (i = 0; i < inlen; i++) + { + uv = (pdc_ushort) instring[i]; + if (inev && uv) + { + uv = inev->codes[uv]; + if (!uv) uv = 0x0020; + } + usinstr[i] = uv; + } + + if (inalloc) + pdc_free(pdc, instring); + + inalloc = pdc_true; + instring = instr; + inlen = len; + inutf = pdc_utf16; + } + else if (flags & PDC_CONV_KEEPBYTES) + { + oututf = pdc_bytes; + } + } + + /* illegal UTF-16 */ + if (inutf != pdc_bytes && inutf != pdc_utf8 && inlen % 2) + { + if (inalloc) + pdc_free(pdc, instring); + errcode = PDC_E_CONV_ILLUTF16; + goto PDC_CONV_ERROR; + } + + /* UTF conversion */ + oututf_s = oututf; + if ((oututf_s == pdc_bytes && inutf == pdc_utf8) || + oututf_s == pdc_utf16be || oututf_s == pdc_utf16le) + oututf_s = pdc_utf16; + if (inutf != oututf_s && oututf_s != pdc_bytes) + { + len = 4 * inlen + 2; + instr = (pdc_byte *) pdc_malloc(pdc, (size_t) len, fn); + + if (inlen) + { + pdc_convers_result result; + pdc_byte *instringa, *instra, *instringe, *instre; + + instringa = instring; + instringe = instring + inlen; + instra = instr; + instre = instr + len; + + if (inutf == pdc_utf8) + result = pdc_convertUTF8toUTF16( + (UTF8 **) &instringa, (UTF8 *) instringe, + (UTF16 **) &instra, (UTF16 *) instre, + strictConversion); + else + result = pdc_convertUTF16toUTF8( + (UTF16 **) &instringa, (UTF16 *) instringe, + (UTF8 **) &instra, (UTF8 *) instre, + strictConversion); + + if (inalloc) + pdc_free(pdc, instring); + + switch (result) + { + case targetExhausted: + errcode = PDC_E_CONV_MEMOVERFLOW; + break; + + case sourceExhausted: + case sourceIllegal: + errcode = PDC_E_CONV_ILLUTF; + break; + + default: + break; + } + + if (errcode) + { + pdc_free(pdc, instr); + goto PDC_CONV_ERROR; + } + + inlen = instra - instr; + } + + if (inlen + 2 != len) + instr = pdc_realloc(pdc, instr, (size_t) (inlen + 2), fn); + instr[inlen] = 0; + instr[inlen + 1] = 0; + + inalloc = pdc_true; + instring = instr; + inutf = oututf_s; + } + + if (inutf == pdc_bytes) + { + if (!inalloc) + { + instr = (pdc_byte *) pdc_malloc(pdc, (size_t) (inlen + 2), fn); + memcpy(instr, instring, (size_t) inlen); + instr[inlen] = 0; + instr[inlen + 1] = 0; + + instring = instr; + } + } + + /* trying to reduce UTF-16 string to bytes string */ + if (inutf == pdc_utf16 && + (flags & PDC_CONV_TRYBYTES || oututf == pdc_bytes)) + { + len = inlen / 2; + instr = (pdc_byte *) pdc_malloc(pdc, (size_t) (len + 2), fn); + usinstr = (pdc_ushort *) instring; + + for (i = 0; i < len; i++) + { + uv = usinstr[i]; + if (outev && uv) + uv = (pdc_ushort) pdc_get_encoding_bytecode(pdc, outev, uv); + if (uv > 0x00FF) + break; + + instr[i] = (pdc_byte) uv; + } + + if (i == len) + { + instr[len] = 0; + instr[len + 1] = 0; + + if (inalloc) + pdc_free(pdc, instring); + + inalloc = pdc_true; + instring = instr; + inlen = len; + inutf = pdc_bytes; + } + else + pdc_free(pdc, instr); + } + + /* UTF-8 format */ + if (inutf == pdc_utf8) + { + hasbom = pdc_is_utf8_unicode(instring); + + if (flags & PDC_CONV_TRY7BYTES) + { + for (i = hasbom ? 3 : 0; i < inlen; i++) + if (instring[i] > 0x7F) + break; + if (i == inlen) + { + flags &= ~PDC_CONV_WITHBOM; + flags |= PDC_CONV_NOBOM; + inutf = pdc_bytes; + } + } + + if (!inalloc || flags & PDC_CONV_WITHBOM || flags & PDC_CONV_NOBOM) + { + i = (flags & PDC_CONV_WITHBOM && !hasbom) ? 3 : 0; + j = (flags & PDC_CONV_NOBOM && hasbom) ? 3 : 0; + + len = inlen + i - j; + instr = (pdc_byte *) pdc_malloc(pdc, (size_t) (len + 1), fn); + memcpy(&instr[i], &instring[j], (size_t) (inlen - j)); + instr[len] = 0; + + if (inalloc) + pdc_free(pdc, instring); + + instring = instr; + inlen = len; + + hasbom = (flags & PDC_CONV_WITHBOM); + } + + if (hasbom) + { + instring[0] = PDF_BOM2; + instring[1] = PDF_BOM3; + instring[2] = PDF_BOM4; + } + } + + /* UTF-16 formats */ + if (inutf == pdc_utf16 || inutf == pdc_utf16be || inutf == pdc_utf16le) + { + hasbom = pdc_is_utf16be_unicode(instring) || + pdc_is_utf16le_unicode(instring); + + if (!inalloc || oututf == pdc_utf16be || oututf == pdc_utf16le || + flags & PDC_CONV_WITHBOM || flags & PDC_CONV_NOBOM) + { + i = (flags & PDC_CONV_WITHBOM && !hasbom) ? 2 : 0; + j = (flags & PDC_CONV_NOBOM && hasbom) ? 2 : 0; + + len = inlen + i - j; + instr = (pdc_byte *) pdc_malloc(pdc, (size_t) (len + 2), fn); + memcpy(&instr[i], &instring[j], (size_t) (inlen - j)); + instr[len] = 0; + instr[len + 1] = 0; + + if (inalloc) + pdc_free(pdc, instring); + + instring = instr; + inlen = len; + + hasbom = (flags & PDC_CONV_WITHBOM); + } + + i = hasbom ? 2 : 0; + if (inutf == pdc_utf16) + { + if (oututf == pdc_utf16be) + { + inutf = pdc_utf16be; + toswap = !PDC_ISBIGENDIAN; + } + if (oututf == pdc_utf16le) + { + inutf = pdc_utf16le; + toswap = PDC_ISBIGENDIAN; + } + if (toswap) + pdc_swap_bytes((char *) &instring[i], inlen - i, NULL); + } + + if (hasbom) + { + if (inutf == pdc_utf16be || + (inutf == pdc_utf16 && PDC_ISBIGENDIAN)) + { + instring[0] = PDF_BOM0; + instring[1] = PDF_BOM1; + } + if (inutf == pdc_utf16le || + (inutf == pdc_utf16 && !PDC_ISBIGENDIAN)) + { + instring[0] = PDF_BOM1; + instring[1] = PDF_BOM0; + } + } + } + + *oututf_p = inutf; + *outlen = inlen; + *outstring = instring; + return 0; + + PDC_CONV_ERROR: + *outlen = 0; + *outstring = NULL; + + if (errcode == PDC_E_CONV_ILLUTF) + { + const char *stemp = + pdc_errprintf(pdc, "%d", inutf == pdc_utf8 ? 8 : 16); + pdc_set_errmsg(pdc, errcode, stemp, 0, 0, 0); + } + else + pdc_set_errmsg(pdc, errcode, 0, 0, 0, 0); + + if (verbose) + pdc_error(pdc, -1, 0, 0, 0, 0); + + return errcode; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/pdflib/libs/pdcore/pc_unicode.h b/src/libs/pdflib/libs/pdcore/pc_unicode.h new file mode 100644 index 0000000000..aa284c9128 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_unicode.h @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_unicode.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Unicode glyph name conversion routines + * + */ + +#ifndef PC_UNICODE_H +#define PC_UNICODE_H + +#define PDC_MAX_UNICODE (int) 0x0000FFFF + +#define PDC_REPL_CHAR (int) 0x0000FFFD + +#define PDC_EURO_SIGN (pdc_ushort) 0x20AC + +/* The Unicode byte order mark (BOM) byte parts */ +#define PDF_BOM0 0376 /* '\xFE' */ +#define PDF_BOM1 0377 /* '\xFF' */ +#define PDF_BOM2 0357 /* '\xEF' */ +#define PDF_BOM3 0273 /* '\xBB' */ +#define PDF_BOM4 0277 /* '\xBF' */ + +/* + * check whether the string is plain C or UTF16 unicode + * by looking for the BOM in big-endian or little-endian format resp. + * s must not be NULL. + */ +#define pdc_is_utf16be_unicode(s) \ + (((pdc_byte *)(s))[0] == PDF_BOM0 && \ + ((pdc_byte *)(s))[1] == PDF_BOM1) + +#define pdc_is_utf16le_unicode(s) \ + (((pdc_byte *)(s))[0] == PDF_BOM1 && \ + ((pdc_byte *)(s))[1] == PDF_BOM0) + +#define pdc_is_unicode(s) pdc_is_utf16be_unicode(s) + +/* + * check whether the string is plain C or UTF8 unicode + * by looking for the BOM + * s must not be NULL. + */ +#define pdc_is_utf8_unicode(s) \ + (((pdc_byte *)(s))[0] == PDF_BOM2 && \ + ((pdc_byte *)(s))[1] == PDF_BOM3 && \ + ((pdc_byte *)(s))[2] == PDF_BOM4) + +typedef struct +{ + pdc_ushort code; + const char *glyphname; +} pdc_glyph_tab; + +typedef enum +{ + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ +} pdc_convers_result; + +typedef enum +{ + strictConversion = 0, + lenientConversion +} pdc_convers_flags; + +#define PDC_CONV_KEEPBYTES (1<<0) +#define PDC_CONV_TRY7BYTES (1<<1) +#define PDC_CONV_TRYBYTES (1<<2) +#define PDC_CONV_WITHBOM (1<<3) +#define PDC_CONV_NOBOM (1<<4) + +typedef enum +{ + pdc_auto, + pdc_auto2, + pdc_bytes, + pdc_bytes2, + pdc_utf8, + pdc_utf16, + pdc_utf16be, + pdc_utf16le +} pdc_text_format; + +pdc_ushort pdc_adobe2unicode(const char *name); + +const char *pdc_unicode2adobe(pdc_ushort uv); + +unsigned int pdc_name2sid(const char *name); + +const char *pdc_sid2name(unsigned int sid); + +pdc_bool pdc_is_std_charname(const char *name); + +pdc_ushort pdc_get_equi_unicode(pdc_ushort uv); + +int pdc_convert_string(pdc_core *pdc, + pdc_text_format inutf, pdc_encodingvector *inev, + pdc_byte *instring, int inlen, pdc_text_format *oututf_p, + pdc_encodingvector *outev, pdc_byte **outstring, int *outlen, int flags, + pdc_bool verbose); + +#endif /* PC_UNICODE_H */ diff --git a/src/libs/pdflib/libs/pdcore/pc_util.c b/src/libs/pdflib/libs/pdcore/pc_util.c new file mode 100644 index 0000000000..38262744d4 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_util.c @@ -0,0 +1,678 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_util.c,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Various utility routines + * + */ + +#include + +#include "pc_util.h" + +#ifdef AS400 +#include /* for getenv() emulation */ +#endif + +/* -------------------------- Time functions ------------------------------ */ + +#ifndef WINCE +#include +#else +#include +#endif + +void +pdc_get_timestr(char *str) +{ +#ifndef WINCE + time_t timer, gtimer; + struct tm ltime; + double diffminutes; + int utcoffset; +#else + SYSTEMTIME st; +#endif + +#ifndef WINCE + time(&timer); + + /* Calculate UTC offset with standard C functions. */ + /* gmtime(), localtime and mktime() all use the same internal */ + /* buffer. That is why it is done in multiple steps. */ + ltime = *gmtime(&timer); + gtimer = mktime(<ime); + ltime = *localtime(&timer); + ltime.tm_isdst = 0; + diffminutes = difftime(mktime(<ime), gtimer) / 60; + if (diffminutes >= 0) + utcoffset = (int)(diffminutes + 0.5); + else + utcoffset = (int)(diffminutes - 0.5); + + /* Get local time again, previous data is damaged by mktime(). */ + ltime = *localtime(&timer); + + if (utcoffset > 0) + sprintf(str, "D:%04d%02d%02d%02d%02d%02d+%02d'%02d'", + ltime.tm_year + 1900, ltime.tm_mon + 1, ltime.tm_mday, + ltime.tm_hour, ltime.tm_min, ltime.tm_sec, + utcoffset / 60, utcoffset % 60); + else if (utcoffset < 0) + sprintf(str, "D:%04d%02d%02d%02d%02d%02d-%02d'%02d'", + ltime.tm_year + 1900, ltime.tm_mon + 1, ltime.tm_mday, + ltime.tm_hour, ltime.tm_min, ltime.tm_sec, + abs(utcoffset) / 60, abs(utcoffset) % 60); + else + sprintf(str, "D:%04d%02d%02d%02d%02d%02dZ", + ltime.tm_year + 1900, ltime.tm_mon + 1, ltime.tm_mday, + ltime.tm_hour, ltime.tm_min, ltime.tm_sec); + +#else + GetLocalTime (&st); + sprintf(str, "D:%04d%02d%02d%02d%02d%02d", + st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); +#endif /* !WINCE */ +} + +/* -------------------------- Environment ------------------------------ */ + +char * +pdc_getenv(const char *name) +{ +#ifdef HAVE_ENVVARS + return getenv(name); +#else + (void) name; + + return (char *) 0; +#endif +} + + +/* -------------------------- Bit arryas ------------------------------ */ + +void +pdc_setbit(char *bitarr, int bit) +{ + bitarr[bit/8] |= (char) (1<<(bit%8)); +} + +pdc_bool +pdc_getbit(char *bitarr, int bit) +{ + return (pdc_bool) (bitarr[bit/8] & (1<<(bit%8))); +} + +void +pdc_setbit_text(char *bitarr, const pdc_byte *text, int len, + int nbits, int size) +{ + int i, bit; + pdc_ushort *ustext = (pdc_ushort *) text; + + for (i = 0; i < len; i += size) + { + if (size == sizeof(pdc_byte)) + bit = (int) text[i]; + else + bit = ustext[i/size]; + if (bit < nbits) pdc_setbit(bitarr, bit); + } +} + + +/* ---------- Get functions of integer binary data types --------------- */ + +pdc_short +pdc_get_le_short(pdc_byte *data) +{ + return (pdc_short) ((pdc_short) (data[1] << 8) | data[0]); +} + +pdc_ushort +pdc_get_le_ushort(pdc_byte *data) +{ + return (pdc_ushort) ((data[1] << 8) | data[0]); +} + +pdc_ulong +pdc_get_le_ulong3(pdc_byte *data) +{ + return (pdc_ulong) (((((data[2]) << 8) | data[1]) << 8) | data[0]); +} + +pdc_long +pdc_get_le_long(pdc_byte *data) +{ + return ((pdc_long) + (((((data[3] << 8) | data[2]) << 8) | data[1]) << 8) | data[0]); +} + +pdc_ulong +pdc_get_le_ulong(pdc_byte *data) +{ + return (pdc_ulong) + ((((((data[3] << 8) | data[2]) << 8) | data[1]) << 8) | data[0]); +} + +pdc_short +pdc_get_be_short(pdc_byte *data) +{ + return (pdc_short) ((pdc_short) (data[0] << 8) | data[1]); +} + +pdc_ushort +pdc_get_be_ushort(pdc_byte *data) +{ + return (pdc_ushort) ((data[0] << 8) | data[1]); +} + +pdc_ulong +pdc_get_be_ulong3(pdc_byte *data) +{ + return (pdc_ulong) (((((data[0]) << 8) | data[1]) << 8) | data[2]); +} + +pdc_long +pdc_get_be_long(pdc_byte *data) +{ + return ((pdc_long) + (((((data[0] << 8) | data[1]) << 8) | data[2]) << 8) | data[3]); +} + +pdc_ulong +pdc_get_be_ulong(pdc_byte *data) +{ + return (pdc_ulong) + ((((((data[0] << 8) | data[1]) << 8) | data[2]) << 8) | data[3]); +} + + +/* ----------------- String handling for Unicode too ------------------- */ + +/* strlen() for unicode strings, which are terminated by two zero bytes. + * wstrlen() returns the number of bytes in the Unicode string, + * not including the two terminating null bytes. + */ +static size_t +wstrlen(const char *s) +{ + size_t len; + + for(len = 0; + (pdc_byte) (s[len++]) != 0 || + (pdc_byte) (s[len++]) != 0; /* */ ) { + /* */ + } + + return len-2; +} + +/* + * This function returns the length in bytes for C and Unicode strings. + * Note that unlike strlen() it returns the length _including_ the + * terminator, which may be one or two null bytes. + */ +size_t +pdc_strlen(const char *text) +{ + if (pdc_is_unicode(text)) + return wstrlen(text) + 2; + else + return strlen(text) + 1; +} + + +/* Allocate a local buffer and copy the string including + * the terminating sentinel. If the string starts with the Unicode BOM + * it is considered a Unicode string, and must be terminated by + * two null bytes. Otherwise it is considered a plain C string and + * must be terminated by a single null byte. + * The caller is responsible for freeing the buffer. + */ +char * +pdc_strdup(pdc_core *pdc, const char *text) +{ + char *buf; + size_t len; + static const char fn[] = "pdc_strdup"; + + if (text == NULL) + pdc_error(pdc, PDC_E_INT_NULLARG, fn, 0, 0, 0); + + len = pdc_strlen(text); + buf = (char *) pdc_malloc(pdc, len, fn); + memcpy(buf, text, len); + + return buf; +} + +/* Put out a 2 byte string for printing on the screen by replacing + * characters < 0x20 by space. The string will be limited to 40 byte. + */ + +#define PDC_STRPRINTLEN 80 +const char * +pdc_strprint(pdc_core *pdc, const char *str, int len) +{ + pdc_byte c, tmpstr[PDC_STRPRINTLEN + 4]; + int i = 0, maxi; + + if (str) + { + if (!len) + len = (int) strlen(str); + maxi = (len > PDC_STRPRINTLEN) ? PDC_STRPRINTLEN : len; + for (i = 0; i < maxi; i++) + { + c = (pdc_byte) str[i]; + tmpstr[i] = (c < 0x20) ? (pdc_byte) ' ' : c; + } + } + tmpstr[i] = 0; + if (len > PDC_STRPRINTLEN) + strcat((char *) tmpstr, "..."); + + return pdc_errprintf(pdc, "%s", tmpstr); +} + +/* + * Split a given text string into single strings which are separated by + * arbitrary characters. This characters must be specified in a string. + * If this string is NULL, " \f\n\r\t\v" (standard white spaces) is assumed. + * + * There is the convention that text inside braces {} will be taken verbatim. + * Inside brace expressions braces must exist only in pairs. Braces are + * masked by backslash. + * + * The caller is responsible for freeing the resultated string list + * by calling the function pdc_cleanup_stringlist. + * + * Not for unicode strings. + * + * Return value: Number of strings. + * If braces aren't balanced the number is negative. + * + */ + +int +pdc_split_stringlist(pdc_core *pdc, const char *text, const char *i_separstr, + char ***stringlist) +{ + static const char fn[] = "pdc_split_stringlist"; + const char *separstr = " \f\n\r\t\v"; + const char *oldtext; + char **strlist = NULL, *newtext; + int i, it, len, jt = 0, jtb = 0, maxk = 0, count = 0, inside = 0; + + if (text == NULL) + pdc_error(pdc, PDC_E_INT_NULLARG, fn, 0, 0, 0); + + if (stringlist) + *stringlist = NULL; + if (i_separstr) + separstr = i_separstr; + + /* check for empty string */ + i = (int) strspn(text, separstr); + oldtext = &text[i]; + len = (int) strlen(oldtext); + if (!len) return 0; + + newtext = (char *) pdc_malloc(pdc, (size_t) (len + 1), fn); + for (it = 0; it <= len; it++) + { + /* check for separators */ + if (it == len) + i = 1; + else if (inside <= 0) + i = (int) strspn(&oldtext[it], separstr); + else + i = 0; + + /* close text part */ + if (i) + { + newtext[jt] = 0; + if (count == maxk) + { + maxk += 16; + strlist = (strlist == NULL) ? + (char **) pdc_malloc(pdc, maxk * sizeof(char *), fn): + (char **) pdc_realloc(pdc, strlist, maxk * + sizeof(char *), fn); + } + strlist[count] = &newtext[jtb]; + count++; + + /* Exit */ + it += i; + if (it >= len ) break; + + /* new text part */ + jt++; + jtb = jt; + } + + /* open and close brace */ + if (oldtext[it] == '{') + { + inside++; + if (inside == 1) + continue; + } + else if (oldtext[it] == '}') + { + inside--; + if (inside == 0) + continue; + } + + /* masked braces */ + if (oldtext[it] == '\\' && + (oldtext[it+1] == '{' || oldtext[it+1] == '}')) + it++; + + /* save character */ + newtext[jt] = oldtext[it]; + jt++; + } + + if (stringlist) + *stringlist = strlist; + return inside ? -count : count; +} + +void +pdc_cleanup_stringlist(pdc_core *pdc, char **stringlist) +{ + if(stringlist != NULL) + { + if(stringlist[0] != NULL) + pdc_free(pdc, stringlist[0]); + + pdc_free(pdc, stringlist); + } +} + + +/* + * Compares its arguments and returns an integer less than, + * equal to, or greater than zero, depending on whether s1 + * is lexicographically less than, equal to, or greater than s2. + * Null pointer values for s1 and s2 are treated the same as pointers + * to empty strings. + * + * Presupposition: basic character set + * + * Return value: < 0 s1 < s2; + * = 0 s1 == s2; + * > 0 s1 > s2; + * + */ +int +pdc_stricmp(const char *s1, const char *s2) +{ + char c1, c2; + + if (s1 == s2) return (0); + if (s1 == NULL) return (-1); + if (s2 == NULL) return (1); + + for (; *s1 != '\0' && *s2 != '\0'; s1++, s2++) + { + if ((c1 = *s1) == (c2 = *s2)) + continue; + + if (islower((int)c1)) c1 = (char) toupper((int)c1); + if (islower((int)c2)) c2 = (char) toupper((int)c2); + if (c1 != c2) + break; + } + return (*s1 - *s2); +} + + +/* + * Compares its arguments and returns an integer less than, + * equal to, or greater than zero, depending on whether s1 + * is lexicographically less than, equal to, or greater than s2. + * But only up to n characters compared (n less than or equal + * to zero yields equality).Null pointer values for s1 and s2 + * are treated the same as pointers to empty strings. + * + * Presupposition: basic character set + * + * Return value: < 0 s1 < s2; + * = 0 s1 == s2; + * > 0 s1 > s2; + * + */ +int +pdc_strincmp(const char *s1, const char *s2, int n) +{ + char c1, c2; + int i; + + if (s1 == s2) return (0); + if (s1 == NULL) return (-1); + if (s2 == NULL) return (1); + + for (i=0; i < n && *s1 != '\0' && *s2 != '\0'; i++, s1++, s2++) + { + if ((c1 = *s1) == (c2 = *s2)) + continue; + + if (islower((int)c1)) c1 = (char) toupper((int)c1); + if (islower((int)c2)) c2 = (char) toupper((int)c2); + if (c1 != c2) + break; + } + return ((i < n) ? (int)(*s1 - *s2) : 0); +} + +/* + * pdc_strtrim removes trailing white space characters from an input string. + * pdc_str2trim removes leading and trailing white space characters from an + * input string.. + */ +char * +pdc_strtrim(char *str) +{ + int i; + + for (i = (int) strlen(str) - 1; i >= 0; i--) + if (!isspace((unsigned char) str[i])) break; + str[i + 1] = '\0'; + + return str; +} + +char * +pdc_str2trim(char *str) +{ + int i; + + for (i = (int) strlen(str) - 1; i >= 0; i--) + if (!isspace((unsigned char) str[i])) break; + str[i + 1] = '\0'; + + for (i = 0; ; i++) + if (!isspace((unsigned char) str[i])) break; + if (i > 0) + memmove(str, &str[i], strlen(&str[i]) + 1); + + return str; +} + +void +pdc_swap_bytes(char *instring, int inlen, char *outstring) +{ + char c; + int i,j; + + if (instring == NULL) + return; + + if (outstring == NULL) + outstring = instring; + + inlen = 2 * inlen / 2; + for (i = 0; i < inlen; i++) + { + j = i; + i++; + c = instring[j]; + outstring[j] = instring[i]; + outstring[i] = c; + } +} + +/* + * Converts a null terminated and trimed string to a double number + */ +pdc_bool +pdc_str2double(const char *string, double *o_dz) +{ + const char *s = string; + double dz = 0; + int is = 1, isd = 0; + + *o_dz = 0; + + /* sign */ + if (*s == '-') + { + is = -1; + s++; + } + else if (*s == '+') + s++; + + if (!*s) + return pdc_false; + + /* places before decimal point */ + isd = isdigit(*s); + if (isd) + { + do + { + dz = 10 * dz + *s - '0'; + s++; + } + while (isdigit(*s)); + } + + /* decimal point */ + if (*s == '.' || *s == ',') + { + const char *sa; + double adz = 0; + + s++; + isd = isdigit(*s); + if (!isd) + return pdc_false; + + /* places after decimal point */ + sa = s; + do + { + adz = 10 * adz + *s - '0'; + s++; + } + while (isdigit(*s)); + dz += adz / pow(10.0, (double)(s - sa)); + } + + /* power sign */ + if (*s == 'e' || *s == 'E') + { + s++; + if (!isd) + return pdc_false; + + /* sign */ + if (!*s) + { + dz *= 10; + } + else + { + int isp = 1; + double pdz = 0, pdl = log10(dz); + + if (*s == '-') + { + isp = -1; + s++; + } + else if (*s == '+') + s++; + + if (!isdigit(*s)) + return pdc_false; + do + { + pdz = 10 * pdz + *s - '0'; + s++; + } + while (isdigit(*s)); + + + if (*s || fabs(pdl + pdz) > 300.0) + return pdc_false; + + dz *= pow(10.0, isp * pdz); + } + } + else if(*s) + { + return pdc_false; + } + + *o_dz = is * dz; + return pdc_true; +} + +pdc_bool +pdc_str2integer(const char *string, int *o_iz) +{ + double dz; + + if (pdc_str2double(string, &dz) == pdc_true && fabs(dz) <= INT_MAX) + { + *o_iz = (int) dz; + if ((double) *o_iz == dz) + return pdc_true; + } + + *o_iz = 0; + return pdc_false; +} + +/* --------------------------- math --------------------------- */ + +float +pdc_min(float a, float b) +{ + return (a < b ? a : b); +} + +float +pdc_max(float a, float b) +{ + return (a > b ? a : b); +} diff --git a/src/libs/pdflib/libs/pdcore/pc_util.h b/src/libs/pdflib/libs/pdcore/pc_util.h new file mode 100644 index 0000000000..ab8ac0cb11 --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pc_util.h @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pc_util.h,v 1.1 2004/10/06 17:51:27 laplace Exp $ + * + * Various utility routines + * + */ + +#ifndef PC_UTIL_H +#define PC_UTIL_H + +#include +#include +#include +#include +#include +#include +#include + +#include "pc_config.h" +#include "pc_core.h" +#include "pc_ebcdic.h" +#include "pc_encoding.h" +#include "pc_output.h" +#include "pc_unicode.h" + +#define PDC_GET_SHORT pdc_get_le_short +#define PDC_GET_USHORT pdc_get_le_ushort +#define PDC_GET_WORD pdc_get_le_ushort +#define PDC_GET_DWORD pdc_get_le_ulong +#define PDC_GET_DWORD3 pdc_get_le_ulong3 +#define PDC_GET_LONG pdc_get_le_long +#define PDC_GET_ULONG pdc_get_le_ulong + +#define PDC_TIME_SBUF_SIZE 50 +void pdc_get_timestr(char *str); + +void pdc_setbit(char *bitarr, int bit); +pdc_bool pdc_getbit(char *bitarr, int bit); +void pdc_setbit_text(char *bitarr, const unsigned char *text, + int len, int nbits, int size); + +pdc_short pdc_get_le_short(pdc_byte *data); +pdc_ushort pdc_get_le_ushort(pdc_byte *data); +pdc_long pdc_get_le_long(pdc_byte *data); +pdc_ulong pdc_get_le_ulong3(pdc_byte *data); +pdc_ulong pdc_get_le_ulong(pdc_byte *data); +pdc_short pdc_get_be_short(pdc_byte *data); +pdc_ushort pdc_get_be_ushort(pdc_byte *data); +pdc_long pdc_get_be_long(pdc_byte *data); +pdc_ulong pdc_get_be_ulong3(pdc_byte *data); +pdc_ulong pdc_get_be_ulong(pdc_byte *data); + +size_t pdc_strlen(const char *text); +char *pdc_getenv(const char *name); +char *pdc_strdup(pdc_core *pdc, const char *text); +const char *pdc_strprint(pdc_core *pdc, const char *str, int len); +int pdc_split_stringlist(pdc_core *pdc, const char *text, + const char *i_separstr, char ***stringlist); +void pdc_cleanup_stringlist(pdc_core *pdc, char **stringlist); +int pdc_stricmp(const char *s1, const char *s2); +int pdc_strincmp(const char *s1, const char *s2, int n); +char *pdc_strtrim(char *m_str); +char *pdc_str2trim(char *m_str); +void pdc_swap_bytes(char *instring, int inlen, char *outstring); +pdc_bool pdc_str2double(const char *string, double *o_dz); +pdc_bool pdc_str2integer(const char *string, int *o_iz); + + +float pdc_min(float a, float b); +float pdc_max(float a, float b); + +#endif /* PC_UTIL_H */ diff --git a/src/libs/pdflib/libs/pdcore/pdcore.dsp b/src/libs/pdflib/libs/pdcore/pdcore.dsp new file mode 100644 index 0000000000..e23d1e8e4d --- /dev/null +++ b/src/libs/pdflib/libs/pdcore/pdcore.dsp @@ -0,0 +1,352 @@ +# Microsoft Developer Studio Project File - Name="pdcore" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pdcore - Win32 Debug DLL +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pdcore.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pdcore.mak" CFG="pdcore - Win32 Debug DLL" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pdcore - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Release mtDLL" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Release PSP" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Release mtDLL PSP" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Debug PSP" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Release DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Debug PSP DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Debug DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "pdcore - Win32 Release PSP DLL" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pdcore - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Release mtDLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL" +# PROP BASE Intermediate_Dir "Release_mtDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL" +# PROP Intermediate_Dir "Release_mtDLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "..\pdflib" /I "..\flate" /I "..\tiff" /I "..\png" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Release PSP" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_PSP" +# PROP BASE Intermediate_Dir "Release_PSP" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_PSP" +# PROP Intermediate_Dir "Release_PSP" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Release mtDLL PSP" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL_PSP" +# PROP BASE Intermediate_Dir "Release_mtDLL_PSP" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL_PSP" +# PROP Intermediate_Dir "Release_mtDLL_PSP" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Debug PSP" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_PSP" +# PROP BASE Intermediate_Dir "Debug_PSP" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_PSP" +# PROP Intermediate_Dir "Debug_PSP" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"pdcore.lib" +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_DLL" +# PROP BASE Intermediate_Dir "Release_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_DLL" +# PROP Intermediate_Dir "Release_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"pdcore.lib" +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Debug PSP DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_PSP_DLL" +# PROP BASE Intermediate_Dir "Debug_PSP_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_PSP_DLL" +# PROP Intermediate_Dir "Debug_PSP_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"pdcore.lib" +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_DLL" +# PROP BASE Intermediate_Dir "Debug_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_DLL" +# PROP Intermediate_Dir "Debug_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"pdcore.lib" +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ELSEIF "$(CFG)" == "pdcore - Win32 Release PSP DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_PSP_DLL" +# PROP BASE Intermediate_Dir "Release_PSP_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_PSP_DLL" +# PROP Intermediate_Dir "Release_PSP_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdi" /I "../flate" /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"pdcore.lib" +# ADD LIB32 /nologo /out:"pdcore.lib" + +!ENDIF + +# Begin Target + +# Name "pdcore - Win32 Release" +# Name "pdcore - Win32 Debug" +# Name "pdcore - Win32 Release mtDLL" +# Name "pdcore - Win32 Release PSP" +# Name "pdcore - Win32 Release mtDLL PSP" +# Name "pdcore - Win32 Debug PSP" +# Name "pdcore - Win32 Release DLL" +# Name "pdcore - Win32 Debug PSP DLL" +# Name "pdcore - Win32 Debug DLL" +# Name "pdcore - Win32 Release PSP DLL" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\pc_arc4.c +# End Source File +# Begin Source File + +SOURCE=.\pc_core.c +# End Source File +# Begin Source File + +SOURCE=.\pc_corefont.c +# End Source File +# Begin Source File + +SOURCE=.\pc_crypt.c +# End Source File +# Begin Source File + +SOURCE=.\pc_ebcdic.c +# End Source File +# Begin Source File + +SOURCE=.\pc_encoding.c +# End Source File +# Begin Source File + +SOURCE=.\pc_file.c +# End Source File +# Begin Source File + +SOURCE=.\pc_font.c +# End Source File +# Begin Source File + +SOURCE=.\pc_geom.c +# End Source File +# Begin Source File + +SOURCE=.\pc_md5.c +# End Source File +# Begin Source File + +SOURCE=.\pc_optparse.c +# End Source File +# Begin Source File + +SOURCE=.\pc_output.c +# End Source File +# Begin Source File + +SOURCE=.\pc_sbuf.c +# End Source File +# Begin Source File + +SOURCE=.\pc_scope.c +# End Source File +# Begin Source File + +SOURCE=.\pc_unicode.c +# End Source File +# Begin Source File + +SOURCE=.\pc_util.c +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/pdflib/Jamfile b/src/libs/pdflib/libs/pdflib/Jamfile new file mode 100644 index 0000000000..eab3ce7ad9 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/Jamfile @@ -0,0 +1,49 @@ +SubDir OBOS_TOP src libs pdflib libs pdflib ; + +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs pdcore ] ; +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs flate ] ; +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs png ] ; +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs tiff ] ; + +UseLibraryHeaders pdflib ; + +StaticLibrary pdf : + p_afm.c + p_annots.c + p_basic.c + p_block.c + p_bmp.c + p_ccitt.c + p_cid.c + p_color.c + p_draw.c + p_encoding.c + p_filter.c + p_font.c + p_gif.c + p_gstate.c + p_hostfont.c + p_hyper.c + p_icc.c + p_icclib.c + p_image.c + p_jpeg.c + p_kerning.c + p_params.c + p_pattern.c + p_pdi.c + p_pfm.c + p_png.c + p_resource.c + p_shading.c + p_subsett.c + p_template.c + p_text.c + p_tiff.c + p_truetype.c + p_type1.c + p_type3.c + p_xgstate.c +: STATIC_LIBRARY_DIR +; + diff --git a/src/libs/pdflib/libs/pdflib/Makefile b/src/libs/pdflib/libs/pdflib/Makefile new file mode 100644 index 0000000000..de9c11f10e --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/Makefile @@ -0,0 +1,100 @@ +# Makefile for PDFlib +# $Id: Makefile,v 1.1 2004/10/06 17:46:49 laplace Exp $ + +top_builddir = ../.. + +include ../../config/mkcommon.inc + +INCLUDES = $(PDFLIBINC) $(PDCORELIBINC) $(TIFFLIBINC) $(FLATELIBINC)\ + $(PNGLIBINC) $(PDILIBINC) + +LIBNAME = $(PDFLIB_LINK) + +SRC = \ + $(srcdir)/p_afm.c \ + $(srcdir)/p_annots.c \ + $(srcdir)/p_block.c \ + $(srcdir)/p_bmp.c \ + $(srcdir)/p_ccitt.c \ + $(srcdir)/p_cid.c \ + $(srcdir)/p_color.c \ + $(srcdir)/p_draw.c \ + $(srcdir)/p_encoding.c \ + $(srcdir)/p_filter.c \ + $(srcdir)/p_font.c \ + $(srcdir)/p_gif.c \ + $(srcdir)/p_gstate.c \ + $(srcdir)/p_hostfont.c \ + $(srcdir)/p_hyper.c \ + $(srcdir)/p_icc.c \ + $(srcdir)/p_icclib.c \ + $(srcdir)/p_image.c \ + $(srcdir)/p_jpeg.c \ + $(srcdir)/p_kerning.c \ + $(srcdir)/p_params.c \ + $(srcdir)/p_pattern.c \ + $(srcdir)/p_pdi.c \ + $(srcdir)/p_pfm.c \ + $(srcdir)/p_png.c \ + $(srcdir)/p_resource.c \ + $(srcdir)/p_shading.c \ + $(srcdir)/p_subsett.c \ + $(srcdir)/p_template.c \ + $(srcdir)/p_text.c \ + $(srcdir)/p_tiff.c \ + $(srcdir)/p_truetype.c \ + $(srcdir)/p_type1.c \ + $(srcdir)/p_type3.c \ + $(srcdir)/p_xgstate.c + +OBJS = \ + $(srcdir)/p_afm$(LO) \ + $(srcdir)/p_annots$(LO) \ + $(srcdir)/p_block$(LO) \ + $(srcdir)/p_bmp$(LO) \ + $(srcdir)/p_ccitt$(LO) \ + $(srcdir)/p_cid$(LO) \ + $(srcdir)/p_color$(LO) \ + $(srcdir)/p_draw$(LO) \ + $(srcdir)/p_encoding$(LO)\ + $(srcdir)/p_filter$(LO) \ + $(srcdir)/p_font$(LO) \ + $(srcdir)/p_gif$(LO) \ + $(srcdir)/p_gstate$(LO) \ + $(srcdir)/p_hostfont$(LO)\ + $(srcdir)/p_hyper$(LO) \ + $(srcdir)/p_icc$(LO) \ + $(srcdir)/p_icclib$(LO) \ + $(srcdir)/p_image$(LO) \ + $(srcdir)/p_jpeg$(LO) \ + $(srcdir)/p_kerning$(LO) \ + $(srcdir)/p_params$(LO) \ + $(srcdir)/p_pattern$(LO) \ + $(srcdir)/p_pdi$(LO) \ + $(srcdir)/p_pfm$(LO) \ + $(srcdir)/p_png$(LO) \ + $(srcdir)/p_resource$(LO)\ + $(srcdir)/p_shading$(LO) \ + $(srcdir)/p_subsett$(LO) \ + $(srcdir)/p_template$(LO)\ + $(srcdir)/p_text$(LO) \ + $(srcdir)/p_tiff$(LO) \ + $(srcdir)/p_truetype$(LO)\ + $(srcdir)/p_type1$(LO) \ + $(srcdir)/p_type3$(LO) \ + $(srcdir)/p_xgstate$(LO) + +include ../../config/mklibs.inc + +MAINLIBNAME = lib$(PDFLIBNAME)$(LA) + +MAINSRC = $(srcdir)/p_basic.c +MAINOBJ = $(srcdir)/p_basic$(LO) +MAININC = pdflib.h + +INTERNALLIBS = $(PDCORELIBLINK) $(PNGLIBLINK) $(FLATELIBLINK) $(TIFFLIBLINK)\ + $(PDILIBLINK) $(JPEGLIBLINK) $(PDFLIB_LINK) + +include ../../config/mkmainlib.inc + +# Automatically generated dependencies diff --git a/src/libs/pdflib/libs/pdflib/PDFlib.bpf b/src/libs/pdflib/libs/pdflib/PDFlib.bpf new file mode 100644 index 0000000000..4b134c56d1 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/PDFlib.bpf @@ -0,0 +1,120 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +//--------------------------------------------------------------------------- +USEUNIT("p_xgstate.c"); +USEUNIT("p_afm.c"); +USEUNIT("p_annots.c"); +USEUNIT("p_basic.c"); +USEUNIT("p_block.c"); +USEUNIT("p_bmp.c"); +USEUNIT("p_ccitt.c"); +USEUNIT("p_cid.c"); +USEUNIT("p_color.c"); +USEUNIT("p_draw.c"); +USEUNIT("p_encoding.c"); +USEUNIT("p_filter.c"); +USEUNIT("p_font.c"); +USEUNIT("p_gif.c"); +USEUNIT("p_gstate.c"); +USEUNIT("p_hostfont.c"); +USEUNIT("p_hyper.c"); +USEUNIT("p_icc.c"); +USEUNIT("p_icclib.c"); +USEUNIT("p_image.c"); +USEUNIT("p_jpeg.c"); +USEUNIT("p_kerning.c"); +USEUNIT("p_params.c"); +USEUNIT("p_pattern.c"); +USEUNIT("p_pdi.c"); +USEUNIT("p_pfm.c"); +USEUNIT("p_png.c"); +USEUNIT("p_resource.c"); +USEUNIT("p_shading.c"); +USEUNIT("p_subsett.c"); +USEUNIT("p_template.c"); +USEUNIT("p_text.c"); +USEUNIT("p_tiff.c"); +USEUNIT("p_truetype.c"); +USEUNIT("p_type1.c"); +USEUNIT("p_type3.c"); +USEUNIT("..\flate\zutil.c"); +USEUNIT("..\flate\adler32.c"); +USEUNIT("..\flate\compress.c"); +USEUNIT("..\flate\crc32.c"); +USEUNIT("..\flate\deflate.c"); +USEUNIT("..\flate\infblock.c"); +USEUNIT("..\flate\infcodes.c"); +USEUNIT("..\flate\inffast.c"); +USEUNIT("..\flate\inflate.c"); +USEUNIT("..\flate\inftrees.c"); +USEUNIT("..\flate\infutil.c"); +USEUNIT("..\flate\trees.c"); +USEUNIT("..\flate\uncompr.c"); +USEUNIT("..\pdcore\pc_util.c"); +USEUNIT("..\pdcore\pc_arc4.c"); +USEUNIT("..\pdcore\pc_core.c"); +USEUNIT("..\pdcore\pc_corefont.c"); +USEUNIT("..\pdcore\pc_crypt.c"); +USEUNIT("..\pdcore\pc_ebcdic.c"); +USEUNIT("..\pdcore\pc_encoding.c"); +USEUNIT("..\pdcore\pc_file.c"); +USEUNIT("..\pdcore\pc_font.c"); +USEUNIT("..\pdcore\pc_geom.c"); +USEUNIT("..\pdcore\pc_md5.c"); +USEUNIT("..\pdcore\pc_optparse.c"); +USEUNIT("..\pdcore\pc_output.c"); +USEUNIT("..\pdcore\pc_sbuf.c"); +USEUNIT("..\pdcore\pc_scope.c"); +USEUNIT("..\pdcore\pc_unicode.c"); +USEUNIT("..\png\pngvcrd.c"); +USEUNIT("..\png\png.c"); +USEUNIT("..\png\pngerror.c"); +USEUNIT("..\png\pngget.c"); +USEUNIT("..\png\pngmem.c"); +USEUNIT("..\png\pngread.c"); +USEUNIT("..\png\pngrio.c"); +USEUNIT("..\png\pngrtran.c"); +USEUNIT("..\png\pngrutil.c"); +USEUNIT("..\png\pngset.c"); +USEUNIT("..\png\pngtrans.c"); +USEUNIT("..\tiff\tif_zip.c"); +USEUNIT("..\tiff\tif_auxx.c"); +USEUNIT("..\tiff\tif_close.c"); +USEUNIT("..\tiff\tif_codec.c"); +USEUNIT("..\tiff\tif_compress.c"); +USEUNIT("..\tiff\tif_dir.c"); +USEUNIT("..\tiff\tif_dirinfo.c"); +USEUNIT("..\tiff\tif_dirread.c"); +USEUNIT("..\tiff\tif_dirwrite.c"); +USEUNIT("..\tiff\tif_dumpmode.c"); +USEUNIT("..\tiff\tif_error.c"); +USEUNIT("..\tiff\tif_fax3.c"); +USEUNIT("..\tiff\tif_fax3sm.c"); +USEUNIT("..\tiff\tif_flush.c"); +USEUNIT("..\tiff\tif_getimage.c"); +USEUNIT("..\tiff\tif_jpeg.c"); +USEUNIT("..\tiff\tif_luv.c"); +USEUNIT("..\tiff\tif_lzw.c"); +USEUNIT("..\tiff\tif_next.c"); +USEUNIT("..\tiff\tif_ojpeg.c"); +USEUNIT("..\tiff\tif_open.c"); +USEUNIT("..\tiff\tif_packbits.c"); +USEUNIT("..\tiff\tif_pixarlog.c"); +USEUNIT("..\tiff\tif_predict.c"); +USEUNIT("..\tiff\tif_print.c"); +USEUNIT("..\tiff\tif_read.c"); +USEUNIT("..\tiff\tif_strip.c"); +USEUNIT("..\tiff\tif_swab.c"); +USEUNIT("..\tiff\tif_thunder.c"); +USEUNIT("..\tiff\tif_tile.c"); +USEUNIT("..\tiff\tif_unix.c"); +USEUNIT("..\tiff\tif_version.c"); +USEUNIT("..\tiff\tif_warning.c"); +USEUNIT("..\tiff\tif_write.c"); +//--------------------------------------------------------------------------- +#define Library + +// Um eine Datei zur Bibliothek hinzuzufügen, wählen Sie im Projektmenü 'Zum Projekt hinzufügen'. + diff --git a/src/libs/pdflib/libs/pdflib/PDFlib.bpr b/src/libs/pdflib/libs/pdflib/PDFlib.bpr new file mode 100644 index 0000000000..13edc931fd --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/PDFlib.bpr @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1031 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=6 +Item0=..\pdcore;$(BCB)\include;$(BCB)\include\vcl;..\tiff;..\flate;..\png;..\pdi +Item1=..\pdcore;$(BCB)\include;$(BCB)\include\vcl;..\tiff;..\flate;..\png;pdi +Item2=..\pdcore;$(BCB)\include;$(BCB)\include\vcl;..\tiff;..\flate;..\png;.\pdi +Item3=..\pdcore;$(BCB)\include;$(BCB)\include\vcl;..\tiff;..\flate;..\png +Item4=..\pdcore;$(BCB)\include;$(BCB)\include\vcl;..\tiff;..\flate;..\png;..\pdcore +Item5=$(BCB)\include;$(BCB)\include\vcl;..\tiff;..\flate;..\png + +[HistoryLists\hlLibraryPath] +Count=4 +Item0=..\tiff;..\png;..\pdcore;..\flate;$(BCB)\lib\obj;$(BCB)\lib +Item1=$(BCB)\lib\obj;$(BCB)\lib +Item2=..\pdcore;..\flate;..\png;..\tiff;$(BCB)\lib\obj;$(BCB)\lib +Item3=..\tiff;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=1 +Item0=WIN32;_WINDOWS;_MBCS;_MT + +[HistoryLists\hlIntOutputDir] +Count=2 +Item0=Release_BCC +Item1=Release + +[HistoryLists\hlFinalOutputDir] +Count=3 +Item0=Release_BCC\ +Item1=Release_BCC +Item2=.\ + +[HistoryLists\hIBPIOutputDir] +Count=3 +Item0=D:\cvs\pdflib-x\libs\pdflib\Release_BCC\ +Item1=Release_BCC +Item2=. + +[HistoryLists\hlTlibPageSize] +Count=2 +Item0=32 +Item1=0x0010 + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + + \ No newline at end of file diff --git a/src/libs/pdflib/libs/pdflib/PDFlib_dll.bpf b/src/libs/pdflib/libs/pdflib/PDFlib_dll.bpf new file mode 100644 index 0000000000..37c5e8bc00 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/PDFlib_dll.bpf @@ -0,0 +1,114 @@ +USEUNIT("p_xgstate.c"); +USEUNIT("p_afm.c"); +USEUNIT("p_annots.c"); +USEUNIT("p_basic.c"); +USEUNIT("p_block.c"); +USEUNIT("p_bmp.c"); +USEUNIT("p_ccitt.c"); +USEUNIT("p_cid.c"); +USEUNIT("p_color.c"); +USEUNIT("p_draw.c"); +USEUNIT("p_encoding.c"); +USEUNIT("p_filter.c"); +USEUNIT("p_font.c"); +USEUNIT("p_gif.c"); +USEUNIT("p_gstate.c"); +USEUNIT("p_hostfont.c"); +USEUNIT("p_hyper.c"); +USEUNIT("p_icc.c"); +USEUNIT("p_icclib.c"); +USEUNIT("p_image.c"); +USEUNIT("p_jpeg.c"); +USEUNIT("p_kerning.c"); +USEUNIT("p_params.c"); +USEUNIT("p_pattern.c"); +USEUNIT("p_pdi.c"); +USEUNIT("p_pfm.c"); +USEUNIT("p_png.c"); +USEUNIT("p_resource.c"); +USEUNIT("p_shading.c"); +USEUNIT("p_subsett.c"); +USEUNIT("p_template.c"); +USEUNIT("p_text.c"); +USEUNIT("p_tiff.c"); +USEUNIT("p_truetype.c"); +USEUNIT("p_type1.c"); +USEUNIT("p_type3.c"); +USEUNIT("..\flate\zutil.c"); +USEUNIT("..\flate\adler32.c"); +USEUNIT("..\flate\compress.c"); +USEUNIT("..\flate\crc32.c"); +USEUNIT("..\flate\deflate.c"); +USEUNIT("..\flate\infblock.c"); +USEUNIT("..\flate\infcodes.c"); +USEUNIT("..\flate\inffast.c"); +USEUNIT("..\flate\inflate.c"); +USEUNIT("..\flate\inftrees.c"); +USEUNIT("..\flate\infutil.c"); +USEUNIT("..\flate\trees.c"); +USEUNIT("..\flate\uncompr.c"); +USEUNIT("..\pdcore\pc_util.c"); +USEUNIT("..\pdcore\pc_arc4.c"); +USEUNIT("..\pdcore\pc_core.c"); +USEUNIT("..\pdcore\pc_corefont.c"); +USEUNIT("..\pdcore\pc_crypt.c"); +USEUNIT("..\pdcore\pc_ebcdic.c"); +USEUNIT("..\pdcore\pc_encoding.c"); +USEUNIT("..\pdcore\pc_file.c"); +USEUNIT("..\pdcore\pc_font.c"); +USEUNIT("..\pdcore\pc_geom.c"); +USEUNIT("..\pdcore\pc_md5.c"); +USEUNIT("..\pdcore\pc_optparse.c"); +USEUNIT("..\pdcore\pc_output.c"); +USEUNIT("..\pdcore\pc_sbuf.c"); +USEUNIT("..\pdcore\pc_scope.c"); +USEUNIT("..\pdcore\pc_unicode.c"); +USEUNIT("..\png\pngvcrd.c"); +USEUNIT("..\png\png.c"); +USEUNIT("..\png\pngerror.c"); +USEUNIT("..\png\pngget.c"); +USEUNIT("..\png\pngmem.c"); +USEUNIT("..\png\pngread.c"); +USEUNIT("..\png\pngrio.c"); +USEUNIT("..\png\pngrtran.c"); +USEUNIT("..\png\pngrutil.c"); +USEUNIT("..\png\pngset.c"); +USEUNIT("..\png\pngtrans.c"); +USEUNIT("..\tiff\tif_zip.c"); +USEUNIT("..\tiff\tif_auxx.c"); +USEUNIT("..\tiff\tif_close.c"); +USEUNIT("..\tiff\tif_codec.c"); +USEUNIT("..\tiff\tif_compress.c"); +USEUNIT("..\tiff\tif_dir.c"); +USEUNIT("..\tiff\tif_dirinfo.c"); +USEUNIT("..\tiff\tif_dirread.c"); +USEUNIT("..\tiff\tif_dirwrite.c"); +USEUNIT("..\tiff\tif_dumpmode.c"); +USEUNIT("..\tiff\tif_error.c"); +USEUNIT("..\tiff\tif_fax3.c"); +USEUNIT("..\tiff\tif_fax3sm.c"); +USEUNIT("..\tiff\tif_flush.c"); +USEUNIT("..\tiff\tif_getimage.c"); +USEUNIT("..\tiff\tif_jpeg.c"); +USEUNIT("..\tiff\tif_luv.c"); +USEUNIT("..\tiff\tif_lzw.c"); +USEUNIT("..\tiff\tif_next.c"); +USEUNIT("..\tiff\tif_ojpeg.c"); +USEUNIT("..\tiff\tif_open.c"); +USEUNIT("..\tiff\tif_packbits.c"); +USEUNIT("..\tiff\tif_pixarlog.c"); +USEUNIT("..\tiff\tif_predict.c"); +USEUNIT("..\tiff\tif_print.c"); +USEUNIT("..\tiff\tif_read.c"); +USEUNIT("..\tiff\tif_strip.c"); +USEUNIT("..\tiff\tif_swab.c"); +USEUNIT("..\tiff\tif_thunder.c"); +USEUNIT("..\tiff\tif_tile.c"); +USEUNIT("..\tiff\tif_unix.c"); +USEUNIT("..\tiff\tif_version.c"); +USEUNIT("..\tiff\tif_warning.c"); +USEUNIT("..\tiff\tif_write.c"); +//--------------------------------------------------------------------------- +Diese Datei wird nur vom Projekt-Manager verwendet und sollte wie die Projektdatei behandelt werden + +DllMain diff --git a/src/libs/pdflib/libs/pdflib/PDFlib_dll.bpr b/src/libs/pdflib/libs/pdflib/PDFlib_dll.bpr new file mode 100644 index 0000000000..604c54968f --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/PDFlib_dll.bpr @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=5 +MinorVer=0 +Release=3 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=3 +Locale=1033 +CodePage=1252 + +[Version Info Keys] +CompanyName=PDFlib GmbH. +FileDescription=www.pdflib.com +FileVersion=5.0.3.3 +InternalName= +LegalCopyright=(c) 1997-2000 Thomas Merz +LegalTrademarks= +OriginalFilename=pdflib.dll +ProductName=PDFlib for Windows +ProductVersion=5.0.3 +Comments= + +[HistoryLists\hlIncludePath] +Count=2 +Item0=$(BCB)\include;$(BCB)\include\vcl;..\png;..\flate;..\tiff;..\pdi;..\pdcore +Item1=$(BCB)\include;$(BCB)\include\vcl;..\png;..\flate;..\tiff + +[HistoryLists\hlLibraryPath] +Count=2 +Item0=..\tiff;..\png;..\pdcore;..\flate;$(BCB)\lib\obj;$(BCB)\lib +Item1=..\png;..\flate;..\tiff;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=1 +Item0=WIN32;_WINDOWS;_MBCS;_MT;PDFLIB_EXPORTS;NDEBUG;_LIB + +[HistoryLists\hlIntOutputDir] +Count=1 +Item0=Release_dll_BCC + +[HistoryLists\hlFinalOutputDir] +Count=1 +Item0=Release_dll_BCC\ + +[HistoryLists\hIBPIOutputDir] +Count=2 +Item0=Release_dll_BCC\ +Item1=F:\Tommy\pdflib-win-x\pdflib\Release_dll_BCC\ + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + + \ No newline at end of file diff --git a/src/libs/pdflib/libs/pdflib/PDFlib_dll.res b/src/libs/pdflib/libs/pdflib/PDFlib_dll.res new file mode 100644 index 0000000000..8336b22a21 Binary files /dev/null and b/src/libs/pdflib/libs/pdflib/PDFlib_dll.res differ diff --git a/src/libs/pdflib/libs/pdflib/p_afm.c b/src/libs/pdflib/libs/pdflib/p_afm.c new file mode 100644 index 0000000000..01eecbc4e6 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_afm.c @@ -0,0 +1,539 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_afm.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib AFM parsing routines + * + */ + +#include "p_intern.h" +#include "p_font.h" + +#define AFM_LINEBUF 4096 + +#define AFM_SEPARATORS "\f\n\r\t\v ,:;" + +#define AFM_MINNUMGLYPHS 5 + +/* The values of each of these enumerated items correspond to an entry in the + * table of strings defined below. Therefore, if you add a new string as + * new keyword into the keyStrings table, you must also add a corresponding + * pdf_afmkey AND it MUST be in the same position! + * + * IMPORTANT: since the sorting algorithm is a binary search, the strings of + * keywords must be placed in lexicographical order, below. [Therefore, the + * enumerated items are not necessarily in lexicographical order, depending + * on the name chosen. BUT, they must be placed in the same position as the + * corresponding key string.] The NOPE shall remain in the last position, + * since it does not correspond to any key string. + */ + +#ifndef PDFLIB_EBCDIC +typedef enum { + ASCENDER, CHARBBOX, CODE, COMPCHAR, CAPHEIGHT, CHARWIDTH, CHARACTERS, + CHARACTERSET, + COMMENT, DESCENDER, ENCODINGSCHEME, ENDCHARMETRICS, ENDCOMPOSITES, + ENDFONTMETRICS, ENDKERNDATA, ENDKERNPAIRS, ENDTRACKKERN, + FAMILYNAME, FONTBBOX, FONTNAME, FULLNAME, ISFIXEDPITCH, + ITALICANGLE, KERNPAIR, KERNPAIRXAMT, LIGATURE, CHARNAME, + NOTICE, COMPCHARPIECE, STARTCHARMETRICS, STARTCOMPOSITES, + STARTFONTMETRICS, STARTKERNDATA, STARTKERNPAIRS, + STARTTRACKKERN, STDHW, STDVW, TRACKKERN, UNDERLINEPOSITION, + UNDERLINETHICKNESS, VERSION, XYWIDTH, XWIDTH, WEIGHT, XHEIGHT, + NOPE +} pdf_afmkey; + +/* keywords for the system: + * This a table of all of the current strings that are vaild AFM keys. + * Each entry can be referenced by the appropriate pdf_afmkey value (an + * enumerated data type defined above). If you add a new keyword here, + * a corresponding pdf_afmkey MUST be added to the enumerated data type + * defined above, AND it MUST be added in the same position as the + * string is in this table. + * + * IMPORTANT: since the sorting algorithm is a binary search, the keywords + * must be placed in lexicographical order. And, NULL should remain at the + * end. + */ + +static const char *keyStrings[] = { + "Ascender", "B", "C", "CC", "CapHeight", "CharWidth", "Characters", + "CharacterSet", + "Comment", "Descender", "EncodingScheme", "EndCharMetrics", "EndComposites", + "EndFontMetrics", "EndKernData", "EndKernPairs", "EndTrackKern", + "FamilyName", "FontBBox", "FontName", "FullName", "IsFixedPitch", + "ItalicAngle", "KP", "KPX", "L", "N", + "Notice", "PCC", "StartCharMetrics", "StartComposites", + "StartFontMetrics", "StartKernData", "StartKernPairs", + "StartTrackKern", "StdHW", "StdVW", "TrackKern", "UnderlinePosition", + "UnderlineThickness", "Version", "W", "WX", "Weight", "XHeight" +}; + +#else /* !PDFLIB_EBCDIC */ +#endif /* PDFLIB_EBCDIC */ + +static pdc_bool +pdf_parse_afm( + PDF *p, + pdc_file *fp, + pdc_font *font, + const char *fontname, + const char *filename) +{ + static const char fn[] = "pdf_parse_afm"; + char **wordlist, *keyword, *arg1; + char line[AFM_LINEBUF]; + int i, cmp, lo, hi, nwords, nglyphs = 0, nline = 0; + int tablen = ((sizeof keyStrings) / (sizeof (char *))); + double dz; + pdf_afmkey keynumber; + pdc_glyphwidth *glw; + + (void) fontname; + + + /* read loop. because of Mac files we use pdc_fgets_comp */ + while (pdc_fgets_comp(line, AFM_LINEBUF, fp) != NULL) + { + /* split line */ + nline++; + nwords = pdc_split_stringlist(p->pdc, line, AFM_SEPARATORS, &wordlist); + if (!nwords) continue; + keyword = wordlist[0]; + + /* find keynumber */ + lo = 0; + hi = tablen; + keynumber = NOPE; + while (lo < hi) + { + i = (lo + hi) / 2; + cmp = strcmp(keyword, keyStrings[i]); + + if (cmp == 0) + { + keynumber = (pdf_afmkey) i; + break; + } + + if (cmp < 0) + hi = i; + else + lo = i + 1; + } + + /* unkown key */ + if (keynumber == NOPE) + { + if (font->verbose == pdc_true) + pdc_warning(p->pdc, PDF_E_T1_AFMBADKEY, keyword, filename, 0, 0); + + goto PDF_PARSECONTD; + } + if (nwords == 1) goto PDF_PARSECONTD; + + /* key switch */ + arg1 = wordlist[1]; + switch (keynumber) + { + case FONTNAME: + font->name = pdc_strdup(p->pdc, arg1); + break; + + /* Recognize Multiple Master fonts by last part of name */ + case FAMILYNAME: + if (!strcmp(wordlist[nwords-1], "MM")) + font->type = pdc_MMType1; + break; + + /* Default: FontSpecific */ + case ENCODINGSCHEME: + if (!pdc_stricmp(arg1, "StandardEncoding") || + !pdc_stricmp(arg1, "AdobeStandardEncoding")) + font->isstdlatin = pdc_true ; + break; + + case STDHW: + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->StdHW = (int) dz; + break; + + case STDVW: + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->StdVW = (int) dz; + break; + + /* If we don't know StdVW we guess it from the font weight */ + case WEIGHT: + if (font->StdVW == 0) + { + if (!pdc_stricmp(arg1, "Light")) + font->StdVW = PDF_STEMV_LIGHT; + else if (!pdc_stricmp(arg1, "Medium")) + font->StdVW = PDF_STEMV_MEDIUM; + else if (!pdc_stricmp(arg1, "Semi") || + !pdc_stricmp(arg1, "SemiBold")) + font->StdVW = PDF_STEMV_SEMIBOLD; + else if (!pdc_stricmp(arg1, "Bold")) + font->StdVW = PDF_STEMV_BOLD; + else if (!pdc_stricmp(arg1, "Extra") || + !pdc_stricmp(arg1, "ExtraBold")) + font->StdVW = PDF_STEMV_EXTRABOLD; + else if (!pdc_stricmp(arg1, "Black")) + font->StdVW = PDF_STEMV_BLACK; + else + font->StdVW = PDF_STEMV_NORMAL; + } + break; + + case ISFIXEDPITCH: + if (!pdc_stricmp(arg1, "false")) + font->isFixedPitch = pdc_false; + else + font->isFixedPitch = pdc_true; + break; + + /* New AFM 4.1 keyword "CharWidth" implies fixed pitch */ + case CHARWIDTH: + font->isFixedPitch = pdc_true; + break; + + case ITALICANGLE: + { + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->italicAngle = (float) dz; + } + break; + + case UNDERLINEPOSITION: + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->underlinePosition = (int) dz; + break; + + case UNDERLINETHICKNESS: + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->underlineThickness = (int) dz; + break; + + case FONTBBOX: + { + if (nwords != 5) + goto PDF_SYNTAXERROR; + for (i = 1; i < nwords; i++) + { + if (pdc_str2double(wordlist[i], &dz) != pdc_true) + goto PDF_SYNTAXERROR; + if (i == 1) + font->llx = (float) dz; + else if (i == 2) + font->lly = (float) dz; + else if (i == 3) + font->urx = (float) dz; + else if (i == 4) + font->ury = (float) dz; + } + } + break; + + case CAPHEIGHT: + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->capHeight = (int) dz; + break; + + case XHEIGHT: + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->xHeight = (int) dz; + break; + + case DESCENDER: + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->descender = (int) dz; + break; + + case ASCENDER: + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + font->ascender = (int) dz; + break; + + /* Character widths */ + + case STARTCHARMETRICS: + if (pdc_str2integer(arg1, &nglyphs) != pdc_true || nglyphs <= 0) + goto PDF_SYNTAXERROR; + font->glw = (pdc_glyphwidth *) pdc_calloc(p->pdc, + (size_t) nglyphs * sizeof(pdc_glyphwidth), fn); + break; + + /* Character code */ + case CODE: + if (!nglyphs || !font->glw) + goto PDF_SYNTAXERROR; + if (font->numOfGlyphs >= nglyphs) + { + nglyphs++; + font->glw = (pdc_glyphwidth *) pdc_realloc(p->pdc, font->glw, + (size_t) nglyphs * sizeof(pdc_glyphwidth), fn); + } + glw = &font->glw[font->numOfGlyphs]; + if (pdc_str2double(arg1, &dz) != pdc_true) + goto PDF_SYNTAXERROR; + glw->code = (pdc_short) dz; + glw->unicode = 0; + glw->width = 0; + font->numOfGlyphs++; + + /* Character width and name */ + for (i = 2; i < nwords; i++) + { + if (!strcmp(wordlist[i], "W") || + !strcmp(wordlist[i], "WX")) + { + i++; + if (i == nwords) + goto PDF_SYNTAXERROR; + if (pdc_str2double(wordlist[i], &dz) != pdc_true) + goto PDF_SYNTAXERROR; + glw->width = (pdc_ushort) + (font->monospace ? font->monospace : dz); + } + if (!strcmp(wordlist[i], "N")) + { + i++; + if (i == nwords) + goto PDF_SYNTAXERROR; + glw->unicode = pdf_insert_glyphname(p, wordlist[i]); + } + } + break; + + + default: + break; + } + + PDF_PARSECONTD: + pdc_cleanup_stringlist(p->pdc, wordlist); + + if (keynumber == ENDFONTMETRICS) + break; + } + pdc_fclose(fp); + return pdc_true; + + PDF_SYNTAXERROR: + pdc_fclose(fp); + pdc_cleanup_stringlist(p->pdc, wordlist); + + pdc_set_errmsg(p->pdc, PDC_E_IO_ILLSYNTAX, "AFM ", filename, + pdc_errprintf(p->pdc, "%d", nline), 0); + + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; +} + +pdc_bool +pdf_process_metrics_data( + PDF *p, + pdc_font *font, + const char *fontname) +{ + static const char fn[] = "pdf_process_metrics_data"; + int *widths; + pdc_ushort uv; + pdc_glyphwidth *glw; + pdc_encoding enc = font->encoding; + pdc_encodingvector *ev = NULL; + int foundChars = 0, tofree = 0, i, j; + + /* Unallowed encoding */ + if (enc < pdc_builtin) { + + pdc_set_errmsg(p->pdc, PDF_E_FONT_BADENC, + fontname, pdf_get_encoding_name(p, enc), 0, 0); + + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + /* Determine the default character width (width of space character) */ + font->defWidth = font->monospace ? font->monospace : PDF_DEFAULT_WIDTH; + for (j = 0, glw = font->glw; j < font->numOfGlyphs; ++j, ++glw) + { + if (glw->unicode) + foundChars++; + if (glw->unicode == PDF_DEFAULT_GLYPH) + font->defWidth = (int) glw->width; + } + + /* No characters found and lex Symbolii */ + if (enc != pdc_builtin && (foundChars < AFM_MINNUMGLYPHS || + (!strcmp(fontname, "Symbol") && enc == pdc_winansi))) + { + if (font->isstdlatin == pdc_true) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_BADENC, + fontname, pdf_get_encoding_name(p, enc), 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + else + { + /* We enforce builtin encoding */ + if (font->verbose) + pdc_warning(p->pdc, PDF_E_FONT_FORCEENC, + pdf_get_encoding_name(p, pdc_builtin), + pdf_get_encoding_name(p, enc), fontname, 0); + enc = pdc_builtin; + font->encoding = enc; + } + } + + /* + * Generate character width according to the chosen encoding + */ + + { + font->widths = (int *) pdc_calloc(p->pdc, + font->numOfCodes * sizeof(int), fn); + widths = font->widths; + + /* Given encoding */ + if (enc >= 0 && enc < p->encodings_number) + { + ev = p->encodings[enc].ev; + for (i = 0; i < font->numOfCodes; i++) + { + uv = ev->codes[i]; + widths[i] = font->defWidth; + if (uv == 0x000) + continue; + for (j = 0, glw = font->glw; j < font->numOfGlyphs; ++j, ++glw) + { + if (glw->unicode == uv) + { + widths[i] = glw->width; + break; + } + } + } + } + else + { + /* temporary encoding */ + ev = (pdc_encodingvector *) + pdc_malloc(p->pdc, sizeof(pdc_encodingvector), fn); + pdc_init_encoding(p->pdc, ev, ""); + tofree = 1; + for (i = 0; i < font->numOfCodes; i++) + { + widths[i] = font->defWidth; + ev->codes[i] = PDF_DEFAULT_GLYPH; + } + for (i = 0, glw = font->glw; i < font->numOfGlyphs; i++, glw++) + { + if (glw->code >= 0 && glw->code < font->numOfCodes) + { + widths[glw->code] = glw->width; + ev->codes[glw->code] = glw->unicode; + } + } + } + } + + + if (tofree) pdc_cleanup_encoding(p->pdc, ev); + + if (font->glw != NULL) + { + pdc_free(p->pdc, font->glw); + font->glw = NULL; + } + + return pdc_true; +} + +pdc_bool +pdf_get_metrics_afm( + PDF *p, + pdc_font *font, + const char *fontname, + pdc_encoding enc, + const char *filename) +{ + pdc_file *afmfile; + + /* open AFM file */ + if ((afmfile = pdf_fopen(p, filename, "AFM ", 0)) == NULL) + { + if (font->verbose_open) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + /* parse AFM file */ + if (pdf_parse_afm(p, afmfile, font, fontname, filename) == pdc_false) + return pdc_false; + + /* process metric data */ + font->encoding = enc; + if (pdf_process_metrics_data(p, font, fontname) == pdc_false) + return pdc_false; + + if (!pdf_make_fontflag(p, font)) + return pdc_false; + + return pdc_true; +} + +pdc_bool +pdf_get_core_metrics_afm( + PDF *p, + pdc_font *font, + pdc_core_metric *metric, + const char *fontname, + const char *filename) +{ + pdc_file *afmfile; + + /* open AFM file */ + if ((afmfile = pdf_fopen(p, filename, "AFM ", 0)) == NULL) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + /* parse AFM file */ + if (pdf_parse_afm(p, afmfile, font, fontname, filename) == pdc_false) + return pdc_false; + + /* process metric data */ + font->encoding = pdc_invalidenc; + pdc_fill_core_metric(p->pdc, font, metric); + + return pdc_true; +} + diff --git a/src/libs/pdflib/libs/pdflib/p_annots.c b/src/libs/pdflib/libs/pdflib/p_annots.c new file mode 100644 index 0000000000..fd99348512 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_annots.c @@ -0,0 +1,1049 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_annots.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib routines for annnotations + * + */ + +#include "p_intern.h" + +/* Annotation types */ +typedef enum { + ann_text, ann_locallink, + ann_pdflink, ann_weblink, + ann_launchlink, ann_attach +} pdf_annot_type; + +/* icons for file attachments and text annotations */ +typedef enum { + icon_file_graph, icon_file_paperclip, + icon_file_pushpin, icon_file_tag, + + icon_text_comment, icon_text_insert, + icon_text_note, icon_text_paragraph, + icon_text_newparagraph, icon_text_key, + icon_text_help +} pdf_icon; + +/* Annotations */ +struct pdf_annot_s { + pdf_annot_type type; /* used for all annotation types */ + pdc_rectangle rect; /* used for all annotation types */ + pdc_id obj_id; /* used for all annotation types */ + pdf_annot *next; /* used for all annotation types */ + + pdf_icon icon; /* attach and text */ + char *filename; /* attach, launchlink, pdflink,weblink*/ + char *contents; /* text, attach, pdflink */ + char *mimetype; /* attach */ + char *parameters; /* launchlink */ + char *operation; /* launchlink */ + char *defaultdir; /* launchlink */ + + char *title; /* text */ + int open; /* text */ + pdf_dest dest; /* locallink, pdflink */ + + /* -------------- annotation border style and color -------------- */ + pdf_border_style border_style; + float border_width; + float border_red; + float border_green; + float border_blue; + float border_dash1; + float border_dash2; +}; + +static const char *pdf_border_style_names[] = { + "S", /* solid border */ + "D", /* dashed border */ + "B", /* beveled (three-dimensional) border */ + "I", /* inset border */ + "U" /* underlined border */ +}; + +static const char *pdf_icon_names[] = { + /* embedded file icon names */ + "Graph", "Paperclip", "Pushpin", "Tag", + + /* text annotation icon names */ + "Comment", "Insert", "Note", "Paragraph", "NewParagraph", "Key", "Help" +}; + +/* flags for annotation properties */ +typedef enum { + pdf_ann_flag_invisible = 1, + pdf_ann_flag_hidden = 2, + pdf_ann_flag_print = 4, + pdf_ann_flag_nozoom = 8, + pdf_ann_flag_norotate = 16, + pdf_ann_flag_noview = 32, + pdf_ann_flag_readonly = 64 +} pdf_ann_flag; + +void +pdf_init_annots(PDF *p) +{ + /* annotation border style defaults */ + p->border_style = border_solid; + p->border_width = (float) 1.0; + p->border_red = (float) 0.0; + p->border_green = (float) 0.0; + p->border_blue = (float) 0.0; + p->border_dash1 = (float) 3.0; + p->border_dash2 = (float) 3.0; + + /* auxiliary function parameters */ + p->launchlink_parameters = NULL; + p->launchlink_operation = NULL; + p->launchlink_defaultdir = NULL; +} + +void +pdf_cleanup_annots(PDF *p) +{ + if (p->launchlink_parameters) { + pdc_free(p->pdc, p->launchlink_parameters); + p->launchlink_parameters = NULL; + } + + if (p->launchlink_operation) { + pdc_free(p->pdc, p->launchlink_operation); + p->launchlink_operation = NULL; + } + + if (p->launchlink_defaultdir) { + pdc_free(p->pdc, p->launchlink_defaultdir); + p->launchlink_defaultdir = NULL; + } +} + +static void +pdf_init_annot(PDF *p, pdf_annot *ann) +{ + (void) p; + + ann->next = NULL; + ann->filename = NULL; + ann->mimetype = NULL; + ann->contents = NULL; + ann->mimetype = NULL; + ann->parameters = NULL; + ann->operation = NULL; + ann->defaultdir = NULL; + ann->title = NULL; +} + + +/* Write annotation border style and color */ +static void +pdf_write_border_style(PDF *p, pdf_annot *ann) +{ + /* don't write the default values */ + if (ann->border_style == border_solid && + ann->border_width == (float) 1.0 && + ann->border_red == (float) 0.0 && + ann->border_green == (float) 0.0 && + ann->border_blue == (float) 0.0 && + ann->border_dash1 == (float) 3.0 && + ann->border_dash2 == (float) 3.0) + return; + + if (ann->type != ann_attach) { + pdc_puts(p->out, "/BS"); + pdc_begin_dict(p->out); /* BS dict */ + pdc_puts(p->out, "/Type/Border\n"); + + /* Acrobat 6 requires this entry, and does not use /S/S as default */ + pdc_printf(p->out, "/S/%s\n", + pdf_border_style_names[ann->border_style]); + + /* Acrobat 6 requires this entry */ + pdc_printf(p->out, "/W %f\n", ann->border_width); + + if (ann->border_style == border_dashed) + pdc_printf(p->out, "/D[%f %f]\n", + ann->border_dash1, ann->border_dash2); + + pdc_end_dict(p->out); /* BS dict */ + + /* Write the Border key in old-style PDF 1.1 format */ + pdc_printf(p->out, "/Border[0 0 %f", ann->border_width); + + if (ann->border_style == border_dashed && + (ann->border_dash1 != (float) 0.0 || ann->border_dash2 != + (float) 0.0)) + /* set dashed border */ + pdc_printf(p->out, "[%f %f]", ann->border_dash1, ann->border_dash2); + + pdc_puts(p->out, "]\n"); + + } + + /* write annotation color */ + pdc_printf(p->out, "/C[%f %f %f]\n", + ann->border_red, ann->border_green, ann->border_blue); +} + +void +pdf_write_annots_root(PDF *p) +{ + pdf_annot *ann; + + /* Annotations array */ + if (p->annots) { + pdc_puts(p->out, "/Annots["); + + for (ann = p->annots; ann != NULL; ann = ann->next) { + ann->obj_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "%ld 0 R ", ann->obj_id); + } + + pdc_puts(p->out, "]\n"); + } +} + +void +pdf_write_page_annots(PDF *p) +{ + pdf_annot *ann; + + for (ann = p->annots; ann != NULL; ann = ann->next) { + + pdc_begin_obj(p->out, ann->obj_id); /* Annotation object */ + pdc_begin_dict(p->out); /* Annotation dict */ + + + pdc_puts(p->out, "/Type/Annot\n"); + switch (ann->type) { + case ann_text: + pdc_puts(p->out, "/Subtype/Text\n"); + pdc_printf(p->out, "/Rect[%f %f %f %f]\n", + ann->rect.llx, ann->rect.lly, ann->rect.urx, ann->rect.ury); + + pdf_write_border_style(p, ann); + + if (ann->open) + pdc_puts(p->out, "/Open true\n"); + + if (ann->icon != icon_text_note) /* note is default */ + pdc_printf(p->out, "/Name/%s\n", pdf_icon_names[ann->icon]); + + /* Contents key is required, but may be empty */ + pdc_puts(p->out, "/Contents"); + + if (ann->contents) { + pdc_put_pdfunistring(p->out, ann->contents); + pdc_puts(p->out, "\n"); + } else + pdc_puts(p->out, "()\n"); /* empty contents is OK */ + + /* title is optional */ + if (ann->title) { + pdc_puts(p->out, "/T"); + pdc_put_pdfunistring(p->out, ann->title); + pdc_puts(p->out, "\n"); + } + + break; + + case ann_locallink: + pdc_puts(p->out, "/Subtype/Link\n"); + pdc_printf(p->out, "/Rect[%f %f %f %f]\n", + ann->rect.llx, ann->rect.lly, ann->rect.urx, ann->rect.ury); + + pdf_write_border_style(p, ann); + + /* preallocate page object id for a later page */ + if (ann->dest.page > p->current_page) { + while (ann->dest.page >= p->pages_capacity) + pdf_grow_pages(p); + + /* if this page has already been used as a link target + * it will already have an object id. + */ + if (p->pages[ann->dest.page] == PDC_BAD_ID) + p->pages[ann->dest.page] = pdc_alloc_id(p->out); + } + + pdc_puts(p->out, "/Dest"); + pdf_write_destination(p, &ann->dest); + pdc_puts(p->out, "\n"); + + break; + + case ann_pdflink: + pdc_puts(p->out, "/Subtype/Link\n"); + pdc_printf(p->out, "/Rect[%f %f %f %f]\n", + ann->rect.llx, ann->rect.lly, ann->rect.urx, ann->rect.ury); + + pdf_write_border_style(p, ann); + + pdc_puts(p->out, "/A"); + pdc_begin_dict(p->out); /* A dict */ + pdc_puts(p->out, "/Type/Action/S/GoToR\n"); + + pdc_puts(p->out, "/D"); + pdf_write_destination(p, &ann->dest); + pdc_puts(p->out, "\n"); + + pdc_puts(p->out, "/F"); + pdc_begin_dict(p->out); /* F dict */ + pdc_puts(p->out, "/Type/Filespec\n"); + pdc_puts(p->out, "/F"); + pdc_put_pdfstring(p->out, ann->filename, + (int)strlen(ann->filename)); + pdc_puts(p->out, "\n"); + pdc_end_dict(p->out); /* F dict */ + + pdc_end_dict(p->out); /* A dict */ + + break; + + case ann_launchlink: + pdc_puts(p->out, "/Subtype/Link\n"); + pdc_printf(p->out, "/Rect[%f %f %f %f]\n", + ann->rect.llx, ann->rect.lly, ann->rect.urx, ann->rect.ury); + + pdf_write_border_style(p, ann); + + pdc_puts(p->out, "/A"); + pdc_begin_dict(p->out); /* A dict */ + pdc_puts(p->out, "/Type/Action/S/Launch\n"); + + if (ann->parameters || ann->operation || ann->defaultdir) { + pdc_puts(p->out, "/Win"); + pdc_begin_dict(p->out); /* Win dict */ + pdc_printf(p->out, "/F"); + pdc_put_pdfstring(p->out, ann->filename, + (int)strlen(ann->filename)); + pdc_puts(p->out, "\n"); + if (ann->parameters) { + pdc_printf(p->out, "/P"); + pdc_put_pdfstring(p->out, ann->parameters, + (int)strlen(ann->parameters)); + pdc_puts(p->out, "\n"); + pdc_free(p->pdc, ann->parameters); + ann->parameters = NULL; + } + if (ann->operation) { + pdc_printf(p->out, "/O"); + pdc_put_pdfstring(p->out, ann->operation, + (int)strlen(ann->operation)); + pdc_puts(p->out, "\n"); + pdc_free(p->pdc, ann->operation); + ann->operation = NULL; + } + if (ann->defaultdir) { + pdc_printf(p->out, "/D"); + pdc_put_pdfstring(p->out, ann->defaultdir, + (int)strlen(ann->defaultdir)); + pdc_puts(p->out, "\n"); + pdc_free(p->pdc, ann->defaultdir); + ann->defaultdir = NULL; + } + pdc_end_dict(p->out); /* Win dict */ + } else { + pdc_puts(p->out, "/F"); + pdc_begin_dict(p->out); /* F dict */ + pdc_puts(p->out, "/Type/Filespec\n"); + pdc_printf(p->out, "/F"); + pdc_put_pdfstring(p->out, ann->filename, + (int)strlen(ann->filename)); + pdc_puts(p->out, "\n"); + pdc_end_dict(p->out); /* F dict */ + } + + pdc_end_dict(p->out); /* A dict */ + + break; + + case ann_weblink: + pdc_puts(p->out, "/Subtype/Link\n"); + pdc_printf(p->out, "/Rect[%f %f %f %f]\n", + ann->rect.llx, ann->rect.lly, ann->rect.urx, ann->rect.ury); + + pdf_write_border_style(p, ann); + + pdc_puts(p->out, "/A<out, ann->filename, + (int)strlen(ann->filename)); + pdc_puts(p->out, ">>\n"); + break; + + case ann_attach: + pdc_puts(p->out, "/Subtype/FileAttachment\n"); + pdc_printf(p->out, "/Rect[%f %f %f %f]\n", + ann->rect.llx, ann->rect.lly, ann->rect.urx, ann->rect.ury); + + pdf_write_border_style(p, ann); + + if (ann->icon != icon_file_pushpin) /* pushpin is default */ + pdc_printf(p->out, "/Name/%s\n", + pdf_icon_names[ann->icon]); + + if (ann->title) { + pdc_puts(p->out, "/T"); + pdc_put_pdfunistring(p->out, ann->title); + pdc_puts(p->out, "\n"); + } + + if (ann->contents) { + pdc_puts(p->out, "/Contents"); + pdc_put_pdfunistring(p->out, ann->contents); + pdc_puts(p->out, "\n"); + } + + /* the icon is too small without these flags (=28) */ + pdc_printf(p->out, "/F %d\n", + pdf_ann_flag_print | + pdf_ann_flag_nozoom | + pdf_ann_flag_norotate); + + pdc_puts(p->out, "/FS"); + pdc_begin_dict(p->out); /* FS dict */ + pdc_puts(p->out, "/Type/Filespec\n"); + + pdc_puts(p->out, "/F"); + pdc_put_pdfstring(p->out, ann->filename, + (int)strlen(ann->filename)); + pdc_puts(p->out, "\n"); + + /* alloc id for the actual embedded file stream */ + ann->obj_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/EF<>\n", ann->obj_id); + pdc_end_dict(p->out); /* FS dict */ + + break; + + default: + pdc_error(p->pdc, PDF_E_INT_BADANNOT, + pdc_errprintf(p->pdc, "%d", ann->type), 0, 0, 0); + } + + pdc_end_dict(p->out); /* Annotation dict */ + pdc_end_obj(p->out); /* Annotation object */ + } + + /* Write the actual embedded files with preallocated ids */ + for (ann = p->annots; ann != NULL; ann = ann->next) { + pdc_id length_id; + PDF_data_source src; + + if (ann->type != ann_attach) + continue; + + pdc_begin_obj(p->out, ann->obj_id); /* EmbeddedFile */ + pdc_puts(p->out, "<mimetype) { + pdc_puts(p->out, "/Subtype"); + pdc_put_pdfname(p->out, ann->mimetype, strlen(ann->mimetype)); + pdc_puts(p->out, "\n"); + } + + if (pdc_get_compresslevel(p->out)) + pdc_puts(p->out, "/Filter/FlateDecode\n"); + + length_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/Length %ld 0 R\n", length_id); + pdc_end_dict(p->out); /* F dict */ + + /* write the file in the PDF */ + src.private_data = (void *) ann->filename; + src.init = pdf_data_source_file_init; + src.fill = pdf_data_source_file_fill; + src.terminate = pdf_data_source_file_terminate; + src.length = (long) 0; + src.offset = (long) 0; + + pdf_copy_stream(p, &src, pdc_true); /* embedded file stream */ + + pdc_end_obj(p->out); /* EmbeddedFile object */ + + pdc_put_pdfstreamlength(p->out, length_id); + + if (p->flush & pdf_flush_content) + pdc_flush_stream(p->out); + } +} + +void +pdf_init_page_annots(PDF *p) +{ + p->annots = NULL; +} + +void +pdf_cleanup_page_annots(PDF *p) +{ + pdf_annot *ann, *old; + + for (ann = p->annots; ann != (pdf_annot *) NULL; /* */ ) { + switch (ann->type) { + case ann_text: + if (ann->contents) + pdc_free(p->pdc, ann->contents); + if (ann->title) + pdc_free(p->pdc, ann->title); + break; + + case ann_locallink: + pdf_cleanup_destination(p, &ann->dest); + break; + + case ann_launchlink: + pdc_free(p->pdc, ann->filename); + break; + + case ann_pdflink: + pdf_cleanup_destination(p, &ann->dest); + pdc_free(p->pdc, ann->filename); + break; + + case ann_weblink: + pdc_free(p->pdc, ann->filename); + break; + + case ann_attach: + pdf_unlock_pvf(p, ann->filename); + pdc_free(p->pdc, ann->filename); + if (ann->contents) + pdc_free(p->pdc, ann->contents); + if (ann->title) + pdc_free(p->pdc, ann->title); + if (ann->mimetype) + pdc_free(p->pdc, ann->mimetype); + break; + + default: + pdc_error(p->pdc, PDF_E_INT_BADANNOT, + pdc_errprintf(p->pdc, "%d", ann->type), 0, 0, 0); + } + old = ann; + ann = old->next; + pdc_free(p->pdc, old); + } + p->annots = NULL; +} + +/* Insert new annotation at the end of the annots chain */ +static void +pdf_add_annot(PDF *p, pdf_annot *ann) +{ + pdf_annot *last; + + /* fetch current border state from p */ + ann->border_style = p->border_style; + ann->border_width = p->border_width; + ann->border_red = p->border_red; + ann->border_green = p->border_green; + ann->border_blue = p->border_blue; + ann->border_dash1 = p->border_dash1; + ann->border_dash2 = p->border_dash2; + + ann->next = NULL; + + if (p->annots == NULL) + p->annots = ann; + else { + for (last = p->annots; last->next != NULL; /* */ ) + last = last->next; + last->next = ann; + } +} + +static void +pdf_init_rectangle(PDF *p, pdf_annot *ann, + float llx, float lly, float urx, float ury) +{ + pdc_rect_init(&ann->rect, llx, lly, urx, ury); + if (p->usercoordinates == pdc_true) + pdc_rect_transform(&p->gstate[p->sl].ctm, &ann->rect, &ann->rect); +} + + + + +/* Attach an arbitrary file to the PDF. Note that the actual + * embedding takes place in PDF_end_page(). + * description, author, and mimetype may be NULL. + */ + +static const pdc_keyconn pdf_icon_attach_keylist[] = +{ + {"graph", icon_file_graph}, + {"paperclip", icon_file_paperclip}, + {"pushpin", icon_file_pushpin}, + {"tag", icon_file_tag}, + {NULL, 0} +}; + +static void +pdf__attach_file( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *filename, + const char *description, + int len_descr, + const char *author, + int len_auth, + const char *mimetype, + const char *icon) +{ + static const char fn[] = "pdf__attach_file"; + pdf_annot *ann; + pdc_file *attfile; + + if (filename == NULL || *filename == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "filename", 0, 0, 0); + + if ((attfile = pdf_fopen(p, filename, "attachment ", 0)) == NULL) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + pdf_lock_pvf(p, filename); + pdc_fclose(attfile); + + ann = (pdf_annot *) pdc_malloc(p->pdc, sizeof(pdf_annot), fn); + + pdf_init_annot(p, ann); + + ann->type = ann_attach; + pdf_init_rectangle(p, ann, llx, lly, urx, ury); + + if (icon == NULL || !*icon) + icon = "pushpin"; + ann->icon = (pdf_icon) pdc_get_keycode(icon, pdf_icon_attach_keylist); + if (ann->icon == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "icon", icon, 0, 0); + + ann->filename = (char *) pdc_strdup(p->pdc, filename); + + ann->contents = pdf_convert_hypertext(p, description, len_descr); + + ann->title = pdf_convert_hypertext(p, author, len_auth); + + if (mimetype != NULL) { + ann->mimetype = (char *) pdc_strdup(p->pdc, mimetype); + } + + pdf_add_annot(p, ann); +} + +PDFLIB_API void PDFLIB_CALL +PDF_attach_file( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *filename, + const char *description, + const char *author, + const char *mimetype, + const char *icon) +{ + static const char fn[] = "PDF_attach_file"; + + if (pdf_enter_api(p, fn, pdf_state_page, + "(p[%p], %g, %g, %g, %g, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\")\n", + (void *) p, llx, lly, urx, ury, filename, + pdc_strprint(p->pdc, description, 0), + pdc_strprint(p->pdc, author, 0), mimetype, icon)) + { + int len_descr = description ? (int) pdc_strlen(description) : 0; + int len_auth = author ? (int) pdc_strlen(author) : 0; + pdf__attach_file(p, llx, lly, urx, ury, filename, + description, len_descr, author, len_auth, mimetype, icon) ; + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_attach_file2( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *filename, + int reserved, + const char *description, + int len_descr, + const char *author, + int len_auth, + const char *mimetype, + const char *icon) +{ + static const char fn[] = "PDF_attach_file2"; + + if (pdf_enter_api(p, fn, pdf_state_page, + "(p[%p], %g, %g, %g, %g, \"%s\", %d, \"%s\", %d, " + "\"%s\", %d, \"%s\", \"%s\")\n", + (void *) p, llx, lly, urx, ury, filename, reserved, + pdc_strprint(p->pdc, description, len_descr), len_descr, + pdc_strprint(p->pdc, author, len_auth), len_auth, mimetype, icon)) + { + pdf__attach_file(p, llx, lly, urx, ury, filename, + description, len_descr, author, len_auth, mimetype, icon) ; + } +} + +static const pdc_keyconn pdf_icon_note_keylist[] = +{ + {"comment", icon_text_comment}, + {"insert", icon_text_insert}, + {"note", icon_text_note}, + {"paragraph", icon_text_paragraph}, + {"newparagraph", icon_text_newparagraph}, + {"key", icon_text_key}, + {"help", icon_text_help}, + {NULL, 0} +}; + +static void +pdf__add_note( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *contents, + int len_cont, + const char *title, + int len_title, + const char *icon, + int open) +{ + static const char fn[] = "pdf__add_note"; + pdf_annot *ann; + + ann = (pdf_annot *) pdc_malloc(p->pdc, sizeof(pdf_annot), fn); + + pdf_init_annot(p, ann); + + ann->type = ann_text; + ann->open = open; + pdf_init_rectangle(p, ann, llx, lly, urx, ury); + + if (icon == NULL || !*icon) + icon = "note"; + ann->icon = (pdf_icon) pdc_get_keycode(icon, pdf_icon_note_keylist); + if (ann->icon == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "icon", icon, 0, 0); + + /* title may be NULL */ + ann->title = pdf_convert_hypertext(p, title, len_title); + + /* It is legal to create an empty text annnotation */ + ann->contents = pdf_convert_hypertext(p, contents, len_cont); + + pdf_add_annot(p, ann); +} + +PDFLIB_API void PDFLIB_CALL +PDF_add_note( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *contents, + const char *title, + const char *icon, + int open) +{ + static const char fn[] = "PDF_add_note"; + + if (pdf_enter_api(p, fn, pdf_state_page, + "(p[%p], %g, %g, %g, %g, \"%s\", \"%s\", \"%s\", %d)\n", + (void *) p, llx, lly, urx, ury, + pdc_strprint(p->pdc, contents, 0), + pdc_strprint(p->pdc, title, 0), icon, open)) + { + int len_cont = contents ? (int) pdc_strlen(contents) : 0; + int len_title = title ? (int) pdc_strlen(title) : 0; + pdf__add_note(p, llx, lly, urx, ury, contents, len_cont, + title, len_title, icon, open); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_add_note2( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *contents, + int len_cont, + const char *title, + int len_title, + const char *icon, + int open) +{ + static const char fn[] = "PDF_add_note2"; + + if (pdf_enter_api(p, fn, pdf_state_page, + "(p[%p], %g, %g, %g, %g, \"%s\", %d, \"%s\", %d, \"%s\", %d)\n", + (void *) p, llx, lly, urx, ury, + pdc_strprint(p->pdc, contents, len_cont), len_cont, + pdc_strprint(p->pdc, title, len_title), len_title, + icon, open)) + { + pdf__add_note(p, llx, lly, urx, ury, contents, len_cont, + title, len_title, icon, open); + } +} + +/* Add a link to another PDF file */ +PDFLIB_API void PDFLIB_CALL +PDF_add_pdflink( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *filename, + int page, + const char *optlist) +{ + static const char fn[] = "PDF_add_pdflink"; + pdf_annot *ann; + + if (!pdf_enter_api(p, fn, pdf_state_page, + "(p[%p], %g, %g, %g, %g, \"%s\", %d, \"%s\")\n", + (void *) p, llx, lly, urx, ury, filename, page, optlist)) + { + return; + } + + if (filename == NULL) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "filename", 0, 0, 0); + + ann = (pdf_annot *) pdc_malloc(p->pdc, sizeof(pdf_annot), fn); + + pdf_init_annot(p, ann); + + ann->filename = pdc_strdup(p->pdc, filename); + + ann->type = ann_pdflink; + + pdf_parse_destination_optlist(p, optlist, &ann->dest, page, pdf_remotelink); + + pdf_init_rectangle(p, ann, llx, lly, urx, ury); + + pdf_add_annot(p, ann); +} + +/* Add a link to another file of an arbitrary type */ +PDFLIB_API void PDFLIB_CALL +PDF_add_launchlink( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *filename) +{ + static const char fn[] = "PDF_add_launchlink"; + pdf_annot *ann; + + if (!pdf_enter_api(p, fn, pdf_state_page, + "(p[%p], %g, %g, %g, %g, \"%s\")\n", + (void *)p, llx, lly, urx, ury, filename)) + { + return; + } + + if (filename == NULL) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "filename", 0, 0, 0); + + ann = (pdf_annot *) pdc_malloc(p->pdc, sizeof(pdf_annot), fn); + + pdf_init_annot(p, ann); + + ann->filename = pdc_strdup(p->pdc, filename); + + ann->type = ann_launchlink; + + if (p->launchlink_parameters) { + ann->parameters = p->launchlink_parameters; + p->launchlink_parameters = NULL; + } + + if (p->launchlink_operation) { + ann->operation = p->launchlink_operation; + p->launchlink_operation = NULL; + } + + if (p->launchlink_defaultdir) { + ann->defaultdir = p->launchlink_defaultdir; + p->launchlink_defaultdir = NULL; + } + + pdf_init_rectangle(p, ann, llx, lly, urx, ury); + + pdf_add_annot(p, ann); +} + +/* Add a link to a destination in the current PDF file */ +PDFLIB_API void PDFLIB_CALL +PDF_add_locallink( + PDF *p, + float llx, + float lly, + float urx, + float ury, + int page, + const char *optlist) +{ + static const char fn[] = "PDF_add_locallink"; + pdf_annot *ann; + + if (!pdf_enter_api(p, fn, pdf_state_page, + "(p[%p], %g, %g, %g, %g, %d, \"%s\")\n", + (void *) p, llx, lly, urx, ury, page, optlist)) + { + return; + } + + ann = (pdf_annot *) pdc_malloc(p->pdc, sizeof(pdf_annot), fn); + + pdf_init_annot(p, ann); + + ann->type = ann_locallink; + + pdf_parse_destination_optlist(p, optlist, &ann->dest, page, pdf_locallink); + + pdf_init_rectangle(p, ann, llx, lly, urx, ury); + + pdf_add_annot(p, ann); +} + +/* Add a link to an arbitrary Internet resource (URL) */ +PDFLIB_API void PDFLIB_CALL +PDF_add_weblink( + PDF *p, + float llx, + float lly, + float urx, + float ury, + const char *url) +{ + static const char fn[] = "PDF_add_weblink"; + pdf_annot *ann; + + if (!pdf_enter_api(p, fn, pdf_state_page, + "(p[%p], %g, %g, %g, %g, \"%s\")\n", + (void *) p, llx, lly, urx, ury, url)) + { + return; + } + + if (url == NULL || *url == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "url", 0, 0, 0); + + ann = (pdf_annot *) pdc_malloc(p->pdc, sizeof(pdf_annot), fn); + + pdf_init_annot(p, ann); + + ann->filename = pdc_strdup(p->pdc, url); + + ann->type = ann_weblink; + pdf_init_rectangle(p, ann, llx, lly, urx, ury); + + pdf_add_annot(p, ann); +} + +PDFLIB_API void PDFLIB_CALL +PDF_set_border_style(PDF *p, const char *style, float width) +{ + static const char fn[] = "PDF_set_border_style"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page), + "(p[%p], \"%s\", %g)\n", (void *) p, style, width)) + { + return; + } + + if (style == NULL) + p->border_style = border_solid; + else if (!strcmp(style, "solid")) + p->border_style = border_solid; + else if (!strcmp(style, "dashed")) + p->border_style = border_dashed; + else + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "style", style, 0, 0); + + if (width < 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "width", pdc_errprintf(p->pdc, "%f", width), 0, 0); + + p->border_width = width; +} + +PDFLIB_API void PDFLIB_CALL +PDF_set_border_color(PDF *p, float red, float green, float blue) +{ + static const char fn[] = "PDF_set_border_color"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page), + "(p[%p], %g, %g, %g)\n", (void *) p, red, green, blue)) + { + return; + } + + if (red < 0.0 || red > 1.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "red", pdc_errprintf(p->pdc, "%f", red), 0, 0); + if (green < 0.0 || green > 1.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "green", pdc_errprintf(p->pdc, "%f", green), 0, 0); + if (blue < 0.0 || blue > 1.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "blue", pdc_errprintf(p->pdc, "%f", blue), 0, 0); + + p->border_red = red; + p->border_green = green; + p->border_blue = blue; +} + +PDFLIB_API void PDFLIB_CALL +PDF_set_border_dash(PDF *p, float b, float w) +{ + static const char fn[] = "PDF_set_border_dash"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page), + "(p[%p], %g, %g)\n", (void *) p, b, w)) + { + return; + } + + if (b < 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "b", pdc_errprintf(p->pdc, "%f", b), 0, 0); + + if (w < 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "w", pdc_errprintf(p->pdc, "%f", w), 0, 0); + + p->border_dash1 = b; + p->border_dash2 = w; +} diff --git a/src/libs/pdflib/libs/pdflib/p_basic.c b/src/libs/pdflib/libs/pdflib/p_basic.c new file mode 100644 index 0000000000..dd5865e761 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_basic.c @@ -0,0 +1,1586 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_basic.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib general routines + * + */ + + +#include "p_intern.h" +#include "p_font.h" +#include "p_image.h" + + +#if !defined(WIN32) && !defined(OS2) +#include +#endif + +#if (defined(WIN32) || defined(OS2)) && !defined(WINCE) +#include +#include +#endif + +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#undef WIN32_LEAN_AND_MEAN +#endif + +static pdc_error_info pdf_errors[] = +{ +#define pdf_genInfo 1 +#include "p_generr.h" +}; + +#define N_PDF_ERRORS (sizeof pdf_errors / sizeof (pdc_error_info)) + + +static const PDFlib_api PDFlib = { + /* version numbers for checking the DLL against client code */ + sizeof(PDFlib_api), /* size of this structure */ + + PDFLIB_MAJORVERSION, /* PDFlib major version number */ + PDFLIB_MINORVERSION, /* PDFlib minor version number */ + PDFLIB_REVISION, /* PDFlib revision number */ + + 0, /* reserved */ + + /* p_annots.c: */ + PDF_add_launchlink, + PDF_add_locallink, + PDF_add_note, + PDF_add_note2, + PDF_add_pdflink, + PDF_add_weblink, + PDF_attach_file, + PDF_attach_file2, + PDF_set_border_color, + PDF_set_border_dash, + PDF_set_border_style, + /* p_basic.c: */ + PDF_begin_page, + PDF_boot, + PDF_close, + PDF_delete, + PDF_end_page, + PDF_get_api, + PDF_get_apiname, + PDF_get_buffer, + PDF_get_errmsg, + PDF_get_errnum, + PDF_get_majorversion, + PDF_get_minorversion, + PDF_get_opaque, + PDF_new, + PDF_new2, + PDF_open_file, + PDF_open_fp, + PDF_open_mem, + PDF_shutdown, + pdf_jbuf, + pdf_exit_try, + pdf_catch, + pdf_rethrow, + /* p_block.c: */ + PDF_fill_imageblock, + PDF_fill_pdfblock, + PDF_fill_textblock, + /* p_color.c: */ + PDF_makespotcolor, + PDF_setcolor, + PDF_setgray, + PDF_setgray_stroke, + PDF_setgray_fill, + PDF_setrgbcolor, + PDF_setrgbcolor_fill, + PDF_setrgbcolor_stroke, + /* p_draw.c: */ + PDF_arc, + PDF_arcn, + PDF_circle, + PDF_clip, + PDF_closepath, + PDF_closepath_fill_stroke, + PDF_closepath_stroke, + PDF_curveto, + PDF_endpath, + PDF_fill, + PDF_fill_stroke, + PDF_lineto, + PDF_moveto, + PDF_rect, + PDF_stroke, + /* p_encoding.c: */ + PDF_encoding_set_char, + /* p_font.c: */ + PDF_findfont, + PDF_load_font, + PDF_setfont, + /* p_gstate.c */ + PDF_concat, + PDF_initgraphics, + PDF_restore, + PDF_rotate, + PDF_save, + PDF_scale, + PDF_setdash, + PDF_setdashpattern, + PDF_setflat, + PDF_setlinecap, + PDF_setlinejoin, + PDF_setlinewidth, + PDF_setmatrix, + PDF_setmiterlimit, + PDF_setpolydash, + PDF_skew, + PDF_translate, + /* p_hyper.c: */ + PDF_add_bookmark, + PDF_add_bookmark2, + PDF_add_nameddest, + PDF_set_info, + PDF_set_info2, + /* p_icc.c: */ + PDF_load_iccprofile, + /* p_image.c: */ + PDF_add_thumbnail, + PDF_close_image, + PDF_fit_image, + PDF_load_image, + PDF_open_CCITT, + PDF_open_image, + PDF_open_image_file, + PDF_place_image, + /* p_kerning.c: */ + /* p_params.c: */ + PDF_get_parameter, + PDF_get_value, + PDF_set_parameter, + PDF_set_value, + /* p_pattern.c: */ + PDF_begin_pattern, + PDF_end_pattern, + /* p_pdi.c: */ + PDF_close_pdi, + PDF_close_pdi_page, + PDF_fit_pdi_page, + PDF_get_pdi_parameter, + PDF_get_pdi_value, + PDF_open_pdi, + PDF_open_pdi_callback, + PDF_open_pdi_page, + PDF_place_pdi_page, + PDF_process_pdi, + /* p_resource.c: */ + PDF_create_pvf, + PDF_delete_pvf, + /* p_shading.c: */ + PDF_shading, + PDF_shading_pattern, + PDF_shfill, + /* p_template.c: */ + PDF_begin_template, + PDF_end_template, + /* p_text.c: */ + PDF_continue_text, + PDF_continue_text2, + PDF_fit_textline, + PDF_set_text_pos, + PDF_show, + PDF_show2, + PDF_show_boxed, + PDF_show_xy, + PDF_show_xy2, + PDF_stringwidth, + PDF_stringwidth2, + /* p_type3.c: */ + PDF_begin_font, + PDF_begin_glyph, + PDF_end_font, + PDF_end_glyph, + /* p_xgstate.c: */ + PDF_create_gstate, + PDF_set_gstate +}; + + +PDFLIB_API void PDFLIB_CALL +PDF_boot(void) +{ + /* nothing yet */ +} + +PDFLIB_API void PDFLIB_CALL +PDF_shutdown(void) +{ + /* nothing yet */ +} + +PDFLIB_API const PDFlib_api * PDFLIB_CALL +PDF_get_api(void) +{ + return &PDFlib; +} + + +#if (defined(WIN32) || defined(__CYGWIN)) && defined(PDFLIB_EXPORTS) + +/* + * DLL entry function as required by Visual C++. + * It is currently not necessary on Windows, but will eventually + * be used to boot thread-global resources for PDFlib + * (mainly font-related stuff). + */ +BOOL WINAPI +DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved); + +BOOL WINAPI +DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + (void) hModule; + (void) lpReserved; + + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: + PDF_boot(); + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + PDF_shutdown(); + break; + } + + return TRUE; +} +#endif /* WIN32 && PDFLIB_EXPORT */ + +PDFLIB_API int PDFLIB_CALL +PDF_get_majorversion(void) +{ + return PDFLIB_MAJORVERSION; +} + +PDFLIB_API int PDFLIB_CALL +PDF_get_minorversion(void) +{ + return PDFLIB_MINORVERSION; +} + +pdc_bool +pdf_enter_api(PDF *p, const char *funame, pdf_state s, const char *fmt, ...) +{ + va_list args; + + /* check whether the client completely screwed up */ + if (p == NULL || p->magic != PDC_MAGIC) + return pdc_false; + + va_start(args, fmt); + + if (p->debug['t']) + pdc_trace_api(p->pdc, funame, fmt, args); + + va_end(args); + + /* pdc_enter_api() will return pdc_false if the core is in error state. + */ + if (!pdc_enter_api(p->pdc, funame)) + return pdc_false; + + /* check whether we are in a valid scope */ + if ((p->state_stack[p->state_sp] & s) == 0) + { + /* pdc_error() will NOT throw an exception (and simply return instead) + ** if the core is already in error state. + */ + pdc_error(p->pdc, PDF_E_DOC_SCOPE, pdf_current_scope(p), 0, 0, 0); + + return pdc_false; + } + + return pdc_true; +} + +static pdc_bool +pdf_enter_api2(PDF *p, const char *funame, const char *fmt, ...) +{ + va_list args; + + /* check whether the client completely screwed up */ + if (p == NULL || p->magic != PDC_MAGIC) + return pdc_false; + + va_start(args, fmt); + + if (p->debug['t']) + pdc_trace_api(p->pdc, funame, fmt, args); + + va_end(args); + return pdc_true; +} + + +PDFLIB_API int PDFLIB_CALL +PDF_get_errnum(PDF *p) +{ + static const char fn[] = "PDF_get_errnum"; + int ret; + + if (!pdf_enter_api2(p, fn, "(p[%p])", (void *) p)) + { + pdc_trace(p->pdc, "[0]\n"); + return 0; + } + + ret = pdc_get_errnum(p->pdc); + pdc_trace(p->pdc, "[%d]\n", ret); + return ret; +} + +PDFLIB_API const char * PDFLIB_CALL +PDF_get_errmsg(PDF *p) +{ + static const char fn[] = "PDF_get_errmsg"; + const char *ret; + + if (!pdf_enter_api2(p, fn, "(p[%p])", (void *) p)) + { + pdc_trace(p->pdc, "[NULL]\n"); + return (char *) 0; + } + + ret = pdc_get_errmsg(p->pdc); + pdc_trace(p->pdc, "\n[\"%s\"]\n", ret); + return ret; +} + +PDFLIB_API const char * PDFLIB_CALL +PDF_get_apiname(PDF *p) +{ + static const char fn[] = "PDF_get_apiname"; + const char *ret; + + if (!pdf_enter_api2(p, fn, "(p[%p])", (void *) p)) + { + pdc_trace(p->pdc, "[NULL]\n"); + return (char *) 0; + } + + ret = pdc_get_apiname(p->pdc); + pdc_trace(p->pdc, "[\"%s\"]\n", ret); + return ret; +} + +PDFLIB_API void * PDFLIB_CALL +PDF_get_opaque(PDF *p) +{ + static const char fn[] = "PDF_get_opaque"; + + if (p == NULL || p->magic != PDC_MAGIC) + return ((void *) NULL); + + pdc_trace(p->pdc, "/* "); + + if (!pdf_enter_api2(p, fn, "(p[%p])", (void *) p)) + { + return ((void *) NULL); + } + + pdc_trace(p->pdc, "[%p] */\n", p->opaque); + + return p->opaque; +} + +const char * +pdf_current_scope(PDF *p) +{ + /* This array must be kept in sync with the pdf_state enum in p_intern.h */ + static const char *scope_names[] = + { + "object", + "document", + "page", + "pattern", + "template", + "path", + "gstate", + "font", + "glyph", + "error" + }; + + int i; + + for (i = 0; i < (int)(sizeof(scope_names)/sizeof(char *)); ++i) + if (PDF_GET_STATE(p) == (pdf_state) (1 << i)) + return scope_names[i]; + + pdc_error(p->pdc, PDF_E_INT_BADSCOPE, + pdc_errprintf(p->pdc, " (0x%08X)", PDF_GET_STATE(p)), 0, 0, 0); + + return (char *) 0; /* be happy, compiler! */ +} + +/* p may be NULL on the first call - we don't use it anyway */ +static void * +default_malloc(PDF *p, size_t size, const char *caller) +{ + void *ret = malloc(size); + + (void) p; + (void) caller; +#ifdef DEBUG + if (p != NULL && p->debug['m']) + fprintf(stderr, "%p malloced, size %d from %s, page %d\n", + ret, (int) size, caller, p->current_page); +#endif + + return ret; +} + +static void * +default_realloc(PDF *p, void *mem, size_t size, const char *caller) +{ + void *ret = realloc(mem, size); + + (void) p; + (void) caller; +#ifdef DEBUG + if (p->debug['r']) + fprintf(stderr, "%p realloced to %p, %d from %s, page %d\n", + mem, ret, (int) size, caller, p->current_page); +#endif + + return ret; +} + +static void +default_free(PDF *p, void *mem) +{ + (void) p; + +#ifdef DEBUG + if (p->debug['f']) + fprintf(stderr, "%p freed, page %d\n", mem, p->current_page); +#endif + + free(mem); +} + +/* This is the easy version with the default handlers */ +PDFLIB_API PDF * PDFLIB_CALL +PDF_new(void) +{ + return PDF_new2(NULL, NULL, NULL, NULL, NULL); +} + +/* This is the spiced-up version with user-defined error and memory handlers */ + +PDFLIB_API PDF * PDFLIB_CALL +PDF_new2( + void (*errorhandler)(PDF *p, int type, const char *msg), + void* (*allocproc)(PDF *p, size_t size, const char *caller), + void* (*reallocproc)(PDF *p, void *mem, size_t size, const char *caller), + void (*freeproc)(PDF *p, void *mem), + void *opaque) +{ + PDF * p; + pdc_core * pdc; + + /* If allocproc is NULL, all entries are supplied internally by PDFlib */ + if (allocproc == NULL) { + allocproc = default_malloc; + reallocproc = default_realloc; + freeproc = default_free; + } + + p = (PDF *) (*allocproc) (NULL, sizeof(PDF), "PDF_new"); + + if (p == NULL) + return NULL; + + /* + * Guard against crashes when PDF_delete is called without any + * PDF_open_*() in between. + */ + memset((void *)p, 0, (size_t) sizeof(PDF)); + + /* these two are required by PDF_get_opaque() */ + p->magic = PDC_MAGIC; + p->opaque = opaque; + + pdc = pdc_init_core( + (pdc_error_fp) errorhandler, + (pdc_alloc_fp) allocproc, + (pdc_realloc_fp) reallocproc, + (pdc_free_fp) freeproc, p); + + if (pdc == NULL) + { + (*freeproc)(p, p); + return NULL; + } + + pdc_register_errtab(pdc, PDC_ET_PDFLIB, pdf_errors, N_PDF_ERRORS); + + p->freeproc = freeproc; + p->pdc = pdc; + p->compatibility = PDC_1_4; + + p->errorhandler = errorhandler; + + p->flush = pdf_flush_page; + + p->inheritgs = pdc_false; + + p->hypertextencoding= pdc_invalidenc; + p->hypertextformat = pdc_auto; + p->textformat = pdc_auto; + p->currtext = NULL; + + + + + + p->resfilepending = pdc_true; + p->resourcefilename = NULL; + p->resources = NULL; + p->prefix = NULL; + p->filesystem = NULL; + p->binding = NULL; + p->hastobepos = pdc_false; + p->rendintent = AutoIntent; + p->preserveoldpantonenames = pdc_false; + p->spotcolorlookup = pdc_true; + p->ydirection = (float) 1.0; + p->usercoordinates = pdc_false; + p->names = NULL; + p->names_capacity = 0; + p->xobjects = NULL; + p->pdi = NULL; + p->pdi_strict = pdc_false; + p->pdi_sbuf = NULL; + p->state_sp = 0; + PDF_SET_STATE(p, pdf_state_object); + + /* all debug flags are cleared by default because of the above memset... */ + + /* ...but warning messages for non-fatal errors should be set, + * as well as font warnings -- the client must explicitly disable these. + */ + p->debug['e'] = pdc_true; + p->debug['F'] = pdc_true; + p->debug['I'] = pdc_true; + + pdf_init_info(p); + pdf_init_encodings(p); + + p->out = (pdc_output *)pdc_boot_output(p->pdc); + + return p; +} + +static void pdf_cleanup_contents(PDF *p); + +/* + * PDF_delete must be called for cleanup in case of error, + * or when the client is done producing PDF. + * It should never be called more than once for a given PDF, although + * we try to guard against duplicated calls. + * + * Note: all pdf_cleanup_*() functions may safely be called multiple times. + */ + +PDFLIB_API void PDFLIB_CALL +PDF_delete(PDF *p) +{ + static const char fn[] = "PDF_delete"; + + if (!pdf_enter_api2(p, fn, "(p[%p])\n", (void *) p)) + return; + + /* + * Clean up page-related stuff if necessary. Do not raise + * an error here since we may be called from the error handler. + */ + if (PDF_GET_STATE(p) != pdf_state_object) { + pdc_close_output(p->out); + pdf_cleanup_contents(p); + } + pdf_cleanup_encodings(p); + + /* close the output stream. + * This can't be done in PDF_close() because the caller may fetch + * the buffer only after PDF_close()ing the document. + */ + pdc_cleanup_output(p->out); + pdf_cleanup_resources(p); /* release the resources tree */ + pdf_cleanup_filesystem(p); /* release the file system */ + + + if (p->out) + pdc_free(p->pdc, p->out); + + if (p->binding) + pdc_free(p->pdc, p->binding); + + if (p->resourcefilename) + pdc_free(p->pdc, p->resourcefilename); + + if (p->prefix) + pdc_free(p->pdc, p->prefix); + + /* we never reach this point if (p->pdc == NULL). + */ + pdc_delete_core(p->pdc); + + /* free the PDF structure and try to protect against duplicated calls */ + + p->magic = 0L; /* we don't reach this with the wrong magic */ + (*p->freeproc)(p, (void *) p); +} + +static void +pdf_init_document(PDF *p) +{ + static const char *fn = "pdf_init_document"; + int i; + + p->contents_ids_capacity = CONTENTS_CHUNKSIZE; + p->contents_ids = (pdc_id *) pdc_malloc(p->pdc, + sizeof(pdc_id) * p->contents_ids_capacity, fn); + + p->pages_capacity = PAGES_CHUNKSIZE; + p->pages = (pdc_id *) + pdc_malloc(p->pdc, sizeof(pdc_id) * p->pages_capacity, fn); + + /* mark ids to allow for pre-allocation of page ids */ + for (i = 0; i < p->pages_capacity; i++) + p->pages[i] = PDC_BAD_ID; + + p->pnodes_capacity = PNODES_CHUNKSIZE; + p->pnodes = (pdc_id *) + pdc_malloc(p->pdc, sizeof(pdc_id) * p->pnodes_capacity, fn); + + p->current_pnode = 0; + p->current_pnode_kids = 0; + + p->current_page = 0; + p->open_mode = open_auto; + p->base = NULL; + + p->ViewerPreferences.flags = 0; + p->ViewerPreferences.ViewArea = use_none; + p->ViewerPreferences.ViewClip = use_none; + p->ViewerPreferences.PrintArea = use_none; + p->ViewerPreferences.PrintClip = use_none; + + pdf_init_destination(p, &p->open_action); + pdf_init_destination(p, &p->bookmark_dest); + +} + +static void +pdf_init_contents(PDF *p) +{ + /* + * None of these functions must call pdc_alloc_id() or generate + * any output since the output machinery is not yet initialized! + * If required, such calls must go in pdf_init_contents2() below. + */ + + pdf_init_document(p); + pdf_init_images(p); + pdf_init_xobjects(p); + pdf_init_fonts(p); + pdf_init_transition(p); + pdf_init_outlines(p); + pdf_init_annots(p); + pdf_init_colorspaces(p); + pdf_init_pattern(p); + pdf_init_shadings(p); + pdf_init_extgstate(p); + + /* clients may set char/word spacing and horizontal scaling outside pages + ** for PDF_stringwidth() calculations, and they may set a color for use + ** in PDF_makespotcolor(). Here we set the defaults. + */ + p->sl = 0; + pdf_init_tstate(p); + pdf_init_cstate(p); + +} + +static void +pdf_init_contents2(PDF *p) +{ + /* second part of initialization, including pdcore services */ + + p->pnodes[0] = pdc_alloc_id(p->out); + + PDF_SET_STATE(p, pdf_state_document); +} + +static void +pdf_feed_digest(PDF *p, unsigned char *custom, unsigned int len) +{ + pdc_init_digest(p->out); + + if (custom) + pdc_update_digest(p->out, custom, len); + + pdc_update_digest(p->out, (unsigned char *) &p, sizeof(PDF*)); + + pdc_update_digest(p->out, (unsigned char *) p, sizeof(PDF)); + + pdc_update_digest(p->out, + (unsigned char *) p->time_str, strlen(p->time_str)); + + pdf_feed_digest_info(p); + + + pdc_finish_digest(p->out); +} + +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma unmanaged +#endif +PDFLIB_API int PDFLIB_CALL +PDF_open_file(PDF *p, const char *filename) +{ + static const char fn[] = "PDF_open_file"; + + if (!pdf_enter_api(p, fn, pdf_state_object, "(p[%p], \"%s\")", + (void *) p, filename)) + { + PDF_RETURN_BOOLEAN(p, -1); + } + + pdf_init_contents(p); + + if (filename) + pdf_feed_digest(p, + (unsigned char*) filename, (unsigned int) strlen(filename)); + else + pdf_feed_digest(p, NULL, 0); + + if (!pdc_init_output((void *) p, p->out, filename, NULL, NULL, + p->compatibility)) { + pdc_set_errmsg(p->pdc, pdc_get_fopen_errnum(p->pdc, PDC_E_IO_WROPEN), + "PDF ", filename, 0, 0); + + if (p->debug['o']) + pdc_warning(p->pdc, -1, 0, 0, 0, 0); + + PDF_RETURN_BOOLEAN(p, -1); + } + + pdf_init_contents2(p); + + PDF_RETURN_BOOLEAN(p, 1); +} +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma managed +#endif + +PDFLIB_API int PDFLIB_CALL +PDF_open_fp(PDF *p, FILE *fp) +{ + static const char fn[] = "PDF_open_fp"; + + if (!pdf_enter_api(p, fn, pdf_state_object, "(p[%p], fp[%p])", + (void *) p, fp)) + { + PDF_RETURN_BOOLEAN(p, -1); + } + + if (fp == NULL) + { + PDF_RETURN_BOOLEAN(p, -1); + } + +/* + * It is the callers responsibility to open the file in binary mode, + * but it doesn't hurt to make sure it really is. + * The Intel version of the Metrowerks compiler doesn't have setmode(). + */ +#if !defined(__MWERKS__) && (defined(WIN32) || defined(OS2)) +#if defined WINCE + _setmode(fileno(fp), _O_BINARY); +#else + setmode(fileno(fp), O_BINARY); +#endif +#endif + + pdf_init_contents(p); + + pdf_feed_digest(p, (unsigned char*) fp, sizeof(FILE)); + + (void) pdc_init_output((void *) p, p->out, NULL, fp, NULL, + p->compatibility); + + pdf_init_contents2(p); + + PDF_RETURN_BOOLEAN(p, 1); +} + +/* + * The external callback interface requires a PDF* as the first argument, + * while the internal interface uses pdc_output* and doesn't know about PDF*. + * We use a wrapper to bridge the gap, and store the PDF* within the + * pdc_output structure opaquely. + */ + +static size_t +writeproc_wrapper(pdc_output *out, void *data, size_t size) +{ + PDF *p = (PDF *) pdc_get_opaque(out); + + return (p->writeproc)(p, data, size); +} + +PDFLIB_API void PDFLIB_CALL +PDF_open_mem(PDF *p, size_t (*i_writeproc)(PDF *p, void *data, size_t size)) +{ + static const char fn[] = "PDF_open_mem"; + size_t (*writeproc)(PDF *, void *, size_t) = i_writeproc; + + if (!pdf_enter_api(p, fn, pdf_state_object, + "(p[%p], wp[%p])\n", (void *) p, (void *) writeproc)) + return; + + if (writeproc == NULL) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "writeproc", 0, 0, 0); + + p->writeproc = writeproc; + + pdf_init_contents(p); + + pdf_feed_digest(p, (unsigned char*) &writeproc, + (unsigned int) sizeof(writeproc)); + + (void) pdc_init_output((void *) p, p->out, NULL, NULL, writeproc_wrapper, + p->compatibility); + + pdf_init_contents2(p); +} + +/* + * The caller must use the contents of the returned buffer before + * calling the next PDFlib function. + */ + +PDFLIB_API const char * PDFLIB_CALL +PDF_get_buffer(PDF *p, long *size) +{ + static const char fn[] = "PDF_get_buffer"; + const char *ret; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_object | pdf_state_document), + "(p[%p], &size[%p])", (void *) p, (void *) size)) { + *size = (long) 0; + return (const char) NULL; + } + + ret = pdc_get_stream_contents(p->out, size); + + pdc_trace(p->pdc, "[%p, size=%ld]\n", (void *) (ret), *size); + return ret; +} + +static void +pdf_write_pnode(PDF *p, + pdc_id node_id, + pdc_id parent_id, + pdc_id *kids, + int n_kids, + int n_pages) +{ + pdc_begin_obj(p->out, node_id); + pdc_begin_dict(p->out); + pdc_puts(p->out, "/Type/Pages\n"); + pdc_printf(p->out, "/Count %d\n", n_pages); + + if (parent_id != PDC_BAD_ID) + pdc_printf(p->out, "/Parent %ld 0 R\n", parent_id); + + pdc_puts(p->out, "/Kids["); + + do + { + pdc_printf(p->out, "%ld 0 R", *kids++); + pdc_puts(p->out, "\n"); + } while (--n_kids > 0); + + pdc_puts(p->out, "]"); + pdc_end_dict(p->out); + pdc_end_obj(p->out); +} + +#define N_KIDS 10 + +static pdc_id +pdf_get_pnode_id(PDF *p) +{ + static const char fn[] = "pdf_get_pnode_id"; + + if (p->current_pnode_kids == N_KIDS) + { + if (++p->current_pnode == p->pnodes_capacity) + { + p->pnodes_capacity *= 2; + p->pnodes = (pdc_id *) pdc_realloc(p->pdc, p->pnodes, + sizeof (pdc_id) * p->pnodes_capacity, fn); + } + + p->pnodes[p->current_pnode] = pdc_alloc_id(p->out); + p->current_pnode_kids = 1; + } + else + ++p->current_pnode_kids; + + return p->pnodes[p->current_pnode]; +} + +static pdc_id +pdf_make_tree(PDF *p, + pdc_id parent_id, + pdc_id *pnodes, + pdc_id *pages, + int n_pages) +{ + if (n_pages <= N_KIDS) + { + /* this is a near-to-leaf node. use the pre-allocated id + ** from p->pnodes. + */ + pdf_write_pnode(p, *pnodes, parent_id, pages, n_pages, n_pages); + return *pnodes; + } + else + { + pdc_id node_id = pdc_alloc_id(p->out); + pdc_id kids[N_KIDS]; + int n_kids, rest; + int tpow = N_KIDS; + int i; + + /* tpow < n_pages <= tpow*N_KIDS + */ + while (tpow * N_KIDS < n_pages) + tpow *= N_KIDS; + + n_kids = n_pages / tpow; + rest = n_pages % tpow; + + for (i = 0; i < n_kids; ++i, pnodes += tpow / N_KIDS, pages += tpow) + { + kids[i] = pdf_make_tree(p, node_id, pnodes, pages, tpow); + } + + if (rest) + { + kids[i] = pdf_make_tree(p, node_id, pnodes, pages, rest); + ++n_kids; + } + + pdf_write_pnode(p, node_id, parent_id, kids, n_kids, n_pages); + return node_id; + } +} + +static pdc_id +pdf_write_pages_and_catalog(PDF *p) +{ + pdc_id pages_id; + pdc_id root_id; + pdc_id names_id; + + pages_id = + pdf_make_tree(p, PDC_BAD_ID, p->pnodes, p->pages+1, p->current_page); + + + names_id = pdf_write_names(p); + + root_id = pdc_begin_obj(p->out, PDC_NEW_ID); /* Catalog or Root object */ + + pdc_begin_dict(p->out); + pdc_puts(p->out, "/Type/Catalog\n"); + + + if (p->ViewerPreferences.flags || + p->ViewerPreferences.ViewArea != use_none || + p->ViewerPreferences.ViewClip != use_none || + p->ViewerPreferences.PrintArea != use_none || + p->ViewerPreferences.PrintClip != use_none) + { + pdc_printf(p->out, "/ViewerPreferences\n"); + pdc_begin_dict(p->out); + + if (p->ViewerPreferences.flags & HideToolbar) + pdc_printf(p->out, "/HideToolbar true\n"); + + if (p->ViewerPreferences.flags & HideMenubar) + pdc_printf(p->out, "/HideMenubar true\n"); + + if (p->ViewerPreferences.flags & HideWindowUI) + pdc_printf(p->out, "/HideWindowUI true\n"); + + if (p->ViewerPreferences.flags & FitWindow) + pdc_printf(p->out, "/FitWindow true\n"); + + if (p->ViewerPreferences.flags & CenterWindow) + pdc_printf(p->out, "/CenterWindow true\n"); + + if (p->ViewerPreferences.flags & DisplayDocTitle) + pdc_printf(p->out, "/DisplayDocTitle true\n"); + + if (p->ViewerPreferences.flags & NonFullScreenPageModeOutlines) + pdc_printf(p->out, "/NonFullScreenPageMode/UseOutlines\n"); + else if (p->ViewerPreferences.flags & NonFullScreenPageModeThumbs) + pdc_printf(p->out, "/NonFullScreenPageMode/UseThumbs\n"); + + if (p->ViewerPreferences.flags & DirectionR2L) + pdc_printf(p->out, "/Direction/R2L\n"); + + if (p->ViewerPreferences.ViewArea == use_media) + pdc_printf(p->out, "/ViewArea/MediaBox\n"); + if (p->ViewerPreferences.ViewArea == use_bleed) + pdc_printf(p->out, "/ViewArea/BleedBox\n"); + else if (p->ViewerPreferences.ViewArea == use_trim) + pdc_printf(p->out, "/ViewArea/TrimBox\n"); + else if (p->ViewerPreferences.ViewArea == use_art) + pdc_printf(p->out, "/ViewArea/ArtBox\n"); + + if (p->ViewerPreferences.ViewClip == use_media) + pdc_printf(p->out, "/ViewClip/MediaBox\n"); + if (p->ViewerPreferences.ViewClip == use_bleed) + pdc_printf(p->out, "/ViewClip/BleedBox\n"); + else if (p->ViewerPreferences.ViewClip == use_trim) + pdc_printf(p->out, "/ViewClip/TrimBox\n"); + else if (p->ViewerPreferences.ViewClip == use_art) + pdc_printf(p->out, "/ViewClip/ArtBox\n"); + + if (p->ViewerPreferences.PrintArea == use_media) + pdc_printf(p->out, "/PrintArea/MediaBox\n"); + if (p->ViewerPreferences.PrintArea == use_bleed) + pdc_printf(p->out, "/PrintArea/BleedBox\n"); + else if (p->ViewerPreferences.PrintArea == use_trim) + pdc_printf(p->out, "/PrintArea/TrimBox\n"); + else if (p->ViewerPreferences.PrintArea == use_art) + pdc_printf(p->out, "/PrintArea/ArtBox\n"); + + if (p->ViewerPreferences.PrintClip == use_media) + pdc_printf(p->out, "/PrintClip/MediaBox\n"); + if (p->ViewerPreferences.PrintClip == use_bleed) + pdc_printf(p->out, "/PrintClip/BleedBox\n"); + else if (p->ViewerPreferences.PrintClip == use_trim) + pdc_printf(p->out, "/PrintClip/TrimBox\n"); + else if (p->ViewerPreferences.PrintClip == use_art) + pdc_printf(p->out, "/PrintClip/ArtBox\n"); + + pdc_end_dict(p->out); /* ViewerPreferences */ + } + + /* + * specify the open action (display of the first page) + * default: top of the first page at default zoom level + */ + if (p->open_action.type != fitwindow || + p->open_action.zoom != -1 || + p->open_action.page != 0) { + pdc_puts(p->out, "/OpenAction"); + pdf_write_destination(p, &p->open_action); + pdc_puts(p->out, "\n"); + } + + /* + * specify the document's open mode + * default = open_none: open document with neither bookmarks nor + * thumbnails visible + */ + if (p->open_mode == open_bookmarks) { + pdc_printf(p->out, "/PageMode/UseOutlines\n"); + + } else if (p->open_mode == open_thumbnails) { + pdc_printf(p->out, "/PageMode/UseThumbs\n"); + + } else if (p->open_mode == open_fullscreen) { + pdc_printf(p->out, "/PageMode/FullScreen\n"); + } + + if (p->base) { + pdc_puts(p->out, "/URI<out, p->base, (int) strlen(p->base)); + pdc_end_dict(p->out); + } + + /* Pages object */ + pdc_printf(p->out, "/Pages %ld 0 R\n", pages_id); + + if (names_id != PDC_BAD_ID) { + pdc_printf(p->out, "/Names"); + pdc_begin_dict(p->out); /* Names */ + pdc_printf(p->out, "/Dests %ld 0 R\n", names_id); + pdc_end_dict(p->out); /* Names */ + } + + pdf_write_outline_root(p); + + pdc_end_dict(p->out); /* Catalog */ + pdc_end_obj(p->out); + + return root_id; +} + +static void +pdf_cleanup_contents(PDF *p) +{ + /* clean up all document-related stuff */ + if (p->contents_ids) { + pdc_free(p->pdc, p->contents_ids); + p->contents_ids = NULL; + } + if (p->pages) { + pdc_free(p->pdc, p->pages); + p->pages = NULL; + } + if (p->base) { + pdc_free(p->pdc, p->base); + p->base = NULL; + } + if (p->pnodes) { + pdc_free(p->pdc, p->pnodes); + p->pnodes = NULL; + } + + if (p->currtext) { + pdc_free(p->pdc, p->currtext); + p->currtext = NULL; + } + + pdf_cleanup_destination(p, &p->open_action); + pdf_cleanup_destination(p, &p->bookmark_dest); + + pdf_cleanup_info(p); + pdf_cleanup_fonts(p); + pdf_cleanup_outlines(p); + pdf_cleanup_annots(p); + pdf_cleanup_names(p); + pdf_cleanup_colorspaces(p); + pdf_cleanup_pattern(p); + pdf_cleanup_shadings(p); + pdf_cleanup_images(p); + pdf_cleanup_xobjects(p); + pdf_cleanup_extgstates(p); +} + +PDFLIB_API void PDFLIB_CALL +PDF_close(PDF *p) +{ + static const char fn[] = "PDF_close"; + + pdc_id info_id; + pdc_id root_id; + + if (!pdf_enter_api(p, fn, pdf_state_document, "(p[%p])\n", (void *) p)) + return; + + if (PDF_GET_STATE(p) != pdf_state_error) { + if (p->current_page == 0) + pdc_error(p->pdc, PDF_E_DOC_EMPTY, 0, 0, 0, 0); + + /* Write all pending document information up to xref table + trailer */ + info_id = pdf_write_info(p); + pdf_write_doc_fonts(p); /* font objects */ + pdf_write_doc_colorspaces(p); /* color space resources */ + pdf_write_doc_extgstates(p); /* ExtGState resources */ + root_id = pdf_write_pages_and_catalog(p); + pdf_write_outlines(p); + pdc_write_xref_and_trailer(p->out, info_id, root_id); + } + + pdc_close_output(p->out); + + /* Don't call pdc_cleanup_output() here because we may still need + * the buffer contents for PDF_get_buffer() after PDF_close(). + */ + pdf_cleanup_contents(p); + + /* UPR stuff not released here but in PDF_delete() */ + + PDF_SET_STATE(p, pdf_state_object); +} + +void +pdf_begin_contents_section(PDF *p) +{ + if (p->contents != c_none) + return; + + if (p->next_content >= p->contents_ids_capacity) { + p->contents_ids_capacity *= 2; + p->contents_ids = (pdc_id *) pdc_realloc(p->pdc, p->contents_ids, + sizeof(pdc_id) * p->contents_ids_capacity, + "pdf_begin_contents_section"); + } + + p->contents_ids[p->next_content] = pdc_begin_obj(p->out, PDC_NEW_ID); + p->contents = c_page; + pdc_begin_dict(p->out); + p->length_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/Length %ld 0 R\n", p->length_id); + + if (pdc_get_compresslevel(p->out)) + pdc_puts(p->out, "/Filter/FlateDecode\n"); + + pdc_end_dict(p->out); + + pdc_begin_pdfstream(p->out); + + p->next_content++; +} + +void +pdf_end_contents_section(PDF *p) +{ + if (p->contents == c_none) + return; + + pdf_end_text(p); + p->contents = c_none; + + pdc_end_pdfstream(p->out); + pdc_end_obj(p->out); + + pdc_put_pdfstreamlength(p->out, p->length_id); +} + +PDFLIB_API void PDFLIB_CALL +PDF_begin_page(PDF *p, float width, float height) +{ + static const char fn[] = "PDF_begin_page"; + + if (!pdf_enter_api(p, fn, pdf_state_document, "(p[%p], %g, %g)\n", + (void *) p, width, height)) + return; + + if (width <= 0) + pdc_error(p->pdc, PDC_E_ILLARG_POSITIVE, "width", 0, 0, 0); + + if (height <= 0) + pdc_error(p->pdc, PDC_E_ILLARG_POSITIVE, "height", 0, 0, 0); + + if ((height < PDF_ACRO4_MINPAGE || width < PDF_ACRO4_MINPAGE || + height > PDF_ACRO4_MAXPAGE || width > PDF_ACRO4_MAXPAGE)) + pdc_warning(p->pdc, PDF_E_PAGE_SIZE_ACRO4, 0, 0, 0, 0); + + + if (++(p->current_page) >= p->pages_capacity) + pdf_grow_pages(p); + + /* no id has been preallocated */ + if (p->pages[p->current_page] == PDC_BAD_ID) + p->pages[p->current_page] = pdc_alloc_id(p->out); + + p->height = height; + p->width = width; + p->thumb_id = PDC_BAD_ID; + p->next_content = 0; + p->contents = c_none; + p->sl = 0; + + pdc_rect_init(&p->CropBox, (float) 0, (float) 0, (float) 0, (float) 0); + pdc_rect_init(&p->BleedBox, (float) 0, (float) 0, (float) 0, (float) 0); + pdc_rect_init(&p->TrimBox, (float) 0, (float) 0, (float) 0, (float) 0); + pdc_rect_init(&p->ArtBox, (float) 0, (float) 0, (float) 0, (float) 0); + + PDF_SET_STATE(p, pdf_state_page); + + pdf_init_page_annots(p); + pdf_init_tstate(p); + pdf_init_gstate(p); + pdf_init_cstate(p); + + pdf_begin_contents_section(p); + + + /* top-down y coordinates */ + pdf_set_topdownsystem(p, height); +} + +PDFLIB_API void PDFLIB_CALL +PDF_end_page(PDF *p) +{ + static const char fn[] = "PDF_end_page"; + int idx; + + + if (!pdf_enter_api(p, fn, pdf_state_page, "(p[%p])\n", (void *) p)) + return; + + + /* check whether PDF_save() and PDF_restore() calls are balanced */ + if (p->sl > 0) + pdc_error(p->pdc, PDF_E_GSTATE_UNMATCHEDSAVE, 0, 0, 0, 0); + + /* restore text parameter and color defaults for out-of-page usage. + */ + pdf_init_tstate(p); + pdf_init_cstate(p); + + pdf_end_contents_section(p); + + /* Page object */ + pdc_begin_obj(p->out, p->pages[p->current_page]); + + pdc_begin_dict(p->out); + pdc_puts(p->out, "/Type/Page\n"); + pdc_printf(p->out, "/Parent %ld 0 R\n", pdf_get_pnode_id(p)); + + p->res_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/Resources %ld 0 R\n", p->res_id); + + pdc_printf(p->out, "/MediaBox[0 0 %f %f]\n", p->width, p->height); + + + if (!pdc_rect_isnull(&p->CropBox)) + { + if (p->CropBox.urx <= p->CropBox.llx || + p->CropBox.ury <= p->CropBox.lly) + pdc_error(p->pdc, PDF_E_PAGE_BADBOX, "CropBox", + pdc_errprintf(p->pdc, "%f %f %f %f", + p->CropBox.llx, p->CropBox.lly, + p->CropBox.urx, p->CropBox.ury), 0, 0); + + pdc_printf(p->out, "/CropBox[%f %f %f %f]\n", + p->CropBox.llx, p->CropBox.lly, p->CropBox.urx, p->CropBox.ury); + } + + if (!pdc_rect_isnull(&p->BleedBox)) + { + if (p->BleedBox.urx <= p->BleedBox.llx || + p->BleedBox.ury <= p->BleedBox.lly) + pdc_error(p->pdc, PDF_E_PAGE_BADBOX, "BleedBox", + pdc_errprintf(p->pdc, "%f %f %f %f", + p->BleedBox.llx, p->BleedBox.lly, + p->BleedBox.urx, p->BleedBox.ury), 0, 0); + + pdc_printf(p->out, "/BleedBox[%f %f %f %f]\n", + p->BleedBox.llx, p->BleedBox.lly, p->BleedBox.urx, p->BleedBox.ury); + } + + if (!pdc_rect_isnull(&p->TrimBox)) + { + if (p->TrimBox.urx <= p->TrimBox.llx || + p->TrimBox.ury <= p->TrimBox.lly) + pdc_error(p->pdc, PDF_E_PAGE_BADBOX, "TrimBox", + pdc_errprintf(p->pdc, "%f %f %f %f", + p->TrimBox.llx, p->TrimBox.lly, + p->TrimBox.urx, p->TrimBox.ury), 0, 0); + + pdc_printf(p->out, "/TrimBox[%f %f %f %f]\n", + p->TrimBox.llx, p->TrimBox.lly, p->TrimBox.urx, p->TrimBox.ury); + } + + if (!pdc_rect_isnull(&p->ArtBox)) + { + if (p->ArtBox.urx <= p->ArtBox.llx || + p->ArtBox.ury <= p->ArtBox.lly) + pdc_error(p->pdc, PDF_E_PAGE_BADBOX, "ArtBox", + pdc_errprintf(p->pdc, "%f %f %f %f", + p->ArtBox.llx, p->ArtBox.lly, + p->ArtBox.urx, p->ArtBox.ury), 0, 0); + + pdc_printf(p->out, "/ArtBox[%f %f %f %f]\n", + p->ArtBox.llx, p->ArtBox.lly, p->ArtBox.urx, p->ArtBox.ury); + } + + /* + * The duration can be placed in the transition dictionary (/D) + * or in the page dictionary (/Dur). We put it here so it can + * be used without setting a transition effect. + */ + + if (p->duration > 0) + pdc_printf(p->out, "/Dur %f\n", p->duration); + + pdf_write_page_transition(p); + + pdc_puts(p->out, "/Contents["); + for (idx = 0; idx < p->next_content; idx++) { + pdc_printf(p->out, "%ld 0 R", p->contents_ids[idx]); + pdc_putc(p->out, (char) (idx + 1 % 8 ? PDF_SPACE : PDF_NEWLINE)); + } + pdc_puts(p->out, "]\n"); + + /* Thumbnail image */ + if (p->thumb_id != PDC_BAD_ID) + pdc_printf(p->out, "/Thumb %ld 0 R\n", p->thumb_id); + + pdf_write_annots_root(p); + + pdc_end_dict(p->out); /* Page object */ + pdc_end_obj(p->out); + + pdf_write_page_annots(p); /* Annotation dicts */ + + pdc_begin_obj(p->out, p->res_id); /* resource object */ + pdc_begin_dict(p->out); /* resource dict */ + + pdf_write_page_fonts(p); /* Font resources */ + + pdf_write_page_colorspaces(p); /* Color space resources */ + + pdf_write_page_pattern(p); /* Pattern resources */ + + pdf_write_page_shadings(p); /* Shading resources */ + + pdf_write_xobjects(p); /* XObject resources */ + + pdf_write_page_extgstates(p); /* ExtGState resources */ + + pdc_end_dict(p->out); /* resource dict */ + pdc_end_obj(p->out); /* resource object */ + + /* Free all page-related resources */ + pdf_cleanup_page_annots(p); + + PDF_SET_STATE(p, pdf_state_document); + + if (p->flush & pdf_flush_page) + pdc_flush_stream(p->out); +} + +void +pdf_grow_pages(PDF *p) +{ + int i; + + p->pages_capacity *= 2; + p->pages = (pdc_id *) pdc_realloc(p->pdc, p->pages, + sizeof(pdc_id) * p->pages_capacity, "pdf_grow_pages"); + for (i = p->pages_capacity/2; i < p->pages_capacity; i++) + p->pages[i] = PDC_BAD_ID; +} + +/* ------------------- exception handling ------------------- */ + +PDFLIB_API pdf_jmpbuf * PDFLIB_CALL +pdf_jbuf(PDF *p) +{ + return (pdf_jmpbuf *) pdc_jbuf(p->pdc); +} + +PDFLIB_API void PDFLIB_CALL +pdf_exit_try(PDF *p) +{ + if (p == NULL || p->magic != PDC_MAGIC) + return; + + pdc_exit_try(p->pdc); +} + +PDFLIB_API int PDFLIB_CALL +pdf_catch(PDF *p) +{ + if (p == NULL || p->magic != PDC_MAGIC) + return pdc_false; + + return pdc_catch_extern(p->pdc); +} + +PDFLIB_API void PDFLIB_CALL +pdf_rethrow(PDF *p) +{ + if (p == NULL || p->magic != PDC_MAGIC) + return; + + pdc_rethrow(p->pdc); +} + +PDFLIB_API void PDFLIB_CALL +pdf_throw(PDF *p, const char *parm1, const char *parm2, const char *parm3) +{ + pdc_enter_api(p->pdc, "pdf_throw"); + + pdc_error(p->pdc, PDF_E_INT_WRAPPER, parm1, parm2, parm3, NULL); +} + +/* -------------------------- handle check -------------------------------*/ + +void +pdf_check_handle(PDF *p, int handle, pdc_opttype type) +{ + int minval = 0, maxval = 0; + pdc_bool empty = pdc_false; + + switch (type) + { + case pdc_colorhandle: + maxval = p->colorspaces_number - 1; + break; + + + case pdc_fonthandle: + maxval = p->fonts_number - 1; + break; + + case pdc_gstatehandle: + maxval = p->extgstates_number; + break; + + + case pdc_imagehandle: + maxval = p->images_capacity - 1; + if (handle >= minval && handle <= maxval && + (!p->images[handle].in_use || + p->xobjects[p->images[handle].no].type == pdi_xobject)) + empty = pdc_true; + break; + + case pdc_pagehandle: + maxval = p->images_capacity - 1; + if (handle >= minval && handle <= maxval && + (!p->images[handle].in_use || + p->xobjects[p->images[handle].no].type != pdi_xobject)) + empty = pdc_true; + break; + + case pdc_patternhandle: + maxval = p->pattern_number - 1; + break; + + case pdc_shadinghandle: + maxval = p->shadings_number - 1; + break; + + default: + break; + } + + if (handle < minval || handle > maxval || empty) + { + const char *stemp1 = pdc_errprintf(p->pdc, "%s", + pdc_get_handletype(type)); + const char *stemp2 = pdc_errprintf(p->pdc, "%d", + p->hastobepos ? handle + 1 : handle); + pdc_error(p->pdc, PDC_E_ILLARG_HANDLE, stemp1, stemp2, 0, 0); + } +} diff --git a/src/libs/pdflib/libs/pdflib/p_block.c b/src/libs/pdflib/libs/pdflib/p_block.c new file mode 100644 index 0000000000..525c2ce5be --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_block.c @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_block.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * Block processing routines (require the PDI library) + * + */ + +#define P_BLOCK_C + +#include "p_intern.h" +#include "p_font.h" +#include "p_image.h" + + +PDFLIB_API int PDFLIB_CALL +PDF_fill_textblock(PDF *p, +int page, const char *blockname, const char *text, int len, const char *optlist) +{ + static const char fn[] = "PDF_fill_textblock"; + + if (!pdf_enter_api(p, fn, + (pdf_state) pdf_state_content, + "(p[%p], %d, \"%s\", \"%s\", %d, \"%s\")", + (void *) p, page, blockname, + pdc_strprint(p->pdc, text, len), len, optlist)) + { + PDF_RETURN_BOOLEAN(p, -1); + } + + pdc_error(p->pdc, PDF_E_UNSUPP_BLOCK, 0, 0, 0, 0); + + PDF_RETURN_BOOLEAN(p, -1); +} + +PDFLIB_API int PDFLIB_CALL +PDF_fill_imageblock(PDF *p, +int page, const char *blockname, int image, const char *optlist) +{ + static const char fn[] = "PDF_fill_imageblock"; + + if (!pdf_enter_api(p, fn, + (pdf_state) pdf_state_content, + "(p[%p], %d, \"%s\", %d, \"%s\")", + (void *) p, page, blockname, image, optlist)) + { + PDF_RETURN_BOOLEAN(p, -1); + } + + pdc_error(p->pdc, PDF_E_UNSUPP_BLOCK, 0, 0, 0, 0); + + PDF_RETURN_BOOLEAN(p, -1); +} + +PDFLIB_API int PDFLIB_CALL +PDF_fill_pdfblock(PDF *p, +int page, const char *blockname, int contents, const char *optlist) +{ + static const char fn[] = "PDF_fill_pdfblock"; + + if (!pdf_enter_api(p, fn, + (pdf_state) pdf_state_content, + "(p[%p], %d, \"%s\", %d, \"%s\")", + (void *) p, page, blockname, contents, optlist)) + { + PDF_RETURN_BOOLEAN(p, -1); + } + + pdc_error(p->pdc, PDF_E_UNSUPP_BLOCK, 0, 0, 0, 0); + + PDF_RETURN_BOOLEAN(p, -1); +} + diff --git a/src/libs/pdflib/libs/pdflib/p_bmp.c b/src/libs/pdflib/libs/pdflib/p_bmp.c new file mode 100644 index 0000000000..688d920eb3 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_bmp.c @@ -0,0 +1,597 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_bmp.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * BMP processing for PDFlib + * + */ + +#include "p_intern.h" +#include "p_image.h" + +#ifndef PDF_BMP_SUPPORTED + +pdc_bool +pdf_is_BMP_file(PDF *p, pdc_file *fp) +{ + (void) p; + (void) fp; + + return pdc_false; +} + +int +pdf_process_BMP_data( + PDF *p, + int imageslot) +{ + (void) imageslot; + + pdc_warning(p->pdc, PDF_E_UNSUPP_IMAGE, "BMP", 0, 0, 0); + return -1; +} + +#else /* !PDF_BMP_SUPPORTED */ + +/* for documentation only */ +#if 0 + +/* BMP file header structure */ +typedef struct +{ + pdc_ushort bfType; /* Magic number for file */ + pdc_ulong bfSize; /* Size of file */ + pdc_ushort bfReserved1; /* Reserved */ + pdc_ushort bfReserved2; /* ... */ + pdc_ulong bfOffBits; /* Offset to bitmap data */ +} +BITMAPFILEHEADER; + +/* BMP file info structure */ +typedef struct +{ + pdc_ulong biSize; /* Size of info header */ + pdc_long biWidth; /* Width of image */ + pdc_long biHeight; /* Height of image */ + pdc_ushort biPlanes; /* Number of color planes */ + pdc_ushort biBitCount; /* Number of bits per pixel */ + pdc_ulong biCompression; /* Type of compression to use */ + pdc_ulong biSizeImage; /* Size of image data */ + pdc_long biXPelsPerMeter; /* X pixels per meter */ + pdc_long biYPelsPerMeter; /* Y pixels per meter */ + pdc_ulong biClrUsed; /* Number of colors used */ + pdc_ulong biClrImportant; /* Number of important colors */ +} +BITMAPINFOHEADER; + +#endif + +#define PDF_GET_BYTE(pos) *pos, pos += sizeof(pdc_byte) +#define PDF_GET_SHORT(pos) pdc_get_le_short(pos), pos += sizeof(pdc_short) +#define PDF_GET_USHORT(pos) pdc_get_le_ushort(pos), pos += sizeof(pdc_ushort) +#define PDF_GET_LONG(pos) pdc_get_le_long(pos), pos += sizeof(pdc_long) +#define PDF_GET_ULONG(pos) pdc_get_le_ulong(pos), pos += sizeof(pdc_ulong) + +#define PDF_BMP_STRING "\102\115" /* "BM" */ + +#define PDF_BMP_RGB 0 /* No compression - straight BGR data */ +#define PDF_BMP_RLE8 1 /* 8-bit run-length compression */ +#define PDF_BMP_RLE4 2 /* 4-bit run-length compression */ +#define PDF_BMP_BITFIELDS 3 /* RGB bitmap with RGB masks */ + +#define PDF_BMP_FILE_HEADSIZE 14 /* File header size */ +#define PDF_BMP_INFO_HEAD2SIZE 12 /* Info header size BMP Version 2 */ +#define PDF_BMP_INFO_HEAD3SIZE 40 /* Info header size BMP Version 3 */ +#define PDF_BMP_INFO_HEAD4SIZE 108 /* Info header size BMP Version 4 */ + +static void +pdf_data_source_BMP_init(PDF *p, PDF_data_source *src) +{ + static const char *fn = "pdf_data_source_BMP_init"; + pdf_image *image = (pdf_image *) src->private_data; + + src->buffer_length = image->info.bmp.rowbytes_pdf; + src->buffer_start = (pdc_byte *) + pdc_calloc(p->pdc, image->info.bmp.rowbytes_pad, fn); + src->bytes_available = image->info.bmp.rowbytes_pdf; + src->next_byte = src->buffer_start; +} + +static pdc_bool +pdf_data_source_BMP_fill(PDF *p, PDF_data_source *src) +{ + pdf_image *image = (pdf_image *) src->private_data; + pdc_byte c; + int i; + + /* No compression */ + if (image->info.bmp.compression == PDF_BMP_RGB) + { + size_t avail; + + /* Read 1 padded row from file */ + avail = pdc_fread(src->buffer_start, 1, image->info.bmp.rowbytes_pad, + image->fp); + if (avail > 0) + { + /* Fill up remaining bytes */ + if (avail < image->info.bmp.rowbytes_pad) + { + for (i = (int) avail; i < (int) src->buffer_length; i++) + src->buffer_start[i] = 0; + } + + /* Swap red and blue */ + if (image->colorspace == DeviceRGB) + { + for (i = 0; i < (int) src->bytes_available; i += 3) + { + c = src->buffer_start[i]; + src->buffer_start[i] = src->buffer_start[i + 2]; + src->buffer_start[i + 2] = c; + } + } + } + else + { + src->bytes_available = 0; + } + } + + /* Compression methods RLE8 and RLE4 */ + else + { + int col = 0, fnibble = 1; + pdc_byte cc, ccc, cn[2], ccn; + + if (image->info.bmp.pos < image->info.bmp.end) + { + if (image->info.bmp.skiprows) + { + for (; col < (int) image->info.bmp.rowbytes; col++) + src->buffer_start[col] = 0; + image->info.bmp.skiprows--; + } + else + { + while (1) + { + c = *image->info.bmp.pos; + image->info.bmp.pos++; + if (image->info.bmp.pos >= image->info.bmp.end) + goto PDF_BMP_CORRUPT; + cc = *image->info.bmp.pos; + + if (c != 0) + { + /* Repeat c time pixel value */ + if (image->info.bmp.compression == PDF_BMP_RLE8) + { + for (i = 0; i < (int) c; i++) + { + if (col >= (int) image->info.bmp.rowbytes) + goto PDF_BMP_CORRUPT; + src->buffer_start[col] = cc; + col++; + } + } + else + { + cn[0] = (pdc_byte) ((cc & 0xF0) >> 4); + cn[1] = (pdc_byte) (cc & 0x0F); + for (i = 0; i < (int) c; i++) + { + if (col >= (int) image->info.bmp.rowbytes) + goto PDF_BMP_CORRUPT; + ccn = cn[i%2]; + if (fnibble) + { + fnibble = 0; + src->buffer_start[col] = + (pdc_byte) (ccn << 4); + } + else + { + fnibble = 1; + src->buffer_start[col] |= ccn; + col++; + } + } + } + } + else if (cc > 2) + { + /* cc different pixel values */ + if (image->info.bmp.compression == PDF_BMP_RLE8) + { + for (i = 0; i < (int) cc; i++) + { + image->info.bmp.pos++; + if (image->info.bmp.pos >= image->info.bmp.end) + goto PDF_BMP_CORRUPT; + if (col >= (int) image->info.bmp.rowbytes) + goto PDF_BMP_CORRUPT; + src->buffer_start[col] = *image->info.bmp.pos; + col++; + } + } + else + { + for (i = 0; i < (int) cc; i++) + { + if (!(i%2)) + { + image->info.bmp.pos++; + if (image->info.bmp.pos >= + image->info.bmp.end) + goto PDF_BMP_CORRUPT; + ccc = *image->info.bmp.pos; + cn[0] = (pdc_byte) ((ccc & 0xF0) >> 4); + cn[1] = (pdc_byte) (ccc & 0x0F); + } + if (col >= (int) image->info.bmp.rowbytes) + goto PDF_BMP_CORRUPT; + ccn = cn[i%2]; + if (fnibble) + { + fnibble = 0; + src->buffer_start[col] = + (pdc_byte) (ccn << 4); + } + else + { + fnibble = 1; + src->buffer_start[col] |= ccn; + col++; + } + } + if (cc % 2) cc++; + cc /= 2; + } + + /* Odd number of bytes */ + if (cc % 2) + image->info.bmp.pos++; + } + else if (cc < 2) + { + /* End of scan line or end of bitmap data*/ + for (; col < (int) image->info.bmp.rowbytes; col++) + src->buffer_start[col] = 0; + } + else if (cc == 2) + { + int cola; + + /* Run offset marker */ + if (image->info.bmp.pos >= image->info.bmp.end - 1) + goto PDF_BMP_CORRUPT; + image->info.bmp.pos++; + c = *image->info.bmp.pos; + image->info.bmp.pos++; + cc = *image->info.bmp.pos; + + /* Fill current row */ + cola = col; + for (; col < (int) image->info.bmp.rowbytes; col++) + src->buffer_start[col] = 0; + if (col - cola != (int) c) + goto PDF_BMP_CORRUPT; + + /* Number of rows to be skipped */ + image->info.bmp.skiprows = (size_t) cc; + } + + image->info.bmp.pos++; + if (col >= (int) image->info.bmp.rowbytes) + { + /* Skip end of scan line marker */ + if (image->info.bmp.pos < image->info.bmp.end - 1) + { + c = *image->info.bmp.pos; + cc = *(image->info.bmp.pos + 1); + if(cc == 0 && cc <= 1) + image->info.bmp.pos += 2; + } + break; + } + } + } + } + else + { + src->bytes_available = 0; + } + } + + return (src->bytes_available ? pdc_true : pdc_false); + + PDF_BMP_CORRUPT: + pdc_error(p->pdc, PDF_E_IMAGE_CORRUPT, "BMP", + pdc_errprintf(p->pdc, "%s", image->filename), 0, 0); + src->bytes_available = 0; + return pdc_false; +} + +static void +pdf_data_source_BMP_terminate(PDF *p, PDF_data_source *src) +{ + pdf_image *image = (pdf_image *) src->private_data; + + pdc_free(p->pdc, (void *) src->buffer_start); + if (image->info.bmp.bitmap != NULL) + pdc_free(p->pdc, (void *) image->info.bmp.bitmap); +} + +pdc_bool +pdf_is_BMP_file(PDF *p, pdc_file *fp) +{ + pdc_byte buf[2]; + + (void) p; + + if (pdc_fread(buf, 1, 2, fp) < 2 || + strncmp((const char *) buf, PDF_BMP_STRING, 2) != 0) + { + pdc_fseek(fp, 0L, SEEK_SET); + return pdc_false; + } + return pdc_true; +} + +int +pdf_process_BMP_data( + PDF *p, + int imageslot) +{ + static const char *fn = "pdf_process_BMP_data"; + pdc_byte buf[256], *pos, *cmap, bdummy; + pdf_image *image = &p->images[imageslot]; + pdc_file *fp = image->fp; + pdc_ulong uldummy, infosize = 0, offras = 0, planes = 0, bitmapsize = 0; + pdc_ulong ncolors = 0, importcolors = 0, compression = PDF_BMP_RGB; + pdc_ushort usdummy, bpp = 0; + pdc_long width = 0, height = 0, dpi_x = 0, dpi_y = 0; + size_t nbytes; + pdf_colorspace cs; + pdf_colormap colormap; + int i, slot, colsize = 0, errcode = 0; + + /* Error reading magic number or not a BMP file */ + if (pdf_is_BMP_file(p, image->fp) == pdc_false) + { + errcode = PDC_E_IO_BADFORMAT; + goto PDF_BMP_ERROR; + } + + /* read file header without FileType field + */ + /* Size field of info header */ + pos = &buf[2]; + nbytes = PDF_BMP_FILE_HEADSIZE - 2 + 4; + if (!PDC_OK_FREAD(fp, pos, nbytes)) + { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_BMP_ERROR; + } + uldummy = PDF_GET_ULONG(pos); + usdummy = PDF_GET_USHORT(pos); + usdummy = PDF_GET_USHORT(pos); + offras = PDF_GET_ULONG(pos); + infosize = PDF_GET_ULONG(pos); + + /* no support of later version than 3 */ + if (infosize != PDF_BMP_INFO_HEAD2SIZE && + infosize != PDF_BMP_INFO_HEAD3SIZE) + { + errcode = PDF_E_BMP_VERSUNSUPP; + goto PDF_BMP_ERROR; + } + + /* info header */ + pos = buf; + nbytes = infosize - 4; + if (!PDC_OK_FREAD(fp, pos, nbytes)) + { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_BMP_ERROR; + } + if (infosize == PDF_BMP_INFO_HEAD2SIZE) + { + width = PDF_GET_SHORT(pos); + height = PDF_GET_SHORT(pos); + planes = PDF_GET_USHORT(pos); + bpp = PDF_GET_USHORT(pos); + colsize = 3; + } + else if (infosize == PDF_BMP_INFO_HEAD3SIZE) + { + width = PDF_GET_LONG(pos); + height = PDF_GET_LONG(pos); + planes = PDF_GET_USHORT(pos); + bpp = PDF_GET_USHORT(pos); + compression = PDF_GET_ULONG(pos); + bitmapsize = PDF_GET_ULONG(pos); + dpi_x = PDF_GET_LONG(pos); + dpi_y = PDF_GET_LONG(pos); + ncolors = PDF_GET_ULONG(pos); + importcolors = PDF_GET_ULONG(pos); + colsize = 4; + } + + /* only uncompressed BMP images */ + if (compression > PDF_BMP_RLE4) + { + errcode = PDF_E_BMP_COMPUNSUPP; + goto PDF_BMP_ERROR; + } + image->bpc = bpp; + image->width = (float) width; + image->height = (float) -height; + image->dpi_x = (float) (PDC_INCH2METER * dpi_x); + image->dpi_y = (float) (PDC_INCH2METER * dpi_y); + + /* color map only for bpp = 1, 4, 8 */ + if (bpp < 16) + { + if (!ncolors) + ncolors = (pdc_ulong) (1 << bpp); + if (ncolors > (offras - PDF_BMP_FILE_HEADSIZE - infosize) / colsize) + { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_BMP_ERROR; + } + + /* allocate and read color map */ + nbytes = colsize * ncolors; + cmap = (pdc_byte *) pdc_malloc(p->pdc, nbytes, fn); + if (!PDC_OK_FREAD(fp, cmap, nbytes)) + { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_BMP_ERROR; + } + + /* set color map (bgr) */ + pos = cmap; + for (i = 0; i < (int) ncolors; i++) + { + colormap[i][2] = PDF_GET_BYTE(pos); + colormap[i][1] = PDF_GET_BYTE(pos); + colormap[i][0] = PDF_GET_BYTE(pos); + if (infosize == PDF_BMP_INFO_HEAD3SIZE) + { + bdummy = PDF_GET_BYTE(pos); + } + } + pdc_free(p->pdc, cmap); + + image->components = 1; + + cs.type = Indexed; + cs.val.indexed.base = DeviceRGB; + cs.val.indexed.palette_size = (int) ncolors; + cs.val.indexed.colormap = &colormap; + cs.val.indexed.colormap_id = PDC_BAD_ID; + slot = pdf_add_colorspace(p, &cs, pdc_false); + + image->colorspace = (pdf_colorspacetype) slot; + + + } + else + { + image->colorspace = DeviceRGB; + image->components = 3; + image->bpc = 8; + } + + if (image->imagemask) + { + if (image->components != 1) { + errcode = PDF_E_IMAGE_BADMASK; + goto PDF_BMP_ERROR; + } + + if (p->compatibility <= PDC_1_3) { + if (image->components != 1 || image->bpc != 1) { + errcode = PDF_E_IMAGE_MASK1BIT13; + goto PDF_BMP_ERROR; + } + } else if (image->bpc > 1) { + /* images with more than one bit will be written as /SMask, + * and don't require an /ImageMask entry. + */ + image->imagemask = pdc_false; + } + image->colorspace = DeviceGray; + } + + + /* we invert this flag later */ + if (image->ignoremask) + image->transparent = pdc_true; + + /* numbers of bytes per row */ + image->info.bmp.rowbytes_pdf = (size_t) ((bpp * width + 7) / 8); + if (bpp == 4) + image->info.bmp.rowbytes = image->info.bmp.rowbytes_pdf; + else + image->info.bmp.rowbytes = (size_t) ((bpp * width) / 8); + image->info.bmp.rowbytes_pad = (size_t) (4 * ((bpp * width + 31) / 32)); + image->info.bmp.compression = compression; + image->info.bmp.skiprows = 0; + image->info.bmp.bitmap = NULL; + + /* read whole bitmap */ + if (image->info.bmp.compression != PDF_BMP_RGB) + { + image->info.bmp.bitmap = + (pdc_byte *) pdc_malloc(p->pdc, bitmapsize, fn); + if (!PDC_OK_FREAD(fp, image->info.bmp.bitmap, bitmapsize)) + { + pdc_free(p->pdc, (void *) image->info.bmp.bitmap); + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_BMP_ERROR; + } + image->info.bmp.pos = image->info.bmp.bitmap; + image->info.bmp.end = image->info.bmp.bitmap + bitmapsize; + } + + /* offset bitmap data */ + pdc_fseek(image->fp, (pdc_long) offras, SEEK_SET); + + /* put image data */ + image->src.init = pdf_data_source_BMP_init; + image->src.fill = pdf_data_source_BMP_fill; + image->src.terminate = pdf_data_source_BMP_terminate; + image->src.private_data = (void *) image; + + image->use_raw = pdc_false; + image->in_use = pdc_true; + + pdf_put_image(p, imageslot, pdc_true); + + return imageslot; + + PDF_BMP_ERROR: + { + const char *stemp = pdc_errprintf(p->pdc, "%s", image->filename); + switch (errcode) + { + case PDF_E_IMAGE_MASK1BIT13: + case PDF_E_BMP_VERSUNSUPP: + case PDF_E_BMP_COMPUNSUPP: + case PDF_E_IMAGE_BADMASK: + pdc_set_errmsg(p->pdc, errcode, stemp, 0, 0, 0); + break; + + case PDC_E_IO_BADFORMAT: + pdc_set_errmsg(p->pdc, errcode, stemp, "BMP", 0, 0); + break; + + case PDF_E_IMAGE_CORRUPT: + pdc_set_errmsg(p->pdc, errcode, "BMP", stemp, 0, 0); + break; + + case 0: /* error code and message already set */ + break; + } + } + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; +} + +#endif /* PDF_BMP_SUPPORTED */ + diff --git a/src/libs/pdflib/libs/pdflib/p_ccitt.c b/src/libs/pdflib/libs/pdflib/p_ccitt.c new file mode 100644 index 0000000000..f240b2ed9e --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_ccitt.c @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_ccitt.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * CCITT (Fax G3 and G4) processing for PDFlib + * + */ + +#include "p_intern.h" +#include "p_image.h" + +/* + * Do a bit-reversal of all bytes in the buffer. + * This is supported for some clients which provide + * CCITT-compressed data in a byte-reversed format. + */ + +static void +pdf_reverse_bit_order(unsigned char *buffer, size_t size) +{ + size_t i; + + /* table for fast byte reversal */ + static const pdc_byte reverse[256] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff + }; + + if (buffer != NULL) { + for (i = 0; i < size; i++) { + buffer[i] = reverse[buffer[i]]; + } + } +} + +static void +pdf_data_source_ccitt_raw_init(PDF *p, PDF_data_source *src) +{ + (void) p; + + src->bytes_available = 0; +} + +static pdc_bool +pdf_data_source_ccitt_raw_fill(PDF *p, PDF_data_source *src) +{ + pdf_image *image; + pdc_bool ismem; + + (void) p; + + if (src->bytes_available) + return pdc_false; + + image = (pdf_image *) src->private_data; + + src->buffer_start = (pdc_byte *) + pdc_freadall(image->fp, (size_t *) &src->buffer_length, &ismem); + + if (src->buffer_length == 0) + return pdc_false; + + src->bytes_available = src->buffer_length; + src->next_byte = src->buffer_start; + + if (image->info.ccitt.BitReverse) + pdf_reverse_bit_order(src->buffer_start, src->bytes_available); + + if (ismem) + src->buffer_length = 0; + + return pdc_true; +} + +static void +pdf_data_source_ccitt_raw_terminate(PDF *p, PDF_data_source *src) +{ + if (src->buffer_length) + pdc_free(p->pdc, (void *) src->buffer_start); +} + +static int +pdf_process_ccitt_raw_data(PDF *p, int imageslot) +{ + pdf_image *image = &p->images[imageslot]; + const char *stemp = NULL; + + /* check data length for raw uncompressed images */ + if (image->compression == none && image->fp) + { + size_t length = pdc_file_size(image->fp); + if (length != (size_t)(image->height_pixel * + ((image->width_pixel * image->components * image->bpc + 7) / 8))) + { + stemp = pdc_errprintf(p->pdc, "%s", image->filename); + + pdc_set_errmsg(p->pdc, PDF_E_RAW_ILLSIZE, + pdc_errprintf(p->pdc, "%d", length), stemp, 0, 0); + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; + } + } + + + + if (image->reference == pdf_ref_direct) + { + image->src.init = pdf_data_source_ccitt_raw_init; + image->src.fill = pdf_data_source_ccitt_raw_fill; + image->src.terminate = pdf_data_source_ccitt_raw_terminate; + image->src.private_data = (void *) image; + } + + image->in_use = pdc_true; /* mark slot as used */ + + if (image->doinline) + pdf_put_inline_image(p, imageslot); + else + pdf_put_image(p, imageslot, pdc_true); + + return imageslot; +} + +int +pdf_process_CCITT_data(PDF *p, int imageslot) +{ + pdf_image *image = &p->images[imageslot]; + + /* CCITT specific information */ + image->info.ccitt.BitReverse = image->bitreverse; + image->compression = ccitt; + image->use_raw = pdc_true; + + return pdf_process_ccitt_raw_data(p, imageslot); +} + +int +pdf_process_RAW_data(PDF *p, int imageslot) +{ + pdf_image *image = &p->images[imageslot]; + + /* RAW specific information */ + image->info.ccitt.BitReverse = 0; + image->compression = none; + + return pdf_process_ccitt_raw_data(p, imageslot); +} diff --git a/src/libs/pdflib/libs/pdflib/p_cid.c b/src/libs/pdflib/libs/pdflib/p_cid.c new file mode 100644 index 0000000000..bd64d193f2 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_cid.c @@ -0,0 +1,185 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_cid.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib CID font handling routines + * + */ + +#include "p_intern.h" +#include "p_font.h" +#include "p_cid.h" + +/* returns font handle, +** or -1 if no font found, +** or -2 in case of an error. +*/ +int +pdf_handle_cidfont(PDF *p, const char *fontname, const char *encoding) +{ + pdc_font *font = &p->fonts[p->fonts_number]; + int slot, cmap, metric; + + /* + * Look whether font is already in the cache. + * If font with same name and encoding is found, + * return its descriptor. + */ + + for (slot = 0; slot < p->fonts_number; slot++) { + if (p->fonts[slot].encoding == pdc_cid && + p->fonts[slot].style == font->style && + !strcmp(p->fonts[slot].name, fontname) && + !strcmp(p->fonts[slot].cmapname, encoding)) + return slot; + } + + /* Check the requested CMap */ + for (cmap = 0; cmap < NUMBER_OF_CMAPS; cmap++) + if (!strcmp(cmaps[cmap].name, encoding)) + break; + + /* Unknown CMap */ + if (cmap == NUMBER_OF_CMAPS) + return -1; + + /* Check whether this CMap is supported in the desired PDF version */ + if (cmaps[cmap].compatibility > p->compatibility) + { + pdc_set_errmsg(p->pdc, PDF_E_DOC_PDFVERSION, + encoding, pdc_errprintf(p->pdc, "%d.%d", + p->compatibility/10, p->compatibility % 10), 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -2; + } + + /* Check whether the font name is among the known CID fonts */ + for (metric = 0; metric < SIZEOF_CID_METRICS; metric++) { + if (!strcmp(pdf_cid_metrics[metric].name, fontname)) + break; + } + + /* Unknown font */ + if (metric == SIZEOF_CID_METRICS) + { + pdc_set_errmsg(p->pdc, PDF_E_CJK_NOSTANDARD, fontname, 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -2; + } + + /* Selected CMap and font don't match */ + if (cmaps[cmap].charcoll != cc_identity && + cmaps[cmap].charcoll != pdf_cid_metrics[metric].charcoll) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_BADENC, fontname, encoding, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -2; + } + + /* For Unicode capable language wrappers only UCS2 CMaps allowed */ + if (cmaps[cmap].codesize == 0 && p->textformat == pdc_auto2) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_NEEDUCS2, encoding, fontname, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -2; + } + + p->fonts_number++; + + /* Code size of CMap */ + font->codeSize = 0; + font->numOfCodes = 0; + + /* Fill up the font struct */ + pdc_fill_font_metric(p->pdc, font, &pdf_cid_metrics[metric]); + + /* Now everything is fine; fill the remaining entries */ + font->encoding = pdc_cid; + font->cmapname = pdc_strdup(p->pdc, encoding); + font->ttname = pdc_strdup(p->pdc, fontname); + font->apiname = pdc_strdup(p->pdc, fontname); + font->obj_id = pdc_alloc_id(p->out); + font->embedding = pdc_false; + font->kerning = pdc_false; + font->subsetting = pdc_false; + font->autocidfont = pdc_false; + font->unicodemap = pdc_false; + font->autosubsetting = pdc_false; + + /* return valid font descriptor */ + return slot; +} + +const char * +pdf_get_ordering_cid(PDF *p, pdc_font *font) +{ + (void) p; + return pdc_get_keyword(font->charcoll, charcoll_names); /* in ASCII */ +} + +int +pdf_get_supplement_cid(PDF *p, pdc_font *font) +{ + int cmap, supplement; + + for (cmap = 0; cmap < NUMBER_OF_CMAPS; cmap++) + if (!strcmp(cmaps[cmap].name, font->cmapname)) + break; + + switch (p->compatibility) + { + case PDC_1_3: + supplement = cmaps[cmap].supplement13; + break; + + default: + supplement = cmaps[cmap].supplement14; + break; + } + + return supplement; +} + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED +void +pdf_put_cidglyph_widths(PDF *p, pdc_font *font) +{ + int slot; + + /* Check whether the font name is among the known CID fonts */ + for (slot = 0; slot < SIZEOF_CID_METRICS; slot++) { + if (!strcmp(pdf_cid_metrics[slot].name, font->apiname)) + break; + } + pdc_printf(p->out, "/DW %d\n", + font->monospace ? font->monospace : PDF_DEFAULT_CIDWIDTH); + if (!font->monospace) + { + if (slot < SIZEOF_CID_METRICS && pdf_cid_width_arrays[slot]) { + pdc_puts(p->out, pdf_cid_width_arrays[slot]); + } + } +} +#endif /* PDF_CJKFONTWIDTHS_SUPPORTED */ diff --git a/src/libs/pdflib/libs/pdflib/p_cid.h b/src/libs/pdflib/libs/pdflib/p_cid.h new file mode 100644 index 0000000000..e0ea6449d5 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_cid.h @@ -0,0 +1,955 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_cid.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * Header file for PDFlib CID font information + * + */ + +#ifndef P_CID_H +#define P_CID_H + +#include "pc_corefont.h" + +typedef struct { + const char *name; + pdc_charcoll charcoll; + short codesize; + short compatibility; + short supplement13; + short supplement14; +} pdf_cmap; + +static const pdc_keyconn charcoll_names[] = +{ + { "\107\102\061", cc_simplified_chinese }, /* GB1 */ + { "\103\116\123\061", cc_traditional_chinese}, /* CNS1 */ + { "\112\141\160\141\156\061", cc_japanese }, /* Japan1 */ + { "\113\157\162\145\141\061", cc_korean}, /* Korea1 */ + { "\111\144\145\156\164\151\164\171", cc_identity} /* Identity */ +}; + +/* predefined CMaps and the corresponding character collection */ + +static const pdf_cmap cmaps[] = { + { "GB-EUC-H", cc_simplified_chinese, 0, PDC_1_3, 0, 0 }, + { "GB-EUC-V", cc_simplified_chinese, 0, PDC_1_3, 0, 0 }, + { "GBpc-EUC-H", cc_simplified_chinese, 0, PDC_1_3, 0, 0 }, + { "GBpc-EUC-V", cc_simplified_chinese, 0, PDC_1_3, 0, 0 }, + { "GBK-EUC-H", cc_simplified_chinese, 0, PDC_1_3, 2, 2 }, + { "GBK-EUC-V", cc_simplified_chinese, 0, PDC_1_3, 2, 2 }, + { "GBKp-EUC-H", cc_simplified_chinese, 0, PDC_1_4, 0, 2 }, + { "GBKp-EUC-V", cc_simplified_chinese, 0, PDC_1_4, 0, 2 }, + { "GBK2K-H", cc_simplified_chinese, 0, PDC_1_4, 0, 4 }, + { "GBK2K-V", cc_simplified_chinese, 0, PDC_1_4, 0, 4 }, + { "UniGB-UCS2-H", cc_simplified_chinese, 2, PDC_1_3, 2, 4 }, + { "UniGB-UCS2-V", cc_simplified_chinese, 2, PDC_1_3, 2, 4 }, + + { "B5pc-H", cc_traditional_chinese, 0, PDC_1_3, 0, 0 }, + { "B5pc-V", cc_traditional_chinese, 0, PDC_1_3, 0, 0 }, + { "HKscs-B5-H", cc_traditional_chinese, 0, PDC_1_4, 0, 3 }, + { "HKscs-B5-V", cc_traditional_chinese, 0, PDC_1_4, 0, 3 }, + { "ETen-B5-H", cc_traditional_chinese, 0, PDC_1_3, 0, 0 }, + { "ETen-B5-V", cc_traditional_chinese, 0, PDC_1_3, 0, 0 }, + { "ETenms-B5-H", cc_traditional_chinese, 0, PDC_1_3, 0, 0 }, + { "ETenms-B5-V", cc_traditional_chinese, 0, PDC_1_3, 0, 0 }, + { "CNS-EUC-H", cc_traditional_chinese, 0, PDC_1_3, 0, 0 }, + { "CNS-EUC-V", cc_traditional_chinese, 0, PDC_1_3, 0, 0 }, + { "UniCNS-UCS2-H", cc_traditional_chinese, 2, PDC_1_3, 0, 3 }, + { "UniCNS-UCS2-V", cc_traditional_chinese, 2, PDC_1_3, 0, 3 }, + + { "83pv-RKSJ-H", cc_japanese, 0, PDC_1_3, 1, 1 }, + { "90ms-RKSJ-H", cc_japanese, 0, PDC_1_3, 2, 2 }, + { "90ms-RKSJ-V", cc_japanese, 0, PDC_1_3, 2, 2 }, + { "90msp-RKSJ-H", cc_japanese, 0, PDC_1_3, 2, 2 }, + { "90msp-RKSJ-V", cc_japanese, 0, PDC_1_3, 2, 2 }, + { "90pv-RKSJ-H", cc_japanese, 0, PDC_1_3, 1, 1 }, + { "Add-RKSJ-H", cc_japanese, 0, PDC_1_3, 1, 1 }, + { "Add-RKSJ-V", cc_japanese, 0, PDC_1_3, 1, 1 }, + { "EUC-H", cc_japanese, 0, PDC_1_3, 1, 1 }, + { "EUC-V", cc_japanese, 0, PDC_1_3, 1, 1 }, + { "Ext-RKSJ-H", cc_japanese, 0, PDC_1_3, 2, 2 }, + { "Ext-RKSJ-V", cc_japanese, 0, PDC_1_3, 2, 2 }, + { "H", cc_japanese, 0, PDC_1_3, 1, 1 }, + { "V", cc_japanese, 0, PDC_1_3, 1, 1 }, + { "UniJIS-UCS2-H", cc_japanese, 2, PDC_1_3, 2, 4 }, + { "UniJIS-UCS2-V", cc_japanese, 2, PDC_1_3, 2, 4 }, + { "UniJIS-UCS2-HW-H", cc_japanese, -2, PDC_1_3, 2, 4 }, + { "UniJIS-UCS2-HW-V", cc_japanese, -2, PDC_1_3, 2, 4 }, + + { "KSC-EUC-H", cc_korean, 0, PDC_1_3, 0, 0 }, + { "KSC-EUC-V", cc_korean, 0, PDC_1_3, 0, 0 }, + { "KSCms-UHC-H", cc_korean, 0, PDC_1_3, 1, 1 }, + { "KSCms-UHC-V", cc_korean, 0, PDC_1_3, 1, 1 }, + { "KSCms-UHC-HW-H", cc_korean, 0, PDC_1_3, 1, 1 }, + { "KSCms-UHC-HW-V", cc_korean, 0, PDC_1_3, 1, 1 }, + { "KSCpc-EUC-H", cc_korean, 0, PDC_1_3, 0, 0 }, + { "UniKS-UCS2-H", cc_korean, 2, PDC_1_3, 1, 1 }, + { "UniKS-UCS2-V", cc_korean, 2, PDC_1_3, 1, 1 }, + + { "Identity-H", cc_identity, 0, PDC_1_3, 0, 0 }, + { "Identity-V", cc_identity, 0, PDC_1_3, 0, 0 } +}; + + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + +/* PDF width arrays for glyph widths indexed by CID */ +/* Must be parallel to the pdf_cid_metrics array */ + +static char *pdf_cid_width_arrays[] = +{ + /* HeiseiKakuGo-W5 */ + "/W[1[278 278 355 556 556 889 667 191 333 333 389 584 278 333 278\n" + "278 556 556 556 556 556 556 556 556 556 556 278 278 584 584 584\n" + "556 1015 667 667 722 722 667 611 778 722 278 500 667 556 833 722\n" + "778 667 778 722 667 611 722 667 944 667 667 611 278 556 278 469\n" + "556 333 556 556 500 556 556 278 556 556 222 222 500 222 833 556\n" + "556 556 556 333 500 278 556 500 722 500 500 500 334 260 334 333\n" + "1000 278 1000 260 1000 333 556 556 167 1000 1000 556 1000 556 333 333\n" + "500 500 556 1000 1000 278 1000 350 222 333 1000 556 1000 1000 611]\n" + "127 137 333\n" + "140[370 556 778 1000\n" + "365 889 278 222 611 944 611 584 737 584 737 1000 1000 333 333 556\n" + "333 834 834 834 667 667 667 667 667 667 722 667 667 667 667 278\n" + "278 278 278 722 722 778 778 778 778 778 1000 722 722 722 722 667\n" + "667 556 556 556 556 556 556 500 556 556 556 556 278 278 278 278\n" + "556 556 556 556 556 556 556 1000 556 556 556 556 500 556 500 667\n" + "667 611 556 500 1000 500 556]\n" + "231 632 500\n" + "8718 8719 500]\n", + + /* HeiseiMin-W3 */ + "/W[1[250 333 408 500 500 833 778 180 333 333 500 564 250 333 250\n" + "278 500 500 500 500 500 500 500 500 500 500 278 278 564 564 564\n" + "444 921 722 667 667 722 611 556 722 722 333 389 722 611 889 722\n" + "722 556 722 667 556 611 722 722 944 722 722 611 333 500 333 469\n" + "500 333 444 500 444 500 444 333 500 500 278 278 500 278 778 500\n" + "500 500 500 333 389 278 500 500 722 500 500 444 480 200 480 333\n" + "1000 278 1000 200 1000 333 500 500 167 1000 1000 500 1000 500 333 333\n" + "556 556 500 1000 1000 250 1000 350 333 444 1000 500 1000 1000 444]\n" + "127 137 333\n" + "139[889 276 611 722 889\n" + "310 667 278 278 500 722 500 564 760 564 760 1000 1000 300 300 500\n" + "300 750 750 750 722 722 722 722 722 722 667 611 611 611 611 333\n" + "333 333 333 722 722 722 722 722 722 722 1000 722 722 722 722 722\n" + "556 444 444 444 444 444 444 444 444 444 444 444 278 278 278 278\n" + "500 500 500 500 500 500 500 1000 500 500 500 500 500 500 500 556\n" + "722 611 500 389 980 444]\n" + "230 632 500\n" + "8718 8719 500]\n", + + /* HYGoThic-Medium */ + "/W[1[333 416 416 833 666 916 750 250 416 416 583 833 375 833 375\n" + "375 583 583 583 583 583 583 583 583 583 583 416 416 833 833 833\n" + "583 1000 666 708 750 750 666 625 833 750 291 541 708 583 875 750\n" + "791 666 791 708 666 583 750 625 916 625 625 625 416 375 416 500\n" + "500 500 583 625 583 625 583 375 625 583 250 250 541 250 916 625\n" + "625 625 625 333 541 333 583 500 750 500 500 500 500 500 500 750]]\n", + + /* "HYSMyeongJo-Medium" */ + "/W[1[278 278 355 556 556 889 667 222 333 333 389 584 278 333 278\n" + "278 556 556 556 556 556 556 556 556 556 556 278 278 584 584 584\n" + "556 1015 667 667 722 722 667 611 778 722 278 500 667 556 833 722\n" + "778 667 778 722 667 611 722 667 944 667 667 611 278 278 278 469\n" + "556 222 556 556 500 556 556 278 556 556 222 222 500 222 833 556\n" + "556 556 556 333 500 278 556 500 722 500 500 500 334 260 334 584]]\n", + + /* "MHei-Medium" (identical with HYSMyeongJo-Medium) */ + "/W[1[278 278 355 556 556 889 667 222 333 333 389 584 278 333 278\n" + "278 556 556 556 556 556 556 556 556 556 556 278 278 584 584 584\n" + "556 1015 667 667 722 722 667 611 778 722 278 500 667 556 833 722\n" + "778 667 778 722 667 611 722 667 944 667 667 611 278 278 278 469\n" + "556 222 556 556 500 556 556 278 556 556 222 222 500 222 833 556\n" + "556 556 556 333 500 278 556 500 722 500 500 500 334 260 334 584]]\n", + + /* "MSung-Light" */ + "/W[1[250 250 408 668 490 875 698 250 240 240 417 667 250 313 250\n" + "520 500 500 500 500 500 500 500 500 500 500 250 250 667 667 667\n" + "396 921 677 615 719 760 625 552 771 802 354 354 781 604 927 750\n" + "823 563 823 729 542 698 771 729 948 771 677 635 344 520 344 469\n" + "500 250 469 521 427 521 438 271 469 531 250 250 458 240 802 531\n" + "500 521 521 365 333 292 521 458 677 479 458 427 480 496 480 667]]\n", + + /* "STSong-Light" */ + "/W[1[207 270 342 467 462 797 710 239 374 374 423 605 238 375 238\n" + "334 462 462 462 462 462 462 462 462 462 462 238 238 605 605 605\n" + "344 748 684 560 695 739 563 511 729 793 318 312 666 526 896 758\n" + "772 544 772 628 465 607 753 711 972 647 620 607 374 333 374 606\n" + "500 239 417 503 427 529 415 264 444 518 241 230 495 228 793 527\n" + "524 524 504 338 336 277 517 450 652 466 452 407 370 258 370 605]]\n", + + /* HYSMyeongJoStd-Medium-Acro */ + "/W[1[333 416 416 833 625 916 833 250 500 500 500 833 291 833 291\n" + "375 625 625 625 625 625 625 625 625 625 625 333 333 833 833 916\n" + "500 1000 791 708 708 750 708 666 750 791 375 500 791 666 916 791\n" + "750 666 750 708 666 791 791 750 1000 708 708 666 500 375 500 500\n" + "500 333 541 583 541 583 583 375 583 583 291 333 583 291 875 583\n" + "583 583 583 458 541 375 583 583 833 625 625 500 583 583 583 750]]\n", + + /* KozMinPro-Regular-Acro */ + "/W[1[278 299 353 614 614 721 735 216 323 323 449 529 219 306 219\n" + "453 614 614 614 614 614 614 614 614 614 614 219 219 529 529 529\n" + "486 744 646 604 617 681 567 537 647 738 320 433 637 566 904 710\n" + "716 605 716 623 517 601 690 668 990 681 634 578 316 614 316 529\n" + "500 387 509 566 478 565 503 337 549 580 275 266 544 276 854 579\n" + "550 578 566 410 444 340 575 512 760 503 529 453 326 380 326 387\n" + "1000 453 1000 380 1000 299 614 614 265 1000 1000 614 1000 451 291 291\n" + "588 589 500 1000 1000 219 1000 452 216 353 1000 451 1000 1000 486 387]\n" + "128 135 387\n" + "136[387 387 1000 880 448 566 716 903\n" + "460 805 275 276 550 886 582 529 738 529 738 1000 1000 406 406 575\n" + "406 934 934 934 646 646 646 646 646 646 617 567 567 567 567 320\n" + "320 320 320 681 710 716 716 716 716 716 1000 690 690 690 690 634\n" + "605 509 509 509 509 509 509 478 503 503 503 503 275 275 275 275\n" + "550 579 550 550 550 550 550 1000 575 575 575 575 529 578 529 517\n" + "634 578 445 444 842 453 1000 500]\n" + "323[500 1000 500 1000 500]\n" + "328 383 500\n" + "384[500 500 500 500 500 500]\n" + "9354[614 684 1000 1000 648 899\n" + "903 509 275 575 503 550 646 320 690 567 716 934 934 934 934 934\n" + "934 426 426 426 426 426 426 426 426 425 425 425 439 426 426 426\n" + "426 426 646 567 1000 567 320 1000 320 716 1000 690 690 690 509 503\n" + "1000 503 275 1000 275 550 1000 575 575 575 513 1000 1000 805 1000 478\n" + "1000 1000 503 1000 1000 735 1000 1000 426 1000 1000 1000 578 553 512\n" + "1000 1000 640 594 284]]\n", + + /* MSungStd-Light-Acro */ + "/W[1[250 250 408 668 490 875 698 250 240 240 417 667 250 313 250\n" + "520 500 500 500 500 500 500 500 500 500 500 250 250 667 667 667\n" + "396 921 677 615 719 760 625 552 771 802 354 354 781 604 927 750\n" + "823 563 823 729 542 698 771 729 948 771 677 635 344 520 344 469\n" + "500 250 469 521 427 521 438 271 469 531 250 250 458 240 802 531\n" + "500 521 521 365 333 292 521 458 677 479 458 427 480 496 480 667]\n" + "17601 17601 500]\n", + + /* STSongStd-Light-Acro */ + "/W[1[207 270 342 467 462 797 710 239 374 374 423 605 238 375 238\n" + "334 462 462 462 462 462 462 462 462 462 462 238 238 605 605 605\n" + "344 748 684 560 695 739 563 511 729 793 318 312 666 526 896 758\n" + "772 544 772 628 465 607 753 711 972 647 620 607 374 333 374 606\n" + "500 239 417 503 427 529 415 264 444 518 241 230 495 228 793 527\n" + "524 524 504 338 336 277 517 450 652 466 452 407 370 258 370 605]\n" + "22353[462 462 1000 1000 500]]\n", + + NULL +}; + + +/* Unicode intervals for glyph widths of preinstalled CID fonts */ + +static pdc_interwidth pdf_HeiseiKakuGo_W5_widths[163] = +{ + {0x0000, 278}, {0x0022, 355}, {0x0023, 556}, {0x0025, 889}, + {0x0026, 667}, {0x0027, 191}, {0x0028, 333}, {0x002A, 389}, + {0x002B, 584}, {0x002C, 278}, {0x002D, 333}, {0x002E, 278}, + {0x0030, 556}, {0x003A, 278}, {0x003C, 584}, {0x003F, 556}, + {0x0040,1015}, {0x0041, 667}, {0x0043, 722}, {0x0045, 667}, + {0x0046, 611}, {0x0047, 778}, {0x0048, 722}, {0x0049, 278}, + {0x004A, 500}, {0x004B, 667}, {0x004C, 556}, {0x004D, 833}, + {0x004E, 722}, {0x004F, 778}, {0x0050, 667}, {0x0051, 778}, + {0x0052, 722}, {0x0053, 667}, {0x0054, 611}, {0x0055, 722}, + {0x0056, 667}, {0x0057, 944}, {0x0058, 667}, {0x005A, 611}, + {0x005B, 278}, {0x005E, 469}, {0x005F, 556}, {0x0060, 333}, + {0x0061, 556}, {0x0063, 500}, {0x0064, 556}, {0x0066, 278}, + {0x0067, 556}, {0x0069, 222}, {0x006B, 500}, {0x006C, 222}, + {0x006D, 833}, {0x006E, 556}, {0x0072, 333}, {0x0073, 500}, + {0x0074, 278}, {0x0075, 556}, {0x0076, 500}, {0x0077, 722}, + {0x0078, 500}, {0x007B, 334}, {0x007C, 260}, {0x007D, 334}, + {0x007E, 333}, {0x007F,1000}, {0x00A1, 333}, {0x00A2, 556}, + {0x00A6, 260}, {0x00A7,1000}, {0x00A9, 737}, {0x00AA, 370}, + {0x00AB, 556}, {0x00AC, 584}, {0x00AE, 737}, {0x00AF, 333}, + {0x00B0,1000}, {0x00B2, 333}, {0x00B4,1000}, {0x00B5, 556}, + {0x00B6,1000}, {0x00B7, 278}, {0x00B8, 333}, {0x00BA, 365}, + {0x00BB, 556}, {0x00BC, 834}, {0x00BF, 611}, {0x00C0, 667}, + {0x00C6,1000}, {0x00C7, 722}, {0x00C8, 667}, {0x00CC, 278}, + {0x00D0, 722}, {0x00D2, 778}, {0x00D7,1000}, {0x00D8, 778}, + {0x00D9, 722}, {0x00DD, 667}, {0x00DF, 611}, {0x00E0, 556}, + {0x00E6, 889}, {0x00E7, 500}, {0x00E8, 556}, {0x00EC, 278}, + {0x00F0, 556}, {0x00F7,1000}, {0x00F8, 611}, {0x00F9, 556}, + {0x00FD, 500}, {0x00FE, 556}, {0x00FF, 500}, {0x0100,1000}, + {0x0131, 278}, {0x0132,1000}, {0x0141, 556}, {0x0142, 222}, + {0x0143,1000}, {0x0153, 944}, {0x0154,1000}, {0x0160, 667}, + {0x0161, 500}, {0x0162,1000}, {0x0178, 667}, {0x0179,1000}, + {0x017D, 611}, {0x017E, 500}, {0x017F,1000}, {0x01C0, 260}, + {0x01C1,1000}, {0x0300, 333}, {0x0305, 556}, {0x0306, 333}, + {0x0309,1000}, {0x030A, 333}, {0x030D,1000}, {0x0327, 333}, + {0x0329,1000}, {0x0332, 556}, {0x0333,1000}, {0x2002, 500}, + {0x2003,1000}, {0x2011, 333}, {0x2012, 556}, {0x2014,1000}, + {0x201A, 222}, {0x201B,1000}, {0x201E, 333}, {0x201F,1000}, + {0x2022, 350}, {0x2023,1000}, {0x2039, 333}, {0x203B,1000}, + {0x203E, 500}, {0x203F,1000}, {0x2044, 167}, {0x2045,1000}, + {0xFB01, 500}, {0xFB03,1000}, {0xFF61, 500}, {0xFFA0,1000}, + {0xFFE8, 500}, {0xFFE9,1000}, {0xFFFF,1000} +}; + +static pdc_interwidth pdf_HeiseiMin_W3_widths[164] = +{ + {0x0000, 250}, {0x0021, 333}, {0x0022, 408}, {0x0023, 500}, + {0x0025, 833}, {0x0026, 778}, {0x0027, 180}, {0x0028, 333}, + {0x002A, 500}, {0x002B, 564}, {0x002C, 250}, {0x002D, 333}, + {0x002E, 250}, {0x002F, 278}, {0x0030, 500}, {0x003A, 278}, + {0x003C, 564}, {0x003F, 444}, {0x0040, 921}, {0x0041, 722}, + {0x0042, 667}, {0x0044, 722}, {0x0045, 611}, {0x0046, 556}, + {0x0047, 722}, {0x0049, 333}, {0x004A, 389}, {0x004B, 722}, + {0x004C, 611}, {0x004D, 889}, {0x004E, 722}, {0x0050, 556}, + {0x0051, 722}, {0x0052, 667}, {0x0053, 556}, {0x0054, 611}, + {0x0055, 722}, {0x0057, 944}, {0x0058, 722}, {0x005A, 611}, + {0x005B, 333}, {0x005C, 278}, {0x005D, 333}, {0x005E, 469}, + {0x005F, 500}, {0x0060, 333}, {0x0061, 444}, {0x0062, 500}, + {0x0063, 444}, {0x0064, 500}, {0x0065, 444}, {0x0066, 333}, + {0x0067, 500}, {0x0069, 278}, {0x006B, 500}, {0x006C, 278}, + {0x006D, 778}, {0x006E, 500}, {0x0072, 333}, {0x0073, 389}, + {0x0074, 278}, {0x0075, 500}, {0x0077, 722}, {0x0078, 500}, + {0x007A, 444}, {0x007B, 480}, {0x007C, 200}, {0x007D, 480}, + {0x007E, 333}, {0x007F,1000}, {0x00A1, 333}, {0x00A2, 500}, + {0x00A6, 200}, {0x00A7,1000}, {0x00A9, 760}, {0x00AA, 276}, + {0x00AB, 500}, {0x00AC, 564}, {0x00AE, 760}, {0x00AF, 333}, + {0x00B0,1000}, {0x00B2, 300}, {0x00B4,1000}, {0x00B5, 500}, + {0x00B6,1000}, {0x00B7, 250}, {0x00B8, 333}, {0x00B9, 300}, + {0x00BA, 310}, {0x00BB, 500}, {0x00BC, 750}, {0x00BF, 444}, + {0x00C0, 722}, {0x00C6, 889}, {0x00C7, 667}, {0x00C8, 611}, + {0x00CC, 333}, {0x00D0, 722}, {0x00D7,1000}, {0x00D8, 722}, + {0x00DE, 556}, {0x00DF, 500}, {0x00E0, 444}, {0x00E6, 667}, + {0x00E7, 444}, {0x00EC, 278}, {0x00F0, 500}, {0x00F7,1000}, + {0x00F8, 500}, {0x0100,1000}, {0x0131, 278}, {0x0132,1000}, + {0x0141, 611}, {0x0142, 278}, {0x0143,1000}, {0x0152, 889}, + {0x0153, 722}, {0x0154,1000}, {0x0160, 556}, {0x0161, 389}, + {0x0162,1000}, {0x0178, 722}, {0x0179,1000}, {0x017D, 611}, + {0x017E, 444}, {0x017F,1000}, {0x01C0, 200}, {0x01C1,1000}, + {0x0300, 333}, {0x0305, 500}, {0x0306, 333}, {0x0309,1000}, + {0x030A, 333}, {0x030D,1000}, {0x0327, 333}, {0x0329,1000}, + {0x0332, 500}, {0x0333,1000}, {0x2002, 500}, {0x2003,1000}, + {0x2011, 333}, {0x2012, 500}, {0x2014,1000}, {0x201A, 333}, + {0x201B,1000}, {0x201E, 444}, {0x201F,1000}, {0x2022, 350}, + {0x2023,1000}, {0x2039, 333}, {0x203B,1000}, {0x203E, 500}, + {0x203F,1000}, {0x2044, 167}, {0x2045,1000}, {0x2122, 980}, + {0x2123,1000}, {0xFB01, 556}, {0xFB03,1000}, {0xFF61, 500}, + {0xFFA0,1000}, {0xFFE8, 500}, {0xFFE9,1000}, {0xFFFF,1000} +}; + +static pdc_interwidth pdf_HYGoThic_Medium_widths[68] = +{ + {0x0000, 333}, {0x0021, 416}, {0x0023, 833}, {0x0024, 666}, + {0x0025, 916}, {0x0026, 750}, {0x0027, 250}, {0x0028, 416}, + {0x002A, 583}, {0x002B, 833}, {0x002C, 375}, {0x002D, 833}, + {0x002E, 375}, {0x0030, 583}, {0x003A, 416}, {0x003C, 833}, + {0x003F, 583}, {0x0040,1000}, {0x0041, 666}, {0x0042, 708}, + {0x0043, 750}, {0x0045, 666}, {0x0046, 625}, {0x0047, 833}, + {0x0048, 750}, {0x0049, 291}, {0x004A, 541}, {0x004B, 708}, + {0x004C, 583}, {0x004D, 875}, {0x004E, 750}, {0x004F, 791}, + {0x0050, 666}, {0x0051, 791}, {0x0052, 708}, {0x0053, 666}, + {0x0054, 583}, {0x0055, 750}, {0x0056, 625}, {0x0057, 916}, + {0x0058, 625}, {0x005B, 416}, {0x005C, 375}, {0x005D, 416}, + {0x005E, 500}, {0x0061, 583}, {0x0062, 625}, {0x0063, 583}, + {0x0064, 625}, {0x0065, 583}, {0x0066, 375}, {0x0067, 625}, + {0x0068, 583}, {0x0069, 250}, {0x006B, 541}, {0x006C, 250}, + {0x006D, 916}, {0x006E, 625}, {0x0072, 333}, {0x0073, 541}, + {0x0074, 333}, {0x0075, 583}, {0x0076, 500}, {0x0077, 750}, + {0x0078, 500}, {0x007E, 750}, {0x007F,1000}, {0xFFFF,1000} +}; + +static pdc_interwidth pdf_HYSMyeongJo_Medium_widths[67] = +{ + {0x0000, 278}, {0x0022, 355}, {0x0023, 556}, {0x0025, 889}, + {0x0026, 667}, {0x0027, 222}, {0x0028, 333}, {0x002A, 389}, + {0x002B, 584}, {0x002C, 278}, {0x002D, 333}, {0x002E, 278}, + {0x0030, 556}, {0x003A, 278}, {0x003C, 584}, {0x003F, 556}, + {0x0040,1015}, {0x0041, 667}, {0x0043, 722}, {0x0045, 667}, + {0x0046, 611}, {0x0047, 778}, {0x0048, 722}, {0x0049, 278}, + {0x004A, 500}, {0x004B, 667}, {0x004C, 556}, {0x004D, 833}, + {0x004E, 722}, {0x004F, 778}, {0x0050, 667}, {0x0051, 778}, + {0x0052, 722}, {0x0053, 667}, {0x0054, 611}, {0x0055, 722}, + {0x0056, 667}, {0x0057, 944}, {0x0058, 667}, {0x005A, 611}, + {0x005B, 278}, {0x005E, 469}, {0x005F, 556}, {0x0060, 222}, + {0x0061, 556}, {0x0063, 500}, {0x0064, 556}, {0x0066, 278}, + {0x0067, 556}, {0x0069, 222}, {0x006B, 500}, {0x006C, 222}, + {0x006D, 833}, {0x006E, 556}, {0x0072, 333}, {0x0073, 500}, + {0x0074, 278}, {0x0075, 556}, {0x0076, 500}, {0x0077, 722}, + {0x0078, 500}, {0x007B, 334}, {0x007C, 260}, {0x007D, 334}, + {0x007E, 584}, {0x007F,1000}, {0xFFFF,1000} +}; + +static pdc_interwidth pdf_MSung_Light_widths[80] = +{ + {0x0000, 250}, {0x0022, 408}, {0x0023, 668}, {0x0024, 490}, + {0x0025, 875}, {0x0026, 698}, {0x0027, 250}, {0x0028, 240}, + {0x002A, 417}, {0x002B, 667}, {0x002C, 250}, {0x002D, 313}, + {0x002E, 250}, {0x002F, 520}, {0x0030, 500}, {0x003A, 250}, + {0x003C, 667}, {0x003F, 396}, {0x0040, 921}, {0x0041, 677}, + {0x0042, 615}, {0x0043, 719}, {0x0044, 760}, {0x0045, 625}, + {0x0046, 552}, {0x0047, 771}, {0x0048, 802}, {0x0049, 354}, + {0x004B, 781}, {0x004C, 604}, {0x004D, 927}, {0x004E, 750}, + {0x004F, 823}, {0x0050, 563}, {0x0051, 823}, {0x0052, 729}, + {0x0053, 542}, {0x0054, 698}, {0x0055, 771}, {0x0056, 729}, + {0x0057, 948}, {0x0058, 771}, {0x0059, 677}, {0x005A, 635}, + {0x005B, 344}, {0x005C, 520}, {0x005D, 344}, {0x005E, 469}, + {0x005F, 500}, {0x0060, 250}, {0x0061, 469}, {0x0062, 521}, + {0x0063, 427}, {0x0064, 521}, {0x0065, 438}, {0x0066, 271}, + {0x0067, 469}, {0x0068, 531}, {0x0069, 250}, {0x006B, 458}, + {0x006C, 240}, {0x006D, 802}, {0x006E, 531}, {0x006F, 500}, + {0x0070, 521}, {0x0072, 365}, {0x0073, 333}, {0x0074, 292}, + {0x0075, 521}, {0x0076, 458}, {0x0077, 677}, {0x0078, 479}, + {0x0079, 458}, {0x007A, 427}, {0x007B, 480}, {0x007C, 496}, + {0x007D, 480}, {0x007E, 667}, {0x007F,1000}, {0xFFFF,1000} +}; + +static pdc_interwidth pdf_STSong_Light_widths[83] = +{ + {0x0000, 207}, {0x0021, 270}, {0x0022, 342}, {0x0023, 467}, + {0x0024, 462}, {0x0025, 797}, {0x0026, 710}, {0x0027, 239}, + {0x0028, 374}, {0x002A, 423}, {0x002B, 605}, {0x002C, 238}, + {0x002D, 375}, {0x002E, 238}, {0x002F, 334}, {0x0030, 462}, + {0x003A, 238}, {0x003C, 605}, {0x003F, 344}, {0x0040, 748}, + {0x0041, 684}, {0x0042, 560}, {0x0043, 695}, {0x0044, 739}, + {0x0045, 563}, {0x0046, 511}, {0x0047, 729}, {0x0048, 793}, + {0x0049, 318}, {0x004A, 312}, {0x004B, 666}, {0x004C, 526}, + {0x004D, 896}, {0x004E, 758}, {0x004F, 772}, {0x0050, 544}, + {0x0051, 772}, {0x0052, 628}, {0x0053, 465}, {0x0054, 607}, + {0x0055, 753}, {0x0056, 711}, {0x0057, 972}, {0x0058, 647}, + {0x0059, 620}, {0x005A, 607}, {0x005B, 374}, {0x005C, 333}, + {0x005D, 374}, {0x005E, 606}, {0x005F, 500}, {0x0060, 239}, + {0x0061, 417}, {0x0062, 503}, {0x0063, 427}, {0x0064, 529}, + {0x0065, 415}, {0x0066, 264}, {0x0067, 444}, {0x0068, 518}, + {0x0069, 241}, {0x006A, 230}, {0x006B, 495}, {0x006C, 228}, + {0x006D, 793}, {0x006E, 527}, {0x006F, 524}, {0x0071, 504}, + {0x0072, 338}, {0x0073, 336}, {0x0074, 277}, {0x0075, 517}, + {0x0076, 450}, {0x0077, 652}, {0x0078, 466}, {0x0079, 452}, + {0x007A, 407}, {0x007B, 370}, {0x007C, 258}, {0x007D, 370}, + {0x007E, 605}, {0x007F,1000}, {0xFFFF,1000} +}; + +static pdc_interwidth pdf_HYSMyeongJoStd_Medium_widths[69] = +{ + {0x0000, 333}, {0x0021, 416}, {0x0023, 833}, {0x0024, 625}, + {0x0025, 916}, {0x0026, 833}, {0x0027, 250}, {0x0028, 500}, + {0x002B, 833}, {0x002C, 291}, {0x002D, 833}, {0x002E, 291}, + {0x002F, 375}, {0x0030, 625}, {0x003A, 333}, {0x003C, 833}, + {0x003E, 916}, {0x003F, 500}, {0x0040,1000}, {0x0041, 791}, + {0x0042, 708}, {0x0044, 750}, {0x0045, 708}, {0x0046, 666}, + {0x0047, 750}, {0x0048, 791}, {0x0049, 375}, {0x004A, 500}, + {0x004B, 791}, {0x004C, 666}, {0x004D, 916}, {0x004E, 791}, + {0x004F, 750}, {0x0050, 666}, {0x0051, 750}, {0x0052, 708}, + {0x0053, 666}, {0x0054, 791}, {0x0056, 750}, {0x0057,1000}, + {0x0058, 708}, {0x005A, 666}, {0x005B, 500}, {0x005C, 375}, + {0x005D, 500}, {0x0060, 333}, {0x0061, 541}, {0x0062, 583}, + {0x0063, 541}, {0x0064, 583}, {0x0066, 375}, {0x0067, 583}, + {0x0069, 291}, {0x006A, 333}, {0x006B, 583}, {0x006C, 291}, + {0x006D, 875}, {0x006E, 583}, {0x0072, 458}, {0x0073, 541}, + {0x0074, 375}, {0x0075, 583}, {0x0077, 833}, {0x0078, 625}, + {0x007A, 500}, {0x007B, 583}, {0x007E, 750}, {0x007F,1000}, + {0xFFFF,1000} +}; + +static pdc_interwidth pdf_KozMinPro_Regular_widths[265] = +{ + {0x0000, 278}, {0x0021, 299}, {0x0022, 353}, {0x0023, 614}, + {0x0025, 721}, {0x0026, 735}, {0x0027, 216}, {0x0028, 323}, + {0x002A, 449}, {0x002B, 529}, {0x002C, 219}, {0x002D, 306}, + {0x002E, 219}, {0x002F, 453}, {0x0030, 614}, {0x003A, 219}, + {0x003C, 529}, {0x003F, 486}, {0x0040, 744}, {0x0041, 646}, + {0x0042, 604}, {0x0043, 617}, {0x0044, 681}, {0x0045, 567}, + {0x0046, 537}, {0x0047, 647}, {0x0048, 738}, {0x0049, 320}, + {0x004A, 433}, {0x004B, 637}, {0x004C, 566}, {0x004D, 904}, + {0x004E, 710}, {0x004F, 716}, {0x0050, 605}, {0x0051, 716}, + {0x0052, 623}, {0x0053, 517}, {0x0054, 601}, {0x0055, 690}, + {0x0056, 668}, {0x0057, 990}, {0x0058, 681}, {0x0059, 634}, + {0x005A, 578}, {0x005B, 316}, {0x005C, 453}, {0x005D, 316}, + {0x005E, 529}, {0x005F, 500}, {0x0060, 387}, {0x0061, 509}, + {0x0062, 566}, {0x0063, 478}, {0x0064, 565}, {0x0065, 503}, + {0x0066, 337}, {0x0067, 549}, {0x0068, 580}, {0x0069, 275}, + {0x006A, 266}, {0x006B, 544}, {0x006C, 276}, {0x006D, 854}, + {0x006E, 579}, {0x006F, 550}, {0x0070, 578}, {0x0071, 566}, + {0x0072, 410}, {0x0073, 444}, {0x0074, 340}, {0x0075, 575}, + {0x0076, 512}, {0x0077, 760}, {0x0078, 503}, {0x0079, 529}, + {0x007A, 453}, {0x007B, 326}, {0x007C, 380}, {0x007D, 326}, + {0x007E, 387}, {0x007F,1000}, {0x00A1, 299}, {0x00A2, 614}, + {0x00A6, 380}, {0x00A7,1000}, {0x00A9, 738}, {0x00AA, 448}, + {0x00AB, 451}, {0x00AC, 529}, {0x00AE, 738}, {0x00AF, 387}, + {0x00B0,1000}, {0x00B2, 406}, {0x00B4,1000}, {0x00B5, 575}, + {0x00B6,1000}, {0x00B7, 219}, {0x00B8, 387}, {0x00B9, 406}, + {0x00BA, 460}, {0x00BB, 451}, {0x00BC, 934}, {0x00BF, 486}, + {0x00C0, 646}, {0x00C6, 880}, {0x00C7, 617}, {0x00C8, 567}, + {0x00CC, 320}, {0x00D0, 681}, {0x00D1, 710}, {0x00D2, 716}, + {0x00D7,1000}, {0x00D8, 716}, {0x00D9, 690}, {0x00DD, 634}, + {0x00DE, 605}, {0x00DF, 582}, {0x00E0, 509}, {0x00E6, 805}, + {0x00E7, 478}, {0x00E8, 503}, {0x00EC, 275}, {0x00F0, 550}, + {0x00F1, 579}, {0x00F2, 550}, {0x00F7,1000}, {0x00F8, 550}, + {0x00F9, 575}, {0x00FD, 529}, {0x00FE, 578}, {0x00FF, 529}, + {0x0100, 646}, {0x0101, 509}, {0x0102,1000}, {0x0112, 567}, + {0x0113, 503}, {0x0114,1000}, {0x011A, 567}, {0x011B, 503}, + {0x011C,1000}, {0x0128, 320}, {0x0129, 275}, {0x012A, 320}, + {0x012B, 275}, {0x012C,1000}, {0x0131, 275}, {0x0132,1000}, + {0x0141, 566}, {0x0142, 276}, {0x0143,1000}, {0x014B, 578}, + {0x014C, 716}, {0x014D, 550}, {0x014E,1000}, {0x0152, 903}, + {0x0153, 886}, {0x0154,1000}, {0x0160, 517}, {0x0161, 444}, + {0x0162,1000}, {0x0168, 690}, {0x0169, 575}, {0x016A, 690}, + {0x016B, 575}, {0x016C,1000}, {0x016E, 690}, {0x016F, 575}, + {0x0170,1000}, {0x0178, 634}, {0x0179,1000}, {0x017D, 578}, + {0x017E, 453}, {0x017F,1000}, {0x01C0, 380}, {0x01C1,1000}, + {0x01CD, 646}, {0x01CE, 509}, {0x01CF, 320}, {0x01D0, 275}, + {0x01D1, 716}, {0x01D2, 550}, {0x01D3, 690}, {0x01D4, 575}, + {0x01D5,1000}, {0x01FD, 805}, {0x01FE,1000}, {0x0251, 513}, + {0x0252,1000}, {0x0254, 478}, {0x0255,1000}, {0x0259, 503}, + {0x025A, 735}, {0x025B, 426}, {0x025C,1000}, {0x0275, 553}, + {0x0276,1000}, {0x0283, 594}, {0x0284,1000}, {0x028C, 512}, + {0x028D,1000}, {0x0292, 640}, {0x0293,1000}, {0x02D0, 284}, + {0x02D1,1000}, {0x0300, 387}, {0x0305, 445}, {0x0306, 387}, + {0x0309,1000}, {0x030A, 387}, {0x030D,1000}, {0x0327, 387}, + {0x0329,1000}, {0x0332, 500}, {0x0333,1000}, {0x0EBC, 567}, + {0x0EBD, 503}, {0x0EBE,1000}, {0x2002, 500}, {0x2003,1000}, + {0x2011, 306}, {0x2012, 500}, {0x2014,1000}, {0x201A, 216}, + {0x201B,1000}, {0x201E, 353}, {0x201F,1000}, {0x2022, 452}, + {0x2023,1000}, {0x2039, 291}, {0x203B,1000}, {0x203E, 500}, + {0x203F,1000}, {0x2044, 265}, {0x2045,1000}, {0x2070, 426}, + {0x2071,1000}, {0x2074, 426}, {0x207A,1000}, {0x2080, 426}, + {0x2081, 425}, {0x2084, 439}, {0x2085, 426}, {0x208A,1000}, + {0x20AC, 614}, {0x20AD,1000}, {0x2122, 842}, {0x2123,1000}, + {0x2126, 684}, {0x2127,1000}, {0x2153, 934}, {0x2155,1000}, + {0x215B, 934}, {0x215F,1000}, {0xFB00, 648}, {0xFB01, 588}, + {0xFB02, 589}, {0xFB03, 899}, {0xFB04, 903}, {0xFB05,1000}, + {0xFF61, 500}, {0xFFA0,1000}, {0xFFE8, 500}, {0xFFE9,1000}, + {0xFFFF,1000} +}; + +static pdc_interwidth pdf_MSungStd_Light_widths[82] = +{ + {0x0000, 250}, {0x0022, 408}, {0x0023, 668}, {0x0024, 490}, + {0x0025, 875}, {0x0026, 698}, {0x0027, 250}, {0x0028, 240}, + {0x002A, 417}, {0x002B, 667}, {0x002C, 250}, {0x002D, 313}, + {0x002E, 250}, {0x002F, 520}, {0x0030, 500}, {0x003A, 250}, + {0x003C, 667}, {0x003F, 396}, {0x0040, 921}, {0x0041, 677}, + {0x0042, 615}, {0x0043, 719}, {0x0044, 760}, {0x0045, 625}, + {0x0046, 552}, {0x0047, 771}, {0x0048, 802}, {0x0049, 354}, + {0x004B, 781}, {0x004C, 604}, {0x004D, 927}, {0x004E, 750}, + {0x004F, 823}, {0x0050, 563}, {0x0051, 823}, {0x0052, 729}, + {0x0053, 542}, {0x0054, 698}, {0x0055, 771}, {0x0056, 729}, + {0x0057, 948}, {0x0058, 771}, {0x0059, 677}, {0x005A, 635}, + {0x005B, 344}, {0x005C, 520}, {0x005D, 344}, {0x005E, 469}, + {0x005F, 500}, {0x0060, 250}, {0x0061, 469}, {0x0062, 521}, + {0x0063, 427}, {0x0064, 521}, {0x0065, 438}, {0x0066, 271}, + {0x0067, 469}, {0x0068, 531}, {0x0069, 250}, {0x006B, 458}, + {0x006C, 240}, {0x006D, 802}, {0x006E, 531}, {0x006F, 500}, + {0x0070, 521}, {0x0072, 365}, {0x0073, 333}, {0x0074, 292}, + {0x0075, 521}, {0x0076, 458}, {0x0077, 677}, {0x0078, 479}, + {0x0079, 458}, {0x007A, 427}, {0x007B, 480}, {0x007C, 496}, + {0x007D, 480}, {0x007E, 667}, {0x007F,1000}, {0x20AC, 500}, + {0x20AD,1000}, {0xFFFF,1000} +}; + +static pdc_interwidth pdf_STSongStd_Light_widths[89] = +{ + {0x0000, 207}, {0x0021, 270}, {0x0022, 342}, {0x0023, 467}, + {0x0024, 462}, {0x0025, 797}, {0x0026, 710}, {0x0027, 239}, + {0x0028, 374}, {0x002A, 423}, {0x002B, 605}, {0x002C, 238}, + {0x002D, 375}, {0x002E, 238}, {0x002F, 334}, {0x0030, 462}, + {0x003A, 238}, {0x003C, 605}, {0x003F, 344}, {0x0040, 748}, + {0x0041, 684}, {0x0042, 560}, {0x0043, 695}, {0x0044, 739}, + {0x0045, 563}, {0x0046, 511}, {0x0047, 729}, {0x0048, 793}, + {0x0049, 318}, {0x004A, 312}, {0x004B, 666}, {0x004C, 526}, + {0x004D, 896}, {0x004E, 758}, {0x004F, 772}, {0x0050, 544}, + {0x0051, 772}, {0x0052, 628}, {0x0053, 465}, {0x0054, 607}, + {0x0055, 753}, {0x0056, 711}, {0x0057, 972}, {0x0058, 647}, + {0x0059, 620}, {0x005A, 607}, {0x005B, 374}, {0x005C, 333}, + {0x005D, 374}, {0x005E, 606}, {0x005F, 500}, {0x0060, 239}, + {0x0061, 417}, {0x0062, 503}, {0x0063, 427}, {0x0064, 529}, + {0x0065, 415}, {0x0066, 264}, {0x0067, 444}, {0x0068, 518}, + {0x0069, 241}, {0x006A, 230}, {0x006B, 495}, {0x006C, 228}, + {0x006D, 793}, {0x006E, 527}, {0x006F, 524}, {0x0071, 504}, + {0x0072, 338}, {0x0073, 336}, {0x0074, 277}, {0x0075, 517}, + {0x0076, 450}, {0x0077, 652}, {0x0078, 466}, {0x0079, 452}, + {0x007A, 407}, {0x007B, 370}, {0x007C, 258}, {0x007D, 370}, + {0x007E, 605}, {0x007F,1000}, {0x00A5, 462}, {0x00A6,1000}, + {0x20AC, 462}, {0x20AD,1000}, {0x303F, 500}, {0x3040,1000}, + {0xFFFF,1000} +}; + +#endif /* PDF_CJKFONTWIDTHS_SUPPORTED */ + +/* Font descriptors for the preinstalled CID fonts */ + +static const pdc_core_metric pdf_cid_metrics[] = { + +/* Acrobat 4 standard fonts */ +/* ---------------------------------------------------------- */ +{ "HeiseiKakuGo-W5", /* FontName */ + 4L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_japanese, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -92, /* llx */ + -250, /* lly */ + 1010, /* urx */ + 922, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 553, /* xHeight */ + 752, /* Ascender */ + -221, /* Descender */ + 114, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 163, /* numOfInter */ + pdf_HeiseiKakuGo_W5_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "HeiseiMin-W3", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_japanese, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -123, /* llx */ + -257, /* lly */ + 1001, /* urx */ + 910, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 709, /* CapHeight */ + 450, /* xHeight */ + 723, /* Ascender */ + -241, /* Descender */ + 69, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 164, /* numOfInter */ + pdf_HeiseiMin_W3_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "HYGoThic-Medium", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_korean, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -6, /* llx */ + -145, /* lly */ + 1003, /* urx */ + 880, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 553, /* xHeight */ + 752, /* Ascender */ + -271, /* Descender */ + 58, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 68, /* numOfInter */ + pdf_HYGoThic_Medium_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "HYSMyeongJo-Medium", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_korean, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -0, /* llx */ + -148, /* lly */ + 1001, /* urx */ + 880, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 553, /* xHeight */ + 752, /* Ascender */ + -271, /* Descender */ + 58, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 67, /* numOfInter */ + pdf_HYSMyeongJo_Medium_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "MHei-Medium", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_traditional_chinese, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -45, /* llx */ + -250, /* lly */ + 1015, /* urx */ + 887, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 553, /* xHeight */ + 752, /* Ascender */ + -271, /* Descender */ + 58, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 67, /* numOfInter */ + pdf_HYSMyeongJo_Medium_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "MSung-Light", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_traditional_chinese, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -160, /* llx */ + -259, /* lly */ + 1015, /* urx */ + 888, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 553, /* xHeight */ + 752, /* Ascender */ + -271, /* Descender */ + 58, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 80, /* numOfInter */ + pdf_MSung_Light_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "STSong-Light", /* FontName */ + 4L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_simplified_chinese, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -250, /* llx */ + -143, /* lly */ + 600, /* urx */ + 857, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 857, /* CapHeight */ + 599, /* xHeight */ + 857, /* Ascender */ + -143, /* Descender */ + 91, /* StdVW */ + 91, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 83, /* numOfInter */ + pdf_STSong_Light_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* Acrobat 5 standard fonts */ +/* ---------------------------------------------------------- */ +{ "HYSMyeongJoStd-Medium-Acro", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_korean, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -28, /* llx */ + -148, /* lly */ + 1001, /* urx */ + 880, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 553, /* xHeight */ + 752, /* Ascender */ + -271, /* Descender */ + 58, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 69, /* numOfInter */ + pdf_HYSMyeongJoStd_Medium_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "KozMinPro-Regular-Acro", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_japanese, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -195, /* llx */ + -272, /* lly */ + 1110, /* urx */ + 1075, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 553, /* xHeight */ + 752, /* Ascender */ + -271, /* Descender */ + 58, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 265, /* numOfInter */ + pdf_KozMinPro_Regular_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "MSungStd-Light-Acro", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_traditional_chinese, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -160, /* llx */ + -249, /* lly */ + 1015, /* urx */ + 1071, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 553, /* xHeight */ + 752, /* Ascender */ + -271, /* Descender */ + 58, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 82, /* numOfInter */ + pdf_MSungStd_Light_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +}, + +/* ---------------------------------------------------------- */ +{ "STSongStd-Light-Acro", /* FontName */ + 6L, /* Font flags */ + pdc_CIDFontType0, /* font type */ + cc_simplified_chinese, /* Character collection */ + (float) 0.0, /* ItalicAngle */ + pdc_true, /* isFixedPitch */ + -134, /* llx */ + -254, /* lly */ + 1001, /* urx */ + 905, /* ury */ + -100, /* UnderlinePosition */ + 50, /* UnderlineThickness */ + 737, /* CapHeight */ + 535, /* xHeight */ + 752, /* Ascender */ + -271, /* Descender */ + 58, /* StdVW */ + 0, /* StdHW */ + +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + 89, /* numOfInter */ + pdf_STSongStd_Light_widths, /* ciw */ +#else /* PDF_CJKFONTWIDTHS_SUPPORTED */ + 0, + NULL, +#endif /* !PDF_CJKFONTWIDTHS_SUPPORTED */ + + 0, /* numOfGlyphs */ + (pdc_glyphwidth *) NULL, /* glw */ + +} + +}; + +#define SIZEOF_CID_METRICS \ + ((int) (sizeof(pdf_cid_metrics)/sizeof(pdc_core_metric))) +#define NUMBER_OF_CMAPS ((int) (sizeof(cmaps)/sizeof(pdf_cmap))) + +#endif /* P_CID_H */ diff --git a/src/libs/pdflib/libs/pdflib/p_color.c b/src/libs/pdflib/libs/pdflib/p_color.c new file mode 100644 index 0000000000..c85798d377 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_color.c @@ -0,0 +1,936 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_color.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib color routines + * + */ + +#define P_COLOR_C + +#include "p_intern.h" +#include "p_font.h" + + + + +/* Avoid wrong error messages due to rounding artifacts. + * This doesn't do any harm since we truncate to 5 decimal places anyway + * when producing PDF output. + */ +#define EPSILON ((float) (1.0 + PDF_SMALLREAL)) + +static void pdf_check_color_values(PDF *p, pdf_colorspacetype type, + float c1, float c2, float c3, float c4); + +int +pdf_color_components(PDF *p, int slot) +{ + pdf_colorspace *cs; + int components = 0; + + cs = &p->colorspaces[slot]; + + switch (cs->type) { + case DeviceGray: + case Indexed: + components = 1; + break; + + case DeviceRGB: + components = 3; + break; + + case DeviceCMYK: + components = 4; + break; + + case PatternCS: + if (cs->val.pattern.base == pdc_undef) + components = 0; /* PaintType 1: colored pattern */ + else + components = pdf_color_components(p, cs->val.pattern.base); + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", cs->type), 0, 0, 0); + } + + return components; +} /* pdf_color_components */ + +void +pdf_write_color_values(PDF *p, pdf_color *color, pdf_drawmode drawmode) +{ + pdf_colorspace *cs = &p->colorspaces[color->cs]; + + switch (cs->type) { + case DeviceGray: + pdc_printf(p->out, "%f", color->val.gray); + + if (drawmode == pdf_fill) + pdc_puts(p->out, " g\n"); + else if (drawmode == pdf_stroke) + pdc_puts(p->out, " G\n"); + break; + + case DeviceRGB: + pdc_printf(p->out, "%f %f %f", + color->val.rgb.r, color->val.rgb.g, color->val.rgb.b); + + if (drawmode == pdf_fill) + pdc_puts(p->out, " rg\n"); + else if (drawmode == pdf_stroke) + pdc_puts(p->out, " RG\n"); + break; + + case DeviceCMYK: + pdc_printf(p->out, "%f %f %f %f", + color->val.cmyk.c, color->val.cmyk.m, + color->val.cmyk.y, color->val.cmyk.k); + + if (drawmode == pdf_fill) + pdc_puts(p->out, " k\n"); + else if (drawmode == pdf_stroke) + pdc_puts(p->out, " K\n"); + break; + + + case PatternCS: + if (drawmode == pdf_fill) { + if (p->pattern[color->val.pattern].painttype == 1) { + pdc_puts(p->out, "/Pattern cs"); + } else if (p->pattern[color->val.pattern].painttype == 2) { + pdc_printf(p->out, "/CS%d cs ", color->cs); + pdf_write_color_values(p, + &p->cstate[p->sl].fill, pdf_none); + } + pdc_printf(p->out, "/P%d scn\n", color->val.pattern); + + } else if (drawmode == pdf_stroke) { + if (p->pattern[color->val.pattern].painttype == 1) { + pdc_puts(p->out, "/Pattern CS"); + } else if (p->pattern[color->val.pattern].painttype == 2) { + pdc_printf(p->out, "/CS%d CS ", color->cs); + pdf_write_color_values(p, + &p->cstate[p->sl].stroke, pdf_none); + } + pdc_printf(p->out, "/P%d SCN\n", color->val.pattern); + } + + p->pattern[color->val.pattern].used_on_current_page = pdc_true; + break; + + + case Indexed: /* LATER */ + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", + p->colorspaces[color->cs].type), 0, 0, 0); + } +} /* pdf_write_color_values */ + +static pdc_bool +pdf_color_equal(PDF *p, pdf_color *c1, pdf_color *c2) +{ + pdf_colorspace *cs1; + + cs1 = &p->colorspaces[c1->cs]; + + if (c1->cs != c2->cs) + return pdc_false; + + switch (cs1->type) { + case DeviceGray: + return (c1->val.gray == c2->val.gray); + break; + + case DeviceRGB: + return (c1->val.rgb.r == c2->val.rgb.r && + c1->val.rgb.g == c2->val.rgb.g && + c1->val.rgb.b == c2->val.rgb.b); + break; + + case DeviceCMYK: + return (c1->val.cmyk.c == c2->val.cmyk.c && + c1->val.cmyk.m == c2->val.cmyk.m && + c1->val.cmyk.y == c2->val.cmyk.y && + c1->val.cmyk.k == c2->val.cmyk.k); + break; + + case Indexed: + return (c1->val.idx == c2->val.idx); + break; + + case PatternCS: + return (c1->val.pattern == c2->val.pattern); + break; + + + default: + break; + } + + return pdc_true; +} /* pdf_color_equal */ + +static pdc_bool +pdf_colorspace_equal(PDF *p, pdf_colorspace *cs1, pdf_colorspace *cs2) +{ + if (cs1->type != cs2->type) + return pdc_false; + + switch (cs1->type) { + case DeviceGray: + case DeviceRGB: + case DeviceCMYK: + return pdc_true; + break; + + + case Indexed: + return ((cs1->val.indexed.base == cs2->val.indexed.base) && + (cs1->val.indexed.palette_size==cs2->val.indexed.palette_size)&& + (cs1->val.indexed.colormap_id != PDC_BAD_ID && + cs1->val.indexed.colormap_id == cs2->val.indexed.colormap_id)); + break; + + case PatternCS: + return (cs1->val.pattern.base == cs2->val.pattern.base); + break; + + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", cs1->type), 0, 0, 0); + } + + return pdc_false; +} /* pdf_colorspace_equal */ + +static void +pdf_grow_colorspaces(PDF *p) +{ + int i; + + p->colorspaces = (pdf_colorspace *) pdc_realloc(p->pdc, p->colorspaces, + sizeof(pdf_colorspace) * 2 * p->colorspaces_capacity, + "pdf_grow_colorspaces"); + + for (i = p->colorspaces_capacity; i < 2 * p->colorspaces_capacity; i++) { + p->colorspaces[i].used_on_current_page = pdc_false; + } + + p->colorspaces_capacity *= 2; +} + +int +pdf_add_colorspace(PDF *p, pdf_colorspace *cs, pdc_bool inuse) +{ + pdf_colorspace *cs_new; + static const char fn[] = "pdf_add_colorspace"; + int slot; + + for (slot = 0; slot < p->colorspaces_number; slot++) + { + if (pdf_colorspace_equal(p, &p->colorspaces[slot], cs)) + { + if (inuse) + p->colorspaces[slot].used_on_current_page = pdc_true; + return slot; + } + } + + slot = p->colorspaces_number; + + if (p->colorspaces_number >= p->colorspaces_capacity) + pdf_grow_colorspaces(p); + + cs_new = &p->colorspaces[slot]; + + cs_new->type = cs->type; + + /* don't allocate id for simple color spaces, since we don't write these */ + if (PDF_SIMPLE_COLORSPACE(cs)) { + cs_new->obj_id = PDC_BAD_ID; + cs_new->used_on_current_page = pdc_false; + + } else { + cs_new->obj_id = pdc_alloc_id(p->out); + cs_new->used_on_current_page = inuse; + } + + switch (cs_new->type) { + case DeviceGray: + case DeviceRGB: + case DeviceCMYK: + break; + + + case Indexed: + cs_new->val.indexed.base = cs->val.indexed.base; + cs_new->val.indexed.palette_size = cs->val.indexed.palette_size; + cs_new->val.indexed.colormap_id = pdc_alloc_id(p->out); + cs_new->val.indexed.colormap = + (pdf_colormap *) pdc_malloc(p->pdc, sizeof(pdf_colormap), fn); + memcpy(cs_new->val.indexed.colormap, cs->val.indexed.colormap, + sizeof(pdf_colormap)); + cs_new->val.indexed.colormap_done = pdc_false; + break; + + case PatternCS: + cs_new->val.pattern.base = cs->val.pattern.base; + break; + + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", cs_new->type), 0, 0, 0); + } + + p->colorspaces_number++; + + return slot; +} /* pdf_add_colorspace */ + +void +pdf_init_cstate(PDF *p) +{ + pdf_cstate *cstate; + + cstate = &p->cstate[p->sl]; + + cstate->fill.cs = DeviceGray; + cstate->fill.val.gray = (float) 0.0; + + cstate->stroke.cs = DeviceGray; + cstate->stroke.val.gray = (float) 0.0; +} + +void +pdf_set_color_values(PDF *p, pdf_color *c, pdf_drawmode drawmode) +{ + pdf_color *current; + pdf_colorspace *cs; + + cs = &p->colorspaces[c->cs]; + + if (drawmode == pdf_stroke || drawmode == pdf_fillstroke) { + current = &p->cstate[p->sl].stroke; + + if (!pdf_color_equal(p, current, c) || PDF_FORCE_OUTPUT()) + { + if (PDF_GET_STATE(p) != pdf_state_document) + pdf_write_color_values(p, c, pdf_stroke); + + *current = *c; + } + } + if (drawmode == pdf_fill || drawmode == pdf_fillstroke) { + current = &p->cstate[p->sl].fill; + + if (!pdf_color_equal(p, current, c) || PDF_FORCE_OUTPUT()) + { + if (PDF_GET_STATE(p) != pdf_state_document) + pdf_write_color_values(p, c, pdf_fill); + + *current = *c; + } + } + + /* simple colorspaces don't get written */ + if (!PDF_SIMPLE_COLORSPACE(cs)) + cs->used_on_current_page = pdc_true; + +} /* pdf_set_color_values */ + +PDFLIB_API void PDFLIB_CALL +PDF_setgray_fill(PDF *p, float g) +{ + static const char fn[] = "PDF_setgray_fill"; + pdf_color c; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g)\n", + (void *) p, g)) + return; + + pdf_check_color_values(p, DeviceGray, g, (float) 0, (float) 0, (float) 0); + c.cs = DeviceGray; + c.val.gray = g; + pdf_set_color_values(p, &c, pdf_fill); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setgray_stroke(PDF *p, float g) +{ + static const char fn[] = "PDF_setgray_stroke"; + pdf_color c; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g)\n", + (void *) p, g)) + return; + + pdf_check_color_values(p, DeviceGray, g, (float) 0, (float) 0, (float) 0); + c.cs = DeviceGray; + c.val.gray = g; + pdf_set_color_values(p, &c, pdf_stroke); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setgray(PDF *p, float g) +{ + static const char fn[] = "PDF_setgray"; + pdf_color c; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g)\n", + (void *) p, g)) + return; + + pdf_check_color_values(p, DeviceGray, g, (float) 0, (float) 0, (float) 0); + c.cs = DeviceGray; + c.val.gray = g; + pdf_set_color_values(p, &c, pdf_fillstroke); +} + +/* RGB functions */ + +PDFLIB_API void PDFLIB_CALL +PDF_setrgbcolor_fill(PDF *p, float r, float g, float b) +{ + static const char fn[] = "PDF_setrgbcolor_fill"; + pdf_color c; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g, %g, %g)\n", + (void *) p, r, g, b)) + return; + + pdf_check_color_values(p, DeviceRGB, r, g, b, 0); + c.cs = DeviceRGB; + c.val.rgb.r = r; + c.val.rgb.g = g; + c.val.rgb.b = b; + pdf_set_color_values(p, &c, pdf_fill); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setrgbcolor_stroke(PDF *p, float r, float g, float b) +{ + static const char fn[] = "PDF_setrgbcolor_stroke"; + pdf_color c; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g, %g, %g)\n", + (void *) p, r, g, b)) + return; + + pdf_check_color_values(p, DeviceRGB, r, g, b, 0); + c.cs = DeviceRGB; + c.val.rgb.r = r; + c.val.rgb.g = g; + c.val.rgb.b = b; + pdf_set_color_values(p, &c, pdf_stroke); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setrgbcolor(PDF *p, float r, float g, float b) +{ + static const char fn[] = "PDF_setrgbcolor"; + pdf_color c; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g, %g, %g)\n", + (void *) p, r, g, b)) + return; + + pdf_check_color_values(p, DeviceRGB, r, g, b, 0); + c.cs = DeviceRGB; + c.val.rgb.r = r; + c.val.rgb.g = g; + c.val.rgb.b = b; + pdf_set_color_values(p, &c, pdf_fillstroke); +} + +void +pdf_init_colorspaces(PDF *p) +{ + int i, slot; + pdf_colorspace cs; + + + p->colorspaces_number = 0; + p->colorspaces_capacity = COLORSPACES_CHUNKSIZE; + + p->colorspaces = (pdf_colorspace *) + pdc_malloc(p->pdc, sizeof(pdf_colorspace) * p->colorspaces_capacity, + "pdf_init_colorspaces"); + + for (i = 0; i < p->colorspaces_capacity; i++) { + p->colorspaces[i].used_on_current_page = pdc_false; + } + + /* + * Initialize a few slots with simple color spaces for easier use. + * These can be used without further ado: the slot number is identical + * to the enum value due to the ordering below. + */ + + cs.type = DeviceGray; + slot = pdf_add_colorspace(p, &cs, pdc_false); + cs.type = DeviceRGB; + slot = pdf_add_colorspace(p, &cs, pdc_false); + cs.type = DeviceCMYK; + slot = pdf_add_colorspace(p, &cs, pdc_false); + +} /* pdf_init_colorspaces */ + +void +pdf_write_page_colorspaces(PDF *p) +{ + int i, total = 0; + + for (i = 0; i < p->colorspaces_number; i++) + if (p->colorspaces[i].used_on_current_page) + total++; + + if (total > 0 + ) { + pdc_puts(p->out, "/ColorSpace"); + + pdc_begin_dict(p->out); /* color space names */ + + for (i = 0; i < p->colorspaces_number; i++) { + pdf_colorspace *cs = &p->colorspaces[i]; + + if (cs->used_on_current_page) { + cs->used_on_current_page = pdc_false; /* reset */ + + /* don't write simple color spaces as resource */ + if (!PDF_SIMPLE_COLORSPACE(cs)) + pdc_printf(p->out, "/CS%d %ld 0 R\n", i, cs->obj_id); + } + } + + + pdc_end_dict(p->out); /* color space names */ + } +} /* pdf_write_page_colorspaces */ + +void +pdf_write_function_dict(PDF *p, pdf_color *c0, pdf_color *c1, float N) +{ + pdf_colorspace *cs; + + cs = &p->colorspaces[c1->cs]; + + pdc_begin_dict(p->out); /* function dict */ + + pdc_puts(p->out, "/FunctionType 2\n"); + pdc_puts(p->out, "/Domain[0 1]\n"); + pdc_printf(p->out, "/N %f\n", N); + + switch (cs->type) { + + case DeviceGray: + pdc_puts(p->out, "/Range[0 1]\n"); + if (c0->val.gray != 0) pdc_printf(p->out, "/C0[%f]\n", c0->val.gray); + if (c1->val.gray != 1) pdc_printf(p->out, "/C1[%f]", c1->val.gray); + break; + + case DeviceRGB: + pdc_puts(p->out, "/Range[0 1 0 1 0 1]\n"); + pdc_printf(p->out, "/C0[%f %f %f]\n", + c0->val.rgb.r, c0->val.rgb.g, c0->val.rgb.b); + pdc_printf(p->out, "/C1[%f %f %f]", + c1->val.rgb.r, c1->val.rgb.g, c1->val.rgb.b); + break; + + case DeviceCMYK: + pdc_puts(p->out, "/Range[0 1 0 1 0 1 0 1]\n"); + pdc_printf(p->out, "/C0[%f %f %f %f]\n", + c0->val.cmyk.c, c0->val.cmyk.m, c0->val.cmyk.y, c0->val.cmyk.k); + pdc_printf(p->out, "/C1[%f %f %f %f]", + c1->val.cmyk.c, c1->val.cmyk.m, c1->val.cmyk.y, c1->val.cmyk.k); + break; + + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", cs->type), 0, 0, 0); + } + + pdc_end_dict(p->out); /* function dict */ +} /* pdf_write_function_dict */ + +void +pdf_write_colormap(PDF *p, int slot) +{ + PDF_data_source src; + pdf_colorspace *cs, *base; + pdc_id length_id; + + cs = &p->colorspaces[slot]; + + if (cs->type != Indexed || cs->val.indexed.colormap_done == pdc_true) + return; + + base = &p->colorspaces[cs->val.indexed.base]; + + pdc_begin_obj(p->out, cs->val.indexed.colormap_id); /* colormap object */ + pdc_begin_dict(p->out); + + if (p->debug['a']) + pdc_puts(p->out, "/Filter/ASCIIHexDecode\n"); + else if (pdc_get_compresslevel(p->out)) + pdc_puts(p->out, "/Filter/FlateDecode\n"); + + /* Length of colormap object */ + length_id = pdc_alloc_id(p->out); + pdc_printf(p->out,"/Length %ld 0 R\n", length_id); + pdc_end_dict(p->out); + + src.init = NULL; + src.fill = pdf_data_source_buf_fill; + src.terminate = NULL; + + src.buffer_start = (unsigned char *) cs->val.indexed.colormap; + + src.buffer_length = (size_t) (cs->val.indexed.palette_size * + pdf_color_components(p, cs->val.indexed.base)); + + src.bytes_available = 0; + src.next_byte = NULL; + + /* Write colormap data */ + if (p->debug['a']) + pdf_ASCIIHexEncode(p, &src); + else { + pdf_copy_stream(p, &src, pdc_true); /* colormap data */ + } + + pdc_end_obj(p->out); /* colormap object */ + + pdc_put_pdfstreamlength(p->out, length_id); + + /* free the colormap now that it's written */ + pdc_free(p->pdc, cs->val.indexed.colormap); + cs->val.indexed.colormap = NULL; + cs->val.indexed.colormap_done = pdc_true; +} /* pdf_write_colormap */ + +void +pdf_write_colorspace(PDF *p, int slot, pdc_bool direct) +{ + pdf_colorspace *cs; + int base; + + if (slot < 0 || slot >= p->colorspaces_number) + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", slot), 0, 0, 0); + + cs = &p->colorspaces[slot]; + + /* we always write simple colorspaces directly */ + if (PDF_SIMPLE_COLORSPACE(cs)) + direct = pdc_true; + + if (!direct) { + pdc_printf(p->out, " %ld 0 R", cs->obj_id); + return; + } + + switch (cs->type) { + case DeviceGray: + pdc_printf(p->out, "/DeviceGray"); + break; + + case DeviceRGB: + pdc_printf(p->out, "/DeviceRGB"); + break; + + case DeviceCMYK: + pdc_printf(p->out, "/DeviceCMYK"); + break; + + + + case Indexed: + base = cs->val.indexed.base; + + pdc_puts(p->out, "[/Indexed"); + + pdf_write_colorspace(p, base, pdc_false); + pdc_puts(p->out, " "); + + pdc_printf(p->out, "%d %ld 0 R", cs->val.indexed.palette_size - 1, + cs->val.indexed.colormap_id); + pdc_puts(p->out, "]"); + break; + + case PatternCS: + pdc_printf(p->out, "[/Pattern"); + pdf_write_colorspace(p, cs->val.pattern.base, pdc_false); + pdc_puts(p->out, "]"); + break; + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", cs->type), 0, 0, 0); + } +} /* pdf_write_colorspace */ + +void +pdf_write_doc_colorspaces(PDF *p) +{ + int i; + + for (i = 0; i < p->colorspaces_number; i++) { + pdf_colorspace *cs = &p->colorspaces[i]; + + /* don't write simple color spaces as resource */ + if (PDF_SIMPLE_COLORSPACE(cs)) + continue; + + pdc_begin_obj(p->out, cs->obj_id); + pdf_write_colorspace(p, i, pdc_true); + pdc_puts(p->out, "\n"); + pdc_end_obj(p->out); /* color space resource */ + + pdf_write_colormap(p, i); /* write pending colormaps */ + } +} + +void +pdf_cleanup_colorspaces(PDF *p) +{ + int i; + + if (!p->colorspaces) + return; + + for (i = 0; i < p->colorspaces_number; i++) { + pdf_colorspace *cs = &p->colorspaces[i];; + + switch (cs->type) { + case DeviceGray: + case DeviceRGB: + case DeviceCMYK: + case PatternCS: + break; + + case Indexed: + if (cs->val.indexed.colormap) + pdc_free(p->pdc, cs->val.indexed.colormap); + break; + + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", cs->type), 0, 0, 0); + } + } + + pdc_free(p->pdc, p->colorspaces); + p->colorspaces = NULL; +} + + + + + +PDFLIB_API int PDFLIB_CALL +PDF_makespotcolor(PDF *p, const char *spotname, int reserved) +{ + static const char fn[] = "PDF_makespotcolor"; + int slot = -1; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_content | pdf_state_document), + "(p[%p], \"%s\", %d)", (void *) p, spotname, reserved)) + { + PDF_RETURN_HANDLE(p, slot) + } + + pdc_error(p->pdc, PDF_E_UNSUPP_SPOTCOLOR, 0, 0, 0, 0); + + PDF_RETURN_HANDLE(p, slot) +} + + + +static void +pdf_check_color_values( + PDF *p, + pdf_colorspacetype type, + float c1, float c2, float c3, float c4) +{ + switch (type) { + case DeviceGray: + if (c1 < 0.0 || c1 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c1", pdc_errprintf(p->pdc, "%f", c1), 0, 0); + break; + + case DeviceRGB: + if (c1 < 0.0 || c1 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c1", pdc_errprintf(p->pdc, "%f", c1), 0, 0); + if (c2 < 0.0 || c2 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c2", pdc_errprintf(p->pdc, "%f", c2), 0, 0); + if (c3 < 0.0 || c3 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c3", pdc_errprintf(p->pdc, "%f", c3), 0, 0); + + break; + + case DeviceCMYK: + if (c1 < 0.0 || c1 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c1", pdc_errprintf(p->pdc, "%f", c1), 0, 0); + if (c2 < 0.0 || c2 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c2", pdc_errprintf(p->pdc, "%f", c2), 0, 0); + if (c3 < 0.0 || c3 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c3", pdc_errprintf(p->pdc, "%f", c3), 0, 0); + + if (c4 < 0.0 || c4 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c4", pdc_errprintf(p->pdc, "%f", c4), 0, 0); + break; + + + + case PatternCS: + pdf_check_handle(p, (int) c1, pdc_patternhandle); + break; + + case Separation: + pdf_check_handle(p, (int) c1, pdc_colorhandle); + if (c2 < 0.0 || c2 > EPSILON ) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "c2", pdc_errprintf(p->pdc, "%f", c2), 0, 0); + break; + + case Indexed: + default: + break; + } +} /* pdf_check_color_values */ + +static const pdc_keyconn pdf_fstype_keylist[] = +{ + {"stroke", pdf_stroke}, + {"fill", pdf_fill}, + {"fillstroke", pdf_stroke | pdf_fill}, + {"both", pdf_stroke | pdf_fill}, + {NULL, 0} +}; + +void +pdf__setcolor( + PDF *p, + const char *fstype, + const char *colorspace, + float c1, float c2, float c3, float c4) +{ + pdf_color c; + pdf_drawmode drawmode = pdf_none; + pdf_colorspace cs; + int k; + + k = pdc_get_keycode_ci(fstype, pdf_fstype_keylist); + if (k == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "fstype", fstype, 0, 0); + drawmode = (pdf_drawmode) k; + + k = pdc_get_keycode_ci(colorspace, pdf_colorspace_keylist); + if (k == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "colorspace", colorspace, 0, 0); + cs.type = (pdf_colorspacetype) k; + + switch (cs.type) { + + case DeviceGray: + c.cs = cs.type; + c.val.gray = c1; + pdf_check_color_values(p, cs.type, c1, c2, c3, c4); + break; + + case DeviceRGB: + c.cs = cs.type; + c.val.rgb.r = c1; + c.val.rgb.g = c2; + c.val.rgb.b = c3; + pdf_check_color_values(p, cs.type, c1, c2, c3, c4); + break; + + case DeviceCMYK: + c.cs = cs.type; + c.val.cmyk.c = c1; + c.val.cmyk.m = c2; + c.val.cmyk.y = c3; + c.val.cmyk.k = c4; + pdf_check_color_values(p, cs.type, c1, c2, c3, c4); + break; + + + case PatternCS: + + c.val.pattern = (int) c1; + PDF_INPUT_HANDLE(p, c.val.pattern) + pdf_check_color_values(p, cs.type, c1, c2, c3, c4); + + if (p->pattern[c.val.pattern].painttype == 1) { + cs.val.pattern.base = pdc_undef; + c.cs = pdf_add_colorspace(p, &cs, pdc_false); + } else { + cs.val.pattern.base = p->cstate[p->sl].fill.cs; + c.cs = pdf_add_colorspace(p, &cs, pdc_true); + } + break; + + + default: + pdc_error(p->pdc, PDC_E_OPT_UNSUPP, colorspace, 0, 0, 0); + } + + pdf_set_color_values(p, &c, drawmode); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setcolor( + PDF *p, + const char *fstype, + const char *colorspace, + float c1, float c2, float c3, float c4) +{ + static const char fn[] = "PDF_setcolor"; + int legal_states; + + if (PDF_GET_STATE(p) == pdf_state_glyph && !pdf_get_t3colorized(p)) + legal_states = pdf_state_page | pdf_state_pattern | pdf_state_template; + else + legal_states = pdf_state_content | pdf_state_document; + + if (!pdf_enter_api(p, fn, (pdf_state) legal_states, + "(p[%p], \"%s\", \"%s\", %g, %g, %g, %g)\n", + (void *) p, fstype, colorspace, c1, c2, c3, c4)) + return; + + if (!fstype || !*fstype) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "fstype", 0, 0, 0); + + if (!colorspace || !*colorspace) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "colorspace", 0, 0, 0); + + pdf__setcolor(p, fstype, colorspace, c1, c2, c3, c4); +} diff --git a/src/libs/pdflib/libs/pdflib/p_color.h b/src/libs/pdflib/libs/pdflib/p_color.h new file mode 100644 index 0000000000..55cb7e4e6f --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_color.h @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_color.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib color definitions + * + */ + +#ifndef P_COLOR_H +#define P_COLOR_H + +typedef enum { + NoColor = -1, DeviceGray = 0, DeviceRGB, DeviceCMYK, + CalGray, CalRGB, Lab, ICCBased, + Indexed, PatternCS, Separation, DeviceN +} pdf_colorspacetype; + +/* + * These are treated specially in the global colorspace list, and are not + * written as /ColorSpace resource since we always specify them directly. + * Pattern colorspace with base == pdc_undef means PaintType == 1. + */ +#define PDF_SIMPLE_COLORSPACE(cs) \ + ((cs)->type == DeviceGray || \ + (cs)->type == DeviceRGB || \ + (cs)->type == DeviceCMYK || \ + ((cs)->type == PatternCS && cs->val.pattern.base == pdc_undef)) + +/* Rendering Intents */ +typedef enum { + AutoIntent = 0, + AbsoluteColorimetric, + RelativeColorimetric, + Saturation, + Perceptual +} pdf_renderingintent; + +/* BlendModes */ +typedef enum { + BM_None = 0, + BM_Normal = 1<<0, + BM_Multiply = 1<<1, + BM_Screen = 1<<2, + BM_Overlay = 1<<3, + BM_Darken = 1<<4, + BM_Lighten = 1<<5, + BM_ColorDodge = 1<<6, + BM_ColorBurn = 1<<7, + BM_HardLight = 1<<8, + BM_SoftLight = 1<<9, + BM_Difference = 1<<10, + BM_Exclusion = 1<<11, + BM_Hue = 1<<12, + BM_Saturation = 1<<13, + BM_Color = 1<<14, + BM_Luminosity = 1<<15 +} pdf_blendmode; + + +struct pdf_pattern_s { + pdc_id obj_id; /* object id of this pattern */ + int painttype; /* colored (1) or uncolored (2) */ + pdc_bool used_on_current_page; /* this pattern used on current page */ +}; + +typedef enum { + pdf_none = 0, + pdf_fill, + pdf_stroke, + pdf_fillstroke +} pdf_drawmode; + +typedef pdc_byte pdf_colormap[256][3]; + +typedef struct pdf_colorspace_s pdf_colorspace; + +typedef struct { + int cs; /* slot of underlying color space */ + + union { + float gray; /* DeviceGray */ + int pattern; /* Pattern */ + int idx; /* Indexed */ + struct { /* DeviceRGB */ + float r; + float g; + float b; + } rgb; + struct { /* DeviceCMYK */ + float c; + float m; + float y; + float k; + } cmyk; + } val; +} pdf_color; + +struct pdf_colorspace_s { + pdf_colorspacetype type; /* color space type */ + + union { + struct { /* Indexed */ + int base; /* base color space */ + pdf_colormap *colormap; /* pointer to colormap */ + pdc_bool colormap_done; /* colormap already written to output */ + int palette_size; /* # of palette entries (not bytes!) */ + pdc_id colormap_id; /* object id of colormap */ + } indexed; + + struct { /* Pattern */ + int base; /* base color space for PaintType 2 */ + } pattern; + + } val; + + pdc_id obj_id; /* object id of this colorspace */ + pdc_bool used_on_current_page; /* this resource used on current page */ +}; + +typedef struct { + pdf_color fill; + pdf_color stroke; +} pdf_cstate; + +/* p_color.c */ +void pdf_init_cstate(PDF *p); +void pdf_init_colorspaces(PDF *p); +void pdf_write_page_colorspaces(PDF *p); +void pdf_write_function_dict(PDF *p, pdf_color *c0, pdf_color *c1, float N); +void pdf_write_doc_colorspaces(PDF *p); +void pdf_write_colorspace(PDF *p, int slot, pdc_bool direct); +void pdf_write_color_values(PDF *p, pdf_color *color, pdf_drawmode mode); +void pdf_set_color_values(PDF *p, pdf_color *c, pdf_drawmode drawmode); +int pdf_add_colorspace(PDF *p, pdf_colorspace *cs, pdc_bool inuse); +void pdf_cleanup_colorspaces(PDF *p); +void pdf_write_colormap(PDF *p, int slot); +int pdf_color_components(PDF *p, int slot); +int pdf__makespotcolor(PDF *p, const char *spotname); +void pdf__setcolor(PDF *p, const char *fstype, const char *colorspace, + float c1, float c2, float c3, float c4); + + +/* p_pattern.c */ +void pdf_grow_pattern(PDF *p); +#endif /* P_COLOR_H */ diff --git a/src/libs/pdflib/libs/pdflib/p_draw.c b/src/libs/pdflib/libs/pdflib/p_draw.c new file mode 100644 index 0000000000..9fd114dca8 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_draw.c @@ -0,0 +1,554 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_draw.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib drawing routines + * + */ + +#include "p_intern.h" + +/* Path segment operators */ + +void +pdf_begin_path(PDF *p) +{ + if (PDF_GET_STATE(p) == pdf_state_path) + return; + + pdf_end_text(p); + p->contents = c_path; + PDF_PUSH_STATE(p, "pdf_begin_path", pdf_state_path); +} + +void +pdf_end_path(PDF *p) +{ + p->contents = c_page; + PDF_POP_STATE(p, "pdf_end_path"); + + p->gstate[p->sl].x = (float) 0.0; + p->gstate[p->sl].y = (float) 0.0; +} + +/* ----------------- Basic functions for API functions --------------*/ + +void +pdf__moveto(PDF *p, float x, float y) +{ + p->gstate[p->sl].startx = p->gstate[p->sl].x = x; + p->gstate[p->sl].starty = p->gstate[p->sl].y = y; + + pdf_begin_path(p); + pdc_printf(p->out, "%f %f m\n", x, y); +} + +void +pdf__rmoveto(PDF *p, float x, float y) +{ + float x_0 = p->gstate[p->sl].x; + float y_0 = p->gstate[p->sl].y; + + pdf__moveto(p, x_0 + x, y_0 + y); +} + +void +pdf__lineto(PDF *p, float x, float y) +{ + pdc_printf(p->out, "%f %f l\n", x, y); + + p->gstate[p->sl].x = x; + p->gstate[p->sl].y = y; +} + +void +pdf__rlineto(PDF *p, float x, float y) +{ + float x_0 = p->gstate[p->sl].x; + float y_0 = p->gstate[p->sl].y; + + pdf__lineto(p, x_0 + x, y_0 + y); +} + +void +pdf__curveto(PDF *p, + float x_1, float y_1, + float x_2, float y_2, + float x_3, float y_3) +{ + if (x_2 == x_3 && y_2 == y_3) /* second c.p. coincides with final point */ + pdc_printf(p->out, "%f %f %f %f y\n", x_1, y_1, x_3, y_3); + + else /* general case with four distinct points */ + pdc_printf(p->out, "%f %f %f %f %f %f c\n", + x_1, y_1, x_2, y_2, x_3, y_3); + + p->gstate[p->sl].x = x_3; + p->gstate[p->sl].y = y_3; +} + +void +pdf__rcurveto(PDF *p, + float x_1, float y_1, + float x_2, float y_2, + float x_3, float y_3) +{ + float x_0 = p->gstate[p->sl].x; + float y_0 = p->gstate[p->sl].y; + + pdf__curveto(p, x_0 + x_1, y_0 + y_1, + x_0 + x_2, y_0 + y_2, + x_0 + x_3, y_0 + y_3); +} + +void +pdf__rrcurveto(PDF *p, + float x_1, float y_1, + float x_2, float y_2, + float x_3, float y_3) +{ + pdf__rcurveto(p, x_1, y_1, + x_1 + x_2, y_1 + y_2, + x_1 + x_2 + x_3, y_1 + y_2 + y_3); +} + +void +pdf__hvcurveto(PDF *p, float x_1, float x_2, float y_2, float y_3) +{ + pdf__rrcurveto(p, x_1, 0, x_2, y_2, 0, y_3); +} + +void +pdf__vhcurveto(PDF *p, float y_1, float x_2, float y_2, float x_3) +{ + pdf__rrcurveto(p, 0, y_1, x_2, y_2, x_3, 0); +} + +void +pdf__rect(PDF *p, float x, float y, float width, float height) +{ + p->gstate[p->sl].startx = p->gstate[p->sl].x = x; + p->gstate[p->sl].starty = p->gstate[p->sl].y = y; + + pdf_begin_path(p); + pdc_printf(p->out, "%f %f %f %f re\n", x, y, width, p->ydirection * height); +} + +/* 4/3 * (1-cos 45°)/sin 45° = 4/3 * sqrt(2) - 1 */ +#define ARC_MAGIC ((float) 0.552284749) + +static void +pdf_short_arc(PDF *p, float x, float y, float r, float alpha, float beta) +{ + float bcp; + float cos_alpha, cos_beta, sin_alpha, sin_beta; + + alpha = (float) (alpha * PDC_M_PI / 180); + beta = (float) (beta * PDC_M_PI / 180); + + /* This formula yields ARC_MAGIC for alpha == 0, beta == 90 degrees */ + bcp = (float) (4.0/3 * (1 - cos((beta - alpha)/2)) / sin((beta - alpha)/2)); + + sin_alpha = (float) sin(alpha); + sin_beta = (float) sin(beta); + cos_alpha = (float) cos(alpha); + cos_beta = (float) cos(beta); + + pdf__curveto(p, + x + r * (cos_alpha - bcp * sin_alpha), /* p1 */ + y + r * (sin_alpha + bcp * cos_alpha), + x + r * (cos_beta + bcp * sin_beta), /* p2 */ + y + r * (sin_beta - bcp * cos_beta), + x + r * cos_beta, /* p3 */ + y + r * sin_beta); +} + +static void +pdf_orient_arc(PDF *p, float x, float y, float r, float alpha, float beta, + float orient) +{ + float rad_a = (float) (alpha * PDC_M_PI / 180); + float startx = (float) (x + r * cos(rad_a)); + float starty = (float) (y + r * sin(rad_a)); + + if (r < 0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "r", pdc_errprintf(p->pdc, "%f", r), 0, 0); + + if (p->contents != c_path) + pdf__moveto(p, startx, starty); + else if ((p->gstate[p->sl].x != startx || p->gstate[p->sl].y != starty)) + pdf__lineto(p, startx, starty); + + if (orient > 0) + { + while (beta < alpha) + beta += 360; + + if (alpha == beta) + return; + + while (beta - alpha > 90) + { + pdf_short_arc(p, x, y, r, alpha, alpha + 90); + alpha += 90; + } + } + else + { + while (alpha < beta) + alpha += 360; + + if (alpha == beta) + return; + + while (alpha - beta > 90) + { + pdf_short_arc(p, x, y, r, alpha, alpha - 90); + alpha -= 90; + } + } + + if (alpha != beta) + pdf_short_arc(p, x, y, r, alpha, beta); +} + +void +pdf__arc(PDF *p, float x, float y, float r, float alpha, float beta) +{ + pdf_orient_arc(p, x, y, r, + p->ydirection * alpha, p->ydirection * beta, p->ydirection); +} + +void +pdf__arcn(PDF *p, float x, float y, float r, float alpha, float beta) +{ + pdf_orient_arc(p, x, y, r, + p->ydirection * alpha, p->ydirection * beta, -p->ydirection); +} + +void +pdf__circle(PDF *p, float x, float y, float r) +{ + if (r < 0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "r", pdc_errprintf(p->pdc, "%f", r), 0, 0); + + /* + * pdf_begin_path() not required since we descend to other + * path segment functions. + */ + + /* draw four Bezier curves to approximate a circle */ + pdf__moveto(p, x + r, y); + pdf__curveto(p, x + r, y + r*ARC_MAGIC, x + r*ARC_MAGIC, y + r, x, y + r); + pdf__curveto(p, x - r*ARC_MAGIC, y + r, x - r, y + r*ARC_MAGIC, x - r, y); + pdf__curveto(p, x - r, y - r*ARC_MAGIC, x - r*ARC_MAGIC, y - r, x, y - r); + pdf__curveto(p, x + r*ARC_MAGIC, y - r, x + r, y - r*ARC_MAGIC, x + r, y); + + pdf__closepath(p); +} + +void +pdf__closepath(PDF *p) +{ + pdc_puts(p->out, "h\n"); + + p->gstate[p->sl].x = p->gstate[p->sl].startx; + p->gstate[p->sl].y = p->gstate[p->sl].starty; +} + +void +pdf__endpath(PDF *p) +{ + pdc_puts(p->out, "n\n"); + pdf_end_path(p); +} + +void +pdf__stroke(PDF *p) +{ + pdc_puts(p->out, "S\n"); + pdf_end_path(p); +} + +void +pdf__closepath_stroke(PDF *p) +{ + pdc_puts(p->out, "s\n"); + pdf_end_path(p); +} + +void +pdf__fill(PDF *p) +{ + if (p->fillrule == pdf_fill_winding) + pdc_puts(p->out, "f\n"); + else if (p->fillrule == pdf_fill_evenodd) + pdc_puts(p->out, "f*\n"); + + pdf_end_path(p); +} + +void +pdf__fill_stroke(PDF *p) +{ + if (p->fillrule == pdf_fill_winding) + pdc_puts(p->out, "B\n"); + else if (p->fillrule == pdf_fill_evenodd) + pdc_puts(p->out, "B*\n"); + + pdf_end_path(p); +} + +void +pdf__closepath_fill_stroke(PDF *p) +{ + if (p->fillrule == pdf_fill_winding) + pdc_puts(p->out, "b\n"); + else if (p->fillrule == pdf_fill_evenodd) + pdc_puts(p->out, "b*\n"); + + pdf_end_path(p); +} + +void +pdf__clip(PDF *p) +{ + if (p->fillrule == pdf_fill_winding) + pdc_puts(p->out, "W n\n"); + else if (p->fillrule == pdf_fill_evenodd) + pdc_puts(p->out, "W* n\n"); + + pdf_end_path(p); +} + +/* --------------------------- API functions ------------------------------*/ + +PDFLIB_API void PDFLIB_CALL +PDF_moveto(PDF *p, float x, float y) +{ + static const char fn[] = "PDF_moveto"; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_content | pdf_state_path), + "(p[%p], %g, %g)\n", (void *) p, x, y)) + { + pdf__moveto(p, x, y); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_rmoveto(PDF *p, float x, float y) +{ + static const char fn[] = "PDF_rmoveto"; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_content | pdf_state_path), + "(p[%p], %g, %g)\n", (void *) p, x, y)) + { + pdf__rmoveto(p, x, y); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_lineto(PDF *p, float x, float y) +{ + static const char fn[] = "PDF_lineto"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p], %g, %g)\n", + (void *) p, x, y)) + { + pdf__lineto(p, x, y); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_rlineto(PDF *p, float x, float y) +{ + static const char fn[] = "PDF_rlineto"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p], %g, %g)\n", + (void *) p, x, y)) + { + pdf__rlineto(p, x, y); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_curveto(PDF *p, + float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) +{ + static const char fn[] = "PDF_curveto"; + + if (pdf_enter_api(p, fn, pdf_state_path, + "(p[%p], %g, %g, %g, %g, %g, %g)\n", + (void *) p, x_1, y_1, x_2, y_2, x_3, y_3)) + { + pdf__curveto(p, x_1, y_1, x_2, y_2, x_3, y_3); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_rcurveto(PDF *p, + float x_1, float y_1, float x_2, float y_2, float x_3, float y_3) +{ + static const char fn[] = "PDF_rcurveto"; + + if (pdf_enter_api(p, fn, pdf_state_path, + "(p[%p], %g, %g, %g, %g, %g, %g)\n", + (void *) p, x_1, y_1, x_2, y_2, x_3, y_3)) + { + pdf__rcurveto(p, x_1, y_1, x_2, y_2, x_3, y_3); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_rect(PDF *p, float x, float y, float width, float height) +{ + static const char fn[] = "PDF_rect"; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_content | pdf_state_path), + "(p[%p], %g, %g, %g, %g)\n", (void *) p, x, y, width, height)) + { + pdf__rect(p, x, y, width, height); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_arc(PDF *p, float x, float y, float r, float alpha, float beta) +{ + static const char fn[] = "PDF_arc"; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_content | pdf_state_path), + "(p[%p], %g, %g, %g, %g, %g)\n", (void *) p, x, y, r, alpha, beta)) + { + pdf__arc(p, x, y, r, alpha, beta); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_arcn(PDF *p, float x, float y, float r, float alpha, float beta) +{ + static const char fn[] = "PDF_arcn"; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_content | pdf_state_path), + "(p[%p], %g, %g, %g, %g, %g)\n", (void *) p, x, y, r, alpha, beta)) + { + pdf__arcn(p, x, y, r, alpha, beta); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_circle(PDF *p, float x, float y, float r) +{ + static const char fn[] = "PDF_circle"; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_content | pdf_state_path), + "(p[%p], %g, %g, %g)\n", (void *) p, x, y, r)) + { + pdf__circle(p, x, y, r); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_closepath(PDF *p) +{ + static const char fn[] = "PDF_closepath"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p])\n", (void *) p)) + { + pdf__closepath(p); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_endpath(PDF *p) +{ + static const char fn[] = "PDF_endpath"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p])\n", (void *) p)) + { + pdf__endpath(p); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_stroke(PDF *p) +{ + static const char fn[] = "PDF_stroke"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p])\n", (void *) p)) + { + pdf__stroke(p); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_closepath_stroke(PDF *p) +{ + static const char fn[] = "PDF_closepath_stroke"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p])\n", (void *) p)) + { + pdf__closepath_stroke(p); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_fill(PDF *p) +{ + static const char fn[] = "PDF_fill"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p])\n", (void *) p)) + { + pdf__fill(p); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_fill_stroke(PDF *p) +{ + static const char fn[] = "PDF_fill_stroke"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p])\n", (void *) p)) + { + pdf__fill_stroke(p); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_closepath_fill_stroke(PDF *p) +{ + static const char fn[] = "PDF_closepath_fill_stroke"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p])\n", (void *) p)) + { + pdf__closepath_fill_stroke(p); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_clip(PDF *p) +{ + static const char fn[] = "PDF_clip"; + + if (pdf_enter_api(p, fn, pdf_state_path, "(p[%p])\n", (void *) p)) + { + pdf__clip(p); + } +} diff --git a/src/libs/pdflib/libs/pdflib/p_encoding.c b/src/libs/pdflib/libs/pdflib/p_encoding.c new file mode 100644 index 0000000000..c426d49ea3 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_encoding.c @@ -0,0 +1,945 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_encoding.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib encoding handling routines + * + */ + +#include "p_intern.h" +#include "p_font.h" + +#if defined(WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif /* WIN32 */ + + + +void +pdf__encoding_set_char(PDF *p, const char *encoding, int slot, + const char *glyphname, int uv) +{ + int enc; + pdc_encodingvector *ev; + char given; + + for (enc = (int) pdc_invalidenc + 1; enc < (int) pdc_firstvarenc; enc++) + { + if (!strcmp(encoding, pdc_get_fixed_encoding_name((pdc_encoding) enc))) + pdc_error(p->pdc, PDF_E_ENC_CANTCHANGE, encoding, 0, 0, 0); + } + + if (uv == 0) + { + given = 1; + uv = (int) pdf_insert_glyphname(p, glyphname); + } + else if (!glyphname || !*glyphname) + { + given = 0; + glyphname = pdf_insert_unicode(p, (pdc_ushort) uv); + } + else + { + const char *reg_glyphname; + pdc_ushort reg_uv; + + given = 1; + reg_glyphname = pdc_unicode2adobe((pdc_ushort) uv); + if (reg_glyphname) + { + if (strcmp(reg_glyphname, glyphname) && + p->debug['F'] == pdc_true) + { + pdc_warning(p->pdc, PDF_E_ENC_BADGLYPH, + glyphname, + pdc_errprintf(p->pdc, "0x%04X", uv), + reg_glyphname, 0); + } + + /* We take the registered name */ + } + else + { + reg_uv = pdc_adobe2unicode(glyphname); + if (reg_uv && reg_uv != (pdc_ushort) uv && + p->debug['F'] == pdc_true) + { + pdc_error(p->pdc, PDF_E_ENC_BADUNICODE, + pdc_errprintf(p->pdc, "0x%04X", uv), glyphname, + pdc_errprintf(p->pdc, "0x%04X", reg_uv), 0); + } + + /* We register the new unicode value */ + pdf_register_glyphname(p, glyphname, (pdc_ushort) uv); + } + } + + /* search for a registered encoding */ + enc = pdf_find_encoding(p, encoding); + if (enc >= p->encodings_capacity) + pdf_grow_encodings(p); + + if (enc == pdc_invalidenc) + { + enc = p->encodings_number; + p->encodings[enc].ev = pdc_new_encoding(p->pdc, encoding); + p->encodings[enc].ev->flags |= PDC_ENC_USER; + p->encodings[enc].ev->flags |= PDC_ENC_SETNAMES; + p->encodings[enc].ev->flags |= PDC_ENC_ALLOCCHARS; + p->encodings_number++; + } + else if (!(p->encodings[enc].ev->flags & PDC_ENC_USER)) + { + pdc_error(p->pdc, PDF_E_ENC_CANTCHANGE, encoding, 0, 0, 0); + } + else if (p->encodings[enc].ev->flags & PDC_ENC_USED) + { + pdc_error(p->pdc, PDF_E_ENC_INUSE, encoding, 0, 0, 0); + } + + /* Free character name */ + ev = p->encodings[enc].ev; + if (ev->chars[slot] != NULL) + pdc_free(p->pdc, ev->chars[slot]); + + /* Saving */ + ev->codes[slot] = (pdc_ushort) uv; + if (glyphname != NULL) + ev->chars[slot] = pdc_strdup(p->pdc, glyphname); + ev->given[slot] = given; +} + +PDFLIB_API void PDFLIB_CALL +PDF_encoding_set_char(PDF *p, const char *encoding, int slot, + const char *glyphname, int uv) +{ + static const char fn[] = "PDF_encoding_set_char"; + + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", %d, \"%s\", 0x%04X)\n", + (void *) p, encoding, slot, glyphname, uv)) + { + return; + } + + if (!encoding || !*encoding) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "encoding", 0, 0, 0); + + if (slot < 0 || slot > 255) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "slot", pdc_errprintf(p->pdc, "%d", slot), 0, 0); + + if (uv < 0 || uv > PDC_MAX_UNICODE) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "uv", pdc_errprintf(p->pdc, "%d", uv), 0, 0); + + if (!glyphname || !*glyphname) + { + if (uv == 0) + pdc_error(p->pdc, PDF_E_ENC_GLYPHORCODE, 0, 0, 0, 0); + } + + pdf__encoding_set_char(p, encoding, slot, glyphname, uv); +} + +PDFLIB_API const char * PDFLIB_CALL +PDF_encoding_get_glyphname(PDF *p, const char *encoding, int slot) +{ + static const char fn[] = "PDF_encoding_get_glyphname"; + const char *name = NULL; + pdc_encoding enc; + + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", 0x%04X)", (void *) p, encoding, slot)) + { + name = ".notdef"; + pdc_trace(p->pdc, "[%s]\n", name); + return name; + } + + /* search for a registered encoding */ + enc = pdf_find_encoding(p, encoding); + + /* Unicode, glyphid or 8-bit encoding */ + if (enc == pdc_unicode) + { + if (slot < 0 || slot > PDC_MAX_UNICODE) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "slot", pdc_errprintf(p->pdc, "%d", slot), 0, 0); + + name = pdf_unicode2glyphname(p, (pdc_ushort) slot); + } + else if (enc == pdc_glyphid) + { + int font = pdf_get_font(p); + if (font > -1) + { + if (slot < 0 || slot >= p->fonts[font].numOfCodes) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "slot", pdc_errprintf(p->pdc, "%d", slot), 0, 0); + + if (p->fonts[font].encoding != pdc_glyphid) + pdc_error(p->pdc, PDF_E_ENC_BADFONT, + pdc_errprintf(p->pdc, "%d", font), + pdf_get_encoding_name(p, enc), 0, 0); + + if (p->fonts[font].GID2Name) + name = (const char *) p->fonts[font].GID2Name[slot]; + else if (p->fonts[font].GID2code) + name = pdf_unicode2glyphname(p, + (pdc_ushort) p->fonts[font].GID2code[slot]); + } + } + else + { + if (slot < 0 || slot >= 256) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "slot", pdc_errprintf(p->pdc, "%d", slot), 0, 0); + + /* cid or builtin */ + if (enc < 0) + pdc_error(p->pdc, PDF_E_ENC_CANTQUERY, encoding, 0, 0, 0); + + if (enc >= p->encodings_number) + pdc_error(p->pdc, PDF_E_ENC_NOTFOUND, encoding, 0, 0, 0); + + pdf_set_encoding_glyphnames(p, enc); + + if (p->encodings[enc].ev->chars[slot]) + name = p->encodings[enc].ev->chars[slot]; + } + + if (!name) + name = ".notdef"; + pdc_trace(p->pdc, "[%s]\n", name); + return name; +} + +PDFLIB_API int PDFLIB_CALL +PDF_encoding_get_unicode(PDF *p, const char *encoding, int slot) +{ + static const char fn[] = "PDF_encoding_get_unicode"; + pdc_encoding enc; + int code = 0; + + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", 0x%04X)", (void *) p, encoding, slot)) + { + pdc_trace(p->pdc, "[%d]\n", code); + return code; + } + + /* search for a registered encoding */ + enc = pdf_find_encoding(p, encoding); + + /* Unicode, glyphid or 8-bit encoding */ + if (enc == pdc_unicode) + { + if (slot < 0 || slot > PDC_MAX_UNICODE) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "slot", pdc_errprintf(p->pdc, "%d", slot), 0, 0); + + code = slot; + } + else if (enc == pdc_glyphid) + { + int font = pdf_get_font(p); + if (font > -1 && p->fonts[font].GID2code) + { + if (slot < 0 || slot >= p->fonts[font].numOfCodes) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "slot", pdc_errprintf(p->pdc, "%d", slot), 0, 0); + + if (p->fonts[font].encoding != pdc_glyphid) + pdc_error(p->pdc, PDF_E_ENC_BADFONT, + pdc_errprintf(p->pdc, "%d", font), + pdf_get_encoding_name(p, enc), 0, 0); + + code = p->fonts[font].GID2code[slot]; + } + } + else + { + if (slot < 0 || slot > 255) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "slot", pdc_errprintf(p->pdc, "%d", slot), 0, 0); + + /* cid or builtin */ + if (enc < 0) + pdc_error(p->pdc, PDF_E_ENC_CANTQUERY, encoding, 0, 0, 0); + + if (enc >= p->encodings_number) + pdc_error(p->pdc, PDF_E_ENC_NOTFOUND, encoding, 0, 0, 0); + + code = (int) p->encodings[enc].ev->codes[slot]; + } + + pdc_trace(p->pdc, "[%d]\n", code); + return code; +} + + +/* + * Try to read an encoding from file. + * + * Return value: allocated encoding struct + * NULL: error + */ + +pdc_encodingvector * +pdf_read_encoding(PDF *p, const char *encoding, const char *filename) +{ + pdc_encodingvector *ev = NULL; + pdc_file *fp; + char **linelist; + char *line, glyphname[128]; + int slot, nlines = 0, l, i_uv; + pdc_ushort uv; + + enum state { + s_init, s_names, s_codes + } stat = s_init; + + if ((fp = pdf_fopen(p, filename, "encoding ", 0)) == NULL) + { + if (p->debug['F']) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + } + else + { + nlines = pdc_read_textfile(p->pdc, fp, &linelist); + pdc_fclose(fp); + } + if (!nlines) + return ev; + + ev = pdc_new_encoding(p->pdc, encoding); + if (ev == NULL) + return ev; + + for (l = 0; l < nlines; l++) + { + line = linelist[l]; + if (stat == s_init) + { + if (sscanf(line, "0x%x", &i_uv) == 1) + stat = s_codes; + else + stat = s_names; + } + + if (stat == s_names) + { + i_uv = 0; + if ((sscanf(line, "%s 0x%x 0x%x", glyphname, &slot, &i_uv) != 3 && + sscanf(line, "%s %d 0x%x", glyphname, &slot, &i_uv) != 3) || + slot < 0 || slot >= 256 || + i_uv < 0 || i_uv > PDC_MAX_UNICODE) + { + if ((sscanf(line, "%s 0x%x", glyphname, &slot) != 2 && + sscanf(line, "%s %d", glyphname, &slot) != 2) || + slot < 0 || slot >= 256) + { + const char *stemp = pdc_errprintf(p->pdc, "%s", line); + pdc_cleanup_encoding(p->pdc, ev); + pdc_cleanup_stringlist(p->pdc, linelist); + ev = NULL; + if (p->debug['F'] == pdc_true) + pdc_error(p->pdc, PDF_E_ENC_BADLINE, + filename, stemp, 0, 0); + else + return ev; + } + uv = pdf_insert_glyphname(p, glyphname); + } + else + { + uv = (pdc_ushort) i_uv; + } + + ev->codes[slot] = uv; + ev->chars[slot] = pdc_strdup(p->pdc, glyphname); + ev->given[slot] = 1; + } + else + { + /* stat == s_codes + */ + if ((sscanf(line, "0x%x 0x%x", &i_uv, &slot) != 2 && + sscanf(line, "0x%x %d", &i_uv, &slot) != 2) || + slot < 0 || slot >= 256 || + i_uv < 0 || i_uv > PDC_MAX_UNICODE) + { + const char *stemp = pdc_errprintf(p->pdc, "%s", line); + pdc_cleanup_encoding(p->pdc, ev); + pdc_cleanup_stringlist(p->pdc, linelist); + ev = NULL; + if (p->debug['F'] == pdc_true) + pdc_error(p->pdc, PDF_E_ENC_BADLINE, + filename, stemp, 0, 0); + else + return ev; + } + + uv = (pdc_ushort) i_uv; + ev->codes[slot] = uv; + ev->chars[slot] = (char *) pdf_insert_unicode(p, uv); + } + } + + ev->flags |= PDC_ENC_FILE; + ev->flags |= PDC_ENC_SETNAMES; + if (stat == s_names) + ev->flags |= PDC_ENC_ALLOCCHARS; + + pdc_cleanup_stringlist(p->pdc, linelist); + + return ev; +} + +/* + * Try to generate an encoding from an Unicode code page. + * + * Return value: allocated encoding struct + * NULL: error + */ + +pdc_encodingvector * +pdf_generate_encoding(PDF *p, const char *encoding) +{ + pdc_encodingvector *ev = NULL; + pdc_ushort uv; + int i_uv1, i_uv2, slot; + size_t len; + + /* first unicode offset */ + len = strlen(encoding); + if (len >= 6 && !strncmp(encoding, "U+", 2) && + sscanf(&encoding[2], "%x", &i_uv1) == 1) + { + if (i_uv1 < 0 || i_uv1 > PDC_MAX_UNICODE) + return ev; + + /* second unicode offset */ + i_uv2 = -1; + if (len >= 12) + { + char *se = strstr(&encoding[6], "U+"); + if (se && sscanf(&se[2], "%x", &i_uv2) == 1) + { + if (i_uv2 < 0 || i_uv2 > PDC_MAX_UNICODE) + return ev; + } + } + uv = (pdc_ushort) i_uv1; + ev = pdc_new_encoding(p->pdc, encoding); + if (ev != NULL) + { + for (slot = 0; slot < 256; slot++) + { + if (i_uv2 > -1 && slot == 128) + uv = (pdc_ushort) i_uv2; + ev->codes[slot] = uv; + ev->chars[slot] = (char *) pdf_insert_unicode(p, uv); + uv++; + } + ev->flags |= PDC_ENC_GENERATE; + ev->flags |= PDC_ENC_SETNAMES; + } + } + + return ev; +} + +static const char * +pdf_subst_encoding_name(PDF *p, const char *encoding, char *buffer) +{ + (void) p; + (void) buffer; + + /* special case for the platform-specific host encoding */ + if (!strcmp(encoding, "host") || !strcmp(encoding, "auto")) + { + +#if defined(PDFLIB_EBCDIC) + return "ebcdic"; + +#elif defined(MAC) + return "macroman"; + +#elif defined(WIN32) + UINT cpident = GetACP(); + if (!strcmp(encoding, "auto")) + { + if (cpident == 10000) + strcpy(buffer, "macroman"); + else if (cpident == 20924) + strcpy(buffer, "ebcdic"); + else if (cpident >= 28590 && cpident <= 28599) + sprintf(buffer, "iso8859-%d", cpident-28590); + else if (cpident >= 28600 && cpident <= 28609) + sprintf(buffer, "iso8859-%d", cpident-28600+10); + else if (cpident == 1200 || cpident == 1201) + strcpy(buffer, "unicode"); + else + { + CPINFO CPInfo ; + + if (GetCPInfo(cpident, (LPCPINFO) &CPInfo) && + CPInfo.MaxCharSize == 1) + { + sprintf(buffer, "cp%d", cpident); + } + else + { + pdc_error(p->pdc, PDF_E_ENC_UNSUPP, + pdc_errprintf(p->pdc, "%d", cpident), 0, 0, 0); + } + } + encoding = buffer; + } + else + { + return "winansi"; + } +#endif + } + + /* These encodings will be mapped to winansi */ + if (!strcmp(encoding, "host") || + !strcmp(encoding, "auto") || + !strcmp(encoding, "cp1252")) + return "winansi"; + + return encoding; +} + +pdc_encoding +pdf_insert_encoding(PDF *p, const char *encoding) +{ + char *filename; + char buffer[32]; + pdc_encodingvector *ev = NULL; + pdc_encoding enc = (pdc_encoding) p->encodings_number; + + /* substituting encoding name */ + encoding = pdf_subst_encoding_name(p, encoding, buffer); + + /* check for an user-defined encoding */ + filename = pdf_find_resource(p, "Encoding", encoding); + if (filename) + ev = pdf_read_encoding(p, encoding, filename); + if (ev == NULL) + { + /* check for a generate encoding */ + ev = pdf_generate_encoding(p, encoding); + if (ev == NULL) + { + { + pdc_set_errmsg(p->pdc, PDF_E_ENC_NOTFOUND, encoding, 0, 0, 0); + + if (p->debug['F']) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_invalidenc; + } + } + } + p->encodings[enc].ev = ev; + p->encodings_number++; + + return enc; +} + +pdc_encoding +pdf_find_encoding(PDF *p, const char *encoding) +{ + int slot; + char buffer[32]; + + /* substituting encoding name */ + encoding = pdf_subst_encoding_name(p, encoding, buffer); + + /* search for a fixed encoding */ + for (slot = (pdc_encoding) pdc_invalidenc + 1; + slot < (pdc_encoding) pdc_firstvarenc; slot++) + { + if (!strcmp(encoding, pdc_get_fixed_encoding_name((pdc_encoding) slot))) + { + /* copy in-core encoding at fixed slots */ + if (slot >= 0 && p->encodings[slot].ev == NULL) + p->encodings[slot].ev = pdc_copy_core_encoding(p->pdc, encoding); + return((pdc_encoding) slot); + } + } + + /* search for a user defined encoding */ + for (slot = (pdc_encoding) pdc_firstvarenc; + slot < p->encodings_number; slot++) + { + if (p->encodings[slot].ev->apiname != NULL && + !strcmp(encoding, p->encodings[slot].ev->apiname)) + return((pdc_encoding) slot); + } + + if (slot >= p->encodings_capacity) + pdf_grow_encodings(p); + + /* search for an in-core encoding */ + p->encodings[slot].ev = pdc_copy_core_encoding(p->pdc, encoding); + if (p->encodings[slot].ev != NULL) + { + p->encodings_number++; + return((pdc_encoding) slot); + } + + return (pdc_invalidenc); +} + +const char * +pdf_get_encoding_name(PDF *p, pdc_encoding enc) +{ + const char *apiname = pdc_get_fixed_encoding_name(enc); + if (!apiname[0] && enc >= 0) + apiname = (const char *) p->encodings[enc].ev->apiname; + return apiname; +} + +void +pdf_set_encoding_glyphnames(PDF *p, pdc_encoding enc) +{ + pdc_encodingvector *ev = p->encodings[enc].ev; + int slot; + pdc_ushort uv; + + if (!(ev->flags & PDC_ENC_SETNAMES)) + { + ev->flags |= PDC_ENC_SETNAMES; + for (slot = 0; slot < 256; slot++) + { + uv = ev->codes[slot]; + ev->chars[slot] = (char *)pdf_unicode2glyphname(p, uv); + } + } +} + +pdc_bool +pdf_get_encoding_isstdflag(PDF *p, pdc_encoding enc) +{ + pdc_encodingvector *ev = p->encodings[enc].ev; + int slot; + pdc_bool isstd = pdc_true; + + if (!(ev->flags & PDC_ENC_INCORE) && !(ev->flags & PDC_ENC_STDNAMES)) + { + for (slot = 0; slot < 256; slot++) + { + if (!(ev->flags & PDC_ENC_SETNAMES)) + ev->chars[slot] = + (char *) pdf_unicode2glyphname(p, ev->codes[slot]); + if (isstd == pdc_true && ev->chars[slot]) + { + isstd = pdc_is_std_charname((char *) ev->chars[slot]); + if (isstd == pdc_false && (ev->flags & PDC_ENC_SETNAMES)) + break; + } + } + ev->flags |= PDC_ENC_SETNAMES; + if (isstd == pdc_true) + ev->flags |= PDC_ENC_STDNAMES; + } + + return (ev->flags & PDC_ENC_STDNAMES) ? pdc_true : pdc_false; +} + +pdc_ushort +pdf_glyphname2unicode(PDF *p, const char *glyphname) +{ + int lo, hi; + + /* Private glyph name table available */ + if (p->glyph_tab_size) + { + /* Searching for private glyph name */ + lo = 0; + hi = p->glyph_tab_size; + while (lo < hi) + { + int i = (lo + hi) / 2; + int cmp = strcmp(glyphname, p->name2unicode[i].glyphname); + + if (cmp == 0) + return p->name2unicode[i].code; + + if (cmp < 0) + hi = i; + else + lo = i + 1; + } + } + + /* Searching for glyph name in AGL */ + return pdc_adobe2unicode(glyphname); +} + +pdc_ushort +pdf_register_glyphname(PDF *p, const char *glyphname, pdc_ushort uv) +{ + static const char fn[] = "pdf_register_glyphname"; + char buf[16]; + int slot, slotname, slotuv; + + if (!glyphname) + return 0; + + /* Allocate private glyphname tables */ + if (!p->glyph_tab_capacity) + { + p->next_unicode = (pdc_ushort) 0xE000; /* Begin PUA */ + p->glyph_tab_size = 0; + p->glyph_tab_capacity = PRIVGLYPHS_CHUNKSIZE; + p->unicode2name = (pdc_glyph_tab *) pdc_malloc(p->pdc, + sizeof(pdc_glyph_tab) * p->glyph_tab_capacity, fn); + p->name2unicode = (pdc_glyph_tab *) pdc_malloc(p->pdc, + sizeof(pdc_glyph_tab) * p->glyph_tab_capacity, fn); + } + + /* Re-allocate private glyphname tables */ + if (p->glyph_tab_size == p->glyph_tab_capacity) + { + int n = p->glyph_tab_capacity + PRIVGLYPHS_CHUNKSIZE; + p->unicode2name = (pdc_glyph_tab *) pdc_realloc(p->pdc, + p->unicode2name, n * sizeof(pdc_glyph_tab), fn); + p->name2unicode = (pdc_glyph_tab *) pdc_realloc(p->pdc, + p->name2unicode, n * sizeof(pdc_glyph_tab), fn); + p->glyph_tab_capacity = n; + } + + /* Set reasonable glyph name "unixxxx" */ + if (!glyphname) + { + sprintf(buf, "uni%04X", uv); + glyphname = buf; + } + + /* Find slot so that new glyphname is sorted in to name table */ + for (slot = 0; slot < p->glyph_tab_size; slot++) + { + if (strcmp(glyphname, p->name2unicode[slot].glyphname) < 0) + break; + } + slotname = slot; + if (slot < p->glyph_tab_size) + { + for (slot = p->glyph_tab_size; slot > slotname; slot--) + { + p->name2unicode[slot].code = p->name2unicode[slot-1].code; + p->name2unicode[slot].glyphname = + p->name2unicode[slot-1].glyphname; + } + } + + /* Set reasonable unicode value in the case of "unixxxx" glyph names */ + if (!uv) + { + if (!strncmp(glyphname, "uni", 3)) + { + int i; + if (sscanf(glyphname, "uni%x", &i) == 1) + uv = (pdc_ushort) i; + } + if (!uv) + uv = p->next_unicode; + } + + if (uv >= p->next_unicode) + { + slotuv = p->glyph_tab_size; + p->next_unicode = (pdc_ushort) (uv + 1); + } + else + { + /* Find slot so that new unicode is sorted in to unicode table */ + for (slot = 0; slot < p->glyph_tab_size; slot++) + { + if (uv < p->unicode2name[slot].code) + break; + } + slotuv = slot; + if (slot < p->glyph_tab_size) + { + for (slot = p->glyph_tab_size; slot > slotuv; slot--) + { + p->unicode2name[slot].code = p->unicode2name[slot-1].code; + p->unicode2name[slot].glyphname = + p->unicode2name[slot-1].glyphname; + } + } + } + + p->name2unicode[slotname].code = uv; + p->name2unicode[slotname].glyphname = pdc_strdup(p->pdc, glyphname); + p->unicode2name[slotuv].code = uv; + p->unicode2name[slotuv].glyphname = p->name2unicode[slotname].glyphname; + + p->glyph_tab_size += 1; + + return uv; +} + +pdc_ushort +pdf_insert_glyphname(PDF *p, const char *glyphname) +{ + pdc_ushort uv; + + uv = pdf_glyphname2unicode(p, glyphname); + if (!uv) + uv = pdf_register_glyphname(p, glyphname, 0); + return uv; +} + +const char * +pdf_insert_unicode(PDF *p, pdc_ushort uv) +{ + const char *glyphname; + + glyphname = pdf_unicode2glyphname(p, uv); + if (!glyphname) + { + pdf_register_glyphname(p, NULL, uv); + glyphname = pdf_unicode2glyphname(p, uv); + } + return glyphname; +} + +const char * +pdf_unicode2glyphname(PDF *p, pdc_ushort uv) +{ + int lo, hi; + + /* Private unicode table available */ + if (p->glyph_tab_size) + { + /* Searching for private Unicode */ + lo = 0; + hi = p->glyph_tab_size; + while (lo < hi) + { + int i = (lo + hi) / 2; + + if (uv == p->unicode2name[i].code) + return p->unicode2name[i].glyphname; + + if (uv < p->unicode2name[i].code) + hi = i; + else + lo = i + 1; + } + } + + /* Searching for unicode value in AGL */ + return pdc_unicode2adobe(uv); +} + +void +pdf_init_encoding_ids(PDF *p) +{ + int slot; + + for (slot = 0; slot < p->encodings_capacity; slot++) + { + p->encodings[slot].id = PDC_BAD_ID; + p->encodings[slot].tounicode_id = PDC_BAD_ID; + } +} + +void +pdf_init_encodings(PDF *p) +{ + static const char fn[] = "pdf_init_encodings"; + int slot; + + p->encodings_capacity = ENCODINGS_CHUNKSIZE; + + p->encodings = (pdf_encoding *) pdc_malloc(p->pdc, + sizeof(pdf_encoding) * p->encodings_capacity, fn); + + for (slot = 0; slot < p->encodings_capacity; slot++) + p->encodings[slot].ev = NULL; + + /* we must reserve the first 4 slots for standard encodings, because + * the program identify their by index of p->encodings array! + */ + p->encodings_number = 4; + + /* init private glyphname tables */ + p->unicode2name = NULL; + p->name2unicode = NULL; + p->glyph_tab_capacity = 0; +} + +void +pdf_grow_encodings(PDF *p) +{ + static const char fn[] = "pdf_grow_encodings"; + int slot; + + p->encodings = (pdf_encoding *) pdc_realloc(p->pdc, p->encodings, + sizeof(pdf_encoding) * 2 * p->encodings_capacity, fn); + + p->encodings_capacity *= 2; + for (slot = p->encodings_number; slot < p->encodings_capacity; slot++) + { + p->encodings[slot].ev = NULL; + p->encodings[slot].id = PDC_BAD_ID; + p->encodings[slot].tounicode_id = PDC_BAD_ID; + } +} + +void +pdf_cleanup_encodings(PDF *p) +{ + int slot; + + if (!p->encodings) + return; + + for (slot = 0; slot < p->encodings_number; slot++) + { + if (p->encodings[slot].ev) + pdc_cleanup_encoding(p->pdc, p->encodings[slot].ev); + } + + if (p->encodings) + pdc_free(p->pdc, p->encodings); + p->encodings = NULL; + + /* clean up private glyphname tables */ + if (p->unicode2name) + { + for (slot = 0; slot < p->glyph_tab_size; slot++) + pdc_free(p->pdc, (char *)p->unicode2name[slot].glyphname); + + if (p->unicode2name) + pdc_free(p->pdc, p->unicode2name); + p->unicode2name = NULL; + } + + if (p->name2unicode) + pdc_free(p->pdc, p->name2unicode); + p->name2unicode = NULL; + p->glyph_tab_capacity = 0; +} + diff --git a/src/libs/pdflib/libs/pdflib/p_filter.c b/src/libs/pdflib/libs/pdflib/p_filter.c new file mode 100644 index 0000000000..bbe84fbc77 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_filter.c @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_filter.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * ASCII85 and Hex encoding for PDFlib + * + */ + +#include "p_intern.h" + +void +pdf_ASCIIHexEncode(PDF *p, PDF_data_source *src) +{ + static const char BinToHex[] = PDF_STRING_0123456789ABCDEF; + int CharsPerLine; + size_t i; + pdc_byte *data; + + CharsPerLine = 0; + + if (src->init) + src->init(p, src); + + while (src->fill(p, src)) + { + for (data=src->next_byte, i=src->bytes_available; i > 0; i--, data++) + { + pdc_putc(p->out, BinToHex[*data>>4]); /* first nibble */ + pdc_putc(p->out, BinToHex[*data & 0x0F]); /* second nibble */ + if ((CharsPerLine += 2) >= 64) { + pdc_putc(p->out, PDF_NEWLINE); + CharsPerLine = 0; + } + } + } + + if (src->terminate) + src->terminate(p, src); + + pdc_puts(p->out, ">\n"); /* EOD marker for PDF hex strings */ +} + +/* methods for constructing a data source from a file */ + +#define FILE_BUFSIZE 1024 + +void +pdf_data_source_file_init(PDF *p, PDF_data_source *src) +{ + pdc_file *fp; + + src->buffer_length = FILE_BUFSIZE; + src->buffer_start = (pdc_byte *) + pdc_malloc(p->pdc, src->buffer_length, "pdf_data_source_file_init"); + + fp = pdf_fopen(p, (const char *) src->private_data, "embedded ", + PDC_FILE_BINARY); + + if (fp == NULL) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + if (src->offset) + pdc_fseek(fp, src->offset, SEEK_SET); + + src->private_data = (void *) fp; + src->total = (long) 0; +} + +pdc_bool +pdf_data_source_file_fill(PDF *p, PDF_data_source *src) +{ + size_t bytes_needed; + (void) p; /* avoid compiler warning "unreferenced parameter" */ + + if (src->length != (long) 0 && src->total + FILE_BUFSIZE > src->length) + bytes_needed = (size_t) (src->length - src->total); + else + bytes_needed = FILE_BUFSIZE; + + src->next_byte = src->buffer_start; + src->bytes_available = pdc_fread(src->buffer_start, 1, + bytes_needed, (pdc_file *) (src->private_data)); + + src->total += (long) src->bytes_available; + + if (src->bytes_available == 0) + return pdc_false; + else + return pdc_true; +} + +void +pdf_data_source_file_terminate(PDF *p, PDF_data_source *src) +{ + pdc_free(p->pdc, (void *) src->buffer_start); + pdc_fclose((pdc_file *) src->private_data); + + if (src->length != (long) 0 && src->total != src->length) + pdc_error(p->pdc, PDC_E_IO_NODATA, "?", 0, 0, 0); +} + +/* methods for constructing a data source from a memory buffer */ + +int +pdf_data_source_buf_fill(PDF *p, PDF_data_source *src) +{ + (void) p; /* avoid compiler warning "unreferenced parameter" */ + + if (src->next_byte == NULL) { + src->next_byte = src->buffer_start; + src->bytes_available = src->buffer_length; + return pdc_true; + } + + return pdc_false; +} + +/* copy the complete contents of src to a stream */ +void +pdf_copy_stream(PDF *p, PDF_data_source *src, pdc_bool compress) +{ + int oldcompresslevel = pdc_get_compresslevel(p->out); + + if (!compress) + pdc_set_compresslevel(p->out, 0); + + if (src->init) + src->init(p, src); + + pdc_begin_pdfstream(p->out); + + while (src->fill(p, src)) + pdc_write(p->out, src->next_byte, src->bytes_available); + + pdc_end_pdfstream(p->out); + + if (src->terminate) + src->terminate(p, src); + + if (!compress) + pdc_set_compresslevel(p->out, oldcompresslevel); +} diff --git a/src/libs/pdflib/libs/pdflib/p_font.c b/src/libs/pdflib/libs/pdflib/p_font.c new file mode 100644 index 0000000000..78e20571d0 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_font.c @@ -0,0 +1,1516 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_font.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib font handling routines + * + */ + +#define P_FONT_C + +#include "p_intern.h" +#include "p_font.h" +#include "p_truetype.h" + + +static const pdc_keyconn pdf_extension_names[] = +{ + {".ttf", 1}, + {".otf", 1}, + {".afm", 2}, + {".pfm", 3}, + {".ttc", 1}, + {".TTF", 1}, + {".OTF", 1}, + {".AFM", 2}, + {".PFM", 3}, + {".TTC", 1}, + {".pfa", 4}, + {".pfb", 4}, + {".PFA", 4}, + {".PFB", 4}, + {NULL, 0} +}; + +static const pdc_keyconn pdf_fontstyle_pdfkeys[] = +{ + {"Normal", pdc_Normal}, + {"Bold", pdc_Bold}, + {"Italic", pdc_Italic}, + {"BoldItalic", pdc_BoldItalic}, + {NULL, 0} +}; + +const char * +pdf_get_fontname(PDF *p) +{ + if (p->fonts_number == 0 || p->tstate[p->sl].f == -1) /* no font set */ + pdc_error(p->pdc, PDF_E_TEXT_NOFONT_PAR, "fontname", 0, 0, 0); + + return p->fonts[p->tstate[p->sl].f].name; +} + +const char * +pdf_get_fontstyle(PDF *p) +{ + if (p->fonts_number == 0 || p->tstate[p->sl].f == -1) /* no font set */ + pdc_error(p->pdc, PDF_E_TEXT_NOFONT_PAR, "fontstyle", 0, 0, 0); + + return pdc_get_keyword(p->fonts[p->tstate[p->sl].f].style, + pdf_fontstyle_keylist); +} + +const char * +pdf_get_fontencoding(PDF *p) +{ + pdc_font *font; + const char *ret; + + if (p->fonts_number == 0 || p->tstate[p->sl].f == -1) /* no font set */ + pdc_error(p->pdc, PDF_E_TEXT_NOFONT_PAR, "fontencoding", 0, 0, 0); + + font = &p->fonts[p->tstate[p->sl].f]; + switch (font->encoding) + { + case pdc_cid: + ret = (const char *) font->cmapname; + break; + + default: + ret = pdf_get_encoding_name(p, font->encoding); + } + + return ret; +} + +int +pdf_get_monospace(PDF *p) +{ + if (p->fonts_number == 0 || p->tstate[p->sl].f == -1) /* no font set */ + pdc_error(p->pdc, PDF_E_TEXT_NOFONT_PAR, "fontstyle", 0, 0, 0); + + return p->fonts[p->tstate[p->sl].f].monospace; +} + +int +pdf_get_font(PDF *p) +{ + if (p->fonts_number == 0 || p->tstate[p->sl].f == -1) /* no font set */ + pdc_error(p->pdc, PDF_E_TEXT_NOFONT_PAR, "font", 0, 0, 0); + + return p->tstate[p->sl].f; +} + +static void +pdf_cleanup_font(PDF *p, pdc_font *font) +{ + if (font->imgname) + pdf_unlock_pvf(p, font->imgname); + pdc_cleanup_font_struct(p->pdc, font); +} + +void +pdf_cleanup_fonts(PDF *p) +{ + int slot; + + if (p->fonts) + { + for (slot = 0; slot < p->fonts_number; slot++) + pdf_cleanup_font(p, &p->fonts[slot]); + + if (p->fonts) + pdc_free(p->pdc, p->fonts); + p->fonts = NULL; + } +} + +void +pdf_init_fonts(PDF *p) +{ + p->fonts_number = 0; + p->fonts_capacity = FONTS_CHUNKSIZE; + + p->fonts = (pdc_font *) pdc_calloc(p->pdc, + sizeof(pdc_font) * p->fonts_capacity, "pdf_init_fonts"); + + p->t3font = (pdc_t3font *) NULL; + + pdf_init_encoding_ids(p); +} + +void +pdf_grow_fonts(PDF *p) +{ + p->fonts = (pdc_font *) pdc_realloc(p->pdc, p->fonts, + sizeof(pdc_font) * 2 * p->fonts_capacity, "pdf_grow_fonts"); + + p->fonts_capacity *= 2; +} + +int +pdf_init_newfont(PDF *p) +{ + pdc_font *font; + int slot; + + /* slot for font struct */ + slot = p->fonts_number; + if (slot >= p->fonts_capacity) + pdf_grow_fonts(p); + + /* initialize font struct */ + font = &p->fonts[slot]; + pdc_init_font_struct(p->pdc, font); + + /* inherite global settings */ + font->verbose = p->debug['F']; + font->verbose_open = font->verbose; + + return slot; +} + +static pdc_bool +pdf_get_metrics_core(PDF *p, pdc_font *font, const char *fontname, + pdc_encoding enc) +{ + const pdc_core_metric *metric; + + metric = pdc_get_core_metric(fontname); + if (metric != NULL) + { + /* Fill up the font struct */ + pdc_fill_font_metric(p->pdc, font, metric); + font->encoding = enc; + + /* Process metric data */ + if (pdf_process_metrics_data(p, font, fontname)) + { + if (!pdf_make_fontflag(p, font)) + return pdc_false; + + if (font->monospace) + { + pdc_set_errmsg(p->pdc, PDC_E_OPT_IGNORED, "monospace", 0, 0, 0); + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + return pdc_false; + } + return pdc_true; + } + } + return pdc_undef; +} + +pdc_bool +pdf_make_fontflag(PDF *p, pdc_font *font) +{ + (void) p; + + if (font->type != pdc_Type3) + { + if (font->isFixedPitch) + font->flags |= FIXEDWIDTH; + + if (font->isstdlatin == pdc_true || + font->encoding == pdc_winansi || + font->encoding == pdc_macroman || + font->encoding == pdc_ebcdic) + font->flags |= ADOBESTANDARD; + else + font->flags |= SYMBOL; + + if (font->italicAngle < 0 || + font->style == pdc_Italic || font->style == pdc_BoldItalic) + font->flags |= ITALIC; + if (font->italicAngle == 0 && font->flags & ITALIC) + font->italicAngle = PDC_DEF_ITALICANGLE; + + /* heuristic to identify (small) caps fonts */ + if (font->name && + (strstr(font->name, "Caps") || + !strcmp(font->name + strlen(font->name) - 2, "SC"))) + font->flags |= SMALLCAPS; + + if (font->style == pdc_Bold || font->style == pdc_BoldItalic) + font->StdVW = PDF_STEMV_BOLD; + + if (strstr(font->name, "Bold") || font->StdVW > PDF_STEMV_SEMIBOLD) + font->flags |= FORCEBOLD; + } + + if (font->style != pdc_Normal && + (font->embedding || font->type == pdc_Type1 || + font->type == pdc_MMType1 || font->type == pdc_Type3)) + { + pdc_set_errmsg(p->pdc, PDC_E_OPT_IGNORED, "fontstyle", 0, 0, 0); + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + return pdc_false; + } + return pdc_true; +} + +#define PDF_KERNING_FLAG PDC_OPT_UNSUPP + +#define PDF_SUBSETTING_FLAG PDC_OPT_UNSUPP +#define PDF_AUTOSUBSETT_FLAG PDC_OPT_UNSUPP + +#define PDF_AUTOCIDFONT_FLAG PDC_OPT_UNSUPP + +/* definitions of image options */ +static const pdc_defopt pdf_load_font_options[] = +{ + {"fontwarning", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + {"embedding", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + {"kerning", pdc_booleanlist, PDF_KERNING_FLAG, 1, 1, 0.0, 0.0, NULL}, + + {"subsetting", pdc_booleanlist, PDF_SUBSETTING_FLAG, 1, 1, 0.0, 0.0, + NULL}, + + {"autosubsetting", pdc_booleanlist, PDF_AUTOSUBSETT_FLAG, 1, 1, 0.0, 0.0, + NULL}, + + {"subsetlimit", pdc_floatlist, PDF_SUBSETTING_FLAG, 1, 1, 0.0, 100.0, + NULL}, + + {"subsetminsize", pdc_floatlist, PDF_SUBSETTING_FLAG, 1, 1, + 0.0, PDC_FLOAT_MAX, NULL}, + + {"autocidfont", pdc_booleanlist, PDF_AUTOCIDFONT_FLAG, 1, 1, 0.0, 0.0, + NULL}, + + {"unicodemap", pdc_booleanlist, PDF_AUTOCIDFONT_FLAG, 1, 1, 0.0, 0.0, + NULL}, + + {"fontstyle", pdc_keywordlist, 0, 1, 1, 0.0, 0.0, + pdf_fontstyle_keylist}, + + {"monospace", pdc_integerlist, 0, 1, 1, 1.0, 2048.0, + NULL}, + + PDC_OPT_TERMINATE +}; + +int +pdf__load_font(PDF *p, const char *fontname, int inlen, + const char *encoding, const char *optlist) +{ + static const char fn[] = "pdf__load_font"; + pdc_resopt *results; + pdc_encoding enc = pdc_invalidenc; + pdc_bool fontwarning; + pdc_bool kret; + int slot = -1; + size_t len; + int i; + int retval, inum; + pdc_font *font; + const char *extension = NULL; + char *fontname_p = NULL; + char *outfilename = NULL; + char *filename = NULL, testfilename[PDF_MAX_FONTNAME + 5]; + char *mmparam, mastername[PDF_MAX_FONTNAME + 1]; + + if (encoding == NULL || *encoding == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "encoding", 0, 0, 0); + + if (fontname == NULL) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "fontname", 0, 0, 0); + + /* Converting fontname to UTF-8 */ + if (inlen) + { + pdc_byte *utf8fontname; + pdc_text_format textformat = pdc_bytes2; + pdc_text_format targettextformat = pdc_utf8; + int outlen; + + if (pdc_convert_string(p->pdc, textformat, NULL, + (pdc_byte *) fontname, inlen, + &targettextformat, NULL, + &utf8fontname, &outlen, + PDC_CONV_WITHBOM | PDC_CONV_TRY7BYTES, + p->debug['F'])) + { + if (p->debug['F']) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + return -1; + } + + fontname = pdc_errprintf(p->pdc, "%s", utf8fontname); + pdc_free(p->pdc, utf8fontname); + } + + if (*fontname == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "fontname", 0, 0, 0); + + /* slot for new font struct */ + slot = pdf_init_newfont(p); + font = &p->fonts[slot]; + + /* parsing optlist */ + font->verbose = p->debug['F']; + if (optlist && strlen(optlist)) + { + results = pdc_parse_optionlist(p->pdc, optlist, pdf_load_font_options, + NULL, font->verbose); + if (!results) + return -1; + + /* save and check options */ + pdc_get_optvalues(p->pdc, "fontwarning", results, + &font->verbose, NULL); + + pdc_get_optvalues(p->pdc, "embedding", results, + &font->embedding, NULL); + + + + + if (pdc_get_optvalues(p->pdc, "fontstyle", results, &inum, NULL)) + font->style = (pdc_fontstyle) inum; + + pdc_get_optvalues(p->pdc, "monospace", results, + &font->monospace, NULL); + + pdc_cleanup_optionlist(p->pdc, results); + } + + /* search for a registered encoding */ + slot = -1; + kret = pdc_false; + fontwarning = p->debug['F']; + p->debug['F'] = (char) font->verbose; + enc = pdf_find_encoding(p, encoding); + + if (enc == pdc_unicode || enc == pdc_glyphid) + pdc_error(p->pdc, PDF_E_UNSUPP_UNICODE, 0, 0, 0, 0); + + if (enc == pdc_invalidenc) + { + /* check the known CMap names */ + slot = pdf_handle_cidfont(p, fontname, encoding); + if (slot == -1) + { + /* look for a new encoding */ + enc = pdf_insert_encoding(p, encoding); + if (enc == pdc_invalidenc) + kret = pdc_true; + } + else + { + kret = pdc_true; + if (slot == -2) /* error occurred in pdf_handle_cidfont() */ + slot = -1; + } + } + p->debug['F'] = (char) fontwarning; + if (kret) + return slot; + + /* + * Look whether font is already in the cache. + * If a font with same encoding and same relevant options is found, + * return its descriptor. + * If a Type 3 font with the same name but different encoding + * is found, make a copy in a new slot and attach the requested encoding. + */ + + for (slot = 0; slot < p->fonts_number; slot++) + { + if (!strcmp(p->fonts[slot].apiname, fontname) && + p->fonts[slot].style == font->style) + { + if (p->fonts[slot].type == pdc_Type3) + { + if (enc < 0 ) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_BADENC, + p->fonts[slot].name, + pdf_get_encoding_name(p, enc), 0, 0); + + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; + } + if (p->fonts[slot].encoding != enc) + slot = pdf_handle_t3font(p, fontname, enc, slot); + + return slot; + } + else if (p->fonts[slot].monospace == font->monospace) + { + if (p->fonts[slot].encoding == enc) + { + return slot; + } + else if (p->fonts[slot].encoding >= 0) + { + char *encname, *adaptname; + int kc; + + /* Comparing apiname of encoding */ + if (!strcmp(encoding, p->fonts[slot].encapiname)) + return slot; + + /* Name of adapted to font encoding */ + encname = (char *) pdf_get_encoding_name(p, enc); + len = strlen(encname) + 1 + strlen(fontname) + 1; + adaptname = (char *) pdc_malloc(p->pdc, len, fn); + strcpy(adaptname, encname); + strcat(adaptname, PDC_ENC_MODSEPAR); + strcat(adaptname, fontname); + kc = strcmp(adaptname, + pdf_get_encoding_name(p, p->fonts[slot].encoding)); + pdc_free(p->pdc, adaptname); + if (!kc) + return slot; + } + } + } + } + + + /* Multiple Master handling: + * - strip MM parameters to build the master name + * - the master name is used to find the metrics + * - the instance name (client-supplied font name) is used in all places + * - although the master name is used for finding the metrics, the + * instance name is stored in the font struct. + */ + + len = strlen(fontname); + if (len > PDF_MAX_FONTNAME) + { + pdc_set_errmsg(p->pdc, PDC_E_ILLARG_TOOLONG, "fontname", + pdc_errprintf(p->pdc, "%d", PDF_MAX_FONTNAME), 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; + } + strcpy(mastername, fontname); + + /* A Multiple Master font was requested */ + if ((mmparam = strstr(mastername, "MM_")) != NULL) + { + if (font->embedding) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_EMBEDMM, fontname, 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; + } + mmparam[2] = '\0'; /* strip the parameter from the master name */ + } + + /* Font with vertical writing mode */ + fontname_p = mastername; + if (mastername[0] == '@') + { + font->vertical = pdc_true; + fontname_p = &mastername[1]; + } + + /* API font name */ + font->apiname = pdc_strdup(p->pdc, fontname); + + /* Font file search hierarchy + * - Check "FontOutline" resource entry and check TrueType font + * - Check "FontAFM" resource entry + * - Check "FontPFM" resource entry + * - Check "HostFont" resource entry + * - Check available in-core metrics + * - Check host font + */ + retval = pdc_false; + while (1) + { +#ifdef PDF_TRUETYPE_SUPPORTED + /* Check specified TrueType file */ + filename = pdf_find_resource(p, "FontOutline", fontname_p); + if (filename) { + outfilename = filename; + retval = pdf_check_tt_font(p, filename, fontname_p, font); + if (retval == pdc_undef) { + retval = pdc_false; + break; + } + if (retval == pdc_true) { + retval = pdf_get_metrics_tt(p, font, fontname_p, enc, filename); + break; + } + } +#endif /* PDF_TRUETYPE_SUPPORTED */ + + /* Check specified AFM file */ + filename = pdf_find_resource(p, "FontAFM", fontname_p); + if (filename) { + retval = pdf_get_metrics_afm(p, font, fontname_p, enc, filename); + break; + } + + /* Check specified PFM file */ + filename = pdf_find_resource(p, "FontPFM", fontname_p); + if (filename) { + retval = pdf_get_metrics_pfm(p, font, fontname_p, enc, filename); + break; + } + + + + /* Check available in-core metrics */ + retval = pdf_get_metrics_core(p, font, fontname_p, enc); + if (retval != pdc_undef) break; + retval = pdc_false; + + + /* Search for a metric file */ + font->verbose_open = pdc_false; + filename = testfilename; + for (i = 0; i < 100; i++) + { + extension = pdf_extension_names[i].word; + if (!extension) break; + strcpy(testfilename, fontname_p); + strcat(testfilename, extension); + switch (pdf_extension_names[i].code) + { + case 1: + if (pdf_check_tt_font(p, filename, fontname_p, font) == + pdc_true) + retval = pdf_get_metrics_tt(p, font, fontname_p, enc, + filename); + break; + + case 2: + retval = pdf_get_metrics_afm(p, font, fontname_p, enc, + filename); + break; + + case 3: + retval = pdf_get_metrics_pfm(p, font, fontname_p, enc, + filename); + break; + } + if (retval == pdc_true) + { + if (pdf_extension_names[i].code == 1) + outfilename = filename; + break; + } + } + + if (retval == pdc_false) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_NOMETRICS, fontname, 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + } + break; + } + + if (retval == pdc_false) { + pdf_cleanup_font(p, font); + return -1; + } + + /* store instance name instead of master name in the font structure */ + if (mmparam) { + pdc_free(p->pdc, font->name); + font->name = pdc_strdup(p->pdc, fontname); + } + + /* If embedding was requested, check font file (or raise an exception) */ + font->verbose_open = font->verbose; + if (font->embedding) { + if (font->img == NULL) { + pdc_file *fp = NULL; + if (outfilename) { + if ((fp = pdf_fopen(p, outfilename, "font ", 0)) == NULL) + { + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + retval = pdc_false; + } + if ((font->type == pdc_Type1 || font->type == pdc_MMType1) && + (pdf_t1check_fontfile(p, font, fp) == pdc_undef)) { + pdc_fclose(fp); + retval = pdc_false; + } + } else { + outfilename = testfilename; + for (i = 0; i < 100; i++) { + extension = pdf_extension_names[i].word; + if (!extension) break; + strcpy(testfilename, fontname_p); + strcat(testfilename, extension); + if (pdf_extension_names[i].code == 4 && + (fp = pdf_fopen(p, outfilename, NULL, 0)) != NULL) { + if (pdf_t1check_fontfile(p, font, fp) != pdc_undef) + break; + pdc_fclose(fp); + fp = NULL; + } + } + if (fp == NULL) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_NOOUTLINE, fontname, + 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + retval = pdc_false; + } + } + if (retval == pdc_true) { + if (pdc_file_isvirtual(fp) == pdc_true) { + font->imgname = pdc_strdup(p->pdc, outfilename); + pdf_lock_pvf(p, font->imgname); + } + pdc_fclose(fp); + font->fontfilename = pdc_strdup(p->pdc, outfilename); + } + } + } else if (font->img) { + if (!font->imgname) { + pdc_free(p->pdc, font->img); + } else { + pdf_unlock_pvf(p, font->imgname); + pdc_free(p->pdc, font->imgname); + font->imgname = NULL; + } + font->img = NULL; + font->filelen = 0; + } + + if (retval && font->monospace && font->embedding) + { + pdc_set_errmsg(p->pdc, PDC_E_OPT_IGNORED, "monospace", 0, 0, 0); + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + retval = pdc_false; + } + + if (retval == pdc_false) { + pdf_cleanup_font(p, font); + return -1; + } + + /* Now everything is fine; fill the remaining font cache entries */ + + p->fonts_number++; + + font->verbose_open = pdc_true; + + font->encapiname = pdc_strdup(p->pdc, encoding); + + if (enc >= 0) + p->encodings[enc].ev->flags |= PDC_ENC_USED; + + font->obj_id = pdc_alloc_id(p->out); + + return slot; +} + +PDFLIB_API int PDFLIB_CALL +PDF_load_font(PDF *p, const char *fontname, int len, + const char *encoding, const char *optlist) +{ + static const char fn[] = "PDF_load_font"; + int slot = -1; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_content), + "(p[%p], \"%s\", %d, \"%s\", \"%s\")", + (void *) p, pdc_strprint(p->pdc, fontname, len), len, encoding,optlist)) + { + slot = pdf__load_font(p, fontname, len, encoding, optlist); + } + + PDF_RETURN_HANDLE(p, slot) +} + +PDFLIB_API int PDFLIB_CALL +PDF_findfont(PDF *p, const char *fontname, const char *encoding, int embed) +{ + static const char fn[] = "PDF_findfont"; + char optlist[256]; + int slot = -1; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_content), + "(p[%p], \"%s\", \"%s\", %d)", (void *) p, fontname, encoding, embed)) + { + PDF_RETURN_HANDLE(p, slot) + } + + if (embed < 0 || embed > 1) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "embed", pdc_errprintf(p->pdc, "%d", embed), 0, 0); + + optlist[0] = 0; + if (embed) + strcat(optlist, "embedding true "); + + slot = pdf__load_font(p, fontname, 0, encoding, (const char *) optlist); + + PDF_RETURN_HANDLE(p, slot) +} + +PDFLIB_API int PDFLIB_CALL +PDF_get_glyphid(PDF *p, int font, int code) +{ + static const char fn[] = "PDF_get_glyphid"; + int gid = 0; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_content | pdf_state_path), + "(p[%p], %d, %04X)", (void *) p, font, code)) + { + pdc_trace(p->pdc, "[%d]\n", gid); + return gid; + } + + PDF_INPUT_HANDLE(p, font) + if (font < 0 || font >= p->fonts_number) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "font", pdc_errprintf(p->pdc, "%d", font), 0, 0); + + if (code < 0 || code >= p->fonts[font].numOfCodes) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "code", pdc_errprintf(p->pdc, "%d", code), 0, 0); + + if (p->fonts[font].code2GID) + gid = p->fonts[font].code2GID[code]; + else + pdc_error(p->pdc, PDF_E_FONT_NOGLYPHID, p->fonts[font].apiname, 0, 0,0); + + pdc_trace(p->pdc, "[%d]\n", gid); + return gid; +} + + +static void +pdf_write_fontdescriptor( + PDF *p, + pdc_font *font, + pdc_id fontdescriptor_id, + pdc_id fontfile_id) +{ + /* + * Font descriptor object + */ + pdc_begin_obj(p->out, fontdescriptor_id); /* font descriptor obj */ + pdc_begin_dict(p->out); /* font descriptor dict */ + + pdc_puts(p->out, "/Type/FontDescriptor\n"); + pdc_printf(p->out, "/Ascent %d\n", font->ascender); + pdc_printf(p->out, "/CapHeight %d\n", font->capHeight); + pdc_printf(p->out, "/Descent %d\n", font->descender); + pdc_printf(p->out, "/Flags %ld\n", font->flags); + pdc_printf(p->out, "/FontBBox[%d %d %d %d]\n", + (int) font->llx, (int) font->lly, (int) font->urx, (int) font->ury); + + pdc_printf(p->out, "/FontName"); + pdc_put_pdfname(p->out, font->name, strlen(font->name)); + pdc_puts(p->out, "\n"); + + pdc_printf(p->out, "/ItalicAngle %d\n", (int) (font->italicAngle)); + pdc_printf(p->out, "/StemV %d\n", font->StdVW); + + if (font->StdHW > 0) + pdc_printf(p->out, "/StemH %d\n", font->StdHW); + + if (font->xHeight > 0) + pdc_printf(p->out, "/XHeight %d\n", font->xHeight); + + if (fontfile_id != PDC_BAD_ID) + { + switch(font->type) + { + case pdc_Type1: + case pdc_MMType1: + pdc_printf(p->out, "/FontFile %ld 0 R\n", fontfile_id); + break; + +#ifdef PDF_TRUETYPE_SUPPORTED + case pdc_TrueType: + case pdc_CIDFontType2: + pdc_printf(p->out, "/FontFile2 %ld 0 R\n", fontfile_id); + break; + + case pdc_Type1C: + case pdc_CIDFontType0: + pdc_printf(p->out, "/FontFile3 %ld 0 R\n", fontfile_id); + break; +#endif /* PDF_TRUETYPE_SUPPORTED */ + + default: + break; + } + } + + pdc_end_dict(p->out); /* font descriptor dict */ + pdc_end_obj(p->out); /* font descriptor obj */ +} + +static void +pdf_put_font(PDF *p, pdc_font *font) +{ + const char *fontname = font->name; + pdc_id fontdescriptor_id = PDC_BAD_ID; + pdc_id fontfile_id = PDC_BAD_ID; + pdc_id encoding_id = PDC_BAD_ID; + const char *Adobe_str = "\101\144\157\142\145"; + pdc_id descendant_id = PDC_BAD_ID; + pdc_encoding enc = font->encoding; + pdc_bool base_font = pdc_false; + pdc_bool comp_font = pdc_false; + float a = (float) 1.0; + PDF_data_source src; + int slot, i, j; + + /* + * This Type3 font has been defined, but never used. Ignore it. + * However, the font's object id has already been allocated. + * Write a dummy object in order to avoid a complaint + * of the object machinery. + */ + if (enc == pdc_invalidenc) + { + pdc_begin_obj(p->out, font->obj_id); /* dummy font obj */ + pdc_printf(p->out, "null %% unused Type 3 font '%s'\n", + font->apiname); + pdc_end_obj(p->out); + return; + } + + + /* ID for embedded font */ + if (font->embedding) + { + switch(font->type) + { + case pdc_Type1: + case pdc_MMType1: + case pdc_TrueType: + case pdc_CIDFontType2: + case pdc_Type1C: + case pdc_CIDFontType0: + fontfile_id = pdc_alloc_id(p->out); + break; + + default: + break; + } + } + else if (font->type == pdc_Type1) + { + const char *basename; + + /* check whether we have one of the base 14 fonts */ + for (slot = 0; ; slot++) + { + basename = pdc_get_base14_name(slot); + if (basename == NULL) + break; + if (!strcmp(basename, fontname)) + { + base_font = pdc_true; + break; + } + } + } + + /* + * Font dictionary + */ + pdc_begin_obj(p->out, font->obj_id); /* font obj */ + pdc_begin_dict(p->out); /* font dict */ + pdc_puts(p->out, "/Type/Font\n"); + + /* /Subtype */ + switch (font->type) + { + case pdc_Type1: + pdc_puts(p->out, "/Subtype/Type1\n"); + break; + + case pdc_MMType1: + pdc_puts(p->out, "/Subtype/MMType1\n"); + break; + + case pdc_TrueType: + pdc_puts(p->out, "/Subtype/TrueType\n"); + fontname = font->ttname; + break; + + case pdc_Type1C: + fontname = font->ttname; + pdc_puts(p->out, "/Subtype/Type1\n"); + break; + + case pdc_CIDFontType2: + case pdc_CIDFontType0: + fontname = font->ttname; + pdc_puts(p->out, "/Subtype/Type0\n"); + comp_font = pdc_true; + break; + + case pdc_Type3: + pdc_puts(p->out, "/Subtype/Type3\n"); + break; + } + + /* /Name */ + if (font->type == pdc_Type3) + { + /* + * The name is optional, but if we include it it will show up + * in Acrobat's font info box. However, if the same font name + * is used with different encodings Acrobat 4 will not be + * able to distinguish both. For this reason we add the + * encoding name to make the font name unique. + */ + pdc_puts(p->out, "/Name"); + pdc_put_pdfname(p->out, fontname, strlen(fontname)); + pdc_puts(p->out, "\n"); + } + + /* /BaseFont */ + switch (font->type) + { + case pdc_Type1: + case pdc_MMType1: + case pdc_TrueType: + case pdc_Type1C: + case pdc_CIDFontType2: + case pdc_CIDFontType0: + { + pdc_puts(p->out, "/BaseFont"); + pdc_put_pdfname(p->out, fontname, strlen(fontname)); + if (font->cmapname) + pdc_printf(p->out, "-%s", font->cmapname); + if (font->style != pdc_Normal && !comp_font) + pdc_printf(p->out, ",%s", + pdc_get_keyword(font->style, pdf_fontstyle_pdfkeys)); + pdc_puts(p->out, "\n"); + } + break; + + /* /FontBBox, /FontMatrix, /CharProcs /Resources */ + case pdc_Type3: + pdc_printf(p->out, "/FontBBox[%f %f %f %f]\n", + font->t3font->bbox.llx, font->t3font->bbox.lly, + font->t3font->bbox.urx, font->t3font->bbox.ury); + + pdc_printf(p->out, "/FontMatrix[%f %f %f %f %f %f]\n", + font->t3font->matrix.a, font->t3font->matrix.b, + font->t3font->matrix.c, font->t3font->matrix.d, + font->t3font->matrix.e, font->t3font->matrix.f); + pdc_printf(p->out, "/CharProcs %ld 0 R\n", font->t3font->charprocs_id); + pdc_printf(p->out, "/Resources %ld 0 R\n", font->t3font->res_id); + + /* We must apply a correctional factor since Type 3 fonts not + * necessarily use 1000 units per em. We apply the correction + * here, and store the 1000-based width values in the font in + * order to speed up PDF_stringwidth(). + */ + a = (float) 1000 * font->t3font->matrix.a; + break; + } + + /* /FontDescriptor, /FirstChar, /LastChar, /Widths */ + switch (font->type) + { + case pdc_Type1: + if (base_font == pdc_true) break; + case pdc_MMType1: + case pdc_TrueType: + case pdc_Type1C: + { + fontdescriptor_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/FontDescriptor %ld 0 R\n", fontdescriptor_id); + } + case pdc_Type3: + { + + pdc_puts(p->out, "/FirstChar 0\n"); + pdc_puts(p->out, "/LastChar 255\n"); + + pdc_puts(p->out, "/Widths[\n"); + for (i = 0; i < 16; i++) + { + for (j = 0; j < 16; j++) + pdc_printf(p->out, " %d", + (int) ((font->widths[16*i + j]) / a + 0.5)); + pdc_puts(p->out, "\n"); + } + pdc_puts(p->out, "]\n"); + } + break; + + default: + break; + } + + /* /Encoding */ + switch (font->type) + { + case pdc_Type1: + case pdc_MMType1: + case pdc_TrueType: + case pdc_Type1C: + if (enc == pdc_winansi) + { + pdc_printf(p->out, "/Encoding/WinAnsiEncoding\n"); + break; + } + if (enc == pdc_macroman && font->hasnomac == pdc_false) + { + pdc_printf(p->out, "/Encoding/MacRomanEncoding\n"); + break; + } + case pdc_Type3: + if (enc >= 0) + { + if (p->encodings[enc].id == PDC_BAD_ID) + p->encodings[enc].id = pdc_alloc_id(p->out); + encoding_id = p->encodings[enc].id; + } + if (encoding_id != PDC_BAD_ID) + pdc_printf(p->out, "/Encoding %ld 0 R\n", encoding_id); + break; + + case pdc_CIDFontType2: + case pdc_CIDFontType0: + if (font->cmapname) + pdc_printf(p->out, "/Encoding/%s\n", font->cmapname); + break; + } + + + /* /DescendantFonts */ + if (comp_font == pdc_true) + { + descendant_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/DescendantFonts[%ld 0 R]\n", descendant_id); + } + + pdc_end_dict(p->out); /* font dict */ + pdc_end_obj(p->out); /* font obj */ + + /* + * Encoding dictionary + */ + if (encoding_id != PDC_BAD_ID) + { + char *charname; + + pdc_begin_obj(p->out, encoding_id); /* encoding obj */ + pdc_begin_dict(p->out); /* encoding dict */ + + pdc_puts(p->out, "/Type/Encoding\n"); + + { + pdc_encodingvector *ev = p->encodings[enc].ev; + pdc_encodingvector *evb = NULL; + int islatin1 = + !strncmp((const char *) ev->apiname, "iso8859-1", + strlen("iso8859-1")); + + pdf_set_encoding_glyphnames(p, enc); + + if (!strncmp(ev->apiname, PDC_ENC_MODWINANSI, + strlen(PDC_ENC_MODWINANSI)) + || islatin1) + { + pdc_puts(p->out, "/BaseEncoding/WinAnsiEncoding\n"); + evb = p->encodings[pdc_winansi].ev; + if (!evb) + p->encodings[pdc_winansi].ev = + pdc_copy_core_encoding(p->pdc, "winansi"); + } + if (!strncmp(ev->apiname, PDC_ENC_MODMACROMAN, + strlen(PDC_ENC_MODMACROMAN))) + { + pdc_puts(p->out, "/BaseEncoding/MacRomanEncoding\n"); + evb = p->encodings[pdc_macroman].ev; + if (!evb) + p->encodings[pdc_macroman].ev = + pdc_copy_core_encoding(p->pdc, "macroman"); + } + + if (evb && font->type != pdc_Type3) + { + int iv = -1; + for (i = 0; i < font->numOfCodes; i++) + { + if ((ev->chars[i] && !evb->chars[i]) || + (!ev->chars[i] && evb->chars[i]) || + (ev->chars[i] && evb->chars[i] && + strcmp(ev->chars[i], evb->chars[i]))) + { + if (iv == -1) + pdc_puts(p->out, "/Differences["); + if (i > iv + 1) + pdc_printf(p->out, "%d", i); + charname = (char *) + ev->chars[i] ? ev->chars[i] : (char *) ".notdef"; + pdc_put_pdfname(p->out, charname, strlen(charname)); + pdc_puts(p->out, "\n"); + iv = i; + } + } + if (iv > -1) + pdc_puts(p->out, "]\n"); + } + else + { + pdc_puts(p->out, "/Differences[0"); + for (i = 0; i < font->numOfCodes; i++) + { + charname = (char *) ev->chars[i] ? + ev->chars[i] : (char *) ".notdef"; + pdc_put_pdfname(p->out, charname, strlen(charname)); + pdc_puts(p->out, "\n"); + } + pdc_puts(p->out, "]\n"); + } + } + + pdc_end_dict(p->out); /* encoding dict */ + pdc_end_obj(p->out); /* encoding obj */ + + if (p->flush & pdf_flush_content) + pdc_flush_stream(p->out); + } + + + /* + * CID fonts dictionary + */ + if (descendant_id != PDC_BAD_ID) + { + const char *tmpstr; + + pdc_begin_obj(p->out, descendant_id); /* CID font obj */ + pdc_begin_dict(p->out); /* CID font dict */ + pdc_puts(p->out, "/Type/Font\n"); + + /* /Subtype */ + if (font->type == pdc_CIDFontType0) + pdc_puts(p->out, "/Subtype/CIDFontType0\n"); + if (font->type == pdc_CIDFontType2) + pdc_puts(p->out, "/Subtype/CIDFontType2\n"); + + /* /BaseFont */ + pdc_puts(p->out, "/BaseFont"); + pdc_put_pdfname(p->out, fontname, strlen(fontname)); + if (font->style != pdc_Normal) + pdc_printf(p->out, ",%s", + pdc_get_keyword(font->style, pdf_fontstyle_pdfkeys)); + pdc_puts(p->out, "\n"); + + /* /CIDSystemInfo */ + tmpstr = pdf_get_ordering_cid(p, font); + pdc_puts(p->out, "/CIDSystemInfo<out, Adobe_str, (int) strlen(Adobe_str)); + pdc_puts(p->out, "/Ordering"); + pdc_put_pdfstring(p->out, tmpstr, (int) strlen(tmpstr)); + pdc_printf(p->out, "/Supplement %d>>\n", + pdf_get_supplement_cid(p, font)); + + /* /FontDescriptor */ + fontdescriptor_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/FontDescriptor %ld 0 R\n", fontdescriptor_id); + + /* /DW /W */ +#ifdef PDF_CJKFONTWIDTHS_SUPPORTED + if (enc == pdc_cid) + pdf_put_cidglyph_widths(p, font); +#endif /* PDF_CJKFONTWIDTHS_SUPPORTED */ + + + pdc_end_dict(p->out); /* CID font dict */ + pdc_end_obj(p->out); /* CID font obj */ + } + + /* + * FontDescriptor dictionary + */ + if (fontdescriptor_id != PDC_BAD_ID) + pdf_write_fontdescriptor(p, font, fontdescriptor_id, fontfile_id); + + /* + * Font embedding + */ + if (fontfile_id != PDC_BAD_ID) + { + pdc_id length_id = PDC_BAD_ID; + pdc_id length1_id = PDC_BAD_ID; + pdc_id length2_id = PDC_BAD_ID; + pdc_id length3_id = PDC_BAD_ID; + pdc_bool hexencode = pdc_false; + pdc_bool compress = pdc_false; + + /* Prepare embedding */ + switch(font->type) + { + case pdc_Type1: + case pdc_MMType1: + { + pdf_make_t1src(p, font, &src); + length1_id = pdc_alloc_id(p->out); + length2_id = pdc_alloc_id(p->out); + length3_id = pdc_alloc_id(p->out); + } + break; + +#ifdef PDF_TRUETYPE_SUPPORTED + case pdc_TrueType: + case pdc_CIDFontType2: + { + length1_id = pdc_alloc_id(p->out); + } + case pdc_Type1C: + case pdc_CIDFontType0: + { + src.private_data = (void *) font->fontfilename; + if (font->fontfilename) + { + /* Read the font from file */ + src.init = pdf_data_source_file_init; + src.fill = pdf_data_source_file_fill; + src.terminate = pdf_data_source_file_terminate; + switch(font->type) + { + case pdc_TrueType: + case pdc_CIDFontType2: + src.offset = (long) 0; + src.length = (long) 0; + break; + + case pdc_Type1C: + case pdc_CIDFontType0: + src.offset = font->cff_offset; + src.length = (long) font->cff_length; + break; + + default: + break; + } + } + else + { + /* Read the font from memory */ + src.init = NULL; + src.fill = pdf_data_source_buf_fill; + src.terminate = NULL; + switch(font->type) + { + case pdc_TrueType: + case pdc_CIDFontType2: + src.buffer_start = font->img; + src.buffer_length = font->filelen; + break; + + case pdc_Type1C: + case pdc_CIDFontType0: + src.buffer_start = font->img + font->cff_offset; + src.buffer_length = font->cff_length; + break; + + default: + break; + } + src.bytes_available = 0; + src.next_byte = NULL; + } + } + break; +#endif /* PDF_TRUETYPE_SUPPORTED */ + + default: + break; + } + + /* Embedded font stream dictionary */ + pdc_begin_obj(p->out, fontfile_id); /* Embedded font stream obj */ + pdc_begin_dict(p->out); /* Embedded font stream dict */ + + /* /Length, /Filter */ + length_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/Length %ld 0 R\n", length_id); + switch(font->type) + { + case pdc_Type1: + case pdc_MMType1: + if (p->debug['a']) + { + hexencode = pdc_true; + pdc_puts(p->out, "/Filter/ASCIIHexDecode\n"); + } + break; + +#ifdef PDF_TRUETYPE_SUPPORTED + case pdc_TrueType: + case pdc_CIDFontType2: + case pdc_Type1C: + case pdc_CIDFontType0: + if (font->filelen != 0L) + { + compress = pdc_true; + if (pdc_get_compresslevel(p->out)) + pdc_puts(p->out, "/Filter/FlateDecode\n"); + } + break; +#endif /* PDF_TRUETYPE_SUPPORTED */ + + default: + break; + } + + /* /Length1, /Length2, Length3 */ + if (length1_id != PDC_BAD_ID) + pdc_printf(p->out, "/Length1 %ld 0 R\n", length1_id); + if (length2_id != PDC_BAD_ID) + pdc_printf(p->out, "/Length2 %ld 0 R\n", length2_id); + if (length3_id != PDC_BAD_ID) + pdc_printf(p->out, "/Length3 %ld 0 R\n", length3_id); + +#ifdef PDF_TRUETYPE_SUPPORTED + /* /Subtype */ + if(font->type == pdc_Type1C) + pdc_puts(p->out, "/Subtype/Type1C\n"); + if (font->type == pdc_CIDFontType0) + pdc_puts(p->out, "/Subtype/CIDFontType0C\n"); +#endif /* PDF_TRUETYPE_SUPPORTED */ + + pdc_end_dict(p->out); /* Embedded font stream dict */ + + /* Stream */ + if (hexencode == pdc_true) + pdf_ASCIIHexEncode(p, &src); + else + pdf_copy_stream(p, &src, compress); + + pdc_end_obj(p->out); /* Embedded font stream obj */ + + pdc_put_pdfstreamlength(p->out, length_id); + + /* Length objects */ + switch(font->type) + { + case pdc_Type1: + case pdc_MMType1: + pdf_put_length_objs(p, &src, length1_id, length2_id, length3_id); + break; + +#ifdef PDF_TRUETYPE_SUPPORTED + case pdc_TrueType: + case pdc_CIDFontType2: + if (compress) + { + pdc_begin_obj(p->out, length1_id); /* Length1 obj */ + pdc_printf(p->out, "%ld\n", (long) font->filelen); + pdc_end_obj(p->out); /* Length1 obj */ + } + else + { + /* same as /Length */ + pdc_put_pdfstreamlength(p->out, length1_id); + } + break; +#endif /* PDF_TRUETYPE_SUPPORTED */ + + default: + break; + } + } + + if (p->flush & pdf_flush_content) + pdc_flush_stream(p->out); +} + +void +pdf_write_doc_fonts(PDF *p) +{ + int slot; + + /* output pending font objects */ + for (slot = 0; slot < p->fonts_number; slot++) + { + switch(p->fonts[slot].type) + { + case pdc_Type1: + case pdc_MMType1: +#ifdef PDF_TRUETYPE_SUPPORTED + case pdc_TrueType: + case pdc_CIDFontType2: + case pdc_Type1C: +#endif /* PDF_TRUETYPE_SUPPORTED */ + case pdc_CIDFontType0: + case pdc_Type3: + pdf_put_font(p, &p->fonts[slot]); + break; + + default: + break; + } + } +} + +void +pdf_write_page_fonts(PDF *p) +{ + int i, total = 0; + + /* This doesn't really belong here, but all modules which write + * font resources also need this, so we include it here. + * Note that keeping track of ProcSets is considered obsolete + * starting with PDF 1.4, so we always include the full set. + */ + + pdc_puts(p->out, "/ProcSet[/PDF/ImageB/ImageC/ImageI/Text]\n"); + + for (i = 0; i < p->fonts_number; i++) + if (p->fonts[i].used_on_current_page == pdc_true) + total++; + + if (total > 0) + { + pdc_puts(p->out, "/Font"); + + pdc_begin_dict(p->out); /* font resource dict */ + + for (i = 0; i < p->fonts_number; i++) + if (p->fonts[i].used_on_current_page == pdc_true) { + p->fonts[i].used_on_current_page = pdc_false; /* reset */ + pdc_printf(p->out, "/F%d %ld 0 R\n", i, p->fonts[i].obj_id); + } + + pdc_end_dict(p->out); /* font resource dict */ + } +} diff --git a/src/libs/pdflib/libs/pdflib/p_font.h b/src/libs/pdflib/libs/pdflib/p_font.h new file mode 100644 index 0000000000..9380a8b3f6 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_font.h @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_font.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * Header file for the PDFlib font subsystem + * + */ + +#ifndef P_FONT_H +#define P_FONT_H + +#define PDF_DEFAULT_WIDTH 250 /* some reasonable default */ +#define PDF_DEFAULT_CIDWIDTH 1000 /* for CID fonts */ +#define PDF_DEFAULT_GLYPH 0x0020 /* space */ + +/* internal maximal length of fontnames */ +#define PDF_MAX_FONTNAME 128 + +/* last text rendering mode number */ +#define PDF_LAST_TRMODE 7 + +/* p_truetype.c */ +pdc_bool pdf_get_metrics_tt(PDF *p, pdc_font *font, + const char *fontname, pdc_encoding enc, + const char *filename); +int pdf_check_tt_font(PDF *p, const char *filename, + const char *fontname, pdc_font *font); +int pdf_check_tt_hostfont(PDF *p, const char *hostname); + +/* p_afm.c */ +pdc_bool pdf_process_metrics_data(PDF *p, pdc_font *font, + const char *fontname); +pdc_bool pdf_get_metrics_afm(PDF *p, pdc_font *font, + const char *fontname, pdc_encoding enc, + const char *filename); +pdc_bool pdf_get_core_metrics_afm(PDF *p, pdc_font *font, + pdc_core_metric *metric, const char *fontname, + const char *filename); + +/* p_pfm.c */ +pdc_bool pdf_check_pfm_encoding(PDF *p, pdc_font *font, + const char *fontname, pdc_encoding enc); +pdc_bool pdf_get_metrics_pfm(PDF *p, pdc_font *font, + const char *fontname, pdc_encoding enc, + const char *filename); + +/* p_cid.c */ +pdc_bool pdf_get_metrics_cid(PDF *p, pdc_font *font, + const char *fontname, + const char *encoding); +int pdf_handle_cidfont(PDF *p, const char *fontname, + const char *encoding); +const char* pdf_get_ordering_cid(PDF *p, pdc_font *font); +int pdf_get_supplement_cid(PDF *p, pdc_font *font); +void pdf_put_cidglyph_widths(PDF *p, pdc_font *font); + + +/* p_font.c */ +void pdf_init_fonts(PDF *p); +void pdf_grow_fonts(PDF *p); +int pdf_init_newfont(PDF *p); +void pdf_write_page_fonts(PDF *p); +void pdf_write_doc_fonts(PDF *p); +void pdf_cleanup_fonts(PDF *p); +int pdf__load_font(PDF *p, const char *fontname, int reserved, + const char *encoding, const char *optlist); +pdc_bool pdf_make_fontflag(PDF *p, pdc_font *font); +int pdf_get_font(PDF *p); +int pdf_get_monospace(PDF *p); +const char *pdf_get_fontname(PDF *p); +const char *pdf_get_fontstyle(PDF *p); +const char *pdf_get_fontencoding(PDF *p); + + +/* p_type1.c */ +int pdf_t1check_fontfile(PDF *p, pdc_font *font, pdc_file *fp); +PDF_data_source *pdf_make_t1src(PDF *p, pdc_font *font, + PDF_data_source *t1src); +void pdf_put_length_objs(PDF *p, PDF_data_source *t1src, + pdc_id length1_id, pdc_id length2_id, pdc_id length3_id); + +/* p_type3.c */ +void pdf_init_type3(PDF *p); +int pdf_get_t3colorized(PDF *p); +int pdf_handle_t3font(PDF *p, const char *fontname, pdc_encoding enc, + int oldslot); +void pdf__begin_font(PDF *p, const char *fontname, + float a, float b, float c, float d, float e, float f, + const char *optlist); +void pdf__end_font(PDF *p); +void pdf__begin_glyph(PDF *p, const char *glyphname, float wx, + float llx, float lly, float urx, float ury); +void pdf__end_glyph(PDF *p); + +#endif /* P_FONT_H */ diff --git a/src/libs/pdflib/libs/pdflib/p_generr.h b/src/libs/pdflib/libs/pdflib/p_generr.h new file mode 100644 index 0000000000..7006393eee --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_generr.h @@ -0,0 +1,402 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_generr.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib error messages + * + */ + +#if pdf_genNames +#define gen(n, num, nam, msg) PDF_E_##nam = num, +#elif pdf_genInfo +#define gen(n, num, nam, msg) { n, num, msg, (const char *) 0 }, + +#else +#error invalid inclusion of generator file +#endif + + +/* -------------------------------------------------------------------- */ +/* Configuration (20xx) */ +/* -------------------------------------------------------------------- */ + +gen(0, 2000, UNSUPP_CRYPT, "Encryption not supported in this configuration") + +gen(0, 2002, UNSUPP_KERNING, "Kerning not supported in this configuration") + +gen(0, 2004, UNSUPP_SUBSET, "Subsetting not supported in this configuration") + +gen(0, 2006, UNSUPP_PDFX, "PDF/X not supported in this configuration") + +gen(1, 2008, UNSUPP_IMAGE, "$1 images not supported in this configuration") + +gen(0, 2010, UNSUPP_ICC, "ICC profiles not supported in this configuration") + +gen(0, 2012, UNSUPP_UNICODE, + "Unicode and glyph id addressing not supported in this configuration") + +gen(0, 2014, UNSUPP_SPOTCOLOR, + "Spot colors not supported in this configuration") + +gen(0, 2016, UNSUPP_PDI, "PDF import (PDI) not supported in this configuration") + +gen(0, 2018, UNSUPP_BLOCK, + "Personalization with blocks not supported in this configuration") + + +/* -------------------------------------------------------------------- */ +/* Document, page, scoping and resource (21xx) */ +/* -------------------------------------------------------------------- */ + +gen(1, 2100, DOC_SCOPE, "Function must not be called in '$1' scope") + +gen(1, 2102, DOC_FUNCUNSUPP, "Function not supported for '$1'") + +gen(2, 2104, DOC_PDFVERSION, "$1 is not supported in PDF $2") + +gen(0, 2106, DOC_EMPTY, "Generated document doesn't contain any pages") + +gen(0, 2110, PAGE_SIZE_ACRO4, "Page size incompatible with Acrobat 4") + +gen(2, 2112, PAGE_BADBOX, "Illegal $1 [$2]") + +gen(0, 2114, PAGE_ILLCHGSIZE, + "Page size cannot be changed in top-down coordinate system") + +gen(2, 2120, RES_BADRES, "Bad resource specification '$1' for category '$2'") + +gen(2, 2122, DOC_SCOPE_GET, "Can't get parameter '$1' in '$2' scope") + +gen(2, 2124, DOC_SCOPE_SET, "Can't set parameter '$1' in '$2' scope") + + +/* -------------------------------------------------------------------- */ +/* Graphics and Text (22xx) */ +/* -------------------------------------------------------------------- */ + +gen(0, 2200, GSTATE_UNMATCHEDSAVE, "Unmatched save level") + +gen(0, 2202, GSTATE_RESTORE, "Invalid restore (no matching save level") + +gen(1, 2204, GSTATE_SAVELEVEL, "Too many save levels (max. $1)") + +/* Currently unused */ +gen(0, 2210, PATTERN_SELF, "Can't use a pattern within its own definition") + +gen(0, 2212, SHADING13, "Smooth shadings are not supported in PDF 1.3") + +gen(1, 2220, TEMPLATE_SELF, + "Can't place template handle $1 within its own definition") + +gen(1, 2230, TEXT_UNICODENOTSHOW, + "Can't show text character with Unicode value $1") + +gen(1, 2232, TEXT_GLYPHIDNOTSHOW, "Can't show text character with glyph ID $1") + +gen(1, 2234, TEXT_TOOLONG, "Text too long (max. $1)") + +gen(0, 2236, TEXT_TOOMANYCODES, "Too many different unicode values (> 256)") + +gen(0, 2238, TEXT_NOFONT, "No font set for text") + +gen(1, 2240, TEXT_NOFONT_PAR, "No font set for parameter '$1'") + + + +/* -------------------------------------------------------------------- */ +/* Color (23xx) */ +/* -------------------------------------------------------------------- */ + +gen(0, 2300, COLOR_SPOT, +"Spot color can not be based on a Pattern, Indexed, or Separation color space") + +gen(2, 2302, COLOR_BADSPOT, "Color name '$1' not found in $2 table") + +gen(0, 2304, COLOR_SPOTBW, "Alternate color for spot color is black or white") + +gen(1, 2306, COLOR_UNLIC_SPOTCOLOR, "$1 spot colors not licensed") + + + +/* -------------------------------------------------------------------- */ +/* Image (24xx) */ +/* -------------------------------------------------------------------- */ + +gen(2, 2400, IMAGE_CORRUPT, "Corrupt $1 image file '$2'") + +gen(3, 2402, IMAGE_NOPAGE, "Requested page $1 in $2 image '$3' not found") + +gen(2, 2404, IMAGE_BADDEPTH, + "Bad number of bits per pixel ($1) in image file '$2'") + +gen(1, 2406, IMAGE_BADMASK, + "Image '$1' not suitable as mask (has more than one color component)") + +gen(1, 2408, IMAGE_MASK1BIT13, + "Image '$1' with more than 1 bit is not supported as mask in PDF 1.3") + +gen(1, 2410, IMAGE_COLORMAP, "Couldn't read colormap in image '$1'") + +gen(2, 2412, IMAGE_BADCOMP, + "Bad number of color components ($1) in image '$2'") + +gen(1, 2414, IMAGE_COLORIZE, + "Can't colorize image '$1' with more than 1 component") + +gen(1, 2416, IMAGE_ICC, "Couldn't handle embedded ICC profile in image '$1'") + +gen(1, 2418, IMAGE_ICC2, + "ICC profile for image file '$1' doesn't match image data") + +gen(0, 2420, IMAGE_THUMB, "More than one thumbnail for this page") + +gen(1, 2422, IMAGE_THUMB_MULTISTRIP, + "Can't use multi-strip image $1 as thumbnail") + +gen(1, 2424, IMAGE_THUMB_CS, + "Unsupported color space in thumbnail image handle $1") + +gen(2, 2426, IMAGE_THUMB_SIZE, "Thumbnail image $1 larger than $2 pixels") + +gen(2, 2428, IMAGE_OPTUNSUPP, + "Option '$1' for $2 images will be ignored (not supported)") + +gen(2, 2430, IMAGE_OPTUNREAS, "Option '$1' for $2 images will be ignored") + +gen(2, 2432, IMAGE_OPTBADMASK, "Option '$1' has bad image mask $2") + +gen(1, 2434, IMAGE_UNKNOWN, "Unknown image type in file '$1'") + +gen(0, 2436, IMAGE_NOADJUST, + "Option 'adjustpage' must not be used in top-down system") + +gen(2, 2440, RAW_ILLSIZE, + "Size ($1 bytes) of raw image file '$2' doesn't match specified options") + +gen(1, 2444, BMP_VERSUNSUPP, + "Version of BMP image file '$1' not supported") + +gen(1, 2446, BMP_COMPUNSUPP, + "Compression in BMP image file '$1' not supported") + +gen(2, 2450, JPEG_COMPRESSION, + "JPEG compression scheme '$1' in file '$2' not supported in PDF") + +gen(1, 2452, JPEG_MULTISCAN, + "JPEG file '$1' contains multiple scans, which is not supported in PDF") + +gen(1, 2460, GIF_LZWOVERFLOW, "LZW code size overflow in GIF file '$1'") + +gen(1, 2462, GIF_LZWSIZE, + "Color palette in GIF file '$1' with fewer than 128 colors not supported") + +gen(1, 2464, GIF_INTERLACED, "Interlaced GIF image '$1' not supported") + +gen(2, 2470, TIFF_UNSUPP_CS, + "Couldn't open TIFF image '$1' (unsupported color space; photometric $2)") + +gen(2, 2472, TIFF_UNSUPP_PREDICT, + "Couldn't open TIFF image '$1' (unsupported predictor tag $2)") + +gen(1, 2474, TIFF_UNSUPP_LZW_TILED, + "Couldn't open TIFF image '$1' (tiled image with LZW compression)") + +gen(1, 2476, TIFF_UNSUPP_LZW_PLANES, + "Couldn't open TIFF image '$1' (separate planes with LZW compression)") + +gen(1, 2478, TIFF_UNSUPP_LZW_ALPHA, + "Couldn't open TIFF image '$1' (alpha channel with LZW compression)") + +gen(2, 2480, TIFF_UNSUPP_JPEG, + "Couldn't open TIFF image '$1' (JPEG compression scheme $2)") + +gen(1, 2482, TIFF_UNSUPP_JPEG_TILED, + "Couldn't open TIFF image '$1' (tiled image with JPEG compression)") + +gen(1, 2484, TIFF_UNSUPP_JPEG_ALPHA, + "Couldn't open TIFF image '$1' (alpha channel with JPEG compression)") + +gen(2, 2486, TIFF_UNSUPP_SEP_NONCMYK, + "Couldn't open TIFF image '$1' (unsupported inkset tag $2)") + +gen(1, 2488, TIFF_MASK_MULTISTRIP, "Can't mask multistrip TIFF image '$1'") + +gen(1, 2490, TIFF_MULTISTRIP_MASK, + "Can't use multistrip TIFF image '$1' as mask") + + +/* -------------------------------------------------------------------- */ +/* Font (25xx) */ +/* -------------------------------------------------------------------- */ + +gen(2, 2500, FONT_CORRUPT, "Corrupt $1 font file '$2'") + +gen(2, 2502, FONT_BADENC, "Font '$1' doesn't support '$2' encoding") + +gen(3, 2504, FONT_FORCEENC, "Using '$1' encoding instead of '$2' for font '$3'") + +gen(2, 2505, FONT_NEEDUCS2, + "Font '$2' requires UCS2-compatible CMap instead of '$1'") + +gen(2, 2506, FONT_FORCEEMBED, "Encoding '$1' for font '$2' requires embedding") + +gen(1, 2508, FONT_BADTEXTFORM, + "Current text format not allowed for builtin encoding") + +gen(1, 2510, FONT_HOSTNOTFOUND, "Host font '$1' not found") + +gen(1, 2512, FONT_TTHOSTNOTFOUND, "TrueType host font '$1' not found") + +gen(1, 2514, FONT_EMBEDMM, "Multiple Master font '$1' cannot be embedded") + +gen(1, 2516, FONT_NOMETRICS, "Metrics data for font '$1' not found") + +gen(1, 2518, FONT_NOOUTLINE, + "No file specified with outline data for font '$1'") + +gen(1, 2520, FONT_NOGLYPHID, "Font '$1' does not contain glyph IDs") + +gen(1, 2530, CJK_NOSTANDARD, "Unknown standard CJK font '$1'") + +gen(1, 2540, T3_BADBBOX, + "Bounding box values must be 0 for colorized Type 3 font '$1'") + +gen(2, 2542, T3_GLYPH, "Glyph '$1' already defined in Type 3 font '$2'") + +gen(1, 2544, T3_FONTEXISTS, "Font '$1' already exists") + +gen(3, 2550, T1_BADCHARSET, + "Encoding (dfCharSet $1) in font/PFM file '$2' not supported") + +/* Unused +gen(3, 2552, T1_PFMFONTNAME, + "Font name mismatch in PFM file '$1' ('$2' vs. '$3')") +*/ + +gen(2, 2554, T1_AFMBADKEY, + "Unknown key '$1' in AFM file '$2'") + +/* Unused +gen(3, 2556, T1_AFMFONTNAME, + "Font name mismatch in AFM file '$1' ('$2' vs. '$3')") +*/ + +gen(1, 2558, T1_NOFONT, "'$1' is not a PostScript Type 1 font") + +gen(1, 2560, TT_BITMAP, "TrueType bitmap Font '$1' not supported") + +gen(1, 2562, TT_NOFONT, "Font '$1' is not a TrueType or OpenType font") + +gen(1, 2564, TT_BADCMAP, "Font '$1' contains unknown encodings (cmaps) only") + +gen(1, 2566, TT_SYMBOLOS2, "Symbol font '$1' does not contain OS/2 table") + +gen(1, 2568, TT_EMBED, +"Couldn't embed font '$1' due to licensing restrictions in the font file") + +gen(0, 2570, TT_ASSERT1, "TrueType parser error") + +gen(1, 2572, TT_ASSERT2, "TrueType parser error in font '$1'") + +gen(2, 2574, TTC_NOTFOUND, + "Font '$1' not found in TrueType Collection file '$2'") + +gen(1, 2576, TT_NOGLYFDESC, + "TrueType font '$1' does not contain any character outlines") + +gen(1, 2578, TT_NONAME, "TrueType font '$1' contains only unsupported " + "font name records in naming table") + +gen(1, 2580, OT_CHARSET, "OpenType font '$1' contains no charset data") + +/* Unused +gen(3, 2582, OT_GLYPH, + "OpenType font '$1' does not contain glyph name '$2' from encoding '$3'") +*/ + +gen(2, 2584, TT_GLYPHIDNOTFOUND, + "Couldn't find glyph ID for Unicode value $1 in TrueType font '$2'") + + +/* -------------------------------------------------------------------- */ +/* Encoding (26xx) */ +/* -------------------------------------------------------------------- */ + +gen(1, 2600, ENC_NOTFOUND, "Couldn't find encoding '$1'") + +gen(1, 2602, ENC_UNSUPP, "Code page '$1' not supported") + +/* Unused +gen(2, 2604, ENC_ADAPT, "Encoding '$1' was adapted to font '$2'") +*/ + +gen(1, 2606, ENC_CANTQUERY, "Can't query encoding '$1'") + +gen(1, 2608, ENC_CANTCHANGE, "Can't change encoding '$1'") + +gen(1, 2610, ENC_INUSE, + "Encoding '$1' can't be changed since it has already been used") + +gen(2, 2612, ENC_TOOLONG, "Encoding name '$1' too long (max. $2)") + +gen(2, 2614, ENC_BADLINE, "Syntax error in encoding file '$1' (line '$2')") + +gen(0, 2616, ENC_GLYPHORCODE, "Glyph name or Unicode value required") + +gen(3, 2618, ENC_BADGLYPH, + "Glyph name '$1' for Unicode value $2 differs from AGL name '$3'") + +gen(3, 2620, ENC_BADUNICODE, + "Unicode value $1 for glyph name '$2' differs from AGL value $3") + +gen(2, 2622, ENC_BADFONT, + "Current font $1 wasn't specified with encoding '$2'") + + + + +/* -------------------------------------------------------------------- */ +/* Hypertext (28xx) */ +/* -------------------------------------------------------------------- */ + +gen(2, 2802, HYP_OPTIGNORE_FORTYPE, + "Option '$1' for destination type '$2' will be ignored") + +gen(1, 2804, HYP_OPTIGNORE_FORELEM, + "Option '$1' for hypertext function will be ignored") + + +/* -------------------------------------------------------------------- */ +/* Internal (29xx) */ +/* -------------------------------------------------------------------- */ + +gen(1, 2900, INT_BADSCOPE, "Bad scope '$1'") + +gen(1, 2902, INT_BADANNOT, "Bad annotation type '$1'") + +gen(1, 2904, INT_BADCS, "Unknown color space $1") + +gen(1, 2906, INT_BADALTERNATE, "Bad alternate color space $1") + +gen(1, 2908, INT_BADPROFILE, "Unknown number of profile components ($1)") + +gen(1, 2910, INT_SSTACK_OVER, "State stack overflow in function '$1'") + +gen(1, 2912, INT_SSTACK_UNDER, "State stack underflow in function '$1'") + +gen(3, 2914, INT_WRAPPER, "Error in PDFlib $1 wrapper function $2 ($3)") + + +#undef gen +#undef pdf_genNames +#undef pdf_genInfo diff --git a/src/libs/pdflib/libs/pdflib/p_gif.c b/src/libs/pdflib/libs/pdflib/p_gif.c new file mode 100644 index 0000000000..d10ff0133b --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_gif.c @@ -0,0 +1,513 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_gif.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * GIF processing for PDFlib + * + */ + +#include "p_intern.h" +#include "p_image.h" + +#ifndef PDF_GIF_SUPPORTED + +pdc_bool +pdf_is_GIF_file(PDF *p, pdc_file *fp) +{ + (void) p; + (void) fp; + + return pdc_false; +} + +int +pdf_process_GIF_data( + PDF *p, + int imageslot) +{ + (void) imageslot; + + pdc_warning(p->pdc, PDF_E_UNSUPP_IMAGE, "GIF", 0, 0, 0); + return -1; +} + +#else + +#define LOCALCOLORMAP 0x80 +#define BitSet(byteval, bitval) (((byteval) & (bitval)) == (bitval)) + +static int ReadColorMap(pdc_core *pdc, pdc_file *fp, + int number, pdf_colormap *buffer); +static int DoExtension(PDF *p, pdf_image *image, int label); +static int GetDataBlock(PDF *p, pdf_image *image, unsigned char *buf); + +static void +pdf_data_source_GIF_init(PDF *p, PDF_data_source *src) +{ + pdf_image *image = (pdf_image *) src->private_data; + + src->buffer_length = 260; /* max. GIF "data sub-block" length */ + + src->buffer_start = (pdc_byte*) pdc_malloc(p->pdc, src->buffer_length, + "pdf_data_source_GIF_init"); + src->bytes_available= 0; + src->next_byte = src->buffer_start; + + /* init the LZW transformation vars */ + image->info.gif.c_size = 9; /* initial code size */ + image->info.gif.t_size = 257; /* initial "table" size */ + image->info.gif.i_buff = 0; /* input buffer */ + image->info.gif.i_bits = 0; /* input buffer empty */ + image->info.gif.o_bits = 0; /* output buffer empty */ +} /* pdf_data_source_GIF_init */ + +static pdc_bool +pdf_data_source_GIF_fill(PDF *p, PDF_data_source *src) +{ +#define c_size image->info.gif.c_size +#define t_size image->info.gif.t_size +#define i_buff image->info.gif.i_buff +#define i_bits image->info.gif.i_bits +#define o_buff image->info.gif.o_buff +#define o_bits image->info.gif.o_bits + + pdf_image * image = (pdf_image *) src->private_data; + pdc_file * fp = image->fp; + int n_bytes = pdc_fgetc(fp); + /* # of bytes to read */ + unsigned char * o_curr = src->buffer_start; + int c_mask = (1 << c_size) - 1; + pdc_bool flag13 = pdc_false; + + src->bytes_available = 0; + + if (n_bytes == EOF) + { + const char *stemp = pdc_errprintf(p->pdc, "%s", image->filename); + pdc_error(p->pdc, PDF_E_IMAGE_CORRUPT, "GIF", stemp, 0, 0); + } + + if (n_bytes == 0) + return pdc_false; + + for (/* */ ; /* */ ; /* */) + { + int w_bits = c_size; /* number of bits to write */ + int code; + + /* get at least c_size bits into i_buff */ + while (i_bits < c_size) + { + if (n_bytes-- == 0) + { + src->bytes_available = (size_t) (o_curr - src->buffer_start); + return pdc_true; + } + /* EOF will be caught later */ + i_buff |= pdc_fgetc(fp) << i_bits; + i_bits += 8; + } + code = i_buff & c_mask; + i_bits -= c_size; + i_buff >>= c_size; + + if (flag13 && code != 256 && code != 257) + { + const char *stemp = pdc_errprintf(p->pdc, "%s", image->filename); + pdc_error(p->pdc, PDF_E_IMAGE_CORRUPT, "GIF", stemp, 0, 0); + } + + if (o_bits > 0) + { + o_buff |= code >> (c_size - 8 + o_bits); + w_bits -= 8 - o_bits; + *(o_curr++) = (unsigned char) o_buff; + } + if (w_bits >= 8) + { + w_bits -= 8; + *(o_curr++) = (unsigned char) (code >> w_bits); + } + o_bits = w_bits; + if (o_bits > 0) + o_buff = code << (8 - o_bits); + + ++t_size; + if (code == 256) /* clear code */ + { + c_size = 9; + c_mask = (1 << c_size) - 1; + t_size = 257; + flag13 = pdc_false; + } + + if (code == 257) /* end code */ + { + src->bytes_available = (size_t) (o_curr - src->buffer_start); + return pdc_true; + } + + if (t_size == (1 << c_size)) + { + if (++c_size > 12) + { + --c_size; + flag13 = pdc_true; + } + else + c_mask = (1 << c_size) - 1; + } + } /* for (;;) */ + +#undef c_size +#undef t_size +#undef i_buff +#undef i_bits +#undef o_buff +#undef o_bits +} /* pdf_data_source_GIF_fill */ + +static void +pdf_data_source_GIF_terminate(PDF *p, PDF_data_source *src) +{ + pdc_free(p->pdc, (void *) src->buffer_start); +} + +#define PDF_STRING_GIF "\107\111\106" +#define PDF_STRING_87a "\070\067\141" +#define PDF_STRING_89a "\070\071\141" + +pdc_bool +pdf_is_GIF_file(PDF *p, pdc_file *fp) +{ + unsigned char buf[3]; + + (void) p; + + if (!PDC_OK_FREAD(fp, buf, 3) || + strncmp((const char *) buf, PDF_STRING_GIF, 3) != 0) { + pdc_fseek(fp, 0L, SEEK_SET); + return pdc_false; + } + return pdc_true; +} + +int +pdf_process_GIF_data( + PDF *p, + int imageslot) +{ + static const char fn[] = "pdf_process_GIF_data"; + unsigned char buf[16]; + char c; + int imageCount = 0; + char version[4]; + int errcode = 0; + pdf_image *image; + pdf_colorspace cs; + pdf_colormap colormap; + int slot; + + image = &p->images[imageslot]; + + + /* we invert this flag later */ + if (image->ignoremask) + image->transparent = pdc_true; + + if (image->page == pdc_undef) + image->page = 1; + + /* Error reading magic number or not a GIF file */ + if (pdf_is_GIF_file(p, image->fp) == pdc_false) { + errcode = PDC_E_IO_BADFORMAT; + goto PDF_GIF_ERROR; + } + + /* Version number */ + if (! PDC_OK_FREAD(image->fp, buf, 3)) { + errcode = PDC_E_IO_BADFORMAT; + goto PDF_GIF_ERROR; + } + strncpy(version, (const char *) buf, 3); + version[3] = '\0'; + if ((strcmp(version, PDF_STRING_87a) != 0) && + (strcmp(version, PDF_STRING_89a) != 0)) { + errcode = PDC_E_IO_BADFORMAT; + goto PDF_GIF_ERROR; + } + + /* Failed to read screen descriptor */ + if (! PDC_OK_FREAD(image->fp, buf, 7)) { + errcode = PDC_E_IO_BADFORMAT; + goto PDF_GIF_ERROR; + } + + cs.type = Indexed; + /* size of the global color table */ + cs.val.indexed.palette_size = 2 << (buf[4] & 0x07); + cs.val.indexed.base = DeviceRGB; + cs.val.indexed.colormap = &colormap; + cs.val.indexed.colormap_id = PDC_BAD_ID; + + if (BitSet(buf[4], LOCALCOLORMAP)) { /* Global Colormap */ + if (ReadColorMap(p->pdc, image->fp, + cs.val.indexed.palette_size, &colormap)) { + errcode = PDF_E_IMAGE_COLORMAP; + goto PDF_GIF_ERROR; + } + } + + /* translate the aspect ratio to PDFlib notation */ + if (buf[6] != 0) { + image->dpi_x = -(buf[6] + ((float) 15.0)) / ((float) 64.0); + image->dpi_y = (float) -1.0; + } + + for (/* */ ; /* */ ; /* */) { + /* EOF / read error in image data */ + if (!PDC_OK_FREAD(image->fp, &c, 1)) { + errcode = PDC_E_IO_NODATA; + goto PDF_GIF_ERROR; + } + +#define PDF_SEMICOLON ((char) 0x3b) /* ASCII ';' */ + + if (c == PDF_SEMICOLON) { /* GIF terminator */ + /* Not enough images found in file */ + if (imageCount < image->page) { + if (!imageCount) + errcode = PDF_E_IMAGE_CORRUPT; + else + errcode = PDF_E_IMAGE_NOPAGE; + goto PDF_GIF_ERROR; + } + break; + } + +#define PDF_EXCLAM ((char) 0x21) /* ASCII '!' */ + + if (c == PDF_EXCLAM) { /* Extension */ + if (!PDC_OK_FREAD(image->fp, &c, 1)) { + /* EOF / read error on extension function code */ + errcode = PDC_E_IO_NODATA; + goto PDF_GIF_ERROR; + } + DoExtension(p, image, (int) c); + continue; + } + +#define PDF_COMMA ((char) 0x2c) /* ASCII ',' */ + + if (c != PDF_COMMA) { /* Not a valid start character */ + /* Bogus character, ignoring */ + continue; + } + + ++imageCount; + + if (! PDC_OK_FREAD(image->fp, buf, 9)) { + /* Couldn't read left/top/width/height */ + errcode = PDC_E_IO_NODATA; + goto PDF_GIF_ERROR; + } + + image->components = 1; + image->bpc = 8; + image->width = (float) pdc_get_le_ushort(&buf[4]); + image->height = (float) pdc_get_le_ushort(&buf[6]); + + if (image->imagemask) + { + if (p->compatibility <= PDC_1_3) { + errcode = PDF_E_IMAGE_MASK1BIT13; + goto PDF_GIF_ERROR; + } else { + /* images with more than one bit will be written as /SMask, + * and don't require an /ImageMask entry. + */ + image->imagemask = pdc_false; + } + image->colorspace = DeviceGray; + } + +#define INTERLACE 0x40 + if (BitSet(buf[8], INTERLACE)) { + errcode = PDF_E_GIF_INTERLACED; + goto PDF_GIF_ERROR; + } + + if (BitSet(buf[8], LOCALCOLORMAP)) { + if (ReadColorMap(p->pdc, image->fp, + cs.val.indexed.palette_size, &colormap)) + { + errcode = PDF_E_IMAGE_COLORMAP; + goto PDF_GIF_ERROR; + } + } + + /* read the "LZW initial code size". + */ + if (!PDC_OK_FREAD(image->fp, buf, 1)) { + errcode = PDC_E_IO_NODATA; + goto PDF_GIF_ERROR; + } + if (buf[0] != 8) { + if (imageCount > 1) + errcode = PDF_E_IMAGE_NOPAGE; + else + errcode = PDF_E_GIF_LZWSIZE; + goto PDF_GIF_ERROR; + } + + if (imageCount == image->page) + break; + } + + image->src.init = pdf_data_source_GIF_init; + image->src.fill = pdf_data_source_GIF_fill; + image->src.terminate = pdf_data_source_GIF_terminate; + image->src.private_data = (void *) image; + + image->compression = lzw; + image->use_raw = pdc_true; + + image->params = (char *) pdc_malloc(p->pdc, PDF_MAX_PARAMSTRING, fn); + strcpy(image->params, "/EarlyChange 0"); + + image->in_use = pdc_true; /* mark slot as used */ + + slot = pdf_add_colorspace(p, &cs, pdc_false); + image->colorspace = (pdf_colorspacetype) slot; + + + + pdf_put_image(p, imageslot, pdc_true); + + return imageslot; + + PDF_GIF_ERROR: + { + const char *stemp = pdc_errprintf(p->pdc, "%s", image->filename); + switch (errcode) + { + case PDC_E_IO_NODATA: + case PDF_E_IMAGE_COLORMAP: + case PDF_E_GIF_INTERLACED: + case PDF_E_GIF_LZWSIZE: + pdc_set_errmsg(p->pdc, errcode, stemp, 0, 0, 0); + break; + + case PDC_E_IO_BADFORMAT: + pdc_set_errmsg(p->pdc, errcode, stemp, "GIF", 0, 0); + break; + + case PDF_E_IMAGE_CORRUPT: + pdc_set_errmsg(p->pdc, errcode, "GIF", stemp, 0, 0); + break; + + case PDF_E_IMAGE_NOPAGE: + pdc_set_errmsg(p->pdc, errcode, + pdc_errprintf(p->pdc, "%d", image->page), "GIF", stemp, 0); + break; + + case 0: /* error code and message already set */ + break; + } + } + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; +} /* pdf_open_GIF_data */ + +static int +ReadColorMap(pdc_core *pdc, pdc_file *fp, int number, pdf_colormap *buffer) +{ + int i; + unsigned char rgb[3]; + + (void) pdc; + + for (i = 0; i < number; ++i) { + if (! PDC_OK_FREAD(fp, rgb, sizeof(rgb))) { + return pdc_true; /* yk: true == error */ + } + + (*buffer)[i][0] = rgb[0] ; + (*buffer)[i][1] = rgb[1] ; + (*buffer)[i][2] = rgb[2] ; + } + return pdc_false; /* yk: false == ok. */ +} /* ReadColorMap */ + +static int +DoExtension(PDF *p, pdf_image *image, int label) +{ + pdc_byte buf[256]; + + switch ((unsigned char) label) { + case 0x01: /* Plain Text Extension */ + break; + + case 0xff: /* Application Extension */ + break; + + case 0xfe: /* Comment Extension */ + while (GetDataBlock(p, image, (unsigned char*) buf) != 0) { + /* */ + } + return pdc_false; + + case 0xf9: /* Graphic Control Extension */ + (void) GetDataBlock(p, image, (unsigned char*) buf); + + if ((buf[0] & 0x1) != 0) { + image->transparent = !image->transparent; + image->transval[0] = buf[3]; + } + + while (GetDataBlock(p, image, (unsigned char*) buf) != 0) { + /* */ ; + } + return pdc_false; + + default: + break; + } + + while (GetDataBlock(p, image, (unsigned char*) buf) != 0) { + /* */ ; + } + + return pdc_false; +} /* DoExtension */ + +static int +GetDataBlock(PDF *p, pdf_image *image, unsigned char *buf) +{ + unsigned char count; + pdc_file *fp = image->fp; + + if ((!PDC_OK_FREAD(fp, &count, 1)) || + ((count != 0) && (!PDC_OK_FREAD(fp, buf, count)))) + { + const char *stemp = pdc_errprintf(p->pdc, "%s", image->filename); + pdc_error(p->pdc, PDF_E_IMAGE_CORRUPT, "GIF", stemp, 0, 0); + } + + return count; +} /* GetDataBlock */ + +#endif /* PDF_GIF_SUPPORTED */ diff --git a/src/libs/pdflib/libs/pdflib/p_gstate.c b/src/libs/pdflib/libs/pdflib/p_gstate.c new file mode 100644 index 0000000000..b3805b8488 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_gstate.c @@ -0,0 +1,645 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_gstate.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib routines dealing with the graphics states + * + */ + +#include "p_intern.h" + +/* ---------------------- matrix functions ----------------------------- */ + +void +pdf_concat_raw(PDF *p, pdc_matrix *m) +{ + if (pdc_is_identity_matrix(m)) + return; + + pdf_end_text(p); + + pdc_printf(p->out, "%f %f %f %f %f %f cm\n", + m->a, m->b, m->c, m->d, m->e, m->f); + + pdc_multiply_matrix(m, &p->gstate[p->sl].ctm); +} + +void +pdf_concat_raw_ob(PDF *p, pdc_matrix *m, pdc_bool blind) +{ + if (!blind) + pdf_concat_raw(p, m); + else + pdc_multiply_matrix(m, &p->gstate[p->sl].ctm); +} + +void +pdf_set_topdownsystem(PDF *p, float height) +{ + if (p->ydirection < (float) 0.0) + { + pdc_matrix m; + pdc_translation_matrix(0, height, &m); + pdf_concat_raw(p, &m); + pdc_scale_matrix(1, -1, &m); + pdf_concat_raw(p, &m); + pdf_set_horiz_scaling(p, 100); + } +} + +/* -------------------- Special graphics state ---------------------------- */ + +void +pdf_init_gstate(PDF *p) +{ + pdf_gstate *gs = &p->gstate[p->sl]; + + gs->ctm.a = (float) 1; + gs->ctm.b = (float) 0; + gs->ctm.c = (float) 0; + gs->ctm.d = (float) 1; + gs->ctm.e = (float) 0.0; + gs->ctm.f = (float) 0.0; + + gs->x = (float) 0.0; + gs->y = (float) 0.0; + + p->fillrule = pdf_fill_winding; + + gs->lwidth = (float) 1; + gs->lcap = 0; + gs->ljoin = 0; + gs->miter = (float) 10; + gs->flatness = (float) -1; /* -1 means "has not been set" */ + gs->dashed = pdc_false; +} + +void +pdf__save(PDF *p) +{ + if (p->sl == PDF_MAX_SAVE_LEVEL - 1) + pdc_error(p->pdc, PDF_E_GSTATE_SAVELEVEL, + pdc_errprintf(p->pdc, "%d", PDF_MAX_SAVE_LEVEL - 1), 0, 0, 0); + + pdf_end_text(p); + + pdc_puts(p->out, "q\n"); + + /* propagate states to next level */ + p->sl++; + memcpy(&p->gstate[p->sl], &p->gstate[p->sl - 1], sizeof(pdf_gstate)); + memcpy(&p->tstate[p->sl], &p->tstate[p->sl - 1], sizeof(pdf_tstate)); + memcpy(&p->cstate[p->sl], &p->cstate[p->sl - 1], sizeof(pdf_cstate)); +} + + +void +pdf__restore(PDF *p) +{ + if (p->sl == 0) + pdc_error(p->pdc, PDF_E_GSTATE_RESTORE, 0, 0, 0, 0); + + pdf_end_text(p); + + pdc_puts(p->out, "Q\n"); + + p->sl--; +} + +PDFLIB_API void PDFLIB_CALL +PDF_save(PDF *p) +{ + static const char fn[] = "PDF_save"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p])\n", (void *) p)) + return; + + pdf__save(p); +} + +PDFLIB_API void PDFLIB_CALL +PDF_restore(PDF *p) +{ + static const char fn[] = "PDF_restore"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p])\n", (void *) p)) + return; + + pdf__restore(p); +} + +PDFLIB_API void PDFLIB_CALL +PDF_translate(PDF *p, float tx, float ty) +{ + static const char fn[] = "PDF_translate"; + pdc_matrix m; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g, %g)\n", + (void *) p, tx, ty)) + return; + + if (tx == (float) 0 && ty == (float) 0) + return; + + pdc_translation_matrix(tx, ty, &m); + + pdf_concat_raw(p, &m); +} + +PDFLIB_API void PDFLIB_CALL +PDF_scale(PDF *p, float sx, float sy) +{ + static const char fn[] = "PDF_scale"; + pdc_matrix m; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g, %g)\n", + (void *) p, sx, sy)) + return; + + if (sx == (float) 0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, "sx", "0", 0, 0); + + if (sy == (float) 0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, "sy", "0", 0, 0); + + if (sx == (float) 1 && sy == (float) 1) + return; + + pdc_scale_matrix(sx, sy, &m); + + pdf_concat_raw(p, &m); +} + +PDFLIB_API void PDFLIB_CALL +PDF_rotate(PDF *p, float phi) +{ + static const char fn[] = "PDF_rotate"; + pdc_matrix m; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g)\n", + (void *) p, phi)) + return; + + if (phi == (float) 0) + return; + + pdc_rotation_matrix(p->ydirection * phi, &m); + + pdf_concat_raw(p, &m); +} + +PDFLIB_API void PDFLIB_CALL +PDF_skew(PDF *p, float alpha, float beta) +{ + static const char fn[] = "PDF_skew"; + pdc_matrix m; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g, %g)\n", + (void *) p, alpha, beta)) + return; + + if (alpha == (float) 0 && beta == (float) 0) + return; + + if (alpha > (float) 360 || alpha < (float) -360 || + alpha == (float) -90 || alpha == (float) -270 || + alpha == (float) 90 || alpha == (float) 270) { + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "alpha", pdc_errprintf(p->pdc, "%f", alpha), 0, 0); + } + + if (beta > (float) 360 || beta < (float) -360 || + beta == (float) -90 || beta == (float) -270 || + beta == (float) 90 || beta == (float) 270) { + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "beta", pdc_errprintf(p->pdc, "%f", beta), 0, 0); + } + + pdc_skew_matrix(p->ydirection * alpha, p->ydirection * beta, &m); + + pdf_concat_raw(p, &m); +} + +PDFLIB_API void PDFLIB_CALL +PDF_concat(PDF *p, float a, float b, float c, float d, float e, float f) +{ + static const char fn[] = "PDF_concat"; + pdc_matrix m; + float det = a * d - b * c; + + if (!pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], %g, %g, %g, %g, %g, %g)\n", (void *) p, a, b, c, d, e, f)) + { + return; + } + + if (fabs(det) < (float) PDF_SMALLREAL) + pdc_error(p->pdc, PDC_E_ILLARG_MATRIX, + pdc_errprintf(p->pdc, "%f %f %f %f %f %f", a, b, c, d, e, f), + 0, 0, 0); + + m.a = (float) a; + m.b = (float) b; + m.c = (float) c; + m.d = (float) d; + m.e = (float) e; + m.f = (float) f; + + pdf_concat_raw(p, &m); +} + +void +pdf__setmatrix(PDF *p, pdc_matrix *n) +{ + pdc_matrix m; + float det = n->a * n->d - n->b * n->c; + + if (fabs(det) < (float) PDF_SMALLREAL) + pdc_error(p->pdc, PDC_E_ILLARG_MATRIX, + pdc_errprintf(p->pdc, "%f %f %f %f %f %f", + n->a, n->b, n->c, n->d, n->e, n->f), + 0, 0, 0); + + pdc_invert_matrix(p->pdc, &m, &p->gstate[p->sl].ctm); + pdf_concat_raw(p, &m); + pdf_concat_raw(p, n); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setmatrix(PDF *p, float a, float b, float c, float d, float e, float f) +{ + static const char fn[] = "PDF_setmatrix"; + pdc_matrix m; + float det = a * d - b * c; + + if (!pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], %g, %g, %g, %g, %g, %g)\n", (void *) p, a, b, c, d, e, f)) + { + return; + } + + if (fabs(det) < (float) PDF_SMALLREAL) + pdc_error(p->pdc, PDC_E_ILLARG_MATRIX, + pdc_errprintf(p->pdc, "%f %f %f %f %f %f", a, b, c, d, e, f), + 0, 0, 0); + + pdc_invert_matrix(p->pdc, &m, &p->gstate[p->sl].ctm); + pdf_concat_raw(p, &m); + + m.a = (float) a; + m.b = (float) b; + m.c = (float) c; + m.d = (float) d; + m.e = (float) e; + m.f = (float) f; + + pdf_concat_raw(p, &m); +} + +/* -------------------- General graphics state ---------------------------- */ + +/* definitions of dash options */ +static const pdc_defopt pdf_dashoptions[] = +{ + {"dasharray", pdc_floatlist, 0, 2, MAX_DASH_LENGTH, + PDC_FLOAT_PREC, PDC_FLOAT_MAX, NULL}, + + {"dashphase", pdc_floatlist, 0, 1, 1, 0.0, PDC_FLOAT_MAX, NULL}, + + PDC_OPT_TERMINATE +}; + +static void +pdf__setdashpattern(PDF *p, float *darray, int length, float phase) +{ + pdf_gstate *gs = &p->gstate[p->sl]; + + /* length == 0 or 1 means solid line */ + if (length < 2) + { + if (gs->dashed || PDF_FORCE_OUTPUT()) + { + pdc_puts(p->out, "[] 0 d\n"); + gs->dashed = pdc_false; + } + } + else + { + int i; + + pdc_puts(p->out, "["); + for (i = 0; i < length; i++) + { + pdc_printf(p->out, "%f ", darray[i]); + } + pdc_printf(p->out, "] %f d\n", phase); + gs->dashed = pdc_true; + } +} + +void +pdf__setdash(PDF *p, float b, float w) +{ + float darray[2]; + int length = 2; + + /* both zero means solid line */ + if (b == 0.0 && w == 0.0) + { + length = 0; + } + else + { + darray[0] = b; + darray[1] = w; + } + pdf__setdashpattern(p, darray, length, (float) 0.0); +} + +void +pdf__setflat(PDF *p, float flat) +{ + pdf_gstate *gs = &p->gstate[p->sl]; + + if (flat != gs->flatness || PDF_FORCE_OUTPUT()) + { + gs->flatness = flat; + pdc_printf(p->out, "%f i\n", flat); + } +} + +void +pdf__setlinejoin(PDF *p, int join) +{ + pdf_gstate *gs = &p->gstate[p->sl]; + + if (join != gs->ljoin || PDF_FORCE_OUTPUT()) + { + gs->ljoin = join; + pdc_printf(p->out, "%d j\n", join); + } +} + +void +pdf__setlinecap(PDF *p, int cap) +{ + pdf_gstate *gs = &p->gstate[p->sl]; + + if (cap != gs->lcap || PDF_FORCE_OUTPUT()) + { + gs->lcap = cap; + pdc_printf(p->out, "%d J\n", cap); + } +} + +void +pdf__setlinewidth(PDF *p, float width) +{ + pdf_gstate *gs = &p->gstate[p->sl]; + + if (width != gs->lwidth || PDF_FORCE_OUTPUT()) + { + gs->lwidth = width; + pdc_printf(p->out, "%f w\n", width); + } +} + +void +pdf__setmiterlimit(PDF *p, float miter) +{ + pdf_gstate *gs = &p->gstate[p->sl]; + + if (miter != gs->miter || PDF_FORCE_OUTPUT()) + { + gs->miter = miter; + pdc_printf(p->out, "%f M\n", miter); + } +} + + +PDFLIB_API void PDFLIB_CALL +PDF_setdash(PDF *p, float b, float w) +{ + static const char fn[] = "PDF_setdash"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g, %g)\n", + (void *) p, b, w)) + return; + + if (b < (float) 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "b", pdc_errprintf(p->pdc, "%f", b), 0, 0); + + if (w < (float) 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "w", pdc_errprintf(p->pdc, "%f", w), 0, 0); + + pdf__setdash(p, b, w); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setpolydash(PDF *p, float *darray, int length) +{ + static const char fn[] = "PDF_setpolydash"; + + int i; + + for (i = 0; i < length; i++) + pdc_trace(p->pdc, "*(darray+%d) = %g;\n", i, darray[i]); + + if (!pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], darray[%p], %d)\n", (void *) p, (void *) darray, length)) + { + return; + } + + if (length > 1) + { + /* sanity checks */ + if (!darray) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "darray", 0, 0, 0); + + if (length < 0 || length > MAX_DASH_LENGTH) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "length", pdc_errprintf(p->pdc, "%d", length), 0, 0); + + for (i = 0; i < length; i++) { + if (darray[i] < (float) 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "darray[i]", pdc_errprintf(p->pdc, "%f", darray[i]), 0, 0); + } + } + + pdf__setdashpattern(p, darray, length, (float) 0.0); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setdashpattern(PDF *p, const char *optlist) +{ + static const char fn[] = "PDF_setdashpattern"; + pdc_resopt *results; + float *darray, phase; + int length; + + if (!pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], \"%s\")\n", (void *) p, optlist)) + return; + + /* parsing optlist */ + results = pdc_parse_optionlist(p->pdc, optlist, pdf_dashoptions, NULL, + pdc_true); + + length = pdc_get_optvalues(p->pdc, "dasharray", results, + NULL, (void **) &darray); + + phase = (float) 0.0; + (void) pdc_get_optvalues(p->pdc, "dashphase", results, &phase, NULL); + + pdc_cleanup_optionlist(p->pdc, results); + + pdf__setdashpattern(p, darray, length, phase); + + if (darray) + pdc_free(p->pdc, darray); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setflat(PDF *p, float flat) +{ + static const char fn[] = "PDF_setflat"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g)\n", + (void *) p, flat)) + return; + + if (flat < 0.0 || flat > 100.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "flat", pdc_errprintf(p->pdc, "%f", flat), 0, 0); + + pdf__setflat(p, flat); +} + + +PDFLIB_API void PDFLIB_CALL +PDF_setlinejoin(PDF *p, int join) +{ + static const char fn[] = "PDF_setlinejoin"; + const int LAST_JOIN = 2; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %d)\n", + (void *) p, join)) + return; + + if (join < 0 || join > LAST_JOIN) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "join", pdc_errprintf(p->pdc, "%d", join), 0, 0); + + pdf__setlinejoin(p, join); +} + + +PDFLIB_API void PDFLIB_CALL +PDF_setlinecap(PDF *p, int cap) +{ + static const char fn[] = "PDF_setlinecap"; + const int LAST_CAP = 2; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %d)\n", + (void *) p, cap)) + return; + + if (cap < 0 || cap > LAST_CAP) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "cap", pdc_errprintf(p->pdc, "%d", cap), 0, 0); + + pdf__setlinecap(p, cap); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setmiterlimit(PDF *p, float miter) +{ + static const char fn[] = "PDF_setmiterlimit"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g)\n", + (void *) p, miter)) + return; + + if (miter < (float) 1.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "miter", pdc_errprintf(p->pdc, "%f", miter), 0, 0); + + pdf__setmiterlimit(p, miter); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setlinewidth(PDF *p, float width) +{ + static const char fn[] = "PDF_setlinewidth"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g)\n", + (void *) p, width)) + return; + + if (width <= (float) 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "width", pdc_errprintf(p->pdc, "%f", width), 0, 0); + + pdf__setlinewidth(p, width); +} + +/* reset all gstate parameters except CTM +*/ +void +pdf_reset_gstate(PDF *p) +{ + pdf_gstate *gs = &p->gstate[p->sl]; + + + pdf__setcolor(p, "fillstroke", "gray", + (float) 0, (float) 0, (float) 0, (float) 0); + + + pdf__setlinewidth(p, 1); + pdf__setlinecap(p, 0); + pdf__setlinejoin(p, 0); + pdf__setmiterlimit(p, 10); + pdf__setdash(p, 0, 0); + + if (gs->flatness != (float) -1) + pdf__setflat(p, (float) 1.0); +} + +void +pdf__initgraphics(PDF *p) +{ + pdc_matrix inv_ctm; + + pdf_reset_gstate(p); + + pdc_invert_matrix(p->pdc, &inv_ctm, &p->gstate[p->sl].ctm); + pdf_concat_raw(p, &inv_ctm); + + /* This also resets the CTM which guards against rounding artifacts. */ + pdf_init_gstate(p); +} + +PDFLIB_API void PDFLIB_CALL +PDF_initgraphics(PDF *p) +{ + static const char fn[] = "PDF_initgraphics"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p])\n", (void *) p)) + return; + + pdf__initgraphics(p); +} diff --git a/src/libs/pdflib/libs/pdflib/p_hkscmyk.h b/src/libs/pdflib/libs/pdflib/p_hkscmyk.h new file mode 100644 index 0000000000..2cd4286aa5 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_hkscmyk.h @@ -0,0 +1,28 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_hkscmyk.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib HKS spot CMYK color table + * + * HKS is a registered trademark of + * HKS (Hostmann-Steinberg, K+E, Schmincke)-Warenzeichenverband e.V. + * Germany + * + */ + +#ifndef P_HKSCMYK_H +#define P_HKSCMYK_H + + +#endif /* P_HKSCMYK_H */ + diff --git a/src/libs/pdflib/libs/pdflib/p_hkslab.h b/src/libs/pdflib/libs/pdflib/p_hkslab.h new file mode 100644 index 0000000000..c6717bb6b1 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_hkslab.h @@ -0,0 +1,28 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_hkslab.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib HKS spot LAB color table + * + * HKS is a registered trademark of + * HKS (Hostmann-Steinberg, K+E, Schmincke)-Warenzeichenverband e.V. + * Germany + * + */ + +#ifndef P_HKSLAB_H +#define P_HKSLAB_H + + +#endif /* P_HKSTAB_H */ + diff --git a/src/libs/pdflib/libs/pdflib/p_hostfont.c b/src/libs/pdflib/libs/pdflib/p_hostfont.c new file mode 100644 index 0000000000..838c00f9c6 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_hostfont.c @@ -0,0 +1,23 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_hostfont.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib host font handling routines for Windows and Mac + * + */ + +#include "p_intern.h" +#include "p_font.h" +#include "p_truetype.h" + + diff --git a/src/libs/pdflib/libs/pdflib/p_hyper.c b/src/libs/pdflib/libs/pdflib/p_hyper.c new file mode 100644 index 0000000000..a7e02f2ba9 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_hyper.c @@ -0,0 +1,1264 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_hyper.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib routines for hypertext stuff: bookmarks, document info, transitions + * + */ + +#define P_HYPER_C + +#include "p_intern.h" + + +/* We can't work with pointers in the outline objects because + * the complete outline block may be reallocated. Therefore we use + * this simple mechanism for achieving indirection. + */ +#define COUNT(index) (p->outlines[index].count) +#define OPEN(index) (p->outlines[index].open) +#define LAST(index) (p->outlines[index].last) +#define PARENT(index) (p->outlines[index].parent) +#define FIRST(index) (p->outlines[index].first) +#define SELF(index) (p->outlines[index].self) +#define PREV(index) (p->outlines[index].prev) +#define NEXT(index) (p->outlines[index].next) + +struct pdf_outline_s { + pdc_id self; /* id of this outline object */ + pdc_id prev; /* previous entry at this level */ + pdc_id next; /* next entry at this level */ + int parent; /* ancestor's index */ + int first; /* first sub-entry */ + int last; /* last sub-entry */ + char *text; /* bookmark text */ + int count; /* number of open sub-entries */ + int open; /* whether or not to display children */ + pdf_dest dest; /* outline destination */ +}; + +struct pdf_info_s { + char *key; /* ASCII string */ + char *value; /* Unicode string */ + pdf_info *next; /* next info entry */ +}; + +struct pdf_name_s { + pdc_id obj_id; /* id of this name object */ + char * name; /* name string */ + int len; /* length of name string */ +}; + +void +pdf_init_outlines(PDF *p) +{ + p->outline_count = 0; +} + +/* Free outline entries */ +void +pdf_cleanup_outlines(PDF *p) +{ + int i; + + if (!p->outlines || p->outline_count == 0) + return; + + /* outlines[0] is the outline root object */ + for (i = 0; i <= p->outline_count; i++) + { + if (p->outlines[i].text) + pdc_free(p->pdc, p->outlines[i].text); + pdf_cleanup_destination(p, &p->outlines[i].dest); + } + + pdc_free(p->pdc, (void*) p->outlines); + + p->outlines = NULL; +} + +static const pdc_keyconn pdf_type_keylist[] = +{ + {"fixed", fixed}, + {"fitwindow", fitwindow}, + {"fitwidth", fitwidth}, + {"fitheight", fitheight}, + {"fitrect", fitrect}, + {"fitvisible", fitvisible}, + {"fitvisiblewidth", fitvisiblewidth}, + {"fitvisibleheight",fitvisibleheight}, + {"nameddest", nameddest}, + {"file", filedest}, + {NULL, 0} +}; + +#define PDF_MAXDESTLEN 64000 + +static const pdc_defopt pdf_destination_options[] = +{ + {"fitbbox", pdc_booleanlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, NULL}, + + {"fitheight", pdc_booleanlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, NULL}, + + {"fitpage", pdc_booleanlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, NULL}, + + {"fitwidth", pdc_booleanlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, NULL}, + + {"retain", pdc_booleanlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, NULL}, + + {"type", pdc_keywordlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, pdf_type_keylist}, + + {"name", pdc_stringlist, PDC_OPT_NONE, 1, 1, 0.0, PDF_MAXDESTLEN, NULL}, + + /* page 0 means "current page" for PDF_add_bookmark() */ + {"page", pdc_integerlist, PDC_OPT_NONE, 1, 1, 0, INT_MAX, NULL}, + + /* Acrobat 5 supports a maximum zoom of 1600%, but we allow some more */ + {"zoom", pdc_floatlist, PDC_OPT_NONE, 1, 1, 0.0, 10000, NULL}, + + {"left", pdc_floatlist, PDC_OPT_NONE, 1, 1, 0.0, PDF_ACRO4_MAXPAGE, NULL}, + + {"right", pdc_floatlist, PDC_OPT_NONE, 1, 1, 0.0, PDF_ACRO4_MAXPAGE, NULL}, + + {"bottom", pdc_floatlist, PDC_OPT_REQUIRIF1, 1, 1, 0.0, PDF_ACRO4_MAXPAGE, + NULL}, + + {"top", pdc_floatlist, PDC_OPT_NONE, 1, 1, 0.0, PDF_ACRO4_MAXPAGE, NULL}, + + {"color", pdc_floatlist, PDC_OPT_NONE, 1, 3, 0.0, 1.0, NULL}, + + {"fontstyle", pdc_keywordlist, PDC_OPT_NONE, 1, 1, 0.0, 0.0, + pdf_fontstyle_keylist}, + + {"filename", pdc_stringlist, PDC_OPT_NONE, 1, 1, 0.0, PDF_FILENAMELEN, + NULL}, + + PDC_OPT_TERMINATE +}; + +void +pdf_init_destination(PDF *p, pdf_dest *dest) +{ + (void) p; + + dest->type = fitwindow; + dest->remote = pdc_false; + dest->page = 0; + dest->left = -1; + dest->right = -1; + dest->bottom = -1; + dest->top = -1; + dest->zoom = -1; + dest->name = NULL; + dest->color[0] = (float) 0.0; + dest->color[1] = (float) 0.0; + dest->color[2] = (float) 0.0; + dest->fontstyle = pdc_Normal; + dest->filename = NULL; +} + +static void +pdf_copy_destination(PDF *p, pdf_dest *dest, pdf_dest *source) +{ + *dest = *source; + if (source->name) + dest->name = pdc_strdup(p->pdc, source->name); + if (source->filename) + dest->filename = pdc_strdup(p->pdc, source->filename); +} + +void +pdf_cleanup_destination(PDF *p, pdf_dest *dest) +{ + if (dest->name) + pdc_free(p->pdc, dest->name); + dest->name = NULL; + if (dest->filename) + pdc_free(p->pdc, dest->filename); + dest->filename = NULL; +} + +void +pdf_parse_destination_optlist( + PDF *p, + const char *optlist, + pdf_dest *dest, + int page, + pdf_destuse destuse) +{ + pdc_resopt *results; + const char *keyword; + const char *type_name; + char **name = NULL; + char **filename = NULL; + int inum, minpage; + pdc_bool boolval; + + /* Defaults */ + pdf_init_destination(p, dest); + dest->page = page; + + /* parse option list */ + results = pdc_parse_optionlist(p->pdc, optlist, pdf_destination_options, + NULL, pdc_true); + + if (pdc_get_optvalues(p->pdc, "fitbbox", results, &boolval, NULL) && + boolval == pdc_true) + dest->type = fitvisible; + + if (pdc_get_optvalues(p->pdc, "fitheight", results, &boolval, NULL) && + boolval == pdc_true) + dest->type = fitheight; + + if (pdc_get_optvalues(p->pdc, "fitpage", results, &boolval, NULL) && + boolval == pdc_true) + dest->type = fitwindow; + + if (pdc_get_optvalues(p->pdc, "fitwidth", results, &boolval, NULL) && + boolval == pdc_true) + dest->type = fitwidth; + + if (pdc_get_optvalues(p->pdc, "retain", results, &boolval, NULL) && + boolval == pdc_true) + dest->type = fixed; + + if (pdc_get_optvalues(p->pdc, "type", results, &inum, NULL)) + dest->type = (pdf_desttype) inum; + type_name = pdc_get_keyword(dest->type, pdf_type_keylist); + + keyword = "name"; + if (pdc_get_optvalues(p->pdc, keyword, results, NULL, (void **) &name) && + dest->type != nameddest) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORTYPE, keyword, type_name, + 0, 0); + + keyword = "page"; + if (pdc_get_optvalues(p->pdc, keyword, results, &dest->page, NULL) && + dest->type == filedest) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORTYPE, keyword, type_name, + 0, 0); + + keyword = "zoom"; + if (pdc_get_optvalues(p->pdc, keyword, results, &dest->zoom, NULL) && + dest->type != fixed) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORTYPE, keyword, type_name, + 0, 0); + + keyword = "left"; + if (pdc_get_optvalues(p->pdc, keyword, results, &dest->left, NULL) && + (dest->type == fitwindow || dest->type == fitwidth || + dest->type == fitvisible || dest->type == fitvisiblewidth || + dest->type == nameddest || dest->type == filedest)) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORTYPE, keyword, type_name, + 0, 0); + + keyword = "right"; + if (pdc_get_optvalues(p->pdc, keyword, results, &dest->right, NULL) && + dest->type != fitrect) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORTYPE, keyword, type_name, + 0, 0); + + keyword = "bottom"; + if (pdc_get_optvalues(p->pdc, keyword, results, &dest->bottom, NULL) && + dest->type != fitrect) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORTYPE, keyword, type_name, + 0, 0); + + keyword = "top"; + if (pdc_get_optvalues(p->pdc, keyword, results, &dest->top, NULL) && + (dest->type == fitwindow || dest->type == fitheight || + dest->type == fitvisible || dest->type == fitvisibleheight || + dest->type == nameddest || dest->type == filedest)) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORTYPE, keyword, type_name, + 0, 0); + + keyword = "color"; + if (pdc_get_optvalues(p->pdc, keyword, results, &dest->color, NULL) && + destuse != pdf_bookmark) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORELEM, keyword, 0, 0, 0); + + keyword = "fontstyle"; + if (pdc_get_optvalues(p->pdc, keyword, results, &inum, NULL)) + { + dest->fontstyle = (pdc_fontstyle) inum; + if (destuse != pdf_bookmark) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORELEM, keyword, 0, 0, 0); + } + + keyword = "filename"; + if (pdc_get_optvalues(p->pdc, keyword, results, NULL, (void **) &filename) + && dest->type != filedest) + pdc_warning(p->pdc, PDF_E_HYP_OPTIGNORE_FORTYPE, keyword, type_name, + 0, 0); + + pdc_cleanup_optionlist(p->pdc, results); + + switch (dest->type) + { + case fitwidth: + /* Trick: we don't know the height of a future page yet, + * so we use a "large" value for top which will do for + * most pages. If it doesn't work, not much harm is done. + */ + if (dest->top == -1) + dest->top = 10000; + break; + + case fitrect: + case fitheight: + case fitvisiblewidth: + case fitvisibleheight: + if (dest->left == -1) + dest->left = 0; + if (dest->bottom == -1) + dest->bottom = 0; + if (dest->right == -1) + dest->right = 1000; + if (dest->top == -1) + dest->top = 1000; + break; + + case nameddest: + if (destuse == pdf_nameddest) + { + pdc_cleanup_stringlist(p->pdc, name); + pdc_error(p->pdc, PDC_E_OPT_ILLKEYWORD, "type", type_name, 0, 0); + } + if (name) + { + dest->name = name[0]; + pdc_free(p->pdc, name); + name = NULL; + } + else + { + pdc_error(p->pdc, PDC_E_OPT_NOTFOUND, "name", 0, 0, 0); + } + break; + + case filedest: + if (destuse != pdf_bookmark) + { + pdc_cleanup_stringlist(p->pdc, filename); + pdc_error(p->pdc, PDC_E_OPT_ILLKEYWORD, "type", type_name, 0, 0); + } + if (filename) + { + dest->filename = filename[0]; + pdc_free(p->pdc, filename); + filename = NULL; + } + else + { + pdc_error(p->pdc, PDC_E_OPT_NOTFOUND, "filename", 0, 0, 0); + } + break; + + default: + break; + } + + if (name) + pdc_cleanup_stringlist(p->pdc, name); + if (filename) + pdc_cleanup_stringlist(p->pdc, filename); + + /* check for minpage */ + minpage = (destuse == pdf_bookmark) ? 0 : 1; + switch (destuse) + { + case pdf_nameddest: + case pdf_locallink: + if (dest->page == 0) + dest->page = p->current_page; + case pdf_bookmark: + case pdf_openaction: + case pdf_remotelink: + if (dest->page < minpage) + { + pdc_error(p->pdc, PDC_E_ILLARG_HANDLE, "page", + pdc_errprintf(p->pdc, "%d", dest->page), 0, 0); + } + break; + } + + /* remote flag */ + if (destuse == pdf_remotelink) + dest->remote = pdc_true; +} + +void +pdf_write_destination(PDF *p, pdf_dest *dest) +{ + if (dest->type == nameddest) { + pdc_put_pdfstring(p->out, dest->name, (int) strlen(dest->name)); + pdc_puts(p->out, "\n"); + return; + } + + pdc_puts(p->out, "["); + + if (dest->remote) { + pdc_printf(p->out, "%d", dest->page - 1); /* zero-based */ + + } else { + /* preallocate page object id for a later page */ + if (dest->page > p->current_page) { + while (dest->page >= p->pages_capacity) + pdf_grow_pages(p); + + /* if this page has already been used as a link target + * it will already have an object id. Otherwise we allocate one. + */ + if (p->pages[dest->page] == PDC_BAD_ID) + p->pages[dest->page] = pdc_alloc_id(p->out); + } + pdc_printf(p->out, "%ld 0 R", p->pages[dest->page]); + } + + switch (dest->type) { + + case fixed: + pdc_puts(p->out, "/XYZ "); + + if (dest->left != -1) + pdc_printf(p->out, "%f ", dest->left); + else + pdc_puts(p->out, "null "); + + if (dest->top != -1) + pdc_printf(p->out, "%f ", dest->top); + else + pdc_puts(p->out, "null "); + + if (dest->zoom != -1) + pdc_printf(p->out, "%f", dest->zoom); + else + pdc_puts(p->out, "null"); + + break; + + case fitwindow: + pdc_puts(p->out, "/Fit"); + break; + + case fitwidth: + pdc_printf(p->out, "/FitH %f", dest->top); + break; + + case fitheight: + pdc_printf(p->out, "/FitV %f", dest->left); + break; + + case fitrect: + pdc_printf(p->out, "/FitR %f %f %f %f", + dest->left, dest->bottom, dest->right, dest->top); + break; + + case fitvisible: + pdc_puts(p->out, "/FitB"); + break; + + case fitvisiblewidth: + pdc_printf(p->out, "/FitBH %f", dest->top); + break; + + case fitvisibleheight: + pdc_printf(p->out, "/FitBV %f", dest->left); + break; + + default: + break; + } + + pdc_puts(p->out, "]"); +} + +static void +pdf_write_outline_dict(PDF *p, int entry) +{ + pdf_dest *dest = &p->outlines[entry].dest; + + pdc_begin_obj(p->out, SELF(entry)); /* outline object */ + pdc_begin_dict(p->out); + + pdc_printf(p->out, "/Parent %ld 0 R\n", SELF(PARENT(entry))); + + /* outline destination */ + if (dest->filename == NULL) + { + pdc_puts(p->out, "/Dest"); + pdf_write_destination(p, dest); + pdc_puts(p->out, "\n"); + } + else + { + pdc_puts(p->out, "/A"); + pdc_begin_dict(p->out); /* A dict */ + pdc_puts(p->out, "/Type/Action/S/Launch\n"); + pdc_puts(p->out, "/F"); + pdc_begin_dict(p->out); /* F dict */ + pdc_puts(p->out, "/Type/Filespec\n"); + pdc_printf(p->out, "/F"); + pdc_put_pdfstring(p->out, dest->filename, + (int) strlen(dest->filename)); + pdc_puts(p->out, "\n"); + pdc_end_dict(p->out); /* F dict */ + pdc_end_dict(p->out); /* A dict */ + } + + pdc_puts(p->out, "/Title"); /* outline text */ + pdc_put_pdfunistring(p->out, p->outlines[entry].text); + pdc_puts(p->out, "\n"); + + if (PREV(entry)) + pdc_printf(p->out, "/Prev %ld 0 R\n", PREV(entry)); + if (NEXT(entry)) + pdc_printf(p->out, "/Next %ld 0 R\n", NEXT(entry)); + + if (FIRST(entry)) { + pdc_printf(p->out, "/First %ld 0 R\n", SELF(FIRST(entry))); + pdc_printf(p->out, "/Last %ld 0 R\n", SELF(LAST(entry))); + } + if (COUNT(entry)) { + if (OPEN(entry)) + pdc_printf(p->out, "/Count %d\n", COUNT(entry)); /* open */ + else + pdc_printf(p->out, "/Count %d\n", -COUNT(entry));/* closed */ + } + + /* Color */ + if (dest->color[0] != 0.0 || dest->color[1] != 0.0 || dest->color[2] != 0.0) + pdc_printf(p->out, "/C [%f %f %f]\n", + dest->color[0], dest->color[1], dest->color[2]); + + /* FontStyle */ + if (dest->fontstyle != pdc_Normal) + { + int fontstyle = 0; + if (dest->fontstyle == pdc_Bold) + fontstyle = 2; + if (dest->fontstyle == pdc_Italic) + fontstyle = 1; + if (dest->fontstyle == pdc_BoldItalic) + fontstyle = 3; + pdc_printf(p->out, "/F %d\n", fontstyle); + } + + pdc_end_dict(p->out); + pdc_end_obj(p->out); /* outline object */ +} + +void +pdf_write_outlines(PDF *p) +{ + int i; + + if (p->outline_count == 0) /* no outlines: return */ + return; + + pdc_begin_obj(p->out, p->outlines[0].self); /* root outline object */ + pdc_begin_dict(p->out); + + if (p->outlines[0].count != 0) + pdc_printf(p->out, "/Count %d\n", COUNT(0)); + pdc_printf(p->out, "/First %ld 0 R\n", SELF(FIRST(0))); + pdc_printf(p->out, "/Last %ld 0 R\n", SELF(LAST(0))); + + pdc_end_dict(p->out); + pdc_end_obj(p->out); /* root outline object */ + +#define PDF_FLUSH_AFTER_MANY_OUTLINES 1000 /* ca. 50-100 KB */ + for (i = 1; i <= p->outline_count; i++) { + /* reduce memory usage for many outline entries */ + if (i % PDF_FLUSH_AFTER_MANY_OUTLINES) + pdc_flush_stream(p->out); + + pdf_write_outline_dict(p, i); + } +} + +void +pdf_write_outline_root(PDF *p) +{ + if (p->outline_count != 0) + pdc_printf(p->out, "/Outlines %ld 0 R\n", p->outlines[0].self); +} + +static int +pdf__add_bookmark(PDF *p, const char *text, int len, int parent, int open) +{ + pdf_outline *self; /* newly created outline */ + char *outtext; + + if (parent < 0 || parent > p->outline_count) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "parent", pdc_errprintf(p->pdc, "%d", parent), 0, 0); + + /* convert text string */ + outtext = pdf_convert_hypertext(p, text, len); + if (!outtext) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "text", 0, 0, 0); + + /* create the root outline object */ + if (p->outline_count == 0) { + p->outlines = (pdf_outline *) pdc_calloc(p->pdc, + sizeof(pdf_outline) * OUTLINE_CHUNKSIZE, "PDF_add_bookmark"); + p->outline_capacity = OUTLINE_CHUNKSIZE; + + /* populate the root outline object */ + p->outlines[0].self = pdc_alloc_id(p->out); + p->outlines[0].count = 0; + p->outlines[0].parent = 0; + p->outlines[0].open = 1; + + /* set the open mode show bookmarks if we have at least one, + * and the client didn't already set his own open mode. + */ + if (p->open_mode == open_auto) + p->open_mode = open_bookmarks; + } + + /* + * It's crucial to increase p->outline_count only after + * successfully having realloc()ed. Otherwise the error handler + * may try to free too much if the realloc goes wrong. + */ + if (p->outline_count+1 >= p->outline_capacity) { /* used up all space */ + p->outlines = (pdf_outline *) pdc_realloc(p->pdc, p->outlines, + sizeof(pdf_outline) * 2 * p->outline_capacity, + "PDF_add_bookmark"); + p->outline_capacity *= 2; + } + + p->outline_count++; + + self = &p->outlines[p->outline_count]; + + self->text = outtext; + + /* If the global parameter doesn't say otherwise we link to the + * current page. + */ + pdf_copy_destination(p, &self->dest, &p->bookmark_dest); + + /* 0 is a shortcut for "current page" */ + if (self->dest.page == 0) + self->dest.page = p->current_page; + + self->self = pdc_alloc_id(p->out); + self->first = 0; + self->last = 0; + self->prev = 0; + self->next = 0; + self->count = 0; + self->open = open; + self->parent = parent; + + /* insert new outline at the end of the chain or start a new chain */ + if (FIRST(parent) == 0) { + FIRST(parent) = p->outline_count; + } else { + self->prev = SELF(LAST(parent)); + NEXT(LAST(parent))= self->self; + } + + /* insert new outline as last child of parent in all cases */ + LAST(parent) = p->outline_count; + + /* increase the number of open sub-entries for all relevant ancestors */ + do { + COUNT(parent)++; + } while (OPEN(parent) && (parent = PARENT(parent)) != 0); + + return (p->outline_count); /* caller may use this as handle */ +} + +PDFLIB_API int PDFLIB_CALL +PDF_add_bookmark(PDF *p, const char *text, int parent, int open) +{ + static const char fn[] = "PDF_add_bookmark"; + int retval = 0; + + if (pdf_enter_api(p, fn, pdf_state_page, "(p[%p], \"%s\", %d, %d)", + (void *) p, pdc_strprint(p->pdc, text, 0), parent, open)) + { + int len = text ? (int) pdc_strlen(text) : 0; + retval = pdf__add_bookmark(p, text, len, parent, open); + } + pdc_trace(p->pdc, "[%d]\n", retval); + return retval; +} + +PDFLIB_API int PDFLIB_CALL +PDF_add_bookmark2(PDF *p, const char *text, int len, int parent, int open) +{ + static const char fn[] = "PDF_add_bookmark2"; + int retval = 0; + + if (pdf_enter_api(p, fn, pdf_state_page, "(p[%p], \"%s\", %d, %d, %d)", + (void *) p, pdc_strprint(p->pdc, text, len), len, parent, open)) + { + retval = pdf__add_bookmark(p, text, len, parent, open); + } + pdc_trace(p->pdc, "[%d]\n", retval); + return retval; +} + +void +pdf_feed_digest_info(PDF *p) +{ + pdf_info *info; + + if (p->Keywords) + pdc_update_digest(p->out, + (unsigned char *) p->Keywords, strlen(p->Keywords)); + + if (p->Subject) + pdc_update_digest(p->out, + (unsigned char *) p->Subject, strlen(p->Subject)); + + if (p->Title) + pdc_update_digest(p->out, + (unsigned char *) p->Title, strlen(p->Title)); + + if (p->Creator) + pdc_update_digest(p->out, + (unsigned char *) p->Creator, strlen(p->Creator)); + + if (p->Author) + pdc_update_digest(p->out, + (unsigned char *) p->Author, strlen(p->Author)); + + if (p->userinfo) { + for (info = p->userinfo; info != NULL; info = info->next) { + pdc_update_digest(p->out, + (unsigned char *) info->key, strlen(info->key)); + } + } +} + +void +pdf_init_info(PDF *p) +{ + p->Keywords = NULL; + p->Subject = NULL; + p->Title = NULL; + p->Creator = NULL; + p->Author = NULL; + p->userinfo = NULL; + + pdc_get_timestr(p->time_str); +} + +#define PDF_TRAPPED_TRUE "\124\162\165\145" +#define PDF_TRAPPED_FALSE "\106\141\154\163\145" +#define PDF_TRAPPED_UNKNOWN "\125\156\153\156\157\167\156" + +/* Set Info dictionary entries */ +static void +pdf__set_info(PDF *p, const char *key, const char *value, int len) +{ + static const char fn[] = "pdf__set_info"; + char *key_buf, *val_buf; + pdf_info *newentry; + + if (key == NULL || !*key) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "key", 0, 0, 0); + + if (!strcmp(key, "Producer") || !strcmp(key, "CreationDate") || + !strcmp(key, "ModDate")) + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "key", key, 0, 0); + + /* convert text string */ + val_buf = pdf_convert_hypertext(p, value, len); + if (!val_buf) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "value", 0, 0, 0); + + /* key_buf will be converted in pdf_printf() */ + key_buf = pdc_strdup(p->pdc, key); + if (!strcmp(key_buf, "Keywords")) { + if (p->Keywords) + pdc_free(p->pdc, p->Keywords); + p->Keywords = val_buf; + } else if (!strcmp(key_buf, "Subject")) { + if (p->Subject) + pdc_free(p->pdc, p->Subject); + p->Subject = val_buf; + } else if (!strcmp(key_buf, "Title")) { + if (p->Title) + pdc_free(p->pdc, p->Title); + p->Title = val_buf; + } else if (!strcmp(key_buf, "Creator")) { + if (p->Creator) + pdc_free(p->pdc, p->Creator); + p->Creator = val_buf; + } else if (!strcmp(key_buf, "Author")) { + if (p->Author) + pdc_free(p->pdc, p->Author); + p->Author = val_buf; + } else { /* user-defined keyword */ + /* special handling required for "Trapped" */ + if (!strcmp(key_buf, "Trapped")) { + if (strcmp(val_buf, PDF_TRAPPED_TRUE) && + strcmp(val_buf, PDF_TRAPPED_FALSE) && + strcmp(val_buf, PDF_TRAPPED_UNKNOWN)) + { + pdc_free(p->pdc, val_buf); + pdc_free(p->pdc, key_buf); + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + } + } + + newentry = (pdf_info *) + pdc_malloc(p->pdc, sizeof(pdf_info), fn); + newentry->key = key_buf; + newentry->value = val_buf; + newentry->next = p->userinfo; + + /* ordering doesn't matter so we insert at the beginning */ + p->userinfo = newentry; + + return; + } + + pdc_free(p->pdc, key_buf); +} + +/* Set Info dictionary entries */ +PDFLIB_API void PDFLIB_CALL +PDF_set_info(PDF *p, const char *key, const char *value) +{ + static const char fn[] = "PDF_set_info"; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page), + "\t(p[%p], \"%s\", \"%s\")\n", + (void *) p, key, pdc_strprint(p->pdc, value, 0))) + { + int len = value ? (int) pdc_strlen(value) : 0; + pdf__set_info(p, key, value, len); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_set_info2(PDF *p, const char *key, const char *value, int len) +{ + static const char fn[] = "PDF_set_info2"; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page), + "(p[%p], \"%s\", \"%s\", %d)\n", + (void *) p, key, pdc_strprint(p->pdc, value, len), len)) + { + pdf__set_info(p, key, value, len); + } +} + +static void +pdf_init_names(PDF *p) +{ + int i; + + p->names_number = 0; + p->names_capacity = NAMES_CHUNKSIZE; + + p->names = (pdf_name *) pdc_malloc(p->pdc, + sizeof(pdf_name) * p->names_capacity, "pdf_init_names"); + + for (i = 0; i < p->names_capacity; i++) { + p->names[i].obj_id = PDC_BAD_ID; + p->names[i].name = NULL; + p->names[i].len = 0; + } +} + +static void +pdf_grow_names(PDF *p) +{ + int i; + + p->names = (pdf_name *) pdc_realloc(p->pdc, p->names, + sizeof(pdf_name) * 2 * p->names_capacity, "pdf_grow_names"); + + for (i = p->names_capacity; i < 2 * p->names_capacity; i++) { + p->names[i].obj_id = PDC_BAD_ID; + p->names[i].name = NULL; + p->names[i].len = 0; + } + + p->names_capacity *= 2; +} + +void +pdf_cleanup_names(PDF *p) +{ + int i; + + if (p->names == NULL) + return; + + for (i = 0; i < p->names_number; i++) { + pdc_free(p->pdc, p->names[i].name); + } + + pdc_free(p->pdc, p->names); + p->names = NULL; +} + +static int +name_compare( const void* a, const void* b) +{ + pdf_name *p1 = (pdf_name *) a; + pdf_name *p2 = (pdf_name *) b; + + return strcmp(p1->name, p2->name); +} + +pdc_id +pdf_write_names(PDF *p) +{ + pdc_id ret; + int i; + + /* nothing to do */ + if (p->names_number == 0) + return PDC_BAD_ID; + + + ret = pdc_begin_obj(p->out, PDC_NEW_ID); /* Names object */ + + qsort(p->names, (size_t) p->names_number, sizeof(pdf_name), name_compare); + + pdc_begin_dict(p->out); /* Node dict */ + + /* TODO: construct a balanced tree instead of a linear list */ + pdc_puts(p->out, "/Limits["); + pdc_put_pdfstring(p->out, p->names[0].name, p->names[0].len); + pdc_put_pdfstring(p->out, p->names[p->names_number-1].name, + p->names[p->names_number-1].len); + pdc_puts(p->out, "]\n"); + + pdc_puts(p->out, "/Names["); + + for (i = 0; i < p->names_number; i++) { + pdc_put_pdfstring(p->out, p->names[i].name, p->names[i].len); + pdc_printf(p->out, "%ld 0 R\n", p->names[i].obj_id); + } + + pdc_puts(p->out, "]"); + + pdc_end_dict(p->out); /* Node dict */ + + pdc_end_obj(p->out); /* Names object */ + + return ret; +} + +PDFLIB_API void PDFLIB_CALL +PDF_add_nameddest( + PDF *p, + const char *name, + int reserved, + const char *optlist) +{ + static const char fn[] = "PDF_add_nameddest"; + pdf_dest dest; + int i; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_page | pdf_state_document), + "(p[%p], %s, %d, \"%s\")\n", + (void *) p, name, reserved, optlist)) + { + return; + } + + if (!name || !*name) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "name", 0, 0, 0); + + if (p->names == NULL) + pdf_init_names(p); + + for (i = 0; i < p->names_number; i++) { + if (!strcmp(p->names[i].name, name)) + /* silently ignore duplicate destination names */ + return; + } + + if (p->names_number == p->names_capacity) + pdf_grow_names(p); + + pdf_parse_destination_optlist(p, optlist, &dest, 0, pdf_nameddest); + + /* interrupt the content stream if we are on a page */ + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_end_contents_section(p); + /* Dest object */ + p->names[p->names_number].obj_id = pdc_begin_obj(p->out, PDC_NEW_ID); + p->names[p->names_number].name = (char *) pdc_strdup(p->pdc, name); + p->names[p->names_number].len = (int) strlen(name); + p->names_number++; + + pdc_begin_dict(p->out); /* Destination dict */ + + pdc_puts(p->out, "/D"); + pdf_write_destination(p, &dest); + pdc_puts(p->out, "\n"); + + pdc_end_dict(p->out); /* Destination dict */ + pdc_end_obj(p->out); /* Dest object */ + + /* continue the contents stream */ + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_begin_contents_section(p); +} + + + +pdc_id +pdf_write_info(PDF *p) +{ + char producer[256]; + pdf_info *info; + pdc_id info_id; + char * product = "PDFlib Lite"; + + info_id = pdc_begin_obj(p->out, PDC_NEW_ID); /* Info object */ + + pdc_begin_dict(p->out); + + /* + * Although it would be syntactically correct, we must not remove + * the space characters after the dictionary keys since this + * would break the PDF properties feature in Windows Explorer. + */ + + if (p->Keywords) { + pdc_puts(p->out, "/Keywords "); + pdc_put_pdfunistring(p->out, p->Keywords); + pdc_puts(p->out, "\n"); + } + if (p->Subject) { + pdc_puts(p->out, "/Subject "); + pdc_put_pdfunistring(p->out, p->Subject); + pdc_puts(p->out, "\n"); + } + if (p->Title) { + pdc_puts(p->out, "/Title "); + pdc_put_pdfunistring(p->out, p->Title); + pdc_puts(p->out, "\n"); + } + if (p->Creator) { + pdc_puts(p->out, "/Creator "); + pdc_put_pdfunistring(p->out, p->Creator); + pdc_puts(p->out, "\n"); + } + if (p->Author) { + pdc_puts(p->out, "/Author "); + pdc_put_pdfunistring(p->out, p->Author); + pdc_puts(p->out, "\n"); + } + if (p->userinfo) { + for (info = p->userinfo; info != NULL; info = info->next) { + pdc_put_pdfname(p->out, info->key, strlen(info->key)); + pdc_puts(p->out, " "); + + if (strcmp(info->key, "Trapped")) { + pdc_put_pdfunistring(p->out, info->value); + } else { + /* "Trapped" value is already encoded in PDFDocEncoding */ + pdc_put_pdfname(p->out, info->value, strlen(info->value)); + } + + pdc_puts(p->out, "\n"); + } + } + + pdc_puts(p->out, "/CreationDate "); + pdc_put_pdfstring(p->out, p->time_str, (int) strlen(p->time_str)); + pdc_puts(p->out, "\n"); + + + /* + * If you change the /Producer entry your license to use + * PDFlib will be void! + */ + + if (p->binding) + sprintf(producer, "%s %s (%s/%s)", product, + PDFLIB_VERSIONSTRING, p->binding, PDF_PLATFORM); + else + sprintf(producer, "%s %s (%s)", product, + PDFLIB_VERSIONSTRING, PDF_PLATFORM); + + pdc_puts(p->out, "/Producer "); + pdc_put_pdfstring(p->out, producer, (int) strlen(producer)); + pdc_puts(p->out, "\n"); + + pdc_end_dict(p->out); + pdc_end_obj(p->out); /* Info object */ + + return info_id; +} + +void +pdf_cleanup_info(PDF *p) +{ + pdf_info *info, *last; + + /* Free Info dictionary entries */ + if (p->Keywords) { + pdc_free(p->pdc, p->Keywords); + p->Keywords = NULL; + } + if (p->Subject) { + pdc_free(p->pdc, p->Subject); + p->Subject = NULL; + } + if (p->Title) { + pdc_free(p->pdc, p->Title); + p->Title = NULL; + } + if (p->Creator) { + pdc_free(p->pdc, p->Creator); + p->Creator = NULL; + } + if (p->Author) { + pdc_free(p->pdc, p->Author); + p->Author = NULL; + } + if (p->userinfo) { + for (info = p->userinfo; info != NULL; /* */) { + last = info; + info = info->next; + + pdc_free(p->pdc, last->key); + pdc_free(p->pdc, last->value); + pdc_free(p->pdc, last); + } + p->userinfo = NULL; + } +} + +/* Page transition effects */ + +static const pdc_keyconn pdf_transition_keylist[] = +{ + {"none", trans_none}, + {"split", trans_split}, + {"blinds", trans_blinds}, + {"box", trans_box}, + {"wipe", trans_wipe}, + {"dissolve", trans_dissolve}, + {"glitter", trans_glitter}, + {"replace", trans_replace}, + {NULL, 0} +}; + +static const pdc_keyconn pdf_transition_pdfkeylist[] = +{ + {"", trans_none}, + {"Split", trans_split}, + {"Blinds", trans_blinds}, + {"Box", trans_box}, + {"Wipe", trans_wipe}, + {"Dissolve", trans_dissolve}, + {"Glitter", trans_glitter}, + {"R", trans_replace}, + {NULL, 0} +}; + +void +pdf_init_transition(PDF *p) +{ + p->transition = trans_none; + p->duration = 0; +} + +/* set page display duration for current and future pages */ +void +pdf_set_duration(PDF *p, float t) +{ + p->duration = t; +} + +void +pdf_write_page_transition(PDF *p) +{ + if (p->transition != trans_none) { + pdc_puts(p->out, "/Trans"); + pdc_begin_dict(p->out); + pdc_printf(p->out, "/S/%s", + pdc_get_keyword(p->transition, pdf_transition_pdfkeylist)); + + pdc_end_dict(p->out); + } +} + +/* set transition mode for current and future pages */ + +void +pdf_set_transition(PDF *p, const char *type) +{ + if (type == NULL || !*type) + type = "none"; + p->transition = + (pdf_transition) pdc_get_keycode(type, pdf_transition_keylist); + if (p->transition == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, type, "transition", 0, 0); +} + +char * +pdf_convert_hypertext(PDF *p, const char *text, int len) +{ + pdc_encoding enc; + pdc_encodingvector *ev = NULL; + pdc_encodingvector *ev_pdfdoc = NULL; + pdc_byte *outtext = NULL; + pdc_text_format textformat = pdc_utf16be; + int outlen; + + if (text && len == 0) + len = (int) strlen(text); + if (text == NULL || len <= 0) + return NULL; + + /* encoding struct available */ + if (p->encodings) + { + /* User encoding */ + enc = p->hypertextencoding; + if (enc == pdc_invalidenc) + enc = pdf_find_encoding(p, "auto"); + if (enc == pdc_invalidenc) + enc = pdf_insert_encoding(p, "auto"); + if (enc >= 0) + ev = p->encodings[enc].ev; + + /* PDFDocEncoding */ + ev_pdfdoc = p->encodings[pdc_pdfdoc].ev; + if (ev_pdfdoc == NULL) + { + pdf_find_encoding(p, "pdfdoc"); + ev_pdfdoc = p->encodings[pdc_pdfdoc].ev; + } + } + + /* Convert hypertext string */ + pdc_convert_string(p->pdc, p->hypertextformat, ev, (pdc_byte *)text, len, + &textformat, ev_pdfdoc, &outtext, &outlen, + PDC_CONV_WITHBOM | PDC_CONV_TRYBYTES, pdc_true); + + return (char *) outtext; +} diff --git a/src/libs/pdflib/libs/pdflib/p_icc.c b/src/libs/pdflib/libs/pdflib/p_icc.c new file mode 100644 index 0000000000..234cfb6a89 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_icc.c @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_icc.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib ICC handling routines + * + * This software is based in part on the work of Graeme W. Gill + * + */ + +#include "p_intern.h" + +#if defined(WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif + + +PDFLIB_API int PDFLIB_CALL +PDF_load_iccprofile(PDF *p, const char *profilename, int reserved, + const char *optlist) +{ + static const char fn[] = "PDF_load_iccprofile"; + int slot = -1; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_content), + "(p[%p], \"%s\", %d, \"%s\")", + (void *) p, profilename, reserved, optlist)) + { + PDF_RETURN_HANDLE(p, slot) + } + + pdc_warning(p->pdc, PDF_E_UNSUPP_ICC, 0, 0, 0, 0); + + PDF_RETURN_HANDLE(p, slot) +} + diff --git a/src/libs/pdflib/libs/pdflib/p_icc.h b/src/libs/pdflib/libs/pdflib/p_icc.h new file mode 100644 index 0000000000..13617fbee9 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_icc.h @@ -0,0 +1,24 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_icc.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib ICC typedefs, structures, and enums + * + */ + +#ifndef P_ICC_H +#define P_ICC_H + + +#endif /* P_ICC_H */ + diff --git a/src/libs/pdflib/libs/pdflib/p_icc9809.h b/src/libs/pdflib/libs/pdflib/p_icc9809.h new file mode 100644 index 0000000000..9ab9299798 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_icc9809.h @@ -0,0 +1,38 @@ +/* $Id: p_icc9809.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * Header file of ICC (name see note above) for ICClib and PDFlib + * + */ + +/* + * Note: Modified for use by icclib V2.00: + * + * Changed guard bands from ICC_H to ICC9809_H + * + * Replace tag last values 0xFFFFFFFFL with define icMaxTagVal, + * and define this to be -1, for better compiler compatibility. + * + * Add section to use machine specific INR & ORD to define + * the sizes of ic Numbers, if ORD is defined. + * + * Adding colorspaces 'MCH5-8' for Hexachrome and others. (Colorsync ?) + * Added the Positive/Negative and Color/BlackAndWhite Attribute bits + * + * I believe icMeasurementFlare as an enumeration is bogus in + * this file. It is meant to be a u16.16 number. + * + * Add Chromaticity Tag and Type from ICC.1A:1999-04, + * but there is no formal "icc.h" from the ICC that indicates + * what the names should be. + * + * Added Colorsync 2.5 specific VideoCardGamma defines. + * + * Graeme Gill. + */ + +/* Header file guard bands */ +#ifndef P_ICC9809_H +#define P_ICC9809_H + + +#endif /* P_ICC9809_H */ diff --git a/src/libs/pdflib/libs/pdflib/p_icclib.c b/src/libs/pdflib/libs/pdflib/p_icclib.c new file mode 100644 index 0000000000..cf91139280 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_icclib.c @@ -0,0 +1,35 @@ +/* $Id: p_icclib.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * ICClib routines for PDFlib, slightly modified from the original ICClib. + * (see below). + * + */ + +/* + * International Color Consortium Format Library (icclib) + * For ICC profile version 3.4 + * + * Author: Graeme W. Gill + * Date: 2002/04/22 + * Version: 2.02 + * + * Copyright 1997 - 2002 Graeme W. Gill + * See Licence.txt file for conditions of use. + */ + +#include +#include +#include +#include +#include +#include +#include +#ifdef __sun +#include +#endif +#if defined(__IBMC__) && defined(_M_IX86) +#include +#endif + +/* PDFlib */ +#include "pc_core.h" diff --git a/src/libs/pdflib/libs/pdflib/p_icclib.h b/src/libs/pdflib/libs/pdflib/p_icclib.h new file mode 100644 index 0000000000..b730892a94 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_icclib.h @@ -0,0 +1,19 @@ +/* $Id: p_icclib.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * ICClib Header file icc.h for PDFlib + * + * $Log: p_icclib.h,v $ + * Revision 1.1 2004/10/06 17:46:49 laplace + * Added PDFlib lite 5.0.3 which is required to build the PDF printer driver. + * + * Revision 1.10 2003/03/03 12:46:43 tm + * Changed the licensing comment. + * + */ + +#ifndef P_ICCLIB_H +#define P_ICCLIB_H + + +#endif /* P_ICCLIB_H */ + diff --git a/src/libs/pdflib/libs/pdflib/p_image.c b/src/libs/pdflib/libs/pdflib/p_image.c new file mode 100644 index 0000000000..efc4fe074d --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_image.c @@ -0,0 +1,1762 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_image.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib image routines + * + */ + +#define P_IMAGE_C + +#include "p_intern.h" +#include "p_image.h" +#include "p_font.h" + +/* must be kept in sync with the pdf_compression enum in p_intern.h */ +static const char *pdf_filter_names[] = { + "", "LZWDecode", "RunLengthDecode", "CCITTFaxDecode", + "DCTDecode", "FlateDecode", "JBIG2Decode" +}; + +static const char *pdf_short_filter_names[] = { + "", "LZW", "RL", "CCF", "DCT", "Fl", "" +}; + +static void +pdf_init_image_struct(PDF *p, pdf_image *image) +{ + (void) p; + + /********** option variables *************/ + image->verbose = pdc_true; + image->bitreverse = pdc_false; + image->bpc = pdc_undef; + image->components = pdc_undef; + image->height_pixel = pdc_undef; + image->ignoremask = pdc_false; + image->doinline = pdc_false; + image->interpolate = pdc_false; + image->invert = pdc_false; + image->K = 0; + image->imagemask = pdc_false; + image->mask = pdc_undef; + image->ri = AutoIntent; + image->page = 1; + image->reference = pdf_ref_direct; + image->width_pixel = pdc_undef; + /*****************************************/ + + image->transparent = pdc_false; + image->compression = none; + image->predictor = pred_default; + image->in_use = pdc_false; + image->fp = (pdc_file *) NULL; + image->filename = (char *) NULL; + image->params = (char *) NULL; + image->dpi_x = (float) 0; + image->dpi_y = (float) 0; + image->strips = 1; + image->rowsperstrip = 1; + image->colorspace = pdc_undef; + image->dochandle = pdc_undef; /* this means "not a PDI page" */ + image->use_raw = pdc_false; + image->transval[0] = 0; + image->transval[1] = 0; + image->transval[2] = 0; + image->transval[3] = 0; +} + +void +pdf_init_images(PDF *p) +{ + int im; + + p->images_capacity = IMAGES_CHUNKSIZE; + + p->images = (pdf_image *) + pdc_malloc(p->pdc, + sizeof(pdf_image) * p->images_capacity, "pdf_init_images"); + + for (im = 0; im < p->images_capacity; im++) + pdf_init_image_struct(p, &(p->images[im])); +} + +void +pdf_grow_images(PDF *p) +{ + int im; + + p->images = (pdf_image *) pdc_realloc(p->pdc, p->images, + sizeof(pdf_image) * 2 * p->images_capacity, "pdf_grow_images"); + + for (im = p->images_capacity; im < 2 * p->images_capacity; im++) + pdf_init_image_struct(p, &(p->images[im])); + + p->images_capacity *= 2; +} + +void +pdf_cleanup_image(PDF *p, int im) +{ + /* clean up parameter string if necessary */ + if (p->images[im].params) { + pdc_free(p->pdc, p->images[im].params); + p->images[im].params = NULL; + } + + if (p->images[im].filename) { + pdc_free(p->pdc, p->images[im].filename); + p->images[im].filename = NULL; + } + + if (p->images[im].fp) { + pdc_fclose(p->images[im].fp); + p->images[im].fp = NULL; + } + + /* free the image slot and prepare for next use */ + pdf_init_image_struct(p, &(p->images[im])); +} + +void +pdf_cleanup_images(PDF *p) +{ + int im; + + if (!p->images) + return; + + /* Free images which the caller left open */ + + /* When we think of inter-document survival of images, + ** we MUST NOT FORGET that the current TIFF algorithm + ** depends on contiguous image slots for the image strips! + */ + for (im = 0; im < p->images_capacity; im++) + { + pdf_image *img = &p->images[im]; + + if (img->in_use) /* found used slot */ + pdf_cleanup_image(p, im); /* free image descriptor */ + } + + pdc_free(p->pdc, p->images); + p->images = NULL; +} + +void +pdf_init_xobjects(PDF *p) +{ + int idx; + + p->xobjects_number = 0; + + if (p->xobjects == (pdf_xobject *) 0) + { + p->xobjects_capacity = XOBJECTS_CHUNKSIZE; + + p->xobjects = (pdf_xobject *) + pdc_malloc(p->pdc, sizeof(pdf_xobject) * p->xobjects_capacity, + "pdf_init_xobjects"); + } + + for (idx = 0; idx < p->xobjects_capacity; idx++) + p->xobjects[idx].flags = 0; +} + +int +pdf_new_xobject(PDF *p, pdf_xobj_type type, pdc_id obj_id) +{ + static const char fn[] = "pdf_new_xobject"; + int i, slot = p->xobjects_number++; + + if (slot == p->xobjects_capacity) + { + p->xobjects = (pdf_xobject *) pdc_realloc(p->pdc, p->xobjects, + sizeof(pdf_xobject) * 2 * p->xobjects_capacity, fn); + + for (i = p->xobjects_capacity; i < 2 * p->xobjects_capacity; i++) + p->xobjects[i].flags = 0; + + p->xobjects_capacity *= 2; + } + + if (obj_id == PDC_NEW_ID) + obj_id = pdc_begin_obj(p->out, PDC_NEW_ID); + + p->xobjects[slot].obj_id = obj_id; + p->xobjects[slot].type = type; + p->xobjects[slot].flags = xobj_flag_used; + + return slot; +} + +void +pdf_write_xobjects(PDF *p) +{ + if (p->xobjects_number > 0) + { + pdc_bool hit = pdc_false; + int i; + + for (i = 0; i < p->xobjects_capacity; ++i) + { + if (p->xobjects[i].flags & xobj_flag_write) + { + if (!hit) + { + pdc_puts(p->out, "/XObject"); + pdc_begin_dict(p->out); + hit = pdc_true; + } + + pdc_printf(p->out, "/I%d %ld 0 R\n", i, p->xobjects[i].obj_id); + p->xobjects[i].flags &= ~xobj_flag_write; + } + } + + if (hit) + pdc_end_dict(p->out); + } +} + +void +pdf_cleanup_xobjects(PDF *p) +{ + if (p->xobjects) { + pdc_free(p->pdc, p->xobjects); + p->xobjects = NULL; + } +} + +void +pdf_put_inline_image(PDF *p, int im) +{ + pdf_image *image; + pdc_matrix m; + PDF_data_source *src; + int i; + + image = &p->images[im]; + + /* Image object */ + + image->no = -1; + + pdf__save(p); + + pdc_scale_matrix(image->width, image->height, &m); + + pdf_concat_raw(p, &m); + + pdc_puts(p->out, "BI"); + + pdc_printf(p->out, "/W %d", (int) image->width); + pdc_printf(p->out, "/H %d", (int) image->height); + + if (image->imagemask == pdc_true) { + pdc_puts(p->out, "/IM true"); + + } else { + + pdc_printf(p->out, "/BPC %d", image->bpc); + + switch (p->colorspaces[image->colorspace].type) { + case DeviceGray: + pdc_printf(p->out, "/CS/G"); + break; + + case DeviceRGB: + pdc_printf(p->out, "/CS/RGB"); + break; + + case DeviceCMYK: + pdc_printf(p->out, "/CS/CMYK"); + break; + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", image->colorspace), 0, 0, 0); + break; + } + } + + if (image->compression != none) { + pdc_printf(p->out, "/F/%s", + pdf_short_filter_names[image->compression]); + } + + /* prepare precompressed (raw) image data */ + if (image->use_raw && + (image->params || + image->predictor != pred_default || + image->compression == ccitt)) { + + pdc_printf(p->out, "/DP[<<"); + + /* write EarlyChange */ + if (image->params) + pdc_puts(p->out, image->params); + + if (image->compression == ccitt) { + if (image->K != 0) + pdc_printf(p->out, "/K %d", image->K); + } + + if (image->compression == flate || image->compression == lzw) { + if (image->predictor != pred_default) { + pdc_printf(p->out, "/Predictor %d", (int) image->predictor); + pdc_printf(p->out, "/Columns %d", (int) image->width); + if (image->bpc != 8) + pdc_printf(p->out, "/BitsPerComponent %d", image->bpc); + + if (image->components != 1) /* 1 is default */ + pdc_printf(p->out, "/Colors %d", image->components); + } + } + + if (image->compression == ccitt) { + if ((int) image->width != 1728) /* CCITT default width */ + pdc_printf(p->out, "/Columns %d", (int) image->width); + + pdc_printf(p->out, "/Rows %d", (int) fabs(image->height)); + } + pdc_puts(p->out, ">>]"); /* DecodeParms dict and array */ + } + + if (image->invert) { + pdc_puts(p->out, "/D[1 0"); + for (i = 1; i < image->components; i++) + pdc_puts(p->out, " 1 0"); + pdc_puts(p->out, "]"); + } + + if (image->ri != AutoIntent) { + pdc_printf(p->out, "/Intent/%s", + pdc_get_keyword(image->ri, gs_renderingintents)); + } + + if (image->interpolate) { + pdc_puts(p->out, "/I true"); + } + + pdc_puts(p->out, " ID\n"); + + /* Write the actual image data to the content stream */ + + src = &image->src; + + /* We can't use pdf_copy_stream() here because it automatically + * generates a stream object, which is not correct for inline + * image data. + */ + if (src->init) + src->init(p, src); + + while (src->fill(p, src)) + pdc_write(p->out, src->next_byte, src->bytes_available); + + if (src->terminate) + src->terminate(p, src); + + pdc_puts(p->out, "EI\n"); + + pdf__restore(p); + + /* Do the equivalent of PDF_close_image() since the image handle + * cannot be re-used anyway. + */ + pdf_cleanup_image(p, im); +} + +void +pdf_put_image(PDF *p, int im, pdc_bool firststrip) +{ + pdc_id length_id; + pdf_image *image; + int i; + + image = &p->images[im]; + + /* Images may also be written to the output before the first page */ + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_end_contents_section(p); + + /* Image object */ + + image->no = pdf_new_xobject(p, image_xobject, PDC_NEW_ID); + + pdc_begin_dict(p->out); /* XObject */ + + pdc_puts(p->out, "/Subtype/Image\n"); + + pdc_printf(p->out, "/Width %d\n", (int) image->width); + pdc_printf(p->out, "/Height %d\n", (int) fabs(image->height)); + + /* + * Transparency handling + */ + + /* Masking by color: single transparent color value */ + if (image->transparent) { + pdf_colorspace *cs = &p->colorspaces[image->colorspace]; + + switch (cs->type) { + case Indexed: + case DeviceGray: + pdc_printf(p->out,"/Mask[%d %d]\n", + (int) image->transval[0], (int) image->transval[0]); + break; + + + case DeviceRGB: + pdc_printf(p->out,"/Mask[%d %d %d %d %d %d]\n", + (int) image->transval[0], (int) image->transval[0], + (int) image->transval[1], (int) image->transval[1], + (int) image->transval[2], (int) image->transval[2]); + break; + + case DeviceCMYK: + pdc_printf(p->out,"/Mask[%d %d %d %d %d %d %d %d]\n", + (int) image->transval[0], (int) image->transval[0], + (int) image->transval[1], (int) image->transval[1], + (int) image->transval[2], (int) image->transval[2], + (int) image->transval[3], (int) image->transval[3]); + break; + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", + (int) p->colorspaces[image->colorspace].type), 0, 0, 0); + } + + /* Masking by position: separate bitmap mask */ + } else if (image->mask != pdc_undef && p->images[image->mask].bpc > 1) { + pdc_printf(p->out, "/SMask %ld 0 R\n", + p->xobjects[p->images[image->mask].no].obj_id); + + } else if (image->mask != pdc_undef) { + pdc_printf(p->out, "/Mask %ld 0 R\n", + p->xobjects[p->images[image->mask].no].obj_id); + } + + /* + * /BitsPerComponent is optional for image masks according to the + * PDF reference, but some viewers require it nevertheless. + * We must therefore always write it. + */ + pdc_printf(p->out, "/BitsPerComponent %d\n", image->bpc); + + if (image->imagemask) { + pdc_puts(p->out, "/ImageMask true\n"); + + } else { + + switch (p->colorspaces[image->colorspace].type) { + case DeviceGray: + break; + + case DeviceRGB: + break; + + case DeviceCMYK: + break; + + case Indexed: + break; + + + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", image->colorspace), 0, 0, 0); + } + + pdc_puts(p->out, "/ColorSpace"); + pdf_write_colorspace(p, image->colorspace, pdc_false); + pdc_puts(p->out, "\n"); + } + + if (image->invert) { + pdc_puts(p->out, "/Decode[1 0"); + for (i = 1; i < image->components; i++) + pdc_puts(p->out, " 1 0"); + pdc_puts(p->out, "]\n"); + } + + if (image->ri != AutoIntent) { + pdc_printf(p->out, "/Intent/%s\n", + pdc_get_keyword(image->ri, gs_renderingintents)); + } + + if (image->interpolate) { + pdc_puts(p->out, "/Interpolate true\n"); + } + + /* special case: referenced image data instead of direct data */ + if (image->reference != pdf_ref_direct) { + + if (image->compression != none) { + pdc_printf(p->out, "/FFilter[/%s]\n", + pdf_filter_names[image->compression]); + } + + if (image->compression == ccitt) { + pdc_puts(p->out, "/FDecodeParms[<<"); + + if ((int) image->width != 1728) /* CCITT default width */ + pdc_printf(p->out, "/Columns %d", (int) image->width); + + pdc_printf(p->out, "/Rows %d", (int) fabs(image->height)); + + if (image->K != 0) + pdc_printf(p->out, "/K %d", image->K); + + pdc_puts(p->out, ">>]\n"); + + } + + if (image->reference == pdf_ref_file) { + + /* LATER: make image file name platform-neutral: + * Change : to / on the Mac + * Change \ to / on Windows + */ + pdc_puts(p->out, "/F"); + pdc_put_pdfstring(p->out, image->filename, + (int) strlen(image->filename)); + pdc_puts(p->out, "/Length 0"); + + } else if (image->reference == pdf_ref_url) { + + pdc_puts(p->out, "/F<out, image->filename, + (int) strlen(image->filename)); + pdc_puts(p->out, ">>/Length 0"); + } + + pdc_end_dict(p->out); /* XObject */ + + /* We must avoid pdc_begin/end_pdfstream() here in order to + * generate a really empty stream. + */ + pdc_puts(p->out, "stream\n"); /* dummy image stream */ + pdc_puts(p->out, "endstream\n"); + + pdc_end_obj(p->out); /* XObject */ + + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_begin_contents_section(p); + + return; + } + + /* + * Now the (more common) handling of actual image + * data to be included in the PDF output. + */ + /* do we need a filter (either ASCII or decompression)? */ + + if (p->debug['a']) { + pdc_puts(p->out, "/Filter[/ASCIIHexDecode"); + if (image->compression != none) + pdc_printf(p->out, "/%s", pdf_filter_names[image->compression]); + pdc_puts(p->out, "]\n"); + + } else { + /* force compression if not a recognized precompressed image format */ + if (!image->use_raw && pdc_get_compresslevel(p->out)) + image->compression = flate; + + if (image->compression != none) + pdc_printf(p->out, "/Filter/%s\n", + pdf_filter_names[image->compression]); + } + + /* prepare precompressed (raw) image data; avoid empty DecodeParms */ + if (image->use_raw && + (image->params || + image->predictor != pred_default || + image->compression == ccitt)) { + + if (p->debug['a']) + pdc_printf(p->out, "/DecodeParms[%s<<", "null"); + else + pdc_printf(p->out, "/DecodeParms<<"); + + /* write EarlyChange */ + if (image->params) + pdc_puts(p->out, image->params); + + if (image->compression == ccitt) { + if (image->K != 0) + pdc_printf(p->out, "/K %d", image->K); + } + + if (image->compression == flate || image->compression == lzw) { + if (image->predictor != pred_default) { + pdc_printf(p->out, "/Predictor %d", (int) image->predictor); + pdc_printf(p->out, "/Columns %d", (int) image->width); + if (image->bpc != 8) + pdc_printf(p->out, "/BitsPerComponent %d", image->bpc); + + if (image->components != 1) /* 1 is default */ + pdc_printf(p->out, "/Colors %d", image->components); + } + } + + if (image->compression == ccitt) { + if ((int) image->width != 1728) /* CCITT default width */ + pdc_printf(p->out, "/Columns %d", (int) image->width); + + pdc_printf(p->out, "/Rows %d", (int) fabs(image->height)); + } + + if (p->debug['a']) + pdc_puts(p->out, ">>]\n"); /* DecodeParms dict and array */ + else + pdc_puts(p->out, ">>\n"); /* DecodeParms dict */ + } + + /* Write the actual image data */ + length_id = pdc_alloc_id(p->out); + + pdc_printf(p->out,"/Length %ld 0 R\n", length_id); + pdc_end_dict(p->out); /* XObject */ + + /* image data */ + + if (p->debug['a']) + pdf_ASCIIHexEncode(p, &image->src); + else { + pdf_copy_stream(p, &image->src, !image->use_raw); /* image data */ + } + + pdc_end_obj(p->out); /* XObject */ + + pdc_put_pdfstreamlength(p->out, length_id); + + if (p->flush & pdf_flush_content) + pdc_flush_stream(p->out); + + /* + * Write colormap information for indexed color spaces + */ + if (firststrip && p->colorspaces[image->colorspace].type == Indexed) { + pdf_write_colormap(p, image->colorspace); + } + + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_begin_contents_section(p); + + if (p->flush & pdf_flush_content) + pdc_flush_stream(p->out); +} + +void +pdf__fit_image(PDF *p, int im, float x, float y, const char *optlist) +{ + pdf_image *image; + int legal_states; + + pdf_check_handle(p, im, pdc_imagehandle); + + image = &p->images[im]; + + if (PDF_GET_STATE(p) == pdf_state_glyph && !pdf_get_t3colorized(p) && + image->imagemask == pdc_false) + legal_states = pdf_state_page | pdf_state_pattern | pdf_state_template; + else + legal_states = pdf_state_content; + PDF_CHECK_STATE(p, legal_states); + + if (PDF_GET_STATE(p) == pdf_state_template && im == p->templ) + pdc_error(p->pdc, PDF_E_TEMPLATE_SELF, + pdc_errprintf(p->pdc, "%d", im), 0, 0, 0); + + pdf_place_xobject(p, im, x, y, optlist); +} + +PDFLIB_API void PDFLIB_CALL +PDF_fit_image(PDF *p, int image, float x, float y, const char *optlist) +{ + static const char fn[] = "PDF_fit_image"; + + /* precise scope diagnosis in pdf__fit_image */ + if (pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], %d, %g, %g, \"%s\")\n", (void *) p, image, x, y, optlist)) + { + PDF_INPUT_HANDLE(p, image) + pdf__fit_image(p, image, x, y, optlist); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_place_image(PDF *p, int image, float x, float y, float scale) +{ + static const char fn[] = "PDF_place_image"; + + /* precise scope diagnosis in pdf__fit_image */ + if (pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], %d, %g, %g, %g)\n", (void *) p, image, x, y, scale)) + { + char optlist[32]; + sprintf(optlist, "dpi none scale %g", scale); + PDF_INPUT_HANDLE(p, image) + pdf__fit_image(p, image, x, y, optlist); + } +} + +/* definitions of place image options */ +static const pdc_defopt pdf_place_xobject_options[] = +{ + {"dpi", pdc_floatlist, 0, 1, 2, 0.0, INT_MAX, pdf_dpi_keylist}, + + {"scale", pdc_floatlist, PDC_OPT_NOZERO, 1, 2, PDC_FLOAT_MIN, PDC_FLOAT_MAX, + NULL}, + + {"orientate", pdc_keywordlist, 0, 1, 1, 0.0, 0.0, pdf_orientate_keylist}, + + {"boxsize", pdc_floatlist, 0, 2, 2, PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"rotate", pdc_floatlist, 0, 1, 1, PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"position", pdc_floatlist, 0, 1, 2, PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"fitmethod", pdc_keywordlist, 0, 1, 1, 0.0, 0.0, pdf_fitmethod_keylist}, + + {"distortionlimit", pdc_floatlist, PDC_OPT_NONE, 1, 1, 0.0, 100.0, NULL}, + + {"adjustpage", pdc_booleanlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 0.0, NULL}, + + {"blind", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + PDC_OPT_TERMINATE +}; + +void +pdf_place_xobject(PDF *p, int im, float x, float y, const char *optlist) +{ + pdf_image *image; + pdc_resopt *results; + pdc_clientdata data; + pdc_matrix m; + pdc_fitmethod method; + pdc_vector imgscale, elemsize, elemscale, relpos, polyline[5]; + pdc_box fitbox, elembox; + pdc_scalar ss, scaley, rowsize = 1, lastratio = 1, minfscale; + pdc_bool adjustpage, hasresol; + pdc_bool blindmode; + pdc_bool negdir = pdc_false; + float dpi[2], scale[2], boxsize[2], position[2], angle, distortionlimit; + float dpi_x, dpi_y, tx = 0, ty = 0; + int orientangle, indangle; + int inum, num, is, ip, islast; + int imageno; + + image = &p->images[im]; + + /* has resolution (image_xobject) */ + hasresol = p->xobjects[image->no].type == image_xobject ? + pdc_true : pdc_false; + + /* defaults */ + orientangle = 0; + dpi[0] = dpi[1] = (float) 0.0; + scale[0] = scale[1] = (float) 1.0; + boxsize[0] = boxsize[1] = (float) 0.0; + position[0] = position[1] = (float) 0.0; + angle = (float) 0.0; + method = pdc_nofit; + distortionlimit = (float) 75.0; + adjustpage = pdc_false; + blindmode = pdc_false; + + /* parsing optlist */ + if (optlist && strlen(optlist)) + { + data.compatibility = p->compatibility; + results = pdc_parse_optionlist(p->pdc, optlist, + pdf_place_xobject_options, + &data, pdc_true); + + /* save and check options */ + if (hasresol) + dpi[0] = (float) dpi_internal; + if ((num = pdc_get_optvalues(p->pdc, "dpi", results, dpi, NULL)) > 0) + { + if (!hasresol && dpi[0] != (float) dpi_none) + pdc_warning(p->pdc, PDC_E_OPT_IGNORED, "dpi", 0, 0, 0); + else if (num == 1) + dpi[1] = dpi[0]; + } + + if (1 == pdc_get_optvalues(p->pdc, "scale", results, scale, NULL)) + scale[1] = scale[0]; + + pdc_get_optvalues(p->pdc, "orientate", results, &orientangle, NULL); + + pdc_get_optvalues(p->pdc, "boxsize", results, boxsize, NULL); + + pdc_get_optvalues(p->pdc, "rotate", results, &angle, NULL); + + if (1 == pdc_get_optvalues(p->pdc, "position", results, position, NULL)) + position[1] = position[0]; + + if (pdc_get_optvalues(p->pdc, "fitmethod", results, &inum, NULL)) + method = (pdc_fitmethod) inum; + + pdc_get_optvalues(p->pdc, "distortionlimit", results, + &distortionlimit, NULL); + + pdc_get_optvalues(p->pdc, "adjustpage", results, &adjustpage, NULL); + pdc_get_optvalues(p->pdc, "blind", results, &blindmode, NULL); + + pdc_cleanup_optionlist(p->pdc, results); + } + + /* calculation of image scale and size */ + imgscale.x = scale[0]; + imgscale.y = scale[1]; + if (hasresol) + { + if (dpi[0] == (float) dpi_internal) + { + dpi_x = image->dpi_x; + dpi_y = image->dpi_y; + if (dpi_x > 0 && dpi_y > 0) + { + imgscale.x *= 72.0 / dpi_x; + imgscale.y *= 72.0 / dpi_y; + } + else if (dpi_x < 0 && dpi_y < 0) + { + imgscale.y *= dpi_y / dpi_x; + } + } + else if (dpi[0] > 0) + { + imgscale.x *= 72.0 / dpi[0]; + imgscale.y *= 72.0 / dpi[1]; + } + rowsize = imgscale.y * image->rowsperstrip; + imgscale.x *= image->width; + imgscale.y *= image->height; + lastratio = (imgscale.y / rowsize) - (image->strips - 1); + elemsize.x = imgscale.x; + elemsize.y = imgscale.y; + } + else + { + elemsize.x = imgscale.x * image->width; + elemsize.y = imgscale.y * image->height; + } + + /* negative direction (e.g. BMP images) */ + if (image->height < 0) + { + elemsize.y = -elemsize.y; + negdir = pdc_true; + } + + /* minimal horizontal scaling factor */ + minfscale = distortionlimit / 100.0; + + /* orientation */ + indangle = orientangle / 90; + if (indangle % 2) + { + ss = elemsize.x; + elemsize.x = elemsize.y; + elemsize.y = ss; + } + + /* box for fitting */ + fitbox.ll.x = 0; + fitbox.ll.y = 0; + fitbox.ur.x = boxsize[0]; + fitbox.ur.y = boxsize[1]; + + /* relative position */ + relpos.x = position[0] / 100.0; + relpos.y = position[1] / 100.0; + + /* calculate image box */ + pdc_place_element(method, minfscale, &fitbox, &relpos, + &elemsize, &elembox, &elemscale); + + /* adjust page size */ + if (adjustpage && PDF_GET_STATE(p) == pdf_state_page) + { + float urx, ury, height; + + urx = (float) (2 * x + elembox.ur.x); + ury = (float) (2 * y + elembox.ur.y); + pdc_transform_point(&p->gstate[p->sl].ctm, + urx, ury, &p->width, &height); + p->height = (p->ydirection > 0) ? + height : p->height - p->ydirection * height; + if (p->height < p->ydirection * height / 2.0) + pdc_error(p->pdc, PDF_E_IMAGE_NOADJUST, 0, 0, 0, 0); + + p->CropBox.llx = 0.0f; + p->CropBox.lly = 0.0f; + p->CropBox.urx = p->width; + p->CropBox.ury = p->height; + + if ((p->width < PDF_ACRO4_MINPAGE || p->width > PDF_ACRO4_MAXPAGE || + p->height < PDF_ACRO4_MINPAGE || p->height > PDF_ACRO4_MAXPAGE)) + pdc_warning(p->pdc, PDF_E_PAGE_SIZE_ACRO4, 0, 0, 0, 0); + } + + if (!blindmode) + { + pdf_end_text(p); + pdf_begin_contents_section(p); + + pdf__save(p); + } + + /* reference point */ + pdc_translation_matrix(x, y, &m); + pdf_concat_raw_ob(p, &m, blindmode); + + /* clipping */ + if (!blindmode && (method == pdc_clip || method == pdc_slice)) + { + pdf__rect(p, 0, 0, boxsize[0], boxsize[1]); + pdf__clip(p); + } + + /* optional rotation */ + if (fabs((double)(angle)) > PDC_FLOAT_PREC) + { + pdc_rotation_matrix(p->ydirection * angle, &m); + pdf_concat_raw_ob(p, &m, blindmode); + } + + /* translation of element box */ + elembox.ll.y *= p->ydirection; + elembox.ur.y *= p->ydirection; + pdc_box2polyline(&elembox, polyline); + ip = indangle; + if (negdir) + { + ip = indangle - 1; + if (ip < 0) ip = 3; + } + tx = (float) polyline[ip].x; + ty = (float) polyline[ip].y; + pdc_translation_matrix(tx, ty, &m); + pdf_concat_raw_ob(p, &m, blindmode); + + /* orientation of image */ + if (orientangle != 0) + { + pdc_rotation_matrix(p->ydirection * orientangle, &m); + pdf_concat_raw_ob(p, &m, blindmode); + if (indangle % 2) + { + ss = elemscale.x; + elemscale.x = elemscale.y; + elemscale.y = ss; + } + } + + /* scaling of image */ + if (image->strips == 1) + scaley = p->ydirection * imgscale.y * elemscale.y; + else + scaley = p->ydirection * rowsize * elemscale.y; + pdc_scale_matrix((float)(imgscale.x * elemscale.x), (float) scaley, &m); + pdf_concat_raw_ob(p, &m, blindmode); + + if (!hasresol && !blindmode) + { + pdf_reset_gstate(p); + pdf_reset_tstate(p); + } + + + if (!blindmode) + { + /* last strip first */ + if (image->strips > 1 && lastratio != 1.0) + { + pdc_scale_matrix((float) 1.0, (float) lastratio, &m); + pdf_concat_raw(p, &m); + } + + /* put out image strips separately if available */ + islast = image->strips - 1; + imageno = image->no + islast; + for (is = islast; is >= 0; is--) + { + pdc_printf(p->out, "/I%d Do\n", imageno); + p->xobjects[imageno].flags |= xobj_flag_write; + if (image->strips > 1 && is > 0) + { + pdc_translation_matrix(0, 1, &m); + pdf_concat_raw(p, &m); + if (is == islast && lastratio != 1.0) + { + pdc_scale_matrix((float) 1.0, (float) (1. / lastratio), &m); + pdf_concat_raw(p, &m); + } + imageno--; + } + } + if (image->mask != pdc_undef) + p->xobjects[p->images[image->mask].no].flags |= xobj_flag_write; + + pdf__restore(p); + } +} + +#define MAX_THUMBNAIL_SIZE 106 + +PDFLIB_API void PDFLIB_CALL +PDF_add_thumbnail(PDF *p, int im) +{ + static const char fn[] = "PDF_add_thumbnail"; + pdf_image *image; + + if (!pdf_enter_api(p, fn, pdf_state_page, "(p[%p], %d)\n", (void *) p, im)) + return; + + PDF_INPUT_HANDLE(p, im) + pdf_check_handle(p, im, pdc_imagehandle); + + if (p->thumb_id != PDC_BAD_ID) + pdc_error(p->pdc, PDF_E_IMAGE_THUMB, 0, 0, 0, 0); + + image = &p->images[im]; + + if (image->strips > 1) + pdc_error(p->pdc, PDF_E_IMAGE_THUMB_MULTISTRIP, + pdc_errprintf(p->pdc, "%d", im), 0, 0, 0); + + if (image->width > MAX_THUMBNAIL_SIZE || image->height > MAX_THUMBNAIL_SIZE) + pdc_error(p->pdc, PDF_E_IMAGE_THUMB_SIZE, + pdc_errprintf(p->pdc, "%d", im), + pdc_errprintf(p->pdc, "%d", MAX_THUMBNAIL_SIZE), 0, 0); + + if (image->colorspace != (int) DeviceGray && + image->colorspace != (int) DeviceRGB && + image->colorspace != (int) Indexed) + pdc_error(p->pdc, PDF_E_IMAGE_THUMB_CS, + pdc_errprintf(p->pdc, "%d", im), 0, 0, 0); + + /* Add the image to the thumbnail key of the current page. */ + p->thumb_id = p->xobjects[image->no].obj_id; +} + +PDFLIB_API void PDFLIB_CALL +PDF_close_image(PDF *p, int image) +{ + static const char fn[] = "PDF_close_image"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page | pdf_state_font), + "(p[%p], %d)\n", (void *) p, image)) + { + return; + } + + PDF_INPUT_HANDLE(p, image) + pdf_check_handle(p, image, pdc_imagehandle); + + pdf_cleanup_image(p, image); +} + +/* interface for using image data directly in memory */ + +PDFLIB_API int PDFLIB_CALL +PDF_open_image( + PDF *p, + const char *type, + const char *source, + const char *data, + long length, + int width, + int height, + int components, + int bpc, + const char *params) +{ + static const char fn[] = "PDF_open_image"; + const char *filename = data; + char optlist[512]; + pdc_bool memory = pdc_false; + int retval = -1; + + /* precise scope diagnosis in pdf__load_image */ + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", \"%s\", data[%p], %ld, %d, %d, %d, %d, \"%s\")", + (void *) p, type, source, (void *) data, length, + width, height, components, bpc, params)) + { + PDF_RETURN_HANDLE(p, retval) + } + + if (type == NULL || *type == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "type", 0, 0, 0); + + if (source == NULL || *source == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "source", 0, 0, 0); + + if (!strcmp(type, "raw") && data == NULL) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "data", 0, 0, 0); + + /* create optlist */ + optlist[0] = 0; + sprintf(optlist,"width %d height %d components %d bpc %d ", + width, height, components, bpc); + + if (length < 0L) + { + strcat(optlist, "bitreverse true "); + length = -length; + } + + strcat(optlist, "reftype "); + if (!strcmp(source, "fileref")) + strcat(optlist, "fileref "); + else if (!strcmp(source, "memory")) + { + memory = pdc_true; + strcat(optlist, "direct "); + } + else if (!strcmp(source, "url")) + strcat(optlist, "url "); + + if (params != NULL && *params != '\0') + { + char **items; + int i, nitems; + + /* separator characters because of compatibility */ + nitems = pdc_split_stringlist(p->pdc, params, "\t :", &items); + for (i = 0; i < nitems; i++) + { + if (!strcmp(items[i], "invert")) + strcat(optlist, "invert true "); + else if (!strcmp(items[i], "ignoremask")) + strcat(optlist, "ignoremask true "); + else if (!strcmp(items[i], "inline")) + strcat(optlist, "inline true "); + else if (!strcmp(items[i], "interpolate")) + strcat(optlist, "interpolate true "); + else if (!strcmp(items[i], "mask")) + strcat(optlist, "mask true "); + else if (!strcmp(items[i], "/K")) + strcat(optlist, "K "); + else if (!strcmp(items[i], "/BlackIs1")) + strcat(optlist, "invert "); + else + strcat(optlist, items[i]); + } + pdc_cleanup_stringlist(p->pdc, items); + } + + /* create virtual file */ + if (memory) + { + filename = "__raw__image__data__"; + pdf__create_pvf(p, filename, 0, data, (size_t) length, ""); + } + + retval = pdf__load_image(p, type, filename, (const char *) optlist); + + if (memory) + (void) pdf__delete_pvf(p, filename, 0); + + PDF_RETURN_HANDLE(p, retval) +} + +PDFLIB_API int PDFLIB_CALL +PDF_open_image_file( + PDF *p, + const char *type, + const char *filename, + const char *stringparam, + int intparam) +{ + static const char fn[] = "PDF_open_image_file"; + char optlist[256]; + int retval = -1; + + /* precise scope diagnosis in pdf__load_image */ + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", \"%s\", \"%s\", %d)", + (void *) p, type, filename, stringparam, intparam)) + { + PDF_RETURN_HANDLE(p, retval) + } + + optlist[0] = 0; + if (stringparam != NULL && *stringparam != '\0') + { + if (!strcmp(stringparam, "invert")) + strcpy(optlist, "invert true "); + else if (!strcmp(stringparam, "inline")) + strcpy(optlist, "inline true "); + else if (!strcmp(stringparam, "ignoremask")) + strcpy(optlist, "ignoremask true "); + else if (!strcmp(stringparam, "mask")) + strcpy(optlist, "mask true "); + else if (!strcmp(stringparam, "masked")) + sprintf(optlist, "masked %d ", intparam); + else if (!strcmp(stringparam, "colorize")) + sprintf(optlist, "colorize %d ", intparam); + else if (!strcmp(stringparam, "page")) + sprintf(optlist, "page %d ", intparam); + else if (!strcmp(stringparam, "iccprofile")) + sprintf(optlist, "iccprofile %d ", intparam); + } + + retval = pdf__load_image(p, type, filename, (const char *) optlist); + + PDF_RETURN_HANDLE(p, retval) +} + +PDFLIB_API int PDFLIB_CALL +PDF_open_CCITT(PDF *p, const char *filename, int width, int height, + int BitReverse, int K, int BlackIs1) +{ + static const char fn[] = "PDF_open_CCITT"; + int retval = -1; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page | pdf_state_font), + "(p[%p], \"%s\", %d, %d, %d, %d, %d)", + (void *) p, filename, width, height, BitReverse, K, BlackIs1)) + { + /* create optlist */ + char optlist[256]; + sprintf(optlist,"width %d height %d bitreverse %s K %d invert %s", + width, height, PDC_BOOLSTR(BitReverse), K, PDC_BOOLSTR(BlackIs1)); + + retval = pdf__load_image(p, "CCITT", filename, (const char *) optlist); + } + + PDF_RETURN_HANDLE(p, retval) +} + +PDFLIB_API int PDFLIB_CALL +PDF_load_image( + PDF *p, + const char *type, + const char *filename, + int reserved, + const char *optlist) +{ + static const char fn[] = "PDF_load_image"; + int retval = -1; + + /* precise scope diagnosis in pdf__load_image */ + if (pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", \"%s\", %d ,\"%s\")", + (void *) p, type, filename, reserved, optlist)) + { + retval = pdf__load_image(p, type, filename, optlist); + } + + PDF_RETURN_HANDLE(p, retval) +} + + +/* keywords for options 'reftype' */ +static const pdc_keyconn pdf_reftype_keys[] = +{ + {"direct", pdf_ref_direct}, + {"fileref", pdf_ref_file}, + {"url", pdf_ref_url}, + {NULL, 0} +}; + +/* allowed values for options 'bcp' */ +static const pdc_keyconn pdf_bpcvalues[] = +{ + {"1", 1}, {"2", 2}, {"4", 4}, {"8", 8}, {NULL, 0} +}; + +/* allowed values for options 'components' */ +static const pdc_keyconn pdf_compvalues[] = +{ + {"1", 1}, {"3", 3}, {"4", 4}, {NULL, 0} +}; + +#define PDF_ICCOPT_FLAG PDC_OPT_UNSUPP + +/* definitions of open image options */ +static const pdc_defopt pdf_open_image_options[] = +{ + {"bitreverse", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + {"bpc", pdc_integerlist, PDC_OPT_INTLIST, 1, 1, 1.0, 8.0, pdf_bpcvalues}, + + {"components", pdc_integerlist, PDC_OPT_INTLIST, 1, 1, 1.0, 4.0, + pdf_compvalues}, + + {"height", pdc_integerlist, 0, 1, 1, 1.0, INT_MAX, NULL}, + + {"honoriccprofile", pdc_booleanlist, PDF_ICCOPT_FLAG, 1, 1, 0.0, 0.0, NULL}, + + /* ordering of the next three options is significant */ + + {"iccprofile", pdc_iccprofilehandle, PDF_ICCOPT_FLAG, 1, 1, 1.0, 0.0, NULL}, + + {"colorize", pdc_colorhandle, PDC_OPT_IGNOREIF1, 1, 1, 0.0, 0.0, NULL}, + + {"mask", pdc_booleanlist, PDC_OPT_IGNOREIF2, 1, 1, 0.0, 0.0, NULL}, + + {"ignoremask", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + {"imagewarning", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + {"inline", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + {"interpolate", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + {"invert", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + {"K", pdc_integerlist, 0, 1, 1, -1.0, 1.0, NULL}, + + {"masked", pdc_imagehandle, 0, 1, 1, 0.0, 0.0, NULL}, + + {"page", pdc_integerlist, 0, 1, 1, 1.0, INT_MAX, NULL}, + + {"renderingintent", pdc_keywordlist, 0, 1, 1, 0.0, 0.0, + gs_renderingintents}, + + {"reftype", pdc_keywordlist, 0, 1, 1, 0.0, 0.0, pdf_reftype_keys}, + + {"width", pdc_integerlist, 0, 1, 1, 1.0, INT_MAX, NULL}, + + PDC_OPT_TERMINATE +}; + +int +pdf__load_image( + PDF *p, + const char *type, + const char *filename, + const char *optlist) +{ + const char *keyword = NULL; + char qualname[32]; + pdc_clientdata data; + pdc_resopt *results; + pdf_image_type imgtype; + int colorize = pdc_undef; + pdf_image *image; + pdc_bool indjpeg = pdc_false; + int legal_states = 0; + int k, inum, imageslot, retval = -1; + + if (type == NULL || *type == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "type", 0, 0, 0); + + if (filename == NULL || *filename == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "filename", 0, 0, 0); + + /* parsing image type */ + k = pdc_get_keycode_ci(type, pdf_image_keylist); + if (k == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "type", type, 0, 0); + imgtype = (pdf_image_type) k; + type = pdc_get_keyword(imgtype, pdf_image_keylist); + + /* automatic check */ + if (imgtype == pdf_img_auto) + { + pdc_file *fp; + pdf_jpeg_info jpeg_info; + pdf_tiff_info tiff_info; + + if ((fp = pdf_fopen(p, filename, "", PDC_FILE_BINARY)) == NULL) + { + if (p->debug['i']) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; + } + + if (pdf_is_BMP_file(p, fp)) + imgtype = pdf_img_bmp; + else if (pdf_is_GIF_file(p, fp)) + imgtype = pdf_img_gif; + else if (pdf_is_PNG_file(p, fp)) + imgtype = pdf_img_png; + else if (pdf_is_TIFF_file(p, fp, &tiff_info, pdc_true)) + imgtype = pdf_img_tiff; + else if (pdf_is_JPEG_file(p, fp, &jpeg_info)) + imgtype = pdf_img_jpeg; + else + { + pdc_fclose(fp); + + pdc_set_errmsg(p->pdc, PDF_E_IMAGE_UNKNOWN, filename, 0, 0, 0); + + if (p->debug['i']) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; + } + pdc_fclose(fp); + type = pdc_get_keyword(imgtype, pdf_image_keylist); + } + + /* find free slot */ + for (imageslot = 0; imageslot < p->images_capacity; imageslot++) + if (!p->images[imageslot].in_use) + break; + + if (imageslot == p->images_capacity) + pdf_grow_images(p); + image = &p->images[imageslot]; + + /* inherit global flags */ + image->verbose = p->debug['i']; + image->ri = p->rendintent; + + /* parsing optlist */ + if (optlist && strlen(optlist)) + { + data.compatibility = p->compatibility; + data.maxcolor = p->colorspaces_number - 1; + data.maximage = p->images_capacity - 1; + data.hastobepos = p->hastobepos; + results = pdc_parse_optionlist(p->pdc, optlist, pdf_open_image_options, + &data, image->verbose); + if (!results) + return -1; + + /* save and check options */ + keyword = "imagewarning"; + pdc_get_optvalues(p->pdc, keyword, results, + &image->verbose, NULL); + keyword = "reftype"; + if (pdc_get_optvalues(p->pdc, keyword, results, &inum, NULL)) + { + image->reference = (pdf_ref_type) inum; + if (image->reference != pdf_ref_direct && + imgtype != pdf_img_ccitt && + imgtype != pdf_img_jpeg && + imgtype != pdf_img_raw) + { + if (image->verbose) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNSUPP, keyword, type, + 0, 0); + image->reference = pdf_ref_direct; + } + } + indjpeg = (imgtype == pdf_img_jpeg && + image->reference != pdf_ref_direct) ? pdc_true : pdc_false; + + keyword = "bpc"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->bpc, NULL)) + { + if (image->verbose && imgtype != pdf_img_raw && !indjpeg) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNREAS, keyword, type, 0, 0); + } + + keyword = "components"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->components, NULL)) + { + if (image->verbose && imgtype != pdf_img_raw && !indjpeg) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNREAS, keyword, type, 0, 0); + } + + keyword = "height"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->height_pixel, NULL)) + { + if (image->verbose && imgtype != pdf_img_ccitt && + imgtype != pdf_img_raw && !indjpeg) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNREAS, keyword, type, 0, 0); + } + + keyword = "width"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->width_pixel, NULL)) + { + if (image->verbose && imgtype != pdf_img_raw && + imgtype != pdf_img_ccitt && !indjpeg) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNREAS, keyword, type, 0, 0); + } + + keyword = "bitreverse"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->bitreverse, NULL)) + { + if (image->verbose && image->bitreverse && + (imgtype != pdf_img_ccitt || image->reference != pdf_ref_direct)) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNREAS, keyword, type, 0, 0); + } + + keyword = "colorize"; + pdc_get_optvalues(p->pdc, keyword, results, &colorize, NULL); + + + keyword = "ignoremask"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->ignoremask, NULL)) + { + if (image->verbose && (imgtype == pdf_img_bmp || + imgtype == pdf_img_ccitt || + imgtype == pdf_img_raw)) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNSUPP, keyword, type, 0, 0); + } + + keyword = "inline"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->doinline, NULL) && image->doinline) + { + if (imgtype != pdf_img_ccitt && + imgtype != pdf_img_jpeg && + imgtype != pdf_img_raw) + { + if (image->verbose) + pdc_warning(p->pdc, + PDF_E_IMAGE_OPTUNSUPP, keyword, type, 0, 0); + image->doinline = pdc_false; + } + else if (image->verbose && image->reference != pdf_ref_direct) + { + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNREAS, keyword, type, 0, 0); + image->doinline = pdc_false; + } + } + + keyword = "interpolate"; + pdc_get_optvalues(p->pdc, keyword, results, + &image->interpolate, NULL); + + keyword = "invert"; + pdc_get_optvalues(p->pdc, keyword, results, + &image->invert, NULL); + + keyword = "K"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->K, NULL)) + { + if (image->verbose && imgtype != pdf_img_ccitt) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNREAS, keyword, type, 0, 0); + } + + keyword = "mask"; + pdc_get_optvalues(p->pdc, keyword, results, + &image->imagemask, NULL); + + keyword = "masked"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->mask, NULL)) + { + if (!p->images[image->mask].in_use || + p->images[image->mask].strips != 1 || + (p->compatibility <= PDC_1_3 && + (p->images[image->mask].imagemask != pdc_true || + p->images[image->mask].bpc != 1))) + { + pdc_set_errmsg(p->pdc, PDF_E_IMAGE_OPTBADMASK, keyword, + pdc_errprintf(p->pdc, "%d", image->mask), 0, 0); + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + pdc_cleanup_optionlist(p->pdc, results); + pdf_cleanup_image(p, imageslot); + return -1; + } + } + + keyword = "renderingintent"; + if (pdc_get_optvalues(p->pdc, keyword, results, &inum, NULL)) + image->ri = (pdf_renderingintent) inum; + + keyword = "page"; + if (pdc_get_optvalues(p->pdc, keyword, results, + &image->page, NULL)) + { + if (imgtype != pdf_img_gif && imgtype != pdf_img_tiff) + { + if (image->page == 1) + { + if (image->verbose) + pdc_warning(p->pdc, PDF_E_IMAGE_OPTUNSUPP, keyword, + type, 0, 0); + } + else + { + pdc_set_errmsg(p->pdc, PDF_E_IMAGE_NOPAGE, + pdc_errprintf(p->pdc, "%d", image->page), type, + pdc_errprintf(p->pdc, "%s", filename), 0); + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + pdc_cleanup_optionlist(p->pdc, results); + pdf_cleanup_image(p, imageslot); + return -1; + } + } + } + + pdc_cleanup_optionlist(p->pdc, results); + } + + /* precise scope diagnosis */ + if (image->doinline) + legal_states = pdf_state_content; + else + legal_states = pdf_state_document | pdf_state_page | pdf_state_font; + PDF_CHECK_STATE(p, legal_states); + + /* required options */ + if (imgtype == pdf_img_raw || imgtype == pdf_img_ccitt || indjpeg) + { + keyword = ""; + if (image->height_pixel == pdc_undef) + keyword = "height"; + else if (image->width_pixel == pdc_undef) + keyword = "width"; + else + { + image->width = (float) image->width_pixel; + image->height = (float) image->height_pixel; + } + + if (imgtype == pdf_img_ccitt) + { + image->components = 1; + image->bpc = 1; + } + if (image->bpc == pdc_undef) + keyword = "bpc"; + else if (image->components == pdc_undef) + keyword = "components"; + + if (*keyword) + { + pdc_set_errmsg(p->pdc, PDC_E_OPT_NOTFOUND, keyword, 0, 0, 0); + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + pdf_cleanup_image(p, imageslot); + return -1; + } + } + + /* set colorspace */ + if (colorize != pdc_undef) + { + image->colorspace = colorize; + } + else if (image->imagemask == pdc_true) + { + image->colorspace = (int) DeviceGray; + } + else + { + switch(image->components) + { + case 1: + image->colorspace = DeviceGray; + break; + + case 3: + image->colorspace = DeviceRGB; + break; + + case 4: + image->colorspace = DeviceCMYK; + break; + + default: + break; + } + } + + /* try to open image file */ + if (image->reference == pdf_ref_direct) + { + strcpy(qualname, type); + strcat(qualname, " "); + image->fp = pdf_fopen(p, filename, qualname, PDC_FILE_BINARY); + + if (image->fp == NULL) + { + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + pdf_cleanup_image(p, imageslot); + return -1; + } + } + + /* copy filename */ + image->filename = pdc_strdup(p->pdc, filename); + + + /* call working function */ + switch (imgtype) + { + case pdf_img_bmp: + retval = pdf_process_BMP_data(p, imageslot); + break; + + case pdf_img_ccitt: + retval = pdf_process_CCITT_data(p, imageslot); + break; + + case pdf_img_gif: + retval = pdf_process_GIF_data(p, imageslot); + break; + + case pdf_img_jpeg: + retval = pdf_process_JPEG_data(p, imageslot); + break; + + case pdf_img_png: + retval = pdf_process_PNG_data(p, imageslot); + break; + + default: + case pdf_img_raw: + retval = pdf_process_RAW_data(p, imageslot); + break; + + case pdf_img_tiff: + retval = pdf_process_TIFF_data(p, imageslot); + break; + } + + /* cleanup */ + if (retval == -1) + { + pdf_cleanup_image(p, imageslot); + } + else + { + if (image->fp) + pdc_fclose(image->fp); + image->fp = NULL; + } + + return retval; +} diff --git a/src/libs/pdflib/libs/pdflib/p_image.h b/src/libs/pdflib/libs/pdflib/p_image.h new file mode 100644 index 0000000000..6db66f0ec6 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_image.h @@ -0,0 +1,249 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_image.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * Header file for the PDFlib image subsystem + * + */ + +#ifndef P_IMAGE_H +#define P_IMAGE_H + +#ifdef HAVE_LIBTIFF +#include "tiffio.h" +#endif + +#ifdef HAVE_LIBPNG +#include "png.h" +#endif + +/* Type of image reference */ +typedef enum +{ + pdf_img_auto, + pdf_img_bmp, + pdf_img_ccitt, + pdf_img_gif, + pdf_img_jpeg, + pdf_img_png, + pdf_img_raw, + pdf_img_tiff +} +pdf_image_type; + +#ifdef P_IMAGE_C +const pdc_keyconn pdf_image_keylist[] = +{ + {"AUTO", pdf_img_auto}, + {"BMP", pdf_img_bmp}, + {"CCITT", pdf_img_ccitt}, + {"GIF", pdf_img_gif}, + {"JPEG", pdf_img_jpeg}, + {"PNG", pdf_img_png}, + {"RAW", pdf_img_raw}, + {"TIFF", pdf_img_tiff}, + {NULL, 0} +}; +#endif /* P_IMAGE_C */ + +/* BMP specific image information */ +typedef struct pdf_bmp_info_t { + pdc_ulong compression; /* BMP compression */ + size_t rowbytes; /* length of row data */ + size_t rowbytes_pad; /* padded length of row data */ + size_t rowbytes_pdf; /* length of row data for PDF */ + size_t skiprows; /* number of rows to be skipped */ + pdc_byte *bitmap; /* bitmap buffer */ + pdc_byte *end; /* first byte above bitmap buffer */ + pdc_byte *pos; /* current position in bitmap buffer */ +} pdf_bmp_info; + +/* JPEG specific image information */ +typedef struct pdf_jpeg_info_t { + long startpos; /* start of image data in file */ +} pdf_jpeg_info; + +/* GIF specific image information */ +typedef struct pdf_gif_info_t { + int c_size; /* current code size (9..12) */ + int t_size; /* current table size (257...) */ + int i_buff; /* input buffer */ + int i_bits; /* # of bits in i_buff */ + int o_buff; /* output buffer */ + int o_bits; /* # of bits in o_buff */ +} pdf_gif_info; + + +/* PNG specific image information */ +typedef struct pdf_png_info_t { + size_t nbytes; /* number of bytes left */ + /* in current IDAT chunk */ +#ifdef HAVE_LIBPNG + png_structp png_ptr; + png_infop info_ptr; + png_uint_32 rowbytes; + pdc_byte *raster; + int cur_line; +#endif /* HAVE_LIBPNG */ +} pdf_png_info; + + +/* TIFF specific image information */ +typedef struct pdf_tiff_info_t { +#ifdef HAVE_LIBTIFF + TIFF *tif; /* pointer to TIFF data structure */ + uint32 *raster; /* frame buffer */ +#endif /* HAVE_LIBTIFF */ + + int cur_line; /* current image row or strip */ +} pdf_tiff_info; + +/* CCITT specific image information */ +typedef struct pdf_ccitt_info_t { + int BitReverse; /* reverse all bits prior to use */ +} pdf_ccitt_info; + +/* Type of image reference */ +typedef enum {pdf_ref_direct, pdf_ref_file, pdf_ref_url} pdf_ref_type; + +/* must be kept in sync with pdf_filter_names[] in p_image.c */ +typedef enum { none, lzw, runlength, ccitt, dct, flate, jbig2 } pdf_compression; + +typedef enum { pred_default = 1, pred_tiff = 2, pred_png = 15 } pdf_predictor; + +/* The image descriptor */ +struct pdf_image_s { + pdc_file *fp; /* image file pointer */ + char *filename; /* image file name or url */ + /* width and height in pixels, or in points for PDF pages and templates */ + float width; /* image width */ + float height; /* image height */ + pdf_compression compression; /* image compression type */ + int colorspace; /* image color space */ + + /*************************** option variables *****************************/ + pdc_bool verbose; /* put out warning/error messages */ + pdc_bool bitreverse; /* bitwise reversal of all bytes */ + int bpc; /* bits per color component */ + int components; /* number of color components */ + int height_pixel; /* image height in pixel */ + pdc_bool ignoremask; /* ignore any transparency information*/ + pdc_bool doinline; /* inline image */ + pdc_bool interpolate; /* interpolate image */ + pdc_bool invert; /* reverse black and white */ + int K; /* encoding type of CCITT */ + pdc_bool imagemask; /* create a mask from a 1-bit image */ + int mask; /* image number of image mask */ + pdf_renderingintent ri; /* rendering intent of image */ + int page; /* page number of TIFF image */ + pdf_ref_type reference; /* kind of image data reference */ + int width_pixel; /* image width in pixel */ + /**************************************************************************/ + + pdc_bool transparent; /* image is transparent */ + pdc_byte transval[4]; /* transparent color values */ + pdf_predictor predictor; /* predictor for lzw and flate */ + + float dpi_x; /* horiz. resolution in dots per inch */ + float dpi_y; /* vert. resolution in dots per inch */ + /* dpi is 0 if unknown */ + + pdc_bool in_use; /* image slot currently in use */ + + char *params; /* for TIFF */ + int strips; /* number of strips in image */ + int rowsperstrip; /* number of rows per strip */ + int pagehandle; /* PDI page handle */ + int dochandle; /* PDI document handle */ + pdc_usebox usebox; + pdc_bool use_raw; /* use raw (compressed) image data */ + + /* image format specific information */ + union { + pdf_bmp_info bmp; + pdf_jpeg_info jpeg; + pdf_gif_info gif; + pdf_png_info png; + pdf_tiff_info tiff; + pdf_ccitt_info ccitt; + } info; + + int no; /* PDF image number */ + PDF_data_source src; +}; + +/* xobject types */ +typedef enum { + image_xobject = 1 << 0, + form_xobject = 1 << 1, + pdi_xobject = 1 << 2 +} pdf_xobj_type; + +typedef enum { + xobj_flag_used = 1 << 0, /* in use */ + xobj_flag_write = 1 << 1 /* write at end of page */ +} pdf_xobj_flags; + +/* A PDF xobject */ +struct pdf_xobject_s { + pdc_id obj_id; /* object id of this xobject */ + int flags; /* bit mask of pdf_xobj_flags */ + pdf_xobj_type type; /* type of this xobject */ +}; + +/* p_bmp.c */ +int pdf_process_BMP_data(PDF *p, int imageslot); +pdc_bool pdf_is_BMP_file(PDF *p, pdc_file *fp); + +/* p_ccitt.c */ +int pdf_process_CCITT_data(PDF *p, int imageslot); +int pdf_process_RAW_data(PDF *p, int imageslot); + +/* p_gif.c */ +int pdf_process_GIF_data(PDF *p, int imageslot); +pdc_bool pdf_is_GIF_file(PDF *p, pdc_file *fp); + +/* p_jpeg.c */ +int pdf_process_JPEG_data(PDF *p, int imageslot); +pdc_bool pdf_is_JPEG_file(PDF *p, pdc_file *fp, pdf_jpeg_info *jpeg); + +/* p_png.c */ +int pdf_process_PNG_data(PDF *p, int imageslot); +pdc_bool pdf_is_PNG_file(PDF *p, pdc_file *fp); + +/* p_tiff.c */ +int pdf_process_TIFF_data(PDF *p, int imageslot); +pdc_bool pdf_is_TIFF_file(PDF *p, pdc_file *fp, pdf_tiff_info *tiff, + pdc_bool check); + + +/* p_image.c */ +int pdf_new_xobject(PDF *p, pdf_xobj_type type, pdc_id obj_id); +void pdf_grow_images(PDF *p); +void pdf_put_image(PDF *p, int im, pdc_bool firststrip); +void pdf_put_inline_image(PDF *p, int im); + +void pdf_init_images(PDF *p); +void pdf_cleanup_images(PDF *p); +void pdf_cleanup_image(PDF *p, int im); +void pdf_init_xobjects(PDF *p); +void pdf_write_xobjects(PDF *p); +void pdf_cleanup_xobjects(PDF *p); +void pdf_place_xobject(PDF *p, int im, float x, float y, + const char *optlist); +void pdf__fit_image(PDF *p, int im, float x, float y, const char *optlist); +int pdf__load_image(PDF *p, const char *type, const char *filename, + const char *optlist); + + +#endif /* P_IMAGE_H */ diff --git a/src/libs/pdflib/libs/pdflib/p_intern.h b/src/libs/pdflib/libs/pdflib/p_intern.h new file mode 100644 index 0000000000..52b9d567f5 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_intern.h @@ -0,0 +1,742 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_intern.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib internal definitions + * + */ + +#ifndef P_INTERN_H +#define P_INTERN_H + +#include "pdflib.h" + +#include "pc_util.h" +#include "pc_geom.h" +#include "pc_file.h" +#include "pc_sbuf.h" +#include "pc_font.h" +#include "pc_optparse.h" + +#include "p_color.h" +#include "p_keyconn.h" + +/* PDFlib error numbers. +*/ +enum +{ +#define pdf_genNames 1 +#include "p_generr.h" + + PDF_E_dummy +}; + +/* ------------------------ PDFlib feature configuration ------------------- */ + +/* changing the following is not recommended, and not supported */ + +/* BMP image support */ +#define PDF_BMP_SUPPORTED + +/* GIF image support */ +#define PDF_GIF_SUPPORTED + +/* JPEG image support */ +#define PDF_JPEG_SUPPORTED + +/* PNG image support, requires HAVE_LIBZ */ +#define HAVE_LIBPNG + +/* TIFF image support */ +#define HAVE_LIBTIFF + +/* TrueType font support */ +#define PDF_TRUETYPE_SUPPORTED + +/* support proportional widths for the standard CJK fonts */ +#define PDF_CJKFONTWIDTHS_SUPPORTED + + +/* ----------------------------------- macros ------------------------------- */ + +#define PDFLIBSERIAL "PDFLIBSERIAL" /* name of env var. */ + +/* + * Allocation chunk sizes. These don't affect the generated documents + * in any way. In order to save initial memory, however, you can lower + * the values. Increasing the values will bring some performance gain + * for large documents, but will waste memory for small ones. + */ +#define PAGES_CHUNKSIZE 512 /* pages */ +#define PNODES_CHUNKSIZE 64 /* page tree nodes */ +#define CONTENTS_CHUNKSIZE 64 /* page content streams */ +#define FONTS_CHUNKSIZE 16 /* document fonts */ +#define ENCODINGS_CHUNKSIZE 8 /* document encodings */ +#define XOBJECTS_CHUNKSIZE 128 /* document xobjects */ +#define IMAGES_CHUNKSIZE 128 /* document images */ +#define OUTLINE_CHUNKSIZE 256 /* document outlines */ +#define NAMES_CHUNKSIZE 256 /* names */ +#define PDI_CHUNKSIZE 16 /* PDI instances */ +#define COLORSPACES_CHUNKSIZE 16 /* color spaces */ +#define PATTERN_CHUNKSIZE 4 /* pattern */ +#define SHADINGS_CHUNKSIZE 4 /* shadings */ +#define EXTGSTATE_CHUNKSIZE 4 /* external graphic states */ +#define T3GLYPHS_CHUNKSIZE 256 /* type 3 font glyph table */ +#define PRIVGLYPHS_CHUNKSIZE 256 /* private glyph table */ +#define ICCPROFILE_CHUNKSIZE 4 /* ICC profiles */ + +/* The following shouldn't require any changes */ +#define PDF_MAX_SAVE_LEVEL 12 /* max number of save levels */ +#define PDF_FILENAMELEN 1024 /* maximum file name length */ +#define PDF_MAX_PARAMSTRING 256 /* image parameter string */ + +/* Acrobat limit for page dimensions */ +#define PDF_ACRO4_MINPAGE ((float) 3) /* 1/24 inch = 0.106 cm */ +#define PDF_ACRO4_MAXPAGE ((float) 14400) /* 200 inch = 508 cm */ + +/* --------------------- typedefs, enums and structs ------------------------ */ + +typedef enum {pdf_fill_winding, pdf_fill_evenodd} pdf_fillrule; +typedef enum { c_none, c_page, c_path, c_text } pdf_content_type; + +/* Transition types for page transition effects */ +typedef enum { + trans_none, trans_split, trans_blinds, trans_box, + trans_wipe, trans_dissolve, trans_glitter, trans_replace +} pdf_transition; + +/* Document open modes */ +typedef enum { + open_auto, open_none, open_bookmarks, open_thumbnails, open_fullscreen +} pdf_openmode; + +/* Destination uses */ +typedef enum { + pdf_openaction, + pdf_bookmark, + pdf_remotelink, + pdf_locallink, + pdf_nameddest +} pdf_destuse; + +/* Destination types for internal and external links */ +typedef enum { + fixed, + fitwindow, + fitwidth, + fitheight, + fitrect, + fitvisible, + fitvisiblewidth, + fitvisibleheight, + nameddest, + filedest +} pdf_desttype; + +/* Border styles for links */ +typedef enum { + border_solid, border_dashed, border_beveled, + border_inset, border_underlined +} pdf_border_style; + +/* configurable flush points */ +typedef enum { + pdf_flush_none = 0, /* end of document */ + pdf_flush_page = 1<<0, /* after page */ + pdf_flush_content = 1<<1, /* font, xobj, annots */ + pdf_flush_reserved1 = 1<<2, /* reserved */ + pdf_flush_reserved2 = 1<<3, /* reserved */ + pdf_flush_heavy = 1<<4 /* before realloc attempt */ +} pdf_flush_state; + +/* + * Internal PDFlib states for error checking. + * This enum must be kept in sync with the scope_names array in + * p_basic.c::pdf_current_scope. + */ +typedef enum { + pdf_state_object = 1<<0, /* outside any document */ + pdf_state_document = 1<<1, /* document */ + pdf_state_page = 1<<2, /* page description in a document */ + pdf_state_pattern = 1<<3, /* pattern in a document */ + pdf_state_template = 1<<4, /* template in a document */ + pdf_state_path = 1<<5, /* path in a page description */ + + pdf_state_font = 1<<7, /* font definition */ + pdf_state_glyph = 1<<8, /* glyph description in a font */ + pdf_state_error = 1<<9 /* in error cleanup */ +} pdf_state; + +#define pdf_state_content \ + (pdf_state) (pdf_state_page | pdf_state_pattern | \ + pdf_state_template | pdf_state_glyph) + +#define pdf_state_all \ + (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page | \ + pdf_state_pattern | pdf_state_template | pdf_state_path | \ + pdf_state_font | pdf_state_glyph) + +#define PDF_STATE_STACK_SIZE 4 + +#define PDF_GET_STATE(p) \ + ((p)->state_stack[(p)->state_sp]) + +#define PDF_SET_STATE(p, s) \ + ((p)->state_stack[(p)->state_sp] = (s)) + +#define PDF_CHECK_STATE(p, s) \ + if ((((p)->state_stack[(p)->state_sp] & (s)) == 0)) \ + pdc_error(p->pdc, PDF_E_DOC_SCOPE, pdf_current_scope(p), 0, 0, 0) + +#define PDF_PUSH_STATE(p, fn, s) \ + if ((p)->state_sp == PDF_STATE_STACK_SIZE - 1) \ + pdc_error(p->pdc, PDF_E_INT_SSTACK_OVER, fn, 0, 0, 0); \ + else \ + (p)->state_stack[++(p)->state_sp] = (s) + +#define PDF_POP_STATE(p, fn) \ + if ((p)->state_sp == 0) \ + pdc_error(p->pdc, PDF_E_INT_SSTACK_UNDER, fn, 0, 0, 0); \ + else \ + --(p)->state_sp + +#define PDF_GET_EXTHANDLE(p, val) \ + (p->hastobepos ? val + 1 : val) + +#define PDF_INPUT_HANDLE(p, val) \ + if (p->hastobepos) val--; + +#define PDF_RETURN_HANDLE(p, val) \ + if (p->hastobepos) val++; \ + pdc_trace(p->pdc, "[%d]\n", val); \ + return val; + +#define PDF_RETURN_BOOLEAN(p, val) \ + return pdc_trace(p->pdc, "[%d]\n", \ + (val == -1 && p->hastobepos) ? 0 : val), \ + (val == -1 && p->hastobepos) ? 0 : val + +#ifndef PDI_DEFINED +#define PDI_DEFINED +typedef struct PDI_s PDI; /* The opaque PDI type */ +#endif + +typedef struct +{ + pdc_bool pdfx_ok; + PDI * pi; +} pdf_pdi; + +typedef enum { + HideToolbar = (1<<0), + HideMenubar = (1<<1), + HideWindowUI = (1<<2), + FitWindow = (1<<3), + CenterWindow = (1<<4), + DisplayDocTitle = (1<<5), + NonFullScreenPageModeOutlines= (1<<6), + NonFullScreenPageModeThumbs = (1<<7), + DirectionR2L = (1<<8) +} pdf_prefs_e; + +typedef struct { + int flags; + pdc_usebox ViewArea; + pdc_usebox ViewClip; + pdc_usebox PrintArea; + pdc_usebox PrintClip; +} pdf_prefs; + +/* Destination structure for bookmarks and links */ +typedef struct { + pdf_desttype type; + char *filename; /* name of a file to be launched */ + pdc_bool remote; /* local or remote target file */ + int page; /* target page number */ + char *name; /* destination name, only for type=nameddest */ + int len; /* length of the name string */ + float zoom; /* magnification */ + float left; + float right; + float bottom; + float top; + float color[3]; /* rgb color of bookmark text */ + pdc_fontstyle fontstyle; /* font style of bookmark text */ +} pdf_dest; + +typedef struct { + pdc_encodingvector *ev; /* encoding vector */ + pdc_id id; /* encoding object id */ + pdc_id tounicode_id; /* tounicode object ids */ +} pdf_encoding; + +/* Opaque types which are detailed in the respective modules */ +typedef struct pdf_xobject_s pdf_xobject; +typedef struct pdf_res_s pdf_res; +typedef struct pdf_category_s pdf_category; +typedef struct pdf_virtfile_s pdf_virtfile; +typedef struct pdf_annot_s pdf_annot; +typedef struct pdf_name_s pdf_name; +typedef struct pdf_info_s pdf_info; +typedef struct pdf_outline_s pdf_outline; +typedef struct pdf_image_s pdf_image; +typedef struct pdf_pattern_s pdf_pattern; +typedef struct pdf_shading_s pdf_shading; +typedef struct pdf_extgstateresource_s pdf_extgstateresource; + +/* -------------------- special graphics state -------------------- */ +typedef struct { + pdc_matrix ctm; /* current transformation matrix */ + float x; /* current x coordinate */ + float y; /* current y coordinate */ + + float startx; /* starting x point of the subpath */ + float starty; /* starting y point of the subpath */ + + float lwidth; /* line width */ + int lcap; /* line cap style */ + int ljoin; /* line join style */ + float miter; /* line join style */ + float flatness; /* line join style */ + pdc_bool dashed; /* line dashing in effect */ + + /* LATER: rendering intent and flatness */ +} pdf_gstate; + +/* ------------------------ text state ---------------------------- */ +typedef struct { + float c; /* character spacing */ + float w; /* word spacing */ + float h; /* horizontal scaling */ + float l; /* leading */ + int f; /* slot number of the current font */ + float fs; /* font size */ + pdc_matrix m; /* text matrix */ + float me; /* last text matrix component e */ + int mode; /* text rendering mode */ + float rise; /* text rise */ + pdc_matrix lm; /* text line matrix */ + pdc_bool potm; /* text matrix must be output at begin text */ +} pdf_tstate; + +/* Force graphics or color operator output, avoiding the optimization + * which checks whether the new value might be the same as the old. + * This is especially required for Type 3 glyph descriptions which + * inherit the surrounding page description's gstate parameters, + * and therefore even must write default values. + */ +#define PDF_FORCE_OUTPUT() (PDF_GET_STATE(p) == pdf_state_glyph) + +/* + * ************************************************************************* + * The core PDF document descriptor + * ************************************************************************* + */ + +struct PDF_s { + /* -------------------------- general stuff ------------------------ */ + unsigned long magic; /* poor man's integrity check */ + void (*freeproc)(PDF *p, void *mem); + pdc_core *pdc; /* core context */ + int compatibility; /* PDF version number * 10 */ + + char *binding; /* name of the language binding */ + pdc_bool hastobepos; /* return value has to be positiv */ + + pdf_state state_stack[PDF_STATE_STACK_SIZE]; + int state_sp; /* state stack pointer */ + + /* ------------------- PDF Info dictionary entries ----------------- */ + char time_str[PDC_TIME_SBUF_SIZE]; /* time string */ + char *Keywords; + char *Subject; + char *Title; + char *Creator; + char *Author; + pdf_info *userinfo; /* list of user-defined entries */ + + /* -------------- I/O, error handling and memory management ------------- */ + size_t (*writeproc)(PDF *p, void *data, size_t size); + void (*errorhandler)(PDF *p, int level, const char* msg); + void *opaque; /* user-specific, opaque data */ + + /* ------------------------- PDF import ---------------------------- */ + pdf_pdi *pdi; /* PDI context array */ + int pdi_capacity; /* currently allocated size */ + pdc_usebox pdi_usebox; + pdc_bool pdi_strict; /* strict PDF parser mode */ + pdc_sbuf * pdi_sbuf; /* string buffer for pdi parms */ + + /* ------------------------ resource stuff ------------------------- */ + pdf_category *resources; /* anchor for the resource list */ + pdc_bool resfilepending; /* to read resource file is pending */ + char *resourcefilename; /* name of the resource file */ + char *prefix; /* prefix for resource file names */ + + /* ---------------- virtual file system stuff ----------------------- */ + pdf_virtfile *filesystem; /* anchor for the virtual file system */ + + /* ------------------- hypertext bookkeeping ------------------- */ + pdf_openmode open_mode; /* document open mode */ + pdf_dest open_action; /* open action/first page display */ + pdf_dest bookmark_dest; /* destination for bookmarks */ + char *base; /* document base URI */ + + /* ------------------- PDF output bookkeeping ------------------- */ + pdc_output *out; /* output manager */ + pdc_id length_id; /* id of current stream's length*/ + pdf_flush_state flush; /* flush state */ + + /* ------------------- page bookkeeping ------------------- */ + pdc_id *pages; /* page ids */ + int pages_capacity; + int current_page; /* current page number (1-based) */ + + pdc_id *pnodes; /* page tree node ids */ + int pnodes_capacity; /* current # of entries in pnodes */ + int current_pnode; /* current node number (0-based) */ + int current_pnode_kids; /* current # of kids in current node */ + + + /* ------------------- document resources ------------------- */ + pdc_font *fonts; /* all fonts in document */ + int fonts_capacity; /* currently allocated size */ + int fonts_number; /* next available font number */ + + pdf_xobject *xobjects; /* all xobjects in document */ + int xobjects_capacity; /* currently allocated size */ + int xobjects_number; /* next available xobject slot */ + + pdf_colorspace *colorspaces; /* all color space resources */ + int colorspaces_capacity; /* currently allocated size */ + int colorspaces_number; /* next available color space number */ + + + pdf_pattern *pattern; /* all pattern resources */ + int pattern_capacity; /* currently allocated size */ + int pattern_number; /* next available pattern number */ + + pdf_shading *shadings; /* all shading resources */ + int shadings_capacity; /* currently allocated size */ + int shadings_number; /* next available shading number */ + + pdf_extgstateresource *extgstates; /* all ext. graphic state resources */ + int extgstates_capacity; /* currently allocated size */ + int extgstates_number; /* next available extgstate number */ + + pdf_image *images; /* all images in document */ + int images_capacity; /* currently allocated size */ + + /* ------------------- encodings ------------------- */ + pdf_encoding *encodings; /* all encodings in document */ + int encodings_capacity; /* currently allocated size */ + int encodings_number; /* next available encoding slot */ + + /* ------------------- document outline tree ------------------- */ + int outline_capacity; /* currently allocated size */ + int outline_count; /* total number of outlines */ + pdf_outline *outlines; /* dynamic array of outlines */ + + /* ------------------- name tree ------------------- */ + pdf_name *names; /* page ids */ + int names_capacity; + int names_number; /* next available names number */ + + /* ------------------- page specific stuff ------------------- */ + pdc_id res_id; /* id of this page's res dict */ + pdc_id *contents_ids; /* content sections' chain */ + int contents_ids_capacity; /* # of content sections */ + pdc_id next_content; /* # of current content section */ + pdf_content_type contents; /* type of current content section */ + pdf_transition transition; /* type of page transition */ + float duration; /* duration of page transition */ + pdf_prefs ViewerPreferences; /* bit mask with preferences */ + + pdc_t3font *t3font; /* type 3 font info */ + + pdf_annot *annots; /* annotation chain */ + + float width; /* MediaBox: current page's width */ + float height; /* MediaBox: current page's height */ + pdc_rectangle CropBox; + pdc_rectangle BleedBox; + pdc_rectangle TrimBox; + pdc_rectangle ArtBox; + pdc_id thumb_id; /* id of page's thumb, or PDC_BAD_ID */ + + float ydirection; /* direction of y axis of default */ + /* system rel. to viewport (1 or -1) */ + + pdc_bool usercoordinates; /* interprete rectangle coordinates */ + /* of hypertext funcs. in user space */ + + int sl; /* current save level */ + pdf_gstate gstate[PDF_MAX_SAVE_LEVEL]; /* graphics state */ + pdf_tstate tstate[PDF_MAX_SAVE_LEVEL]; /* text state */ + pdf_cstate cstate[PDF_MAX_SAVE_LEVEL]; /* color state */ + + + pdf_renderingintent rendintent; /* RenderingIntent */ + + pdc_bool preserveoldpantonenames;/* preserve old PANTONE names */ + pdc_bool spotcolorlookup; /* use internal look-up table for + * color values */ + + + /* ------------------------ template stuff ----------------------- */ + int templ; /* current template if in templ. state*/ + + /* ------------ other text and graphics-related stuff ------------ */ + /* leading, word, and character spacing are treated as a group */ + pdc_text_format textformat; /* text storage format */ + pdc_bool textparams_done; /* text parameters already set */ + pdc_bool underline; /* underline text */ + pdc_bool overline; /* overline text */ + pdc_bool strikeout; /* strikeout text */ + pdc_bool inheritgs; /* inherit gstate in templates */ + pdf_fillrule fillrule; /* nonzero or evenodd fill rule */ + pdc_byte *currtext; /* current allocated text string */ + + /* -------------- auxiliary API function parameters -------------- */ + /* PDF_add_launchlink() */ + char *launchlink_parameters; + char *launchlink_operation; + char *launchlink_defaultdir; + + /* ------------ hypertext encoding and storage format ------------ */ + pdc_encoding hypertextencoding; + pdc_text_format hypertextformat; + + /* -------------- annotation border style and color -------------- */ + pdf_border_style border_style; + float border_width; + float border_red; + float border_green; + float border_blue; + float border_dash1; + float border_dash2; + + /* ------------------------ miscellaneous ------------------------ */ + char debug[256]; /* debug flags */ + + /* -------------------- private glyph tables ---------------------- */ + pdc_glyph_tab *unicode2name; /* private unicode to glyphname table */ + pdc_glyph_tab *name2unicode; /* private glyphname to unicode table */ + int glyph_tab_capacity; /* currently allocated size */ + int glyph_tab_size; /* size of glyph tables */ + pdc_ushort next_unicode; /* next available unicode number */ + +}; + +/* Data source for images, compression, ASCII encoding, fonts, etc. */ +typedef struct PDF_data_source_s PDF_data_source; +struct PDF_data_source_s { + pdc_byte *next_byte; + size_t bytes_available; + void (*init)(PDF *, PDF_data_source *src); + int (*fill)(PDF *, PDF_data_source *src); + void (*terminate)(PDF *, PDF_data_source *src); + + pdc_byte *buffer_start; + size_t buffer_length; + void *private_data; + long offset; /* start of data to read */ + long length; /* length of data to read */ + long total; /* total bytes read so far */ +}; + +/* ------ Private functions for library-internal use only --------- */ + +/* p_basic.c */ +void pdf_begin_contents_section(PDF *p); +void pdf_end_contents_section(PDF *p); +void pdf_error(PDF *, int level, const char *fmt, ...); +pdc_bool pdf_enter_api(PDF *p, const char *funame, pdf_state s, + const char *fmt, ...); +const char * pdf_current_scope(PDF *p); +void pdf_grow_pages(PDF *p); +void pdf_check_handle(PDF *p, int value, pdc_opttype type); + +/* p_text.c */ +void pdf_init_tstate(PDF *p); +void pdf_reset_tstate(PDF *p); +void pdf_end_text(PDF *p); +void pdf_set_leading(PDF *p, float leading); +void pdf_set_text_rise(PDF *p, float rise); +void pdf_set_horiz_scaling(PDF *p, float scale); +void pdf_set_text_rendering(PDF *p, int mode); +void pdf_set_char_spacing(PDF *p, float spacing); +void pdf_set_word_spacing(PDF *p, float spacing); +float pdf_get_horiz_scaling(PDF *p); +float pdf_get_fontsize(PDF *p); +void pdf_output_kern_text(PDF *p, pdc_byte *text, int len, int charlen); +void pdf_put_textstring(PDF *p, pdc_byte *text, int len, int charlen); +void pdf_show_text(PDF *p, const char *text, int len, + const float *x_p, const float *y_p, pdc_bool cont); +float pdf__stringwidth(PDF *p, const char *text, int len, + int font, float size); +void pdf__setfont(PDF *p, int font, float fontsize); +void pdf__fit_textline(PDF *p, const char *text, int len, float x, float y, + const char *optlist); + +/* p_gstate.c */ +void pdf__save(PDF *p); +void pdf__restore(PDF *p); +void pdf_init_gstate(PDF *p); +void pdf_concat_raw(PDF *p, pdc_matrix *m); +void pdf_concat_raw_ob(PDF *p, pdc_matrix *m, pdc_bool blind); +void pdf_reset_gstate(PDF *p); +void pdf_set_topdownsystem(PDF *p, float height); +void pdf__setmatrix(PDF *p, pdc_matrix *n); + +/* p_extgstate.c */ +void pdf_init_extgstate(PDF *p); +void pdf_write_page_extgstates(PDF *p); +void pdf_write_doc_extgstates(PDF *p); +void pdf_cleanup_extgstates(PDF *p); + + + +/* p_filter.c */ +void pdf_ASCII85Encode(PDF *p, PDF_data_source *src); +void pdf_ASCIIHexEncode(PDF *p, PDF_data_source *src); +int pdf_data_source_buf_fill(PDF *p, PDF_data_source *src); + +void pdf_data_source_file_init(PDF *p, PDF_data_source *src); +int pdf_data_source_file_fill(PDF *p, PDF_data_source *src); +void pdf_data_source_file_terminate(PDF *p, PDF_data_source *src); + +void pdf_copy_stream(PDF *p, PDF_data_source *src, pdc_bool compress); + +/* p_annots.c */ +void pdf_init_annots(PDF *p); +void pdf_write_annots_root(PDF *p); +void pdf_init_page_annots(PDF *p); +void pdf_write_page_annots(PDF *p); +void pdf_cleanup_page_annots(PDF *p); +void pdf_cleanup_annots(PDF *p); + +/* p_draw.c */ +void pdf_begin_path(PDF *p); +void pdf_end_path(PDF *p); +void pdf__moveto(PDF *p, float x, float y); +void pdf__rmoveto(PDF *p, float x, float y); +void pdf__lineto(PDF *p, float x, float y); +void pdf__rlineto(PDF *p, float x, float y); +void pdf__curveto(PDF *p, float x_1, float y_1, + float x_2, float y_2, float x_3, float y_3); +void pdf__rcurveto(PDF *p, float x_1, float y_1, + float x_2, float y_2, float x_3, float y_3); +void pdf__rrcurveto(PDF *p, float x_1, float y_1, + float x_2, float y_2, float x_3, float y_3); +void pdf__hvcurveto(PDF *p, float x_1, float x_2, float y_2, float y_3); +void pdf__vhcurveto(PDF *p, float y_1, float x_2, float y_2, float x_3); +void pdf__rect(PDF *p, float x, float y, float width, float height); +void pdf__arc(PDF *p, float x, float y, float r, float alpha, float beta); +void pdf__arcn(PDF *p, float x, float y, float r, float alpha, float beta); +void pdf__circle(PDF *p, float x, float y, float r); +void pdf__closepath(PDF *p); +void pdf__endpath(PDF *p); +void pdf__stroke(PDF *p); +void pdf__closepath_stroke(PDF *p); +void pdf__fill(PDF *p); +void pdf__fill_stroke(PDF *p); +void pdf__closepath_fill_stroke(PDF *p); +void pdf__clip(PDF *p); + +/* p_gstate.c */ +void pdf__setdash(PDF *p, float b, float w); +void pdf__setflat(PDF *p, float flat); +void pdf__setlinejoin(PDF *p, int join); +void pdf__setlinecap(PDF *p, int cap); +void pdf__setlinewidth(PDF *p, float width); +void pdf__setmiterlimit(PDF *p, float miter); +void pdf__initgraphics(PDF *p); + +/* p_hyper.c */ +void pdf_init_destination(PDF *p, pdf_dest *dest); +void pdf_cleanup_destination(PDF *p, pdf_dest *dest); +void pdf_parse_destination_optlist(PDF *p, const char *optlist, + pdf_dest *dest, int page, pdf_destuse destuse); +void pdf_write_destination(PDF *p, pdf_dest *dest); + +void pdf_init_outlines(PDF *p); +void pdf_write_outlines(PDF *p); +void pdf_write_outline_root(PDF *p); +void pdf_cleanup_outlines(PDF *p); + +void pdf_init_transition(PDF *p); +void pdf_write_page_transition(PDF *p); + +void pdf_feed_digest_info(PDF *p); +void pdf_init_info(PDF *p); +pdc_id pdf_write_info(PDF *p); +void pdf_cleanup_info(PDF *p); + +void pdf_cleanup_names(PDF *p); +pdc_id pdf_write_names(PDF *p); + +void pdf_set_transition(PDF *p, const char *type); +void pdf_set_duration(PDF *p, float t); + +char *pdf_convert_hypertext(PDF *p, const char *text, int len); + + +/* p_resource.c */ +void pdf_add_resource(PDF *p, const char *category, const char *resource); +void pdf_cleanup_resources(PDF *p); +void pdf__create_pvf(PDF *p, const char *filename, int reserved, + const void *data, size_t size, const char *options); +int pdf__delete_pvf(PDF *p, const char *filename, int reserved); +char *pdf_find_resource(PDF *p, const char *category, const char *name); +void pdf_lock_pvf(PDF *p, const char *filename); +void pdf_unlock_pvf(PDF *p, const char *filename); +void pdf_cleanup_filesystem(PDF *p); +pdc_file *pdf_fopen(PDF *p, const char *filename, const char *qualifier, + int flags); + +/* p_encoding.c */ +void pdf__encoding_set_char(PDF *p, const char *encoding, int slot, + const char *glyphname, int uv); +pdc_encodingvector *pdf_generate_encoding(PDF *p, const char *encoding); +pdc_encodingvector *pdf_read_encoding(PDF *p, const char *encoding, + const char *filename); +pdc_ushort pdf_glyphname2unicode(PDF *p, const char *glyphname); +const char *pdf_unicode2glyphname(PDF *p, pdc_ushort uv); +pdc_ushort pdf_insert_glyphname(PDF *p, const char *glyphname); +const char *pdf_insert_unicode(PDF *p, pdc_ushort uv); +pdc_ushort pdf_register_glyphname(PDF *p, const char *glyphname, + pdc_ushort uv); +const char *pdf_get_encoding_name(PDF *p, pdc_encoding enc); +pdc_encoding pdf_insert_encoding(PDF *p, const char *encoding); +pdc_encoding pdf_find_encoding(PDF *p, const char *encoding); +void pdf_set_encoding_glyphnames(PDF *p, pdc_encoding enc); +pdc_bool pdf_get_encoding_isstdflag(PDF *p, pdc_encoding enc); +void pdf_init_encoding_ids(PDF *p); +void pdf_init_encodings(PDF *p); +void pdf_grow_encodings(PDF *p); +void pdf_cleanup_encodings(PDF *p); + +/* p_pattern.c */ +void pdf_init_pattern(PDF *p); +void pdf_write_page_pattern(PDF *p); +void pdf_cleanup_pattern(PDF *p); + +/* p_shading.c */ +void pdf_init_shadings(PDF *p); +void pdf_write_page_shadings(PDF *p); +void pdf_cleanup_shadings(PDF *p); + +/* p_xgstate.c */ +pdc_id pdf_get_gstate_id(PDF *p, int gstate); +#endif /* P_INTERN_H */ diff --git a/src/libs/pdflib/libs/pdflib/p_jpeg.c b/src/libs/pdflib/libs/pdflib/p_jpeg.c new file mode 100644 index 0000000000..6780a182c7 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_jpeg.c @@ -0,0 +1,643 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_jpeg.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * JPEG processing for PDFlib + * + */ + +#include "p_intern.h" +#include "p_image.h" + +#ifndef PDF_JPEG_SUPPORTED + +pdc_bool +pdf_is_JPEG_file(PDF *p, pdc_file *fp, pdf_jpeg_info *jpeg) +{ + (void) p; + (void) fp; + + return pdc_false; +} + +int +pdf_process_JPEG_data( + PDF *p, + int imageslot) +{ + (void) imageslot; + + pdc_warning(p->pdc, PDF_E_UNSUPP_IMAGE, "JPEG", 0, 0, 0); + return -1; +} + +#else + +/* + * The following enum is stolen from the IJG JPEG library + * Comments added by tm. + * This table contains far too many names since PDFlib + * is rather simple-minded about markers. + */ + +typedef enum { /* JPEG marker codes */ + M_SOF0 = 0xc0, /* baseline DCT */ + M_SOF1 = 0xc1, /* extended sequential DCT */ + M_SOF2 = 0xc2, /* progressive DCT */ + M_SOF3 = 0xc3, /* lossless (sequential) */ + + M_SOF5 = 0xc5, /* differential sequential DCT */ + M_SOF6 = 0xc6, /* differential progressive DCT */ + M_SOF7 = 0xc7, /* differential lossless */ + + M_JPG = 0xc8, /* JPEG extensions */ + M_SOF9 = 0xc9, /* extended sequential DCT */ + M_SOF10 = 0xca, /* progressive DCT */ + M_SOF11 = 0xcb, /* lossless (sequential) */ + + M_SOF13 = 0xcd, /* differential sequential DCT */ + M_SOF14 = 0xce, /* differential progressive DCT */ + M_SOF15 = 0xcf, /* differential lossless */ + + M_DHT = 0xc4, /* define Huffman tables */ + + M_DAC = 0xcc, /* define arithmetic conditioning table */ + + M_RST0 = 0xd0, /* restart */ + M_RST1 = 0xd1, /* restart */ + M_RST2 = 0xd2, /* restart */ + M_RST3 = 0xd3, /* restart */ + M_RST4 = 0xd4, /* restart */ + M_RST5 = 0xd5, /* restart */ + M_RST6 = 0xd6, /* restart */ + M_RST7 = 0xd7, /* restart */ + + M_SOI = 0xd8, /* start of image */ + M_EOI = 0xd9, /* end of image */ + M_SOS = 0xda, /* start of scan */ + M_DQT = 0xdb, /* define quantization tables */ + M_DNL = 0xdc, /* define number of lines */ + M_DRI = 0xdd, /* define restart interval */ + M_DHP = 0xde, /* define hierarchical progression */ + M_EXP = 0xdf, /* expand reference image(s) */ + + M_APP0 = 0xe0, /* application marker, used for JFIF */ + M_APP1 = 0xe1, /* application marker, used for Exif */ + M_APP2 = 0xe2, /* application marker, used for FlashPix* + * and ICC Profiles */ + M_APP3 = 0xe3, /* application marker */ + M_APP4 = 0xe4, /* application marker */ + M_APP5 = 0xe5, /* application marker */ + M_APP6 = 0xe6, /* application marker */ + M_APP7 = 0xe7, /* application marker */ + M_APP8 = 0xe8, /* application marker, used for SPIFF */ + M_APP9 = 0xe9, /* application marker */ + M_APP10 = 0xea, /* application marker */ + M_APP11 = 0xeb, /* application marker */ + M_APP12 = 0xec, /* application marker */ + M_APP13 = 0xed, /* application marker, used by Photoshop*/ + M_APP14 = 0xee, /* application marker, used by Adobe */ + M_APP15 = 0xef, /* application marker */ + + M_JPG0 = 0xf0, /* reserved for JPEG extensions */ + M_JPG13 = 0xfd, /* reserved for JPEG extensions */ + M_COM = 0xfe, /* comment */ + + M_TEM = 0x01, /* temporary use */ + + M_ERROR = 0x100, /* dummy marker, internal use only */ + M_CONT = 0x101 /* dummy marker, internal use only */ +} JPEG_MARKER; + +#define JPEG_BUFSIZE 1024 + +static void +pdf_data_source_JPEG_init(PDF *p, PDF_data_source *src) +{ + pdf_image *image; + + image = (pdf_image *) src->private_data; + + src->buffer_start = (pdc_byte *) + pdc_malloc(p->pdc, JPEG_BUFSIZE, "PDF_data_source_JPEG_init"); + src->buffer_length = JPEG_BUFSIZE; + + pdc_fseek(image->fp, image->info.jpeg.startpos, SEEK_SET); +} + +static pdc_bool +pdf_data_source_JPEG_fill(PDF *p, PDF_data_source *src) +{ + pdf_image *image; + + (void) p; /* avoid compiler warning "unreferenced parameter" */ + + image = (pdf_image *) src->private_data; + + src->next_byte = src->buffer_start; + src->bytes_available = + pdc_fread(src->buffer_start, 1, JPEG_BUFSIZE, image->fp); + + if (src->bytes_available == 0) + return pdc_false; + else + return pdc_true; +} + +static void +pdf_data_source_JPEG_terminate(PDF *p, PDF_data_source *src) +{ + pdc_free(p->pdc, (void *) src->buffer_start); +} + +/* + * The following routine used to be a macro in its first incarnation: + * + * #define get_2bytes(fp) ((unsigned int) (getc(fp) << 8) + getc(fp)) + * + * However, this is bad programming since C doesn't guarantee + * the evaluation order of the getc() calls! As suggested by + * Murphy's law, there are indeed compilers which produce the wrong + * order of the getc() calls, e.g. the Metrowerks C compiler for BeOS. + * Since there are only a few calls we don't care about the performance + * penalty and use a simplistic C function which does the right thing. + */ + +/* read two byte parameter, MSB first */ +static unsigned int +get_2bytes(pdc_file *fp) +{ + unsigned int val; + val = (unsigned int) (pdc_fgetc(fp) << 8); + val += (unsigned int) pdc_fgetc(fp); + return val; +} + +static int +pdf_next_jpeg_marker(pdc_file *fp) +{ /* look for next JPEG Marker */ + int c; + + do { + do { /* skip to FF */ + if (pdc_feof(fp)) + return M_ERROR; /* dummy marker */ + c = pdc_fgetc(fp); + } while (c != 0xFF); + + do { /* skip repeated FFs */ + if (pdc_feof(fp)) + return M_ERROR; /* dummy marker */ + c = pdc_fgetc(fp); + } while (c == 0xFF); + } while (c == 0); /* repeat if FF/00 */ + + return c; +} + +pdc_bool +pdf_is_JPEG_file(PDF *p, pdc_file *fp, pdf_jpeg_info *jpeg) +{ + int c; + + (void) p; + +#if defined(MVS) && defined(I370) + jpeg->startpos = 0L; +#else + /* Tommy's special trick for Macintosh JPEGs: simply skip some */ + /* hundred bytes at the beginning of the file! */ + do { + do { /* skip if not FF */ + c = pdc_fgetc(fp); + } while (!pdc_feof(fp) && c != 0xFF); + + if (pdc_feof(fp)) { + pdc_fseek(fp, 0L, SEEK_SET); + return pdc_false; + } + + do { /* skip repeated FFs */ + c = pdc_fgetc(fp); + } while (c == 0xFF); + + /* remember start position */ + if ((jpeg->startpos = pdc_ftell(fp)) < 0L) { + pdc_fseek(fp, 0L, SEEK_SET); + return pdc_false; + } + + jpeg->startpos -= 2; /* subtract marker length */ + + if (c == M_SOI) { + pdc_fseek(fp, jpeg->startpos, SEEK_SET); + break; + } + } while (!pdc_feof(fp)); +#endif /* !MVS || !I370 */ + +#define BOGUS_LENGTH 768 + /* Heuristics: if we are that far from the start chances are + * it is a TIFF file with embedded JPEG data which we cannot + * handle - regard as hopeless... + */ + if (pdc_feof(fp) || jpeg->startpos > BOGUS_LENGTH) { + pdc_fseek(fp, 0L, SEEK_SET); + return pdc_false; + } + + return pdc_true; +} + +/* open JPEG image and analyze marker */ +int +pdf_process_JPEG_data( + PDF *p, + int imageslot) +{ + static const char fn[] = "pdf_process_JPEG_data"; + int b, c, unit; + unsigned long i, length; +#define APP_MAX 255 + unsigned char appstring[APP_MAX]; + pdc_byte *app13; + pdc_byte *s; + pdf_image *image; + pdc_bool adobeflag = pdc_false; + pdc_bool markers_done = pdc_false; + int errint = 0; + int errcode = 0; + + image = &p->images[imageslot]; + image->compression = dct; + image->use_raw = pdc_true; + + /* jpeg file not available */ + if (image->reference != pdf_ref_direct) + { + + image->in_use = pdc_true; /* mark slot as used */ + pdf_put_image(p, imageslot, pdc_true); + return imageslot; + } + + if (pdf_is_JPEG_file(p, image->fp, &image->info.jpeg) == pdc_false) { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_JPEG_ERROR; + } + + image->src.init = pdf_data_source_JPEG_init; + image->src.fill = pdf_data_source_JPEG_fill; + image->src.terminate = pdf_data_source_JPEG_terminate; + image->src.private_data = (void *) image; + + /* process JPEG markers */ + while (!markers_done && (c = pdf_next_jpeg_marker(image->fp)) != M_EOI) { + + + switch (c) { + case M_ERROR: + /* The following are not supported in PDF 1.3 and above */ + case M_SOF3: + case M_SOF5: + case M_SOF6: + case M_SOF7: + case M_SOF9: + case M_SOF11: + case M_SOF13: + case M_SOF14: + case M_SOF15: + errint = c; + errcode = PDF_E_JPEG_COMPRESSION; + goto PDF_JPEG_ERROR; + + + /* SOF2 and SOF10 are progressive DCT */ + case M_SOF2: + case M_SOF10: + /* fallthrough */ + + case M_SOF0: + case M_SOF1: + (void) get_2bytes(image->fp); /* read segment length */ + + image->bpc = pdc_fgetc(image->fp); + image->height = (float) get_2bytes(image->fp); + image->width = (float) get_2bytes(image->fp); + image->components = pdc_fgetc(image->fp); + + /* + * No need to read more markers since multiscan detection + * not required for single-component images. + */ + if (image->components == 1) + markers_done = pdc_true; + + break; + + case M_APP0: /* check for JFIF marker with resolution */ + length = get_2bytes(image->fp); + + for (i = 0; i < length-2; i++) { /* get contents of marker */ + b = pdc_fgetc(image->fp); + if (i < APP_MAX) /* store marker in appstring */ + appstring[i] = (unsigned char) b; + } + + /* Check for JFIF application marker and read density values + * per JFIF spec version 1.02. + */ + +#define JFIF_ASPECT_RATIO 0 /* JFIF unit byte: aspect ratio only */ +#define JFIF_DOTS_PER_INCH 1 /* JFIF unit byte: dots per inch */ +#define JFIF_DOTS_PER_CM 2 /* JFIF unit byte: dots per cm */ + +#define PDF_STRING_JFIF "\112\106\111\106" + + if (length >= 14 && !strncmp(PDF_STRING_JFIF, (char *) appstring, 4)) { + unit = appstring[7]; /* resolution unit */ + /* resolution value */ + image->dpi_x = (float) ((appstring[8]<<8) + appstring[9]); + image->dpi_y = (float) ((appstring[10]<<8) + appstring[11]); + + if (image->dpi_x <= (float) 0.0 || image->dpi_y <= (float) 0.0) { + image->dpi_x = (float) 0.0; + image->dpi_y = (float) 0.0; + break; + } + + switch (unit) { + case JFIF_DOTS_PER_INCH: + break; + + case JFIF_DOTS_PER_CM: + image->dpi_x *= (float) 2.54; + image->dpi_y *= (float) 2.54; + break; + + case JFIF_ASPECT_RATIO: + image->dpi_x *= -1; + image->dpi_y *= -1; + break; + + default: /* unknown ==> ignore */ + /* */ ; + } + } + + break; + + +#ifdef NYI + /* LATER: read SPIFF marker */ + case M_APP8: /* check for SPIFF marker */ + + break; +#endif + + case M_APP13: /* check for Photoshop marker */ + length = get_2bytes(image->fp); + + /* get marker contents */ + length -= 2; /* account for two length bytes */ + app13 = (pdc_byte*)pdc_malloc(p->pdc, length, fn); + + if (!PDC_OK_FREAD(image->fp, app13, length)) { + pdc_free(p->pdc, app13); + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_JPEG_ERROR; + } + +#define PS_HEADER_LEN 14 +#define PDF_STRING_Photoshop "\120\150\157\164\157\163\150\157\160" +#define PDF_STRING_8BIM "\070\102\111\115" +#define RESOLUTION_INFO_ID 0x03ED /* resolution info resource block */ +#define PS_FIXED_TO_FLOAT(h, l) ((float) (h) + ((float) (l)/(1<<16))) + + /* Not a valid Photoshop marker */ + if (length < 9 || strncmp(PDF_STRING_Photoshop, (char *) app13, 9)) { + pdc_free(p->pdc, app13); + break; + } + + /* walk all image resource blocks and look for ResolutionInfo */ + for (s = app13 + PS_HEADER_LEN; s < app13 + length; /* */) { + long len; + unsigned int type; + + if (strncmp((char *) s, PDF_STRING_8BIM, 4)) + break; /* out of sync */ + s += 4; /* identifying string */ + + type = (unsigned int) ((s[0]<<8) + s[1]); + s += 2; /* resource type */ + + s += *s + ((*s & 1) ? 1 : 2); /* resource name */ + + len = (((((s[0]<<8) + s[1])<<8) + s[2])<<8) + s[3]; + s += 4; /* Size */ + + if (type == RESOLUTION_INFO_ID && len >= 16) { + image->dpi_x = + PS_FIXED_TO_FLOAT((s[0]<<8) + s[1], (s[2]<<8) + s[3]); + image->dpi_y = + PS_FIXED_TO_FLOAT((s[8]<<8) + s[9], (s[10]<<8) + s[11]); + break; + } + + s += len + ((len & 1) ? 1 : 0); /* Data */ + } + + pdc_free(p->pdc, app13); + break; + + case M_APP14: /* check for Adobe marker */ + length = get_2bytes(image->fp); + + for (i = 0; i < length-2; i++) { /* get contents of marker */ + b = pdc_fgetc(image->fp); + if (i < APP_MAX) /* store marker in appstring */ + appstring[i] = (unsigned char) b; + else + break; + } + + /* + * Check for Adobe application marker. It is known (per Adobe's TN5116) + * to contain the string "Adobe" at the start of the APP14 marker. + */ +#define PDF_STRING_Adobe "\101\144\157\142\145" + + if (length >= 12 && !strncmp(PDF_STRING_Adobe, (char *) appstring, 5)) + adobeflag = pdc_true; /* set Adobe flag */ + + break; + + case M_SOS: + markers_done = pdc_true; + length = get_2bytes(image->fp); + + /* + * If the scan doesn't contain all components it must be + * a multiscan image, which doesn't work in Acrobat. + */ + if (pdc_fgetc(image->fp) < image->components) { + errcode = PDF_E_JPEG_MULTISCAN; + goto PDF_JPEG_ERROR; + } + + /* account for the "number of components in scan" byte just read */ + for (length -= 3; length > 0; length--) { + if (pdc_feof(image->fp)) { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_JPEG_ERROR; + } + (void) pdc_fgetc(image->fp); + } + break; + + case M_SOI: /* ignore markers without parameters */ + case M_EOI: + case M_TEM: + case M_RST0: + case M_RST1: + case M_RST2: + case M_RST3: + case M_RST4: + case M_RST5: + case M_RST6: + case M_RST7: + break; + + default: /* skip variable length markers */ + length = get_2bytes(image->fp); + for (length -= 2; length > 0; length--) { + if (pdc_feof(image->fp)) { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_JPEG_ERROR; + } + (void) pdc_fgetc(image->fp); + } + break; + } + } + + /* do some sanity checks with the parameters */ + if (image->height <= 0 || image->width <= 0 || image->components <= 0) { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_JPEG_ERROR; + } + + if (image->bpc != 8) { + errint = image->bpc; + errcode = PDF_E_IMAGE_BADDEPTH; + goto PDF_JPEG_ERROR; + } + + + { + switch (image->components) { + case 1: + /* spot color may have been applied */ + if (image->colorspace == pdc_undef) + image->colorspace = DeviceGray; + break; + + case 3: + image->colorspace = DeviceRGB; + break; + + case 4: + image->colorspace = DeviceCMYK; + break; + + default: + errint = image->components; + errcode = PDF_E_IMAGE_BADCOMP; + goto PDF_JPEG_ERROR; + } + } + + + if (image->imagemask) + { + if (image->components != 1) { + errcode = PDF_E_IMAGE_BADMASK; + goto PDF_JPEG_ERROR; + } + + if (p->compatibility <= PDC_1_3) { + errcode = PDF_E_IMAGE_MASK1BIT13; + goto PDF_JPEG_ERROR; + } else { + /* images with more than one bit will be written as /SMask, + * and don't require an /ImageMask entry. + */ + image->imagemask = pdc_false; + } + } + + /* special handling of Photoshop-generated CMYK JPEG files */ + if (adobeflag && p->colorspaces[image->colorspace].type == DeviceCMYK) { + image->invert = !image->invert; + } + + image->in_use = pdc_true; /* mark slot as used */ + + if (image->doinline) + pdf_put_inline_image(p, imageslot); + else + pdf_put_image(p, imageslot, pdc_true); + + return imageslot; + + PDF_JPEG_ERROR: + { + const char *stemp = pdc_errprintf(p->pdc, "%s", image->filename); + switch (errcode) + { + case PDF_E_IMAGE_ICC: + case PDF_E_IMAGE_ICC2: + case PDF_E_IMAGE_COLORIZE: + case PDF_E_JPEG_MULTISCAN: + case PDF_E_IMAGE_BADMASK: + pdc_set_errmsg(p->pdc, errcode, stemp, 0, 0, 0); + break; + + case PDC_E_IO_BADFORMAT: + pdc_set_errmsg(p->pdc, errcode, stemp, "JPEG", 0, 0); + break; + + case PDF_E_IMAGE_CORRUPT: + pdc_set_errmsg(p->pdc, errcode, "JPEG", stemp, 0, 0); + break; + + case PDF_E_JPEG_COMPRESSION: + case PDF_E_IMAGE_BADDEPTH: + case PDF_E_IMAGE_BADCOMP: + pdc_set_errmsg(p->pdc, errcode, + pdc_errprintf(p->pdc, "%d", errint), stemp, 0, 0); + break; + + case 0: /* error code and message already set */ + break; + } + } + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; +} + +#endif /* PDF_JPEG_SUPPORTED */ diff --git a/src/libs/pdflib/libs/pdflib/p_kerning.c b/src/libs/pdflib/libs/pdflib/p_kerning.c new file mode 100644 index 0000000000..bc07ba6d6e --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_kerning.c @@ -0,0 +1,38 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_kerning.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib kerning routines + * + */ + +#include "p_intern.h" +#include "p_font.h" +#include "p_truetype.h" + + +PDFLIB_API float PDFLIB_CALL +PDF_get_kern_amount( PDF *p, int font, int firstchar, int secondchar) +{ + static const char fn[] = "PDF_get_kern_amount"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_content | pdf_state_path), + "(p[%p], %d, %d, %d)", (void *) p, font, firstchar, secondchar)) + return (float) 0; + + pdc_warning(p->pdc, PDF_E_UNSUPP_KERNING, 0, 0, 0, 0); + + return (float) 0; +} + diff --git a/src/libs/pdflib/libs/pdflib/p_keyconn.h b/src/libs/pdflib/libs/pdflib/p_keyconn.h new file mode 100644 index 0000000000..0a4d2011a8 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_keyconn.h @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_keyconn.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib shared keys connection lists + * + */ + +#ifndef P_KEYCONN_H +#define P_KEYCONN_H + +#if defined(P_IMAGE_C) || defined(P_XGSTATE_C) || defined(P_PARAMS_C) +static const pdc_keyconn gs_renderingintents[] = +{ + {"Auto", AutoIntent}, + {"AbsoluteColorimetric", AbsoluteColorimetric}, + {"RelativeColorimetric", RelativeColorimetric}, + {"Saturation", Saturation}, + {"Perceptual", Perceptual}, + {NULL, 0} +}; +#endif /* P_IMAGE_C || P_XGSTATE_C || P_PARAMS_C */ + +#if defined(P_XGSTATE_C) +static const pdc_keyconn gs_blendmodes[] = +{ + {"Normal", BM_Normal}, + {"Multiply", BM_Multiply}, + {"Screen", BM_Screen}, + {"Overlay", BM_Overlay}, + {"Darken", BM_Darken}, + {"Lighten", BM_Lighten}, + {"ColorDodge", BM_ColorDodge}, + {"ColorBurn", BM_ColorBurn}, + {"HardLight", BM_HardLight}, + {"SoftLight", BM_SoftLight}, + {"Difference", BM_Difference}, + {"Exclusion", BM_Exclusion}, + {"Hue", BM_Hue}, + {"Saturation", BM_Saturation}, + {"Color", BM_Color}, + {"Luminosity", BM_Luminosity}, + {NULL, 0} +}; +#endif /* P_XGSTATE_C */ + +#if defined(P_PDI_C) || defined(P_PARAMS_C) +static const pdc_keyconn pdf_usebox_keylist[] = +{ + {"art", use_art}, + {"bleed", use_bleed}, + {"crop", use_crop}, + {"media", use_media}, + {"trim", use_trim}, + {NULL, 0} +}; +#endif /* P_PDI_C || P_PARAMS_C */ + +#if defined(P_TEXT_C) || defined(P_PARAMS_C) || defined(P_BLOCK_C) +static const pdc_keyconn pdf_textformat_keylist[] = +{ + {"auto", pdc_auto}, + {"auto2", pdc_auto2}, + {"bytes", pdc_bytes}, + {"bytes2", pdc_bytes2}, + {"utf8", pdc_utf8}, + {"utf16", pdc_utf16}, + {"utf16be", pdc_utf16be}, + {"utf16le", pdc_utf16le}, + {NULL, 0} +}; +#endif /* P_TEXT_C || P_PARAMS_C || P_BLOCK_C */ + +#if defined(P_TEXT_C) || defined(P_IMAGE_C) || defined(P_BLOCK_C) +static const pdc_keyconn pdf_orientate_keylist[] = +{ + {"north", 0}, + {"west", 90}, + {"south", 180}, + {"east", 270}, + {NULL, 0} +}; +#endif /* P_TEXT_C || P_IMAGE_C || P_BLOCK_C */ + +#if defined(P_TEXT_C) || defined(P_IMAGE_C) || defined(P_BLOCK_C) +static const pdc_keyconn pdf_fitmethod_keylist[] = +{ + {"nofit", pdc_nofit}, + {"clip", pdc_clip}, + {"slice", pdc_slice}, + {"meet", pdc_meet}, + {"entire", pdc_entire}, + {"auto", pdc_tauto}, + {NULL, 0} +}; +#endif /* P_TEXT_C || P_IMAGE_C || P_BLOCK_C */ + +#if defined(P_FONT_C) || defined(P_HYPER_C) || defined(P_BLOCK_C) +static const pdc_keyconn pdf_fontstyle_keylist[] = +{ + {"normal", pdc_Normal}, + {"bold", pdc_Bold }, + {"italic", pdc_Italic}, + {"bolditalic", pdc_BoldItalic}, + {NULL, 0} +}; +#endif /* P_FONT_C || P_HYPER_C || P_BLOCK_C */ + +#if defined(P_COLOR_C) || defined(P_BLOCK_C) +static const pdc_keyconn pdf_colorspace_keylist[] = +{ + {"none", NoColor}, + {"gray", DeviceGray}, + {"rgb", DeviceRGB }, + {"cmyk", DeviceCMYK}, + {"spotname", Separation}, + {"spot", Separation}, + {"pattern", PatternCS}, + {"iccbasedgray", ICCBased}, + {"iccbasedrgb", ICCBased}, + {"iccbasedcmyk", ICCBased}, + {"lab", Lab}, + {NULL, 0} +}; +#endif /* P_COLOR_C || P_BLOCK_C */ + +#if defined(P_IMAGE_C) || defined(P_BLOCK_C) +typedef enum +{ + dpi_none = -999999, + dpi_internal = 0 +} +pdf_dpi_states; + +static const pdc_keyconn pdf_dpi_keylist[] = +{ + {"none", dpi_none}, + {"internal", dpi_internal}, + {NULL, 0} +}; +#endif /* P_IMAGE_C || P_BLOCK_C */ + +#endif /* P_KEYCONN_H */ diff --git a/src/libs/pdflib/libs/pdflib/p_pantlab.h b/src/libs/pdflib/libs/pdflib/p_pantlab.h new file mode 100644 index 0000000000..565263216b --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_pantlab.h @@ -0,0 +1,28 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_pantlab.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib PANTONE spot LAB color table derived from + * PANTONE MATCHING SYSTEM + * + * PANTONE and PANTONE MATCHING SYSTEM is a registered trademark of + * Pantone,Inc. + * + */ + +#ifndef P_PANTLAB_H +#define P_PANTLAB_H + + +#endif /* P_PANTAB_H */ + diff --git a/src/libs/pdflib/libs/pdflib/p_params.c b/src/libs/pdflib/libs/pdflib/p_params.c new file mode 100644 index 0000000000..741de4effb --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_params.c @@ -0,0 +1,1060 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_params.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib parameter handling + * + */ + +#define P_PARAMS_C + +#include "p_intern.h" +#include "p_font.h" +#include "p_image.h" + +/* + * PDF_get_parameter() and PDF_set_parameter() deal with strings, + * PDF_get_value() and PDF_set_value() deal with numerical values. + */ + +typedef struct +{ + char * name; /* parameter name */ + pdc_bool mod_zero; /* PDF_get_() modifier argument must be 0 */ + int get_scope; /* bit mask of legal states for PDF_get_() */ + int set_scope; /* bit mask of legal states for PDF_set_() */ +} pdf_parm_descr; + +static pdf_parm_descr parms[] = +{ +#define pdf_gen_parm_descr 1 +#include "p_params.h" +#undef pdf_gen_parm_descr + + { "", 0, 0, 0 } +}; + +enum +{ +#define pdf_gen_parm_enum 1 +#include "p_params.h" +#undef pdf_gen_parm_enum + + PDF_PARAMETER_LIMIT +}; + +static int +get_index(const char *key) +{ + int i; + + for (i = 0; i < PDF_PARAMETER_LIMIT; ++i) + if (strcmp(key, parms[i].name) == 0) + return i; + + return -1; +} + +static pdc_bool +pdf_bool_value(PDF *p, const char *key, const char *value) +{ + if (!strcmp(value, "true")) + return pdc_true; + + if (!strcmp(value, "false")) + return pdc_false; + + pdc_error(p->pdc, PDC_E_ILLARG_BOOL, key, value, 0, 0); + + return pdc_false; /* compilers love it */ +} + +PDFLIB_API void PDFLIB_CALL +PDF_set_parameter(PDF *p, const char *key, const char *value) +{ + static const char fn[] = "PDF_set_parameter"; + pdc_usebox usebox = use_none; + pdc_text_format textformat = pdc_auto; + int i, k; + + if (key == NULL || !*key) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "key", 0, 0, 0); + + i = get_index(key); + + if (!pdf_enter_api(p, fn, (pdf_state) pdf_state_all, + "(p[%p], \"%s\", \"%s\")\n", (void *) p, key, value)) + return; + + if (i == -1) + pdc_error(p->pdc, PDC_E_PAR_UNKNOWNKEY, key, 0, 0, 0); + + if ((p->state_stack[p->state_sp] & parms[i].set_scope) == 0) + pdc_error(p->pdc, PDF_E_DOC_SCOPE_SET, key, pdf_current_scope(p), 0, 0); + + if (value == NULL) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "value", 0, 0, 0); + + switch (i) + { + case PDF_PARAMETER_PDIUSEBOX: + case PDF_PARAMETER_VIEWAREA: + case PDF_PARAMETER_VIEWCLIP: + case PDF_PARAMETER_PRINTAREA: + case PDF_PARAMETER_PRINTCLIP: + k = pdc_get_keycode(value, pdf_usebox_keylist); + if (k == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + usebox = (pdc_usebox) k; + break; + + case PDF_PARAMETER_TEXTFORMAT: + case PDF_PARAMETER_HYPERTEXTFORMAT: + k = pdc_get_keycode(value, pdf_textformat_keylist); + if (k == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + textformat = (pdc_text_format) k; + break; + } + + switch (i) + { + case PDF_PARAMETER_SEARCHPATH: + case PDF_PARAMETER_FONTAFM: + case PDF_PARAMETER_FONTPFM: + case PDF_PARAMETER_FONTOUTLINE: + case PDF_PARAMETER_HOSTFONT: + case PDF_PARAMETER_ENCODING: + case PDF_PARAMETER_ICCPROFILE: + case PDF_PARAMETER_STANDARDOUTPUTINTENT: + { + pdf_add_resource(p, key, value); + break; + } + + case PDF_PARAMETER_FLUSH: + if (p->binding != NULL && strcmp(p->binding, "C++")) + break; + + if (!strcmp(value, "none")) + p->flush = pdf_flush_none; + else if (!strcmp(value, "page")) + p->flush = (pdf_flush_state) (p->flush | pdf_flush_page); + else if (!strcmp(value, "content")) + p->flush = (pdf_flush_state) (p->flush | pdf_flush_content); + else if (!strcmp(value, "heavy")) + p->flush = (pdf_flush_state) (p->flush | pdf_flush_heavy); + else + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + + break; + + case PDF_PARAMETER_DEBUG: + { + const unsigned char *c; + + for (c = (const unsigned char *) value; *c; c++) { + p->debug[(int) *c] = 1; + + if (*c == 't') { + pdc_set_trace(p->pdc, "PDFlib " PDFLIB_VERSIONSTRING); + } + } + break; + } + + case PDF_PARAMETER_NODEBUG: + { + const unsigned char *c; + + for (c = (const unsigned char *) value; *c; c++) { + if (*c == 't') + pdc_set_trace(p->pdc, NULL); + + p->debug[(int) *c] = 0; + } + break; + } + + case PDF_PARAMETER_BINDING: + if (!p->binding) + p->binding = pdc_strdup(p->pdc, value); + break; + + case PDF_PARAMETER_HASTOBEPOS: + p->hastobepos = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_UNDERLINE: + p->underline = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_OVERLINE: + p->overline = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_STRIKEOUT: + p->strikeout = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_KERNING: + pdc_warning(p->pdc, PDF_E_UNSUPP_KERNING, 0, 0, 0, 0); + break; + + case PDF_PARAMETER_AUTOSUBSETTING: + pdc_warning(p->pdc, PDF_E_UNSUPP_SUBSET, 0, 0, 0, 0); + break; + + case PDF_PARAMETER_AUTOCIDFONT: + pdc_warning(p->pdc, PDF_E_UNSUPP_UNICODE, 0, 0, 0, 0); + break; + + case PDF_PARAMETER_UNICODEMAP: + pdc_warning(p->pdc, PDF_E_UNSUPP_UNICODE, 0, 0, 0, 0); + break; + + case PDF_PARAMETER_MASTERPASSWORD: + pdc_warning(p->pdc, PDF_E_UNSUPP_CRYPT, 0, 0, 0, 0); + break; + + case PDF_PARAMETER_USERPASSWORD: + pdc_warning(p->pdc, PDF_E_UNSUPP_CRYPT, 0, 0, 0, 0); + break; + + case PDF_PARAMETER_PERMISSIONS: + pdc_warning(p->pdc, PDF_E_UNSUPP_CRYPT, 0, 0, 0, 0); + break; + + case PDF_PARAMETER_COMPATIBILITY: + + if (!strcmp(value, "1.3")) + p->compatibility = PDC_1_3; + else if (!strcmp(value, "1.4")) + p->compatibility = PDC_1_4; + else if (!strcmp(value, "1.5")) + p->compatibility = PDC_1_5; + else + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + break; + + case PDF_PARAMETER_PDFX: + pdc_warning(p->pdc, PDF_E_UNSUPP_PDFX, 0, 0, 0, 0); + + break; + + + case PDF_PARAMETER_RESOURCEFILE: + if (p->resourcefilename) + { + pdc_free(p->pdc, p->resourcefilename); + p->resourcefilename = NULL; + } + p->resourcefilename = pdc_strdup(p->pdc, value); + p->resfilepending = pdc_true; + break; + + case PDF_PARAMETER_PREFIX: + if (p->prefix) + { + pdc_free(p->pdc, p->prefix); + p->prefix = NULL; + } + /* because of downward compatibility */ + p->prefix = pdc_strdup(p->pdc, &value[value[0] == '/' ? 1 : 0]); + break; + + case PDF_PARAMETER_WARNING: + pdc_set_warnings(p->pdc, pdf_bool_value(p, key, value)); + break; + + case PDF_PARAMETER_OPENWARNING: + p->debug['o'] = (char) pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_FONTWARNING: + p->debug['F'] = (char) pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_ICCWARNING: + p->debug['I'] = (char) pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_IMAGEWARNING: + p->debug['i'] = (char) pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_PDIWARNING: + p->debug['p'] = (char) pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_HONORICCPROFILE: + p->debug['e'] = (char) pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_GLYPHWARNING: + p->debug['g'] = (char) pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_RENDERINGINTENT: + k = pdc_get_keycode(value, gs_renderingintents); + if (k == PDC_KEY_NOTFOUND) + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + p->rendintent = (pdf_renderingintent) k; + break; + + case PDF_PARAMETER_PRESERVEOLDPANTONENAMES: + p->preserveoldpantonenames = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_SPOTCOLORLOOKUP: + p->spotcolorlookup = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_INHERITGSTATE: + p->inheritgs = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_PDISTRICT: + p->pdi_strict = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_PDIUSEBOX: + p->pdi_usebox = usebox; + break; + + case PDF_PARAMETER_PASSTHROUGH: + p->debug['P'] = (char) !pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_HIDETOOLBAR: + if (pdf_bool_value(p, key, value)) + p->ViewerPreferences.flags |= HideToolbar; + break; + + case PDF_PARAMETER_HIDEMENUBAR: + if (pdf_bool_value(p, key, value)) + p->ViewerPreferences.flags |= HideMenubar; + break; + + case PDF_PARAMETER_HIDEWINDOWUI: + if (pdf_bool_value(p, key, value)) + p->ViewerPreferences.flags |= HideWindowUI; + break; + + case PDF_PARAMETER_FITWINDOW: + if (pdf_bool_value(p, key, value)) + p->ViewerPreferences.flags |= FitWindow; + break; + + case PDF_PARAMETER_CENTERWINDOW: + if (pdf_bool_value(p, key, value)) + p->ViewerPreferences.flags |= CenterWindow; + break; + + case PDF_PARAMETER_DISPLAYDOCTITLE: + if (pdf_bool_value(p, key, value)) + p->ViewerPreferences.flags |= DisplayDocTitle; + break; + + case PDF_PARAMETER_NONFULLSCREENPAGEMODE: + if (!strcmp(value, "useoutlines")) { + p->ViewerPreferences.flags |= NonFullScreenPageModeOutlines; + p->ViewerPreferences.flags &= ~NonFullScreenPageModeThumbs; + } else if (!strcmp(value, "usethumbs")) { + p->ViewerPreferences.flags &= ~NonFullScreenPageModeOutlines; + p->ViewerPreferences.flags |= NonFullScreenPageModeThumbs; + } else if (!strcmp(value, "usenone")) { + p->ViewerPreferences.flags &= ~NonFullScreenPageModeOutlines; + p->ViewerPreferences.flags &= ~NonFullScreenPageModeThumbs; + } else { + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + } + + break; + + case PDF_PARAMETER_DIRECTION: + if (!strcmp(value, "r2l")) { + p->ViewerPreferences.flags |= DirectionR2L; + } else if (!strcmp(value, "l2r")) { + p->ViewerPreferences.flags &= ~DirectionR2L; + } else { + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + } + break; + + case PDF_PARAMETER_VIEWAREA: + p->ViewerPreferences.ViewArea = usebox; + break; + + case PDF_PARAMETER_VIEWCLIP: + p->ViewerPreferences.ViewClip = usebox; + break; + + case PDF_PARAMETER_PRINTAREA: + p->ViewerPreferences.PrintArea = usebox; + break; + + case PDF_PARAMETER_PRINTCLIP: + p->ViewerPreferences.PrintClip = usebox; + break; + + case PDF_PARAMETER_TOPDOWN: + if (pdf_bool_value(p, key, value)) + p->ydirection = (float) -1.0; + else + p->ydirection = (float) 1.0; + break; + + case PDF_PARAMETER_USERCOORDINATES: + p->usercoordinates = pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_OPENACTION: + pdf_cleanup_destination(p, &p->open_action); + + pdf_parse_destination_optlist(p, + value, &p->open_action, 1, pdf_openaction); + break; + + case PDF_PARAMETER_OPENMODE: + if (!strcmp(value, "none")) { + p->open_mode = open_none; + } else if (!strcmp(value, "bookmarks")) { + p->open_mode = open_bookmarks; + } else if (!strcmp(value, "thumbnails")) { + p->open_mode = open_thumbnails; + } else if (!strcmp(value, "fullscreen")) { + p->open_mode = open_fullscreen; + } else { + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + } + break; + + case PDF_PARAMETER_BOOKMARKDEST: + pdf_cleanup_destination(p, &p->bookmark_dest); + + pdf_parse_destination_optlist(p, + value, &p->bookmark_dest, 0, pdf_bookmark); + break; + + case PDF_PARAMETER_FILLRULE: + if (!strcmp(value, "winding")) { + p->fillrule = pdf_fill_winding; + } else if (!strcmp(value, "evenodd")) { + p->fillrule = pdf_fill_evenodd; + } else { + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + } + break; + + case PDF_PARAMETER_TEXTFORMAT: + p->textformat = textformat; + break; + + case PDF_PARAMETER_HYPERTEXTFORMAT: + p->hypertextformat = textformat; + break; + + case PDF_PARAMETER_HYPERTEXTENCODING: + { + pdc_encoding enc; + + if (!*value) + { + enc = pdc_unicode; + } + else + { + enc = pdf_find_encoding(p, (const char *) value); + if (enc == pdc_invalidenc) + enc = pdf_insert_encoding(p, (const char *) value); + if (enc < 0 && enc != pdc_unicode) + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, value, key, 0, 0); + } + p->hypertextencoding = enc; + break; + } + + /* deprecated */ + case PDF_PARAMETER_NATIVEUNICODE: + (void) pdf_bool_value(p, key, value); + break; + + case PDF_PARAMETER_TRANSITION: + pdf_set_transition(p, value); + break; + + case PDF_PARAMETER_BASE: + if (p->base) { + pdc_free(p->pdc, p->base); + p->base = NULL; + } + + p->base = pdc_strdup(p->pdc, value); + break; + + case PDF_PARAMETER_LAUNCHLINK_PARAMETERS: + if (p->launchlink_parameters) { + pdc_free(p->pdc, p->launchlink_parameters); + p->launchlink_parameters = NULL; + } + p->launchlink_parameters = pdc_strdup(p->pdc, value); + break; + + case PDF_PARAMETER_LAUNCHLINK_OPERATION: + if (p->launchlink_operation) { + pdc_free(p->pdc, p->launchlink_operation); + p->launchlink_operation = NULL; + } + p->launchlink_operation = pdc_strdup(p->pdc, value); + break; + + case PDF_PARAMETER_LAUNCHLINK_DEFAULTDIR: + if (p->launchlink_defaultdir) { + pdc_free(p->pdc, p->launchlink_defaultdir); + p->launchlink_defaultdir = NULL; + } + p->launchlink_defaultdir = pdc_strdup(p->pdc, value); + break; + + case PDF_PARAMETER_TRACE: + if (pdf_bool_value(p, key, value)) { + p->debug['t'] = 1; + pdc_set_trace(p->pdc, "PDFlib " PDFLIB_VERSIONSTRING); + } else { + pdc_set_trace(p->pdc, NULL); + p->debug['t'] = 0; + } + break; + + case PDF_PARAMETER_TRACEFILE: + pdc_set_tracefile(p->pdc, value); + break; + + case PDF_PARAMETER_TRACEMSG: + /* do nothing -- client-supplied string will show up in the trace */ + break; + + case PDF_PARAMETER_SERIAL: + case PDF_PARAMETER_LICENSE: + break; + + case PDF_PARAMETER_LICENSEFILE: + break; + + default: + pdc_error(p->pdc, PDC_E_PAR_UNKNOWNKEY, key, 0, 0, 0); + break; + } /* switch */ +} /* PDF_set_parameter */ + +static float +pdf_value(PDF *p, const char *key, float value, int minver) +{ + if (p->compatibility < minver) + pdc_error(p->pdc, PDC_E_PAR_VERSION, + key, pdc_errprintf(p->pdc, "%d.%d", minver/10, minver%10), 0, 0); + + return value; +} + +static float +pdf_pos_value(PDF *p, const char *key, float value, int minver) +{ + if (p->compatibility < minver) + pdc_error(p->pdc, PDC_E_PAR_VERSION, + key, pdc_errprintf(p->pdc, "%d.%d", minver/10, minver%10), 0, 0); + + if (value <= (float) 0) + pdc_error(p->pdc, PDC_E_PAR_ILLVALUE, + pdc_errprintf(p->pdc, "%f", value), key, 0, 0); + + return value; +} + +PDFLIB_API void PDFLIB_CALL +PDF_set_value(PDF *p, const char *key, float value) +{ + static const char fn[] = "PDF_set_value"; + int i; + int ivalue = (int) value; + + if (key == NULL || !*key) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "key", 0, 0, 0); + + i = get_index(key); + + if (!pdf_enter_api(p, fn, (pdf_state) pdf_state_all, + "(p[%p], \"%s\", %g)\n", (void *) p, key, value)) + return; + + if (i == -1) + pdc_error(p->pdc, PDC_E_PAR_UNKNOWNKEY, key, 0, 0, 0); + + if ((p->state_stack[p->state_sp] & parms[i].set_scope) == 0) + pdc_error(p->pdc, PDF_E_DOC_SCOPE_SET, key, pdf_current_scope(p), 0, 0); + + switch (i) + { + case PDF_PARAMETER_COMPRESS: + if (ivalue < 0 || ivalue > 9) + pdc_error(p->pdc, PDC_E_PAR_ILLVALUE, + pdc_errprintf(p->pdc, "%f", value), key, 0, 0); + + if (pdc_get_compresslevel(p->out) != ivalue) + { + /* + * We must restart the compression engine and start a new + * contents section if we're in the middle of a page. + */ + if (PDF_GET_STATE(p) == pdf_state_page) { + pdf_end_contents_section(p); + pdc_set_compresslevel(p->out, ivalue); + pdf_begin_contents_section(p); + } else + pdc_set_compresslevel(p->out, ivalue); + } + + break; + + case PDF_PARAMETER_FLOATDIGITS: + if (3 <= ivalue && ivalue <= 6) + pdc_set_floatdigits(p->pdc, ivalue); + else + pdc_error(p->pdc, PDC_E_PAR_ILLVALUE, + pdc_errprintf(p->pdc, "%d", ivalue), key, 0, 0); + break; + + case PDF_PARAMETER_PAGEWIDTH: + if (p->ydirection == -1) + pdc_error(p->pdc, PDF_E_PAGE_ILLCHGSIZE, 0, 0, 0, 0); + if (p->compatibility >= PDC_1_3 && + (value < PDF_ACRO4_MINPAGE || value > PDF_ACRO4_MAXPAGE)) + pdc_warning(p->pdc, PDF_E_PAGE_SIZE_ACRO4, 0, 0, 0, 0); + + p->width = pdf_pos_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_PAGEHEIGHT: + if (p->ydirection == -1) + pdc_error(p->pdc, PDF_E_PAGE_ILLCHGSIZE, 0, 0, 0, 0); + if (p->compatibility >= PDC_1_3 && + (value < PDF_ACRO4_MINPAGE || value > PDF_ACRO4_MAXPAGE)) + pdc_warning(p->pdc, PDF_E_PAGE_SIZE_ACRO4, 0, 0, 0, 0); + + p->height = pdf_pos_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_CROPBOX_LLX: + p->CropBox.llx = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_CROPBOX_LLY: + p->CropBox.lly = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_CROPBOX_URX: + p->CropBox.urx = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_CROPBOX_URY: + p->CropBox.ury = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_BLEEDBOX_LLX: + p->BleedBox.llx = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_BLEEDBOX_LLY: + p->BleedBox.lly = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_BLEEDBOX_URX: + p->BleedBox.urx = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_BLEEDBOX_URY: + p->BleedBox.ury = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_TRIMBOX_LLX: + p->TrimBox.llx = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_TRIMBOX_LLY: + p->TrimBox.lly = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_TRIMBOX_URX: + p->TrimBox.urx = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_TRIMBOX_URY: + p->TrimBox.ury = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_ARTBOX_LLX: + p->ArtBox.llx = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_ARTBOX_LLY: + p->ArtBox.lly = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_ARTBOX_URX: + p->ArtBox.urx = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_ARTBOX_URY: + p->ArtBox.ury = pdf_value(p, key, value, PDC_1_3); + break; + + case PDF_PARAMETER_LEADING: + pdf_set_leading(p, value); + break; + + case PDF_PARAMETER_TEXTRISE: + pdf_set_text_rise(p, value); + break; + + case PDF_PARAMETER_HORIZSCALING: + pdf_set_horiz_scaling(p, value); + break; + + case PDF_PARAMETER_TEXTRENDERING: + pdf_set_text_rendering(p, (int) value); + break; + + case PDF_PARAMETER_CHARSPACING: + pdf_set_char_spacing(p, value); + break; + + case PDF_PARAMETER_WORDSPACING: + pdf_set_word_spacing(p, value); + break; + + case PDF_PARAMETER_DURATION: + pdf_set_duration(p, value); + break; + + case PDF_PARAMETER_DEFAULTGRAY: + break; + + case PDF_PARAMETER_DEFAULTRGB: + break; + + case PDF_PARAMETER_DEFAULTCMYK: + break; + + case PDF_PARAMETER_SETCOLOR_ICCPROFILEGRAY: + break; + + case PDF_PARAMETER_SETCOLOR_ICCPROFILERGB: + break; + + case PDF_PARAMETER_SETCOLOR_ICCPROFILECMYK: + break; + + case PDF_PARAMETER_SUBSETLIMIT: + pdc_warning(p->pdc, PDF_E_UNSUPP_SUBSET, 0, 0, 0, 0); + break; + + case PDF_PARAMETER_SUBSETMINSIZE: + pdc_warning(p->pdc, PDF_E_UNSUPP_SUBSET, 0, 0, 0, 0); + break; + + default: + pdc_error(p->pdc, PDC_E_PAR_UNKNOWNKEY, key, 0, 0, 0); + break; + } /* switch */ +} /* PDF_set_value */ + +PDFLIB_API float PDFLIB_CALL +PDF_get_value(PDF *p, const char *key, float mod) +{ + static const char fn[] = "PDF_get_value"; + int i = -1; + int imod = (int) mod; + float result = (float) 0; + + /* some parameters can be retrieved with p == 0. + */ + if (key != NULL && (i = get_index(key)) != -1) + { + switch (i) + { + case PDF_PARAMETER_MAJOR: + result = PDFLIB_MAJORVERSION; + return result; + + case PDF_PARAMETER_MINOR: + result = PDFLIB_MINORVERSION; + return result; + + case PDF_PARAMETER_REVISION: + result = PDFLIB_REVISION; + return result; + } /* switch */ + } + + if (!pdf_enter_api(p, fn, (pdf_state) pdf_state_all, + "(p[%p], \"%s\", %g)", (void *) p, key, mod)) + return (float) 0; + + if (i == -1) + pdc_error(p->pdc, PDC_E_PAR_UNKNOWNKEY, key, 0, 0, 0); + + if ((p->state_stack[p->state_sp] & parms[i].get_scope) == 0) + pdc_error(p->pdc, PDF_E_DOC_SCOPE_GET, key, pdf_current_scope(p), 0, 0); + + if (key == NULL || !*key) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "key", 0, 0, 0); + + if (parms[i].mod_zero && mod != (float) 0) + pdc_error(p->pdc, PDC_E_PAR_ILLVALUE, + pdc_errprintf(p->pdc, "%f", mod), key, 0, 0); + + switch (i) + { + case PDF_PARAMETER_IMAGEWIDTH: + case PDF_PARAMETER_IMAGEHEIGHT: + case PDF_PARAMETER_RESX: + case PDF_PARAMETER_RESY: + PDF_INPUT_HANDLE(p, imod) + pdf_check_handle(p, imod, pdc_imagehandle); + break; + + case PDF_PARAMETER_FONTMAXCODE: + case PDF_PARAMETER_CAPHEIGHT: + case PDF_PARAMETER_ASCENDER: + case PDF_PARAMETER_DESCENDER: + PDF_INPUT_HANDLE(p, imod) + pdf_check_handle(p, imod, pdc_fonthandle); + break; + } + + switch (i) + { + case PDF_PARAMETER_PAGEWIDTH: + result = p->width; + break; + + case PDF_PARAMETER_PAGEHEIGHT: + result = p->height; + break; + + case PDF_PARAMETER_IMAGEWIDTH: + result = (float) (p->images[imod].width); + break; + + case PDF_PARAMETER_IMAGEHEIGHT: + result = (float) fabs((double) (p->images[imod].height)); + break; + + case PDF_PARAMETER_RESX: + result = (float) (p->images[imod].dpi_x); + break; + + case PDF_PARAMETER_RESY: + result = (float) (p->images[imod].dpi_y); + break; + + case PDF_PARAMETER_IMAGE_ICCPROFILE: + break; + + case PDF_PARAMETER_ICCCOMPONENTS: + break; + + case PDF_PARAMETER_CURRENTX: + result = (float) (p->gstate[p->sl].x); + break; + + case PDF_PARAMETER_CURRENTY: + result = (float) (p->gstate[p->sl].y); + break; + + case PDF_PARAMETER_TEXTX: + result = (float) (p->tstate[p->sl].m.e); + break; + + case PDF_PARAMETER_TEXTY: + result = (float) (p->tstate[p->sl].m.f); + break; + + case PDF_PARAMETER_WORDSPACING: + result = (float) (p->tstate[p->sl].w); + break; + + case PDF_PARAMETER_CHARSPACING: + result = (float) (p->tstate[p->sl].c); + break; + + case PDF_PARAMETER_HORIZSCALING: + result = pdf_get_horiz_scaling(p); + break; + + case PDF_PARAMETER_TEXTRISE: + result = (float) (p->tstate[p->sl].rise); + break; + + case PDF_PARAMETER_LEADING: + result = (float) (p->tstate[p->sl].l); + break; + + case PDF_PARAMETER_TEXTRENDERING: + result = (float) (p->tstate[p->sl].mode); + break; + + case PDF_PARAMETER_FONT: + result = (float) (pdf_get_font(p)); + if (p->hastobepos) result += 1; \ + break; + + case PDF_PARAMETER_MONOSPACE: + result = (float) pdf_get_monospace(p); + break; + + case PDF_PARAMETER_FONTSIZE: + result = (float) (pdf_get_fontsize(p)); + break; + + case PDF_PARAMETER_FONTMAXCODE: + result = (float) (p->fonts[imod].numOfCodes - 1); + break; + + case PDF_PARAMETER_CAPHEIGHT: + result = (float) (p->fonts[imod].capHeight / (float) 1000); + break; + + case PDF_PARAMETER_ASCENDER: + result = (float) (p->fonts[imod].ascender / (float) 1000); + break; + + case PDF_PARAMETER_DESCENDER: + result = (float) (p->fonts[imod].descender / (float) 1000); + break; + + case PDF_PARAMETER_SUBSETLIMIT: + break; + + default: + pdc_error(p->pdc, PDC_E_PAR_UNKNOWNKEY, key, 0, 0, 0); + break; + } /* switch */ + + pdc_trace(p->pdc, "[%g]\n", result); + return result; +} /* PDF_get_value */ + +PDFLIB_API const char * PDFLIB_CALL +PDF_get_parameter(PDF *p, const char *key, float mod) +{ + static const char fn[] = "PDF_get_parameter"; + int i = -1; + const char *result = ""; + + /* some parameters can be retrieved with p == 0. + */ + if (key != NULL && (i = get_index(key)) != -1) + { + switch (i) + { + case PDF_PARAMETER_VERSION: + result = PDFLIB_VERSIONSTRING; + return result; + + case PDF_PARAMETER_PDI: + result = "false"; + return result; + } /* switch */ + } + + if (!pdf_enter_api(p, fn, (pdf_state) pdf_state_all, + "(p[%p], \"%s\", %g);", (void *) p, key, mod)) + return ""; + + if (key == NULL || !*key) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "key", 0, 0, 0); + + if (i == -1) + pdc_error(p->pdc, PDC_E_PAR_UNKNOWNKEY, key, 0, 0, 0); + + if ((p->state_stack[p->state_sp] & parms[i].get_scope) == 0) + pdc_error(p->pdc, PDF_E_DOC_SCOPE_GET, key, pdf_current_scope(p), 0, 0); + + if (parms[i].mod_zero && mod != (float) 0) + pdc_error(p->pdc, PDC_E_PAR_ILLPARAM, + pdc_errprintf(p->pdc, "%f", mod), key, 0, 0); + + switch (i) + { + case PDF_PARAMETER_FONTNAME: + result = pdf_get_fontname(p); + break; + + case PDF_PARAMETER_FONTSTYLE: + result = pdf_get_fontstyle(p); + break; + + case PDF_PARAMETER_FONTENCODING: + result = pdf_get_fontencoding(p); + break; + + case PDF_PARAMETER_UNDERLINE: + result = PDC_BOOLSTR(p->underline); + break; + + case PDF_PARAMETER_OVERLINE: + result = PDC_BOOLSTR(p->overline); + break; + + case PDF_PARAMETER_STRIKEOUT: + result = PDC_BOOLSTR(p->strikeout); + break; + + case PDF_PARAMETER_INHERITGSTATE: + result = PDC_BOOLSTR(p->inheritgs); + break; + + case PDF_PARAMETER_SCOPE: + switch (p->state_stack[p->state_sp]) { + case pdf_state_object: result = "object"; break; + case pdf_state_document:result = "document"; break; + case pdf_state_page: result = "page"; break; + case pdf_state_pattern: result = "pattern"; break; + case pdf_state_template:result = "template"; break; + case pdf_state_path: result = "path"; break; + default: result = "(unknown)"; break; + } + break; + + case PDF_PARAMETER_TEXTFORMAT: + result = pdc_get_keyword(p->textformat, pdf_textformat_keylist); + break; + + case PDF_PARAMETER_HYPERTEXTFORMAT: + result = pdc_get_keyword(p->hypertextformat,pdf_textformat_keylist); + break; + + case PDF_PARAMETER_HYPERTEXTENCODING: + result = pdf_get_encoding_name(p, p->hypertextencoding); + break; + + default: + pdc_error(p->pdc, PDC_E_PAR_UNKNOWNKEY, key, 0, 0, 0); + break; + } /* switch */ + + pdc_trace(p->pdc, "[%s]\n", result); + return result; +} /* PDF_get_parameter */ diff --git a/src/libs/pdflib/libs/pdflib/p_params.h b/src/libs/pdflib/libs/pdflib/p_params.h new file mode 100644 index 0000000000..110125c299 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_params.h @@ -0,0 +1,320 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_params.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib parameter table + * + */ + +#if pdf_gen_parm_enum +#define pdf_gen1(code, name, zero, scope) PDF_PARAMETER_##code, +#define pdf_gen2(code, name, zero, gscope, sscope) PDF_PARAMETER_##code, +#elif pdf_gen_parm_descr +#define pdf_gen1(code, name, zero, scope) \ + { name, zero, scope, scope }, +#define pdf_gen2(code, name, zero, gscope, sscope) \ + { name, zero, gscope, sscope }, +#else +#error invalid inclusion of generator file +#endif + +/* + List of unsupported debug parameters: + 2 disable the search for Windows 2000/XP's color directory via mscms.dll + a ASCIIHex output for fonts and images + c trace calloc calls + e extract embedded ICC profiles from image files + f trace free calls + F throw an exception if a font is unavailable (instead of returning -1); + g throw an exception if a glyph cannot be shown; + h disable host font processing + i throw an exception when an image is unavailable + I throw an exception if a ICC is unavailable (instead of returning -1); + m trace malloc calls + o throw an exception if the PDF output file can't be opened + P disable pass-through mode for TIFF images + p throw an exception if an imported PDF is unavailable + r trace realloc calls + t API function name and parameter logging to tracefile enabled + + On by default: e F I +*/ + + +/* + * ---------------------------------------------------------------------- + * Setup + * ---------------------------------------------------------------------- + */ + +pdf_gen1(OPENWARNING, "openwarning", 1, pdf_state_all) +pdf_gen1(COMPRESS, "compress", 1, pdf_state_page | pdf_state_document) +pdf_gen1(FLUSH, "flush", 1, pdf_state_all) +pdf_gen1(RESOURCEFILE, "resourcefile", 1, pdf_state_all) +pdf_gen1(COMPATIBILITY, "compatibility",1, pdf_state_object) +pdf_gen1(PDFX, "pdfx", 1, pdf_state_object) +pdf_gen1(PREFIX, "prefix", 1, pdf_state_all) +pdf_gen1(SEARCHPATH, "SearchPath", 1, pdf_state_all) +pdf_gen1(ASCIIFILE, "asciifile", 1, pdf_state_all) +pdf_gen1(WARNING, "warning", 1, pdf_state_all) +pdf_gen1(LICENSE, "license", 1, pdf_state_object) +pdf_gen1(LICENSEFILE, "licensefile", 1, pdf_state_object) +pdf_gen1(TRACE, "trace", 1, pdf_state_all) +pdf_gen1(TRACEFILE, "tracefile", 1, pdf_state_all) +pdf_gen1(TRACEMSG, "tracemsg", 1, pdf_state_all) + +/* Unsupported */ +pdf_gen1(SERIAL, "serial", 1, pdf_state_object) +pdf_gen1(FLOATDIGITS, "floatdigits", 1, pdf_state_all) +pdf_gen1(BINDING, "binding", 1, pdf_state_all) +pdf_gen1(HASTOBEPOS, "hastobepos", 1, pdf_state_all) +pdf_gen1(DEBUG, "debug", 1, pdf_state_all) +pdf_gen1(NODEBUG, "nodebug", 1, pdf_state_all) + + +/* + * ---------------------------------------------------------------------- + * Versioning + * ---------------------------------------------------------------------- + */ + +pdf_gen1(MAJOR, "major", 1, pdf_state_all) +pdf_gen1(MINOR, "minor", 1, pdf_state_all) +pdf_gen1(REVISION, "revision", 1, pdf_state_all) +pdf_gen1(VERSION, "version", 1, pdf_state_all) + + +/* + * ---------------------------------------------------------------------- + * Page + * ---------------------------------------------------------------------- + */ + +pdf_gen1(PAGEWIDTH, "pagewidth", 1, pdf_state_page | pdf_state_path) +pdf_gen1(PAGEHEIGHT, "pageheight", 1, pdf_state_page | pdf_state_path) +pdf_gen1(CROPBOX_LLX, "CropBox/llx", 1, pdf_state_page | pdf_state_path) +pdf_gen1(CROPBOX_LLY, "CropBox/lly", 1, pdf_state_page | pdf_state_path) +pdf_gen1(CROPBOX_URX, "CropBox/urx", 1, pdf_state_page | pdf_state_path) +pdf_gen1(CROPBOX_URY, "CropBox/ury", 1, pdf_state_page | pdf_state_path) +pdf_gen1(BLEEDBOX_LLX, "BleedBox/llx", 1, pdf_state_page | pdf_state_path) +pdf_gen1(BLEEDBOX_LLY, "BleedBox/lly", 1, pdf_state_page | pdf_state_path) +pdf_gen1(BLEEDBOX_URX, "BleedBox/urx", 1, pdf_state_page | pdf_state_path) +pdf_gen1(BLEEDBOX_URY, "BleedBox/ury", 1, pdf_state_page | pdf_state_path) +pdf_gen1(TRIMBOX_LLX, "TrimBox/llx", 1, pdf_state_page | pdf_state_path) +pdf_gen1(TRIMBOX_LLY, "TrimBox/lly", 1, pdf_state_page | pdf_state_path) +pdf_gen1(TRIMBOX_URX, "TrimBox/urx", 1, pdf_state_page | pdf_state_path) +pdf_gen1(TRIMBOX_URY, "TrimBox/ury", 1, pdf_state_page | pdf_state_path) +pdf_gen1(ARTBOX_LLX, "ArtBox/llx", 1, pdf_state_page | pdf_state_path) +pdf_gen1(ARTBOX_LLY, "ArtBox/lly", 1, pdf_state_page | pdf_state_path) +pdf_gen1(ARTBOX_URX, "ArtBox/urx", 1, pdf_state_page | pdf_state_path) +pdf_gen1(ARTBOX_URY, "ArtBox/ury", 1, pdf_state_page | pdf_state_path) + + +/* + * ---------------------------------------------------------------------- + * Font + * ---------------------------------------------------------------------- + */ + +pdf_gen1(FONTAFM, "FontAFM", 1, pdf_state_all) +pdf_gen1(FONTPFM, "FontPFM", 1, pdf_state_all) +pdf_gen1(FONTOUTLINE, "FontOutline", 1, pdf_state_all) +pdf_gen1(HOSTFONT, "HostFont", 1, pdf_state_all) +pdf_gen1(ENCODING, "Encoding", 1, pdf_state_all) +pdf_gen1(FONTWARNING, "fontwarning", 1, pdf_state_all) +pdf_gen1(KERNING, "kerning", 1, pdf_state_all) +pdf_gen1(SUBSETLIMIT, "subsetlimit", 1, pdf_state_all) +pdf_gen1(SUBSETMINSIZE, "subsetminsize",1, pdf_state_all) +pdf_gen1(AUTOSUBSETTING,"autosubsetting",1, pdf_state_all) +pdf_gen1(AUTOCIDFONT, "autocidfont", 1, pdf_state_all) +pdf_gen1(FONT, "font", 1, pdf_state_content) +pdf_gen1(FONTSIZE, "fontsize", 1, pdf_state_content) +pdf_gen1(FONTNAME, "fontname", 1, pdf_state_content) +pdf_gen1(FONTSTYLE, "fontstyle", 1, pdf_state_content) +pdf_gen1(FONTENCODING, "fontencoding", 1, pdf_state_content) +pdf_gen1(MONOSPACE, "monospace", 1, pdf_state_content) +pdf_gen1(FONTMAXCODE, "fontmaxcode", 0, pdf_state_all) +pdf_gen1(CAPHEIGHT, "capheight", 0, pdf_state_all) +pdf_gen1(ASCENDER, "ascender", 0, pdf_state_all) +pdf_gen1(DESCENDER, "descender", 0, pdf_state_all) +pdf_gen1(UNICODEMAP, "unicodemap", 1, pdf_state_all) + +/* deprecated */ +pdf_gen1(NATIVEUNICODE, "nativeunicode",1, pdf_state_all) + + +/* + * ---------------------------------------------------------------------- + * Text + * ---------------------------------------------------------------------- + */ + +pdf_gen1(TEXTX, "textx", 1, pdf_state_content) +pdf_gen1(TEXTY, "texty", 1, pdf_state_content) +pdf_gen1(LEADING, "leading", 1, pdf_state_content) +pdf_gen1(TEXTRISE, "textrise", 1, pdf_state_content) +pdf_gen1(HORIZSCALING, "horizscaling", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(TEXTRENDERING, "textrendering",1, pdf_state_content) +pdf_gen1(CHARSPACING, "charspacing", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(WORDSPACING, "wordspacing", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(UNDERLINE, "underline", 1, pdf_state_content) +pdf_gen1(OVERLINE, "overline", 1, pdf_state_content) +pdf_gen1(STRIKEOUT, "strikeout", 1, pdf_state_content) +pdf_gen1(TEXTFORMAT, "textformat", 1, pdf_state_all) +pdf_gen1(GLYPHWARNING, "glyphwarning", 1, pdf_state_all) + + +/* + * ---------------------------------------------------------------------- + * Graphics + * ---------------------------------------------------------------------- + */ + +pdf_gen1(CURRENTX, "currentx", 1, pdf_state_content | pdf_state_path) +pdf_gen1(CURRENTY, "currenty", 1, pdf_state_content | pdf_state_path) +pdf_gen1(FILLRULE, "fillrule", 1, pdf_state_content) +pdf_gen1(SCOPE, "scope", 1, pdf_state_all) +pdf_gen1(TOPDOWN, "topdown", 1, pdf_state_document) + + +/* + * ---------------------------------------------------------------------- + * Color + * ---------------------------------------------------------------------- + */ + +pdf_gen1(SETCOLOR_ICCPROFILEGRAY, "setcolor:iccprofilegray", 1, + pdf_state_document | pdf_state_content) +pdf_gen1(SETCOLOR_ICCPROFILERGB, "setcolor:iccprofilergb", 1, + pdf_state_document | pdf_state_content) +pdf_gen1(SETCOLOR_ICCPROFILECMYK, "setcolor:iccprofilecmyk", 1, + pdf_state_document | pdf_state_content) +pdf_gen1(IMAGE_ICCPROFILE,"image:iccprofile", 0, + pdf_state_path | pdf_state_content | pdf_state_document) +pdf_gen1(ICCWARNING, "iccwarning", 1, pdf_state_all) +pdf_gen1(HONORICCPROFILE, "honoriccprofile", 1, pdf_state_all) +pdf_gen1(ICCCOMPONENTS, "icccomponents", 0, pdf_state_all) +pdf_gen1(ICCPROFILE, "ICCProfile", 1, pdf_state_all) +pdf_gen1(STANDARDOUTPUTINTENT, "StandardOutputIntent", 1, pdf_state_all) +pdf_gen1(RENDERINGINTENT, "renderingintent", 1, pdf_state_all) + +pdf_gen1(DEFAULTRGB, "defaultrgb", 1, pdf_state_content | pdf_state_path) +pdf_gen1(DEFAULTGRAY, "defaultgray", 1, pdf_state_content | pdf_state_path) +pdf_gen1(DEFAULTCMYK, "defaultcmyk", 1, pdf_state_content | pdf_state_path) + +pdf_gen1(PRESERVEOLDPANTONENAMES, "preserveoldpantonenames", 1, pdf_state_all) +pdf_gen1(SPOTCOLORLOOKUP, "spotcolorlookup", 1, pdf_state_all) + +/* + * ---------------------------------------------------------------------- + * Image + * ---------------------------------------------------------------------- + */ + +pdf_gen1(IMAGEWARNING, "imagewarning", 1, pdf_state_all) +pdf_gen1(PASSTHROUGH, "passthrough", 1, pdf_state_all) +pdf_gen1(IMAGEWIDTH, "imagewidth", 0, + pdf_state_path | pdf_state_content | pdf_state_document) +pdf_gen1(IMAGEHEIGHT, "imageheight", 0, + pdf_state_path | pdf_state_content | pdf_state_document) +pdf_gen1(RESX, "resx", 0, + pdf_state_path | pdf_state_content | pdf_state_document) +pdf_gen1(RESY, "resy", 0, + pdf_state_path | pdf_state_content | pdf_state_document) + +/* deprecated */ +pdf_gen1(INHERITGSTATE, "inheritgstate",1, pdf_state_all) + + +/* + * ---------------------------------------------------------------------- + * PDI + * ---------------------------------------------------------------------- + */ + +pdf_gen1(PDI, "pdi", 1, pdf_state_all) +pdf_gen1(PDIWARNING, "pdiwarning", 1, pdf_state_all) +pdf_gen1(PDIUSEBOX, "pdiusebox", 1, pdf_state_all) +pdf_gen1(PDISTRICT, "pdistrict", 1, pdf_state_all) + + +/* + * ---------------------------------------------------------------------- + * Hypertext + * ---------------------------------------------------------------------- + */ + +pdf_gen1(HYPERTEXTFORMAT, "hypertextformat", 1, pdf_state_all) +pdf_gen1(HYPERTEXTENCODING, "hypertextencoding", 1, pdf_state_all) +pdf_gen1(USERCOORDINATES, "usercoordinates", 1, pdf_state_all) + +pdf_gen1(HIDETOOLBAR, "hidetoolbar", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(HIDEMENUBAR, "hidemenubar", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(HIDEWINDOWUI, "hidewindowui", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(FITWINDOW, "fitwindow", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(CENTERWINDOW, "centerwindow", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(DISPLAYDOCTITLE, "displaydoctitle", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(NONFULLSCREENPAGEMODE, "nonfullscreenpagemode", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(DIRECTION, "direction", 1, + pdf_state_content | pdf_state_document) + +pdf_gen1(VIEWAREA, "viewarea", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(VIEWCLIP, "viewclip", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(PRINTAREA, "printarea", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(PRINTCLIP, "printclip", 1, + pdf_state_content | pdf_state_document) + +pdf_gen1(OPENACTION, "openaction", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(OPENMODE, "openmode", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(BOOKMARKDEST, "bookmarkdest", 1, + pdf_state_content | pdf_state_document) +pdf_gen1(TRANSITION, "transition", 1, pdf_state_all) +pdf_gen1(DURATION, "duration", 1, pdf_state_all) +pdf_gen1(BASE, "base", 1, + pdf_state_content | pdf_state_document) + +pdf_gen1(LAUNCHLINK_PARAMETERS, "launchlink:parameters", 1, + pdf_state_all) +pdf_gen1(LAUNCHLINK_OPERATION, "launchlink:operation", 1, + pdf_state_all) +pdf_gen1(LAUNCHLINK_DEFAULTDIR, "launchlink:defaultdir", 1, + pdf_state_all) + + +/* + * ---------------------------------------------------------------------- + * Security + * ---------------------------------------------------------------------- + */ + +pdf_gen1(USERPASSWORD, "userpassword", 1, pdf_state_object) +pdf_gen1(MASTERPASSWORD,"masterpassword",1, pdf_state_object) +pdf_gen1(PERMISSIONS, "permissions", 1, pdf_state_object) + +#undef pdf_gen1 +#undef pdf_gen2 diff --git a/src/libs/pdflib/libs/pdflib/p_pattern.c b/src/libs/pdflib/libs/pdflib/p_pattern.c new file mode 100644 index 0000000000..c0c152dc1f --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_pattern.c @@ -0,0 +1,216 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_pattern.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib pattern routines + * + */ + +#include "p_intern.h" +#include "p_image.h" +#include "p_font.h" + +void +pdf_init_pattern(PDF *p) +{ + int i; + + p->pattern_number = 0; + p->pattern_capacity = PATTERN_CHUNKSIZE; + + p->pattern = (pdf_pattern *) pdc_malloc(p->pdc, + sizeof(pdf_pattern) * p->pattern_capacity, "pdf_init_pattern"); + + for (i = 0; i < p->pattern_capacity; i++) { + p->pattern[i].used_on_current_page = pdc_false; + p->pattern[i].obj_id = PDC_BAD_ID; + } +} + +void +pdf_grow_pattern(PDF *p) +{ + int i; + + p->pattern = (pdf_pattern *) pdc_realloc(p->pdc, p->pattern, + sizeof(pdf_pattern) * 2 * p->pattern_capacity, "pdf_grow_pattern"); + + for (i = p->pattern_capacity; i < 2 * p->pattern_capacity; i++) { + p->pattern[i].used_on_current_page = pdc_false; + p->pattern[i].obj_id = PDC_BAD_ID; + } + + p->pattern_capacity *= 2; +} + +void +pdf_write_page_pattern(PDF *p) +{ + int i, total = 0; + + for (i = 0; i < p->pattern_number; i++) + if (p->pattern[i].used_on_current_page) + total++; + + if (total > 0) { + pdc_puts(p->out, "/Pattern"); + + pdc_begin_dict(p->out); /* pattern */ + + for (i = 0; i < p->pattern_number; i++) { + if (p->pattern[i].used_on_current_page) { + p->pattern[i].used_on_current_page = pdc_false; /* reset */ + pdc_printf(p->out, "/P%d %ld 0 R\n", i, p->pattern[i].obj_id); + } + } + + pdc_end_dict(p->out); /* pattern */ + } +} + +void +pdf_cleanup_pattern(PDF *p) +{ + if (p->pattern) { + pdc_free(p->pdc, p->pattern); + p->pattern = NULL; + } +} + +/* Start a new pattern definition. */ +PDFLIB_API int PDFLIB_CALL +PDF_begin_pattern( + PDF *p, + float width, + float height, + float xstep, + float ystep, + int painttype) +{ + static const char fn[] = "PDF_begin_pattern"; + int slot = -1; + + if (!pdf_enter_api(p, fn, pdf_state_document, + "(p[%p], %g, %g, %g, %g, %d)", + (void *) p, width, height, xstep, ystep, painttype)) + { + PDF_RETURN_HANDLE(p, slot) + } + + if (width <= 0) + pdc_error(p->pdc, PDC_E_ILLARG_POSITIVE, "width", 0, 0, 0); + + if (height <= 0) + pdc_error(p->pdc, PDC_E_ILLARG_POSITIVE, "height", 0, 0, 0); + + if (painttype != 1 && painttype != 2) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "painttype", pdc_errprintf(p->pdc, "%d", painttype), 0, 0); + + if (p->pattern_number == p->pattern_capacity) + pdf_grow_pattern(p); + + p->pattern[p->pattern_number].obj_id = pdc_begin_obj(p->out, PDC_NEW_ID); + p->pattern[p->pattern_number].painttype = painttype; + + p->height = height; + p->width = width; + p->thumb_id = PDC_BAD_ID; + PDF_PUSH_STATE(p, fn, pdf_state_pattern); + p->next_content = 0; + p->contents = c_page; + p->sl = 0; + + pdf_init_tstate(p); + pdf_init_gstate(p); + pdf_init_cstate(p); + + pdc_begin_dict(p->out); /* pattern dict*/ + + p->res_id = pdc_alloc_id(p->out); + + pdc_puts(p->out, "/PatternType 1\n"); /* tiling pattern */ + + /* colored or uncolored pattern */ + pdc_printf(p->out, "/PaintType %d\n", painttype); + pdc_puts(p->out, "/TilingType 1\n"); /* constant spacing */ + + pdc_printf(p->out, "/BBox[0 0 %f %f]\n", p->width, p->height); + + pdc_printf(p->out, "/XStep %f\n", xstep); + pdc_printf(p->out, "/YStep %f\n", ystep); + + pdc_printf(p->out, "/Resources %ld 0 R\n", p->res_id); + + p->length_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/Length %ld 0 R\n", p->length_id); + + if (pdc_get_compresslevel(p->out)) + pdc_puts(p->out, "/Filter/FlateDecode\n"); + + pdc_end_dict(p->out); /* pattern dict*/ + pdc_begin_pdfstream(p->out); + + p->next_content++; + + slot = p->pattern_number; + p->pattern_number++; + + /* top-down y-coordinates */ + pdf_set_topdownsystem(p, height); + + PDF_RETURN_HANDLE(p, slot) +} + +/* Finish the pattern definition. */ +PDFLIB_API void PDFLIB_CALL +PDF_end_pattern(PDF *p) +{ + static const char fn[] = "PDF_end_pattern"; + + if (!pdf_enter_api(p, fn, pdf_state_pattern, "(p[%p])\n", (void *) p)) + return; + + /* check whether pdf__save() and pdf__restore() calls are balanced */ + if (p->sl > 0) + pdc_error(p->pdc, PDF_E_GSTATE_UNMATCHEDSAVE, 0, 0, 0, 0); + + pdf_end_text(p); + p->contents = c_none; + + pdc_end_pdfstream(p->out); + pdc_end_obj(p->out); /* pattern */ + + pdc_put_pdfstreamlength(p->out, p->length_id); + + pdc_begin_obj(p->out, p->res_id); /* Resource object */ + pdc_begin_dict(p->out); /* Resource dict */ + + pdf_write_page_fonts(p); /* Font resources */ + + pdf_write_page_colorspaces(p); /* Color space resources */ + + pdf_write_page_pattern(p); /* Pattern resources */ + + pdf_write_xobjects(p); /* XObject resources */ + + pdf_write_page_extgstates(p); /* ExtGState resources */ + + pdc_end_dict(p->out); /* resource dict */ + pdc_end_obj(p->out); /* resource object */ + + PDF_POP_STATE(p, fn); + + if (p->flush & pdf_flush_page) + pdc_flush_stream(p->out); +} diff --git a/src/libs/pdflib/libs/pdflib/p_pdi.c b/src/libs/pdflib/libs/pdflib/p_pdi.c new file mode 100644 index 0000000000..f52c57a7d5 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_pdi.c @@ -0,0 +1,201 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_pdi.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDF import routines (require the PDI library) + * + */ + +#define P_PDI_C + +#include "p_intern.h" + + +PDFLIB_API int PDFLIB_CALL +PDF_open_pdi( + PDF *p, + const char *filename, + const char *optlist, + int reserved) +{ + static const char fn[] = "PDF_open_pdi"; + int retval = -1; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page), + "(p[%p], \"%s\", \"%s\", %d)", + (void *) p, filename, optlist, reserved)) + { + PDF_RETURN_HANDLE(p, retval) + } + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + PDF_RETURN_HANDLE(p, retval) +} + +PDFLIB_API int PDFLIB_CALL +PDF_open_pdi_callback( + PDF *p, + void *opaque, + size_t filesize, + size_t (*readproc)(void *opaque, void *buffer, size_t size), + int (*seekproc)(void *opaque, long offset), + const char *optlist) +{ + static const char fn[] = "PDF_open_pdi_callback"; + int retval = -1; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page), + "(p[%p], opaque[%p], %ld, readproc[%p], seekproc[%p] \"%s\")", + (void *)p, opaque, filesize, readproc, seekproc, optlist)) + { + PDF_RETURN_HANDLE(p, retval) + } + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + PDF_RETURN_HANDLE(p, retval) +} + +PDFLIB_API void PDFLIB_CALL +PDF_close_pdi(PDF *p, int doc) +{ + static const char fn[] = "PDF_close_pdi"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_object | pdf_state_document | pdf_state_page), + "(p[%p], %d)\n", (void *) p, doc)) + return; + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + return; +} + +PDFLIB_API int PDFLIB_CALL +PDF_open_pdi_page( PDF *p, int doc, int page, const char *optlist) +{ + static const char fn[] = "PDF_open_pdi_page"; + int retval = -1; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page), + "(p[%p], %d, %d, \"%s\")", (void *) p, doc, page, optlist)) + { + PDF_RETURN_HANDLE(p, retval) + } + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + PDF_RETURN_HANDLE(p, retval) +} + +PDFLIB_API void PDFLIB_CALL +PDF_fit_pdi_page(PDF *p, int page, float x, float y, const char *optlist) +{ + static const char fn[] = "PDF_fit_pdi_page"; + + /* precise scope diagnosis in pdf__place_image */ + if (!pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], %d, %g, %g, \"%s\")\n", (void *) p, page, x, y, optlist)) + return; + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + return; +} + +PDFLIB_API void PDFLIB_CALL +PDF_place_pdi_page(PDF *p, int page, float x, float y, float sx, float sy) +{ + static const char fn[] = "PDF_place_pdi_page"; + + if (!pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], %d, %g, %g, %g, %g)\n", (void *) p, page, x, y, sx, sy)) + return; + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + return; +} + +PDFLIB_API void PDFLIB_CALL +PDF_close_pdi_page(PDF *p, int page) +{ + static const char fn[] = "PDF_close_pdi_page"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page), + "(p[%p], %d)\n", (void *) p, page)) + return; + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + return; +} + +PDFLIB_API const char *PDFLIB_CALL +PDF_get_pdi_parameter( + PDF *p, + const char *key, + int doc, + int page, + int idx, + int *len) +{ + static const char fn[] = "PDF_get_pdi_parameter"; + + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", %d, %d, %d, len[%p])\n", + (void *) p, key, doc, page, idx, len)) + return (const char *) NULL; + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + return (const char *) NULL; +} + +PDFLIB_API float PDFLIB_CALL +PDF_get_pdi_value(PDF *p, const char *key, int doc, int page, int idx) +{ + static const char fn[] = "PDF_get_pdi_value"; + + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", %d, %d, %d)\n", + (void *) p, key, doc, page, idx)) + return (float) 0; + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + return (float) 0; +} + +PDFLIB_API int PDFLIB_CALL +PDF_process_pdi(PDF *p, int doc, int page, const char *optlist) +{ + static const char fn[] = "PDF_process_pdi"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document), + "(p[%p], %d, %d, %s)\n", (void *) p, doc, page, optlist)) + { + PDF_RETURN_BOOLEAN(p, -1); + } + + pdc_error(p->pdc, PDF_E_UNSUPP_PDI, 0, 0, 0, 0); + + PDF_RETURN_BOOLEAN(p, -1); +} + diff --git a/src/libs/pdflib/libs/pdflib/p_pfm.c b/src/libs/pdflib/libs/pdflib/p_pfm.c new file mode 100644 index 0000000000..1b6593130b --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_pfm.c @@ -0,0 +1,349 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_pfm.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib routines for fast reading of PFM font metrics files + * + */ + +#include "p_intern.h" +#include "p_font.h" + +/* read data types from the PFM */ +#define PFM_BYTE(offset) pfm[offset] +#define PFM_WORD(offset) PDC_GET_WORD(&pfm[offset]) +#define PFM_SHORT(offset) PDC_GET_SHORT(&pfm[offset]) +#define PFM_DWORD(offset) PDC_GET_DWORD3(&pfm[offset]) + +/* Offsets in the buffer containing the various PFM structures */ +#define header_base 0 +#define header_dfVersion (PFM_WORD(header_base + 0)) +#define header_dfSize (PFM_DWORD(header_base + 2)) +#define header_dfAscent (PFM_WORD(header_base + 74)) +#define header_dfItalic (PFM_BYTE(header_base + 80)) +#define header_dfWeight (PFM_WORD(header_base + 83)) +#define header_dfCharSet (PFM_BYTE(header_base + 85)) +#define header_dfPitchAndFamily (PFM_BYTE(header_base + 90)) +#define header_dfMaxWidth (PFM_WORD(header_base + 93)) +#define header_dfFirstChar (PFM_BYTE(header_base + 95)) +#define header_dfLastChar (PFM_BYTE(header_base + 96)) +#define header_dfDefaultChar (PFM_BYTE(header_base + 97)) + +#define ext_base 117 +#define ext_dfExtentTable (PFM_DWORD(ext_base + 6)) +#define ext_dfKernPairs (PFM_DWORD(ext_base + 14)) +#define ext_dfKernTrack (PFM_DWORD(ext_base + 18)) +#define ext_dfDriverInfo (PFM_DWORD(ext_base + 22)) + +#define etm_base 147 +#define etmCapHeight (PFM_SHORT(etm_base + 14)) +#define etmXHeight (PFM_SHORT(etm_base + 16)) +#define etmLowerCaseAscent (PFM_SHORT(etm_base + 18)) +#define etmLowerCaseDescent (PFM_SHORT(etm_base + 20)) +#define etmSlant (PFM_SHORT(etm_base + 22)) +#define etmUnderlineOffset (PFM_SHORT(etm_base + 32)) +#define etmUnderlineWidth (PFM_SHORT(etm_base + 34)) + +#define dfDevice 199 + +/* Windows font descriptor flags */ +#define PDF_FIXED_PITCH 0x01 /* Fixed width font; rarely used flag */ + +#define PDF_DONTCARE 0x00 /* Don't care or don't know. */ +#define PDF_ROMAN 0x10 /* Variable stroke width, serifed */ +#define PDF_SWISS 0x20 /* Variable stroke width, sans-serifed */ +#define PDF_MODERN 0x30 /* fixed pitch */ +#define PDF_SCRIPT 0x40 /* Cursive, etc. */ +#define PDF_DECORATIVE 0x50 /* Old English, etc. */ + +/* Windows character set flags */ +#define PFM_ANSI_CHARSET 0 /* seems to imply codepage 1250/1252 */ +#define PFM_SYMBOL_CHARSET 2 +#define PFM_SHIFTJIS_CHARSET 128 +#define PFM_OEM_CHARSET 255 + +#define PDF_STRING_PostScript \ + ((const char*) "\120\157\163\164\123\143\162\151\160\164") + +/* + * Kerning pairs + */ +typedef struct kern_ { + pdc_byte first; /* First character */ + pdc_byte second; /* Second character */ + pdc_byte kern[2]; /* Kern distance */ +} KERN; + +pdc_bool +pdf_check_pfm_encoding(PDF *p, pdc_font *font, const char *fontname, + pdc_encoding enc) +{ + const char *encname; + pdc_encoding enc_old = enc; + int islatin1 = 0; + + /* Font encoding */ + switch (font->encoding) + { + case PFM_ANSI_CHARSET: + font->encoding = pdc_winansi; + font->isstdlatin = pdc_true; + break; + + case PFM_SYMBOL_CHARSET: + font->encoding = pdc_builtin; + font->isstdlatin = pdc_false; + break; + + default: + pdc_set_errmsg(p->pdc, PDF_E_T1_BADCHARSET, + pdc_errprintf(p->pdc, "%d", font->encoding), fontname, 0, 0); + + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + /* iso8859-1 */ + if (enc > 0) + { + islatin1 = !strcmp(pdf_get_encoding_name(p, enc), "iso8859-1"); + if (font->encoding == pdc_winansi) + font->encoding = enc; + } + + /* Unicode encoding */ + if (enc == pdc_unicode) + { + enc = pdf_find_encoding(p, "iso8859-1"); + font->encoding = enc; + islatin1 = 1; + } + + /* Unallowed encoding */ + encname = pdc_errprintf(p->pdc, "%s", pdf_get_encoding_name(p, enc_old)); + if (enc < pdc_builtin) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_BADENC, fontname, encname, 0, 0); + + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + if (font->verbose == pdc_true) + { + if (enc != pdc_winansi && !islatin1 && + font->encoding != pdc_builtin) + { + pdc_warning(p->pdc, PDF_E_FONT_FORCEENC, + pdf_get_encoding_name(p, pdc_winansi), encname, fontname, 0); + } + if (enc != pdc_builtin && font->encoding == pdc_builtin) + { + pdc_warning(p->pdc, PDF_E_FONT_FORCEENC, + pdf_get_encoding_name(p, pdc_builtin), encname, fontname, 0); + } + } + + return pdc_true; +} + + +/* + * Currently we do not populate the following fields correctly: + * - serif flag + */ + +static pdc_bool +pdf_parse_pfm(PDF *p, pdc_file *fp, pdc_font *font) +{ + static const char fn[] = "pdf_parse_pfm"; + size_t length; + pdc_byte *pfm; + pdc_bool ismem; + int i, dfFirstChar, dfLastChar, default_width; + float w; + unsigned long dfExtentTable; + + /* read whole file and close it */ + pfm = (pdc_byte *) pdc_freadall(fp, &length, &ismem); + pdc_fclose(fp); + + /* check whether this is really a valid PostScript PFM file */ + if (pfm == NULL || + (header_dfVersion != 0x100 && header_dfVersion != 0x200) || + dfDevice > length || + strncmp((const char *) pfm + dfDevice, PDF_STRING_PostScript, 10) || + ext_dfDriverInfo > length) { + + if (!ismem) + pdc_free(p->pdc, pfm); + return pdc_false; + } + + /* fetch relevant data from the PFM */ + font->type = pdc_Type1; + w = header_dfWeight / (float) 65; + font->StdVW = (int) (PDF_STEMV_MIN + w * w); + + font->name = pdc_strdup(p->pdc, (const char *)pfm + ext_dfDriverInfo); + + switch (header_dfPitchAndFamily & 0xF0) { + case PDF_ROMAN: + font->flags |= SERIF; + break; + case PDF_MODERN: + /* Has to be ignored, contrary to MS's specs */ + break; + case PDF_SCRIPT: + font->flags |= SCRIPT; + break; + case PDF_DECORATIVE: + /* the dfCharSet flag lies in this case... */ + header_dfCharSet = PFM_SYMBOL_CHARSET; + break; + case PDF_SWISS: + case PDF_DONTCARE: + default: + break; + } + + /* temporarily */ + font->encoding = (pdc_encoding) header_dfCharSet; + + + dfFirstChar = header_dfFirstChar; + dfLastChar = header_dfLastChar; + dfExtentTable = ext_dfExtentTable; + + /* + * Some rare PFMs do not contain any ExtentTable if the fixed pitch flag + * is set. Use the dfMaxWidth entry for all glyphs in this case. + * If the user forced the font to be monospaced we use this value instead. + */ + if ((!(header_dfPitchAndFamily & PDF_FIXED_PITCH) && dfExtentTable == 0) || + font->monospace) + { + font->isFixedPitch = pdc_true; + default_width = font->monospace ? font->monospace : header_dfMaxWidth; + } else { + + /* default values -- don't take the width of the default character */ + default_width = PDF_DEFAULT_WIDTH; + } + + font->widths = (int *) pdc_calloc(p->pdc, + font->numOfCodes * sizeof(int), fn); + for (i = 0; i < font->numOfCodes; i++) + font->widths[i] = default_width; + + if (!font->isFixedPitch) + { + if (ext_dfExtentTable == 0 || + ext_dfExtentTable + 2 * (header_dfLastChar-header_dfFirstChar) + 1 > + length){ + if (!ismem) + pdc_free(p->pdc, pfm); + return pdc_false; + } + + for (i = dfFirstChar; i <= dfLastChar; i++) + font->widths[i] = + (int) PFM_WORD(dfExtentTable + 2 * (i - dfFirstChar)); + /* + * Check whether the font is actually monospaced + * (the fixed pitch flag is not necessarily set) + */ + default_width = font->widths[dfFirstChar]; + + for (i = dfFirstChar+1; i <= dfLastChar; i++) + if (default_width != font->widths[i]) + break; + + if (i == dfLastChar + 1) + font->isFixedPitch = pdc_true; + } + + font->italicAngle = + (header_dfItalic ? etmSlant/((float) 10.0) : (float) 0.0); + font->capHeight = etmCapHeight; + font->xHeight = etmXHeight; + font->descender = -etmLowerCaseDescent; + if (font->descender > 0) + font->descender = 0; + font->ascender = (int) header_dfAscent; + + font->underlinePosition = -etmUnderlineOffset; + font->underlineThickness = etmUnderlineWidth; + + font->llx = (float) -200; + font->lly = (float) font->descender; + font->urx = (float) header_dfMaxWidth; + font->ury = (float) font->ascender; + + /* try to fix broken entries */ + if (font->lly > font->ury) + font->ury = font->lly + 200; + if (font->llx > font->urx) + font->urx = 1000; + + + if (!ismem) + pdc_free(p->pdc, pfm); + + return pdc_true; +} + +pdc_bool +pdf_get_metrics_pfm( + PDF *p, + pdc_font *font, + const char *fontname, + pdc_encoding enc, + const char *filename) +{ + pdc_file *pfmfile; + + /* open PFM file */ + pfmfile = pdf_fopen(p, filename, "PFM ", PDC_FILE_BINARY); + if (pfmfile == NULL) + { + if (font->verbose_open) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + /* Read PFM metrics */ + if (!pdf_parse_pfm(p, pfmfile, font)) + { + pdc_set_errmsg(p->pdc, PDF_E_FONT_CORRUPT, "PFM", filename, 0, 0); + + if (font->verbose == pdc_true) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + /* Check encoding */ + if (!pdf_check_pfm_encoding(p, font, fontname, enc)) + return pdc_false; + + if (!pdf_make_fontflag(p, font)) + return pdc_false; + + return pdc_true; +} diff --git a/src/libs/pdflib/libs/pdflib/p_png.c b/src/libs/pdflib/libs/pdflib/p_png.c new file mode 100644 index 0000000000..f9771f3f7b --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_png.c @@ -0,0 +1,724 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_png.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PNG processing for PDFlib + * + */ + +#include "p_intern.h" +#include "p_image.h" + +/* SPNG - Simple PNG +** +** The items below, prefixed with spng_, or SPNG_, establish a replacement +** for LIBPNG that works very fast, but processes simple PNG images only: +** - bit_depth <= 8 (no 16-bit) +** - interlace_type 0 (no interlacing) +** - color_type 0, 2, or 3 (no alpha-channel); color type 3 requires +** libpng for palette processing +*/ +#define SPNG_SIGNATURE "\211\120\116\107\015\012\032\012" + +#define SPNG_CHUNK_IHDR 0x49484452 +#define SPNG_CHUNK_PLTE 0x504C5445 +#define SPNG_CHUNK_tRNS 0x74524E53 +#define SPNG_CHUNK_IDAT 0x49444154 +#define SPNG_CHUNK_IEND 0x49454E44 + +/* spng_init() return codes +*/ +#define SPNG_ERR_OK 0 /* no error */ +#define SPNG_ERR_NOPNG 1 /* bad PNG signature */ +#define SPNG_ERR_FMT 2 /* bad PNG file format */ + +typedef struct +{ + /* from IHDR: + */ + int width; + int height; + pdc_byte bit_depth; + pdc_byte color_type; + pdc_byte compr_type; + pdc_byte filter_type; + pdc_byte interlace_type; +} spng_info; + +static int +spng_getint(pdc_file *fp) +{ + unsigned char buf[4]; + + if (!PDC_OK_FREAD(fp, buf, 4)) + return -1; + + return (int) pdc_get_be_long(buf); +} /* spng_getint */ + +static int +spng_init(PDF *p, pdf_image *image, spng_info *spi) +{ + pdc_file *fp = image->fp; + char buf[8]; + + (void) p; + + /* check signature + */ + if (!PDC_OK_FREAD(fp, buf, 8) || + strncmp(buf, SPNG_SIGNATURE, 8) != 0) + return SPNG_ERR_NOPNG; + + /* read IHDR + */ + if (spng_getint(fp) != 13 || + spng_getint(fp) != SPNG_CHUNK_IHDR) + return SPNG_ERR_FMT; + + spi->width = spng_getint(fp); + spi->height = spng_getint(fp); + + if (!PDC_OK_FREAD(fp, buf, 5)) + return SPNG_ERR_FMT; + + spi->bit_depth = (pdc_byte) buf[0]; + spi->color_type = (pdc_byte) buf[1]; + spi->compr_type = (pdc_byte) buf[2]; + spi->filter_type = (pdc_byte) buf[3]; + spi->interlace_type = (pdc_byte) buf[4]; + + (void) spng_getint(fp); /* CRC */ + + /* decide whether this image is "simple". + */ +#ifdef HAVE_LIBPNG + if (spi->bit_depth > 8 || spi->color_type > 3 || spi->interlace_type != 0) +#else + if (spi->bit_depth > 8 || spi->color_type > 2 || spi->interlace_type != 0) +#endif /* !HAVE_LIBPNG */ + { + image->use_raw = pdc_false; + return SPNG_ERR_OK; + } + else + image->use_raw = pdc_true; + + /* read (or skip) all chunks up to the first IDAT. + */ + for (/* */ ; /* */ ; /* */) + { + int len = spng_getint(fp); + int type = spng_getint(fp); + + switch (type) + { + case SPNG_CHUNK_IDAT: /* prepare data xfer */ + image->info.png.nbytes = (size_t) len; + return SPNG_ERR_OK; + + case -1: + return SPNG_ERR_FMT; + + /* if we decide to live without LIBPNG, + ** we should handle these cases, too. + */ + case SPNG_CHUNK_tRNS: /* transparency chunk */ + case SPNG_CHUNK_PLTE: /* read in palette */ + + default: + pdc_fseek(fp, len + 4, SEEK_CUR); + /* skip data & CRC */ + break; + } /* switch */ + } + + return SPNG_ERR_OK; +} /* spng_init */ + +static void +pdf_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + pdc_file *fp = (pdc_file *) png_ptr->io_ptr; + char *filename = (char *) pdc_file_name(fp); + + if (!PDC_OK_FREAD(fp, data, length)) + { + pdc_core *pdc = pdc_file_getpdc(fp); + + pdc_error(pdc, PDF_E_IMAGE_CORRUPT, "PNG", filename, 0, 0); + } +} + +#define PDF_PNG_BUFFERSIZE 8192 + +static void +pdf_data_source_PNG_init(PDF *p, PDF_data_source *src) +{ + static const char fn[] = "pdf_data_source_PNG_init"; + pdf_image *image = (pdf_image *) src->private_data; + +#ifdef HAVE_LIBPNG + if (image->use_raw) + { +#endif + src->buffer_length = PDF_PNG_BUFFERSIZE; + src->buffer_start = (pdc_byte *) + pdc_malloc(p->pdc, src->buffer_length, fn); + src->bytes_available = 0; + src->next_byte = src->buffer_start; + +#ifdef HAVE_LIBPNG + } + else + { + image->info.png.cur_line = 0; + src->buffer_length = image->info.png.rowbytes; + } +#endif +} + +#undef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) + +static void +spng_error(PDF *p, PDF_data_source *src) +{ + pdf_image *image = (pdf_image *) src->private_data; + + pdc_error(p->pdc, PDF_E_IMAGE_CORRUPT, "PNG", image->filename, 0, 0); +} /* spng_error */ + +static pdc_bool +pdf_data_source_PNG_fill(PDF *p, PDF_data_source *src) +{ + pdf_image *image = (pdf_image *) src->private_data; + +#ifdef HAVE_LIBPNG + if (image->use_raw) + { +#endif + pdc_file * fp = image->fp; + size_t buf_avail = src->buffer_length; + pdc_byte *scan = src->buffer_start; + + src->bytes_available = 0; + + if (image->info.png.nbytes == 0) + return pdc_false; + + do + { + size_t nbytes = min(image->info.png.nbytes, buf_avail); + + if (!PDC_OK_FREAD(fp, scan, nbytes)) + spng_error(p, src); + + src->bytes_available += nbytes; + scan += nbytes; + buf_avail -= nbytes; + + if ((image->info.png.nbytes -= nbytes) == 0) + { + /* proceed to next IDAT chunk + */ + (void) spng_getint(fp); /* CRC */ + image->info.png.nbytes = + (size_t) spng_getint(fp); /* length */ + + if (spng_getint(fp) != SPNG_CHUNK_IDAT) + { + image->info.png.nbytes = 0; + return pdc_true; + } + } + } while (buf_avail); + +#ifdef HAVE_LIBPNG + } + else + { + if (image->info.png.cur_line == image->height) + return pdc_false; + + src->next_byte = image->info.png.raster + + image->info.png.cur_line * image->info.png.rowbytes; + + src->bytes_available = src->buffer_length; + + image->info.png.cur_line++; + } +#endif /* HAVE_LIBPNG */ + + return pdc_true; +} + +static void +pdf_data_source_PNG_terminate(PDF *p, PDF_data_source *src) +{ + pdf_image *image = (pdf_image *) src->private_data; + +#ifdef HAVE_LIBPNG + if (image->use_raw) + { +#endif + pdc_free(p->pdc, (void *) src->buffer_start); + +#ifdef HAVE_LIBPNG + } +#endif +} + +#ifdef HAVE_LIBPNG +/* + * We suppress libpng's warning message by supplying + * our own error and warning handlers +*/ +static void +pdf_libpng_warning_handler(png_structp png_ptr, png_const_charp message) +{ + (void) png_ptr; /* avoid compiler warning "unreferenced parameter" */ + (void) message; /* avoid compiler warning "unreferenced parameter" */ + + /* do nothing */ + return; +} + +/* + * use the libpng portability aid in an attempt to overcome version differences + */ +#ifndef png_jmpbuf +#define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#endif + +static void +pdf_libpng_error_handler(png_structp png_ptr, png_const_charp message) +{ + (void) message; /* avoid compiler warning "unreferenced parameter" */ + + longjmp(png_jmpbuf(png_ptr), 1); +} + +static void * +pdf_libpng_malloc(png_structp png_ptr, size_t size) +{ + PDF *p = (PDF *)png_ptr->mem_ptr; + + return pdc_malloc(p->pdc, size, "libpng"); +} + +static void +pdf_libpng_free(png_structp png_ptr, void *mem) +{ + PDF *p = (PDF *)png_ptr->mem_ptr; + + pdc_free(p->pdc, mem); +} + +pdc_bool +pdf_is_PNG_file(PDF *p, pdc_file *fp) +{ + pdc_byte sig[8]; + + (void) p; + + if (!PDC_OK_FREAD(fp, sig, 8) || !png_check_sig(sig, 8)) { + pdc_fseek(fp, 0L, SEEK_SET); + return pdc_false; + } + return pdc_true; +} + +int +pdf_process_PNG_data( + PDF *p, + int imageslot) +{ + static const char *fn = "pdf_process_PNG_data"; + pdc_file *save_fp; + spng_info s_info; + + png_uint_32 width, height, ui; + png_bytep *row_pointers, trans; + png_color_8p sig_bit; + png_color_16p trans_values; + int bit_depth, color_type, i, num_trans; + float dpi_x, dpi_y; + pdf_image *image; + volatile int errcode = 0; + pdf_colorspace cs; + pdf_colormap *colormap; + volatile int slot; + + image = &p->images[imageslot]; + + /* + * We can install our own memory handlers in libpng since + * our PNG library is specially extended to support this. + * A custom version of libpng without support for + * png_create_read_struct_2() is no longer supported. + */ + + image->info.png.png_ptr = + png_create_read_struct_2(PNG_LIBPNG_VER_STRING, (png_voidp) NULL, + pdf_libpng_error_handler, pdf_libpng_warning_handler, + p, (png_malloc_ptr) pdf_libpng_malloc, + (png_free_ptr) pdf_libpng_free); + + if (!image->info.png.png_ptr) { + pdc_error(p->pdc, PDC_E_MEM_OUT, fn, 0, 0, 0); + } + + image->info.png.info_ptr = png_create_info_struct(image->info.png.png_ptr); + + if (image->info.png.info_ptr == NULL) { + png_destroy_read_struct(&image->info.png.png_ptr, + (png_infopp) NULL, (png_infopp) NULL); + pdc_error(p->pdc, PDC_E_MEM_OUT, fn, 0, 0, 0); + } + + if (setjmp(png_jmpbuf(image->info.png.png_ptr))) { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_PNG_ERROR; + } + + if (pdf_is_PNG_file(p, image->fp) == pdc_false) { + errcode = PDC_E_IO_BADFORMAT; + goto PDF_PNG_ERROR; + } + + /* from file or from file or memory */ + png_set_read_fn(image->info.png.png_ptr, image->fp, pdf_png_read_data); + + png_set_sig_bytes(image->info.png.png_ptr, 8); + png_read_info(image->info.png.png_ptr, image->info.png.info_ptr); + png_get_IHDR(image->info.png.png_ptr, image->info.png.info_ptr, + &width, &height, &bit_depth, &color_type, NULL, NULL, NULL); + + image->width = (float) width; + image->height = (float) height; + + /* reduce 16-bit images to 8 bit since PDF stops at 8 bit */ + if (bit_depth == 16) { + png_set_strip_16(image->info.png.png_ptr); + bit_depth = 8; + } + + image->bpc = bit_depth; + + /* + * Since PDF doesn't support a real alpha channel but only binary + * tranparency ("poor man's alpha"), we do our best and treat + * alpha values of up to 50% as transparent, and values above 50% + * as opaque. + * + * Since this behaviour is not exactly what the image author had in mind, + * it should probably be made user-configurable. + * + */ +#define ALPHA_THRESHOLD 128 + + switch (color_type) { + case PNG_COLOR_TYPE_GRAY_ALPHA: + /* LATER: construct mask from alpha channel */ + /* + png_set_IHDR(image->info.png.png_ptr, image->info.png.info_ptr, + width, height, bit_depth, PNG_COLOR_MASK_ALPHA, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + */ + png_set_strip_alpha(image->info.png.png_ptr); + /* fall through */ + + case PNG_COLOR_TYPE_GRAY: + if (png_get_sBIT(image->info.png.png_ptr, + image->info.png.info_ptr, &sig_bit)) { + png_set_shift(image->info.png.png_ptr, sig_bit); + } + + image->colorspace = DeviceGray; + + image->components = 1; + break; + + case PNG_COLOR_TYPE_RGB_ALPHA: + /* LATER: construct mask from alpha channel */ + png_set_strip_alpha(image->info.png.png_ptr); + /* fall through */ + + case PNG_COLOR_TYPE_RGB: + if (image->colorspace == pdc_undef) + image->colorspace = DeviceRGB; + image->components = 3; + + break; + + case PNG_COLOR_TYPE_PALETTE: + png_get_PLTE(image->info.png.png_ptr, image->info.png.info_ptr, + (png_colorp*) &colormap, &cs.val.indexed.palette_size); + + image->components = 1; + + /* This case should arguably be prohibited. However, we allow + * it and take the palette indices 0 and 1 as the mask, + * disregarding any color values in the palette. + */ + if (image->imagemask) { + image->colorspace = DeviceGray; + break; + } + + cs.type = Indexed; + cs.val.indexed.base = DeviceRGB; + cs.val.indexed.colormap = colormap; + cs.val.indexed.colormap_id = PDC_BAD_ID; + slot = pdf_add_colorspace(p, &cs, pdc_false); + + image->colorspace = (pdf_colorspacetype) slot; + + + break; + } + + if (image->imagemask) + { + if (image->components != 1) { + errcode = PDF_E_IMAGE_BADMASK; + goto PDF_PNG_ERROR; + } + + if (p->compatibility <= PDC_1_3) { + if (image->components != 1 || image->bpc != 1) { + errcode = PDF_E_IMAGE_MASK1BIT13; + goto PDF_PNG_ERROR; + } + } else if (image->bpc > 1) { + /* images with more than one bit will be written as /SMask, + * and don't require an /ImageMask entry. + */ + image->imagemask = pdc_false; + } + image->colorspace = DeviceGray; + } + + /* we invert this flag later */ + if (image->ignoremask) + image->transparent = pdc_true; + + /* let libpng expand interlaced images */ + (void) png_set_interlace_handling(image->info.png.png_ptr); + + /* read the physical dimensions chunk to find the resolution values */ + dpi_x = (float) png_get_x_pixels_per_meter(image->info.png.png_ptr, + image->info.png.info_ptr); + dpi_y = (float) png_get_y_pixels_per_meter(image->info.png.png_ptr, + image->info.png.info_ptr); + + if (dpi_x != 0 && dpi_y != 0) { /* absolute values */ + image->dpi_x = dpi_x * (float) PDC_INCH2METER; + image->dpi_y = dpi_y * (float) PDC_INCH2METER; + + } else { /* aspect ratio */ + image->dpi_y = -png_get_pixel_aspect_ratio(image->info.png.png_ptr, + image->info.png.info_ptr); + + if (image->dpi_y == (float) 0) /* unknown */ + image->dpi_x = (float) 0; + else + image->dpi_x = (float) -1.0; + } + + /* read the transparency chunk */ + if (png_get_valid(image->info.png.png_ptr, image->info.png.info_ptr, + PNG_INFO_tRNS)) { + png_get_tRNS(image->info.png.png_ptr, image->info.png.info_ptr, + &trans, &num_trans, &trans_values); + if (num_trans > 0) { + if (color_type == PNG_COLOR_TYPE_GRAY) { + image->transparent = !image->transparent; + /* LATER: scale down 16-bit transparency values ? */ + image->transval[0] = (pdc_byte) trans_values[0].gray; + + } else if (color_type == PNG_COLOR_TYPE_RGB) { + image->transparent = !image->transparent; + /* LATER: scale down 16-bit transparency values ? */ + image->transval[0] = (pdc_byte) trans_values[0].red; + image->transval[1] = (pdc_byte) trans_values[0].green; + image->transval[2] = (pdc_byte) trans_values[0].blue; + + } else if (color_type == PNG_COLOR_TYPE_PALETTE) { + /* we use the first transparent entry in the tRNS palette */ + for (i = 0; i < num_trans; i++) { + if ((pdc_byte) trans[i] < ALPHA_THRESHOLD) { + image->transparent = !image->transparent; + image->transval[0] = (pdc_byte) i; + break; + } + } + } + } + } + + + + png_read_update_info(image->info.png.png_ptr, image->info.png.info_ptr); + + image->info.png.rowbytes = + png_get_rowbytes(image->info.png.png_ptr, image->info.png.info_ptr); + + image->info.png.raster = (pdc_byte *) + pdc_calloc(p->pdc,image->info.png.rowbytes * height, fn); + + row_pointers = (png_bytep *) + pdc_malloc(p->pdc, height * sizeof(png_bytep), fn); + + for (ui = 0; ui < height; ui++) { + row_pointers[ui] = + image->info.png.raster + ui * image->info.png.rowbytes; + } + + /* try the simple way: + */ + save_fp = image->fp; + + image->src.init = pdf_data_source_PNG_init; + image->src.fill = pdf_data_source_PNG_fill; + image->src.terminate = pdf_data_source_PNG_terminate; + image->src.private_data = (void *) image; + + + image->fp = pdf_fopen(p, image->filename, NULL, PDC_FILE_BINARY); + if (image->fp != NULL && + spng_init(p, image, &s_info) == SPNG_ERR_OK && image->use_raw) + { + pdc_fclose(save_fp); + image->predictor = pred_png; + image->compression = flate; + } + else + { + if (image->fp != (pdc_file *) 0) + pdc_fclose(image->fp); + + image->fp = save_fp; + + /* fetch the actual image data */ + png_read_image(image->info.png.png_ptr, row_pointers); + } + + image->in_use = pdc_true; /* mark slot as used */ + + pdf_put_image(p, imageslot, pdc_true); + + pdc_free(p->pdc, image->info.png.raster); + pdc_free(p->pdc, row_pointers); + + png_destroy_read_struct(&image->info.png.png_ptr, + &image->info.png.info_ptr, NULL); + + return imageslot; + + PDF_PNG_ERROR: + png_destroy_read_struct(&image->info.png.png_ptr, + &image->info.png.info_ptr, NULL); + { + const char *stemp = pdc_errprintf(p->pdc, "%s", image->filename); + switch (errcode) + { + case PDF_E_IMAGE_ICC: + case PDF_E_IMAGE_ICC2: + case PDF_E_IMAGE_MASK1BIT13: + case PDF_E_IMAGE_BADMASK: + pdc_set_errmsg(p->pdc, errcode, stemp, 0, 0, 0); + break; + + case PDC_E_IO_BADFORMAT: + pdc_set_errmsg(p->pdc, errcode, stemp, "PNG", 0, 0); + break; + + case PDF_E_IMAGE_CORRUPT: + pdc_set_errmsg(p->pdc, errcode, "PNG", stemp, 0, 0); + break; + + case 0: /* error code and message already set */ + break; + } + } + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; +} + +#else /* !HAVE_LIBPNG */ + +pdc_bool +pdf_is_PNG_file(PDF *p, pdc_file *fp) +{ + return pdc_false; +} + +/* simple built-in PNG reader without libpng */ + +int +pdf_process_PNG_data( + PDF *p, + int imageslot) +{ + static const char fn[] = "pdf_process_PNG_data"; + spng_info s_info; + pdf_image *image; + + image = &p->images[imageslot]; + + image->src.init = pdf_data_source_PNG_init; + image->src.fill = pdf_data_source_PNG_fill; + image->src.terminate = pdf_data_source_PNG_terminate; + image->src.private_data = (void *) image; + + if (spng_init(p, image, &s_info) == SPNG_ERR_OK && image->use_raw) + { + image->predictor = pred_png; + image->compression = flate; + + image->width = (float) s_info.width; + image->height = (float) s_info.height; + image->bpc = s_info.bit_depth; + + image->components = 3; + + /* other types are rejected in spng_init() */ + image->colorspace = + (s_info.color_type == 0 ? DeviceGray : DeviceRGB); + + } + else + { + pdc_set_errmsg(p->pdc, PDF_E_UNSUPP_IMAGE, "PNG", 0, 0, 0); + + if (image->verbose) + pdc_warning(p->pdc, -1, 0, 0, 0, 0); + + return -1; + } + + image->in_use = pdc_true; /* mark slot as used */ + + pdf_put_image(p, imageslot, pdc_true); + + return imageslot; + +} + +#endif /* !HAVE_LIBPNG */ diff --git a/src/libs/pdflib/libs/pdflib/p_resource.c b/src/libs/pdflib/libs/pdflib/p_resource.c new file mode 100644 index 0000000000..296d781ed9 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_resource.c @@ -0,0 +1,746 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_resource.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib resource routines + * + */ + +#include + +#include "p_intern.h" + +#if defined(WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif + +#define RESOURCEFILE "PDFLIBRESOURCE" /* name of env var. */ + +#ifndef MVS +#define DEFAULTRESOURCEFILE "pdflib.upr" +#else +#define DEFAULTRESOURCEFILE "upr" +#endif + +struct pdf_res_s { + char *name; + char *value; + pdf_res *prev; + pdf_res *next; +}; + +struct pdf_category_s { + char *category; + pdf_res *kids; + pdf_category *next; +}; + +struct pdf_virtfile_s { + char *name; + const void *data; + size_t size; + pdc_bool iscopy; + int lockcount; + pdf_virtfile *next; +}; + +typedef enum { + pdf_FontOutline, + pdf_FontAFM, + pdf_FontPFM, + pdf_HostFont, + pdf_Encoding, + pdf_ICCProfile, + pdf_StandardOutputIntent, + pdf_SearchPath +} pdf_rescategory; + +static const pdc_keyconn pdf_rescategories[] = +{ + {"FontOutline", pdf_FontOutline}, + {"FontAFM", pdf_FontAFM}, + {"FontPFM", pdf_FontPFM}, + {"HostFont", pdf_HostFont}, + {"Encoding", pdf_Encoding}, + {"ICCProfile", pdf_ICCProfile}, + {"StandardOutputIntent", pdf_StandardOutputIntent}, + {"SearchPath", pdf_SearchPath}, + {NULL, 0} +}; + +static void +pdf_read_resourcefile(PDF *p, const char *filename) +{ + pdc_file *fp = NULL; + char **linelist; + char *line; + char *category = NULL; + char *uprfilename = NULL; +#if defined(AS400) || defined(WIN32) +#define BUFSIZE 2048 + char buffer[BUFSIZE]; +#ifdef WIN32 + char regkey[128]; + HKEY hKey = NULL; + DWORD size, lType; +#endif +#endif + int il, nlines = 0, nextcat, begin; + +#ifdef WIN32 + +/* don't add patchlevel's to registry searchpath */ +#define stringiz1(x) #x +#define stringiz(x) stringiz1(x) + +#define PDFLIBKEY "Software\\PDFlib\\PDFlib\\" + + strcpy(regkey, PDFLIBKEY); + strcat(regkey, PDFLIB_VERSIONSTRING); + + /* process registry entries */ + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, regkey, 0L, + (REGSAM) KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + size = BUFSIZE - 2; + if (RegQueryValueExA(hKey, "SearchPath", (LPDWORD) NULL, + &lType, (LPBYTE) buffer, &size) + == ERROR_SUCCESS && *buffer) + { + char **pathlist; + int ip, np; + + np = pdc_split_stringlist(p->pdc, buffer, + ";", &pathlist); + for (ip = 0; ip < np; ip++) + pdf_add_resource(p, "SearchPath", pathlist[ip]); + pdc_cleanup_stringlist(p->pdc, pathlist); + } + + size = BUFSIZE - 2; + if (RegQueryValueExA(hKey, "prefix", (LPDWORD) NULL, + &lType, (LPBYTE) buffer, &size) + == ERROR_SUCCESS && *buffer) + { + /* '/' because of downward compatibility */ + if (p->prefix) + { + pdc_free(p->pdc, p->prefix); + p->prefix = NULL; + } + p->prefix = pdc_strdup(p->pdc, + &buffer[buffer[0] == '/' ? 1 : 0]); + } + + RegCloseKey(hKey); + } +#endif /* WIN32 */ + +#ifdef AS400 + strcpy (buffer, "/pdflib/"); + strcat (buffer, PDFLIB_VERSIONSTRING); + il = (int) strlen(buffer); + strcat (buffer, "/fonts"); + pdf_add_resource(p, "SearchPath", buffer); + strcpy(&buffer[il], "/bind/data"); + pdf_add_resource(p, "SearchPath", buffer); +#endif /* AS400 */ + + /* searching for name of upr file */ + uprfilename = (char *)filename; + if (!uprfilename || *uprfilename == '\0') + { + /* user-supplied upr file */ + uprfilename = pdc_getenv(RESOURCEFILE); + if (!uprfilename || *uprfilename == '\0') + { + uprfilename = DEFAULTRESOURCEFILE; + + /* user-supplied upr file */ + fp = pdf_fopen(p, uprfilename, NULL, 0); + if (fp == NULL) + { + uprfilename = NULL; +#ifdef WIN32 + /* process registry entries */ + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, regkey, 0L, + (REGSAM) KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + size = BUFSIZE - 2; + if (RegQueryValueExA(hKey, "resourcefile", (LPDWORD) NULL, + &lType, (LPBYTE) buffer, &size) + == ERROR_SUCCESS && *buffer) + { + uprfilename = buffer; + } + + RegCloseKey(hKey); + } +#endif /* WIN32 */ + } + } + + if (!uprfilename || *uprfilename == '\0') + return; + + if (p->resourcefilename) + { + pdc_free(p->pdc, p->resourcefilename); + p->resourcefilename = NULL; + } + p->resourcefilename = pdc_strdup(p->pdc, uprfilename); + } + + /* read upr file */ + if ((fp == NULL) && ((fp = pdf_fopen(p, uprfilename, "UPR ", 0)) == NULL)) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + nlines = pdc_read_textfile(p->pdc, fp, &linelist); + pdc_fclose(fp); + + if (!nlines) return; + + /* Lines loop */ + begin = 1; + nextcat = 0; + for (il = 0; il < nlines; il++) + { + line = linelist[il]; + + /* Next category */ + if (line[0] == '.' && strlen(line) == 1) + { + begin = 0; + nextcat = 1; + continue; + } + + /* Skip category list */ + if (begin) continue; + + /* Prefiex or category expected */ + if (nextcat) + { + /* Directory prefix */ + if (line[0] == '/') + { + if (p->prefix) + { + pdc_free(p->pdc, p->prefix); + p->prefix = NULL; + } + p->prefix = pdc_strdup(p->pdc, &line[1]); + continue; + } + + /* Ressource Category */ + category = line; + nextcat = 0; + continue; + } + + /* Add resource */ + pdf_add_resource(p, category, line); + } + + pdc_cleanup_stringlist(p->pdc, linelist); +} + +void +pdf_add_resource(PDF *p, const char *category, const char *resource) +{ + static const char fn[] = "pdf_add_resource"; + pdf_rescategory rescat; + pdf_category *cat, *lastcat = NULL; + pdf_res *res, *lastres = NULL; + char *name; + char *value; + char *prefix = NULL; + size_t len; + int k, absolut; + + /* We no longer raise an error but silently ignore unknown categories */ + k = pdc_get_keycode(category, pdf_rescategories); + if (k == PDC_KEY_NOTFOUND) + return; + rescat = (pdf_rescategory) k; + + /* Read resource configuration file if it is pending */ + if (p->resfilepending) + { + p->resfilepending = pdc_false; + pdf_read_resourcefile(p, p->resourcefilename); + } + + /* Find start of this category's resource list, if the category exists */ + for (cat = p->resources; cat != (pdf_category *) NULL; cat = cat->next) + { + lastcat = cat; + if (!strcmp(cat->category, category)) + break; + } + if (cat == NULL) + { + cat = (pdf_category *) pdc_malloc(p->pdc, sizeof(pdf_category), fn); + cat->category = pdc_strdup(p->pdc, category); + cat->kids = NULL; + cat->next = NULL; + + if (lastcat) + lastcat->next = cat; + else + p->resources = cat; + } + + /* Determine name and value of resource */ + absolut = 0; + len = strlen(resource); + value = strchr(resource, '='); + if (value) + { + len = (size_t) (value - resource); + value++; + if (*value == '=') + { + absolut = 1; + value++; + } + + /* file name is assumed */ + if (value[0] != '\0' && value[0] == '.' && value[1] == '/') + { + value += 2; + } + } + + /* Copy resource name */ + name = (char *) pdc_malloc(p->pdc, len + 1, fn); + strncpy(name, resource, len); + name[len] = 0; + pdc_strtrim(name); + + /* Find resource name in resource list */ + for (res = cat->kids; res != (pdf_res *) NULL; res = res->next) + { + if (!strcmp(res->name, name)) + break; + lastres = res; + } + + /* New resource */ + if (res) + { + pdc_free(p->pdc, name); + } + else + { + res = (pdf_res *) pdc_calloc(p->pdc, sizeof(pdf_res), fn); + if (lastres) + lastres->next = res; + else + cat->kids = res; + res->prev = lastres; + res->name = name; + } + + /* New value */ + if (res->value) + pdc_free(p->pdc, res->value); + res->value = NULL; + if (!value) + { + value = ""; + } + else if (!absolut && p->prefix) + { + /* Directory prefix */ + prefix = p->prefix; + if (prefix[0] != '\0' && prefix[0] == '.' && prefix[1] == '/') + prefix += 2; + if (prefix) + { + len = strlen(prefix) + strlen(value) + 6; + res->value = (char *) pdc_malloc(p->pdc, len, fn); + pdc_file_fullname(prefix, value, res->value); + } + } + if (!res->value) + { + res->value = pdc_strdup(p->pdc, value); + pdc_str2trim(res->value); + } + +#undef PDF_TEST_RESOURCE +#ifdef PDF_TEST_RESOURCE + printf("%s.%s: '%s'\n", category, res->name, res->value); +#endif + + switch (rescat) + { + case pdf_FontOutline: + case pdf_FontAFM: + case pdf_FontPFM: + case pdf_HostFont: + case pdf_Encoding: + case pdf_ICCProfile: + if (!strlen(res->name) || !strlen(res->value)) + pdc_error(p->pdc, PDF_E_RES_BADRES, resource, category, 0, 0); + break; + + default: + break; + } +} + +char * +pdf_find_resource(PDF *p, const char *category, const char *name) +{ + pdf_category *cat; + pdf_res *res; + + /* Read resource configuration file if it is pending */ + if (p->resfilepending) + { + p->resfilepending = pdc_false; + pdf_read_resourcefile(p, p->resourcefilename); + } + + for (cat = p->resources; cat != (pdf_category *) NULL; cat = cat->next) + { + if (!strcmp(cat->category, category)) + { + for (res = cat->kids; res != (pdf_res *)NULL; res = res->next) + { + if (!strcmp(res->name, name)) + { + return res->value; + } + } + } + } + + return NULL; +} + +void +pdf_cleanup_resources(PDF *p) +{ + pdf_category *cat, *lastcat; + pdf_res *res, *lastres; + + for (cat = p->resources; cat != (pdf_category *) NULL; /* */) { + for (res = cat->kids; res != (pdf_res *) NULL; /* */) { + lastres = res; + res = lastres->next; + pdc_free(p->pdc, lastres->name); + if (lastres->value) + pdc_free(p->pdc, lastres->value); + pdc_free(p->pdc, lastres); + } + lastcat = cat; + cat = lastcat->next; + pdc_free(p->pdc, lastcat->category); + pdc_free(p->pdc, lastcat); + } + + p->resources = NULL; +} + +static pdf_virtfile * +pdf_find_pvf(PDF *p, const char *filename, pdf_virtfile **lastvfile) +{ + pdf_virtfile *vfile; + + if (lastvfile != NULL) + *lastvfile = NULL; + for (vfile = p->filesystem; vfile != NULL; vfile = vfile->next) + { + if (!strcmp(vfile->name, filename)) + return vfile; + if (lastvfile != NULL) + *lastvfile = vfile; + } + return NULL; +} + +/* definitions of pvf options */ +static const pdc_defopt pdf_create_pvf_options[] = +{ + {"copy", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + PDC_OPT_TERMINATE +}; + +void +pdf__create_pvf(PDF *p, const char *filename, int reserved, + const void *data, size_t size, const char *optlist) +{ + static const char fn[] = "pdf__create_pvf"; + pdc_bool iscopy = pdc_false; + pdf_virtfile *vfile, *lastvfile = NULL; + pdc_resopt *results; + + (void) reserved; + + /* Parse optlist */ + results = pdc_parse_optionlist(p->pdc, optlist, pdf_create_pvf_options, + NULL, pdc_true); + pdc_get_optvalues(p->pdc, "copy", results, &iscopy, NULL); + pdc_cleanup_optionlist(p->pdc, results); + + /* Find virtual file in file system */ + vfile = pdf_find_pvf(p, filename, &lastvfile); + + /* Name already exists */ + if (vfile != NULL) + pdc_error(p->pdc, PDC_E_PVF_NAMEEXISTS, filename, 0, 0, 0); + + /* New virtual file */ + vfile = (pdf_virtfile *) pdc_calloc(p->pdc, sizeof(pdf_virtfile), fn); + if (lastvfile) + lastvfile->next = vfile; + else + p->filesystem = vfile; + + /* Fill up file struct */ + vfile->name = pdc_strdup(p->pdc, filename); + if (iscopy == pdc_true) + { + vfile->data = (const void *) pdc_malloc(p->pdc, size, fn); + memcpy((void *) vfile->data, data, size); + } + else + { + vfile->data = data; + } + vfile->size = size; + vfile->iscopy = iscopy; + vfile->lockcount = 0; + vfile->next = NULL; +} + +int +pdf__delete_pvf(PDF *p, const char *filename, int reserved) +{ + pdf_virtfile *vfile, *lastvfile = NULL; + + (void) reserved; + + /* Find virtual file in file system */ + vfile = pdf_find_pvf(p, filename, &lastvfile); + if (vfile) + { + /* File exists but locked */ + if (vfile->lockcount > 0) + { + return pdc_undef; + } + + /* Delete */ + if (vfile->iscopy == pdc_true) + { + pdc_free(p->pdc, (void *) vfile->data); + vfile->data = NULL; + } + pdc_free(p->pdc, vfile->name); + if (lastvfile) + lastvfile->next = vfile->next; + else + p->filesystem = vfile->next; + pdc_free(p->pdc, vfile); + } + + return pdc_true; +} + +PDFLIB_API void PDFLIB_CALL +PDF_create_pvf(PDF *p, const char *filename, int reserved, + const void *data, size_t size, const char *optlist) +{ + static const char fn[] = "PDF_create_pvf"; + + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", %d, \"%p\", %d, \"%s\")\n", + (void *) p, filename, reserved, data, size, optlist)) + { + return; + } + + if (filename == NULL || *filename == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "filename", 0, 0, 0); + + if (!data) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "data", 0, 0, 0); + + if (!size) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "size", 0, 0, 0); + + pdf__create_pvf(p, filename, reserved, data, size, optlist); +} + +PDFLIB_API int PDFLIB_CALL +PDF_delete_pvf(PDF *p, const char *filename, int reserved) +{ + static const char fn[] = "PDF_delete_pvf"; + pdc_bool retval = pdc_true; + + if (!pdf_enter_api(p, fn, pdf_state_all, + "(p[%p], \"%s\", %d)", + (void *) p, filename, reserved)) + { + PDF_RETURN_BOOLEAN(p, retval); + } + + if (filename == NULL || *filename == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "filename", 0, 0, 0); + + retval = pdf__delete_pvf(p, filename, reserved); + + PDF_RETURN_BOOLEAN(p, retval); +} + +void +pdf_lock_pvf(PDF *p, const char *filename) +{ + pdf_virtfile *vfile = pdf_find_pvf(p, filename, NULL); + if (vfile) + (vfile->lockcount)++; +} + +void +pdf_unlock_pvf(PDF *p, const char *filename) +{ + pdf_virtfile *vfile = pdf_find_pvf(p, filename, NULL); + if (vfile) + (vfile->lockcount)--; +} + +void +pdf_cleanup_filesystem(PDF *p) +{ + pdf_virtfile *vfile, *nextvfile; + + for (vfile = p->filesystem; vfile != NULL; /* */) + { + nextvfile = vfile->next; + if (vfile->iscopy == pdc_true && vfile->data) + pdc_free(p->pdc, (void *) vfile->data); + if (vfile->name) + pdc_free(p->pdc, vfile->name); + pdc_free(p->pdc, vfile); + vfile = nextvfile; + } + p->filesystem = NULL; +} +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma unmanaged +#endif +pdc_file * +pdf_fopen(PDF *p, const char *filename, const char *qualifier, int flags) +{ + const pdc_byte *data = NULL; + size_t size = 0; + pdf_virtfile *vfile; + + vfile = pdf_find_pvf(p, filename, NULL); + if (vfile) + { + size = vfile->size; + data = (const pdc_byte *) vfile->data; + return pdc_fopen(p->pdc, filename, qualifier, data, size, flags); + } + else + { + pdf_category *cat; + + /* Bad filename */ + if (!*filename || !strcmp(filename, ".") || !strcmp(filename, "..")) + { + pdc_set_errmsg(p->pdc, PDC_E_IO_ILLFILENAME, filename, 0, 0, 0); + return NULL; + } + + /* Read resource configuration file if it is pending */ + if (p->resfilepending) + { + p->resfilepending = pdc_false; + pdf_read_resourcefile(p, p->resourcefilename); + } + +#ifdef PDF_TEST_RESOURCE + printf("Search for file '%s'\n", filename); +#endif + + /* Searching resource category */ + for (cat = p->resources; cat != (pdf_category *) NULL; cat = cat->next) + if (!strcmp(cat->category, "SearchPath")) break; + + if (!cat) + { + /* No resource category */ + return pdc_fopen(p->pdc, filename, qualifier, NULL, 0, flags); + } + else + { + pdf_res *res = cat->kids; + pdf_res *lastres = cat->kids; + char *pathname = NULL; + char fullname[PDC_FILENAMELEN]; + FILE *fp = NULL; + int errnum = PDC_E_IO_RDOPEN_NF; + + /* Find last SearchPath entry */ + while (res != (pdf_res *) NULL) + { + lastres = res; + res = res->next; + } + + /* First local search and then search with concatenated + * filename with search paths one after another backwards + */ + while (1) + { + /* Test opening */ + pdc_file_fullname(pathname, filename, fullname); + +#ifdef PDF_TEST_RESOURCE + printf(" pathname '%s' -> fullname: '%s'\n", pathname, fullname); +#endif + fp = fopen(fullname, READBMODE); + if (fp) + { + /* File found */ + fclose(fp); + return + pdc_fopen(p->pdc, fullname, qualifier, NULL, 0, flags); + } + errnum = pdc_get_fopen_errnum(p->pdc, PDC_E_IO_RDOPEN); + if (errno != 0 && errnum != PDC_E_IO_RDOPEN_NF) break; + + if (lastres == (pdf_res *) NULL) + break; + + pathname = lastres->name; + lastres = lastres->prev; + } + + pdc_set_errmsg(p->pdc, errnum, qualifier, filename, 0, 0); + return NULL; + } + } +} +#if defined(_MSC_VER) && defined(_MANAGED) +#pragma managed +#endif diff --git a/src/libs/pdflib/libs/pdflib/p_shading.c b/src/libs/pdflib/libs/pdflib/p_shading.c new file mode 100644 index 0000000000..fc9dd1f564 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_shading.c @@ -0,0 +1,381 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_shading.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib routines for smooth shading + * + */ + +#include "p_intern.h" +#include "p_font.h" + +typedef enum +{ + shnone = 0, + axial = 2, + radial = 3 +} pdf_shadingtype_e; + +struct pdf_shading_s { + pdc_id obj_id; /* object id of this shading */ + pdc_bool used_on_current_page; /* this shading used on current page */ +}; + +void +pdf_init_shadings(PDF *p) +{ + int i; + + p->shadings_number = 0; + p->shadings_capacity = SHADINGS_CHUNKSIZE; + + p->shadings = (pdf_shading *) pdc_malloc(p->pdc, + sizeof(pdf_shading) * p->shadings_capacity, "pdf_init_shadings"); + + for (i = 0; i < p->shadings_capacity; i++) { + p->shadings[i].used_on_current_page = pdc_false; + p->shadings[i].obj_id = PDC_BAD_ID; + } +} + +static void +pdf_grow_shadings(PDF *p) +{ + int i; + + p->shadings = (pdf_shading *) pdc_realloc(p->pdc, p->shadings, + sizeof(pdf_shading) * 2 * p->shadings_capacity, "pdf_grow_shadings"); + + for (i = p->shadings_capacity; i < 2 * p->shadings_capacity; i++) { + p->shadings[i].used_on_current_page = pdc_false; + p->shadings[i].obj_id = PDC_BAD_ID; + } + + p->shadings_capacity *= 2; +} + +void +pdf_write_page_shadings(PDF *p) +{ + int i, total = 0; + + for (i = 0; i < p->shadings_number; i++) + if (p->shadings[i].used_on_current_page) + total++; + + if (total > 0) { + pdc_puts(p->out, "/Shading"); + + pdc_begin_dict(p->out); /* Shading */ + + for (i = 0; i < p->shadings_number; i++) { + if (p->shadings[i].used_on_current_page) { + p->shadings[i].used_on_current_page = pdc_false; /* reset */ + pdc_printf(p->out, "/Sh%d %ld 0 R\n", i, p->shadings[i].obj_id); + } + } + + pdc_end_dict(p->out); /* Shading */ + } +} + +void +pdf_cleanup_shadings(PDF *p) +{ + if (p->shadings) { + pdc_free(p->pdc, p->shadings); + p->shadings = NULL; + } +} + +static const pdc_defopt pdf_shading_pattern_options[] = +{ + {"gstate", pdc_gstatehandle, 0, 1, 1, 0, 0, NULL}, + PDC_OPT_TERMINATE +}; + +PDFLIB_API int PDFLIB_CALL +PDF_shading_pattern(PDF *p, int shading, const char *optlist) +{ + static const char fn[] = "PDF_shading_pattern"; + pdc_resopt *results; + pdc_clientdata data; + int gstate = -1; + int retval = -1; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page | pdf_state_font), + "(p[%p], %d, \"%s\")", (void *) p, shading, optlist)) { + PDF_RETURN_HANDLE(p, retval) + } + + if (p->compatibility == PDC_1_3) + pdc_error(p->pdc, PDF_E_SHADING13, 0, 0, 0, 0); + + PDF_INPUT_HANDLE(p, shading) + pdf_check_handle(p, shading, pdc_shadinghandle); + + if (optlist && strlen(optlist)) { + data.maxgstate = p->extgstates_number - 1; + data.hastobepos = p->hastobepos; + + results = pdc_parse_optionlist(p->pdc, + optlist, pdf_shading_pattern_options, &data, pdc_true); + + (void) pdc_get_optvalues(p->pdc, "gstate", results, &gstate, NULL); + + pdc_cleanup_optionlist(p->pdc, results); + } + + if (p->pattern_number == p->pattern_capacity) + pdf_grow_pattern(p); + + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_end_contents_section(p); + + /* Pattern object */ + p->pattern[p->pattern_number].obj_id = pdc_begin_obj(p->out, PDC_NEW_ID); + + /* Shadings don't have a painttype, but this signals to the + * code which writes the pattern usage that no color values + * will be required when setting the pattern color space. + */ + p->pattern[p->pattern_number].painttype = 1; + + pdc_begin_dict(p->out); /* Pattern dict*/ + + pdc_puts(p->out, "/PatternType 2\n"); /* shading pattern */ + + pdc_printf(p->out, "/Shading %ld 0 R\n", p->shadings[shading].obj_id); + + p->shadings[shading].used_on_current_page = pdc_true; + + if (gstate != -1) { + pdc_printf(p->out, "/ExtGState %ld 0 R\n", + pdf_get_gstate_id(p, gstate)); + } + + pdc_end_dict(p->out); /* Pattern dict*/ + pdc_end_obj(p->out); /* Pattern object */ + + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_begin_contents_section(p); + + retval = p->pattern_number; + p->pattern_number++; + PDF_RETURN_HANDLE(p, retval) +} + +PDFLIB_API void PDFLIB_CALL +PDF_shfill(PDF *p, int shading) +{ + static const char fn[] = "PDF_shfill"; + int legal_states; + + if (PDF_GET_STATE(p) == pdf_state_glyph && !pdf_get_t3colorized(p)) + legal_states = pdf_state_page | pdf_state_pattern | pdf_state_template; + + else if (PDF_GET_STATE(p) == pdf_state_pattern && + p->pattern[p->pattern_number-1].painttype == 2) + legal_states = pdf_state_page | pdf_state_glyph | pdf_state_template; + + else + legal_states = pdf_state_content; + + if (!pdf_enter_api(p, fn, (pdf_state) legal_states, + "(p[%p], %d)\n", (void *) p, shading)) + return; + + if (p->compatibility == PDC_1_3) + pdc_error(p->pdc, PDF_E_SHADING13, 0, 0, 0, 0); + + PDF_INPUT_HANDLE(p, shading) + pdf_check_handle(p, shading, pdc_shadinghandle); + + if (PDF_GET_STATE(p) == pdf_state_path) + pdf_end_path(p); + + pdf_end_text(p); + + pdc_printf(p->out, "/Sh%d sh\n", shading); + + p->shadings[shading].used_on_current_page = pdc_true; +} + +static const pdc_defopt pdf_shading_options[] = +{ + {"N", pdc_floatlist, PDC_OPT_NOZERO, 1, 1, 0, PDC_FLOAT_MAX, NULL}, + {"r0", pdc_floatlist, PDC_OPT_NONE, 1, 1, 0, PDC_FLOAT_MAX, NULL}, + {"r1", pdc_floatlist, PDC_OPT_NONE, 1, 1, 0, PDC_FLOAT_MAX, NULL}, + {"extend0", pdc_booleanlist, PDC_OPT_NONE, 0, 1, 0, 1, NULL}, + {"extend1", pdc_booleanlist, PDC_OPT_NONE, 0, 1, 0, 0, NULL}, + {"antialias", pdc_booleanlist, PDC_OPT_NONE, 0, 1, 0, 0, NULL}, + PDC_OPT_TERMINATE +}; + +PDFLIB_API int PDFLIB_CALL +PDF_shading( + PDF *p, + const char *type, + float x_0, float y_0, + float x_1, float y_1, + float c_1, float c_2, float c_3, float c_4, + const char *optlist) +{ + static const char fn[] = "PDF_shading"; + pdf_shadingtype_e shtype = shnone; + pdf_color *color0, color1; + pdf_colorspace *cs; + pdc_resopt *results; + float N = (float) 1.0; + float r_0, r_1; + pdc_bool extend0 = pdc_false, extend1 = pdc_false, antialias = pdc_false; + int retval = -1; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_page | pdf_state_font), + "(p[%p], \"%s\", \"%s\")", + (void *) p, type, optlist)) + { + PDF_RETURN_HANDLE(p, retval) + } + + if (p->compatibility == PDC_1_3) + pdc_error(p->pdc, PDF_E_SHADING13, 0, 0, 0, 0); + + if (!strcmp(type, "axial")) { + shtype = axial; + + } else if (!strcmp(type, "radial")) { + shtype = radial; + + } else + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "type", type, 0, 0); + + color0 = &p->cstate[p->sl].fill; + + color1.cs = color0->cs; + + cs = &p->colorspaces[color0->cs]; + + switch (cs->type) { + case DeviceGray: + color1.val.gray = c_1; + break; + + case DeviceRGB: + color1.val.rgb.r = c_1; + color1.val.rgb.g = c_2; + color1.val.rgb.b = c_3; + break; + + case DeviceCMYK: + color1.val.cmyk.c = c_1; + color1.val.cmyk.m = c_2; + color1.val.cmyk.y = c_3; + color1.val.cmyk.k = c_4; + break; + + + + default: + pdc_error(p->pdc, PDF_E_INT_BADCS, + pdc_errprintf(p->pdc, "%d", color0->cs), 0, 0, 0); + } + + if (optlist && strlen(optlist)) { + results = pdc_parse_optionlist(p->pdc, + optlist, pdf_shading_options, NULL, pdc_true); + + (void) pdc_get_optvalues(p->pdc, "N", results, &N, NULL); + + (void) pdc_get_optvalues(p->pdc, "antialias", results, &antialias,NULL); + + if (shtype == radial) { + if (pdc_get_optvalues(p->pdc, "r0", results, &r_0, NULL) != 1) + pdc_error(p->pdc, PDC_E_OPT_NOTFOUND, "r0", 0, 0, 0); + + if (pdc_get_optvalues(p->pdc, "r1", results, &r_1, NULL) != 1) + pdc_error(p->pdc, PDC_E_OPT_NOTFOUND, "r1", 0, 0, 0); + } + + if (shtype == axial) { + if (pdc_get_optvalues(p->pdc, "r0", results, &r_0, NULL) == 1) + pdc_warning(p->pdc, PDC_E_OPT_IGNORED, "r0", 0, 0, 0); + + if (pdc_get_optvalues(p->pdc, "r1", results, &r_1, NULL) == 1) + pdc_warning(p->pdc, PDC_E_OPT_IGNORED, "r1", 0, 0, 0); + } + + if (shtype == radial || shtype == axial) { + pdc_get_optvalues(p->pdc, "extend0", results, &extend0, NULL); + pdc_get_optvalues(p->pdc, "extend1", results, &extend1, NULL); + } + + pdc_cleanup_optionlist(p->pdc, results); + } + + if (p->shadings_number == p->shadings_capacity) + pdf_grow_shadings(p); + + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_end_contents_section(p); + + /* Shading object */ + p->shadings[p->shadings_number].obj_id = pdc_begin_obj(p->out, PDC_NEW_ID); + + pdc_begin_dict(p->out); /* Shading dict*/ + + pdc_printf(p->out, "/ShadingType %d\n", (int) shtype); + + pdc_printf(p->out, "/ColorSpace"); + pdf_write_colorspace(p, color1.cs, pdc_false); + pdc_puts(p->out, "\n"); + + if (antialias) + pdc_printf(p->out, "/AntiAlias true\n"); + + switch (shtype) { + case axial: /* Type 2 */ + pdc_printf(p->out, "/Coords[%f %f %f %f]\n", x_0, y_0, x_1, y_1); + if (extend0 || extend1) + pdc_printf(p->out, "/Extend[%s %s]\n", + extend0 ? "true" : "false", extend1 ? "true" : "false"); + pdc_puts(p->out, "/Function"); + pdf_write_function_dict(p, color0, &color1, N); + break; + + case radial: /* Type 3 */ + pdc_printf(p->out, "/Coords[%f %f %f %f %f %f]\n", + x_0, y_0, r_0, x_1, y_1, r_1); + if (extend0 || extend1) + pdc_printf(p->out, "/Extend[%s %s]\n", + extend0 ? "true" : "false", extend1 ? "true" : "false"); + pdc_puts(p->out, "/Function"); + pdf_write_function_dict(p, color0, &color1, N); + break; + + default: + break; + } + + pdc_end_dict(p->out); /* Shading dict */ + pdc_end_obj(p->out); /* Shading object */ + + if (PDF_GET_STATE(p) == pdf_state_page) + pdf_begin_contents_section(p); + + retval = p->shadings_number; + p->shadings_number++; + PDF_RETURN_HANDLE(p, retval) +} diff --git a/src/libs/pdflib/libs/pdflib/p_subsett.c b/src/libs/pdflib/libs/pdflib/p_subsett.c new file mode 100644 index 0000000000..27c1fea502 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_subsett.c @@ -0,0 +1,26 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_subsett.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib subsetting routines + * + */ + +#include + +#include "p_intern.h" +#include "p_font.h" +#include "p_truetype.h" + +#include "pc_md5.h" + diff --git a/src/libs/pdflib/libs/pdflib/p_template.c b/src/libs/pdflib/libs/pdflib/p_template.c new file mode 100644 index 0000000000..0551d181e5 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_template.c @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_template.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib template routines + * + */ + +#include "p_intern.h" +#include "p_image.h" +#include "p_font.h" + +/* Start a new template definition. */ +PDFLIB_API int PDFLIB_CALL +PDF_begin_template(PDF *p, float width, float height) +{ + static const char fn[] = "PDF_begin_template"; + pdf_image *image; + int im = -1; + + if (!pdf_enter_api(p, fn, pdf_state_document, "(p[%p], %g, %g)", + (void *) p, width, height)) + { + PDF_RETURN_HANDLE(p, im) + } + + if (width <= 0) + pdc_error(p->pdc, PDC_E_ILLARG_POSITIVE, "width", 0, 0, 0); + + if (height <= 0) + pdc_error(p->pdc, PDC_E_ILLARG_POSITIVE, "height", 0, 0, 0); + + for (im = 0; im < p->images_capacity; im++) + if (!p->images[im].in_use) /* found free slot */ + break; + + if (im == p->images_capacity) + pdf_grow_images(p); + + image = &p->images[im]; + image->in_use = pdc_true; /* mark slot as used */ + image->no = pdf_new_xobject(p, form_xobject, PDC_NEW_ID); + image->width = width; + image->height = height; + + p->height = height; + p->width = width; + p->thumb_id = PDC_BAD_ID; + PDF_PUSH_STATE(p, fn, pdf_state_template); + p->templ = im; /* remember the current template id */ + p->next_content = 0; + p->contents = c_page; + p->sl = 0; + + pdf_init_tstate(p); + pdf_init_gstate(p); + pdf_init_cstate(p); + + pdc_begin_dict(p->out); /* form xobject dict*/ + pdc_puts(p->out, "/Type/XObject\n"); + pdc_puts(p->out, "/Subtype/Form\n"); + + /* contrary to the PDF reference /FormType and /Matrix are required! */ + pdc_printf(p->out, "/FormType 1\n"); + pdc_printf(p->out, "/Matrix[1 0 0 1 0 0]\n"); + + p->res_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/Resources %ld 0 R\n", p->res_id); + + pdc_printf(p->out, "/BBox[0 0 %f %f]\n", p->width, p->height); + + p->length_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/Length %ld 0 R\n", p->length_id); + + if (pdc_get_compresslevel(p->out)) + pdc_puts(p->out, "/Filter/FlateDecode\n"); + + pdc_end_dict(p->out); /* form xobject dict*/ + pdc_begin_pdfstream(p->out); + + p->next_content++; + + /* top-down y-coordinates */ + pdf_set_topdownsystem(p, height); + + PDF_RETURN_HANDLE(p, im) +} + +/* Finish the template definition. */ +PDFLIB_API void PDFLIB_CALL +PDF_end_template(PDF *p) +{ + static const char fn[] = "PDF_end_template"; + + if (!pdf_enter_api(p, fn, pdf_state_template, "(p[%p])\n", (void *) p)) + return; + + /* check whether pdf__save() and pdf__restore() calls are balanced */ + if (p->sl > 0) + pdc_error(p->pdc, PDF_E_GSTATE_UNMATCHEDSAVE, 0, 0, 0, 0); + + pdf_end_text(p); + p->contents = c_none; + + pdc_end_pdfstream(p->out); + pdc_end_obj(p->out); /* form xobject */ + + pdc_put_pdfstreamlength(p->out, p->length_id); + + pdc_begin_obj(p->out, p->res_id); /* Resource object */ + pdc_begin_dict(p->out); /* Resource dict */ + + pdf_write_page_fonts(p); /* Font resources */ + + pdf_write_page_colorspaces(p); /* Color space resources */ + + pdf_write_page_pattern(p); /* Pattern resources */ + + pdf_write_xobjects(p); /* XObject resources */ + + pdf_write_page_extgstates(p); /* ExtGState resources */ + + pdc_end_dict(p->out); /* resource dict */ + pdc_end_obj(p->out); /* resource object */ + + PDF_POP_STATE(p, fn); + + if (p->flush & pdf_flush_page) + pdc_flush_stream(p->out); +} diff --git a/src/libs/pdflib/libs/pdflib/p_text.c b/src/libs/pdflib/libs/pdflib/p_text.c new file mode 100644 index 0000000000..c91f71b29e --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_text.c @@ -0,0 +1,1632 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_text.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib text routines + * + */ + +#define P_TEXT_C + +#include "p_intern.h" +#include "p_font.h" + +/* ------------------------ Text object operators ------------------------ */ + +static void +pdf_begin_text(PDF *p) +{ + if (p->contents != c_text) + { + p->contents = c_text; + p->textparams_done = pdc_false; + + pdc_puts(p->out, "BT\n"); + + /* BT resets the current point, text matrix, and line matrix */ + p->gstate[p->sl].x = (float) 0.0; + p->gstate[p->sl].y = (float) 0.0; + } +} + +static void +pdf_put_textmatrix(PDF *p) +{ + pdc_matrix *m = &p->tstate[p->sl].m; + + pdc_printf(p->out, "%f %f %f %f %f %f Tm\n", + m->a, m->b, m->c, m->d, m->e, m->f); + p->tstate[p->sl].me = p->tstate[p->sl].m.e; + p->tstate[p->sl].potm = pdc_false; +} + +void +pdf_end_text(PDF *p) +{ + if (p->contents != c_text) + return; + + p->contents = c_page; + + pdc_puts(p->out, "ET\n"); + p->tstate[p->sl].potm = pdc_true; +} + +/* ------------------------ Text state operators ------------------------ */ + +/* Initialize the text state at the beginning of each page */ +void +pdf_init_tstate(PDF *p) +{ + pdf_tstate *ts; + + ts = &p->tstate[p->sl]; + + ts->c = (float) 0; + ts->w = (float) 0; + ts->h = (float) 1; + ts->l = (float) 0; + ts->f = -1; + ts->fs = (float) 0; + + ts->m.a = (float) 1; + ts->m.b = (float) 0; + ts->m.c = (float) 0; + ts->m.d = (float) 1; + ts->m.e = (float) 0; + ts->m.f = (float) 0; + ts->me = (float) 0; + + ts->mode = 0; + ts->rise = (float) 0; + + ts->lm.a = (float) 1; + ts->lm.b = (float) 0; + ts->lm.c = (float) 0; + ts->lm.d = (float) 1; + ts->lm.e = (float) 0; + ts->lm.f = (float) 0; + + ts->potm = pdc_false; + + p->underline = pdc_false; + p->overline = pdc_false; + p->strikeout = pdc_false; + p->textparams_done = pdc_false; +} + +/* reset the text state */ +void +pdf_reset_tstate(PDF *p) +{ + float ydirection = p->ydirection; + p->ydirection = (float) 1.0; + + pdf_set_horiz_scaling(p, 100); + pdf_set_leading(p, 0); + pdf_set_text_rise(p, 0); + pdf_end_text(p); + + p->ydirection = ydirection; +} + +/* character spacing for justified lines */ +void +pdf_set_char_spacing(PDF *p, float spacing) +{ + spacing *= p->ydirection; + if (PDF_GET_STATE(p) == pdf_state_document) + { + p->tstate[p->sl].c = spacing; + return; + } + + /* + * We take care of spacing values != 0 in the text output functions, + * but must explicitly reset here. + */ + if (spacing == (float) 0) { + pdf_begin_text(p); + pdc_printf(p->out, "%f Tc\n", spacing); + } + + p->tstate[p->sl].c = spacing; + p->textparams_done = pdc_false; +} + +/* word spacing for justified lines */ +void +pdf_set_word_spacing(PDF *p, float spacing) +{ + spacing *= p->ydirection; + if (PDF_GET_STATE(p) == pdf_state_document) + { + p->tstate[p->sl].w = spacing; + return; + } + + /* + * We take care of spacing values != 0 in the text output functions, + * but must explicitly reset here. + */ + if (spacing == (float) 0) { + pdf_begin_text(p); + pdc_printf(p->out, "%f Tw\n", spacing); + } + + p->tstate[p->sl].w = spacing; + p->textparams_done = pdc_false; +} + +void +pdf_set_horiz_scaling(PDF *p, float scale) +{ + if (scale == (float) 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "horizscaling", pdc_errprintf(p->pdc, "%f", scale), 0, 0); + + scale *= p->ydirection; + if (PDF_GET_STATE(p) == pdf_state_document) + { + p->tstate[p->sl].h = scale / (float) 100.0; + return; + } + + if (scale == 100 * p->tstate[p->sl].h && !PDF_FORCE_OUTPUT()) + return; + + pdf_begin_text(p); + pdc_printf(p->out, "%f Tz\n", scale); + + p->tstate[p->sl].h = scale / (float) 100.0; +} + +float +pdf_get_horiz_scaling(PDF *p) +{ + return (float) (p->ydirection * p->tstate[p->sl].h * 100); +} + +void +pdf_set_leading(PDF *p, float l) +{ + l *= p->ydirection; + if (l == p->tstate[p->sl].l && !PDF_FORCE_OUTPUT()) + return; + + p->tstate[p->sl].l = l; + p->textparams_done = pdc_false; +} + +void +pdf_set_text_rendering(PDF *p, int mode) +{ + if (mode < 0 || mode > PDF_LAST_TRMODE) + pdc_error(p->pdc, PDC_E_ILLARG_INT, + "textrendering", pdc_errprintf(p->pdc, "%d", mode), 0, 0); + + if (mode == p->tstate[p->sl].mode && !PDF_FORCE_OUTPUT()) + return; + + pdf_begin_text(p); + pdc_printf(p->out, "%d Tr\n", mode); + + p->tstate[p->sl].mode = mode; +} + +void +pdf_set_text_rise(PDF *p, float rise) +{ + rise *= p->ydirection; + if (PDF_GET_STATE(p) == pdf_state_document) + { + p->tstate[p->sl].rise = rise; + return; + } + + if (rise == p->tstate[p->sl].rise && !PDF_FORCE_OUTPUT()) + return; + + pdf_begin_text(p); + pdc_printf(p->out, "%f Ts\n", rise); + + p->tstate[p->sl].rise = rise; +} + +/* Text positioning operators */ + +PDFLIB_API void PDFLIB_CALL +PDF_set_text_matrix(PDF *p, + float a, float b, float c, float d, float e, float f) +{ + static const char fn[] = "PDF_set_text_matrix"; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_content | pdf_state_document), + "(p[%p], %g, %g, %g, %g, %g, %g)\n", (void *) p, a, b, c, d, e, f)) + { + return; + } + + p->tstate[p->sl].m.a = a; + p->tstate[p->sl].m.b = b; + p->tstate[p->sl].m.c = c; + p->tstate[p->sl].m.d = d; + p->tstate[p->sl].m.e = e; + p->tstate[p->sl].m.f = f; + + if (PDF_GET_STATE(p) != pdf_state_document) + { + pdf_begin_text(p); + pdf_put_textmatrix(p); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_set_text_pos(PDF *p, float x, float y) +{ + static const char fn[] = "PDF_set_text_pos"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %g, %g)\n", + (void *) p, x, y)) + return; + + p->tstate[p->sl].m.e = x; + p->tstate[p->sl].m.f = y; + + p->tstate[p->sl].lm.e = x; + p->tstate[p->sl].lm.f = y; + + pdf_begin_text(p); + pdf_put_textmatrix(p); +} + +/* String width calculations */ + +static float +pdf_str_width(PDF *p, pdc_byte *text, int len, int charlen, + int font, float fontsize) +{ + int i; + pdc_font *currfont = &p->fonts[font]; + pdc_ushort uv; + pdc_ushort *ustext = (pdc_ushort *) text; + float chwidth = (float) 0.0, width = (float) 0.0; + pdc_bool haswidths = (currfont->widths != NULL); + + /* We cannot handle empty strings and fonts with unknown + * code size - especially CID fonts with no UCS-2 CMap */ + if (!len || !currfont->codeSize) + return width; + + for (i = 0; i < len/charlen; i++) + { + if (charlen == 1) + uv = (pdc_ushort) text[i]; + else + uv = ustext[i]; + + /* take word spacing parameter into account at each blank */ + if (currfont->codeSize == 1 && uv == (pdc_ushort) PDF_SPACE) + width += p->tstate[p->sl].w; + + /* start by adding in the width of the character */ + if (currfont->monospace) + { + chwidth = (float) currfont->monospace; + } + else if (haswidths) + { + chwidth = (float) currfont->widths[uv]; + } + width += fontsize * chwidth / ((float) 1000); + + + /* now add the character spacing parameter */ + width += p->tstate[p->sl].c; + } + + /* take current text matrix and horizontal scaling factor into account */ + width = width * p->tstate[p->sl].m.a * p->tstate[p->sl].h; + + return width; +} + +/* Convert and check input text string. + * The function returns a pointer to an allocated buffer + * containing the converted string. + * The caller is responsible for freeing this buffer. + * If return value is NULL error was occurred. + */ +static pdc_byte * +pdf_check_textstring(PDF *p, const char *text, int len, int font, + pdc_bool textflow, pdc_bool calcwidth, + int *outlen, int *outcharlen) +{ + pdc_font *currfont = &p->fonts[font]; + pdc_byte *outtext; + pdc_text_format textformat, targettextformt; + int maxlen, charlen = 1; + int codesize = abs(currfont->codeSize); + + (void) textflow; + + /* Convert to 8-bit or UTF-16 text string */ + textformat = p->textformat; + if (textformat == pdc_auto && codesize <= 1) + textformat = pdc_bytes; + else if (textformat == pdc_auto2 && codesize <= 1) + textformat = pdc_bytes2; + targettextformt = pdc_utf16; + pdc_convert_string(p->pdc, textformat, NULL, (pdc_byte *)text, len, + &targettextformt, NULL, &outtext, outlen, + PDC_CONV_NOBOM | PDC_CONV_KEEPBYTES, pdc_true); + textformat = targettextformt; + + if (outtext && *outlen) + { + /* 2 byte storage length of a character */ + if (textformat == pdc_utf16) + { + if (codesize <= 1 && currfont->encoding == pdc_builtin) + pdc_error(p->pdc, PDF_E_FONT_BADTEXTFORM, 0, 0, 0, 0); + charlen = 2; + } + + /* Maximal text string length - found out emprirically! */ + maxlen = (codesize == 1) ? PDF_MAXARRAYSIZE : PDF_MAXDICTSIZE; + if (!calcwidth && *outlen > maxlen) + { + pdc_warning(p->pdc, PDF_E_TEXT_TOOLONG, + pdc_errprintf(p->pdc, "%d", maxlen), 0, 0, 0); + *outlen = maxlen; + } + + } + *outcharlen = charlen; + + return outtext; +} + +float +pdf__stringwidth(PDF *p, const char *text, int len, int font, float fontsize) +{ + pdc_byte *utext; + int charlen; + float result = (float) 0.0; + + if (text && len == 0) + len = (int) strlen(text); + if (text == NULL || len <= 0) + return result; + + pdf_check_handle(p, font, pdc_fonthandle); + + if (fontsize == (float) 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, "fontsize", "0", 0, 0); + + /* convert text string */ + fontsize *= p->ydirection; + utext = pdf_check_textstring(p, text, len, font, pdc_false, pdc_true, + &len, &charlen); + if (utext) + { + p->currtext = utext; + result = pdf_str_width(p, utext, len, charlen, font, fontsize); + p->currtext = NULL; + pdc_free(p->pdc, utext); + } + return result; +} + +PDFLIB_API float PDFLIB_CALL +PDF_stringwidth(PDF *p, const char *text, int font, float fontsize) +{ + static const char fn[] = "PDF_stringwidth"; + float result = (float) 0.0; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_content | pdf_state_path), + "(p[%p], \"%s\", %d, %g)", + (void *) p, pdc_strprint(p->pdc, text, 0), font, fontsize)) + { + int len = text ? (int) strlen(text) : 0; + PDF_INPUT_HANDLE(p, font) + result = pdf__stringwidth(p, text, len, font, fontsize); + } + pdc_trace(p->pdc, "[%g]\n", result); + return result; +} + +PDFLIB_API float PDFLIB_CALL +PDF_stringwidth2(PDF *p, const char *text, int len, int font, float fontsize) +{ + static const char fn[] = "PDF_stringwidth2"; + float result = (float) 0.0; + + if (pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_content | pdf_state_path), + "(p[%p], \"%s\", %d, %d, %g)", + (void *) p, pdc_strprint(p->pdc, text, len), len, font, fontsize)) + { + PDF_INPUT_HANDLE(p, font) + result = pdf__stringwidth(p, text, len, font, fontsize); + } + pdc_trace(p->pdc, "[%g]\n", result); + return result; +} + + +/* ------------------------ Text control functions ------------------------ */ + +static void +pdf_underline(PDF *p, float x, float y, float length) +{ + float delta_y, xscale, yscale; + double linewidth; + pdf_tstate *ts; + + ts = &p->tstate[p->sl]; + + xscale = (float) fabs((double) ts->m.a); + yscale = (float) fabs((double) ts->m.d); + + linewidth = fabs(ts->fs * p->fonts[ts->f].underlineThickness / 1000.0 * + ts->h * (xscale > yscale ? xscale : yscale)); + + delta_y = (ts->fs * p->fonts[ts->f].underlinePosition / 1000 + ts->rise) * + (float) fabs((double) ts->h) * (xscale > yscale ? xscale : yscale); + + pdf__save(p); + + pdf__setlinewidth(p, (float) linewidth); + pdf__setlinecap(p, 0); + pdf__setdash(p, 0, 0); + pdf__moveto(p, x, y + delta_y); + pdf__lineto(p, x + length, y + delta_y); + pdf__stroke(p); + + pdf__restore(p); +} + +static void +pdf_overline(PDF *p, float x, float y, float length) +{ + float delta_y, xscale, yscale, lineheight; + double linewidth; + pdf_tstate *ts; + + ts = &p->tstate[p->sl]; + + xscale = (float) fabs((double) ts->m.a); + yscale = (float) fabs((double) ts->m.d); + + linewidth = fabs(ts->fs * p->fonts[ts->f].underlineThickness / 1000.0 * + ts->h * (xscale > yscale ? xscale : yscale)); + + lineheight = ((float) p->fonts[ts->f].ascender/1000) * ts->fs; + + delta_y = (ts->fs * p->fonts[ts->f].underlinePosition / 1000 - ts->rise) * + (float) fabs((double) ts->h) * (xscale > yscale ? xscale : yscale); + + pdf__save(p); + + pdf__setlinewidth(p, (float)linewidth); + pdf__setlinecap(p, 0); + pdf__setdash(p, 0, 0); + pdf__moveto(p, x, y + lineheight - delta_y); + pdf__lineto(p, x + length, y + lineheight - delta_y); + pdf__stroke(p); + + pdf__restore(p); +} + +static void +pdf_strikeout(PDF *p, float x, float y, float length) +{ + float delta_y, xscale, yscale, lineheight; + double linewidth; + pdf_tstate *ts; + + ts = &p->tstate[p->sl]; + + xscale = (float) fabs((double) ts->m.a); + yscale = (float) fabs((double) ts->m.d); + + linewidth = fabs(ts->fs * p->fonts[ts->f].underlineThickness / 1000.0 * + ts->h * (xscale > yscale ? xscale : yscale)); + + lineheight = ((float) p->fonts[ts->f].ascender/1000) * ts->fs; + + delta_y = (ts->fs * p->fonts[ts->f].underlinePosition / 1000 + ts->rise) * + (float) fabs((double) ts->h) * (xscale > yscale ? xscale : yscale); + pdf__save(p); + + pdf__setlinewidth(p, (float)linewidth); + pdf__setlinecap(p, 0); + pdf__setdash(p, 0, 0); + pdf__moveto(p, x, y + lineheight/2 + delta_y); + pdf__lineto(p, x + length, y + lineheight/2 + delta_y); + pdf__stroke(p); + + pdf__restore(p); +} + +/* ------------------------ font operator ------------------------ */ + +void +pdf__setfont(PDF *p, int font, float fontsize) +{ + /* make font the current font */ + p->fonts[font].used_on_current_page = pdc_true; + p->tstate[p->sl].fs = p->ydirection * fontsize; + p->tstate[p->sl].f = font; + + pdf_begin_text(p); + pdc_printf(p->out, "/F%d %f Tf\n", font, p->tstate[p->sl].fs); + pdf_set_leading(p, fontsize); +} + +PDFLIB_API void PDFLIB_CALL +PDF_setfont(PDF *p, int font, float fontsize) +{ + static const char fn[] = "PDF_setfont"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %d, %g)\n", + (void *) p, font, fontsize)) + return; + + /* Check parameters */ + PDF_INPUT_HANDLE(p, font) + pdf_check_handle(p, font, pdc_fonthandle); + + if (fontsize == (float) 0.0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, "fontsize", "0", 0, 0); + + pdf__setfont(p, font, fontsize); +} + +float +pdf_get_fontsize(PDF *p) +{ + if (p->fonts_number == 0 || p->tstate[p->sl].f == -1) /* no font set */ + pdc_error(p->pdc, PDF_E_TEXT_NOFONT_PAR, "fontsize", 0, 0, 0); + + + return p->ydirection * p->tstate[p->sl].fs; +} + +/* ------------------------ Text rendering operators ------------------------ */ + + +void +pdf_put_textstring(PDF *p, pdc_byte *text, int len, int charlen) +{ + (void) charlen; + + pdc_put_pdfstring(p->out, (const char *) text, len); +} + + +static void +pdf_output_text(PDF *p, pdc_byte *text, int len, int charlen) +{ + { + pdf_put_textstring(p, text, len, charlen); + pdc_puts(p->out, "Tj\n"); + } +} + +#define PDF_RENDERMODE_FILLCLIP 4 + +static void +pdf_place_text(PDF *p, pdc_byte *utext, int len, int charlen, + float x, float y, float width, pdc_bool cont) +{ + pdf_tstate *ts = &p->tstate[p->sl]; + + if (width) + { + if (p->underline) + pdf_underline(p, x, y, width); + if (p->overline) + pdf_overline(p, x, y, width); + if (p->strikeout) + pdf_strikeout(p, x, y, width); + } + + pdf_begin_text(p); + if (ts->potm) + pdf_put_textmatrix(p); + + /* set leading, word, and character spacing if required */ + if (!p->textparams_done) + { + pdc_printf(p->out, "%f TL\n", ts->l); + + if (ts->w != (float) 0) + pdc_printf(p->out,"%f Tw\n", ts->w); + + if (ts->c != (float) 0) + pdc_printf(p->out,"%f Tc\n", ts->c); + + p->textparams_done = pdc_true; + } + + /* text output */ + if (!cont) + { + pdf_output_text(p, utext, len, charlen); + } + else + { + { + pdf_put_textstring(p, utext, len, charlen); + pdc_puts(p->out, "'\n"); + } + } + + if (ts->mode >= PDF_RENDERMODE_FILLCLIP) + pdf_end_text(p); + + ts->m.e += width; + if (cont) ts->m.f -= ts->l; +} + +void +pdf_show_text( + PDF *p, + const char *text, + int len, + const float *x_p, + const float *y_p, + pdc_bool cont) +{ + static const char *fn = "pdf_show_text"; + pdf_tstate *ts = &p->tstate[p->sl]; + pdc_byte *utext = NULL; + int charlen = 1; + float x, y, width; + + if (x_p != NULL) + { + x = *x_p; + y = *y_p; + ts->m.e = x; + ts->m.f = y; + ts->lm.e = x; + ts->lm.f = y; + ts->potm = pdc_true; + } + else if (cont) + { + ts->m.e = ts->lm.e; + x = ts->m.e; + y = ts->m.f - ts->l; + + /* we must output line begin if necessary */ + if (fabs((double) (ts->me - ts->lm.e)) > PDC_FLOAT_PREC) + ts->potm = pdc_true; + } + else + { + x = ts->m.e; + y = ts->m.f; + } + + if (text && len == 0) + len = (int) strlen(text); + if (text == NULL || len <= 0) + { + if (cont) + len = 0; + else + return; + } + + /* no font set */ + if (ts->f == -1) + pdc_error(p->pdc, PDF_E_TEXT_NOFONT, 0, 0, 0, 0); + + width = 0; + if (len) + { + /* convert text string */ + utext = pdf_check_textstring(p, text, len, ts->f, pdc_false, pdc_false, + &len, &charlen); + if (!utext) + return; + + p->currtext = utext; + + /* length of text */ + width = pdf_str_width(p, utext, len, charlen, ts->f, ts->fs); + } + else + { + utext = (pdc_byte *) pdc_calloc(p->pdc, 2, fn); + p->currtext = utext; + } + + /* place text */ + pdf_place_text(p, utext, len, charlen, x, y, width, cont); + + p->currtext = NULL; + if (utext) + pdc_free(p->pdc, utext); +} + +PDFLIB_API void PDFLIB_CALL +PDF_show(PDF *p, const char *text) +{ + static const char fn[] = "PDF_show"; + if (pdf_enter_api(p, fn, pdf_state_content, "(p[%p], \"%s\")\n", + (void *) p, pdc_strprint(p->pdc, text, 0))) + { + int len = text ? (int) strlen(text) : 0; + pdf_show_text(p, text, len, NULL, NULL, pdc_false); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_show2(PDF *p, const char *text, int len) +{ + static const char fn[] = "PDF_show2"; + if (pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], \"%s\", %d)\n", + (void *) p, pdc_strprint(p->pdc, text, len), len)) + { + pdf_show_text(p, text, len, NULL, NULL, pdc_false); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_show_xy(PDF *p, const char *text, float x, float y) +{ + static const char fn[] = "PDF_show_xy"; + if (pdf_enter_api(p, fn, pdf_state_content, "(p[%p], \"%s\", %g, %g)\n", + (void *) p, pdc_strprint(p->pdc, text, 0), x, y)) + { + int len = text ? (int) strlen(text) : 0; + pdf_show_text(p, text, len, &x, &y, pdc_false); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_show_xy2(PDF *p, const char *text, int len, float x, float y) +{ + static const char fn[] = "PDF_show_xy2"; + if (pdf_enter_api(p, fn, pdf_state_content, "(p[%p], \"%s\", %d, %g, %g)\n", + (void *) p, pdc_strprint(p->pdc, text, len), len, x, y)) + { + pdf_show_text(p, text, len, &x, &y, pdc_false); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_continue_text(PDF *p, const char *text) +{ + static const char fn[] = "PDF_continue_text"; + if (pdf_enter_api(p, fn, pdf_state_content, "(p[%p], \"%s\")\n", + (void *) p, pdc_strprint(p->pdc, text, 0))) + { + int len = text ? (int) strlen(text) : 0; + pdf_show_text(p, text, len, NULL, NULL, pdc_true); + } +} + +PDFLIB_API void PDFLIB_CALL +PDF_continue_text2(PDF *p, const char *text, int len) +{ + static const char fn[] = "PDF_continue_text2"; + if (pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], \"%s\", %d)\n", + (void *) p, pdc_strprint(p->pdc, text, len), len)) + { + pdf_show_text(p, text, len, NULL, NULL, pdc_true); + } +} + + +/* ----------------------- Text fitting routines ------------------------ */ + +#define PDF_KERNING_FLAG PDC_OPT_UNSUPP + +/* definitions of fit text options */ +static const pdc_defopt pdf_fit_textline_options[] = +{ + {"font", pdc_fonthandle, PDC_OPT_NONE, 1, 1, + 0, 0, NULL}, + + {"fontsize", pdc_floatlist, PDC_OPT_REQUIRIF1 | PDC_OPT_NOZERO, 1, 1, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"textrendering", pdc_integerlist, PDC_OPT_NONE, 1, 1, + 0, PDF_LAST_TRMODE, NULL}, + + {"wordspacing", pdc_floatlist, PDC_OPT_NONE, 1, 1, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"charspacing", pdc_floatlist, PDC_OPT_NONE, 1, 1, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"horizscaling", pdc_floatlist, PDC_OPT_NOZERO, 1, 1, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"textrise", pdc_floatlist, PDC_OPT_NONE, 1, 1, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"underline", pdc_booleanlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, NULL}, + + {"overline", pdc_booleanlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, NULL}, + + {"strikeout", pdc_booleanlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, NULL}, + + {"kerning", pdc_booleanlist, PDF_KERNING_FLAG, 1, 1, + 0.0, 0.0, NULL}, + + {"textformat", pdc_keywordlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, pdf_textformat_keylist}, + + {"margin", pdc_floatlist, PDC_OPT_NONE, 1, 2, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"orientate", pdc_keywordlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, pdf_orientate_keylist}, + + {"boxsize", pdc_floatlist, PDC_OPT_NONE, 2, 2, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"rotate", pdc_floatlist, PDC_OPT_NONE, 1, 1, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"position", pdc_floatlist, PDC_OPT_NONE, 1, 2, + PDC_FLOAT_MIN, PDC_FLOAT_MAX, NULL}, + + {"fitmethod", pdc_keywordlist, PDC_OPT_NONE, 1, 1, + 0.0, 0.0, pdf_fitmethod_keylist}, + + {"distortionlimit", pdc_floatlist, PDC_OPT_NONE, 1, 1, + 0.0, 100.0, NULL}, + + PDC_OPT_TERMINATE +}; + +void +pdf__fit_textline(PDF *p, const char *text, int len, float x, float y, + const char *optlist) +{ + pdc_byte *utext = (pdc_byte *) ""; + pdc_resopt *results; + pdc_clientdata data; + pdc_text_format textformat_save = p->textformat; + pdc_bool underline_save = p->underline; + pdc_bool overline_save = p->overline; + pdc_bool strikeout_save = p->strikeout; + int charlen; + + int font; + float fontsize; + int textrendering, ntextrendering; + float textrise, wordspacing, charspacing, horizscaling; + int nfontsize, ntextrise, nwordspacing, ncharspacing, nhorizscaling; + float margin[2], boxsize[2], position[2], angle, distortionlimit; + pdc_fitmethod method; + int inum, orientangle, indangle; + + if (text && len == 0) + len = (int) strlen(text); + if (text == NULL || len <= 0) + return; + + /* defaults */ + font = p->tstate[p->sl].f; + fontsize = p->tstate[p->sl].fs; + orientangle = 0; + margin[0] = margin[1] = (float) 0.0; + boxsize[0] = boxsize[1] = (float) 0.0; + position[0] = position[1] = (float) 0.0; + angle = (float) 0.0; + method = pdc_nofit; + distortionlimit = (float) 75.0; + + /* parsing optlist */ + data.compatibility = p->compatibility; + data.maxfont = p->fonts_number - 1; + data.hastobepos = p->hastobepos; + results = pdc_parse_optionlist(p->pdc, optlist, pdf_fit_textline_options, + &data, pdc_true); + + /* save options */ + pdc_get_optvalues(p->pdc, "font", results, &font, NULL); + + nfontsize = pdc_get_optvalues(p->pdc, "fontsize", results, + &fontsize, NULL); + + ntextrendering = pdc_get_optvalues(p->pdc, "textrendering", results, + &textrendering, NULL); + + nwordspacing = pdc_get_optvalues(p->pdc, "wordspacing", results, + &wordspacing, NULL); + + ncharspacing = pdc_get_optvalues(p->pdc, "charspacing", results, + &charspacing, NULL); + + nhorizscaling = pdc_get_optvalues(p->pdc, "horizscaling", results, + &horizscaling, NULL); + + ntextrise = pdc_get_optvalues(p->pdc, "textrise", results, + &textrise, NULL); + + pdc_get_optvalues(p->pdc, "underline", results, &p->underline, NULL); + + pdc_get_optvalues(p->pdc, "overline", results, &p->overline, NULL); + + pdc_get_optvalues(p->pdc, "strikeout", results, &p->strikeout, NULL); + + + if (pdc_get_optvalues(p->pdc, "textformat", results, &inum, NULL)) + p->textformat = (pdc_text_format) inum; + + if (1 == pdc_get_optvalues(p->pdc, "margin", results, margin, NULL)) + margin[1] = margin[0]; + + pdc_get_optvalues(p->pdc, "orientate", results, &orientangle, NULL); + + pdc_get_optvalues(p->pdc, "boxsize", results, boxsize, NULL); + + pdc_get_optvalues(p->pdc, "rotate", results, &angle, NULL); + + pdc_get_optvalues(p->pdc, "distortionlimit", results, + &distortionlimit, NULL); + + if (1 == pdc_get_optvalues(p->pdc, "position", results, position, NULL)) + position[1] = position[0]; + + if (pdc_get_optvalues(p->pdc, "fitmethod", results, &inum, NULL)) + method = (pdc_fitmethod) inum; + + pdc_cleanup_optionlist(p->pdc, results); + + /* save graphic state */ + pdf__save(p); + + while (1) + { + pdf_tstate *ts = &p->tstate[p->sl]; + pdc_matrix m; + pdc_vector elemsize, elemscale, elemmargin, relpos, polyline[5]; + pdc_box fitbox, elembox; + pdc_scalar ss, minfscale; + float width, height, tx = 0, ty = 0; + + /* font size */ + if (nfontsize) + { + pdf__setfont(p, font, fontsize); + fontsize = p->tstate[p->sl].fs; + } + + /* no font set */ + if (p->tstate[p->sl].f == -1) + pdc_error(p->pdc, PDF_E_TEXT_NOFONT, 0, 0, 0, 0); + + /* convert text string */ + utext = pdf_check_textstring(p, text, len, font, pdc_false, pdc_false, + &len, &charlen); + if (utext == NULL || len == 0) + break; + p->currtext = utext; + + /* text rendering */ + if (ntextrendering) + pdf_set_text_rendering(p, textrendering); + + /* options for text width and height */ + if (nwordspacing) + pdf_set_word_spacing(p, wordspacing); + if (ncharspacing) + pdf_set_char_spacing(p, charspacing); + if (nhorizscaling) + pdf_set_horiz_scaling(p, horizscaling); + if (ntextrise) + pdf_set_text_rise(p, textrise); + + /* minimal horizontal scaling factor */ + minfscale = distortionlimit / 100.0; + + /* text width */ + width = pdf_str_width(p, utext, len, charlen, font, fontsize); + if (width < PDF_SMALLREAL) + break; + elemmargin.x = margin[0]; + elemsize.x = width + 2 * elemmargin.x; + + /* text height */ + height = (float) fabs((p->fonts[ts->f].capHeight / 1000.0f) * ts->fs); + elemmargin.y = margin[1]; + elemsize.y = height + 2 * elemmargin.y; + + /* orientation */ + indangle = orientangle / 90; + if (indangle % 2) + { + ss = elemsize.x; + elemsize.x = elemsize.y; + elemsize.y = ss; + } + + /* box for fitting */ + fitbox.ll.x = 0; + fitbox.ll.y = 0; + fitbox.ur.x = boxsize[0]; + fitbox.ur.y = boxsize[1]; + + /* relative position */ + relpos.x = position[0] / 100.0; + relpos.y = position[1] / 100.0; + + /* calculate image box */ + pdc_place_element(method, minfscale, &fitbox, &relpos, + &elemsize, &elembox, &elemscale); + + /* reference point */ + pdc_translation_matrix(x, y, &m); + pdf_concat_raw(p, &m); + + /* clipping */ + if (method == pdc_clip || method == pdc_slice) + { + pdf__rect(p, 0, 0, boxsize[0], boxsize[1]); + pdf__clip(p); + } + + /* optional rotation */ + if (fabs((double)(angle)) > PDC_FLOAT_PREC) + { + pdc_rotation_matrix(p->ydirection * angle, &m); + pdf_concat_raw(p, &m); + } + + /* translation of element box */ + elembox.ll.y *= p->ydirection; + elembox.ur.y *= p->ydirection; + pdc_box2polyline(&elembox, polyline); + tx = (float) polyline[indangle].x; + ty = (float) polyline[indangle].y; + pdc_translation_matrix(tx, ty, &m); + pdf_concat_raw(p, &m); + + /* orientation of text */ + if (orientangle != 0) + { + pdc_rotation_matrix(p->ydirection * orientangle, &m); + pdf_concat_raw(p, &m); + if (indangle % 2) + { + ss = elemscale.x; + elemscale.x = elemscale.y; + elemscale.y = ss; + } + } + + if (elemscale.x != 1 || elemscale.y != 1) + { + pdc_scale_matrix((float) elemscale.x, (float) elemscale.y, &m); + pdf_concat_raw(p, &m); + } + + /* place text */ + x = (float) elemmargin.x; + y = (float) elemmargin.y; + p->tstate[p->sl].m.e = x; + p->tstate[p->sl].m.f = y; + p->tstate[p->sl].lm.e = x; + p->tstate[p->sl].lm.f = y; + p->tstate[p->sl].potm = pdc_true; + pdf_place_text(p, utext, len, charlen, x, y, width, pdc_false); + + break; + } + + /* restore graphic state */ + pdf__restore(p); + p->underline = underline_save; + p->overline = overline_save; + p->strikeout = strikeout_save; + p->textformat = textformat_save; + p->currtext = NULL; + if (utext) + pdc_free(p->pdc, utext); +} + +PDFLIB_API void PDFLIB_CALL +PDF_fit_textline(PDF *p, const char *text, int len, float x, float y, + const char *optlist) +{ + static const char fn[] = "PDF_fit_textline"; + + if (pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], \"%s\", %d, %g, %g, \"%s\")\n", + (void *) p, pdc_strprint(p->pdc, text, len), len, x, y, optlist)) + { + pdf__fit_textline(p, text, len, x, y, optlist); + } +} + +/* ----------------------- Text formatting routines ------------------------ */ + +/* text alignment modes */ +typedef enum { pdf_align_left, pdf_align_right, pdf_align_center, + pdf_align_justify, pdf_align_fulljustify +} pdf_alignment; + +/* this helper function returns the width of the null-terminated string +** 'text' for the current font and size EXCLUDING the last character's +** additional charspacing. +*/ +static float +pdf_swidth(PDF *p, const char *text) +{ + pdf_tstate *ts = &p->tstate[p->sl]; + + return pdf_str_width(p, (pdc_byte *)text, (int) strlen(text), 1, + ts->f, ts->fs) - ts->c * ts->m.a * ts->h; +} + +static void +pdf_show_aligned(PDF *p, const char *text, float x, float y, pdf_alignment mode) +{ + if (!text) + return; + + switch (mode) { + case pdf_align_left: + case pdf_align_justify: + case pdf_align_fulljustify: + /* nothing extra here... */ + break; + + case pdf_align_right: + x -= pdf_swidth(p, text); + break; + + case pdf_align_center: + x -= pdf_swidth(p, text) / 2; + break; + } + + pdf_show_text(p, text, (int) strlen(text), &x, &y, pdc_false); +} + +static int +pdf__show_boxed( + PDF *p, + const char *text, + int totallen, + float left, + float bottom, + float width, + float height, + const char *hmode, + const char *feature) +{ + float textwidth, old_word_spacing, curx, cury; + pdc_bool prematureexit; /* return because box is too small */ + int curTextPos; /* character currently processed */ + int lastdone; /* last input character processed */ + int toconv = totallen; + pdf_tstate *ts = &p->tstate[p->sl]; + pdc_byte *utext = NULL; + pdc_text_format textformat = p->textformat; + pdf_alignment mode = pdf_align_left; + pdc_bool blind = pdc_false; + + if (hmode == NULL || *hmode == '\0') + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "hmode", 0, 0, 0); + + if (!strcmp(hmode, "left")) + mode = pdf_align_left; + else if (!strcmp(hmode, "right")) + mode = pdf_align_right; + else if (!strcmp(hmode, "center")) + mode = pdf_align_center; + else if (!strcmp(hmode, "justify")) + mode = pdf_align_justify; + else if (!strcmp(hmode, "fulljustify")) + mode = pdf_align_fulljustify; + else + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "hmode", hmode, 0, 0); + + if (feature != NULL && *feature != '\0') + { + if (!strcmp(feature, "blind")) + blind = pdc_true; + else + pdc_error(p->pdc, PDC_E_ILLARG_STRING, "feature", feature, 0, 0); + } + + /* no font set */ + if (ts->f == -1) + pdc_error(p->pdc, PDF_E_TEXT_NOFONT, 0, 0, 0, 0); + + if (width == 0 && height != 0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "width", pdc_errprintf(p->pdc, "%f", width), 0, 0); + + if (width != 0 && height == 0) + pdc_error(p->pdc, PDC_E_ILLARG_FLOAT, + "height", pdc_errprintf(p->pdc, "%f", height), 0, 0); + + /* we cannot handle several encodings */ + if (p->fonts[ts->f].encoding == pdc_unicode) + { + pdc_error(p->pdc, PDF_E_DOC_FUNCUNSUPP, "Unicode", 0, 0, 0); + } + + if (p->fonts[ts->f].encoding == pdc_glyphid) + { + pdc_error(p->pdc, PDF_E_DOC_FUNCUNSUPP, "glyphid", 0, 0, 0); + } + + if (p->fonts[ts->f].encoding == pdc_cid) + { + pdc_error(p->pdc, PDF_E_DOC_FUNCUNSUPP, "CID", 0, 0, 0); + } + + if (p->fonts[ts->f].encoding == pdc_ebcdic) + { + pdc_error(p->pdc, PDF_E_DOC_FUNCUNSUPP, "EBCDIC", 0, 0, 0); + } + + /* convert text string */ + if (toconv) + { + int charlen; + utext = pdf_check_textstring(p, text, totallen, ts->f, pdc_true, + pdc_true, &totallen, &charlen); + if (!utext) + return 0; + + utext[totallen] = 0; + text = (const char *) utext; + p->textformat = pdc_bytes; + } + + /* text length */ + if (!totallen) + totallen = (int) strlen(text); + + /* special case for a single aligned line */ + if (width == 0 && height == 0) + { + if (!blind) + pdf_show_aligned(p, text, left, bottom, mode); + + if (toconv) + { + pdc_free(p->pdc, utext); + p->textformat = textformat; + } + return 0; + } + + old_word_spacing = ts->w; + + curx = left; + cury = bottom + p->ydirection * height; + prematureexit = pdc_false; + curTextPos = 0; + lastdone = 0; + + /* switch curx for right and center justification */ + if (mode == pdf_align_right) + curx += width; + else if (mode == pdf_align_center) + curx += (width / 2); + +#define MAX_CHARS_IN_LINE 2048 + + /* loop until all characters processed, or box full */ + + while ((curTextPos < totallen) && !prematureexit) { + /* buffer for constructing the line */ + char linebuf[MAX_CHARS_IN_LINE]; + int curCharsInLine = 0; /* # of chars in constructed line */ + int lastWordBreak = 0; /* the last seen space char */ + int wordBreakCount = 0; /* # of blanks in this line */ + + /* loop over the input string */ + while (curTextPos < totallen) { + if (curCharsInLine >= MAX_CHARS_IN_LINE) + pdc_error(p->pdc, PDC_E_ILLARG_TOOLONG, "(text line)", + pdc_errprintf(p->pdc, "%d", MAX_CHARS_IN_LINE-1), 0, 0); + + /* abandon DOS line-ends */ + if (text[curTextPos] == PDF_RETURN && + text[curTextPos+1] == PDF_NEWLINE) + curTextPos++; + + /* if it's a forced line break draw the line */ + if (text[curTextPos] == PDF_NEWLINE || + text[curTextPos] == PDF_RETURN) { + + cury -= ts->l; /* adjust cury by leading */ + + if (p->ydirection * (cury - bottom) < 0) { + prematureexit = pdc_true; /* box full */ + break; + } + + linebuf[curCharsInLine] = 0; /* terminate the line */ + + /* check whether the line is too long */ + ts->w = (float) 0.0; + textwidth = pdf_swidth(p, linebuf); + + /* the forced break occurs too late for this line */ + if (textwidth > width) { + if (wordBreakCount == 0) { /* no blank found */ + prematureexit = pdc_true; + break; + } + linebuf[lastWordBreak] = 0; /* terminate at last blank */ + if (curTextPos > 0 && text[curTextPos-1] == PDF_RETURN) + --curTextPos; + curTextPos -= (curCharsInLine - lastWordBreak); + + if (!blind) { + textwidth = pdf_swidth(p, linebuf); + if (wordBreakCount != 1 && + (mode == pdf_align_justify || + mode == pdf_align_fulljustify)) { + pdf_set_word_spacing(p, + p->ydirection * (width - textwidth) / + ((wordBreakCount - 1) * ts->h * ts->m.a)); + } + else + pdf_set_word_spacing(p, (float) 0.0); + pdf_show_aligned(p, linebuf, curx, cury, mode); + } + + } else if (!blind) { + + if (mode == pdf_align_fulljustify && wordBreakCount > 0) { + pdf_set_word_spacing(p, + p->ydirection * (width - textwidth) / + (wordBreakCount * ts->h * ts->m.a)); + } else { + pdf_set_word_spacing(p, (float) 0.0); + } + + pdf_show_aligned(p, linebuf, curx, cury, mode); + } + + lastdone = curTextPos; + curCharsInLine = lastWordBreak = wordBreakCount = 0; + curTextPos++; + + } else if (text[curTextPos] == PDF_SPACE) { + linebuf[curCharsInLine] = 0; /* terminate the line */ + ts->w = (float) 0.0; + + /* line too long ==> break at last blank */ + if (pdf_swidth(p, linebuf) > width) { + cury -= ts->l; /* adjust cury by leading */ + + if (p->ydirection * (cury - bottom) < 0) { + prematureexit = pdc_true; /* box full */ + break; + } + + linebuf[lastWordBreak] = 0; /* terminate at last blank */ + curTextPos -= (curCharsInLine - lastWordBreak - 1); + + if (lastWordBreak == 0) + curTextPos--; + + /* LATER: * force break if wordBreakCount == 1, + * i.e., no blank + */ + if (wordBreakCount == 0) { + prematureexit = pdc_true; + break; + } + + /* adjust word spacing for full justify */ + if (wordBreakCount != 1 && (mode == pdf_align_justify || + mode == pdf_align_fulljustify)) { + ts->w = (float) 0.0; + textwidth = pdf_swidth(p, linebuf); + if (!blind) { + pdf_set_word_spacing(p, + p->ydirection * (width - textwidth) / + ((wordBreakCount - 1) * ts->h * ts->m.a)); + } + } + else if (!blind) { + pdf_set_word_spacing(p, (float) 0.0); + } + + + lastdone = curTextPos; + if (!blind) + pdf_show_aligned(p, linebuf, curx, cury, mode); + curCharsInLine = lastWordBreak = wordBreakCount = 0; + + } else { + /* blank found, and line still fits */ + wordBreakCount++; + lastWordBreak = curCharsInLine; + linebuf[curCharsInLine++] = text[curTextPos++]; + } + + } else { + /* regular character ==> store in buffer */ + linebuf[curCharsInLine++] = text[curTextPos++]; + } + } + + if (prematureexit) { + break; /* box full */ + } + + /* if there is anything left in the buffer, draw it */ + if (curTextPos >= totallen && curCharsInLine != 0) { + cury -= ts->l; /* adjust cury for line height */ + + if (p->ydirection * (cury - bottom) < 0) { + prematureexit = pdc_true; /* box full */ + break; + } + + linebuf[curCharsInLine] = 0; /* terminate the line */ + + /* check if the last line is too long */ + ts->w = (float) 0.0; + textwidth = pdf_swidth(p, linebuf); + + if (textwidth > width) { + if (wordBreakCount == 0) + { + prematureexit = pdc_true; + break; + } + + linebuf[lastWordBreak] = 0; /* terminate at last blank */ + curTextPos -= (curCharsInLine - lastWordBreak - 1); + + /* recalculate the width */ + textwidth = pdf_swidth(p, linebuf); + + /* adjust word spacing for full justify */ + if (wordBreakCount != 1 && (mode == pdf_align_justify || + mode == pdf_align_fulljustify)) { + if (!blind) { + pdf_set_word_spacing(p, + p->ydirection * (width - textwidth) / + ((wordBreakCount - 1) * ts->h * ts->m.a)); + } + } + + } else if (!blind) { + + if (mode == pdf_align_fulljustify && wordBreakCount) { + pdf_set_word_spacing(p, + p->ydirection * (width - textwidth) / + (wordBreakCount * ts->h * ts->m.a)); + } else { + pdf_set_word_spacing(p, (float) 0.0); + } + } + + lastdone = curTextPos; + if (!blind) + pdf_show_aligned(p, linebuf, curx, cury, mode); + curCharsInLine = lastWordBreak = wordBreakCount = 0; + } + } + + if (!blind) + pdf_set_word_spacing(p, old_word_spacing); + + /* return number of remaining characters */ + + while (text[lastdone] == PDF_SPACE) + ++lastdone; + + if ((text[lastdone] == PDF_RETURN || + text[lastdone] == PDF_NEWLINE) && text[lastdone+1] == 0) + ++lastdone; + + if (toconv) + { + pdc_free(p->pdc, utext); + p->textformat = textformat; + } + + return (int) (totallen - lastdone); +} + +PDFLIB_API int PDFLIB_CALL +PDF_show_boxed( + PDF *p, + const char *text, + float left, + float bottom, + float width, + float height, + const char *hmode, + const char *feature) +{ + static const char fn[] = "PDF_show_boxed"; + int remchars; + + if (!pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], \"%s\", %g, %g, %g, %g, \"%s\", \"%s\")", + (void *) p, pdc_strprint(p->pdc, text, 0), + left, bottom, width, height, hmode, feature)) + { + return 0; + } + + if (text == NULL || *text == '\0') { + pdc_trace(p->pdc, "[%d]\n", 0); + return 0; + } + + remchars = pdf__show_boxed(p, text, 0, left, bottom, + width, height, hmode, feature); + + pdc_trace(p->pdc, "[%d]\n", remchars); + return remchars; +} + +PDFLIB_API int PDFLIB_CALL +PDF_show_boxed2( + PDF *p, + const char *text, + int len, + float left, + float bottom, + float width, + float height, + const char *hmode, + const char *feature) +{ + static const char fn[] = "PDF_show_boxed2"; + int remchars; + + if (!pdf_enter_api(p, fn, pdf_state_content, + "(p[%p], \"%s\", %d, %g, %g, %g, %g, \"%s\", \"%s\")", + (void *) p, pdc_strprint(p->pdc, text, len), len, + left, bottom, width, height, hmode, feature)) + { + return 0; + } + + if (text == NULL || len == 0) { + pdc_trace(p->pdc, "[%d]\n", 0); + return 0; + } + + remchars = pdf__show_boxed(p, text, len, left, bottom, + width, height, hmode, feature); + + pdc_trace(p->pdc, "[%d]\n", remchars); + return remchars; +} + diff --git a/src/libs/pdflib/libs/pdflib/p_tiff.c b/src/libs/pdflib/libs/pdflib/p_tiff.c new file mode 100644 index 0000000000..7d22574d6c --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_tiff.c @@ -0,0 +1,883 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_tiff.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * TIFF processing for PDFlib + * + */ + +#include "p_intern.h" +#include "p_image.h" + +#ifndef HAVE_LIBTIFF + +pdc_bool +pdf_is_TIFF_file(PDF *p, pdc_file *fp, pdf_tiff_info *tiff, pdc_false) +{ + (void) p; + (void) fp; + (void) tiff; + + return pdc_false; +} + +int +pdf_process_TIFF_data( + PDF *p, + int imageslot) +{ + (void) imageslot; + + pdc_warning(p->pdc, PDF_E_UNSUPP_IMAGE, "TIFF", 0, 0, 0); + return -1; +} + +#else + +#include "tiffiop.h" +static tsize_t +pdf_libtiff_read(void* fd, tdata_t buf, tsize_t size) +{ + pdc_file *fp = (pdc_file *) fd; + + return ((tsize_t) pdc_fread(buf, 1, (size_t) size, fp)); +} + +static toff_t +pdf_libtiff_seek(void* fd, toff_t off, int whence) +{ + pdc_file *fp = (pdc_file *) fd; + + return ((toff_t) pdc_fseek(fp, (long) off, whence)); +} + +static int +pdf_libtiff_close(void* fd) +{ + (void) fd; + + /* pdc_fclose(fp); this happens in caller function */ + + return 0; +} + +static toff_t +pdf_libtiff_size(void* fd) +{ + pdc_file *fp = (pdc_file *) fd; + + return (toff_t) pdc_file_size(fp); +} + +static void * +pdf_libtiff_malloc(TIFF *t, tsize_t size) +{ + PDF *p = (PDF*) t->pdflib_opaque; + return pdc_malloc(p->pdc, (size_t)size, "libtiff"); +} + +static void * +pdf_libtiff_realloc(TIFF *t, tdata_t mem, tsize_t size) +{ + PDF *p = (PDF*) t->pdflib_opaque; + return(pdc_realloc(p->pdc, (void*)mem, (size_t)size, "libtiff")); +} + +static void +pdf_libtiff_free(TIFF *t, tdata_t mem) +{ + PDF *p = (PDF*) t->pdflib_opaque; + pdc_free(p->pdc, (void*)mem); +} + +static void +pdf_data_source_TIFF_init(PDF *p, PDF_data_source *src) +{ + pdf_image *image; + + image = (pdf_image *) src->private_data; + + if (image->strips == 1) + image->info.tiff.cur_line = 0; + + if (image->use_raw) { + /* malloc is done in the fill function */ + src->buffer_length = (size_t) 0; + src->buffer_start = (pdc_byte *) NULL; + } else { + src->buffer_length = (size_t) (image->components * image->width); + src->buffer_start = (pdc_byte *) + pdc_malloc(p->pdc, src->buffer_length, "pdf_data_source_TIFF_init"); + } +} + +static pdc_bool +pdf_data_source_TIFF_fill(PDF *p, PDF_data_source *src) +{ + pdf_image *image; + int col; + pdc_byte *dest; + uint16 fillorder; + uint32 *s, *bc; + + image = (pdf_image *) src->private_data; + + if (image->use_raw) { + if (image->info.tiff.cur_line == image->strips) + return pdc_false; + + TIFFGetField(image->info.tiff.tif, TIFFTAG_STRIPBYTECOUNTS, &bc); + + if (bc[image->info.tiff.cur_line] > src->buffer_length) { + src->buffer_length = bc[image->info.tiff.cur_line]; + src->buffer_start = (pdc_byte *) + pdc_realloc(p->pdc, src->buffer_start, + src->buffer_length, "pdf_data_source_TIFF_fill"); + } + + if (TIFFReadRawStrip(image->info.tiff.tif, + (tstrip_t) image->info.tiff.cur_line, + (tdata_t) src->buffer_start, + (tsize_t) bc[image->info.tiff.cur_line]) == -1) { + + pdc_free(p->pdc, (void *) src->buffer_start); + TIFFClose(image->info.tiff.tif); + image->fp = NULL; + pdc_error(p->pdc, PDF_E_IMAGE_CORRUPT, "TIFF", "?", 0, 0); + } + + src->next_byte = src->buffer_start; + src->bytes_available = bc[image->info.tiff.cur_line]; + + if (TIFFGetField(image->info.tiff.tif, TIFFTAG_FILLORDER, &fillorder) + && (fillorder == FILLORDER_LSB2MSB)) { + TIFFReverseBits((unsigned char *) src->buffer_start, + (unsigned long) src->bytes_available); + } + + if (image->strips > 1) { + /* only a single strip of a multi-strip image */ + image->info.tiff.cur_line = image->strips; + } else + image->info.tiff.cur_line++; + + } else { + if (image->info.tiff.cur_line++ == image->height) + return pdc_false; + + src->next_byte = src->buffer_start; + src->bytes_available = src->buffer_length; + + dest = src->buffer_start; + s = image->info.tiff.raster + + ((int)image->height - image->info.tiff.cur_line) * + (int) image->width; + + switch (image->components) { + case 1: + for (col = 0; col < image->width; col++, s++) { + *dest++ = (pdc_byte) TIFFGetR(*s); + } + break; + + case 3: + for (col = 0; col < image->width; col++, s++) { + *dest++ = (pdc_byte) TIFFGetR(*s); + *dest++ = (pdc_byte) TIFFGetG(*s); + *dest++ = (pdc_byte) TIFFGetB(*s); + } + break; + + case 4: + for (col = 0; col < image->width; col++, s++) { + unsigned char* t = (unsigned char*)&(*s); + *dest++ = (pdc_byte) t[0]; + *dest++ = (pdc_byte) t[1]; + *dest++ = (pdc_byte) t[2]; + *dest++ = (pdc_byte) t[3]; + } + break; + + default: + pdc_error(p->pdc, PDF_E_IMAGE_BADCOMP, + pdc_errprintf(p->pdc, "%d", image->components), + image->filename, 0, 0); + } + } + + return pdc_true; +} + +static void +pdf_data_source_TIFF_terminate(PDF *p, PDF_data_source *src) +{ + pdc_free(p->pdc, (void *) src->buffer_start); +} + +static int +pdf_check_colormap(int n, uint16* r, uint16* g, uint16* b) +{ + while (n-- > 0) + if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) + return(16); + return(8); +} + +pdc_bool +pdf_is_TIFF_file(PDF *p, pdc_file *fp, pdf_tiff_info *tiff_info, pdc_bool check) +{ + const char *filename; + + /* Suppress all warnings and error messages */ + (void) TIFFSetErrorHandler(NULL); + (void) TIFFSetWarningHandler(NULL); + + filename = pdc_file_name(fp); + tiff_info->tif = TIFFClientOpen(filename, "r", + (void *)fp, + pdf_libtiff_read, NULL, + pdf_libtiff_seek, pdf_libtiff_close, pdf_libtiff_size, + NULL, NULL, (void *)p, + pdf_libtiff_malloc, pdf_libtiff_realloc, pdf_libtiff_free, + NULL, NULL); + if (tiff_info->tif == NULL) { + pdc_fseek(fp, 0L, SEEK_SET); + return pdc_false; + } + if (check) + TIFFClose(tiff_info->tif); + return pdc_true; +} + +int +pdf_process_TIFF_data( + PDF *p, + int imageslot) +{ + static const char *fn = "pdf_process_TIFF_data"; + uint32 w, h; + uint16 unit, bpc, compression, photometric, inkset, extra, *sinfo; + uint16 planarconfig, predictor; + uint16 *rmap, *gmap, *bmap; + uint32 group3opts; + tsample_t components; + size_t npixels; + pdf_image *image; + float res_x, res_y; + pdf_colorspace cs; + int slot; + int strip; + int errint = 0; + int errcode = 0; + pdc_bool isopen = pdc_false; + + image = &p->images[imageslot]; + + if (pdf_is_TIFF_file(p, image->fp, &image->info.tiff, pdc_false) + == pdc_false) { + errcode = PDF_E_IMAGE_CORRUPT; + goto PDF_TIFF_ERROR; + } + image->info.tiff.tif->tif_fd = (FILE*)image->fp; + isopen = pdc_true; + + if (image->page != 1) { + if (TIFFSetDirectory(image->info.tiff.tif, (tdir_t) (image->page - 1)) + != 1) { + errint = image->page; + errcode = PDF_E_IMAGE_NOPAGE; + goto PDF_TIFF_ERROR; + } + } + + TIFFGetField(image->info.tiff.tif, TIFFTAG_COMPRESSION, &compression); + + if (compression == COMPRESSION_OJPEG || + compression == COMPRESSION_JPEG) { + /* can't handle these yet */ + errint = compression; + errcode = PDF_E_TIFF_UNSUPP_JPEG; + goto PDF_TIFF_ERROR; + } + + photometric = 255; /* dummy value */ + + if (TIFFGetField(image->info.tiff.tif, TIFFTAG_PHOTOMETRIC, &photometric) && + (photometric == PHOTOMETRIC_YCBCR || + photometric == PHOTOMETRIC_CIELAB || + photometric == PHOTOMETRIC_MASK)) { + /* can't handle these */ + errint = photometric; + errcode = PDF_E_TIFF_UNSUPP_CS; + goto PDF_TIFF_ERROR; + } + + TIFFGetField(image->info.tiff.tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(image->info.tiff.tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetFieldDefaulted(image->info.tiff.tif, TIFFTAG_BITSPERSAMPLE, &bpc); + TIFFGetFieldDefaulted(image->info.tiff.tif, TIFFTAG_SAMPLESPERPIXEL, + &components); + TIFFGetFieldDefaulted(image->info.tiff.tif, TIFFTAG_EXTRASAMPLES, + &extra, &sinfo); + TIFFGetFieldDefaulted(image->info.tiff.tif, TIFFTAG_PLANARCONFIG, + &planarconfig); + + if (bpc != 1 && bpc != 2 && bpc != 4 && bpc != 8) { + /* PDF doesn't support other values of the color depth */ + errint = bpc; + errcode = PDF_E_IMAGE_BADDEPTH; + goto PDF_TIFF_ERROR; + } + + image->width = (float) w; + image->height = (float) h; + image->components = components; + image->strips = 1; + image->bpc = bpc; + + /* fetch the resolution values if found in the file */ + if (TIFFGetField(image->info.tiff.tif, TIFFTAG_XRESOLUTION, &res_x) && + TIFFGetField(image->info.tiff.tif, TIFFTAG_YRESOLUTION, &res_y) && + TIFFGetFieldDefaulted(image->info.tiff.tif, TIFFTAG_RESOLUTIONUNIT, + &unit) && + res_x > 0 && res_y > 0) { + + if (unit == RESUNIT_INCH) { + image->dpi_x = res_x; + image->dpi_y = res_y; + + } else if (unit == RESUNIT_CENTIMETER) { + image->dpi_x = res_x * (float) 2.54; + image->dpi_y = res_y * (float) 2.54; + + } else if (unit == RESUNIT_NONE) { + image->dpi_x = -res_x; + image->dpi_y = -res_y; + } + } + + if (compression != COMPRESSION_LZW && p->debug['P']) + compression = (uint16) 0; /* dummy: disable pass-through mode */ + + /* find out whether we can use the compressed raw data directly */ + switch ((int) compression) { + case COMPRESSION_CCITTRLE: + case COMPRESSION_CCITTRLEW: + if (TIFFIsTiled(image->info.tiff.tif)) { + image->use_raw = pdc_false; + image->bpc = 8; + break; + } + + image->params = (char *) pdc_malloc(p->pdc, PDF_MAX_PARAMSTRING, + fn); + + strcpy(image->params, "/EndOfBlock false"); + strcat(image->params, "/EncodedByteAlign true"); + + if (photometric == PHOTOMETRIC_MINISBLACK) + strcat(image->params, "/BlackIs1 true"); + + image->strips = (int) TIFFNumberOfStrips(image->info.tiff.tif); + image->compression = ccitt; + image->bpc = 1; + image->use_raw = pdc_true; + break; + + case COMPRESSION_CCITTFAX3: + if (TIFFIsTiled(image->info.tiff.tif)) { + image->use_raw = pdc_false; + image->bpc = 8; + break; + } + + image->params = (char *) pdc_malloc(p->pdc, PDF_MAX_PARAMSTRING, + fn); + strcpy(image->params, ""); + + /* The following contains three code segments which are + * disabled. + * Apparently, and contrary to my reading of the specs, + * the following can not be deduced from the respective + * TIFF entry or option: + * - I expected /EndOfBlock and /EndOfLine to be always + * true for CCITTFAX3 images. + * + * - /EncodedByteAlign can not reliably be deduced from + * GROUP3OPT_FILLBITS; + * + * - /BlackIs1 can not reliably be deduced from + * PHOTOMETRIC_MINISBLACK; + * + * From practical experience, the respective lines are + * disabled, but I don't have any clear explanation for this. + * A few TIFF images still don't work with this setting, + * unfortunately. + */ + + /* SEE ABOVE! + strcpy(image->params, "/EndOfBlock false"); + strcat(image->params, "/EndOfLine true"); + */ + /* + strcat(image->params, "/DamagedRowsBeforeError 1"); + */ + + if (TIFFGetField(image->info.tiff.tif, TIFFTAG_GROUP3OPTIONS, + &group3opts)) { + /* /K = 0 (= G3,1D) is default */ + if (group3opts & GROUP3OPT_2DENCODING) + strcat(image->params, "/K 1"); + + /* SEE ABOVE! + if (group3opts & GROUP3OPT_FILLBITS) + strcat(image->params, "/EncodedByteAlign true"); + */ + } + + /* SEE ABOVE! + if ((photometric == PHOTOMETRIC_MINISBLACK)) + strcat(image->params, "/BlackIs1 true"); + */ + + image->strips = (int) TIFFNumberOfStrips(image->info.tiff.tif); + image->compression = ccitt; + image->bpc = 1; + image->use_raw = pdc_true; + break; + + case COMPRESSION_CCITTFAX4: + if (TIFFIsTiled(image->info.tiff.tif)) { + image->use_raw = pdc_false; + image->bpc = 8; + break; + } + + image->params = (char *) pdc_malloc(p->pdc, PDF_MAX_PARAMSTRING, + fn); + + strcpy(image->params, "/K -1"); + + if (photometric == PHOTOMETRIC_MINISBLACK) + strcat(image->params, "/BlackIs1 true"); + + image->strips = (int) TIFFNumberOfStrips(image->info.tiff.tif); + image->compression = ccitt; + image->bpc = 1; + image->use_raw = pdc_true; + break; + + case COMPRESSION_NONE: + /* + * can't use multiple data sources in raw mode, or deal with tiles + */ + if ((planarconfig == PLANARCONFIG_SEPARATE && components > 1) || + TIFFIsTiled(image->info.tiff.tif)) { + image->use_raw = pdc_false; + image->bpc = 8; + break; + } + + if (extra != 0) + image->components -= extra; /* ignore the extra channels */ + + image->use_raw = pdc_false; + image->bpc = 8; + break; + + case COMPRESSION_LZW: + + if (TIFFGetField(image->info.tiff.tif, TIFFTAG_PREDICTOR, + &predictor)) { + if (predictor != pred_default && predictor != pred_tiff) { + errint = predictor; + errcode = PDF_E_TIFF_UNSUPP_PREDICT; + goto PDF_TIFF_ERROR; + } else + image->predictor = (pdf_predictor) predictor; + } + + if (TIFFIsTiled(image->info.tiff.tif)) { + errcode = PDF_E_TIFF_UNSUPP_LZW_TILED; + goto PDF_TIFF_ERROR; + } + + if (planarconfig == PLANARCONFIG_SEPARATE && components > 1) { + errcode = PDF_E_TIFF_UNSUPP_LZW_PLANES; + goto PDF_TIFF_ERROR; + } + + if (extra != 0) { + errcode = PDF_E_TIFF_UNSUPP_LZW_ALPHA; + goto PDF_TIFF_ERROR; + } + + if (photometric == PHOTOMETRIC_MINISWHITE) + image->invert = !image->invert; + + image->strips = (int) TIFFNumberOfStrips(image->info.tiff.tif); + image->compression = lzw; + image->use_raw = pdc_true; + break; + + case COMPRESSION_PACKBITS: + /* + * can't pass through extra bits or use multiple data sources + * in raw mode + */ + if (extra != 0 || + (planarconfig == PLANARCONFIG_SEPARATE && components > 1) || + TIFFIsTiled(image->info.tiff.tif)) { + image->use_raw = pdc_false; + image->bpc = 8; + break; + } + + if (photometric == PHOTOMETRIC_MINISWHITE) + image->invert = !image->invert; + + image->strips = (int) TIFFNumberOfStrips(image->info.tiff.tif); + image->compression = runlength; + image->use_raw = pdc_true; + break; + + case COMPRESSION_DEFLATE: + case COMPRESSION_ADOBE_DEFLATE: + if (extra != 0 || + (planarconfig == PLANARCONFIG_SEPARATE && components > 1) || + TIFFIsTiled(image->info.tiff.tif)) { + image->components -= extra; /* ignore the extra channels */ + image->use_raw = pdc_false; + image->bpc = 8; + break; + } + + if (TIFFGetField(image->info.tiff.tif, TIFFTAG_PREDICTOR, + &predictor)) { + if (predictor != pred_default && predictor != pred_tiff) { + errint = predictor; + errcode = PDF_E_TIFF_UNSUPP_PREDICT; + goto PDF_TIFF_ERROR; + } else + image->predictor = (pdf_predictor) predictor; + } + + image->strips = (int) TIFFNumberOfStrips(image->info.tiff.tif); + image->compression = flate; + image->use_raw = pdc_true; + break; + +#ifdef PDF_NYI + /* dead code, doesn't work yet */ + case COMPRESSION_OJPEG: + case COMPRESSION_JPEG: + if (TIFFIsTiled(image->info.tiff.tif)) { + errcode = PDF_E_TIFF_UNSUPP_JPEG_TILED; + goto PDF_TIFF_ERROR; + } + + if (extra != 0 || + (planarconfig == PLANARCONFIG_SEPARATE && components > 1) || + TIFFIsTiled(image->info.tiff.tif)) { + errcode = PDF_E_UNSUPP_JPEG_ALPHA; + goto PDF_TIFF_ERROR; + } + + image->strips = (int) TIFFNumberOfStrips(image->info.tiff.tif); + image->compression = dct; + image->use_raw = pdc_true; + break; +#endif /* !PDF_NYI */ + + default: + image->use_raw = pdc_false; + image->bpc = 8; + } + + /* palette images are automatically converted to RGB by tifflib */ + if (image->components == 1 && !image->use_raw && + TIFFGetField(image->info.tiff.tif, TIFFTAG_COLORMAP, + &rmap, &gmap, &bmap)) { + image->components = 3; + } + + if (image->imagemask) + { + if (image->components != 1) { + errcode = PDF_E_IMAGE_BADMASK; + goto PDF_TIFF_ERROR; + } + + if (p->compatibility <= PDC_1_3) { + if (image->components != 1 || image->bpc != 1) { + errcode = PDF_E_IMAGE_MASK1BIT13; + goto PDF_TIFF_ERROR; + } + } else if (image->bpc > 1) { + /* images with more than one bit will be written as /SMask, + * and don't require an /ImageMask entry. + */ + image->imagemask = pdc_false; + } + } + + if (image->mask != pdc_undef) + { + if (image->strips != 1) { + errcode = PDF_E_TIFF_MASK_MULTISTRIP; + goto PDF_TIFF_ERROR; + } + } + + if (image->colorspace == pdc_undef) + { + switch (image->components) { + case 1: + image->colorspace = DeviceGray; + break; + + case 3: + if (photometric == PHOTOMETRIC_CIELAB) { + errint = photometric; + errcode = PDF_E_TIFF_UNSUPP_CS; + goto PDF_TIFF_ERROR; + } else + image->colorspace = DeviceRGB; + break; + + case 4: + if (photometric == PHOTOMETRIC_SEPARATED) { + TIFFGetFieldDefaulted(image->info.tiff.tif, TIFFTAG_INKSET, + &inkset); + if (inkset != INKSET_CMYK) { + errint = inkset; + errcode = PDF_E_TIFF_UNSUPP_SEP_NONCMYK; + goto PDF_TIFF_ERROR; + } + image->colorspace = DeviceCMYK; + } else { + /* if it's not separated it must be RGB with alpha */ + image->components = 3; + image->colorspace = DeviceRGB; + image->compression = none; + } + break; + + default: + errint = image->components; + errcode = PDF_E_IMAGE_BADCOMP; + goto PDF_TIFF_ERROR; + } + } + + + image->src.private_data = (void *) image; + image->src.init = pdf_data_source_TIFF_init; + image->src.fill = pdf_data_source_TIFF_fill; + image->src.terminate = pdf_data_source_TIFF_terminate; + + if (image->use_raw) { + uint32 row, rowsperstrip; + + /* must handle colormap ourselves */ + if (photometric == PHOTOMETRIC_PALETTE) { + int i; + pdf_colormap colormap; + + if (!TIFFGetField(image->info.tiff.tif, TIFFTAG_COLORMAP, + &rmap, &gmap, &bmap)) { + errcode = PDF_E_IMAGE_COLORMAP; + goto PDF_TIFF_ERROR; + } + + cs.type = Indexed; + cs.val.indexed.palette_size = 1 << bpc; + cs.val.indexed.colormap = &colormap; + cs.val.indexed.colormap_id = PDC_BAD_ID; + + cs.val.indexed.base = DeviceRGB; + +#define CVT(x) (uint16) (((x) * 255) / ((1L<<16)-1)) + if (pdf_check_colormap(cs.val.indexed.palette_size, + rmap, gmap, bmap) == 16) + { + /* convert colormap to 8 bit values */ + for (i = 0; i < cs.val.indexed.palette_size; i++) { + rmap[i] = CVT(rmap[i]); + gmap[i] = CVT(gmap[i]); + bmap[i] = CVT(bmap[i]); + } + } +#undef CVT + + for (i = 0; i < cs.val.indexed.palette_size; i++) { + colormap[i][0] = (pdc_byte) rmap[i]; + colormap[i][1] = (pdc_byte) gmap[i]; + colormap[i][2] = (pdc_byte) bmap[i]; + } + + image->components = 1; + + slot = pdf_add_colorspace(p, &cs, pdc_false); + image->colorspace = (pdf_colorspacetype) slot; + + + } + + + if (image->strips > image->height) + image->strips = (int) image->height; + + if (TIFFGetFieldDefaulted(image->info.tiff.tif, + TIFFTAG_ROWSPERSTRIP, &rowsperstrip) == 1 && (int) rowsperstrip + != -1) + image->rowsperstrip = (int) rowsperstrip; + else + image->rowsperstrip = (int) image->height; + + /* + * The first strip must be handled separately because it carries the + * colormap for indexed images. Other strips reuse this colormap. + */ + image->info.tiff.cur_line = 0; + image->height = (float) + (image->rowsperstrip > (int) h ? (int) h : image->rowsperstrip); + pdf_put_image(p, imageslot, pdc_true); + + for (row = (uint32) image->rowsperstrip, strip = 1; + row < h; row += (uint32) image->rowsperstrip, strip++) { + + image->height = (float) (row+image->rowsperstrip > h ? + (int) (h - row) : image->rowsperstrip); + + /* + * tell pdf_data_source_TIFF_fill() to read only data of the + * current strip + */ + image->info.tiff.cur_line = strip; + pdf_put_image(p, imageslot, pdc_false); + } + + image->height = (float) h; + image->no -= (image->strips - 1); /* number of first strip */ + + } else { + + + image->info.tiff.raster = (uint32 *) NULL; + + if (p->colorspaces[image->colorspace].type != DeviceCMYK && + !(p->colorspaces[image->colorspace].type == ICCBased && + image->components == 4) && + p->colorspaces[image->colorspace].type != Lab) { + npixels = (size_t) (w * h); + image->info.tiff.raster = (uint32 *) pdc_malloc(p->pdc, + (size_t) (npixels * sizeof (uint32)), "pdf_open_TIFF"); + + if (!TIFFReadRGBAImage(image->info.tiff.tif, + w, h, image->info.tiff.raster, 1)) { + pdc_free(p->pdc, (void *) image->info.tiff.raster); + errcode = PDC_E_IO_NODATA; + goto PDF_TIFF_ERROR; + } + } else { + int linecounter = 0; + + npixels = (size_t) (TIFFScanlineSize(image->info.tiff.tif) * h); + image->info.tiff.raster = (uint32 *) + pdc_malloc(p->pdc, (size_t) npixels, "pdf_open_TIFF"); + + while (linecounter < image->height) { + if (TIFFReadScanline(image->info.tiff.tif, + (tdata_t) (image->info.tiff.raster + + ((int)image->height - linecounter - 1) * (int)image->width), + (uint32) linecounter, (tsample_t) 0) == -1) { + + pdc_free(p->pdc, (void *) image->info.tiff.raster); + errcode = PDC_E_IO_NODATA; + goto PDF_TIFF_ERROR; + } + linecounter++; + } + } + + pdf_put_image(p, imageslot, pdc_true); + + if (image->info.tiff.raster) + pdc_free(p->pdc, (void *) image->info.tiff.raster); + } + + image->in_use = pdc_true; /* mark slot as used */ + + TIFFClose(image->info.tiff.tif); + + return imageslot; + + PDF_TIFF_ERROR: + if (isopen) + TIFFClose(image->info.tiff.tif); + { + const char *stemp = pdc_errprintf(p->pdc, "%s", image->filename); + switch (errcode) + { + case PDC_E_IO_NODATA: + case PDF_E_IMAGE_ICC: + case PDF_E_IMAGE_ICC2: + case PDF_E_IMAGE_MASK1BIT13: + case PDF_E_TIFF_UNSUPP_LZW_TILED: + case PDF_E_TIFF_UNSUPP_LZW_PLANES: + case PDF_E_TIFF_UNSUPP_LZW_ALPHA: + case PDF_E_TIFF_UNSUPP_JPEG_TILED: + case PDF_E_TIFF_UNSUPP_JPEG_ALPHA: + case PDF_E_IMAGE_COLORIZE: + case PDF_E_TIFF_MASK_MULTISTRIP: + case PDF_E_IMAGE_COLORMAP: + case PDF_E_IMAGE_BADMASK: + pdc_set_errmsg(p->pdc, errcode, stemp, 0, 0, 0); + break; + + case PDF_E_IMAGE_CORRUPT: + pdc_set_errmsg(p->pdc, errcode, "TIFF", stemp, 0, 0); + break; + + case PDF_E_IMAGE_BADDEPTH: + case PDF_E_IMAGE_BADCOMP: + pdc_set_errmsg(p->pdc, errcode, + pdc_errprintf(p->pdc, "%d", errint), stemp, 0, 0); + break; + + case PDF_E_IMAGE_NOPAGE: + pdc_set_errmsg(p->pdc, errcode, + pdc_errprintf(p->pdc, "%d", errint), "TIFF", stemp, 0); + break; + + case PDF_E_TIFF_UNSUPP_JPEG: + case PDF_E_TIFF_UNSUPP_CS: + case PDF_E_TIFF_UNSUPP_PREDICT: + case PDF_E_TIFF_UNSUPP_SEP_NONCMYK: + pdc_set_errmsg(p->pdc, errcode, + stemp, pdc_errprintf(p->pdc, "%d", errint), 0, 0); + break; + + case 0: /* error code and message already set */ + break; + } + } + + if (image->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; +} + +#endif /* HAVE_LIBTIFF */ diff --git a/src/libs/pdflib/libs/pdflib/p_truetype.c b/src/libs/pdflib/libs/pdflib/p_truetype.c new file mode 100644 index 0000000000..0a324391f9 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_truetype.c @@ -0,0 +1,1872 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_truetype.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib TrueType handling routines + * + */ + +#include "p_intern.h" +#include "p_font.h" +#include "p_truetype.h" + +#ifdef PDF_TRUETYPE_SUPPORTED + + +void +tt_assert(PDF *p, tt_file *ttf) +{ + const char *filename = ttf->filename; + const char *fontname = ttf->fontname; + + pdf_cleanup_tt(p, ttf); /* this will not free ttf->filename/fontname */ + + if (filename) + pdc_error(p->pdc, PDF_E_TT_ASSERT1, filename, 0, 0, 0); + else if (fontname) + pdc_error(p->pdc, PDF_E_TT_ASSERT1, fontname, 0, 0, 0); + else + pdc_error(p->pdc, PDF_E_TT_ASSERT2, 0, 0, 0, 0); +} /* tt_assert */ + +void +tt_error(PDF *p, tt_file *ttf) +{ + const char *filename = ttf->filename; + const char *fontname = ttf->fontname; + const char *qualifier = "TrueType"; + + pdf_cleanup_tt(p, ttf); /* this will not free ttf->filename/fontname */ + + if (filename) + pdc_error(p->pdc, PDF_E_FONT_CORRUPT, qualifier, filename, 0, 0); + else if (fontname) + pdc_error(p->pdc, PDF_E_FONT_CORRUPT, qualifier, fontname, 0, 0); + else + pdc_error(p->pdc, PDF_E_FONT_CORRUPT, qualifier, "?", 0, 0); + +} /* tt_error */ + +void +tt_seek(PDF *p, tt_file *ttf, long offset) +{ + if (ttf->incore) + { + TT_IOCHECK(p, ttf, ttf->img + (tt_ulong) offset <= ttf->end); + ttf->pos = ttf->img + (tt_ulong) offset; + } + else + TT_IOCHECK(p, ttf, pdc_fseek(ttf->fp, offset, SEEK_SET) == 0); +} + +void +tt_read(PDF *p, tt_file *ttf, void *buf, unsigned int nbytes) +{ + if (ttf->incore) + { + TT_IOCHECK(p, ttf, ttf->pos + (tt_ulong) nbytes <= ttf->end); + memcpy(buf, ttf->pos, (size_t) nbytes); + ttf->pos += (tt_ulong) nbytes; + } + else + TT_IOCHECK(p, ttf, PDC_OK_FREAD(ttf->fp, buf, nbytes)); +} + +long +tt_tell(PDF *p, tt_file *ttf) +{ + (void) p; + if (ttf->incore) + return (long) (ttf->pos - ttf->img); + else + return pdc_ftell(ttf->fp); +} + +tt_ushort +tt_get_ushort(PDF *p, tt_file *ttf) +{ + tt_byte *pos, buf[2]; + + if (ttf->incore) + { + pos = ttf->pos; + TT_IOCHECK(p, ttf, (ttf->pos += 2) <= ttf->end); + } + else + { + pos = buf; + TT_IOCHECK(p, ttf, PDC_OK_FREAD(ttf->fp, buf, 2)); + } + + return pdc_get_be_ushort(pos); +} + +tt_short +tt_get_short(PDF *p, tt_file *ttf) +{ + tt_byte *pos, buf[2]; + + if (ttf->incore) + { + pos = ttf->pos; + TT_IOCHECK(p, ttf, (ttf->pos += 2) <= ttf->end); + } + else + { + pos = buf; + TT_IOCHECK(p, ttf, PDC_OK_FREAD(ttf->fp, buf, 2)); + } + + return pdc_get_be_short(pos); +} + +tt_ulong +tt_get_ulong3(PDF *p, tt_file *ttf) +{ + tt_byte *pos, buf[3]; + + if (ttf->incore) + { + pos = ttf->pos; + TT_IOCHECK(p, ttf, (ttf->pos += 3) <= ttf->end); + } + else + { + pos = buf; + TT_IOCHECK(p, ttf, PDC_OK_FREAD(ttf->fp, buf, 3)); + } + + return pdc_get_be_ulong3(pos); +} + +tt_ulong +tt_get_ulong(PDF *p, tt_file *ttf) +{ + tt_byte *pos, buf[4]; + + if (ttf->incore) + { + pos = ttf->pos; + TT_IOCHECK(p, ttf, (ttf->pos += 4) <= ttf->end); + } + else + { + pos = buf; + TT_IOCHECK(p, ttf, PDC_OK_FREAD(ttf->fp, buf, 4)); + } + + return pdc_get_be_ulong(pos); +} + +tt_long +tt_get_long(PDF *p, tt_file *ttf) +{ + tt_byte *pos, buf[4]; + + if (ttf->incore) + { + pos = ttf->pos; + TT_IOCHECK(p, ttf, (ttf->pos += 4) <= ttf->end); + } + else + { + pos = buf; + TT_IOCHECK(p, ttf, PDC_OK_FREAD(ttf->fp, buf, 4)); + } + + return pdc_get_be_long(pos); +} + +tt_ulong +tt_get_offset(PDF *p, tt_file *ttf, tt_byte offsize) +{ + tt_byte buf; + + switch (offsize) + { + case 1: + tt_read(p, ttf, &buf, 1); + return (tt_ulong) buf; + + case 2: + return (tt_ulong) tt_get_ushort(p, ttf); + + case 3: + return (tt_ulong) tt_get_ulong3(p, ttf); + + case 4: + return (tt_ulong) tt_get_ulong(p, ttf); + } + return 0; +} + +static void +tt_get_dirent(PDF *p, tt_dirent *dirent, tt_file *ttf) +{ + tt_read(p, ttf, dirent->tag, 4); + dirent->tag[4] = 0; + dirent->checksum = tt_get_ulong(p, ttf); + dirent->offset = tt_get_ulong(p, ttf); + dirent->length = tt_get_ulong(p, ttf); +} /* tt_get_dirent */ + + +int +tt_tag2idx(tt_file *ttf, char *tag) +{ + int i; + + for (i = 0; i < ttf->n_tables; ++i) + if (strcmp(ttf->dir[i].tag, tag) == 0) + return i; + + return -1; +} /* tt_tag2idx */ + +static void +tt_get_cmap0(PDF *p, tt_file *ttf, tt_cmap0_6 *cm0_6) +{ + static const char *fn = "tt_get_cmap0"; + tt_ushort c; + tt_byte buf[256]; + + cm0_6->length = tt_get_ushort(p, ttf); + cm0_6->language = tt_get_ushort(p, ttf); + cm0_6->glyphIdArray = (tt_ushort *) 0; + + /* These are not used in format 0 */ + cm0_6->firstCode = 0; + cm0_6->entryCount = 256; + + cm0_6->glyphIdArray = (tt_ushort *) + pdc_malloc(p->pdc, (size_t) (sizeof (tt_ushort) * 256), fn); + + tt_read(p, ttf, buf, 256); + + for (c = 0; c < 256; c++) + cm0_6->glyphIdArray[c] = (tt_ushort) buf[c]; + +} /* tt_get_cmap0 */ + +static void +tt_get_cmap6(PDF *p, tt_file *ttf, tt_cmap0_6 *cm0_6) +{ + static const char *fn = "tt_get_cmap6"; + tt_ushort c, last; + + cm0_6->length = tt_get_ushort(p, ttf); + cm0_6->language = tt_get_ushort(p, ttf); + cm0_6->firstCode = tt_get_ushort(p, ttf); + cm0_6->entryCount = tt_get_ushort(p, ttf); + cm0_6->glyphIdArray = (tt_ushort *) 0; + + last = (tt_ushort) (cm0_6->firstCode + cm0_6->entryCount); + + cm0_6->glyphIdArray = (tt_ushort *) + pdc_malloc(p->pdc, (size_t) (sizeof (tt_ushort) * last), fn); + + /* default for codes outside the range specified in this table */ + for (c = 0; c < last; c++) + cm0_6->glyphIdArray[c] = (tt_ushort) 0; + + for (c = cm0_6->firstCode; c < last; c++) + cm0_6->glyphIdArray[c] = tt_get_ushort(p, ttf); + +} /* tt_get_cmap6 */ + +static void +tt_get_cmap4(PDF *p, tt_file *ttf, tt_cmap4 *cm4) +{ + static const char *fn = "tt_get_cmap4"; + int i, segs; + + /* the instruction order is critical for cleanup after exceptions! + */ + cm4->endCount = (tt_ushort *) 0; + cm4->startCount = (tt_ushort *) 0; + cm4->idDelta = (tt_short *) 0; + cm4->idRangeOffs = (tt_ushort *) 0; + cm4->glyphIdArray = (tt_ushort *) 0; + + cm4->format = tt_get_ushort(p, ttf); + TT_IOCHECK(p, ttf, cm4->format == 4); + cm4->length = tt_get_ushort(p, ttf); + cm4->version = tt_get_ushort(p, ttf); + cm4->segCountX2 = tt_get_ushort(p, ttf); + cm4->searchRange = tt_get_ushort(p, ttf); + cm4->entrySelector = tt_get_ushort(p, ttf); + cm4->rangeShift = tt_get_ushort(p, ttf); + + segs = cm4->segCountX2 / 2; + + cm4->numGlyphIds = (tt_ushort)( + ((cm4->length - ( 16L + 8L * segs )) & 0xFFFFU) / 2); + + TT_IOCHECK(p, ttf, 0 <= cm4->numGlyphIds); + + cm4->endCount = + (tt_ushort *) + pdc_malloc(p->pdc, (size_t) (sizeof (tt_ushort) * segs), fn); + cm4->startCount = + (tt_ushort *) + pdc_malloc(p->pdc, (size_t) (sizeof (tt_ushort) * segs), fn); + cm4->idDelta = + (tt_short *) + pdc_malloc(p->pdc, (size_t) (sizeof (tt_ushort) * segs), fn); + cm4->idRangeOffs = + (tt_ushort *) + pdc_malloc(p->pdc, (size_t) (sizeof (tt_ushort) * segs), fn); + + if (cm4->numGlyphIds) + { + cm4->glyphIdArray = (tt_ushort *) + pdc_malloc(p->pdc, + (size_t) (sizeof (tt_ushort) * cm4->numGlyphIds), fn); + } + + for (i = 0; i < segs; ++i) + cm4->endCount[i] = tt_get_ushort(p, ttf); + + TT_IOCHECK(p, ttf, cm4->endCount[segs - 1] == 0xFFFF); + + (void) tt_get_ushort(p, ttf); /* padding */ + for (i = 0; i < segs; ++i) cm4->startCount[i] = tt_get_ushort(p, ttf); + for (i = 0; i < segs; ++i) cm4->idDelta[i] = tt_get_short(p, ttf); + for (i = 0; i < segs; ++i) cm4->idRangeOffs[i] = tt_get_ushort(p, ttf); + + for (i = 0; i < cm4->numGlyphIds; ++i) + cm4->glyphIdArray[i] = tt_get_ushort(p, ttf); + + /* empty cmap */ + if (segs == 1 && cm4->endCount[0] == cm4->startCount[0]) + { + cm4->segCountX2 = 0; + pdc_free(p->pdc, cm4->endCount); + cm4->endCount = (tt_ushort *) 0; + pdc_free(p->pdc, cm4->startCount); + cm4->startCount = (tt_ushort *) 0; + pdc_free(p->pdc, cm4->idDelta); + cm4->idDelta = (tt_short *) 0; + pdc_free(p->pdc, cm4->idRangeOffs); + cm4->idRangeOffs = (tt_ushort *) 0; + if (cm4->numGlyphIds) + { + pdc_free(p->pdc, cm4->glyphIdArray); + cm4->glyphIdArray = (tt_ushort *) 0; + } + } + +} /* tt_get_cmap4 */ + +/* convert unicode to glyph ID using cmap4. */ +static int +tt_unicode2gidx4(PDF *p, tt_file *ttf, unsigned int uv) +{ + tt_cmap4 * cm4; + int segs; + int i; + int gidx = 0; + + TT_ASSERT(p, ttf, ttf->tab_cmap != (tt_tab_cmap *) 0); + TT_ASSERT(p, ttf, ttf->tab_cmap->win != (tt_cmap4 *) 0); + + cm4 = ttf->tab_cmap->win; + segs = cm4->segCountX2 / 2; + + for (i = 0; i < segs; ++i) + if (uv <= cm4->endCount[i]) + break; + + TT_IOCHECK(p, ttf, i != segs); + if (uv < cm4->startCount[i] || uv == 0xFFFF) + return 0; + + if (cm4->idRangeOffs[i] == 0) + gidx = (int)((uv + cm4->idDelta[i]) & 0xFFFF); + else + { + int idx = (int) cm4->idRangeOffs[i] / 2 + + (int) (uv - cm4->startCount[i]) - (segs - i); + + if (idx < 0 || idx >= cm4->numGlyphIds) + { + if (ttf->font->verbose) + pdc_warning(p->pdc, PDF_E_TT_GLYPHIDNOTFOUND, + pdc_errprintf(p->pdc, "x%04X", uv), + ttf->fontname, 0, 0); + return 0; + } + + if (cm4->glyphIdArray[idx] == 0) + return 0; + else + gidx = (int)((cm4->glyphIdArray[idx] + cm4->idDelta[i]) & 0xFFFF); + } + + /* this is necessary because of some Mac fonts (e.g. Hiragino) */ + return (gidx < ttf->tab_maxp->numGlyphs) ? gidx : 0; + +} /* tt_unicode2gidx4 */ + +/* convert 8-bit code to glyph ID */ +static int +tt_code2gidx(PDF *p, tt_file *ttf, pdc_font *font, int code) +{ + pdc_encoding enc = font->encoding; + pdc_ushort uv = 0; + int gidx = 0; + + + if (enc == pdc_macroman && ttf->tab_cmap->mac) + { + if (code > -1 && code < (int) (ttf->tab_cmap->mac->firstCode + + ttf->tab_cmap->mac->entryCount)) + gidx = ttf->tab_cmap->mac->glyphIdArray[code]; + } + else if (font->isstdlatin == pdc_false) + { + /* This would be an Apple font with an encoding different + * from macroman. + */ + if (!ttf->tab_OS_2) + { + const char *fontname = ttf->fontname; + + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_TT_SYMBOLOS2, fontname, 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return -1; + } + + /* e.g. WingDings has usFirstChar = 0xF020, but we must start + ** at 0xF000. I haven't seen non-symbol fonts with a usFirstChar + ** like that; perhaps we have to apply similar tricks then... + */ + uv = (pdc_ushort) (code + + (ttf->tab_OS_2->usFirstCharIndex & 0xFF00)); + gidx = tt_unicode2gidx4(p, ttf, (unsigned int) uv); + } + else + { + pdc_encodingvector *ev = p->encodings[enc].ev; + uv = ev->codes[code]; + if (uv) + { + gidx = tt_unicode2gidx4(p, ttf, (unsigned int) uv); + } + } + + return gidx; + +} /* tt_code2gidx */ + +void +tt_get_tab_cmap(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_cmap"; + tt_tab_cmap *tp = (tt_tab_cmap *) + pdc_malloc(p->pdc, sizeof (tt_tab_cmap), fn); + int idx = tt_tag2idx(ttf, pdf_str_cmap); + int i; + tt_ulong offset; + tt_ushort numEncTabs; + tt_ushort tableFormat; + + /* the instruction order is critical for cleanup after exceptions! + */ + tp->win = (tt_cmap4 *) 0; + tp->mac = (tt_cmap0_6 *) 0; + ttf->tab_cmap = tp; + + TT_IOCHECK(p, ttf, idx != -1); + offset = ttf->dir[idx].offset; + tt_seek(p, ttf, (long) offset); + + (void) tt_get_ushort(p, ttf); /* version */ + numEncTabs = tt_get_ushort(p, ttf); + + for (i = 0; i < numEncTabs; ++i) + { + tt_ushort platformID = tt_get_ushort(p, ttf); + tt_ushort encodingID = tt_get_ushort(p, ttf); + tt_ulong offsetEncTab = tt_get_ulong(p, ttf); + tt_long pos = tt_tell(p, ttf); + + tt_seek(p, ttf, (long) (offset + offsetEncTab)); + + if (platformID == tt_pfid_mac && encodingID == tt_wenc_symbol) + { + tableFormat = tt_get_ushort(p, ttf); + + /* we currently do not support cmaps + ** other than format 0 and 6 for Macintosh cmaps. + */ + + if (tableFormat == 0 && tp->mac == (tt_cmap0_6 *) 0) + { + tp->mac = (tt_cmap0_6 *) + pdc_malloc(p->pdc, sizeof (tt_cmap0_6), fn); + tp->mac->format = 0; + tt_get_cmap0(p, ttf, tp->mac); + } + else if (tableFormat == 6 && tp->mac == (tt_cmap0_6 *) 0) + { + tp->mac = (tt_cmap0_6 *) + pdc_malloc(p->pdc, sizeof (tt_cmap0_6), fn); + tp->mac->format = 6; + tt_get_cmap6(p, ttf, tp->mac); + } + } + else if (platformID == tt_pfid_win && + (encodingID == tt_wenc_symbol || encodingID == tt_wenc_text)) + { + TT_IOCHECK(p, ttf, tp->win == (tt_cmap4 *) 0); + tp->win = (tt_cmap4 *) pdc_malloc(p->pdc, sizeof (tt_cmap4), fn); + tt_get_cmap4(p, ttf, tp->win); + if (tp->win->segCountX2) + tp->win->encodingID = encodingID; + else + { + pdc_free(p->pdc, tp->win); + tp->win = (tt_cmap4 *) 0; + } + } + + tt_seek(p, ttf, pos); + } /* for */ +} /* tt_get_tab_cmap */ + +void +tt_get_tab_head(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_head"; + tt_tab_head *tp = (tt_tab_head *) + pdc_malloc(p->pdc, sizeof (tt_tab_head), fn); + int idx = tt_tag2idx(ttf, pdf_str_head); + + ttf->tab_head = tp; + TT_IOCHECK(p, ttf, idx != -1); + tt_seek(p, ttf, (long) ttf->dir[idx].offset); + + tp->version = tt_get_fixed(p, ttf); + tp->fontRevision = tt_get_fixed(p, ttf); + tp->checkSumAdjustment = tt_get_ulong(p, ttf); + tp->magicNumber = tt_get_ulong(p, ttf); + tp->flags = tt_get_ushort(p, ttf); + tp->unitsPerEm = tt_get_ushort(p, ttf); + tp->created[1] = tt_get_ulong(p, ttf); + tp->created[0] = tt_get_ulong(p, ttf); + tp->modified[1] = tt_get_ulong(p, ttf); + tp->modified[0] = tt_get_ulong(p, ttf); + tp->xMin = tt_get_fword(p, ttf); + tp->yMin = tt_get_fword(p, ttf); + tp->xMax = tt_get_fword(p, ttf); + tp->yMax = tt_get_fword(p, ttf); + tp->macStyle = tt_get_ushort(p, ttf); + tp->lowestRecPPEM = tt_get_ushort(p, ttf); + tp->fontDirectionHint = tt_get_short(p, ttf); + tp->indexToLocFormat = tt_get_short(p, ttf); + tp->glyphDataFormat = tt_get_short(p, ttf); +} /* tt_get_tab_head */ + +static void +tt_get_tab_hhea(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_hhea"; + tt_tab_hhea *tp = (tt_tab_hhea *) + pdc_malloc(p->pdc, sizeof (tt_tab_hhea), fn); + int idx = tt_tag2idx(ttf, pdf_str_hhea); + + ttf->tab_hhea = tp; + TT_IOCHECK(p, ttf, idx != -1); + tt_seek(p, ttf, (long) ttf->dir[idx].offset); + + tp->version = tt_get_fixed(p, ttf); + tp->ascender = tt_get_fword(p, ttf); + tp->descender = tt_get_fword(p, ttf); + tp->lineGap = tt_get_fword(p, ttf); + tp->advanceWidthMax = tt_get_ufword(p, ttf); + tp->minLeftSideBearing = tt_get_fword(p, ttf); + tp->minRightSideBearing = tt_get_fword(p, ttf); + tp->xMaxExtent = tt_get_fword(p, ttf); + tp->caretSlopeRise = tt_get_short(p, ttf); + tp->caretSlopeRun = tt_get_short(p, ttf); + tp->res1 = tt_get_short(p, ttf); + tp->res2 = tt_get_short(p, ttf); + tp->res3 = tt_get_short(p, ttf); + tp->res4 = tt_get_short(p, ttf); + tp->res5 = tt_get_short(p, ttf); + tp->metricDataFormat = tt_get_short(p, ttf); + tp->numberOfHMetrics = tt_get_ushort(p, ttf); +} /* tt_get_tab_hhea */ + +static void +tt_get_tab_hmtx(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_hmtx"; + tt_tab_hmtx *tp = (tt_tab_hmtx *) + pdc_malloc(p->pdc, sizeof (tt_tab_hmtx), fn); + int idx = tt_tag2idx(ttf, pdf_str_hmtx); + int n_metrics; + int n_lsbs; + int i; + + TT_ASSERT(p, ttf, ttf->tab_hhea != 0); + TT_ASSERT(p, ttf, ttf->tab_maxp != 0); + + /* the instruction order is critical for cleanup after exceptions! + */ + tp->metrics = 0; + tp->lsbs = 0; + ttf->tab_hmtx = tp; + + TT_IOCHECK(p, ttf, idx != -1); + tt_seek(p, ttf, (long) ttf->dir[idx].offset); + + n_metrics = ttf->tab_hhea->numberOfHMetrics; + n_lsbs = ttf->tab_maxp->numGlyphs - n_metrics; + + TT_IOCHECK(p, ttf, n_metrics != 0); + TT_IOCHECK(p, ttf, n_lsbs >= 0); + tp->metrics = (tt_metric *) + pdc_malloc(p->pdc, n_metrics * sizeof (tt_metric), fn); + + for (i = 0; i < n_metrics; ++i) + { + tp->metrics[i].advanceWidth = tt_get_ufword(p, ttf); + tp->metrics[i].lsb = tt_get_fword(p, ttf); + } + + if (n_lsbs == 0) + tp->lsbs = (tt_fword *) 0; + else + { + tp->lsbs = (tt_fword *) + pdc_malloc(p->pdc, n_lsbs * sizeof (tt_fword), fn); + for (i = 0; i < n_lsbs; ++i) + tp->lsbs[i] = tt_get_fword(p, ttf); + } +} /* tt_get_tab_hmtx */ + + + +pdc_bool +tt_get_tab_CFF_(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_CFF_"; + int idx = tt_tag2idx(ttf, pdf_str_CFF_); + + if (idx != -1) + { + /* CFF table found */ + ttf->tab_CFF_ = (tt_tab_CFF_ *) + pdc_malloc(p->pdc, sizeof (tt_tab_CFF_), fn); + ttf->tab_CFF_->offset = ttf->dir[idx].offset; + ttf->tab_CFF_->length = ttf->dir[idx].length; + } + else + { + idx = tt_tag2idx(ttf, pdf_str_glyf); + if (idx == -1 || !ttf->dir[idx].length) + { + const char *fontname = ttf->fontname; + pdc_bool verbose = ttf->font->verbose; + + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_TT_NOGLYFDESC, fontname, 0, 0, 0); + + if (verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + idx = -1; + } + + + return pdc_true; + +} /* tt_get_tab_CFF_ */ + +static int +tt_gidx2width(PDF *p, tt_file *ttf, int gidx) +{ + TT_ASSERT(p, ttf, ttf->tab_hmtx != (tt_tab_hmtx *) 0); + TT_ASSERT(p, ttf, ttf->tab_head != (tt_tab_head *) 0); + TT_ASSERT(p, ttf, ttf->tab_hhea != (tt_tab_hhea *) 0); + + { + int n_metrics = ttf->tab_hhea->numberOfHMetrics; + + if (gidx >= n_metrics) + gidx = n_metrics - 1; + if (ttf->font->monospace) + return ttf->font->monospace; + else + return PDF_TT2PDF(ttf->tab_hmtx->metrics[gidx].advanceWidth); + } +} /* tt_gidx2width */ + + +void +tt_get_tab_maxp(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_maxp"; + tt_tab_maxp *tp = (tt_tab_maxp *) + pdc_malloc(p->pdc, sizeof (tt_tab_maxp), fn); + int idx = tt_tag2idx(ttf, pdf_str_maxp); + + ttf->tab_maxp = tp; + TT_IOCHECK(p, ttf, idx != -1); + tt_seek(p, ttf, (long) ttf->dir[idx].offset); + + tp->version = tt_get_fixed(p, ttf); + tp->numGlyphs = tt_get_ushort(p, ttf); + tp->maxPoints = tt_get_ushort(p, ttf); + tp->maxContours = tt_get_ushort(p, ttf); + tp->maxCompositePoints = tt_get_ushort(p, ttf); + tp->maxCompositeContours = tt_get_ushort(p, ttf); + tp->maxZones = tt_get_ushort(p, ttf); + tp->maxTwilightPoints = tt_get_ushort(p, ttf); + tp->maxStorage = tt_get_ushort(p, ttf); + tp->maxFunctionDefs = tt_get_ushort(p, ttf); + tp->maxInstructionDefs = tt_get_ushort(p, ttf); + tp->maxStackElements = tt_get_ushort(p, ttf); + tp->maxSizeOfInstructions = tt_get_ushort(p, ttf); + tp->maxComponentElements = tt_get_ushort(p, ttf); + tp->maxComponentDepth = tt_get_ushort(p, ttf); +} /* tt_get_tab_maxp */ + +static pdc_bool +tt_get_tab_name(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_name"; + tt_tab_name *tp; + int idx; + int i, j, k, namid, irec, irec4 = -1, irec6 = -1; + size_t len; + tt_nameref *namerec = NULL, lastnamerec; + char *localname = NULL; + tt_ulong offs; + + idx = tt_tag2idx(ttf, pdf_str_name); + + /* not obligatory */ + if (idx == -1) + return pdc_false; + + /* the instruction order is critical for cleanup after exceptions! + */ + tp = (tt_tab_name *) pdc_malloc(p->pdc, sizeof (tt_tab_name), fn); + tp->namerecords = NULL; + tp->englishname4 = NULL; + tp->englishname6 = NULL; + ttf->tab_name = tp; + tt_seek(p, ttf, (long) ttf->dir[idx].offset); + + tp->format = tt_get_ushort(p, ttf); + + /* Format 0 is the only document one, but some Apple fonts use 65535. + * This is very consequent since it follows Microsoft's lead in + * disregarding one's own published specifications. + */ + TT_IOCHECK(p, ttf, (tp->format == 0 || tp->format == 65535)); + + tp->numNameRecords = (tt_ushort) + tt_get_offset(p, ttf, sizeof(tt_ushort)); + tp->offsetStrings = tt_get_ushort(p, ttf); + offs = ttf->dir[idx].offset + tp->offsetStrings; + + len = tp->numNameRecords * sizeof (tt_nameref); + tp->namerecords = (tt_nameref *) pdc_malloc(p->pdc, len, fn); + + for (i = 0; i < tp->numNameRecords; ++i) + { + tt_ushort platformID = tt_get_ushort(p, ttf); + tt_ushort encodingID = tt_get_ushort(p, ttf); + tt_ushort languageID = tt_get_ushort(p, ttf); + tt_ushort nameID = tt_get_ushort(p, ttf); + tt_ushort stringLength = tt_get_ushort(p, ttf); + tt_ushort stringOffset = tt_get_ushort(p, ttf); + + (void) encodingID; /* avoid compiler warning */ + + namerec = &tp->namerecords[i]; + namerec->platform = platformID; + namerec->language = languageID; + namerec->namid = nameID; + namerec->length = stringLength; + namerec->offset = stringOffset; + } + + namid = 4; + for (k = 0; k < 2; k++) + { + lastnamerec.platform = 0; + lastnamerec.language = 0; + lastnamerec.namid = 0; + lastnamerec.length = 0; + lastnamerec.offset = 0; + + for (i = 0; i < tp->numNameRecords; ++i) + { + namerec = &tp->namerecords[i]; + if (!namerec->length || namerec->namid != namid) continue; + + /* TTC font search */ + if (ttf->utf16fontname) + { + /* read font name */ + localname = + (char *) pdc_calloc(p->pdc, (size_t) namerec->length, fn); + tt_seek(p, ttf, (long) (offs + namerec->offset)); + tt_read(p, ttf, localname, (unsigned int) namerec->length); + + if (namerec->platform == tt_pfid_win && + namerec->length == ttf->fnamelen && + !memcmp(localname, ttf->utf16fontname, + (size_t) ttf->fnamelen)) + { + /* font found */ + pdc_free(p->pdc, localname); + return pdc_true; + } + pdc_free(p->pdc, localname); + } + + /* search for the records with english names */ + else + { + /* we take the names from platformID 3 (Microsoft) or + * 1 (Macintosh). We favor Macintosh and then Microsoft + * with American English (LanguageID = 0x0409 = 1033) + */ + if ((lastnamerec.language != 0x0409 || + lastnamerec.platform != tt_pfid_win) && + (namerec->platform == tt_pfid_win || + (namerec->platform == tt_pfid_mac && + namerec->language == 0))) + { + lastnamerec = *namerec; + + /* We simulate always English */ + if (namerec->platform == tt_pfid_mac) + lastnamerec.language = 0x0409; + + if (namid == 4) irec4 = i; + if (namid == 6) irec6 = i; + } + } + } + namid = 6; + } + + /* TTC font not found */ + if (ttf->utf16fontname) return pdc_false; + + /* English font names */ + namid = 4; + irec = irec4; + for (k = 0; k < 2; k++) + { + if (irec == -1) continue; + namerec = &tp->namerecords[irec]; + + /* read font name */ + len = (size_t) (namerec->length + 1); + localname = (char *) pdc_calloc(p->pdc, (size_t) len, fn); + tt_seek(p, ttf, (long) (offs + namerec->offset)); + tt_read(p, ttf, localname, (unsigned int) namerec->length); + + /* low byte picking */ + if (namerec->platform == tt_pfid_win) + { + for (j = 0; j < namerec->length / 2; j++) + { + /* We don't support wide character names */ + if (localname[2*j] != 0) + { + pdc_free(p->pdc, localname); + localname = NULL; + break; + } + localname[j] = localname[2*j + 1]; + } + if (localname) + localname[j] = 0; + } + + /* We observed this in EUDC fonts */ + if (localname && !strcmp(localname, "\060\060")) + { + pdc_free(p->pdc, localname); + localname = NULL; + } + + if (namid == 4 && localname) + tp->englishname4 = localname; + else if (namid == 6 && localname) + tp->englishname6 = localname; + + namid = 6; + irec = irec6; + } + + /* font name 4 (full font name) is required */ + if (tp->englishname6 == NULL && tp->englishname4 == NULL) + { + const char *fontname = ttf->fontname; + pdc_bool verbose = ttf->font->verbose; + + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_TT_NONAME, fontname, 0, 0, 0); + + if (verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + if (tp->englishname4 == NULL) + tp->englishname4 = pdc_strdup(p->pdc, tp->englishname6); + if (tp->englishname6 == NULL) + tp->englishname6 = pdc_strdup(p->pdc, tp->englishname4); + + return pdc_true; +} /* tt_get_tab_name */ + +void +tt_get_tab_OS_2(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_OS_2"; + tt_tab_OS_2 *tp; + int idx; + + idx = tt_tag2idx(ttf, pdf_str_OS_2); + + /* Some Apple fonts don't have an OS/2 table */ + if (idx == -1) + return; + + tp = (tt_tab_OS_2 *) pdc_malloc(p->pdc, sizeof (tt_tab_OS_2), fn); + ttf->tab_OS_2 = tp; + + tt_seek(p, ttf, (long) ttf->dir[idx].offset); + + tp->version = tt_get_ushort(p, ttf); + tp->xAvgCharWidth = tt_get_short(p, ttf); + tp->usWeightClass = tt_get_ushort(p, ttf); + tp->usWidthClass = tt_get_ushort(p, ttf); + tp->fsType = tt_get_ushort(p, ttf); + tp->ySubscriptXSize = tt_get_short(p, ttf); + tp->ySubscriptYSize = tt_get_short(p, ttf); + tp->ySubscriptXOffset = tt_get_short(p, ttf); + tp->ySubscriptYOffset = tt_get_short(p, ttf); + tp->ySuperscriptXSize = tt_get_short(p, ttf); + tp->ySuperscriptYSize = tt_get_short(p, ttf); + tp->ySuperscriptXOffset = tt_get_short(p, ttf); + tp->ySuperscriptYOffset = tt_get_short(p, ttf); + tp->yStrikeoutSize = tt_get_short(p, ttf); + tp->yStrikeoutPosition = tt_get_short(p, ttf); + tp->sFamilyClass = tt_get_ushort(p, ttf); + + tt_read(p, ttf, tp->panose, 10); + + tp->ulUnicodeRange1 = tt_get_ulong(p, ttf); + tp->ulUnicodeRange2 = tt_get_ulong(p, ttf); + tp->ulUnicodeRange3 = tt_get_ulong(p, ttf); + tp->ulUnicodeRange4 = tt_get_ulong(p, ttf); + + tt_read(p, ttf, tp->achVendID, 4); + + tp->fsSelection = tt_get_ushort(p, ttf); + tp->usFirstCharIndex = tt_get_ushort(p, ttf); + tp->usLastCharIndex = tt_get_ushort(p, ttf); + tp->sTypoAscender = tt_get_short(p, ttf); + tp->sTypoDescender = tt_get_short(p, ttf); + tp->sTypoLineGap = tt_get_short(p, ttf); + tp->usWinAscent = tt_get_ushort(p, ttf); + tp->usWinDescent = tt_get_ushort(p, ttf); + + if (tp->version >= 1) + { + tp->ulCodePageRange[0] = tt_get_ulong(p, ttf); + tp->ulCodePageRange[1] = tt_get_ulong(p, ttf); + } + else + { + tp->ulCodePageRange[0] = 0; + tp->ulCodePageRange[1] = 0; + } + + if (tp->version >= 2) + { + tp->sxHeight = tt_get_short(p, ttf); + tp->sCapHeight = tt_get_short(p, ttf); + tp->usDefaultChar = tt_get_ushort(p, ttf); + tp->usBreakChar = tt_get_ushort(p, ttf); + tp->usMaxContext = tt_get_ushort(p, ttf); + } + else + { + tp->sxHeight = 0; + tp->sCapHeight = 0; + tp->usDefaultChar = 0; + tp->usBreakChar = 0; + tp->usMaxContext = 0; + } + + /* there are fonts with inconsistent usFirstCharIndex */ + if (ttf->tab_cmap && ttf->tab_cmap->win && + tp->usFirstCharIndex != ttf->tab_cmap->win->startCount[0]) + ttf->tab_OS_2->usFirstCharIndex = ttf->tab_cmap->win->startCount[0]; + +} /* tt_get_tab_OS_2 */ + +static void +tt_get_tab_post(PDF *p, tt_file *ttf) +{ + static const char *fn = "tt_get_tab_post"; + tt_tab_post *tp = (tt_tab_post *) + pdc_malloc(p->pdc, sizeof (tt_tab_post), fn); + int idx = tt_tag2idx(ttf, pdf_str_post); + + ttf->tab_post = tp; + TT_IOCHECK(p, ttf, idx != -1); + tt_seek(p, ttf, (long) ttf->dir[idx].offset); + + tp->formatType = tt_get_fixed(p, ttf); + tp->italicAngle = tt_get_fixed(p, ttf) / (float) 65536.0; + tp->underlinePosition = tt_get_fword(p, ttf); + tp->underlineThickness = tt_get_fword(p, ttf); + tp->isFixedPitch = tt_get_ulong(p, ttf); + tp->minMemType42 = tt_get_ulong(p, ttf); + tp->maxMemType42 = tt_get_ulong(p, ttf); + tp->minMemType1 = tt_get_ulong(p, ttf); + tp->maxMemType1 = tt_get_ulong(p, ttf); +} /* tt_get_tab_post */ + +tt_file * +pdf_init_tt(PDF *p) +{ + static const char *fn = "pdf_init_tt"; + + tt_file *ttf = (tt_file *) + pdc_malloc(p->pdc, (size_t) sizeof (tt_file), fn); + + ttf->check = pdc_false; + ttf->incore = pdc_false; + ttf->img = NULL; + ttf->end = 0; + ttf->pos = 0; + + ttf->fp = (pdc_file *) 0; + ttf->n_tables = 0; + ttf->offset = 0; + ttf->dir = (tt_dirent *) 0; + + ttf->tab_cmap = (tt_tab_cmap *) 0; + ttf->tab_head = (tt_tab_head *) 0; + ttf->tab_hhea = (tt_tab_hhea *) 0; + ttf->tab_hmtx = (tt_tab_hmtx *) 0; + ttf->tab_maxp = (tt_tab_maxp *) 0; + ttf->tab_name = (tt_tab_name *) 0; + ttf->tab_post = (tt_tab_post *) 0; + ttf->tab_OS_2 = (tt_tab_OS_2 *) 0; + ttf->tab_CFF_ = (tt_tab_CFF_ *) 0; + + ttf->GID2Code = (tt_ushort *) 0; + ttf->hasGlyphNames = 0; + ttf->hasEncoding = 0; + + + ttf->utf16fontname = (char *) 0; + + return ttf; + +} /* pdf_init_tt */ + +#define PDF_O ((char) 0x4f) /* ASCII 'O' */ +#define PDF_T ((char) 0x54) /* ASCII 'T' */ + +#define PDF_t ((char) 0x74) /* ASCII 't' */ +#define PDF_r ((char) 0x72) /* ASCII 'r' */ +#define PDF_u ((char) 0x75) /* ASCII 'u' */ +#define PDF_e ((char) 0x65) /* ASCII 'e' */ + +#define PDF_c ((char) 0x63) /* ASCII 'c' */ +#define PDF_f ((char) 0x66) /* ASCII 'f' */ + +pdc_bool +pdf_test_tt_font(tt_byte *img, tt_ulong *n_fonts) +{ + tt_ushort n_tables; + + /* The TrueType (including OpenType/TT) "version" is always 0x00010000 */ + if (!(img[0] == 0x00 && img[1] == 0x01 && + img[2] == 0x00 && img[3] == 0x00)) + { + /* The OpenType/CFF version is always 'OTTO' */ + if (!(img[0] == PDF_O && img[1] == PDF_T && + img[2] == PDF_T && img[3] == PDF_O)) + { + /* Old Apple fonts have 'true' */ + if (!(img[0] == PDF_t && img[1] == PDF_r && + img[2] == PDF_u && img[3] == PDF_e)) + { + /* TrueType Collection */ + if (n_fonts == NULL || + !(img[0] == PDF_t && img[1] == PDF_t && + img[2] == PDF_c && img[3] == PDF_f)) + return pdc_false; + + /* Version is always 0x00010000 or 0x00020000 */ + if (!(img[4] == 0x00 && (img[5] == 0x01 || img[5] == 0x02) && + img[6] == 0x00 && img[7] == 0x00)) + return pdc_false; + + /* Number of fonts */ + *n_fonts = pdc_get_be_ulong(&img[8]); + return pdc_true; + } + } + } + + /* Number of tables */ + n_tables = pdc_get_be_ushort(&img[4]); + if (n_tables < 8 && n_tables > 64) /* max. 32 tables ? */ + return pdc_false; + + /* Further check of the next 6 bytes not implemented */ + + return pdc_true; +} + +pdc_bool +pdf_read_offset_tab(PDF *p, tt_file *ttf) +{ + static const char *fn = "pdf_get_tab_offset"; + tt_byte img[TT_OFFSETTAB_SIZE]; + int i; + + /* Check */ + tt_read(p, ttf, img, TT_OFFSETTAB_SIZE); + if (pdf_test_tt_font(img, NULL) == pdc_false) + { + const char *filename = ttf->filename; + pdc_bool verbose = ttf->font->verbose; + + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_TT_NOFONT, filename, 0, 0, 0); + + if (verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + /* number of table directories */ + ttf->n_tables = pdc_get_be_ushort(&img[4]); + + /* set up table directory */ + ttf->dir = (tt_dirent *) pdc_malloc(p->pdc, + (size_t) (ttf->n_tables * sizeof (tt_dirent)), fn); + + tt_seek(p, ttf, (long) (ttf->offset + TT_OFFSETTAB_SIZE)); + + for (i = 0; i < ttf->n_tables; ++i) + tt_get_dirent(p, ttf->dir + i, ttf); + + /* make sure this isn't a bitmap-only Mac font */ + if (tt_tag2idx(ttf, pdf_str_bhed) != -1) + { + const char *fontname = ttf->fontname; + pdc_bool verbose = ttf->font->verbose; + + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_TT_BITMAP, fontname, 0, 0, 0); + + if (verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + return pdc_true; + +} /* pdf_read_offset_tab */ + +static pdc_bool +pdf_read_tt(PDF *p, tt_file *ttf, pdc_font *font) +{ + (void) font; + + if (pdf_read_offset_tab(p, ttf) == pdc_false) + return pdc_false; + + /* These are all required TrueType tables; optional tables are not read. + ** + ** There's no error return; pdf_cleanup_tt() is called by all subroutines + ** before exceptions are thrown. LATER: It is a known bug that pdc_malloc() + ** exceptions can't be caught and will lead to resource leaks in this + ** context! + */ + tt_get_tab_cmap(p, ttf); + tt_get_tab_head(p, ttf); + tt_get_tab_hhea(p, ttf); + tt_get_tab_maxp(p, ttf); + tt_get_tab_hmtx(p, ttf); /* MUST be read AFTER hhea & maxp! */ + if (tt_get_tab_name(p, ttf) == pdc_false) + return pdc_false; + tt_get_tab_post(p, ttf); + tt_get_tab_OS_2(p, ttf); /* may be missing from some Apple fonts */ + + /* this is an optional table, present only in OpenType fonts */ + if (tt_get_tab_CFF_(p, ttf) == pdc_false) + return pdc_false; + + + return pdc_true; + +} /* pdf_read_tt */ + +void +pdf_cleanup_tt(PDF *p, tt_file *ttf) +{ + if (ttf->check == pdc_false && ttf->fp != (pdc_file *) 0) + pdc_fclose(ttf->fp); + + if (ttf->dir != (tt_dirent *) 0) + pdc_free(p->pdc, ttf->dir); + ttf->dir = (tt_dirent *) 0; + + + if (ttf->tab_head != (tt_tab_head *) 0) + pdc_free(p->pdc, ttf->tab_head); + if (ttf->tab_hhea != (tt_tab_hhea *) 0) + pdc_free(p->pdc, ttf->tab_hhea); + if (ttf->tab_maxp != (tt_tab_maxp *) 0) + pdc_free(p->pdc, ttf->tab_maxp); + if (ttf->tab_OS_2 != (tt_tab_OS_2 *) 0) + pdc_free(p->pdc, ttf->tab_OS_2); + if (ttf->tab_CFF_ != (tt_tab_CFF_ *) 0) + pdc_free(p->pdc, ttf->tab_CFF_); + if (ttf->tab_post != (tt_tab_post *) 0) + pdc_free(p->pdc, ttf->tab_post); + + if (ttf->tab_cmap != (tt_tab_cmap *) 0) + { + if (ttf->tab_cmap->mac != (tt_cmap0_6 *) 0) { + if (ttf->tab_cmap->mac->glyphIdArray) + pdc_free(p->pdc, ttf->tab_cmap->mac->glyphIdArray); + pdc_free(p->pdc, ttf->tab_cmap->mac); + } + + if (ttf->tab_cmap->win != (tt_cmap4 *) 0) + { + tt_cmap4 *cm4 = (tt_cmap4 *) ttf->tab_cmap->win; + + if (cm4->endCount != 0) pdc_free(p->pdc, cm4->endCount); + if (cm4->startCount != 0) pdc_free(p->pdc, cm4->startCount); + if (cm4->idDelta != 0) pdc_free(p->pdc, cm4->idDelta); + if (cm4->idRangeOffs != 0) pdc_free(p->pdc, cm4->idRangeOffs); + if (cm4->glyphIdArray != 0) pdc_free(p->pdc, cm4->glyphIdArray); + + pdc_free(p->pdc, cm4); + } + + pdc_free(p->pdc, ttf->tab_cmap); + } + + if (ttf->tab_hmtx != (tt_tab_hmtx *) 0) + { + if (ttf->tab_hmtx->metrics != (tt_metric *) 0) + pdc_free(p->pdc, ttf->tab_hmtx->metrics); + if (ttf->tab_hmtx->lsbs != (tt_fword *) 0) + pdc_free(p->pdc, ttf->tab_hmtx->lsbs); + pdc_free(p->pdc, ttf->tab_hmtx); + } + + if (ttf->tab_name != (tt_tab_name *) 0) + { + if (ttf->tab_name->namerecords != (tt_nameref *) 0) + pdc_free(p->pdc, ttf->tab_name->namerecords); + if (ttf->tab_name->englishname4 != (char *) 0) + pdc_free(p->pdc, ttf->tab_name->englishname4); + if (ttf->tab_name->englishname6 != (char *) 0) + pdc_free(p->pdc, ttf->tab_name->englishname6); + pdc_free(p->pdc, ttf->tab_name); + } + ttf->tab_name = (tt_tab_name *) 0; + + if (ttf->GID2Code != (tt_ushort *) 0) + pdc_free(p->pdc, ttf->GID2Code); + + + /* Note: do not clean up ttf->img since the data belongs to font->img + */ + + if (ttf->check == pdc_false) + pdc_free(p->pdc, ttf); + +} /* pdf_cleanup_tt */ + + +static void +pdf_set_tt_fontvalues(PDF *p, tt_file *ttf, pdc_font *font) +{ + float w; + + (void) p; + + font->llx = (float) PDF_TT2PDF(ttf->tab_head->xMin); + font->lly = (float) PDF_TT2PDF(ttf->tab_head->yMin); + font->urx = (float) PDF_TT2PDF(ttf->tab_head->xMax); + font->ury = (float) PDF_TT2PDF(ttf->tab_head->yMax); + + font->italicAngle = (float) ttf->tab_post->italicAngle; + font->isFixedPitch = (pdc_bool) ttf->tab_post->isFixedPitch; + font->underlinePosition = PDF_TT2PDF(ttf->tab_post->underlinePosition); + font->underlineThickness = PDF_TT2PDF(ttf->tab_post->underlineThickness); + + if (ttf->tab_OS_2) { + + w = ttf->tab_OS_2->usWeightClass / (float) 65; + font->StdVW = (int) (PDF_STEMV_MIN + w * w); + + /* some Apple fonts have zero values in the OS/2 table */ + if (ttf->tab_OS_2->sTypoAscender) + font->ascender = PDF_TT2PDF(ttf->tab_OS_2->sTypoAscender); + else + font->ascender = PDF_TT2PDF(ttf->tab_hhea->ascender); + + if (ttf->tab_OS_2->sTypoDescender) + font->descender = PDF_TT2PDF(ttf->tab_OS_2->sTypoDescender); + else + font->descender = PDF_TT2PDF(ttf->tab_hhea->descender); + + /* sCapHeight and sxHeight are only valid if version >= 2 */ + if (ttf->tab_OS_2->version >= 2 && ttf->tab_OS_2->sCapHeight) { + font->capHeight = PDF_TT2PDF(ttf->tab_OS_2->sCapHeight); + } else { + font->capHeight = font->ascender; /* an educated guess */ + } + + if (ttf->tab_OS_2->version >= 2 && ttf->tab_OS_2->sxHeight) { + font->xHeight = PDF_TT2PDF(ttf->tab_OS_2->sxHeight); + } else { + /* guess */ + font->xHeight = (int) ((float) 0.66 * font->ascender); + } + + } else { + +#define PDF_MACSTYLE_BOLD 0x01 + + if (ttf->tab_head->macStyle & PDF_MACSTYLE_BOLD) + font->StdVW = PDF_STEMV_BOLD; + else + font->StdVW = PDF_STEMV_NORMAL; + + /* The OS/2 table is missing from some Apple fonts */ + font->ascender = PDF_TT2PDF(ttf->tab_hhea->ascender); + font->descender = PDF_TT2PDF(ttf->tab_hhea->descender); + + /* estimate the remaining values from the known ones */ + font->xHeight = (int) ((float) 0.66 * font->descender); + font->capHeight = font->ascender; + } +} + +#ifdef PDF_UNUSED + +static pdc_bool +tt_supports_cp(char *name, unsigned *cp_range) +{ + typedef struct + { + const char * s; + int i; + } str_int; + + static const str_int n2i[] = + { + { "1250", TT_CP1250 }, + { "1251", TT_CP1251 }, + { "1252", TT_CP1252 }, + { "1253", TT_CP1253 }, + { "1254", TT_CP1254 }, + { "1255", TT_CP1255 }, + { "1256", TT_CP1256 }, + { "1257", TT_CP1257 }, + { "1258", TT_CP1258 }, + { "1361", TT_CP1361 }, + { "437", TT_CP437 }, + { "708", TT_CP708 }, + { "737", TT_CP737 }, + { "775", TT_CP775 }, + { "850", TT_CP850 }, + { "852", TT_CP852 }, + { "855", TT_CP855 }, + { "857", TT_CP857 }, + { "860", TT_CP860 }, + { "861", TT_CP861 }, + { "862", TT_CP862 }, + { "863", TT_CP863 }, + { "864", TT_CP864 }, + { "865", TT_CP865 }, + { "866", TT_CP866 }, + { "869", TT_CP869 }, + { "874", TT_CP874 }, + { "932", TT_CP932 }, + { "936", TT_CP936 }, + { "949", TT_CP949 }, + { "950", TT_CP950 }, + }; + + int lo = 0; + int hi = (sizeof n2i) / (sizeof (str_int)); + + while (lo != hi) + { + int idx = (lo + hi) / 2; + int cmp = strcmp(name, n2i[idx].s); + + if (cmp == 0) + { + int i = n2i[idx].i; + + return (cp_range[i > 31] & (1 << (i & 0x1F))) != 0; + } + + if (cmp < 0) + hi = idx; + else + lo + idx + 1; + } + + return pdc_false; +} /* tt_supports_cp */ + +#endif /* PDF_UNUSED */ + +pdc_bool +pdf_get_metrics_tt(PDF *p, pdc_font *font, const char *fontname, + pdc_encoding enc, const char *filename) +{ + static const char *fn = "pdf_get_metrics_tt"; + float filesize; + int foundChars, code, ncodes, nwidths, gidx = 0; + tt_file *ttf; + pdc_bool retval; + + /* + * Initialisation + */ + ttf = pdf_init_tt(p); + ttf->incore = pdc_true; + ttf->img = (tt_byte *) font->img; + ttf->pos = ttf->img; + ttf->end = ttf->img + font->filelen; + filesize = (float) (font->filelen / 1024.0); + + ttf->filename = filename; + ttf->fontname = fontname; + ttf->font = font; + + /* + * Read font file + */ + retval = pdf_read_tt(p, ttf, font); + if (retval == pdc_false) + return pdc_false; + + /* + * Font type + */ + if (ttf->tab_CFF_) { + font->type = pdc_Type1C; + font->cff_offset = (long) ttf->tab_CFF_->offset; + font->cff_length = ttf->tab_CFF_->length; + } else { + font->type = pdc_TrueType; + } + + /* These tables are not present in OT fonts */ + if (font->type != pdc_Type1C) { + TT_IOCHECK(p, ttf, tt_tag2idx(ttf, pdf_str_glyf) != -1); + TT_IOCHECK(p, ttf, tt_tag2idx(ttf, pdf_str_loca) != -1); + } + + /* Number of Glyphs */ + if (ttf->tab_maxp->numGlyphs <= 1) + { + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_TT_NOGLYFDESC, fontname, 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + /* + * Encoding + */ + font->isstdlatin = pdc_true; + if (ttf->tab_cmap->mac && !ttf->tab_cmap->win) + { + /* MacRoman font */ + if (enc >= pdc_builtin && enc != pdc_macroman) + { + if (font->verbose) + { + pdc_warning(p->pdc, PDF_E_FONT_FORCEENC, + pdf_get_encoding_name(p, pdc_macroman), + pdf_get_encoding_name(p, enc), fontname, 0); + } + enc = pdc_macroman; + } + if (!p->encodings[pdc_macroman].ev) + p->encodings[pdc_macroman].ev = + pdc_copy_core_encoding(p->pdc, "macroman"); + } + else if (ttf->tab_cmap->win) + { + if (ttf->tab_cmap->win->encodingID == tt_wenc_symbol) + { + /* Symbol font */ + font->isstdlatin = pdc_false; + + /* 8-bit encoding: We enforce builtin encoding */ + if (enc >= 0) + { + if (font->verbose) + { + pdc_warning(p->pdc, PDF_E_FONT_FORCEENC, + pdf_get_encoding_name(p, pdc_builtin), + pdf_get_encoding_name(p, enc), fontname, 0); + } + enc = pdc_builtin; + } + } + else if (!ttf->tab_cmap->mac) + { + /* has no MacRoman cmap */ + font->hasnomac = pdc_true; + } + } + else + { + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_TT_BADCMAP, fontname, 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + font->encoding = enc; + + + /* builtin encoding but text font */ + if (enc == pdc_builtin && font->isstdlatin == pdc_true) + { + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_FONT_BADENC, + fontname, pdf_get_encoding_name(p, enc), 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + + /* /FontName in FontDescriptor */ + font->name = pdc_strdup(p->pdc, ttf->tab_name->englishname4); + + /* /BaseFont name */ + font->ttname = pdc_strdup(p->pdc, ttf->tab_name->englishname6); + + +#define PDF_RESTRICTED_TT_EMBEDDING 0x02 + /* check embedding flags */ + if ((font->embedding) && ttf->tab_OS_2 && + ttf->tab_OS_2->fsType == PDF_RESTRICTED_TT_EMBEDDING) + { + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_TT_EMBED, fontname, 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + + + /* Save font values */ + pdf_set_tt_fontvalues(p, ttf, font); + + /* Allocate encoding dependent arrays */ + font->numOfGlyphs = ttf->tab_maxp->numGlyphs; + ncodes = font->numOfCodes; + nwidths = font->numOfCodes; + + + font->code2GID = (pdc_ushort *) pdc_calloc(p->pdc, + font->numOfCodes * sizeof (pdc_ushort), fn); + ttf->GID2Code = (tt_ushort *) pdc_calloc(p->pdc, + font->numOfGlyphs * sizeof (tt_ushort), fn); + if (nwidths) + font->widths = (int *) pdc_calloc(p->pdc, nwidths * sizeof(int), fn); + + + /* + * Build the char width tables for the font, set mappings GID <-> Code, + * and count the characters. + */ + foundChars = 0; + for (code = 0; code < ncodes; code++) + { + gidx = tt_code2gidx(p, ttf, font, code); + if (gidx == -1) + return pdc_false; + if (gidx) + { + /* we prefer the first occurence of gidx (SPACE vs. NBSP) */ + if (!ttf->GID2Code[gidx]) + ttf->GID2Code[gidx] = (tt_ushort) code; + if (font->GID2code) + font->GID2code[gidx] = (tt_ushort) code; + foundChars++; + } + + switch (enc) + { + + default: + font->widths[code] = tt_gidx2width(p, ttf, gidx); + break; + } + + font->code2GID[code] = (pdc_ushort) gidx; + } + + /* No characters found */ + if (!foundChars) + { + pdf_cleanup_tt(p, ttf); + pdc_set_errmsg(p->pdc, PDF_E_FONT_BADENC, fontname, + pdf_get_encoding_name(p, enc), 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_false; + } + else + { + + + pdf_cleanup_tt(p, ttf); + } + + if (!pdf_make_fontflag(p, font)) + return pdc_false; + + return pdc_true; +} + +static pdc_bool +pdf_check_and_read_ttc(PDF *p, pdc_file *fp, + const char *filename, const char *fontname, + pdc_font *font, tt_ulong n_fonts) +{ + static const char *fn = "pdf_check_and_read_ttc"; + tt_file *ttf; + char *utf16fontname = NULL; + char *fontname_p = (char *) fontname; + pdc_bool retval = pdc_false; + pdc_text_format textformat = pdc_bytes; + pdc_text_format targettextformat = pdc_utf16be; + int i, inlen, outlen; + + /* initialize */ + ttf = pdf_init_tt(p); + ttf->check = pdc_true; + ttf->fp = fp; + ttf->filename = filename; + ttf->fontname = fontname; + ttf->font = font; + + /* create UTF-16-BE font name string for searching in font file */ + inlen = (int) strlen(fontname_p); + if (pdc_is_utf8_unicode(fontname_p)) + textformat = pdc_utf8; + if (pdc_convert_string(p->pdc, textformat, NULL, + (pdc_byte *) fontname_p, inlen, + &targettextformat, NULL, + (pdc_byte **) &utf16fontname, &outlen, + PDC_CONV_NOBOM, font->verbose)) + { + pdf_cleanup_tt(p, ttf); + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + return pdc_false; + } + + /* search font */ + for (i = 0; i < (int)n_fonts; ++i) + { + if (i) pdf_cleanup_tt(p, ttf); + + tt_seek(p, ttf, (long) (TT_OFFSETTAB_SIZE + i * sizeof(tt_ulong))); + ttf->offset = tt_get_ulong(p, ttf); + tt_seek(p, ttf, (long) ttf->offset); + + /* Offset Table */ + if (!pdf_read_offset_tab(p, ttf)) + break; + + /* font name match in Naming Table */ + ttf->utf16fontname = utf16fontname; + ttf->fnamelen = outlen; + if (tt_get_tab_name(p, ttf)) + break; + } + pdc_free(p->pdc, utf16fontname); + + /* font found */ + if (i < (int)n_fonts) + { + tt_byte *pos; + tt_ulong headlen, dirlen, tablen, length, offset; + + /* create file in memory */ + tablen = 0; + dirlen = 4 * sizeof(tt_ulong); + headlen = (tt_ulong) (TT_OFFSETTAB_SIZE + ttf->n_tables * dirlen); + font->filelen = headlen; + for (i = 0; i < ttf->n_tables; i++) + { + length = ttf->dir[i].length; + if (length > tablen) tablen = length; + font->filelen += length; + } + font->img = (pdc_byte *) pdc_malloc(p->pdc, font->filelen, fn); + + /* read font file */ + tt_seek(p, ttf, (long) ttf->offset); + tt_read(p, ttf, font->img, headlen); + pos = font->img + headlen; + for (i = 0; i < ttf->n_tables; i++) + { + length = ttf->dir[i].length; + tt_seek(p, ttf, (long) ttf->dir[i].offset); + tt_read(p, ttf, pos, length); + ttf->dir[i].offset = (unsigned int) (pos - font->img); + pos += length; + } + + /* correct offsets in Table Directory */ + pos = font->img + TT_OFFSETTAB_SIZE + 2 * sizeof(tt_ulong); + for (i = 0; i < ttf->n_tables; i++) + { + offset = ttf->dir[i].offset; + pos[0] = (tt_byte) (offset >> 24); + pos[1] = (tt_byte) (offset >> 16); + pos[2] = (tt_byte) (offset >> 8); + pos[3] = (tt_byte) (offset); + pos += dirlen; + } + retval = pdc_true; + } + else + { + pdc_set_errmsg(p->pdc, PDF_E_TTC_NOTFOUND, fontname, filename, 0, 0); + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + } + + ttf->check = pdc_false; + pdf_cleanup_tt(p, ttf); + return retval; +} + +int +pdf_check_tt_font(PDF *p, const char *filename, const char *fontname, + pdc_font *font) +{ + pdc_file *fp; + tt_byte img[TT_OFFSETTAB_SIZE]; + pdc_bool ismem = pdc_false; + tt_ulong n_fonts = 0; + int retval = pdc_undef; + + if ((fp = pdf_fopen(p, filename, "font ", PDC_FILE_BINARY)) == NULL) + { + if (font->verbose_open) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + } + else + { + retval = pdc_false; + if (PDC_OK_FREAD(fp, img, TT_OFFSETTAB_SIZE)) + { + retval = pdf_test_tt_font(img, &n_fonts); + if (retval == pdc_true) + { + if (n_fonts > 1) + { + retval = pdf_check_and_read_ttc(p, fp, filename, fontname, + font, n_fonts); + } + else + { + font->img = (pdc_byte *) + pdc_freadall(fp, &font->filelen, &ismem); + pdc_fclose(fp); + } + if (retval == pdc_true) + { + if (font->filelen == 0) + { + pdc_set_errmsg(p->pdc, + PDC_E_IO_NODATA, filename, 0, 0, 0); + + if (font->verbose) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + retval = pdc_false; + } + else if (ismem) + { + font->imgname = pdc_strdup(p->pdc, filename); + pdf_lock_pvf(p, font->imgname); + } + } + fp = NULL; + } + } + if (fp) pdc_fclose(fp); + } + + return retval; +} + + +#endif /* PDF_TRUETYPE_SUPPORTED */ diff --git a/src/libs/pdflib/libs/pdflib/p_truetype.h b/src/libs/pdflib/libs/pdflib/p_truetype.h new file mode 100644 index 0000000000..01f27ec818 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_truetype.h @@ -0,0 +1,437 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_truetype.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib TrueType typedefs, structures, and enums + * + */ + +typedef unsigned char tt_byte; +typedef char tt_char; +typedef unsigned short tt_ushort; +typedef short tt_short; +typedef unsigned int tt_ulong; +typedef int tt_long; + +typedef long tt_fixed; +typedef short tt_fword; +typedef unsigned short tt_ufword; + +#define tt_get_fixed tt_get_long +#define tt_get_fword tt_get_short +#define tt_get_ufword tt_get_ushort + +#undef ROUND +#define ROUND(x) (((x) < 0) ? ceil((x) - 0.5) : floor((x) + 0.5)) + +#define TT_XKERNPAIR_CHUNKSIZE 256 + +#define TT_NUMSTDSTRINGS 391 + +#define TT_OFFSETTAB_SIZE 12 + +#define TT_MINUSEDCHARS_SIZE 32 + +typedef struct +{ + char tag[5]; + tt_ulong checksum; + tt_ulong offset; + tt_ulong length; +} tt_dirent; + +typedef enum +{ + tt_pfid_apple, + tt_pfid_mac, + tt_pfid_iso, + tt_pfid_win +} tt_platform_id; + +typedef enum +{ + tt_wenc_symbol, + tt_wenc_text +} tt_win_encoding_id; + +/* format 4 encoding table: +*/ +typedef struct +{ + tt_ushort encodingID; + tt_ushort format; + tt_ushort length; + tt_ushort version; + tt_ushort segCountX2; /* segCount * 2 */ + tt_ushort searchRange; + tt_ushort entrySelector; + tt_ushort rangeShift; + tt_ushort * endCount; /* [segCount] */ + tt_ushort * startCount; /* [segCount] */ + tt_short * idDelta; /* [segCount] */ + tt_ushort * idRangeOffs; /* [segCount] */ + int numGlyphIds; + tt_ushort * glyphIdArray; +} tt_cmap4; + +/* combined data structure for format 0 and format 6 encoding tables: +*/ +typedef struct +{ + tt_ushort format; + tt_ushort length; + tt_ushort language; + tt_ushort firstCode; + tt_ushort entryCount; + tt_ushort *glyphIdArray; +} tt_cmap0_6; + +typedef struct +{ + tt_ushort version; + tt_ushort numEncTabs; + + tt_cmap4 *win; + tt_cmap0_6 *mac; +} tt_tab_cmap; + +typedef struct +{ + tt_fixed version; + tt_fixed fontRevision; + tt_ulong checkSumAdjustment; + tt_ulong magicNumber; + tt_ushort flags; + tt_ushort unitsPerEm; + tt_ulong created[2]; + tt_ulong modified[2]; + tt_fword xMin, yMin; + tt_fword xMax, yMax; + tt_ushort macStyle; + tt_ushort lowestRecPPEM; + tt_short fontDirectionHint; + tt_short indexToLocFormat; + tt_short glyphDataFormat; +} tt_tab_head; + +typedef struct +{ + tt_fixed version; + tt_fword ascender; + tt_fword descender; + tt_fword lineGap; + tt_ufword advanceWidthMax; + tt_fword minLeftSideBearing; + tt_fword minRightSideBearing; + tt_fword xMaxExtent; + tt_short caretSlopeRise; + tt_short caretSlopeRun; + tt_short res1; + tt_short res2; + tt_short res3; + tt_short res4; + tt_short res5; + tt_short metricDataFormat; + tt_ushort numberOfHMetrics; +} tt_tab_hhea; + +typedef struct +{ + tt_ufword advanceWidth; + tt_fword lsb; +} tt_metric; + +typedef struct +{ + tt_metric * metrics; + tt_fword * lsbs; +} tt_tab_hmtx; + +typedef struct +{ + tt_fixed version; + tt_ushort numGlyphs; + tt_ushort maxPoints; + tt_ushort maxContours; + tt_ushort maxCompositePoints; + tt_ushort maxCompositeContours; + tt_ushort maxZones; + tt_ushort maxTwilightPoints; + tt_ushort maxStorage; + tt_ushort maxFunctionDefs; + tt_ushort maxInstructionDefs; + tt_ushort maxStackElements; + tt_ushort maxSizeOfInstructions; + tt_ushort maxComponentElements; + tt_ushort maxComponentDepth; +} tt_tab_maxp; + +typedef struct +{ + tt_ushort platform; + tt_ushort language; + tt_ushort namid; + tt_ushort length; + tt_ushort offset; +} tt_nameref; + +typedef struct +{ + tt_ushort format; + tt_ushort numNameRecords; + tt_ushort offsetStrings; + tt_nameref *namerecords; + char *englishname4; + char *englishname6; +} tt_tab_name; + +typedef struct +{ + tt_ushort version; + tt_short xAvgCharWidth; + tt_ushort usWeightClass; + tt_ushort usWidthClass; + tt_ushort fsType; /* tt_short? */ + tt_short ySubscriptXSize; + tt_short ySubscriptYSize; + tt_short ySubscriptXOffset; + tt_short ySubscriptYOffset; + tt_short ySuperscriptXSize; + tt_short ySuperscriptYSize; + tt_short ySuperscriptXOffset; + tt_short ySuperscriptYOffset; + tt_short yStrikeoutSize; + tt_short yStrikeoutPosition; + tt_ushort sFamilyClass; /* ttt_short? */ + tt_byte panose[10]; + tt_ulong ulUnicodeRange1; + tt_ulong ulUnicodeRange2; + tt_ulong ulUnicodeRange3; + tt_ulong ulUnicodeRange4; + tt_char achVendID[4]; + tt_ushort fsSelection; + tt_ushort usFirstCharIndex; + tt_ushort usLastCharIndex; + + /* tt_ushort according to spec; obviously a spec bug. + */ + tt_short sTypoAscender; + tt_short sTypoDescender; + tt_short sTypoLineGap; + + tt_ushort usWinAscent; + tt_ushort usWinDescent; + + /* if version >= 1 + */ + tt_ulong ulCodePageRange[2]; + + /* if version >= 2 (according to OpenType spec) + */ + tt_short sxHeight; + tt_short sCapHeight; + tt_ushort usDefaultChar; + tt_ushort usBreakChar; + tt_ushort usMaxContext; +} tt_tab_OS_2; + +typedef struct +{ + tt_ushort sid; + tt_byte *string; +} tt_string_tab; + +typedef struct +{ + tt_ulong offset; + tt_ulong length; +} tt_tab_CFF_; + +typedef struct +{ + tt_fixed formatType; + double italicAngle; + tt_fword underlinePosition; + tt_fword underlineThickness; + tt_ulong isFixedPitch; + tt_ulong minMemType42; + tt_ulong maxMemType42; + tt_ulong minMemType1; + tt_ulong maxMemType1; + +} tt_tab_post; + +typedef struct +{ + tt_ushort start; + tt_ushort end; + tt_ushort cclass; +} tt_record_classrange; + +typedef struct +{ + tt_ushort left; + tt_ushort right; + tt_short value; + tt_short dominant; +} tt_xkern_pair; + +typedef struct +{ + tt_xkern_pair *pairs; + int capacity; + int number; +} tt_xkern_pair_list; + +typedef struct +{ + pdc_bool check; /* check for fontname */ + pdc_bool incore; /* whole font in-core */ + tt_byte * img; /* in-core TT font file image */ + tt_byte * end; /* first byte above image buf */ + tt_byte * pos; /* current "file" position */ + pdc_file * fp; + + int n_tables; + tt_ulong offset; + tt_dirent * dir; + + /* "required" tables: + */ + tt_tab_cmap *tab_cmap; + tt_tab_head *tab_head; + tt_tab_hhea *tab_hhea; + tt_tab_hmtx *tab_hmtx; + tt_tab_maxp *tab_maxp; + tt_tab_name *tab_name; + tt_tab_post *tab_post; + tt_tab_OS_2 *tab_OS_2; + tt_tab_CFF_ *tab_CFF_; + + tt_ushort *GID2Code; /* [ttf->tab_maxp->numGlyphs] */ + /* glyphid: Code = Unicode */ + int hasGlyphNames; + int hasEncoding; + + + const char *filename; /* font file name */ + const char *fontname; /* font API name */ + char *utf16fontname; /* UTF-16-BE font name for TTC fonts */ + int fnamelen; /* font name length */ + pdc_font *font; +} tt_file; + +/* TrueType table names, defined as octal codes */ +#define pdf_str_ttcf "\164\164\143\146" +#define pdf_str_bhed "\142\150\145\144" +#define pdf_str_CFF_ "\103\106\106\040" +#define pdf_str_cvt_ "\143\166\164\040" +#define pdf_str_cmap "\143\155\141\160" +#define pdf_str_fpgm "\146\160\147\155" +#define pdf_str_glyf "\147\154\171\146" +#define pdf_str_GPOS "\107\120\117\123" +#define pdf_str_head "\150\145\141\144" +#define pdf_str_hhea "\150\150\145\141" +#define pdf_str_hmtx "\150\155\164\170" +#define pdf_str_kern "\153\145\162\156" +#define pdf_str_loca "\154\157\143\141" +#define pdf_str_maxp "\155\141\170\160" +#define pdf_str_name "\156\141\155\145" +#define pdf_str_OS_2 "\117\123\057\062" /* OS/2 */ +#define pdf_str_post "\160\157\163\164" +#define pdf_str_prep "\160\162\145\160" + +/* Windows code page numbers */ +#define TT_CP1252 0 /* Latin 1 */ +#define TT_CP1250 1 /* Latin 2: Eastern Europe */ +#define TT_CP1251 2 /* Cyrillic */ +#define TT_CP1253 3 /* Greek */ +#define TT_CP1254 4 /* Turkish */ +#define TT_CP1255 5 /* Hebrew */ +#define TT_CP1256 6 /* Arabic */ +#define TT_CP1257 7 /* Windows Baltic */ +#define TT_CP1258 8 /* Vietnamese */ +#define TT_CP874 16 /* Thai */ +#define TT_CP932 17 /* JIS/Japan */ +#define TT_CP936 18 /* Chinese: Simplified chars--PRC and Singapore */ +#define TT_CP949 19 /* Korean Wansung */ +#define TT_CP950 20 /* Chinese: Traditional chars--Taiwan and Hong Kong */ +#define TT_CP1361 21 /* Korean Johab */ +#define TT_CP869 48 /* IBM Greek */ +#define TT_CP866 49 /* MS-DOS Russian */ +#define TT_CP865 50 /* MS-DOS Nordic */ +#define TT_CP864 51 /* Arabic */ +#define TT_CP863 52 /* MS-DOS Canadian French */ +#define TT_CP862 53 /* Hebrew */ +#define TT_CP861 54 /* MS-DOS Icelandic */ +#define TT_CP860 55 /* MS-DOS Portuguese */ +#define TT_CP857 56 /* IBM Turkish */ +#define TT_CP855 57 /* IBM Cyrillic; primarily Russian */ +#define TT_CP852 58 /* Latin 2 */ +#define TT_CP775 59 /* MS-DOS Baltic */ +#define TT_CP737 60 /* Greek; former 437 G */ +#define TT_CP708 61 /* Arabic; ASMO 708 */ +#define TT_CP850 62 /* WE/Latin 1 */ +#define TT_CP437 63 /* US */ + +/* Composite font flags. */ +/* See Reference of OpenType: glyf - Glyf Data */ +#define ARGS_ARE_WORDS 0x001 +#define ARGS_ARE_XY_VALUES 0x002 +#define ROUND_XY_TO_GRID 0x004 +#define WE_HAVE_A_SCALE 0x008 +/* reserved 0x010 */ +#define MORE_COMPONENTS 0x020 +#define WE_HAVE_AN_XY_SCALE 0x040 +#define WE_HAVE_A_2X2 0x080 +#define WE_HAVE_INSTR 0x100 +#define USE_MY_METRICS 0x200 + + +/* Functions */ + +#define PDF_TT2PDF(v) (int) ROUND(v * 1000.0f / ttf->tab_head->unitsPerEm) + +#define TT_ASSERT(p, ttf, cond) \ + ((cond) ? (void) 0 : tt_assert(p, ttf)) + +#define TT_IOCHECK(p, ttf, cond) \ + ((cond) ? (void) 0 : tt_error(p, ttf)) + +tt_file *pdf_init_tt(PDF *p); +pdc_bool pdf_read_offset_tab(PDF *p, tt_file *ttf); +pdc_bool pdf_test_tt_font(tt_byte *img, tt_ulong *n_fonts); +void pdf_cleanup_tt(PDF *p, tt_file *ttf); + +int tt_tag2idx(tt_file *ttf, char *tag); +void tt_get_tab_maxp(PDF *p, tt_file *ttf); +void tt_get_tab_head(PDF *p, tt_file *ttf); +void tt_get_tab_cmap(PDF *p, tt_file *ttf); +pdc_bool tt_get_tab_CFF_(PDF *p, tt_file *ttf); +void tt_get_tab_OS_2(PDF *p, tt_file *ttf); + + + +void tt_assert(PDF *p, tt_file *ttf); +void tt_error(PDF *p, tt_file *ttf); +void tt_seek(PDF *p, tt_file *ttf, long offset); +void tt_read(PDF *p, tt_file *ttf, void *buf, unsigned int nbytes); +long tt_tell(PDF *p, tt_file *ttf); +tt_ushort tt_get_ushort(PDF *p, tt_file *ttf); +tt_short tt_get_short(PDF *p, tt_file *ttf); +tt_ulong tt_get_ulong3(PDF *p, tt_file *ttf); +tt_ulong tt_get_ulong(PDF *p, tt_file *ttf); +tt_long tt_get_long(PDF *p, tt_file *ttf); +tt_ulong tt_get_offset(PDF *p, tt_file *ttf, tt_byte offsize); + + diff --git a/src/libs/pdflib/libs/pdflib/p_type1.c b/src/libs/pdflib/libs/pdflib/p_type1.c new file mode 100644 index 0000000000..a20c32d890 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_type1.c @@ -0,0 +1,383 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_type1.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib Type1 font handling routines + * + */ + +#include "p_intern.h" +#include "p_font.h" + + +/* Type 1 font portions: ASCII, encrypted, zeros */ +typedef enum { t1_ascii, t1_encrypted, t1_zeros } pdf_t1portion; + +typedef struct { + pdf_t1portion portion; + size_t length[4]; + pdc_file *fontfile; + pdc_byte *img; /* in-core Type1 font file image */ + pdc_byte *end; /* first byte above image buf */ + pdc_byte *pos; /* current "file" position */ +} t1_private_data; + + +#define PFA_TESTBYTE 4 + +#define PFA_STARTSEQU "%!PS" + +#define PDF_CURRENTFILE "currentfile eexec" + + +#define LINEBUFLEN 256 + +/* + * PFA files are assumed to be encoded in host format. Therefore + * we must use literal strings and characters for interpreting the + * font file. + */ + +static int +PFA_data_fill(PDF *p, PDF_data_source *src) +{ + static const char *fn = "PFA_data_fill"; +#ifndef PDFLIB_EBCDIC + static const char HexToBin['F' - '0' + 1] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, + 0, 10, 11, 12, 13, 14, 15 + }; +#else +#endif + char *s, *c; + int i; + int len; + t1_private_data *t1_private; + pdf_t1portion t1portion; + + t1_private = (t1_private_data *) src->private_data; + + if (src->buffer_start == NULL) { + src->buffer_start = (pdc_byte *) pdc_malloc(p->pdc, LINEBUFLEN + 1, fn); + src->buffer_length = LINEBUFLEN; + } + + + if ((s = pdc_fgets_comp((char *) src->buffer_start, LINEBUFLEN, + t1_private->fontfile)) == NULL) + return pdc_false; + + /* set unix line end */ + len = (int) strlen(s); + s[len] = '\n'; + len++; + s[len] = 0; + + /* check for line of zeros: set t1_zero flag if found */ + if (*s == '0') { + for (i = 0; s[i] == '0'; i++) { + /* */ ; + } + if (s[i] == '\n') + t1_private->portion = t1_zeros; + } + + /* check whether font data portion follows: set t1_encrypted flag later */ + t1portion = t1_private->portion; + if (t1_private->portion != t1_encrypted && + !strncmp((const char *)s, PDF_CURRENTFILE, strlen(PDF_CURRENTFILE))) + t1portion = t1_encrypted; + + src->next_byte = src->buffer_start; + + switch (t1_private->portion) { + case t1_ascii: + t1_private->length[1] += (size_t) len; + src->bytes_available = (size_t) len; + break; + + case t1_encrypted: + src->bytes_available = 0; + + /* Convert to upper case for safe binary conversion */ + for (c = s; *c != '\n'; c++) { + *c = (char) toupper(*c); + } + + /* convert ASCII to binary in-place */ + for (i=0; s[i] != '\n'; i += 2) { + if ((!isxdigit(s[i]) && !isspace(s[i])) || + (!isxdigit(s[i+1]) && !isspace(s[i+1]))) { + pdc_fclose(t1_private->fontfile); + pdc_error(p->pdc, PDF_E_FONT_CORRUPT, "PFA", + "?", 0, 0); + } +#ifndef PDFLIB_EBCDIC + s[i/2] = (char) (16*HexToBin[s[i]-'0'] + HexToBin[s[i+1]-'0']); +#else +#endif + src->bytes_available++; + } + t1_private->length[2] += src->bytes_available; + break; + + case t1_zeros: + t1_private->length[3] += (size_t) len; + src->bytes_available = (size_t) len; + break; + } + + t1_private->portion = t1portion; + + return pdc_true; +} + +#define PFB_MARKER 0x80 +#define PFB_ASCII 1 +#define PFB_BINARY 2 +#define PFB_EOF 3 + +int +pdf_t1check_fontfile(PDF *p, pdc_font *font, pdc_file *fp) +{ + unsigned char magic[PFA_TESTBYTE]; + const char *stemp = NULL; + + + if (fp) + { + pdc_fread(magic, 1, PFA_TESTBYTE, fp); + stemp = pdc_file_name(fp); + } + else if (font->img) + { + strncpy((char *) magic, (const char *)font->img, PFA_TESTBYTE); + stemp = font->name; + } + + /* try to identify PFA files */ + if (magic[0] != PFB_MARKER) + { + char startsequ[5]; + + strcpy(startsequ, PFA_STARTSEQU); + + if (strncmp((const char *) magic, startsequ, PFA_TESTBYTE)) + { + pdc_set_errmsg(p->pdc, PDF_E_T1_NOFONT, stemp, 0, 0, 0); + + if (font->verbose_open) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + + return pdc_undef; + } + return pdc_false; + } + return pdc_true; +} + +static int +pdf_t1getc(t1_private_data *t1) +{ + int val; + + if (t1->fontfile) { + return pdc_fgetc(t1->fontfile); + } + val = (int) *t1->pos; + t1->pos++; + + return val; +} + +static pdc_bool +pdf_read_pfb_segment(PDF *p, PDF_data_source *src, t1_private_data *t1, int i) +{ + static const char *fn = "pdf_read_pfb_segment"; + size_t length, len; + + length = (size_t) (pdf_t1getc(t1) & 0xff); + length |= (size_t) (pdf_t1getc(t1) & 0xff) << 8; + length |= (size_t) (pdf_t1getc(t1) & 0xff) << 16; + length |= (size_t) (pdf_t1getc(t1) & 0xff) << 24; + + if (src->buffer_start) + pdc_free(p->pdc, (void *) src->buffer_start); + src->buffer_start = (pdc_byte *) pdc_malloc(p->pdc, length, fn); + + if (t1->fontfile) { + len = pdc_fread(src->buffer_start, 1, length, t1->fontfile); + } else { + len = length; + if (t1->pos + len > t1->end) + len = (unsigned int)(t1->end - t1->pos); + memcpy(src->buffer_start, t1->pos, len); + t1->pos += len; + } + + t1->length[i] = len; + src->next_byte = src->buffer_start; + src->bytes_available = len; + + return (len != length) ? pdc_true : pdc_false;; +} + +static int +PFB_data_fill(PDF *p, PDF_data_source *src) +{ + t1_private_data *t1; + unsigned char c, type; + pdc_bool err = pdc_false; + + t1 = (t1_private_data *) src->private_data; + + c = (unsigned char) pdf_t1getc(t1); + type = (unsigned char) pdf_t1getc(t1); + + if (t1->length[1] == (size_t) 0) { + if (c != PFB_MARKER || type != PFB_ASCII) { + err = pdc_true; + } else { + err = pdf_read_pfb_segment(p, src, t1, 1); + } + + } else if (t1->length[2] == (size_t) 0) { + if (c != PFB_MARKER || type != PFB_BINARY) { + err = pdc_true; + } else { + err = pdf_read_pfb_segment(p, src, t1, 2); + } + + } else if (t1->length[3] == 0) { + if (c != PFB_MARKER || type != PFB_ASCII) { + err = pdc_true; + } else { + err = pdf_read_pfb_segment(p, src, t1, 3); + } + } else if (c != PFB_MARKER || type != PFB_EOF) { + err = pdc_true; + } else { + return pdc_false; + } + + if (err) { + if (t1->fontfile) + pdc_fclose(t1->fontfile); + pdc_error(p->pdc, PDF_E_FONT_CORRUPT, "PFB", "?", 0, 0); + } + + return pdc_true; +} + +static void +t1data_terminate(PDF *p, PDF_data_source *src) +{ + pdc_free(p->pdc, (void *) src->buffer_start); +} + +static void +t1data_init(PDF *p, PDF_data_source *src) +{ + t1_private_data *t1_private; + + (void) p; + + t1_private = (t1_private_data *) src->private_data; + + t1_private->portion = t1_ascii; + t1_private->length[1] = (size_t) 0; + t1_private->length[2] = (size_t) 0; + t1_private->length[3] = (size_t) 0; + + src->buffer_start = NULL; +} + + +PDF_data_source* +pdf_make_t1src (PDF *p, pdc_font *font, PDF_data_source *t1src) +{ + static const char *fn = "pdf_make_t1src"; + t1_private_data *t1_private; + pdc_file *fontfile = NULL; + int ispfb; + + + if (font->fontfilename) + { + fontfile = pdf_fopen(p, font->fontfilename, "PostScript Type 1 ", + PDC_FILE_BINARY); + if (fontfile == NULL) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + } + + ispfb = pdf_t1check_fontfile(p, font, fontfile); + if (ispfb == pdc_undef) + return NULL; + + t1src->private_data = (unsigned char *) + pdc_malloc(p->pdc, sizeof(t1_private_data), fn); + t1_private = (t1_private_data *) t1src->private_data; + + if (font->fontfilename) { + pdc_fclose(fontfile); + if (ispfb) + t1_private->fontfile = pdf_fopen(p, font->fontfilename, "PFB ", + PDC_FILE_BINARY); + else + t1_private->fontfile = pdf_fopen(p, font->fontfilename, "PFA ", 0); + + if (t1_private->fontfile == NULL) + pdc_error(p->pdc, -1, 0, 0, 0, 0); + } else if (font->img) { + + t1_private->fontfile = NULL; + t1_private->img = font->img; + t1_private->pos = font->img; + t1_private->end = font->img + font->filelen; + + } else { + return NULL; + } + + t1src->init = t1data_init; + t1src->fill = ispfb ? PFB_data_fill : PFA_data_fill; + t1src->terminate = t1data_terminate; + + return t1src; +} + +void +pdf_put_length_objs(PDF *p, PDF_data_source *t1src, + pdc_id length1_id, pdc_id length2_id, pdc_id length3_id) +{ + pdc_begin_obj(p->out, length1_id); /* Length1 object */ + pdc_printf(p->out, "%ld\n", + (long) ((t1_private_data *) t1src->private_data)->length[1]); + pdc_end_obj(p->out); + + pdc_begin_obj(p->out, length2_id); /* Length2 object */ + pdc_printf(p->out, "%ld\n", + (long) ((t1_private_data *) t1src->private_data)->length[2]); + pdc_end_obj(p->out); + + pdc_begin_obj(p->out, length3_id); /* Length3 object */ + pdc_printf(p->out, "%ld\n", + (long) ((t1_private_data *) t1src->private_data)->length[3]); + pdc_end_obj(p->out); + + + if (((t1_private_data *) t1src->private_data)->fontfile) + pdc_fclose(((t1_private_data *) t1src->private_data)->fontfile); + + pdc_free(p->pdc, (void *) t1src->private_data); +} diff --git a/src/libs/pdflib/libs/pdflib/p_type3.c b/src/libs/pdflib/libs/pdflib/p_type3.c new file mode 100644 index 0000000000..a266590411 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_type3.c @@ -0,0 +1,476 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_type3.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * Routines for Type 3 (user-defined) fonts + * + */ + +#include "p_intern.h" +#include "p_font.h" +#include "p_image.h" + +int +pdf_get_t3colorized(PDF *p) +{ + return p->t3font->colorized; +} + +static void +pdf_init_t3font_struct(PDF *p, pdc_t3font *t3font, int glyph_capacity) +{ + static char fn[] = "pdf_init_t3font_struct"; + int i; + + /* statement order is critical for cleanup! + */ + t3font->fontname = NULL; + t3font->next_glyph = 0; + t3font->capacity = glyph_capacity; + t3font->glyphs = (pdc_t3glyph *) 0; + t3font->glyphs = (pdc_t3glyph *) + pdc_malloc(p->pdc, t3font->capacity * sizeof (pdc_t3glyph), fn); + + for (i = 0; i < t3font->capacity; i++) + t3font->glyphs[i].name = NULL; + + t3font->charprocs_id = PDC_BAD_ID; + + t3font->bbox.llx = 0; + t3font->bbox.lly = 0; + t3font->bbox.urx = 0; + t3font->bbox.ury = 0; +} + +static int +name2width(pdc_t3font *t3font, const char *name) +{ + int i; + + for (i = 0; i < t3font->next_glyph; ++i) { + if (t3font->glyphs[i].name && name && + !strcmp(t3font->glyphs[i].name, name)) + return (int) (t3font->glyphs[i].width + 0.5); + } + + return 0; +} + +/* + * We found a Type 3 font in the cache, but its encoding doesn't match. + * Make a copy of the font in a new slot, and attach the new encoding. + */ + +int +pdf_handle_t3font(PDF *p, const char *fontname, pdc_encoding enc, int oldslot) +{ + static const char fn[] = "pdf_handle_t3font"; + char *fname; + int slot, i; + unsigned int namlen; + pdc_font *oldfont, *newfont; + pdc_encodingvector *ev = p->encodings[enc].ev; + + oldfont = &p->fonts[oldslot]; + + /* slot of new font struct - initialized in pdf__load_font */ + slot = p->fonts_number; + newfont = &p->fonts[slot]; + + /* font name incl. encoding name */ + namlen = strlen(fontname) + (int) strlen(ev->apiname) + 2; + fname = (char *) pdc_malloc(p->pdc, namlen, fn); + sprintf(fname, "%s.%s", fontname, ev->apiname); + + /* + * This is a fresh font which has never been used. + * Enter the new encoding, and we're done. + */ + if (oldfont->encoding == pdc_invalidenc) { + + oldfont->encoding = enc; + + for (i = 0; i < oldfont->numOfCodes; i++) { + oldfont->widths[i] = + name2width(oldfont->t3font, ev->chars[i]); + if (newfont->monospace && oldfont->widths[i]) + oldfont->widths[i] = newfont->monospace; + } + ev->flags |= PDC_ENC_USED; + + oldfont->name = fname; + + return oldslot; + } + + p->fonts_number++; + + /* copy the complete font structure */ + memcpy(newfont, oldfont, sizeof(pdc_font)); + + /* make copies of relevant strings to ensure correct cleanup */ + newfont->name = fname; + newfont->apiname = pdc_strdup(p->pdc, fontname); + + /* modify relevant entries */ + newfont->used_on_current_page = pdc_false; + newfont->encoding = enc; + newfont->obj_id = pdc_alloc_id(p->out); + + newfont->t3font = (pdc_t3font*)pdc_malloc(p->pdc, sizeof(pdc_t3font), fn); + pdf_init_t3font_struct(p, newfont->t3font, oldfont->t3font->capacity); + + /* copy relevant entries of Type 3 structure */ + newfont->t3font->charprocs_id = oldfont->t3font->charprocs_id; + newfont->t3font->res_id = oldfont->t3font->res_id; + newfont->t3font->colorized = oldfont->t3font->colorized; + memcpy(&newfont->t3font->matrix, &oldfont->t3font->matrix, + sizeof(pdc_matrix)); + memcpy(&newfont->t3font->bbox, &oldfont->t3font->bbox, + sizeof(pdc_rectangle)); + + /* copy the glyph/width list from oldfont to newfont */ + newfont->t3font->next_glyph = oldfont->t3font->next_glyph; + for (i = 0; i < newfont->t3font->next_glyph; ++i) { + newfont->t3font->glyphs[i].width = + oldfont->t3font->glyphs[i].width; + newfont->t3font->glyphs[i].charproc_id = + oldfont->t3font->glyphs[i].charproc_id; + newfont->t3font->glyphs[i].name = + pdc_strdup(p->pdc, oldfont->t3font->glyphs[i].name); + } + + newfont->widths = (int *) pdc_calloc(p->pdc, + newfont->numOfCodes * sizeof(int), fn); + for (i = 0; i < newfont->numOfCodes; i++) { + newfont->widths[i] = + name2width(newfont->t3font, p->encodings[enc].ev->chars[i]); + if (newfont->monospace && oldfont->widths[i]) + newfont->widths[i] = newfont->monospace; + } + p->encodings[enc].ev->flags |= PDC_ENC_USED; + + return slot; +} + +/* definitions of begin font options */ +static const pdc_defopt pdf_begin_font_options[] = +{ + {"colorized", pdc_booleanlist, 0, 1, 1, 0.0, 0.0, NULL}, + + PDC_OPT_TERMINATE +}; + +void +pdf__begin_font( + PDF *p, + const char *fontname, + float a, float b, float c, float d, float e, float f, + const char *optlist) +{ + static const char fn[] = "pdf__begin_font"; + pdc_resopt *results; + pdc_font *font; + float det; + int colorized = pdc_false; + int slot; + + /* parsing optlist */ + results = pdc_parse_optionlist(p->pdc, optlist, pdf_begin_font_options, + NULL, pdc_true); + pdc_get_optvalues(p->pdc, "colorized", results, &colorized, NULL); + pdc_cleanup_optionlist(p->pdc, results); + + det = a*d - b*c; + + if (det == 0) + pdc_error(p->pdc, PDC_E_ILLARG_MATRIX, + pdc_errprintf(p->pdc, "%f %f %f %f %f %f", a, b, c, d, e, f), + 0, 0, 0); + + /* look for an already existing font */ + for (slot = 0; slot < p->fonts_number; slot++) + { + if (!strcmp(p->fonts[slot].apiname, fontname)) + { + pdc_error(p->pdc, PDF_E_T3_FONTEXISTS, fontname, 0, 0, 0); + } + } + + PDF_SET_STATE(p, pdf_state_font); + + pdf_init_tstate(p); + pdf_init_gstate(p); + pdf_init_cstate(p); + + /* slot for new font struct */ + slot = pdf_init_newfont(p); + font = &p->fonts[slot]; + p->fonts_number++; + + /* + * We store the new font in a font slot marked with "invalidenc" encoding. + * When the font is used for the first time we modify the encoding. + * Later uses will make a copy if the encoding is different. + */ + + font->type = pdc_Type3; + font->obj_id = pdc_alloc_id(p->out); + + font->name = NULL; + font->apiname = pdc_strdup(p->pdc, fontname); + font->encoding = pdc_invalidenc; /* initially there is no encoding */ + font->widths = (int *) pdc_calloc(p->pdc, + font->numOfCodes * sizeof(int), fn); + + font->t3font = (pdc_t3font*) pdc_malloc(p->pdc, sizeof(pdc_t3font), fn); + pdf_init_t3font_struct(p, font->t3font, T3GLYPHS_CHUNKSIZE); + + font->t3font->fontname = pdc_strdup(p->pdc, fontname); + font->t3font->colorized = colorized; + + /* the resource id is needed until the font dict is written */ + font->t3font->res_id = pdc_alloc_id(p->out); + + font->t3font->matrix.a = a; + font->t3font->matrix.b = b; + font->t3font->matrix.c = c; + font->t3font->matrix.d = d; + font->t3font->matrix.e = e; + font->t3font->matrix.f = f; + + /* We won't receive glyph bounding box values for colorized true, + * so we use the font matrix to get an approximation instead. + * + * Writing the font matrix should be optional according to the + * PDF reference, but we must write it in order to work around a + * display bug in Acrobat. + */ + if (font->t3font->colorized == pdc_true) { + font->t3font->bbox.llx = 0; + font->t3font->bbox.lly = 0; + font->t3font->bbox.urx = (d-b)/det; + font->t3font->bbox.ury = (a-c)/det; + } + + /* + * We must store a pointer to the current font because its glyph + * definitions may use other fonts and we would be unable to find + * "our" current font again. This pointer lives throughout the + * font definition, and will be reset in PDF_end_font() below. + */ + p->t3font = font->t3font; +} + +void +pdf__end_font(PDF *p) +{ + int i; + pdc_t3font *t3font; + + PDF_SET_STATE(p, pdf_state_document); + + t3font = p->t3font; + + t3font->charprocs_id = pdc_alloc_id(p->out); + pdc_begin_obj(p->out, t3font->charprocs_id); /* CharProcs dict */ + pdc_begin_dict(p->out); + + for (i = 0; i < t3font->next_glyph; i++) { + pdc_put_pdfname(p->out, + t3font->glyphs[i].name, strlen(t3font->glyphs[i].name)); + pdc_printf(p->out, " %ld 0 R\n", t3font->glyphs[i].charproc_id); + } + + pdc_end_dict(p->out); + pdc_end_obj(p->out); /* CharProcs dict */ + + pdc_begin_obj(p->out, t3font->res_id); + pdc_begin_dict(p->out); /* Resource dict */ + + pdf_write_page_fonts(p); /* Font resources */ + + pdf_write_page_colorspaces(p); /* Color space resources */ + + pdf_write_page_pattern(p); /* Pattern resources */ + + pdf_write_xobjects(p); /* XObject resources */ + + pdc_end_dict(p->out); /* Resource dict */ + pdc_end_obj(p->out); /* Resource object */ + + p->t3font = (pdc_t3font *) NULL; + + if (p->flush & pdf_flush_content) + pdc_flush_stream(p->out); +} + +void +pdf__begin_glyph( + PDF *p, + const char *glyphname, + float wx, float llx, float lly, float urx, float ury) +{ + static const char fn[] = "pdf__begin_glyph"; + pdc_t3font *t3font; + pdc_t3glyph *glyph; + int i; + + t3font = p->t3font; + + if (t3font->colorized == pdc_true && + (llx != (float) 0 || lly != (float) 0 || + urx != (float) 0 || ury != (float) 0)) + pdc_error(p->pdc, PDF_E_T3_BADBBOX, t3font->fontname, 0, 0, 0); + + PDF_SET_STATE(p, pdf_state_glyph); + + for (i = 0; i < t3font->next_glyph; ++i) { + if (!strcmp(t3font->glyphs[i].name, glyphname)) { + pdc_error(p->pdc, PDF_E_T3_GLYPH, glyphname, + t3font->fontname, 0, 0); + } + } + + if (t3font->next_glyph == t3font->capacity) { + t3font->capacity *= 2; + t3font->glyphs = (pdc_t3glyph *) pdc_realloc(p->pdc, t3font->glyphs, + t3font->capacity * sizeof (pdc_t3glyph), fn); + } + + glyph = &t3font->glyphs[t3font->next_glyph]; + glyph->charproc_id = pdc_begin_obj(p->out, PDC_NEW_ID); + glyph->name = pdc_strdup(p->pdc, glyphname); + + /* see comment in p_font.c for explanation */ + glyph->width = 1000 * wx * t3font->matrix.a; + + /* if the strdup above fails, cleanup won't touch this slot. */ + ++t3font->next_glyph; + + p->contents = c_page; + /* glyph description */ + pdc_begin_dict(p->out); /* glyph description dict */ + + p->length_id = pdc_alloc_id(p->out); + pdc_printf(p->out, "/Length %ld 0 R\n", p->length_id); + + if (pdc_get_compresslevel(p->out)) + pdc_puts(p->out, "/Filter/FlateDecode\n"); + + pdc_end_dict(p->out); /* glyph description dict */ + + pdc_begin_pdfstream(p->out); /* glyph description stream */ + + p->next_content++; + + if (t3font->colorized == pdc_true) + pdc_printf(p->out, "%f 0 d0\n", wx); + else { + pdc_printf(p->out, "%f 0 %f %f %f %f d1\n", wx, llx, lly, urx, ury); + + /* adjust the font's bounding box */ + if (llx < t3font->bbox.llx) + t3font->bbox.llx = llx; + if (lly < t3font->bbox.lly) + t3font->bbox.lly = lly; + if (urx > t3font->bbox.urx) + t3font->bbox.urx = urx; + if (ury > t3font->bbox.ury) + t3font->bbox.ury = ury; + } +} + +void +pdf__end_glyph(PDF *p) +{ + PDF_SET_STATE(p, pdf_state_font); + + /* check whether pdf__save() and pdf__restore() calls are balanced */ + if (p->sl > 0) + pdc_error(p->pdc, PDF_E_GSTATE_UNMATCHEDSAVE, 0, 0, 0, 0); + + pdf_end_text(p); + p->contents = c_none; + + pdc_end_pdfstream(p->out); /* glyph description stream */ + pdc_end_obj(p->out); /* glyph description */ + + pdc_put_pdfstreamlength(p->out, p->length_id); +} + +PDFLIB_API void PDFLIB_CALL +PDF_begin_font( + PDF *p, + const char *fontname, int reserved, + float a, float b, float c, float d, float e, float f, + const char *optlist) +{ + static const char fn[] = "PDF_begin_font"; + + if (!pdf_enter_api(p, fn, pdf_state_document, + "(p[%p], \"%s\", %d, %g, %g, %g, %g, %g, %g, \"%s\")\n", + (void *) p, fontname, reserved, a, b, c, d, e, f, optlist)) + return; + + if (!fontname || !*fontname) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "fontname", 0, 0, 0); + + pdf__begin_font(p, fontname, a, b, c, d, e, f, optlist); +} + +PDFLIB_API void PDFLIB_CALL +PDF_end_font(PDF *p) +{ + static const char fn[] = "PDF_end_font"; + + if (!pdf_enter_api(p, fn, pdf_state_font, "(p[%p])\n", (void *) p)) + return; + + pdf__end_font(p); +} + +PDFLIB_API void PDFLIB_CALL +PDF_begin_glyph( + PDF *p, + const char *glyphname, + float wx, float llx, float lly, float urx, float ury) +{ + static const char fn[] = "PDF_begin_glyph"; + + if (!pdf_enter_api(p, fn, pdf_state_font, + "(p[%p], \"%s\", %g, %g, %g, %g, %g)\n", + (void *) p, glyphname, wx, llx, lly, urx, ury)) + return; + + pdf__begin_glyph(p, glyphname, wx, llx, lly, urx, ury); +} + +PDFLIB_API void PDFLIB_CALL +PDF_end_glyph(PDF *p) +{ + static const char fn[] = "PDF_end_glyph"; + + if (!pdf_enter_api(p, fn, pdf_state_glyph, "(p[%p])\n", (void *) p)) + return; + + pdf__end_glyph(p); +} + + +void +pdf_init_type3(PDF *p) +{ + p->t3font = NULL; +} + diff --git a/src/libs/pdflib/libs/pdflib/p_xgstate.c b/src/libs/pdflib/libs/pdflib/p_xgstate.c new file mode 100644 index 0000000000..121be6247b --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/p_xgstate.c @@ -0,0 +1,468 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: p_xgstate.c,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * Extended graphics state handling + * + */ + +#define P_XGSTATE_C + +#include "p_intern.h" + +/* external graphic state */ +struct pdf_extgstateresource_s +{ + pdc_id obj_id; /* object id of this resource */ + pdc_bool used_on_current_page; /* this resource used on current page */ + + pdc_id font_obj; /* font to use */ + float font_size; /* at what size */ + + float line_width; + int line_cap; + int line_join; + float miter_limit; + float* dash_array; + int dash_count; + float dash_phase; + + pdf_renderingintent ri; + pdc_bool stroke_adjust; + pdc_bool overprint_stroke; + pdc_bool overprint_fill; + int overprint_mode; + + /* + The following entries which take functions are not implemented + since PDFlib has no concept of a function at this time. + + BG - black generation + BG2 - black generation + UCR - undercolor-removal + UCR2 - undercolor-removal + TR - transfer + TR2 - transfer + HT - halftone + */ + + float flatness; + float smoothness; + + /* PDF 1.4 additions */ + pdf_blendmode blendmode; /* blend mode */ + float opacity_fill; /* fill opacity level */ + float opacity_stroke; /* stroke opacity level */ + pdc_bool alpha_is_shape; + pdc_bool text_knockout; +}; + +pdc_id +pdf_get_gstate_id(PDF *p, int gstate) +{ + /* TODO: is this required for ExtGStates used in Shadings? */ + p->extgstates[gstate].used_on_current_page = pdc_true; + + return (p->extgstates[gstate].obj_id); +} + +/* Definitions of Explicit Graphics State options */ +static const pdc_defopt pdf_create_gstate_options[] = +{ + {"alphaisshape", pdc_booleanlist, PDC_OPT_PDC_1_4, 1, 1, 0.0, 0.0, NULL}, + + {"blendmode", pdc_keywordlist, PDC_OPT_BUILDOR | PDC_OPT_PDC_1_4, 1, 20, + 0.0, 0.0, gs_blendmodes}, + +/* These features do not work in Acrobat (5.0.1) + {"dasharray", pdc_floatlist, PDC_OPT_PDC_1_3, 1, 8, + PDF_SMALLREAL, PDC_FLOAT_MAX, NULL}, + + {"dashphase", pdc_floatlist, PDC_OPT_PDC_1_3, 1, 1, + 0.0, PDC_FLOAT_MAX, NULL}, + + {"fontsize", pdc_floatlist, PDC_OPT_PDC_1_3, 1, 1, + PDF_SMALLREAL, PDC_FLOAT_MAX, NULL}, + + {"font", pdc_fonthandle, PDC_OPT_PDC_1_3 | PDC_OPT_REQUIRIF1, 1, 1, + 0, 0, NULL}, +*/ + + {"flatness", pdc_floatlist, PDC_OPT_PDC_1_3, 1, 1, + PDF_SMALLREAL, PDC_FLOAT_MAX, NULL}, + + {"linecap", pdc_integerlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 2.0, NULL}, + + {"linejoin", pdc_integerlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 2.0, NULL}, + + {"linewidth", pdc_floatlist, PDC_OPT_PDC_1_3, 1, 1, + PDF_SMALLREAL, PDC_FLOAT_MAX, NULL}, + + {"miterlimit", pdc_floatlist, PDC_OPT_PDC_1_3, 1, 1, 1.0, PDC_FLOAT_MAX, + NULL}, + + {"opacityfill", pdc_floatlist, PDC_OPT_PDC_1_4, 1, 1, 0.0, 1.0, NULL}, + + {"opacitystroke", pdc_floatlist, PDC_OPT_PDC_1_4, 1, 1, 0.0, 1.0, NULL}, + + {"overprintfill", pdc_booleanlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 0.0, NULL}, + + {"overprintmode", pdc_integerlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 1.0, NULL}, + + {"overprintstroke", pdc_booleanlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 0.0, NULL}, + + {"renderingintent", pdc_keywordlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 0.0, + gs_renderingintents}, + + {"smoothness", pdc_floatlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 1.0, NULL}, + + {"strokeadjust", pdc_booleanlist, PDC_OPT_PDC_1_3, 1, 1, 0.0, 0.0, NULL}, + + {"textknockout", pdc_booleanlist, PDC_OPT_PDC_1_4, 1, 1, 0.0, 0.0, NULL}, + + PDC_OPT_TERMINATE +}; + +static void +pdf_init_extgstateresource(pdf_extgstateresource *egsr) +{ + egsr->used_on_current_page = pdc_false; + + /* we need to tell which parms have been set and which haven't, + ** so we initialize to invalid values. even boolean parms are + ** declared as integers, so we can set them to -1 here. + */ + egsr->font_obj = PDC_NEW_ID; + egsr->font_size = pdc_undef; + + egsr->line_width = pdc_undef; + egsr->line_cap = pdc_undef; + egsr->line_join = pdc_undef; + egsr->miter_limit = pdc_undef; + + egsr->dash_array = NULL; + egsr->dash_count = 0; + egsr->dash_phase = (float) 0.0; + + egsr->ri = AutoIntent; + egsr->stroke_adjust = pdc_undef; + egsr->overprint_stroke = pdc_undef; + egsr->overprint_fill = pdc_undef; + egsr->overprint_mode = pdc_undef; + egsr->flatness = pdc_undef; + egsr->smoothness = pdc_undef; + + egsr->blendmode = BM_None; + egsr->opacity_stroke = pdc_undef; + egsr->opacity_fill = pdc_undef; + egsr->alpha_is_shape = pdc_undef; + egsr->text_knockout = pdc_undef; +} + +static void +pdf_grow_extgstates(PDF *p) +{ + int i; + + p->extgstates = (pdf_extgstateresource *) pdc_realloc(p->pdc, p->extgstates, + sizeof(pdf_extgstateresource) * 2 * p->extgstates_capacity, + "pdf_grow_extgstates"); + + for (i = p->extgstates_capacity; i < 2 * p->extgstates_capacity; i++) { + pdf_init_extgstateresource( &p->extgstates[i] ); + } + + p->extgstates_capacity *= 2; +} + +void +pdf_init_extgstate(PDF *p) +{ + int i; + + p->extgstates_number = 0; + p->extgstates_capacity = EXTGSTATE_CHUNKSIZE; + + p->extgstates = (pdf_extgstateresource *) + pdc_malloc(p->pdc, sizeof(pdf_extgstateresource) * p->extgstates_capacity, + "pdf_init_extgstates"); + + for (i = 0; i < p->extgstates_capacity; i++) { + pdf_init_extgstateresource( &p->extgstates[i] ); + } +} + +void +pdf_write_page_extgstates(PDF *p) +{ + int i, total = 0; + + for (i = 0; i < p->extgstates_number; i++) + if (p->extgstates[i].used_on_current_page) + total++; + + if (total > 0) { + pdc_puts(p->out, "/ExtGState"); + + pdc_begin_dict(p->out); /* ExtGState names */ + + for (i = 0; i < p->extgstates_number; i++) { + if (p->extgstates[i].used_on_current_page) { + p->extgstates[i].used_on_current_page = pdc_false; /* reset */ + pdc_printf(p->out, "/GS%d %ld 0 R\n", + i, p->extgstates[i].obj_id); + } + } + + pdc_end_dict(p->out); /* ExtGState names */ + } +} + +void +pdf_write_doc_extgstates(PDF *p) +{ + int i, j; + + pdf_extgstateresource *gs; + + for (i = 0; i < p->extgstates_number; i++) + { + gs = &p->extgstates[i]; + + pdc_begin_obj(p->out, gs->obj_id); /* ExtGState resource */ + pdc_begin_dict(p->out); + + pdc_puts(p->out, "/Type/ExtGState\n"); + + if (gs->font_obj != PDC_NEW_ID) + pdc_printf(p->out, "/Font[%ld 0 R %f]\n", + gs->font_obj, gs->font_size); + + if (gs->line_width != pdc_undef) + pdc_printf(p->out, "/LW %f\n", gs->line_width); + + if (gs->line_cap != pdc_undef) + pdc_printf(p->out, "/LC %d\n", gs->line_cap); + + if (gs->line_join != pdc_undef) + pdc_printf(p->out, "/LJ %d\n", gs->line_join); + + if (gs->miter_limit != pdc_undef) + pdc_printf(p->out, "/ML %f\n", gs->miter_limit); + + if (gs->dash_count > 0) + { + pdc_printf(p->out, "/D[["); + + for (j = 0; j < gs->dash_count; ++j) + pdc_printf(p->out, "%f ", gs->dash_array[j]); + + pdc_printf(p->out, "] %f]\n", gs->dash_phase); + /* but see page 157 of PDF Reference: integer */ + } + + if (gs->ri != AutoIntent) + pdc_printf(p->out, "/RI/%s\n", + pdc_get_keyword((long) gs->ri, gs_renderingintents)); + + if (gs->stroke_adjust != pdc_undef) + pdc_printf(p->out, "/SA %s\n", + gs->stroke_adjust ? "true" : "false"); + + if (gs->overprint_stroke != pdc_undef) + pdc_printf(p->out, "/OP %s\n", + gs->overprint_stroke ? "true" : "false"); + + if (gs->overprint_fill != pdc_undef) + pdc_printf(p->out, "/op %s\n", + gs->overprint_fill ? "true" : "false"); + else if (gs->overprint_stroke == pdc_true) + pdc_puts(p->out, "/op false\n"); + + if (gs->overprint_mode != pdc_undef) + pdc_printf(p->out, "/OPM %d\n", gs->overprint_mode); + + if (gs->flatness != pdc_undef) + pdc_printf(p->out, "/FL %f\n", gs->flatness); + + if (gs->smoothness != pdc_undef) + pdc_printf(p->out, "/SM %f\n", gs->smoothness); + + if (gs->opacity_fill != pdc_undef) + pdc_printf(p->out, "/ca %f\n", gs->opacity_fill); + + if (gs->blendmode != BM_None) { + const char *modename; + + pdc_printf(p->out, "/BM["); + for (j = 0; ; j++) { + modename = gs_blendmodes[j].word; + if (!modename) break; + if (gs->blendmode & gs_blendmodes[j].code) + pdc_printf(p->out, "/%s", modename); + } + pdc_printf(p->out, "]\n"); + } + + if (gs->opacity_stroke != pdc_undef) + pdc_printf(p->out, "/CA %f\n", gs->opacity_stroke); + + if (gs->alpha_is_shape != pdc_undef) + pdc_printf(p->out, "/AIS %s\n", + gs->alpha_is_shape ? "true" : "false"); + + if (gs->text_knockout != pdc_undef) + pdc_printf(p->out, "/TK %s\n", + gs->text_knockout ? "true" : "false"); + + pdc_end_dict(p->out); + pdc_end_obj(p->out); /* ExtGState resource */ + } +} + +void +pdf_cleanup_extgstates(PDF *p) +{ + int i; + + if (!p->extgstates) + return; + + for (i = 0; i < p->extgstates_number; i++) { + if (p->extgstates[i].dash_array) + pdc_free(p->pdc, p->extgstates[i].dash_array); + } + + pdc_free(p->pdc, p->extgstates); + p->extgstates = NULL; +} + +PDFLIB_API int PDFLIB_CALL +PDF_create_gstate(PDF *p, const char *optlist) +{ + static const char fn[] = "PDF_create_gstate"; + pdf_extgstateresource *gs; + int slot = -1; + int font = pdc_undef; + int inum; + pdc_clientdata data; + pdc_resopt *results; + + if (!pdf_enter_api(p, fn, + (pdf_state) (pdf_state_document | pdf_state_content), + "(p[%p], \"%s\")", (void *) p, optlist)) + { + PDF_RETURN_HANDLE(p, slot) + } + + if (optlist == NULL || !*optlist) + pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "optlist", 0, 0, 0); + + slot = p->extgstates_number; + if (slot == p->extgstates_capacity) + pdf_grow_extgstates(p); + + p->extgstates_number++; + gs = &p->extgstates[slot]; + gs->obj_id = pdc_alloc_id(p->out); + + /* parsing optlist */ + data.compatibility = p->compatibility; + data.maxfont = p->fonts_number - 1; + data.hastobepos = p->hastobepos; + results = pdc_parse_optionlist(p->pdc, optlist, pdf_create_gstate_options, + &data, pdc_true); + + pdc_get_optvalues(p->pdc, "alphaisshape", results, + &gs->alpha_is_shape, NULL); + + if (pdc_get_optvalues(p->pdc, "blendmode", results, + &inum, NULL)) + gs->blendmode = (pdf_blendmode) inum; + + gs->dash_count = pdc_get_optvalues(p->pdc, "dasharray", results, + NULL, (void **) &gs->dash_array); + + pdc_get_optvalues(p->pdc, "dashphase", results, + &gs->dash_phase, NULL); + + pdc_get_optvalues(p->pdc, "flatness", results, + &gs->flatness, NULL); + + pdc_get_optvalues(p->pdc, "font", results, &font, NULL); + if (font != pdc_undef) + gs->font_obj = p->fonts[font].obj_id; + + pdc_get_optvalues(p->pdc, "fontsize", results, + &gs->font_size, NULL); + + pdc_get_optvalues(p->pdc, "linecap", results, + &gs->line_cap, NULL); + + pdc_get_optvalues(p->pdc, "linejoin", results, + &gs->line_join, NULL); + + pdc_get_optvalues(p->pdc, "linewidth", results, + &gs->line_width, NULL); + + pdc_get_optvalues(p->pdc, "miterlimit", results, + &gs->miter_limit, NULL); + + pdc_get_optvalues(p->pdc, "opacityfill", results, + &gs->opacity_fill, NULL); + + pdc_get_optvalues(p->pdc, "opacitystroke", results, + &gs->opacity_stroke, NULL); + + pdc_get_optvalues(p->pdc, "overprintfill", results, + &gs->overprint_fill, NULL); + + pdc_get_optvalues(p->pdc, "overprintmode", results, + &gs->overprint_mode, NULL); + + pdc_get_optvalues(p->pdc, "overprintstroke", results, + &gs->overprint_stroke, NULL); + + if (pdc_get_optvalues(p->pdc, "renderingintent", results, + &inum, NULL)) + gs->ri = (pdf_renderingintent) inum; + + pdc_get_optvalues(p->pdc, "smoothness", results, + &gs->smoothness, NULL); + + pdc_get_optvalues(p->pdc, "strokeadjust", results, + &gs->stroke_adjust, NULL); + + pdc_get_optvalues(p->pdc, "textknockout", results, + &gs->text_knockout, NULL); + + pdc_cleanup_optionlist(p->pdc, results); + + PDF_RETURN_HANDLE(p, slot) +} + +PDFLIB_API void PDFLIB_CALL +PDF_set_gstate(PDF *p, int gstate) +{ + static const char fn[] = "PDF_set_gstate"; + + if (!pdf_enter_api(p, fn, pdf_state_content, "(p[%p], %d)\n", + (void *) p, gstate)) + return; + + PDF_INPUT_HANDLE(p, gstate) + pdf_check_handle(p, gstate, pdc_gstatehandle); + + pdc_printf(p->out, "/GS%d gs\n", gstate); + p->extgstates[gstate].used_on_current_page = pdc_true; +} diff --git a/src/libs/pdflib/libs/pdflib/pdf.dsp b/src/libs/pdflib/libs/pdflib/pdf.dsp new file mode 100644 index 0000000000..1bc1db2326 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/pdf.dsp @@ -0,0 +1,303 @@ +# Microsoft Developer Studio Project File - Name="pdf" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pdf - Win32 Debug DLL +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pdf.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pdf.mak" CFG="pdf - Win32 Debug DLL" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pdf - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pdf - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "pdf - Win32 Release mtDLL" (based on "Win32 (x86) Static Library") +!MESSAGE "pdf - Win32 Release DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "pdf - Win32 Debug DLL" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pdf - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /I "../pdpage" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /U "PDF_FEATURE_PDI" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pdf.lib" + +!ELSEIF "$(CFG)" == "pdf - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pdf.lib" + +!ELSEIF "$(CFG)" == "pdf - Win32 Release mtDLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL" +# PROP BASE Intermediate_Dir "Release_mtDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL" +# PROP Intermediate_Dir "Release_mtDLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"pdf.lib" + +!ELSEIF "$(CFG)" == "pdf - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_DLL" +# PROP BASE Intermediate_Dir "Release_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_DLL" +# PROP Intermediate_Dir "Release_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /I "../pdpage" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /U "PDF_FEATURE_PDI" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /I "../pdpage" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_EXPORTS" /U "PDF_FEATURE_PDI" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"pdf.lib" +# ADD LIB32 /nologo /out:"pdf.lib" + +!ELSEIF "$(CFG)" == "pdf - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_DLL" +# PROP BASE Intermediate_Dir "Debug_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_DLL" +# PROP Intermediate_Dir "Debug_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FR /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /D "PDFLIB_EXPORTS" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"pdf.lib" +# ADD LIB32 /nologo /out:"pdf.lib" + +!ENDIF + +# Begin Target + +# Name "pdf - Win32 Release" +# Name "pdf - Win32 Debug" +# Name "pdf - Win32 Release mtDLL" +# Name "pdf - Win32 Release DLL" +# Name "pdf - Win32 Debug DLL" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\p_afm.c +# End Source File +# Begin Source File + +SOURCE=.\p_annots.c +# End Source File +# Begin Source File + +SOURCE=.\p_block.c +# End Source File +# Begin Source File + +SOURCE=.\p_bmp.c +# End Source File +# Begin Source File + +SOURCE=.\p_ccitt.c +# End Source File +# Begin Source File + +SOURCE=.\p_cid.c +# End Source File +# Begin Source File + +SOURCE=.\p_color.c +# End Source File +# Begin Source File + +SOURCE=.\p_draw.c +# End Source File +# Begin Source File + +SOURCE=.\p_encoding.c +# End Source File +# Begin Source File + +SOURCE=.\p_filter.c +# End Source File +# Begin Source File + +SOURCE=.\p_font.c +# End Source File +# Begin Source File + +SOURCE=.\p_gif.c +# End Source File +# Begin Source File + +SOURCE=.\p_gstate.c +# End Source File +# Begin Source File + +SOURCE=.\p_hostfont.c +# End Source File +# Begin Source File + +SOURCE=.\p_hyper.c +# End Source File +# Begin Source File + +SOURCE=.\p_icc.c +# End Source File +# Begin Source File + +SOURCE=.\p_icclib.c +# End Source File +# Begin Source File + +SOURCE=.\p_image.c +# End Source File +# Begin Source File + +SOURCE=.\p_jpeg.c +# End Source File +# Begin Source File + +SOURCE=.\p_kerning.c +# End Source File +# Begin Source File + +SOURCE=.\p_params.c +# End Source File +# Begin Source File + +SOURCE=.\p_pattern.c +# End Source File +# Begin Source File + +SOURCE=.\p_pdi.c +# End Source File +# Begin Source File + +SOURCE=.\p_pfm.c +# End Source File +# Begin Source File + +SOURCE=.\p_png.c +# End Source File +# Begin Source File + +SOURCE=.\p_resource.c +# End Source File +# Begin Source File + +SOURCE=.\p_shading.c +# End Source File +# Begin Source File + +SOURCE=.\p_subsett.c +# End Source File +# Begin Source File + +SOURCE=.\p_template.c +# End Source File +# Begin Source File + +SOURCE=.\p_text.c +# End Source File +# Begin Source File + +SOURCE=.\p_tiff.c +# End Source File +# Begin Source File + +SOURCE=.\p_truetype.c +# End Source File +# Begin Source File + +SOURCE=.\p_type1.c +# End Source File +# Begin Source File + +SOURCE=.\p_type3.c +# End Source File +# Begin Source File + +SOURCE=.\p_xgstate.c +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/pdflib/pdflib.dsp b/src/libs/pdflib/libs/pdflib/pdflib.dsp new file mode 100644 index 0000000000..a29a58ae92 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/pdflib.dsp @@ -0,0 +1,117 @@ +# Microsoft Developer Studio Project File - Name="pdflib" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pdflib - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pdflib.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pdflib.mak" CFG="pdflib - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pdflib - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pdflib - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "pdflib - Win32 Release mtDLL" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pdflib - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "pdflib - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../png" /I "../flate" /I "../tiff" /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "pdflib - Win32 Release mtDLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL" +# PROP BASE Intermediate_Dir "Release_mtDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL" +# PROP Intermediate_Dir "Release_mtDLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ENDIF + +# Begin Target + +# Name "pdflib - Win32 Release" +# Name "pdflib - Win32 Debug" +# Name "pdflib - Win32 Release mtDLL" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\p_basic.c +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/pdflib/pdflib.h b/src/libs/pdflib/libs/pdflib/pdflib.h new file mode 100644 index 0000000000..dcd1786b38 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/pdflib.h @@ -0,0 +1,1301 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdflib.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ + * + * PDFlib public function and constant declarations + * + */ + +#ifndef PDFLIB_H +#define PDFLIB_H + +#include +#include + + +/* + * ---------------------------------------------------------------------- + * Setup, mostly Windows calling conventions and DLL stuff + * ---------------------------------------------------------------------- + */ + +#ifdef WIN32 + +#if !defined(PDFLIB_CALL) +#define PDFLIB_CALL __cdecl +#endif + +#if !defined(PDFLIB_API) +#ifdef PDFLIB_EXPORTS +#define PDFLIB_API __declspec(dllexport) /* prepare a DLL (internal use only) */ + +#elif defined(PDFLIB_DLL) +#define PDFLIB_API __declspec(dllimport) /* PDFlib clients: import PDFlib DLL */ + +#else /* !PDFLIB_DLL */ +#define PDFLIB_API /* */ /* default: generate or use static library */ + +#endif /* !PDFLIB_DLL */ +#endif /* !PDFLIB_API */ + +#else /* !WIN32 */ + +#if ((defined __IBMC__ || defined __IBMCPP__) && defined __DLL__ && defined OS2) + #define PDFLIB_CALL _Export + #define PDFLIB_API +#endif /* IBM VisualAge C++ DLL */ + +#ifndef PDFLIB_CALL +#define PDFLIB_CALL +#endif +#ifndef PDFLIB_API +#define PDFLIB_API +#endif + +#endif /* !WIN32 */ + + +/* export all symbols for a shared library on the Mac */ +#if defined(__MWERKS__) && defined(PDFLIB_EXPORTS) +#pragma export on +#endif + + +/* Make our declarations C++ compatible */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* Define the basic PDF type. This is used opaquely at the API level. */ +#if !defined(PDF) || defined(ACTIVEX) +typedef struct PDF_s PDF; +#endif /* !PDF */ + +/* The API structure with function pointers. */ +typedef struct PDFlib_api_s PDFlib_api; + +/* + * The version defines below may be used to check the version of the + * include file against the library. + */ + +/* do not change this (version.sh will do it for you :) */ +#define PDFLIB_MAJORVERSION 5 /* PDFlib major version number */ +#define PDFLIB_MINORVERSION 0 /* PDFlib minor version number */ +#define PDFLIB_REVISION 3 /* PDFlib revision number */ +#define PDFLIB_VERSIONSTRING "5.0.3" /* The whole bunch */ + + +/* {{{ p_annots.c: file attachments, notes, and links + * ---------------------------------------------------------------------- + */ + +/* Add a launch annotation (to a target of arbitrary file type). */ +PDFLIB_API void PDFLIB_CALL +PDF_add_launchlink(PDF *p, float llx, float lly, float urx, float ury, + const char *filename); + +/* Add a link annotation to a target within the current PDF file. */ +PDFLIB_API void PDFLIB_CALL +PDF_add_locallink(PDF *p, float llx, float lly, float urx, float ury, + int page, const char *optlist); + +/* Add a note annotation. icon is one of of "comment", "insert", "note", + * "paragraph", "newparagraph", "key", or "help". */ +PDFLIB_API void PDFLIB_CALL +PDF_add_note(PDF *p, float llx, float lly, float urx, float ury, + const char *contents, const char *title, const char *icon, int open); + +PDFLIB_API void PDFLIB_CALL +PDF_add_note2(PDF *p, float llx, float lly, float urx, float ury, + const char *contents, int len_cont, const char *title, int len_title, + const char *icon, int open); + +/* Add a file link annotation (to a PDF target). */ +PDFLIB_API void PDFLIB_CALL +PDF_add_pdflink(PDF *p, float llx, float lly, float urx, float ury, + const char *filename, int page, const char *optlist); + +/* Add a weblink annotation to a target URL on the Web. */ +PDFLIB_API void PDFLIB_CALL +PDF_add_weblink(PDF *p, float llx, float lly, float urx, float ury, + const char *url); + +/* Add a file attachment annotation. icon is one of "graph", "paperclip", + * "pushpin", or "tag". */ +PDFLIB_API void PDFLIB_CALL +PDF_attach_file(PDF *p, float llx, float lly, float urx, float ury, + const char *filename, const char *description, const char *author, + const char *mimetype, const char *icon); + +PDFLIB_API void PDFLIB_CALL +PDF_attach_file2(PDF *p, float llx, float lly, float urx, float ury, + const char *filename, int reserved, const char *description, int len_descr, + const char *author, int len_auth, const char *mimetype, const char *icon); + +/* Set the border color for all kinds of annotations. */ +PDFLIB_API void PDFLIB_CALL +PDF_set_border_color(PDF *p, float red, float green, float blue); + +/* Set the border dash style for all kinds of annotations. See PDF_setdash(). */ +PDFLIB_API void PDFLIB_CALL +PDF_set_border_dash(PDF *p, float b, float w); + +/* Set the border style for all kinds of annotations. style is "solid" or + * "dashed". */ +PDFLIB_API void PDFLIB_CALL +PDF_set_border_style(PDF *p, const char *style, float width); +/* }}} */ + + +/* {{{ p_basic.c: general functions + * ---------------------------------------------------------------------- + */ + +/* Add a new page to the document. */ +PDFLIB_API void PDFLIB_CALL +PDF_begin_page(PDF *p, float width, float height); + +/* Boot PDFlib (recommended although currently not required). */ +PDFLIB_API void PDFLIB_CALL +PDF_boot(void); + +/* Close the generated PDF file, and release all document-related resources. */ +PDFLIB_API void PDFLIB_CALL +PDF_close(PDF *p); + +/* Delete the PDFlib object, and free all internal resources. */ +PDFLIB_API void PDFLIB_CALL +PDF_delete(PDF *p); + +/* Finish the page. */ +PDFLIB_API void PDFLIB_CALL +PDF_end_page(PDF *p); + +/* Retrieve a structure with PDFlib API function pointers (mainly for DLLs). + * Although this function is published here, it is not supposed to be used + * directly by clients. Use PDF_new_dl() (in pdflibdl.c) instead. */ +PDFLIB_API const PDFlib_api * PDFLIB_CALL +PDF_get_api(void); + +/* Get the name of the API function which threw the last exception or failed. */ +PDFLIB_API const char * PDFLIB_CALL +PDF_get_apiname(PDF *p); + +/* Get the contents of the PDF output buffer. The result must be used by + * the client before calling any other PDFlib function. */ +PDFLIB_API const char * PDFLIB_CALL +PDF_get_buffer(PDF *p, long *size); + +/* Get the descriptive text of the last thrown exception, or the reason of + * a failed function call. */ +PDFLIB_API const char * PDFLIB_CALL +PDF_get_errmsg(PDF *p); + +/* Get the number of the last thrown exception, or the reason of a failed + * function call. */ +PDFLIB_API int PDFLIB_CALL +PDF_get_errnum(PDF *p); + +/* Depreceated: use PDF_get_value() */ +PDFLIB_API int PDFLIB_CALL +PDF_get_majorversion(void); + +/* Depreceated: use PDF_get_value() */ +PDFLIB_API int PDFLIB_CALL +PDF_get_minorversion(void); + +/* Fetch the opaque application pointer stored in PDFlib. */ +PDFLIB_API void * PDFLIB_CALL +PDF_get_opaque(PDF *p); + +/* Create a new PDFlib object, using default error handling and memory + management. */ +PDFLIB_API PDF * PDFLIB_CALL +PDF_new(void); + +/* Create a new PDFlib object with client-supplied error handling and memory + * allocation routines. */ +typedef void (*errorproc_t)(PDF *p1, int errortype, const char *msg); +typedef void* (*allocproc_t)(PDF *p2, size_t size, const char *caller); +typedef void* (*reallocproc_t)(PDF *p3, + void *mem, size_t size, const char *caller); +typedef void (*freeproc_t)(PDF *p4, void *mem); + +PDFLIB_API PDF * PDFLIB_CALL +PDF_new2(errorproc_t errorhandler, allocproc_t allocproc, + reallocproc_t reallocproc, freeproc_t freeproc, void *opaque); + +/* Create a new PDF file using the supplied file name. */ +PDFLIB_API int PDFLIB_CALL +PDF_open_file(PDF *p, const char *filename); + +/* Open a new PDF file associated with p, using the supplied file handle. */ +PDFLIB_API int PDFLIB_CALL +PDF_open_fp(PDF *p, FILE *fp); + +/* Open a new PDF in memory, and install a callback for fetching the data. */ +typedef size_t (*writeproc_t)(PDF *p1, void *data, size_t size); +PDFLIB_API void PDFLIB_CALL +PDF_open_mem(PDF *p, writeproc_t writeproc); + +/* Shut down PDFlib (recommended although currently not required). */ +PDFLIB_API void PDFLIB_CALL +PDF_shutdown(void); + +/* + * Error classes are deprecated; use PDF_TRY/PDF_CATCH instead. + * Note that old-style error handlers are still supported, but + * they will always receive type PDF_NonfatalError (for warnings) + * or PDF_UnknownError (for other exceptions). + */ + +#define PDF_MemoryError 1 +#define PDF_IOError 2 +#define PDF_RuntimeError 3 +#define PDF_IndexError 4 +#define PDF_TypeError 5 +#define PDF_DivisionByZero 6 +#define PDF_OverflowError 7 +#define PDF_SyntaxError 8 +#define PDF_ValueError 9 +#define PDF_SystemError 10 + +#define PDF_NonfatalError 11 +#define PDF_UnknownError 12 + +/* }}} */ + + +/*{{{ p_block.c: Variable Data Processing with blocks (requires the PDI library) + * -------------------------------------------------------------------------- + */ + +/* Process an image block according to its properties. */ +PDFLIB_API int PDFLIB_CALL +PDF_fill_imageblock(PDF *p, int page, const char *blockname, + int image, const char *optlist); + +/* Process a PDF block according to its properties. */ +PDFLIB_API int PDFLIB_CALL +PDF_fill_pdfblock(PDF *p, int page, const char *blockname, + int contents, const char *optlist); + +/* Process a text block according to its properties. */ +PDFLIB_API int PDFLIB_CALL +PDF_fill_textblock(PDF *p, int page, const char *blockname, + const char *text, int len, const char *optlist); +/* }}} */ + + +/* {{{ p_color.c: color handling + * ---------------------------------------------------------------------- + */ + +/* Make a named spot color from the current color. */ +PDFLIB_API int PDFLIB_CALL +PDF_makespotcolor(PDF *p, const char *spotname, int reserved); + +/* Set the current color space and color. fstype is "fill", "stroke", +or "fillstroke". + */ +PDFLIB_API void PDFLIB_CALL +PDF_setcolor(PDF *p, const char *fstype, const char *colorspace, + float c1, float c2, float c3, float c4); + +/* The following six functions are deprecated, use PDF_setcolor() instead. */ +PDFLIB_API void PDFLIB_CALL +PDF_setgray(PDF *p, float gray); + +PDFLIB_API void PDFLIB_CALL +PDF_setgray_fill(PDF *p, float gray); + +PDFLIB_API void PDFLIB_CALL +PDF_setgray_stroke(PDF *p, float gray); + +PDFLIB_API void PDFLIB_CALL +PDF_setrgbcolor(PDF *p, float red, float green, float blue); + +PDFLIB_API void PDFLIB_CALL +PDF_setrgbcolor_fill(PDF *p, float red, float green, float blue); + +PDFLIB_API void PDFLIB_CALL +PDF_setrgbcolor_stroke(PDF *p, float red, float green, float blue); +/* }}} */ + + +/* {{{ p_draw.c: path construction, painting, and clipping + * ---------------------------------------------------------------------- + */ + +/* Draw a counterclockwise circular arc from alpha to beta degrees. */ +PDFLIB_API void PDFLIB_CALL +PDF_arc(PDF *p, float x, float y, float r, float alpha, float beta); + +/* Draw a clockwise circular arc from alpha to beta degrees. */ +PDFLIB_API void PDFLIB_CALL +PDF_arcn(PDF *p, float x, float y, float r, float alpha, float beta); + +/* Draw a circle with center (x, y) and radius r. */ +PDFLIB_API void PDFLIB_CALL +PDF_circle(PDF *p, float x, float y, float r); + +/* Use the current path as clipping path. */ +PDFLIB_API void PDFLIB_CALL +PDF_clip(PDF *p); + +/* Close the current path. */ +PDFLIB_API void PDFLIB_CALL +PDF_closepath(PDF *p); + +/* Close the path, fill, and stroke it. */ +PDFLIB_API void PDFLIB_CALL +PDF_closepath_fill_stroke(PDF *p); + +/* Close the path, and stroke it. */ +PDFLIB_API void PDFLIB_CALL +PDF_closepath_stroke(PDF *p); + +/* Draw a Bezier curve from the current point, using 3 more control points. */ +PDFLIB_API void PDFLIB_CALL +PDF_curveto(PDF *p, + float x_1, float y_1, float x_2, float y_2, float x_3, float y_3); + +/* End the current path without filling or stroking it. */ +PDFLIB_API void PDFLIB_CALL +PDF_endpath(PDF *p); + +/* Fill the interior of the path with the current fill color. */ +PDFLIB_API void PDFLIB_CALL +PDF_fill(PDF *p); + +/* Fill and stroke the path with the current fill and stroke color. */ +PDFLIB_API void PDFLIB_CALL +PDF_fill_stroke(PDF *p); + +/* Draw a line from the current point to (x, y). */ +PDFLIB_API void PDFLIB_CALL +PDF_lineto(PDF *p, float x, float y); + +/* Draw a line from the current point to (cp + (x, y)) (unsupported). */ +PDFLIB_API void PDFLIB_CALL +PDF_rlineto(PDF *p, float x, float y); + +/* Set the current point. */ +PDFLIB_API void PDFLIB_CALL +PDF_moveto(PDF *p, float x, float y); + +/* Draw a Bezier curve from the current point using relative coordinates + (unsupported). */ +PDFLIB_API void PDFLIB_CALL +PDF_rcurveto(PDF *p, + float x_1, float y_1, float x_2, float y_2, float x_3, float y_3); + +/* Draw a rectangle at lower left (x, y) with width and height. */ +PDFLIB_API void PDFLIB_CALL +PDF_rect(PDF *p, float x, float y, float width, float height); + +/* Set the new current point relative the old current point (unsupported). */ +PDFLIB_API void PDFLIB_CALL +PDF_rmoveto(PDF *p, float x, float y); + +/* Stroke the path with the current color and line width, and clear it. */ +PDFLIB_API void PDFLIB_CALL +PDF_stroke(PDF *p); + +/* }}} */ + + +/* {{{ p_encoding.c: encoding handling + * ---------------------------------------------------------------------- + */ + +/* Request a glyph name from a custom encoding (unsupported). */ +PDFLIB_API const char * PDFLIB_CALL +PDF_encoding_get_glyphname(PDF *p, const char *encoding, int slot); + +/* Request a glyph unicode value from a custom encoding (unsupported). */ +PDFLIB_API int PDFLIB_CALL +PDF_encoding_get_unicode(PDF *p, const char *encoding, int slot); + +/* Add a glyph name to a custom encoding. */ +PDFLIB_API void PDFLIB_CALL +PDF_encoding_set_char(PDF *p, const char *encoding, int slot, + const char *glyphname, int uv); +/* }}} */ + + +/* {{{ p_font.c: text and font handling + * ---------------------------------------------------------------------- + */ + +/* Search a font, and prepare it for later use. PDF_load_font() is + * recommended. */ +PDFLIB_API int PDFLIB_CALL +PDF_findfont(PDF *p, const char *fontname, const char *encoding, int embed); + +/* Request a glyph ID value from a font (unsupported). */ +PDFLIB_API int PDFLIB_CALL +PDF_get_glyphid(PDF *p, int font, int code); + +/* Open and search a font, and prepare it for later use. */ +PDFLIB_API int PDFLIB_CALL +PDF_load_font(PDF *p, const char *fontname, int len, + const char *encoding, const char *optlist); + +/* Set the current font in the given size, using a font handle returned by + * PDF_load_font(). */ +PDFLIB_API void PDFLIB_CALL +PDF_setfont(PDF *p, int font, float fontsize); +/* }}} */ + + +/* {{{ p_gstate.c: graphics state + * ---------------------------------------------------------------------- + */ + +/* Maximum length of dash arrays */ +#define MAX_DASH_LENGTH 8 + +/* Concatenate a matrix to the current transformation matrix. */ +PDFLIB_API void PDFLIB_CALL +PDF_concat(PDF *p, float a, float b, float c, float d, float e, float f); + +/* Reset all color and graphics state parameters to their defaults. */ +PDFLIB_API void PDFLIB_CALL +PDF_initgraphics(PDF *p); + +/* Restore the most recently saved graphics state. */ +PDFLIB_API void PDFLIB_CALL +PDF_restore(PDF *p); + +/* Rotate the coordinate system by phi degrees. */ +PDFLIB_API void PDFLIB_CALL +PDF_rotate(PDF *p, float phi); + +/* Save the current graphics state. */ +PDFLIB_API void PDFLIB_CALL +PDF_save(PDF *p); + +/* Scale the coordinate system. */ +PDFLIB_API void PDFLIB_CALL +PDF_scale(PDF *p, float sx, float sy); + +/* Set the current dash pattern to b black and w white units. */ +PDFLIB_API void PDFLIB_CALL +PDF_setdash(PDF *p, float b, float w); + +/* Set a more complicated dash pattern defined by an optlist. */ +PDFLIB_API void PDFLIB_CALL +PDF_setdashpattern(PDF *p, const char *optlist); + +/* Set the flatness to a value between 0 and 100 inclusive. */ +PDFLIB_API void PDFLIB_CALL +PDF_setflat(PDF *p, float flatness); + +/* Set the linecap parameter to a value between 0 and 2 inclusive. */ +PDFLIB_API void PDFLIB_CALL +PDF_setlinecap(PDF *p, int linecap); + +/* Set the linejoin parameter to a value between 0 and 2 inclusive. */ +PDFLIB_API void PDFLIB_CALL +PDF_setlinejoin(PDF *p, int linejoin); + +/* Set the current linewidth to width. */ +PDFLIB_API void PDFLIB_CALL +PDF_setlinewidth(PDF *p, float width); + +/* Explicitly set the current transformation matrix. */ +PDFLIB_API void PDFLIB_CALL +PDF_setmatrix(PDF *p, float a, float b, float c, float d, float e, float f); + +/* Set the miter limit to a value greater than or equal to 1. */ +PDFLIB_API void PDFLIB_CALL +PDF_setmiterlimit(PDF *p, float miter); + +/* Deprecated, use PDF_setdashpattern() instead. */ +PDFLIB_API void PDFLIB_CALL +PDF_setpolydash(PDF *p, float *dasharray, int length); + +/* Skew the coordinate system in x and y direction by alpha and beta degrees. */ +PDFLIB_API void PDFLIB_CALL +PDF_skew(PDF *p, float alpha, float beta); + +/* Translate the origin of the coordinate system. */ +PDFLIB_API void PDFLIB_CALL +PDF_translate(PDF *p, float tx, float ty); +/* }}} */ + + +/* {{{ p_hyper.c: bookmarks and document info fields + * ---------------------------------------------------------------------- + */ + +/* Add a nested bookmark under parent, or a new top-level bookmark if + * parent = 0. Returns a bookmark descriptor which may be + * used as parent for subsequent nested bookmarks. If open = 1, child + * bookmarks will be folded out, and invisible if open = 0. */ +PDFLIB_API int PDFLIB_CALL +PDF_add_bookmark(PDF *p, const char *text, int parent, int open); + +PDFLIB_API int PDFLIB_CALL +PDF_add_bookmark2(PDF *p, const char *text, int len, int parent, int open); + +/* Create a named destination on an arbitrary page in the current document. */ +PDFLIB_API void PDFLIB_CALL +PDF_add_nameddest(PDF *p, const char *name, int reserved, const char *optlist); + +/* Fill document information field key with value. key is one of "Subject", + * "Title", "Creator", "Author", "Keywords", or a user-defined key. */ +PDFLIB_API void PDFLIB_CALL +PDF_set_info(PDF *p, const char *key, const char *value); + +PDFLIB_API void PDFLIB_CALL +PDF_set_info2(PDF *p, const char *key, const char *value, int len); +/* }}} */ + + +/* {{{ p_icc.c: ICC profile handling + * ---------------------------------------------------------------------- + */ + +/* Search an ICC profile, and prepare it for later use. */ +PDFLIB_API int PDFLIB_CALL +PDF_load_iccprofile(PDF *p, const char *profilename, int reserved, + const char *optlist); +/* }}} */ + + +/* {{{ p_image.c: image handling + * ---------------------------------------------------------------------- + */ + +/* Add an existing image as thumbnail for the current page. */ +PDFLIB_API void PDFLIB_CALL +PDF_add_thumbnail(PDF *p, int image); + +/* Close an image retrieved with PDF_load_image(). */ +PDFLIB_API void PDFLIB_CALL +PDF_close_image(PDF *p, int image); + +/* Place an image or template at (x, y) with various options. */ +PDFLIB_API void PDFLIB_CALL +PDF_fit_image(PDF *p, int image, float x, float y, const char *optlist); + +/* Open a (disk-based or virtual) image file with various options. */ +PDFLIB_API int PDFLIB_CALL +PDF_load_image(PDF *p, const char *imagetype, const char *filename, + int reserved, const char *optlist); + +/* Deprecated, use PDF_load_image() instead. */ +PDFLIB_API int PDFLIB_CALL +PDF_open_CCITT(PDF *p, const char *filename, int width, int height, + int BitReverse, int K, int BlackIs1); + +/* Deprecated, use PDF_load_image() with virtual files instead. */ +PDFLIB_API int PDFLIB_CALL +PDF_open_image(PDF *p, const char *imagetype, const char *source, + const char *data, long length, int width, int height, int components, + int bpc, const char *params); + +/* Deprecated, use PDF_load_image() instead. */ +PDFLIB_API int PDFLIB_CALL +PDF_open_image_file(PDF *p, const char *imagetype, const char *filename, + const char *stringparam, int intparam); + +/* Deprecated, use PDF_fit_image() instead. */ +PDFLIB_API void PDFLIB_CALL +PDF_place_image(PDF *p, int image, float x, float y, float scale); +/* }}} */ + + +/* {{{ p_kerning.c: font kerning + * ---------------------------------------------------------------------- + */ + +/* Request the amount of kerning between two characters in a specified font. + (unsupported) */ +PDFLIB_API float PDFLIB_CALL +PDF_get_kern_amount(PDF *p, int font, int firstchar, int secondchar); +/* }}} */ + + +/* {{{ p_params.c: parameter handling + * ---------------------------------------------------------------------- + */ + +/* Get the contents of some PDFlib parameter with string type. */ +PDFLIB_API const char * PDFLIB_CALL +PDF_get_parameter(PDF *p, const char *key, float modifier); + +/* Get the value of some PDFlib parameter with float type. */ +PDFLIB_API float PDFLIB_CALL +PDF_get_value(PDF *p, const char *key, float modifier); + +/* Set some PDFlib parameter with string type. */ +PDFLIB_API void PDFLIB_CALL +PDF_set_parameter(PDF *p, const char *key, const char *value); + +/* Set the value of some PDFlib parameter with float type. */ +PDFLIB_API void PDFLIB_CALL +PDF_set_value(PDF *p, const char *key, float value); +/* }}} */ + + +/* {{{ p_pattern.c: pattern definition + * ---------------------------------------------------------------------- + */ + +/* Start a new pattern definition. */ +PDFLIB_API int PDFLIB_CALL +PDF_begin_pattern(PDF *p, + float width, float height, float xstep, float ystep, int painttype); + +/* Finish a pattern definition. */ +PDFLIB_API void PDFLIB_CALL +PDF_end_pattern(PDF *p); +/* }}} */ + + +/* {{{ p_pdi.c: PDF import (requires the PDI library) + * ---------------------------------------------------------------------- + */ + +/* Close all open page handles, and close the input PDF document. */ +PDFLIB_API void PDFLIB_CALL +PDF_close_pdi(PDF *p, int doc); + +/* Close the page handle, and free all page-related resources. */ +PDFLIB_API void PDFLIB_CALL +PDF_close_pdi_page(PDF *p, int page); + +/* Place an imported PDF page with the lower left corner at (x, y) with + * various options. */ +PDFLIB_API void PDFLIB_CALL +PDF_fit_pdi_page(PDF *p, int page, float x, float y, const char *optlist); + +/* Get the contents of some PDI document parameter with string type. */ +PDFLIB_API const char *PDFLIB_CALL +PDF_get_pdi_parameter(PDF *p, const char *key, int doc, int page, + int reserved, int *len); + +/* Get the contents of some PDI document parameter with numerical type. */ +PDFLIB_API float PDFLIB_CALL +PDF_get_pdi_value(PDF *p, const char *key, int doc, int page, int reserved); + +/* Open a (disk-based or virtual) PDF document and prepare it for later use. */ +PDFLIB_API int PDFLIB_CALL +PDF_open_pdi(PDF *p, const char *filename, const char *optlist, int reserved); + +/* Open an existing PDF document with callback functions for file access. */ +PDFLIB_API int PDFLIB_CALL +PDF_open_pdi_callback(PDF *p, void *opaque, size_t filesize, + size_t (*readproc)(void *opaque, void *buffer, size_t size), + int (*seekproc)(void *opaque, long offset), + const char *optlist); + +/* Prepare a page for later use with PDF_place_pdi_page(). */ +PDFLIB_API int PDFLIB_CALL +PDF_open_pdi_page(PDF *p, int doc, int pagenumber, const char *optlist); + +/* Deprecated, use PDF_fit_pdi_page( ) instead. */ +PDFLIB_API void PDFLIB_CALL +PDF_place_pdi_page(PDF *p, int page, float x, float y, float sx, float sy); + +/* Perform various actions on a PDI document. */ +PDFLIB_API int PDFLIB_CALL +PDF_process_pdi(PDF *p, int doc, int page, const char *optlist); +/* }}} */ + + +/* {{{ p_resource.c: resources and virtual file system handling + * ---------------------------------------------------------------------- + */ + +/* Create a new virtual file. */ +PDFLIB_API void PDFLIB_CALL +PDF_create_pvf(PDF *p, const char *filename, int reserved, + const void *data, size_t size, const char *optlist); + +/* Delete a virtual file. */ +PDFLIB_API int PDFLIB_CALL +PDF_delete_pvf(PDF *p, const char *filename, int reserved); +/* }}} */ + + +/* {{{ p_shading.c: shadings + * ---------------------------------------------------------------------- + */ + +/* Define a color blend (smooth shading) from the current fill color to the + * supplied color. */ +PDFLIB_API int PDFLIB_CALL +PDF_shading(PDF *p, + const char *shtype, + float x_0, float y_0, + float x_1, float y_1, + float c_1, float c_2, float c_3, float c_4, + const char *optlist); + +/* Define a shading pattern using a shading object. */ +PDFLIB_API int PDFLIB_CALL +PDF_shading_pattern(PDF *p, int shading, const char *optlist); + +/* Fill an area with a shading, based on a shading object. */ +PDFLIB_API void PDFLIB_CALL +PDF_shfill(PDF *p, int shading); +/* }}} */ + + +/* {{{ p_template.c: template definition + * ---------------------------------------------------------------------- + */ + +/* Start a new template definition. */ +PDFLIB_API int PDFLIB_CALL +PDF_begin_template(PDF *p, float width, float height); + +/* Finish a template definition. */ +PDFLIB_API void PDFLIB_CALL +PDF_end_template(PDF *p); +/* }}} */ + + +/* {{{ p_text.c: text output + * ---------------------------------------------------------------------- + */ + +/* Function duplicates with explicit string length for use with +strings containing null characters. These are for C and C++ clients only, +but are used internally for the other language bindings. */ + +/* Print text at the next line. The spacing between lines is determined by + * the "leading" parameter. */ +PDFLIB_API void PDFLIB_CALL +PDF_continue_text(PDF *p, const char *text); + +/* Same as PDF_continue_text but with explicit string length. */ +PDFLIB_API void PDFLIB_CALL +PDF_continue_text2(PDF *p, const char *text, int len); + +/* Place a single text line at (x, y) with various options. */ +PDFLIB_API void PDFLIB_CALL +PDF_fit_textline(PDF *p, const char *text, int len, float x, float y, + const char *optlist); + +/* This function is unsupported, and not considered part of the PDFlib API! */ +PDFLIB_API void PDFLIB_CALL +PDF_set_text_matrix(PDF *p, + float a, float b, float c, float d, float e, float f); + +/* Set the text output position. */ +PDFLIB_API void PDFLIB_CALL +PDF_set_text_pos(PDF *p, float x, float y); + +/* Print text in the current font and size at the current position. */ +PDFLIB_API void PDFLIB_CALL +PDF_show(PDF *p, const char *text); + +/* Same as PDF_show() but with explicit string length. */ +PDFLIB_API void PDFLIB_CALL +PDF_show2(PDF *p, const char *text, int len); + +/* Format text in the current font and size into the supplied text box + * according to the requested formatting mode, which must be one of + * "left", "right", "center", "justify", or "fulljustify". If width and height + * are 0, only a single line is placed at the point (left, top) in the + * requested mode. */ +PDFLIB_API int PDFLIB_CALL +PDF_show_boxed(PDF *p, const char *text, float left, float top, + float width, float height, const char *hmode, const char *feature); + +/* Same as PDF_show_boxed() but with explicit string length. + (unsupported) */ +PDFLIB_API int PDFLIB_CALL +PDF_show_boxed2(PDF *p, const char *text, int len, float left, float top, + float width, float height, const char *hmode, const char *feature); + +/* Print text in the current font at (x, y). */ +PDFLIB_API void PDFLIB_CALL +PDF_show_xy(PDF *p, const char *text, float x, float y); + +/* Same as PDF_show_xy() but with explicit string length. */ +PDFLIB_API void PDFLIB_CALL +PDF_show_xy2(PDF *p, const char *text, int len, float x, float y); + +/* Return the width of text in an arbitrary font. */ +PDFLIB_API float PDFLIB_CALL +PDF_stringwidth(PDF *p, const char *text, int font, float fontsize); + +/* Same as PDF_stringwidth but with explicit string length. */ +PDFLIB_API float PDFLIB_CALL +PDF_stringwidth2(PDF *p, const char *text, int len, int font, float fontsize); +/* }}} */ + + +/* {{{ p_type3.c: Type 3 (user-defined) fonts + * ---------------------------------------------------------------------- + */ + +/* Start a type 3 font definition. */ +PDFLIB_API void PDFLIB_CALL +PDF_begin_font(PDF *p, const char *fontname, int reserved, + float a, float b, float c, float d, float e, float f, const char *optlist); + +/* Start a type 3 glyph definition. */ +PDFLIB_API void PDFLIB_CALL +PDF_begin_glyph(PDF *p, const char *glyphname, float wx, + float llx, float lly, float urx, float ury); + +/* Terminate a type 3 font definition. */ +PDFLIB_API void PDFLIB_CALL +PDF_end_font(PDF *p); + +/* Terminate a type 3 glyph definition. */ +PDFLIB_API void PDFLIB_CALL +PDF_end_glyph(PDF *p); +/* }}} */ + + +/* {{{ p_xgstate.c: explicit graphic states + * ---------------------------------------------------------------------- + */ + +/* Create a gstate object definition. */ +PDFLIB_API int PDFLIB_CALL +PDF_create_gstate(PDF *p, const char *optlist); + +/* Activate a gstate object. */ +PDFLIB_API void PDFLIB_CALL +PDF_set_gstate(PDF *p, int gstate); +/* }}} */ + + +typedef struct +{ + jmp_buf jbuf; +} pdf_jmpbuf; + + +/* + * ---------------------------------------------------------------------- + * PDFlib API structure with function pointers to all API functions + * ---------------------------------------------------------------------- + */ + +/* The API structure with pointers to all PDFlib API functions */ +struct PDFlib_api_s { + /* version numbers for checking the DLL against client code */ + size_t sizeof_PDFlib_api; /* size of this structure */ + + int major; /* PDFlib major version number */ + int minor; /* PDFlib minor version number */ + int revision; /* PDFlib revision number */ + + int reserved; /* reserved */ + + /* {{{ p_annots.c: file attachments, notes, and links */ + void (PDFLIB_CALL * PDF_add_launchlink)(PDF *p, + float llx, float lly, float urx, + float ury, const char *filename); + void (PDFLIB_CALL * PDF_add_locallink)(PDF *p, + float llx, float lly, float urx, + float ury, int page, const char *optlist); + void (PDFLIB_CALL * PDF_add_note)(PDF *p, float llx, float lly, + float urx, float ury, const char *contents, const char *title, + const char *icon, int open); + void (PDFLIB_CALL * PDF_add_note2) (PDF *p, float llx, float lly, + float urx, float ury, const char *contents, int len_cont, + const char *title, int len_title, const char *icon, int open); + void (PDFLIB_CALL * PDF_add_pdflink)(PDF *p, + float llx, float lly, float urx, + float ury, const char *filename, int page, const char *optlist); + void (PDFLIB_CALL * PDF_add_weblink)(PDF *p, + float llx, float lly, float urx, float ury, const char *url); + void (PDFLIB_CALL * PDF_attach_file)(PDF *p, float llx, float lly, + float urx, float ury, const char *filename, + const char *description, + const char *author, const char *mimetype, const char *icon); + void (PDFLIB_CALL * PDF_attach_file2) (PDF *p, float llx, float lly, + float urx, float ury, const char *filename, int reserved, + const char *description, int len_descr, const char *author, + int len_auth, const char *mimetype, const char *icon); + void (PDFLIB_CALL * PDF_set_border_color)(PDF *p, + float red, float green, float blue); + void (PDFLIB_CALL * PDF_set_border_dash)(PDF *p, float b, float w); + + void (PDFLIB_CALL * PDF_set_border_style)(PDF *p, + const char *style, float width); + /* }}} */ + + /* {{{ p_basic.c: general functions */ + void (PDFLIB_CALL * PDF_begin_page)(PDF *p, float width, + float height); + void (PDFLIB_CALL * PDF_boot)(void); + void (PDFLIB_CALL * PDF_close)(PDF *p); + void (PDFLIB_CALL * PDF_delete)(PDF *); + void (PDFLIB_CALL * PDF_end_page)(PDF *p); + const PDFlib_api * (PDFLIB_CALL * PDF_get_api)(void); + const char * (PDFLIB_CALL * PDF_get_apiname) (PDF *p); + const char * (PDFLIB_CALL * PDF_get_buffer)(PDF *p, long *size); + const char * (PDFLIB_CALL * PDF_get_errmsg) (PDF *p); + int (PDFLIB_CALL * PDF_get_errnum) (PDF *p); + int (PDFLIB_CALL * PDF_get_majorversion)(void); + int (PDFLIB_CALL * PDF_get_minorversion)(void); + void * (PDFLIB_CALL * PDF_get_opaque)(PDF *p); + PDF* (PDFLIB_CALL * PDF_new)(void); + PDF* (PDFLIB_CALL * PDF_new2)(errorproc_t errorhandler, + allocproc_t allocproc, + reallocproc_t reallocproc, + freeproc_t freeproc, void *opaque); + int (PDFLIB_CALL * PDF_open_file)(PDF *p, const char *filename); + int (PDFLIB_CALL * PDF_open_fp)(PDF *p, FILE *fp); + void (PDFLIB_CALL * PDF_open_mem)(PDF *p, writeproc_t writeproc); + void (PDFLIB_CALL * PDF_shutdown)(void); + pdf_jmpbuf * (PDFLIB_CALL * pdf_jbuf)(PDF *p); + void (PDFLIB_CALL * pdf_exit_try)(PDF *p); + int (PDFLIB_CALL * pdf_catch)(PDF *p); + void (PDFLIB_CALL * pdf_rethrow)(PDF *p); + + /* }}} */ + + /* {{{ p_block.c: Variable Data Processing with blocks */ + int (PDFLIB_CALL * PDF_fill_imageblock) (PDF *p, int page, + const char *blockname, int image, const char *optlist); + int (PDFLIB_CALL * PDF_fill_pdfblock) (PDF *p, int page, + const char *blockname, int contents, const char *optlist); + int (PDFLIB_CALL * PDF_fill_textblock) (PDF *p, int page, + const char *blockname, const char *text, int len, + const char *optlist); + /* }}} */ + + /* {{{ p_color.c: color handling */ + int (PDFLIB_CALL * PDF_makespotcolor)(PDF *p, const char *spotname, + int reserved); + void (PDFLIB_CALL * PDF_setcolor)(PDF *p, + const char *fstype, const char *colorspace, + float c1, float c2, float c3, float c4); + void (PDFLIB_CALL * PDF_setgray)(PDF *p, float gray); + void (PDFLIB_CALL * PDF_setgray_stroke)(PDF *p, float gray); + void (PDFLIB_CALL * PDF_setgray_fill)(PDF *p, float gray); + void (PDFLIB_CALL * PDF_setrgbcolor)(PDF *p, float red, float green, + float blue); + void (PDFLIB_CALL * PDF_setrgbcolor_fill)(PDF *p, + float red, float green, float blue); + void (PDFLIB_CALL * PDF_setrgbcolor_stroke)(PDF *p, + float red, float green, float blue); + /* }}} */ + + /* {{{ p_draw.c: path construction, painting, and clipping */ + void (PDFLIB_CALL * PDF_arc)(PDF *p, float x, float y, + float r, float alpha, float beta); + void (PDFLIB_CALL * PDF_arcn)(PDF *p, float x, float y, + float r, float alpha, float beta); + void (PDFLIB_CALL * PDF_circle)(PDF *p, float x, float y, float r); + void (PDFLIB_CALL * PDF_clip)(PDF *p); + void (PDFLIB_CALL * PDF_closepath)(PDF *p); + void (PDFLIB_CALL * PDF_closepath_fill_stroke)(PDF *p); + void (PDFLIB_CALL * PDF_closepath_stroke)(PDF *p); + void (PDFLIB_CALL * PDF_curveto)(PDF *p, float x_1, float y_1, + float x_2, float y_2, float x_3, float y_3); + void (PDFLIB_CALL * PDF_endpath)(PDF *p); + void (PDFLIB_CALL * PDF_fill)(PDF *p); + void (PDFLIB_CALL * PDF_fill_stroke)(PDF *p); + void (PDFLIB_CALL * PDF_lineto)(PDF *p, float x, float y); + void (PDFLIB_CALL * PDF_moveto)(PDF *p, float x, float y); + void (PDFLIB_CALL * PDF_rect)(PDF *p, float x, float y, + float width, float height); + void (PDFLIB_CALL * PDF_stroke)(PDF *p); + /* }}} */ + + /* {{{ p_encoding.c: encoding handling */ + void (PDFLIB_CALL * PDF_encoding_set_char) (PDF *p, const char *encoding, + int slot, const char *glyphname, int uv); + /* }}} */ + + /* {{{ p_font.c: text and font handling */ + int (PDFLIB_CALL * PDF_findfont)(PDF *p, const char *fontname, + const char *encoding, int embed); + int (PDFLIB_CALL * PDF_load_font)(PDF *p, const char *fontname, + int len, const char *encoding, const char *optlist); + void (PDFLIB_CALL * PDF_setfont)(PDF *p, int font, float fontsize); + /* }}} */ + + /* {{{ p_gstate.c graphics state */ + void (PDFLIB_CALL * PDF_concat)(PDF *p, float a, float b, + float c, float d, float e, float f); + void (PDFLIB_CALL * PDF_initgraphics)(PDF *p); + void (PDFLIB_CALL * PDF_restore)(PDF *p); + void (PDFLIB_CALL * PDF_rotate)(PDF *p, float phi); + void (PDFLIB_CALL * PDF_save)(PDF *p); + void (PDFLIB_CALL * PDF_scale)(PDF *p, float sx, float sy); + void (PDFLIB_CALL * PDF_setdash)(PDF *p, float b, float w); + void (PDFLIB_CALL * PDF_setdashpattern) (PDF *p, const char *optlist); + void (PDFLIB_CALL * PDF_setflat)(PDF *p, float flatness); + void (PDFLIB_CALL * PDF_setlinecap)(PDF *p, int linecap); + void (PDFLIB_CALL * PDF_setlinejoin)(PDF *p, int linejoin); + void (PDFLIB_CALL * PDF_setlinewidth)(PDF *p, float width); + void (PDFLIB_CALL * PDF_setmatrix)(PDF *p, float a, float b, + float c, float d, float e, float f); + void (PDFLIB_CALL * PDF_setmiterlimit)(PDF *p, float miter); + void (PDFLIB_CALL * PDF_setpolydash)(PDF *p, float *dasharray, + int length); + void (PDFLIB_CALL * PDF_skew)(PDF *p, float alpha, float beta); + void (PDFLIB_CALL * PDF_translate)(PDF *p, float tx, float ty); + /* }}} */ + + /* {{{ p_hyper.c: bookmarks and document info fields */ + int (PDFLIB_CALL * PDF_add_bookmark)(PDF *p, const char *text, + int parent, int open); + int (PDFLIB_CALL * PDF_add_bookmark2) (PDF *p, const char *text, int len, + int parent, int open); + void (PDFLIB_CALL * PDF_add_nameddest) (PDF *p, const char *name, + int reserved, const char *optlist); + void (PDFLIB_CALL * PDF_set_info)(PDF *p, const char *key, + const char *value); + void (PDFLIB_CALL * PDF_set_info2) (PDF *p, const char *key, + const char *value, int len); + /* }}} */ + + /* {{{ p_icc.c: ICC profile handling */ + int (PDFLIB_CALL * PDF_load_iccprofile)(PDF *p, const char *profilename, + int reserved, const char *optlist); + /* }}} */ + + /* {{{ p_image.c: image handling */ + void (PDFLIB_CALL * PDF_add_thumbnail)(PDF *p, int image); + void (PDFLIB_CALL * PDF_close_image)(PDF *p, int image); + void (PDFLIB_CALL * PDF_fit_image) (PDF *p, int image, float x, float y, + const char *optlist); + int (PDFLIB_CALL * PDF_load_image) (PDF *p, const char *imagetype, + const char *filename, int reserved, const char *optlist); + int (PDFLIB_CALL * PDF_open_CCITT)(PDF *p, const char *filename, + int width, int height, + int BitReverse, int K, int BlackIs1); + int (PDFLIB_CALL * PDF_open_image)(PDF *p, const char *imagetype, + const char *source, const char *data, long length, int width, + int height, int components, int bpc, const char *params); + int (PDFLIB_CALL * PDF_open_image_file)(PDF *p, const char *imagetype, + const char *filename, const char *stringparam, int intparam); + void (PDFLIB_CALL * PDF_place_image)(PDF *p, int image, + float x, float y, float scale); + /* }}} */ + + /* {{{ p_kerning.c: font kerning */ + /* }}} */ + + /* {{{ p_params.c: parameter handling */ + const char* (PDFLIB_CALL * PDF_get_parameter)(PDF *p, + const char *key, float modifier); + float (PDFLIB_CALL * PDF_get_value)(PDF *p, const char *key, + float modifier); + void (PDFLIB_CALL * PDF_set_parameter)(PDF *p, + const char *key, const char *value); + void (PDFLIB_CALL * PDF_set_value)(PDF *p, const char *key, + float value); + /* }}} */ + + /* {{{ p_pattern.c: pattern definition */ + int (PDFLIB_CALL * PDF_begin_pattern)(PDF *p, + float width, float height, + float xstep, float ystep, int painttype); + void (PDFLIB_CALL * PDF_end_pattern)(PDF *p); + /* }}} */ + + /* {{{ p_pdi.c: PDF import (requires the PDI library) */ + void (PDFLIB_CALL * PDF_close_pdi)(PDF *p, int doc); + void (PDFLIB_CALL * PDF_close_pdi_page)(PDF *p, int page); + void (PDFLIB_CALL * PDF_fit_pdi_page) (PDF *p, int page, float x, + float y, const char *optlist); + const char * (PDFLIB_CALL * PDF_get_pdi_parameter)(PDF *p, + const char *key, int doc, int page, int reserved, int *len); + float (PDFLIB_CALL * PDF_get_pdi_value)(PDF *p, const char *key, + int doc, int page, int reserved); + int (PDFLIB_CALL * PDF_open_pdi)(PDF *p, const char *filename, + const char *optlist, int reserved); + int (PDFLIB_CALL * PDF_open_pdi_callback) (PDF *p, void *opaque, + size_t filesize, size_t (*readproc)(void *opaque, void *buffer, + size_t size), int (*seekproc)(void *opaque, long offset), + const char *optlist); + int (PDFLIB_CALL * PDF_open_pdi_page)(PDF *p, + int doc, int pagenumber, const char *optlist); + void (PDFLIB_CALL * PDF_place_pdi_page)(PDF *p, int page, + float x, float y, float sx, float sy); + int (PDFLIB_CALL * PDF_process_pdi)(PDF *p, + int doc, int page, const char *optlist); + /* }}} */ + + /* {{{ p_resource.c: resources and virtual file system handling */ + void (PDFLIB_CALL * PDF_create_pvf)(PDF *p, const char *filename, + int reserved, const void *data, size_t size, + const char *options); + int (PDFLIB_CALL * PDF_delete_pvf)(PDF *p, const char *filename, + int reserved); + /* }}} */ + + /* {{{ p_shading.c: shadings */ + int (PDFLIB_CALL * PDF_shading) (PDF *p, const char *shtype, float x_0, + float y_0, float x_1, float y_1, float c_1, float c_2, float c_3, + float c_4, const char *optlist); + int (PDFLIB_CALL * PDF_shading_pattern) (PDF *p, int shading, + const char *optlist); + void (PDFLIB_CALL * PDF_shfill) (PDF *p, int shading); + /* }}} */ + + /* {{{ p_template.c: template definition */ + int (PDFLIB_CALL * PDF_begin_template)(PDF *p, + float width, float height); + void (PDFLIB_CALL * PDF_end_template)(PDF *p); + /* }}} */ + + /* {{{ p_text.c: text output */ + void (PDFLIB_CALL * PDF_continue_text)(PDF *p, const char *text); + void (PDFLIB_CALL * PDF_continue_text2)(PDF *p, const char *text, + int len); + void (PDFLIB_CALL * PDF_fit_textline)(PDF *p, const char *text, + int len, float x, float y, const char *optlist); + void (PDFLIB_CALL * PDF_set_text_pos)(PDF *p, float x, float y); + void (PDFLIB_CALL * PDF_show)(PDF *p, const char *text); + void (PDFLIB_CALL * PDF_show2)(PDF *p, const char *text, int len); + int (PDFLIB_CALL * PDF_show_boxed)(PDF *p, const char *text, + float left, float top, float width, float height, + const char *hmode, const char *feature); + void (PDFLIB_CALL * PDF_show_xy)(PDF *p, const char *text, float x, + float y); + void (PDFLIB_CALL * PDF_show_xy2)(PDF *p, const char *text, + int len, float x, float y); + float (PDFLIB_CALL * PDF_stringwidth)(PDF *p, + const char *text, int font, float fontsize); + float (PDFLIB_CALL * PDF_stringwidth2)(PDF *p, const char *text, + int len, int font, float fontsize); + /* }}} */ + + /* {{{ p_type3.c: Type 3 (user-defined) fonts */ + void (PDFLIB_CALL * PDF_begin_font)(PDF *p, const char *fontname, + int reserved, float a, float b, float c, float d, float e, float f, + const char *optlist); + void (PDFLIB_CALL * PDF_begin_glyph)(PDF *p, const char *glyphname, + float wx, float llx, float lly, float urx, float ury); + void (PDFLIB_CALL * PDF_end_font)(PDF *p); + void (PDFLIB_CALL * PDF_end_glyph)(PDF *p); + /* }}} */ + + /* {{{ p_xgstate.c: explicit graphic states */ + int (PDFLIB_CALL * PDF_create_gstate) (PDF *p, const char *optlist); + void (PDFLIB_CALL * PDF_set_gstate) (PDF *p, int gstate); + /* }}} */ +}; + +/* + * ---------------------------------------------------------------------- + * page size formats + * ---------------------------------------------------------------------- + */ + +/* The page sizes are only available to the C and C++ bindings */ +#define a0_width (float) 2380.0 +#define a0_height (float) 3368.0 +#define a1_width (float) 1684.0 +#define a1_height (float) 2380.0 +#define a2_width (float) 1190.0 +#define a2_height (float) 1684.0 +#define a3_width (float) 842.0 +#define a3_height (float) 1190.0 +#define a4_width (float) 595.0 +#define a4_height (float) 842.0 +#define a5_width (float) 421.0 +#define a5_height (float) 595.0 +#define a6_width (float) 297.0 +#define a6_height (float) 421.0 +#define b5_width (float) 501.0 +#define b5_height (float) 709.0 +#define letter_width (float) 612.0 +#define letter_height (float) 792.0 +#define legal_width (float) 612.0 +#define legal_height (float) 1008.0 +#define ledger_width (float) 1224.0 +#define ledger_height (float) 792.0 +#define p11x17_width (float) 792.0 +#define p11x17_height (float) 1224.0 + + +/* + * ---------------------------------------------------------------------- + * exception handling with try/catch implementation + * ---------------------------------------------------------------------- + */ + +/* Set up an exception handling frame; must always be paired with PDF_CATCH().*/ + +#define PDF_TRY(p) if (p) { if (setjmp(pdf_jbuf(p)->jbuf) == 0) + +/* Inform the exception machinery that a PDF_TRY() will be left without + entering the corresponding PDF_CATCH( ) clause. */ +#define PDF_EXIT_TRY(p) pdf_exit_try(p) + +/* Catch an exception; must always be paired with PDF_TRY(). */ +#define PDF_CATCH(p) } if (pdf_catch(p)) + +/* Re-throw an exception to another handler. */ +#define PDF_RETHROW(p) pdf_rethrow(p) + +/* + * ---------------------------------------------------------------------- + * End of public declarations + * ---------------------------------------------------------------------- + */ + + +/* + * ---------------------------------------------------------------------- + * Private stuff, do not use explicitly but only via the above macros! + * ---------------------------------------------------------------------- + */ + +PDFLIB_API pdf_jmpbuf * PDFLIB_CALL +pdf_jbuf(PDF *p); + +PDFLIB_API void PDFLIB_CALL +pdf_exit_try(PDF *p); + +PDFLIB_API int PDFLIB_CALL +pdf_catch(PDF *p); + +PDFLIB_API void PDFLIB_CALL +pdf_rethrow(PDF *p); + +PDFLIB_API void PDFLIB_CALL +pdf_throw(PDF *p, const char *binding, const char *apiname, const char *errmsg); + + +/* + * ---------------------------------------------------------------------- + * End of useful stuff + * ---------------------------------------------------------------------- + */ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#if defined(__MWERKS__) && defined(PDFLIB_EXPORTS) +#pragma export off +#endif + +#endif /* PDFLIB_H */ + +/* + * vim600: sw=4 fdm=marker + */ diff --git a/src/libs/pdflib/libs/pdflib/pdflib.rc b/src/libs/pdflib/libs/pdflib/pdflib.rc new file mode 100644 index 0000000000..b2fb6c4d1b --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/pdflib.rc @@ -0,0 +1,117 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 5,0,3,3 + PRODUCTVERSION 5,0,3,3 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "www.pdflib.com\0" + VALUE "CompanyName", "PDFlib GmbH\0" + VALUE "FileDescription", "PDFlib - a library for generating PDF on the fly\0" + VALUE "FileVersion", "5.0.0\0" + VALUE "LegalCopyright", "Copyright © 1997-2001 PDFlib GmbH\0" + VALUE "OriginalFilename", "pdflib.dll\0" + VALUE "ProductName", "PDFlib for Windows\0" + VALUE "ProductVersion", "5.0.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resrc1.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""resource.h""\r\n" + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDRETRY "pdflib" +END + +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/src/libs/pdflib/libs/pdflib/pdflib_dll.dsp b/src/libs/pdflib/libs/pdflib/pdflib_dll.dsp new file mode 100644 index 0000000000..d066e4376d --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/pdflib_dll.dsp @@ -0,0 +1,76 @@ +# Microsoft Developer Studio Project File - Name="pdflib_dll" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=pdflib_dll - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pdflib_dll.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pdflib_dll.mak" CFG="pdflib_dll - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pdflib_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Release_dll" +# PROP Intermediate_Dir "Release_dll" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../flate" /I "../tiff" /I "../png" /I "../pdcore" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_MT" /D "PDFLIB_EXPORTS" /D "PDFLIB_PSP_BUILD" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../flate" /I "../tiff" /I "../png" /I "../pdcore" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_MT" /D "PDFLIB_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x55300000" /version:3.1 /dll /pdb:none /machine:I386 /out:"Release_dll/pdflib.dll" +# SUBTRACT BASE LINK32 /debug /nodefaultlib +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x55300000" /version:3.1 /dll /pdb:none /machine:I386 /out:"Release_dll/pdflib.dll" +# SUBTRACT LINK32 /debug /nodefaultlib +# Begin Target + +# Name "pdflib_dll - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\p_basic.c +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\pdflib.rc +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/pdflib/pdflib_pdi.dsp b/src/libs/pdflib/libs/pdflib/pdflib_pdi.dsp new file mode 100644 index 0000000000..571066ba71 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/pdflib_pdi.dsp @@ -0,0 +1,120 @@ +# Microsoft Developer Studio Project File - Name="pdflib_pdi" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=pdflib_pdi - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pdflib_pdi.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pdflib_pdi.mak" CFG="pdflib_pdi - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pdflib_pdi - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "pdflib_pdi - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "pdflib_pdi - Win32 Release mtDLL" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pdflib_pdi - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /I "../pdpage" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"Release/pdflib.lib" + +!ELSEIF "$(CFG)" == "pdflib_pdi - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /I "../pdpage" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"Debug/pdflib.lib" + +!ELSEIF "$(CFG)" == "pdflib_pdi - Win32 Release mtDLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL" +# PROP BASE Intermediate_Dir "Release_mtDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL" +# PROP Intermediate_Dir "Release_mtDLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /I "../pdpage" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FD /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MD /W3 /O2 /I "../png" /I "../flate" /I "../tiff" /I "../pdi" /I "../pdcore" /I "../pdpage" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"pdflib.lib" +# ADD LIB32 /nologo /out:"Release_mtDLL\pdflib.lib" + +!ENDIF + +# Begin Target + +# Name "pdflib_pdi - Win32 Release" +# Name "pdflib_pdi - Win32 Debug" +# Name "pdflib_pdi - Win32 Release mtDLL" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\p_basic.c +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/pdflib/pdflib_pdi_dll.dsp b/src/libs/pdflib/libs/pdflib/pdflib_pdi_dll.dsp new file mode 100644 index 0000000000..0eb9444570 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/pdflib_pdi_dll.dsp @@ -0,0 +1,115 @@ +# Microsoft Developer Studio Project File - Name="pdflib_pdi_dll" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=pdflib_pdi_dll - Win32 Debug DLL +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "pdflib_pdi_dll.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "pdflib_pdi_dll.mak" CFG="pdflib_pdi_dll - Win32 Debug DLL" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "pdflib_pdi_dll - Win32 Release DLL" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "pdflib_pdi_dll - Win32 Debug DLL" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "pdflib_pdi_dll - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Release_DLL" +# PROP BASE Intermediate_Dir "Release_DLL" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Release_DLL" +# PROP Intermediate_Dir "Release_DLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /Z7 /O2 /I "../flate" /I "../tiff" /I "../pdi" /I "../png" /I "../pdcore" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_MT" /D "PDFLIB_EXPORTS" /FD /c +# SUBTRACT BASE CPP /YX +# ADD CPP /nologo /MT /W3 /Z7 /O2 /I "../flate" /I "../tiff" /I "../pdi" /I "../png" /I "../pdcore" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_MT" /D "PDFLIB_EXPORTS" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x55300000" /version:5.0 /dll /pdb:none /machine:I386 /out:"Release_dll/pdflib.dll" +# SUBTRACT BASE LINK32 /debug /nodefaultlib +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x55300000" /version:5.0 /dll /pdb:none /machine:I386 /out:"Release_dll/pdflib.dll" +# SUBTRACT LINK32 /debug /nodefaultlib + +!ELSEIF "$(CFG)" == "pdflib_pdi_dll - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_DLL" +# PROP BASE Intermediate_Dir "Debug_DLL" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_DLL" +# PROP Intermediate_Dir "Debug_DLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../flate" /I "../tiff" /I "../pdi" /I "../png" /I "../pdcore" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_MT" /D "PDFLIB_EXPORTS" /FR /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../flate" /I "../tiff" /I "../pdi" /I "../png" /I "../pdcore" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_MT" /D "PDFLIB_EXPORTS" /FR /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x55300000" /version:5.0 /dll /pdb:none /debug /machine:I386 /out:"Debug_dll/pdflib.dll" +# SUBTRACT BASE LINK32 /nodefaultlib +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x55300000" /version:5.0 /dll /pdb:none /debug /machine:I386 /out:"Debug_dll/pdflib.dll" +# SUBTRACT LINK32 /nodefaultlib + +!ENDIF + +# Begin Target + +# Name "pdflib_pdi_dll - Win32 Release DLL" +# Name "pdflib_pdi_dll - Win32 Debug DLL" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\p_basic.c +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\pdflib.rc +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/pdflib/resource.h b/src/libs/pdflib/libs/pdflib/resource.h new file mode 100644 index 0000000000..bbfa70fdc2 --- /dev/null +++ b/src/libs/pdflib/libs/pdflib/resource.h @@ -0,0 +1,18 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by pdflib.rc +// + +// Next default values for new objects +// +/* $Id: resource.h,v 1.1 2004/10/06 17:46:49 laplace Exp $ */ + +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/libs/pdflib/libs/png/Jamfile b/src/libs/pdflib/libs/png/Jamfile new file mode 100644 index 0000000000..9b4980c500 --- /dev/null +++ b/src/libs/pdflib/libs/png/Jamfile @@ -0,0 +1,22 @@ +SubDir OBOS_TOP src libs pdflib libs png ; + +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs flate ] ; +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs pdcore ] ; + +UseLibraryHeaders pdflib ; + +StaticLibrary pdf : + png.c + pngerror.c + pngget.c + pngmem.c + pngread.c + pngrio.c + pngrtran.c + pngrutil.c + pngset.c + pngtrans.c + pngvcrd.c +: STATIC_LIBRARY_DIR +; + diff --git a/src/libs/pdflib/libs/png/Makefile b/src/libs/pdflib/libs/png/Makefile new file mode 100644 index 0000000000..e7b4b1fc78 --- /dev/null +++ b/src/libs/pdflib/libs/png/Makefile @@ -0,0 +1,38 @@ +# Makefile for libpng 1.2.5 +# This generates a libtool convenience library +# $Id: Makefile,v 1.1 2004/10/06 17:46:50 laplace Exp $ + +top_builddir = ../.. + +include ../../config/mkcommon.inc + +LIBNAME = $(PNGLIBLINK) +INCLUDES = $(ZLIBINC) $(PDCORELIBINC) + +SRC = \ + $(srcdir)/png.c \ + $(srcdir)/pngset.c \ + $(srcdir)/pngget.c \ + $(srcdir)/pngrutil.c \ + $(srcdir)/pngtrans.c \ + $(srcdir)/pngread.c \ + $(srcdir)/pngrio.c \ + $(srcdir)/pngrtran.c \ + $(srcdir)/pngmem.c \ + $(srcdir)/pngerror.c + +OBJS = \ + $(srcdir)/png$(LO) \ + $(srcdir)/pngset$(LO) \ + $(srcdir)/pngget$(LO) \ + $(srcdir)/pngrutil$(LO) \ + $(srcdir)/pngtrans$(LO) \ + $(srcdir)/pngread$(LO) \ + $(srcdir)/pngrio$(LO) \ + $(srcdir)/pngrtran$(LO) \ + $(srcdir)/pngmem$(LO) \ + $(srcdir)/pngerror$(LO) + +include ../../config/mklibs.inc + +# Automatically generated dependencies diff --git a/src/libs/pdflib/libs/png/png.c b/src/libs/pdflib/libs/png/png.c new file mode 100644 index 0000000000..5cf6ba9758 --- /dev/null +++ b/src/libs/pdflib/libs/png/png.c @@ -0,0 +1,808 @@ +/* PDFlib GmbH cvsid: $Id: png.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* png.c - location for general purpose libpng functions + * + * libpng version 1.2.5 - October 3, 2002 + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + */ + +#define PNG_INTERNAL +#define PNG_NO_EXTERN +#include "png.h" + +/* Generate a compiler error if there is an old png.h in the search path. */ +typedef version_1_2_5 Your_png_h_is_not_version_1_2_5; + +/* Version information for C files. This had better match the version + * string defined in png.h. */ + +#ifdef PNG_USE_GLOBAL_ARRAYS +/* png_libpng_ver was changed to a function in version 1.0.5c */ +const char png_libpng_ver[18] = "1.2.5"; + +/* png_sig was changed to a function in version 1.0.5c */ +/* Place to hold the signature string for a PNG file. */ +const png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + +/* Invoke global declarations for constant strings for known chunk types */ +PNG_IHDR; +PNG_IDAT; +PNG_IEND; +PNG_PLTE; +PNG_bKGD; +PNG_cHRM; +PNG_gAMA; +PNG_hIST; +PNG_iCCP; +PNG_iTXt; +PNG_oFFs; +PNG_pCAL; +PNG_sCAL; +PNG_pHYs; +PNG_sBIT; +PNG_sPLT; +PNG_sRGB; +PNG_tEXt; +PNG_tIME; +PNG_tRNS; +PNG_zTXt; + +/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + +/* start of interlace block */ +const int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; + +/* offset to next interlace block */ +const int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; + +/* start of interlace block in the y direction */ +const int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; + +/* offset to next interlace block in the y direction */ +const int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; + +/* width of interlace block (used in assembler routines only) */ +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW +const int FARDATA png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; +#endif + +/* Height of interlace block. This is not currently used - if you need + * it, uncomment it here and in png.h +const int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; +*/ + +/* Mask to determine which pixels are valid in a pass */ +const int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; + +/* Mask to determine which pixels to overwrite while displaying */ +const int FARDATA png_pass_dsp_mask[] + = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; + +#endif + +/* Tells libpng that we have already handled the first "num_bytes" bytes + * of the PNG file signature. If the PNG data is embedded into another + * stream we can set num_bytes = 8 so that libpng will not attempt to read + * or write any of the magic bytes before it starts on the IHDR. + */ + +void PNGAPI +png_set_sig_bytes(png_structp png_ptr, int num_bytes) +{ + png_debug(1, "in png_set_sig_bytes\n"); + if (num_bytes > 8) + png_error(png_ptr, "Too many bytes for PNG signature."); + + png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); +} + +/* Checks whether the supplied bytes match the PNG signature. We allow + * checking less than the full 8-byte signature so that those apps that + * already read the first few bytes of a file to determine the file type + * can simply check the remaining bytes for extra assurance. Returns + * an integer less than, equal to, or greater than zero if sig is found, + * respectively, to be less than, to match, or be greater than the correct + * PNG signature (this is the same behaviour as strcmp, memcmp, etc). + */ +int PNGAPI +png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) +{ + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + if (num_to_check > 8) + num_to_check = 8; + else if (num_to_check < 1) + return (0); + + if (start > 7) + return (0); + + if (start + num_to_check > 8) + num_to_check = 8 - start; + + return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); +} + +/* (Obsolete) function to check signature bytes. It does not allow one + * to check a partial signature. This function might be removed in the + * future - use png_sig_cmp(). Returns true (nonzero) if the file is a PNG. + */ +int PNGAPI +png_check_sig(png_bytep sig, int num) +{ + return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); +} + +/* Function to allocate memory for zlib and clear it to 0. */ +#ifdef PNG_1_0_X +voidpf PNGAPI +#else +voidpf /* private */ +#endif +png_zalloc(voidpf png_ptr, uInt items, uInt size) +{ + png_uint_32 num_bytes = (png_uint_32)items * size; + png_voidp ptr; + png_structp p = (png_structp) png_ptr; + png_uint_32 save_flags=p->flags; + + p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; + ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); + p->flags=save_flags; + +#ifndef PNG_NO_ZALLOC_ZERO + if (ptr == NULL) + return ((voidpf)ptr); + + if (num_bytes > (png_uint_32)0x8000L) + { + png_memset(ptr, 0, (png_size_t)0x8000L); + png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, + (png_size_t)(num_bytes - (png_uint_32)0x8000L)); + } + else + { + png_memset(ptr, 0, (png_size_t)num_bytes); + } +#endif + return ((voidpf)ptr); +} + +/* function to free memory for zlib */ +#ifdef PNG_1_0_X +void PNGAPI +#else +void /* private */ +#endif +png_zfree(voidpf png_ptr, voidpf ptr) +{ + png_free((png_structp)png_ptr, (png_voidp)ptr); +} + +/* Reset the CRC variable to 32 bits of 1's. Care must be taken + * in case CRC is > 32 bits to leave the top bits 0. + */ +void /* PRIVATE */ +png_reset_crc(png_structp png_ptr) +{ + png_ptr->crc = crc32(0, Z_NULL, 0); +} + +/* Calculate the CRC over a section of data. We can only pass as + * much data to this routine as the largest single buffer size. We + * also check that this data will actually be used before going to the + * trouble of calculating it. + */ +void /* PRIVATE */ +png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) +{ + int need_crc = 1; + + if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ + { + if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == + (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) + need_crc = 0; + } + else /* critical */ + { + if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) + need_crc = 0; + } + + if (need_crc) + png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); +} + +/* Allocate the memory for an info_struct for the application. We don't + * really need the png_ptr, but it could potentially be useful in the + * future. This should be used in favour of malloc(sizeof(png_info)) + * and png_info_init() so that applications that want to use a shared + * libpng don't have to be recompiled if png_info changes size. + */ +png_infop PNGAPI +png_create_info_struct(png_structp png_ptr) +{ + png_infop info_ptr; + + png_debug(1, "in png_create_info_struct\n"); + if(png_ptr == NULL) return (NULL); +#ifdef PNG_USER_MEM_SUPPORTED + info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, + png_ptr->malloc_fn, png_ptr->mem_ptr); +#else + info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); +#endif + if (info_ptr != NULL) + png_info_init_3(&info_ptr, sizeof(png_info)); + + return (info_ptr); +} + +/* This function frees the memory associated with a single info struct. + * Normally, one would use either png_destroy_read_struct() or + * png_destroy_write_struct() to free an info struct, but this may be + * useful for some applications. + */ +void PNGAPI +png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) +{ + png_infop info_ptr = NULL; + + png_debug(1, "in png_destroy_info_struct\n"); + if (info_ptr_ptr != NULL) + info_ptr = *info_ptr_ptr; + + if (info_ptr != NULL) + { + png_info_destroy(png_ptr, info_ptr); + +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, + png_ptr->mem_ptr); +#else + png_destroy_struct((png_voidp)info_ptr); +#endif + *info_ptr_ptr = NULL; + } +} + +/* Initialize the info structure. This is now an internal function (0.89) + * and applications using it are urged to use png_create_info_struct() + * instead. + */ +/* PDFlib GmbH +#undef png_info_init +*/ +void PNGAPI +png_info_init(png_infop info_ptr) +{ + /* We only come here via pre-1.0.12-compiled applications */ + png_info_init_3(&info_ptr, 0); +} + +void PNGAPI +png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) +{ + png_infop info_ptr = *ptr_ptr; + + png_debug(1, "in png_info_init_3\n"); + + if(sizeof(png_info) > png_info_struct_size) + { + png_destroy_struct(info_ptr); + info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); + *ptr_ptr = info_ptr; + } + + /* set everything to 0 */ + png_memset(info_ptr, 0, sizeof (png_info)); +} + +#ifdef PNG_FREE_ME_SUPPORTED +void PNGAPI +png_data_freer(png_structp png_ptr, png_infop info_ptr, + int freer, png_uint_32 mask) +{ + png_debug(1, "in png_data_freer\n"); + if (png_ptr == NULL || info_ptr == NULL) + return; + if(freer == PNG_DESTROY_WILL_FREE_DATA) + info_ptr->free_me |= mask; + else if(freer == PNG_USER_WILL_FREE_DATA) + info_ptr->free_me &= ~mask; + else + png_warning(png_ptr, + "Unknown freer parameter in png_data_freer."); +} +#endif + +void PNGAPI +png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, + int num) +{ + png_debug(1, "in png_free_data\n"); + if (png_ptr == NULL || info_ptr == NULL) + return; + +#if defined(PNG_TEXT_SUPPORTED) +/* free text item num or (if num == -1) all text items */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) +#else +if (mask & PNG_FREE_TEXT) +#endif +{ + if (num != -1) + { + if (info_ptr->text && info_ptr->text[num].key) + { + png_free(png_ptr, info_ptr->text[num].key); + info_ptr->text[num].key = NULL; + } + } + else + { + int i; + for (i = 0; i < info_ptr->num_text; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); + png_free(png_ptr, info_ptr->text); + info_ptr->text = NULL; + info_ptr->num_text=0; + } +} +#endif + +#if defined(PNG_tRNS_SUPPORTED) +/* free any tRNS entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) +#endif +{ + png_free(png_ptr, info_ptr->trans); + info_ptr->valid &= ~PNG_INFO_tRNS; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; +#endif + info_ptr->trans = NULL; +} +#endif + +#if defined(PNG_sCAL_SUPPORTED) +/* free any sCAL entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) +#else +if (mask & PNG_FREE_SCAL) +#endif +{ +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, info_ptr->scal_s_width); + png_free(png_ptr, info_ptr->scal_s_height); + info_ptr->scal_s_width = NULL; + info_ptr->scal_s_height = NULL; +#endif + info_ptr->valid &= ~PNG_INFO_sCAL; +} +#endif + +#if defined(PNG_pCAL_SUPPORTED) +/* free any pCAL entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) +#else +if (mask & PNG_FREE_PCAL) +#endif +{ + png_free(png_ptr, info_ptr->pcal_purpose); + png_free(png_ptr, info_ptr->pcal_units); + info_ptr->pcal_purpose = NULL; + info_ptr->pcal_units = NULL; + if (info_ptr->pcal_params != NULL) + { + int i; + for (i = 0; i < (int)info_ptr->pcal_nparams; i++) + { + png_free(png_ptr, info_ptr->pcal_params[i]); + info_ptr->pcal_params[i]=NULL; + } + png_free(png_ptr, info_ptr->pcal_params); + info_ptr->pcal_params = NULL; + } + info_ptr->valid &= ~PNG_INFO_pCAL; +} +#endif + +#if defined(PNG_iCCP_SUPPORTED) +/* free any iCCP entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) +#else +if (mask & PNG_FREE_ICCP) +#endif +{ + png_free(png_ptr, info_ptr->iccp_name); + png_free(png_ptr, info_ptr->iccp_profile); + info_ptr->iccp_name = NULL; + info_ptr->iccp_profile = NULL; + info_ptr->valid &= ~PNG_INFO_iCCP; +} +#endif + +#if defined(PNG_sPLT_SUPPORTED) +/* free a given sPLT entry, or (if num == -1) all sPLT entries */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) +#else +if (mask & PNG_FREE_SPLT) +#endif +{ + if (num != -1) + { + if(info_ptr->splt_palettes) + { + png_free(png_ptr, info_ptr->splt_palettes[num].name); + png_free(png_ptr, info_ptr->splt_palettes[num].entries); + info_ptr->splt_palettes[num].name = NULL; + info_ptr->splt_palettes[num].entries = NULL; + } + } + else + { + if(info_ptr->splt_palettes_num) + { + int i; + for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); + + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes = NULL; + info_ptr->splt_palettes_num = 0; + } + info_ptr->valid &= ~PNG_INFO_sPLT; + } +} +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) +#else +if (mask & PNG_FREE_UNKN) +#endif +{ + if (num != -1) + { + if(info_ptr->unknown_chunks) + { + png_free(png_ptr, info_ptr->unknown_chunks[num].data); + info_ptr->unknown_chunks[num].data = NULL; + } + } + else + { + int i; + + if(info_ptr->unknown_chunks_num) + { + for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); + + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks = NULL; + info_ptr->unknown_chunks_num = 0; + } + } +} +#endif + +#if defined(PNG_hIST_SUPPORTED) +/* free any hIST entry */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_HIST) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) +#endif +{ + png_free(png_ptr, info_ptr->hist); + info_ptr->hist = NULL; + info_ptr->valid &= ~PNG_INFO_hIST; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_HIST; +#endif +} +#endif + +/* free any PLTE entry that was internally allocated */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) +#else +if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) +#endif +{ + png_zfree(png_ptr, info_ptr->palette); + info_ptr->palette = NULL; + info_ptr->valid &= ~PNG_INFO_PLTE; +#ifndef PNG_FREE_ME_SUPPORTED + png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; +#endif + info_ptr->num_palette = 0; +} + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* free any image bits attached to the info structure */ +#ifdef PNG_FREE_ME_SUPPORTED +if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) +#else +if (mask & PNG_FREE_ROWS) +#endif +{ + if(info_ptr->row_pointers) + { + int row; + for (row = 0; row < (int)info_ptr->height; row++) + { + png_free(png_ptr, info_ptr->row_pointers[row]); + info_ptr->row_pointers[row]=NULL; + } + png_free(png_ptr, info_ptr->row_pointers); + info_ptr->row_pointers=NULL; + } + info_ptr->valid &= ~PNG_INFO_IDAT; +} +#endif + +#ifdef PNG_FREE_ME_SUPPORTED + if(num == -1) + info_ptr->free_me &= ~mask; + else + info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); +#endif +} + +/* This is an internal routine to free any memory that the info struct is + * pointing to before re-using it or freeing the struct itself. Recall + * that png_free() checks for NULL pointers for us. + */ +void /* PRIVATE */ +png_info_destroy(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_info_destroy\n"); + + png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->num_chunk_list) + { + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + png_ptr->num_chunk_list=0; + } +#endif + + png_info_init_3(&info_ptr, sizeof(png_info)); +} + +/* This function returns a pointer to the io_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy() or png_read_destroy() are called. + */ +png_voidp PNGAPI +png_get_io_ptr(png_structp png_ptr) +{ + return (png_ptr->io_ptr); +} + +#if !defined(PNG_NO_STDIO) +/* Initialize the default input/output functions for the PNG file. If you + * use your own read or write routines, you can call either png_set_read_fn() + * or png_set_write_fn() instead of png_init_io(). If you have defined + * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't + * necessarily available. + */ +void PNGAPI +png_init_io(png_structp png_ptr, png_FILE_p fp) +{ + png_debug(1, "in png_init_io\n"); + png_ptr->io_ptr = (png_voidp)fp; +} +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +/* Convert the supplied time into an RFC 1123 string suitable for use in + * a "Creation Time" or other text-based time string. + */ +png_charp PNGAPI +png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) +{ + static PNG_CONST char short_months[12][4] = + {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + if (png_ptr->time_buffer == NULL) + { + png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* + sizeof(char))); + } + +#if defined(_WIN32_WCE) + { + wchar_t time_buf[29]; + wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); + WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, + NULL, NULL); + } +#else +#ifdef USE_FAR_KEYWORD + { + char near_time_buf[29]; + sprintf(near_time_buf, "%d %s %d %02d:%02d:%02d +0000", + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); + png_memcpy(png_ptr->time_buffer, near_time_buf, + 29*sizeof(char)); + } +#else + sprintf(png_ptr->time_buffer, "%d %s %d %02d:%02d:%02d +0000", + ptime->day % 32, short_months[(ptime->month - 1) % 12], + ptime->year, ptime->hour % 24, ptime->minute % 60, + ptime->second % 61); +#endif +#endif /* _WIN32_WCE */ + return ((png_charp)png_ptr->time_buffer); +} +#endif /* PNG_TIME_RFC1123_SUPPORTED */ + +#if 0 +/* Signature string for a PNG file. */ +png_bytep PNGAPI +png_sig_bytes(void) +{ + return ((png_bytep)"\211\120\116\107\015\012\032\012"); +} +#endif + +png_charp PNGAPI +png_get_copyright(png_structp png_ptr) +{ + if (png_ptr != NULL || png_ptr == NULL) /* silence compiler warning */ + return ((png_charp) "\n libpng version 1.2.5 - October 3, 2002\n\ + Copyright (c) 1998-2002 Glenn Randers-Pehrson\n\ + Copyright (c) 1996-1997 Andreas Dilger\n\ + Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); + return ((png_charp) ""); +} + +/* The following return the library version as a short string in the + * format 1.0.0 through 99.99.99zz. To get the version of *.h files used + * with your application, print out PNG_LIBPNG_VER_STRING, which is defined + * in png.h. + */ + +png_charp PNGAPI +png_get_libpng_ver(png_structp png_ptr) +{ + /* Version of *.c files used when building libpng */ + if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return((png_charp) "1.2.5"); + return((png_charp) "1.2.5"); +} + +png_charp PNGAPI +png_get_header_ver(png_structp png_ptr) +{ + /* Version of *.h files used when building libpng */ + if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return((png_charp) PNG_LIBPNG_VER_STRING); + return((png_charp) PNG_LIBPNG_VER_STRING); +} + +png_charp PNGAPI +png_get_header_version(png_structp png_ptr) +{ + /* Returns longer string containing both version and date */ + if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */ + return((png_charp) PNG_HEADER_VERSION_STRING); + return((png_charp) PNG_HEADER_VERSION_STRING); +} + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +int PNGAPI +png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) +{ + /* check chunk_name and return "keep" value if it's on the list, else 0 */ + int i; + png_bytep p; + if((png_ptr == NULL && chunk_name == NULL) || png_ptr->num_chunk_list<=0) + return 0; + p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; + for (i = png_ptr->num_chunk_list; i; i--, p-=5) + if (!png_memcmp(chunk_name, p, 4)) + return ((int)*(p+4)); + return 0; +} +#endif + +/* This function, added to libpng-1.0.6g, is untested. */ +int PNGAPI +png_reset_zstream(png_structp png_ptr) +{ + return (inflateReset(&png_ptr->zstream)); +} + +/* This function was added to libpng-1.0.7 */ +png_uint_32 PNGAPI +png_access_version_number(void) +{ + /* Version of *.c files used when building libpng */ + return((png_uint_32) 10205L); +} + + +#if !defined(PNG_1_0_X) +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ +/* this INTERNAL function was added to libpng 1.2.0 */ +void /* PRIVATE */ +png_init_mmx_flags (png_structp png_ptr) +{ + png_ptr->mmx_rowbytes_threshold = 0; + png_ptr->mmx_bitdepth_threshold = 0; + +# if (defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD)) + + png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_COMPILED; + + if (png_mmx_support() > 0) { + png_ptr->asm_flags |= PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU +# ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW + | PNG_ASM_FLAG_MMX_READ_COMBINE_ROW +# endif +# ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE + | PNG_ASM_FLAG_MMX_READ_INTERLACE +# endif +# ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW + ; +# else + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB + | PNG_ASM_FLAG_MMX_READ_FILTER_UP + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; + + png_ptr->mmx_rowbytes_threshold = PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT; + png_ptr->mmx_bitdepth_threshold = PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT; +# endif + } else { + png_ptr->asm_flags &= ~( PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU + | PNG_MMX_READ_FLAGS + | PNG_MMX_WRITE_FLAGS ); + } + +# else /* !((PNGVCRD || PNGGCCRD) && PNG_ASSEMBLER_CODE_SUPPORTED)) */ + + /* clear all MMX flags; no support is compiled in */ + png_ptr->asm_flags &= ~( PNG_MMX_FLAGS ); + +# endif /* ?(PNGVCRD || PNGGCCRD) */ +} + +#endif /* !(PNG_ASSEMBLER_CODE_SUPPORTED) */ + +/* this function was added to libpng 1.2.0 */ +#if !defined(PNG_USE_PNGGCCRD) && \ + !(defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD)) +int PNGAPI +png_mmx_support(void) +{ + return -1; +} +#endif +#endif /* PNG_1_0_X */ diff --git a/src/libs/pdflib/libs/png/png.dsp b/src/libs/pdflib/libs/png/png.dsp new file mode 100644 index 0000000000..9d8c910374 --- /dev/null +++ b/src/libs/pdflib/libs/png/png.dsp @@ -0,0 +1,203 @@ +# Microsoft Developer Studio Project File - Name="png" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=png - Win32 Debug DLL +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "png.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "png.mak" CFG="png - Win32 Debug DLL" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "png - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "png - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "png - Win32 Release mtDLL" (based on "Win32 (x86) Static Library") +!MESSAGE "png - Win32 Release DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "png - Win32 Debug DLL" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "png - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../flate" /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"libpng.lib" + +!ELSEIF "$(CFG)" == "png - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../flate" /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"libpng.lib" + +!ELSEIF "$(CFG)" == "png - Win32 Release mtDLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL" +# PROP BASE Intermediate_Dir "Release_mtDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL" +# PROP Intermediate_Dir "Release_mtDLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../flate" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "../flate" /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"libpng.lib" +# ADD LIB32 /nologo /out:"ibpng.lib" + +!ELSEIF "$(CFG)" == "png - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_DLL" +# PROP BASE Intermediate_Dir "Release_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_DLL" +# PROP Intermediate_Dir "Release_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "../flate" /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "../flate" /I "../pdcore" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"libpng.lib" +# ADD LIB32 /nologo /out:"libpng.lib" + +!ELSEIF "$(CFG)" == "png - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_DLL" +# PROP BASE Intermediate_Dir "Debug_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_DLL" +# PROP Intermediate_Dir "Debug_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../flate" /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../flate" /I "../pdcore" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"libpng.lib" +# ADD LIB32 /nologo /out:"libpng.lib" + +!ENDIF + +# Begin Target + +# Name "png - Win32 Release" +# Name "png - Win32 Debug" +# Name "png - Win32 Release mtDLL" +# Name "png - Win32 Release DLL" +# Name "png - Win32 Debug DLL" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\png.c +# End Source File +# Begin Source File + +SOURCE=.\pngerror.c +# End Source File +# Begin Source File + +SOURCE=.\pngget.c +# End Source File +# Begin Source File + +SOURCE=.\pngmem.c +# End Source File +# Begin Source File + +SOURCE=.\pngread.c +# End Source File +# Begin Source File + +SOURCE=.\pngrio.c +# End Source File +# Begin Source File + +SOURCE=.\pngrtran.c +# End Source File +# Begin Source File + +SOURCE=.\pngrutil.c +# End Source File +# Begin Source File + +SOURCE=.\pngset.c +# End Source File +# Begin Source File + +SOURCE=.\pngtrans.c +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/png/png.h b/src/libs/pdflib/libs/png/png.h new file mode 100644 index 0000000000..9ef1631ee0 --- /dev/null +++ b/src/libs/pdflib/libs/png/png.h @@ -0,0 +1,3289 @@ +/* PDFlib GmbH cvsid: $Id: png.h,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* png.h - header file for PNG reference library + * + * libpng version 1.2.5 - October 3, 2002 + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Authors and maintainers: + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.2.5 - October 3, 2002: Glenn + * See also "Contributing Authors", below. + * + * Note about libpng version numbers: + * + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: + * + * source png.h png.h shared-lib + * version string int version + * ------- ------ ----- ---------- + * 0.89c "1.0 beta 3" 0.89 89 1.0.89 + * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] + * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] + * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] + * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] + * 0.97c 0.97 97 2.0.97 + * 0.98 0.98 98 2.0.98 + * 0.99 0.99 98 2.0.99 + * 0.99a-m 0.99 99 2.0.99 + * 1.00 1.00 100 2.1.0 [100 should be 10000] + * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] + * 1.0.1 png.h string is 10001 2.1.0 + * 1.0.1a-e identical to the 10002 from here on, the shared library + * 1.0.2 source version) 10002 is 2.V where V is the source code + * 1.0.2a-b 10003 version, except as noted. + * 1.0.3 10003 + * 1.0.3a-d 10004 + * 1.0.4 10004 + * 1.0.4a-f 10005 + * 1.0.5 (+ 2 patches) 10005 + * 1.0.5a-d 10006 + * 1.0.5e-r 10100 (not source compatible) + * 1.0.5s-v 10006 (not binary compatible) + * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) + * 1.0.6d-f 10007 (still binary incompatible) + * 1.0.6g 10007 + * 1.0.6h 10007 10.6h (testing xy.z so-numbering) + * 1.0.6i 10007 10.6i + * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) + * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) + * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) + * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) + * 1.0.7 1 10007 (still compatible) + * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 + * 1.0.8rc1 1 10008 2.1.0.8rc1 + * 1.0.8 1 10008 2.1.0.8 + * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 + * 1.0.9rc1 1 10009 2.1.0.9rc1 + * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 + * 1.0.9rc2 1 10009 2.1.0.9rc2 + * 1.0.9 1 10009 2.1.0.9 + * 1.0.10beta1 1 10010 2.1.0.10beta1 + * 1.0.10rc1 1 10010 2.1.0.10rc1 + * 1.0.10 1 10010 2.1.0.10 + * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 + * 1.0.11rc1 1 10011 2.1.0.11rc1 + * 1.0.11 1 10011 2.1.0.11 + * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 + * 1.0.12rc1 2 10012 2.1.0.12rc1 + * 1.0.12 2 10012 2.1.0.12 + * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) + * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 + * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 + * 1.2.0rc1 3 10200 3.1.2.0rc1 + * 1.2.0 3 10200 3.1.2.0 + * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 + * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 + * 1.2.1 3 10201 3.1.2.1 + * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 + * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 + * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 + * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 + * 1.0.13 10 10013 10.so.0.1.0.13 + * 1.2.2 12 10202 12.so.0.1.2.2 + * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 + * 1.2.3 12 10203 12.so.0.1.2.3 + * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 + * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 + * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 + * 1.0.14 10 10014 10.so.0.1.0.14 + * 1.2.4 13 10204 12.so.0.1.2.4 + * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 + * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 + * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 + * 1.0.15 10 10015 10.so.0.1.0.15 + * 1.2.5 13 10205 12.so.0.1.2.5 + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng.txt or libpng.3 for more information. The PNG specification + * is available as RFC 2083 + * and as a W3C Recommendation + */ + +/* + * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + * + * If you modify libpng you may insert additional notices immediately following + * this sentence. + * + * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are + * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are + * distributed according to the same disclaimer and license as libpng-1.0.6 + * with the following individuals added to the list of Contributing Authors + * + * Simon-Pierre Cadieux + * Eric S. Raymond + * Gilles Vollant + * + * and with the following additions to the disclaimer: + * + * There is no warranty against interference with your enjoyment of the + * library or against infringement. There is no warranty that our + * efforts or the library will fulfill any of your particular purposes + * or needs. This library is provided with all faults, and the entire + * risk of satisfactory quality, performance, accuracy, and effort is with + * the user. + * + * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are + * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson + * Distributed according to the same disclaimer and license as libpng-0.96, + * with the following individuals added to the list of Contributing Authors: + * + * Tom Lane + * Glenn Randers-Pehrson + * Willem van Schaik + * + * libpng versions 0.89, June 1996, through 0.96, May 1997, are + * Copyright (c) 1996, 1997 Andreas Dilger + * Distributed according to the same disclaimer and license as libpng-0.88, + * with the following individuals added to the list of Contributing Authors: + * + * John Bowler + * Kevin Bracey + * Sam Bushell + * Magnus Holmgren + * Greg Roelofs + * Tom Tanner + * + * libpng versions 0.5, May 1995, through 0.88, January 1996, are + * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. + * + * For the purposes of this copyright and license, "Contributing Authors" + * is defined as the following set of individuals: + * + * Andreas Dilger + * Dave Martindale + * Guy Eric Schalnat + * Paul Schmidt + * Tim Wegner + * + * The PNG Reference Library is supplied "AS IS". The Contributing Authors + * and Group 42, Inc. disclaim all warranties, expressed or implied, + * including, without limitation, the warranties of merchantability and of + * fitness for any purpose. The Contributing Authors and Group 42, Inc. + * assume no liability for direct, indirect, incidental, special, exemplary, + * or consequential damages, which may result from the use of the PNG + * Reference Library, even if advised of the possibility of such damage. + * + * Permission is hereby granted to use, copy, modify, and distribute this + * source code, or portions hereof, for any purpose, without fee, subject + * to the following restrictions: + * + * 1. The origin of this source code must not be misrepresented. + * + * 2. Altered versions must be plainly marked as such and + * must not be misrepresented as being the original source. + * + * 3. This Copyright notice may not be removed or altered from + * any source or altered source distribution. + * + * The Contributing Authors and Group 42, Inc. specifically permit, without + * fee, and encourage the use of this source code as a component to + * supporting the PNG file format in commercial products. If you use this + * source code in a product, acknowledgment is not required but would be + * appreciated. + */ + +/* + * A "png_get_copyright" function is available, for convenient use in "about" + * boxes and the like: + * + * printf("%s",png_get_copyright(NULL)); + * + * Also, the PNG logo (in PNG format, of course) is supplied in the + * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). + */ + +/* + * Libpng is OSI Certified Open Source Software. OSI Certified is a + * certification mark of the Open Source Initiative. + */ + +/* + * The contributing authors would like to thank all those who helped + * with testing, bug fixes, and patience. This wouldn't have been + * possible without all of you. + * + * Thanks to Frank J. T. Wojcik for helping with the documentation. + */ + +/* + * Y2K compliance in libpng: + * ========================= + * + * October 3, 2002 + * + * Since the PNG Development group is an ad-hoc body, we can't make + * an official declaration. + * + * This is your unofficial assurance that libpng from version 0.71 and + * upward through 1.2.5 are Y2K compliant. It is my belief that earlier + * versions were also Y2K compliant. + * + * Libpng only has three year fields. One is a 2-byte unsigned integer + * that will hold years up to 65535. The other two hold the date in text + * format, and will hold years up to 9999. + * + * The integer is + * "png_uint_16 year" in png_time_struct. + * + * The strings are + * "png_charp time_buffer" in png_struct and + * "near_time_buffer", which is a local character string in png.c. + * + * There are seven time-related functions: + * png.c: png_convert_to_rfc_1123() in png.c + * (formerly png_convert_to_rfc_1152() in error) + * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c + * png_convert_from_time_t() in pngwrite.c + * png_get_tIME() in pngget.c + * png_handle_tIME() in pngrutil.c, called in pngread.c + * png_set_tIME() in pngset.c + * png_write_tIME() in pngwutil.c, called in pngwrite.c + * + * All handle dates properly in a Y2K environment. The + * png_convert_from_time_t() function calls gmtime() to convert from system + * clock time, which returns (year - 1900), which we properly convert to + * the full 4-digit year. There is a possibility that applications using + * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() + * function, or that they are incorrectly passing only a 2-digit year + * instead of "year - 1900" into the png_convert_from_struct_tm() function, + * but this is not under our control. The libpng documentation has always + * stated that it works with 4-digit years, and the APIs have been + * documented as such. + * + * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned + * integer to hold the year, and can hold years as large as 65535. + * + * zlib, upon which libpng depends, is also Y2K compliant. It contains + * no date-related code. + * + * Glenn Randers-Pehrson + * libpng maintainer + * PNG Development Group + */ + +#ifndef PNG_H +#define PNG_H + +/* This is not the place to learn how to use libpng. The file libpng.txt + * describes how to use libpng, and the file example.c summarizes it + * with some code on which to build. This file is useful for looking + * at the actual function definitions and structure components. + */ + +/* Version information for png.h - this should match the version in png.c */ +#define PNG_LIBPNG_VER_STRING "1.2.5" + +#define PNG_LIBPNG_VER_SONUM 0 +#define PNG_LIBPNG_VER_DLLNUM %DLLNUM% + +/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ +#define PNG_LIBPNG_VER_MAJOR 1 +#define PNG_LIBPNG_VER_MINOR 2 +#define PNG_LIBPNG_VER_RELEASE 5 +/* This should match the numeric part of the final component of + * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ + +#define PNG_LIBPNG_VER_BUILD 0 + +#define PNG_LIBPNG_BUILD_ALPHA 1 +#define PNG_LIBPNG_BUILD_BETA 2 +#define PNG_LIBPNG_BUILD_RC 3 +#define PNG_LIBPNG_BUILD_STABLE 4 +#define PNG_LIBPNG_BUILD_TYPEMASK 7 +#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with STABLE only */ +#define PNG_LIBPNG_BUILD_TYPE 4 + +/* Careful here. At one time, Guy wanted to use 082, but that would be octal. + * We must not include leading zeros. + * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only + * version 1.0.0 was mis-numbered 100 instead of 10000). From + * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ +#define PNG_LIBPNG_VER 10205 /* 1.2.5 */ + +#ifndef PNG_VERSION_INFO_ONLY + +/* include the compression library's header */ +#include "zlib.h" + +/* include all user configurable info, including optional assembler routines */ +#include "pngconf.h" + +/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* This file is arranged in several sections. The first section contains + * structure and type definitions. The second section contains the external + * library functions, while the third has the internal library functions, + * which applications aren't expected to use directly. + */ + +#ifndef PNG_NO_TYPECAST_NULL +#define int_p_NULL (int *)NULL +#define png_bytep_NULL (png_bytep)NULL +#define png_bytepp_NULL (png_bytepp)NULL +#define png_doublep_NULL (png_doublep)NULL +#define png_error_ptr_NULL (png_error_ptr)NULL +#define png_flush_ptr_NULL (png_flush_ptr)NULL +#define png_free_ptr_NULL (png_free_ptr)NULL +#define png_infopp_NULL (png_infopp)NULL +#define png_malloc_ptr_NULL (png_malloc_ptr)NULL +#define png_read_status_ptr_NULL (png_read_status_ptr)NULL +#define png_rw_ptr_NULL (png_rw_ptr)NULL +#define png_structp_NULL (png_structp)NULL +#define png_uint_16p_NULL (png_uint_16p)NULL +#define png_voidp_NULL (png_voidp)NULL +#define png_write_status_ptr_NULL (png_write_status_ptr)NULL +#else +#define int_p_NULL NULL +#define png_bytep_NULL NULL +#define png_bytepp_NULL NULL +#define png_doublep_NULL NULL +#define png_error_ptr_NULL NULL +#define png_flush_ptr_NULL NULL +#define png_free_ptr_NULL NULL +#define png_infopp_NULL NULL +#define png_malloc_ptr_NULL NULL +#define png_read_status_ptr_NULL NULL +#define png_rw_ptr_NULL NULL +#define png_structp_NULL NULL +#define png_uint_16p_NULL NULL +#define png_voidp_NULL NULL +#define png_write_status_ptr_NULL NULL +#endif + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* Version information for C files, stored in png.c. This had better match + * the version above. + */ +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const char) png_libpng_ver[18]; + /* need room for 99.99.99beta99z */ +#else +#define png_libpng_ver png_get_header_ver(NULL) +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +/* This was removed in version 1.0.5c */ +/* Structures to facilitate easy interlacing. See png.c for more details */ +PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW +PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; +#endif +/* This isn't currently used. If you need it, see png.c for more details. +PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; +*/ +#endif + +#endif /* PNG_NO_EXTERN */ + +/* Three color definitions. The order of the red, green, and blue, (and the + * exact size) is not important, although the size of the fields need to + * be png_byte or png_uint_16 (as defined below). + */ +typedef struct png_color_struct +{ + png_byte red; + png_byte green; + png_byte blue; +} png_color; +typedef png_color FAR * png_colorp; +typedef png_color FAR * FAR * png_colorpp; + +typedef struct png_color_16_struct +{ + png_byte index; /* used for palette files */ + png_uint_16 red; /* for use in red green blue files */ + png_uint_16 green; + png_uint_16 blue; + png_uint_16 gray; /* for use in grayscale files */ +} png_color_16; +typedef png_color_16 FAR * png_color_16p; +typedef png_color_16 FAR * FAR * png_color_16pp; + +typedef struct png_color_8_struct +{ + png_byte red; /* for use in red green blue files */ + png_byte green; + png_byte blue; + png_byte gray; /* for use in grayscale files */ + png_byte alpha; /* for alpha channel files */ +} png_color_8; +typedef png_color_8 FAR * png_color_8p; +typedef png_color_8 FAR * FAR * png_color_8pp; + +/* + * The following two structures are used for the in-core representation + * of sPLT chunks. + */ +typedef struct png_sPLT_entry_struct +{ + png_uint_16 red; + png_uint_16 green; + png_uint_16 blue; + png_uint_16 alpha; + png_uint_16 frequency; +} png_sPLT_entry; +typedef png_sPLT_entry FAR * png_sPLT_entryp; +typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; + +/* When the depth of the sPLT palette is 8 bits, the color and alpha samples + * occupy the LSB of their respective members, and the MSB of each member + * is zero-filled. The frequency member always occupies the full 16 bits. + */ + +typedef struct png_sPLT_struct +{ + png_charp name; /* palette name */ + png_byte depth; /* depth of palette samples */ + png_sPLT_entryp entries; /* palette entries */ + png_int_32 nentries; /* number of palette entries */ +} png_sPLT_t; +typedef png_sPLT_t FAR * png_sPLT_tp; +typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; + +#ifdef PNG_TEXT_SUPPORTED +/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, + * and whether that contents is compressed or not. The "key" field + * points to a regular zero-terminated C string. The "text", "lang", and + * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. + * However, the * structure returned by png_get_text() will always contain + * regular zero-terminated C strings (possibly empty), never NULL pointers, + * so they can be safely used in printf() and other string-handling functions. + */ +typedef struct png_text_struct +{ + int compression; /* compression value: + -1: tEXt, none + 0: zTXt, deflate + 1: iTXt, none + 2: iTXt, deflate */ + png_charp key; /* keyword, 1-79 character description of "text" */ + png_charp text; /* comment, may be an empty string (ie "") + or a NULL pointer */ + png_size_t text_length; /* length of the text string */ +#ifdef PNG_iTXt_SUPPORTED + png_size_t itxt_length; /* length of the itxt string */ + png_charp lang; /* language code, 0-79 characters + or a NULL pointer */ + png_charp lang_key; /* keyword translated UTF-8 string, 0 or more + chars or a NULL pointer */ +#endif +} png_text; +typedef png_text FAR * png_textp; +typedef png_text FAR * FAR * png_textpp; +#endif + +/* Supported compression types for text in PNG files (tEXt, and zTXt). + * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ +#define PNG_TEXT_COMPRESSION_NONE_WR -3 +#define PNG_TEXT_COMPRESSION_zTXt_WR -2 +#define PNG_TEXT_COMPRESSION_NONE -1 +#define PNG_TEXT_COMPRESSION_zTXt 0 +#define PNG_ITXT_COMPRESSION_NONE 1 +#define PNG_ITXT_COMPRESSION_zTXt 2 +#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ + +/* png_time is a way to hold the time in an machine independent way. + * Two conversions are provided, both from time_t and struct tm. There + * is no portable way to convert to either of these structures, as far + * as I know. If you know of a portable way, send it to me. As a side + * note - PNG has always been Year 2000 compliant! + */ +typedef struct png_time_struct +{ + png_uint_16 year; /* full year, as in, 1995 */ + png_byte month; /* month of year, 1 - 12 */ + png_byte day; /* day of month, 1 - 31 */ + png_byte hour; /* hour of day, 0 - 23 */ + png_byte minute; /* minute of hour, 0 - 59 */ + png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ +} png_time; +typedef png_time FAR * png_timep; +typedef png_time FAR * FAR * png_timepp; + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* png_unknown_chunk is a structure to hold queued chunks for which there is + * no specific support. The idea is that we can use this to queue + * up private chunks for output even though the library doesn't actually + * know about their semantics. + */ +typedef struct png_unknown_chunk_t +{ + png_byte name[5]; + png_byte *data; + png_size_t size; + + /* libpng-using applications should NOT directly modify this byte. */ + png_byte location; /* mode of operation at read time */ +} +png_unknown_chunk; +typedef png_unknown_chunk FAR * png_unknown_chunkp; +typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; +#endif + +/* png_info is a structure that holds the information in a PNG file so + * that the application can find out the characteristics of the image. + * If you are reading the file, this structure will tell you what is + * in the PNG file. If you are writing the file, fill in the information + * you want to put into the PNG file, then call png_write_info(). + * The names chosen should be very close to the PNG specification, so + * consult that document for information about the meaning of each field. + * + * With libpng < 0.95, it was only possible to directly set and read the + * the values in the png_info_struct, which meant that the contents and + * order of the values had to remain fixed. With libpng 0.95 and later, + * however, there are now functions that abstract the contents of + * png_info_struct from the application, so this makes it easier to use + * libpng with dynamic libraries, and even makes it possible to use + * libraries that don't have all of the libpng ancillary chunk-handing + * functionality. + * + * In any case, the order of the parameters in png_info_struct should NOT + * be changed for as long as possible to keep compatibility with applications + * that use the old direct-access method with png_info_struct. + * + * The following members may have allocated storage attached that should be + * cleaned up before the structure is discarded: palette, trans, text, + * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, + * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these + * are automatically freed when the info structure is deallocated, if they were + * allocated internally by libpng. This behavior can be changed by means + * of the png_data_freer() function. + * + * More allocation details: all the chunk-reading functions that + * change these members go through the corresponding png_set_* + * functions. A function to clear these members is available: see + * png_free_data(). The png_set_* functions do not depend on being + * able to point info structure members to any of the storage they are + * passed (they make their own copies), EXCEPT that the png_set_text + * functions use the same storage passed to them in the text_ptr or + * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns + * functions do not make their own copies. + */ +typedef struct png_info_struct +{ + /* the following are necessary for every PNG file */ + png_uint_32 width; /* width of image in pixels (from IHDR) */ + png_uint_32 height; /* height of image in pixels (from IHDR) */ + png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ + png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ + png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ + png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ + png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ + png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ + png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ + /* The following three should have been named *_method not *_type */ + png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ + png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ + png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + + /* The following is informational only on read, and not used on writes. */ + png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte spare_byte; /* to align the data, and for future use */ + png_byte signature[8]; /* magic bytes read by libpng from start of file */ + + /* The rest of the data is optional. If you are reading, check the + * valid field to see if the information in these are valid. If you + * are writing, set the valid field to those chunks you want written, + * and initialize the appropriate fields below. + */ + +#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) + /* The gAMA chunk describes the gamma characteristics of the system + * on which the image was created, normally in the range [1.0, 2.5]. + * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. + */ + float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ +#endif + +#if defined(PNG_sRGB_SUPPORTED) + /* GR-P, 0.96a */ + /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ + png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ +#endif + +#if defined(PNG_TEXT_SUPPORTED) + /* The tEXt, and zTXt chunks contain human-readable textual data in + * uncompressed, compressed, and optionally compressed forms, respectively. + * The data in "text" is an array of pointers to uncompressed, + * null-terminated C strings. Each chunk has a keyword that describes the + * textual data contained in that chunk. Keywords are not required to be + * unique, and the text string may be empty. Any number of text chunks may + * be in an image. + */ + int num_text; /* number of comments read/to write */ + int max_text; /* current size of text array */ + png_textp text; /* array of comments read/to write */ +#endif /* PNG_TEXT_SUPPORTED */ + +#if defined(PNG_tIME_SUPPORTED) + /* The tIME chunk holds the last time the displayed image data was + * modified. See the png_time struct for the contents of this struct. + */ + png_time mod_time; +#endif + +#if defined(PNG_sBIT_SUPPORTED) + /* The sBIT chunk specifies the number of significant high-order bits + * in the pixel data. Values are in the range [1, bit_depth], and are + * only specified for the channels in the pixel data. The contents of + * the low-order bits is not specified. Data is valid if + * (valid & PNG_INFO_sBIT) is non-zero. + */ + png_color_8 sig_bit; /* significant bits in color channels */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ +defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The tRNS chunk supplies transparency data for paletted images and + * other image types that don't need a full alpha channel. There are + * "num_trans" transparency values for a paletted image, stored in the + * same order as the palette colors, starting from index 0. Values + * for the data are in the range [0, 255], ranging from fully transparent + * to fully opaque, respectively. For non-paletted images, there is a + * single color specified that should be treated as fully transparent. + * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. + */ + png_bytep trans; /* transparent values for paletted image */ + png_color_16 trans_values; /* transparent color for non-palette image */ +#endif + +#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The bKGD chunk gives the suggested image background color if the + * display program does not have its own background color and the image + * is needs to composited onto a background before display. The colors + * in "background" are normally in the same color space/depth as the + * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. + */ + png_color_16 background; +#endif + +#if defined(PNG_oFFs_SUPPORTED) + /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards + * and downwards from the top-left corner of the display, page, or other + * application-specific co-ordinate space. See the PNG_OFFSET_ defines + * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. + */ + png_int_32 x_offset; /* x offset on page */ + png_int_32 y_offset; /* y offset on page */ + png_byte offset_unit_type; /* offset units type */ +#endif + +#if defined(PNG_pHYs_SUPPORTED) + /* The pHYs chunk gives the physical pixel density of the image for + * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ + * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. + */ + png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ + png_uint_32 y_pixels_per_unit; /* vertical pixel density */ + png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ +#endif + +#if defined(PNG_hIST_SUPPORTED) + /* The hIST chunk contains the relative frequency or importance of the + * various palette entries, so that a viewer can intelligently select a + * reduced-color palette, if required. Data is an array of "num_palette" + * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) + * is non-zero. + */ + png_uint_16p hist; +#endif + +#ifdef PNG_cHRM_SUPPORTED + /* The cHRM chunk describes the CIE color characteristics of the monitor + * on which the PNG was created. This data allows the viewer to do gamut + * mapping of the input image to ensure that the viewer sees the same + * colors in the image as the creator. Values are in the range + * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float x_white; + float y_white; + float x_red; + float y_red; + float x_green; + float y_green; + float x_blue; + float y_blue; +#endif +#endif + +#if defined(PNG_pCAL_SUPPORTED) + /* The pCAL chunk describes a transformation between the stored pixel + * values and original physical data values used to create the image. + * The integer range [0, 2^bit_depth - 1] maps to the floating-point + * range given by [pcal_X0, pcal_X1], and are further transformed by a + * (possibly non-linear) transformation function given by "pcal_type" + * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ + * defines below, and the PNG-Group's PNG extensions document for a + * complete description of the transformations and how they should be + * implemented, and for a description of the ASCII parameter strings. + * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. + */ + png_charp pcal_purpose; /* pCAL chunk description string */ + png_int_32 pcal_X0; /* minimum value */ + png_int_32 pcal_X1; /* maximum value */ + png_charp pcal_units; /* Latin-1 string giving physical units */ + png_charpp pcal_params; /* ASCII strings containing parameter values */ + png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ + png_byte pcal_nparams; /* number of parameters given in pcal_params */ +#endif + +/* New members added in libpng-1.0.6 */ +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + /* storage for unknown chunks that the library doesn't recognize. */ + png_unknown_chunkp unknown_chunks; + png_size_t unknown_chunks_num; +#endif + +#if defined(PNG_iCCP_SUPPORTED) + /* iCCP chunk data. */ + png_charp iccp_name; /* profile name */ + png_charp iccp_profile; /* International Color Consortium profile data */ + /* Note to maintainer: should be png_bytep */ + png_uint_32 iccp_proflen; /* ICC profile data length */ + png_byte iccp_compression; /* Always zero */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) + /* data on sPLT chunks (there may be more than one). */ + png_sPLT_tp splt_palettes; + png_uint_32 splt_palettes_num; +#endif + +#if defined(PNG_sCAL_SUPPORTED) + /* The sCAL chunk describes the actual physical dimensions of the + * subject matter of the graphic. The chunk contains a unit specification + * a byte value, and two ASCII strings representing floating-point + * values. The values are width and height corresponsing to one pixel + * in the image. This external representation is converted to double + * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. + */ + png_byte scal_unit; /* unit of physical scale */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + double scal_pixel_width; /* width of one pixel */ + double scal_pixel_height; /* height of one pixel */ +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_charp scal_s_width; /* string containing height */ + png_charp scal_s_height; /* string containing width */ +#endif +#endif + +#if defined(PNG_INFO_IMAGE_SUPPORTED) + /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ + /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ + png_bytepp row_pointers; /* the image bits */ +#endif + +#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) + png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ +#endif + +#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) + png_fixed_point int_x_white; + png_fixed_point int_y_white; + png_fixed_point int_x_red; + png_fixed_point int_y_red; + png_fixed_point int_x_green; + png_fixed_point int_y_green; + png_fixed_point int_x_blue; + png_fixed_point int_y_blue; +#endif + +} png_info; + +typedef png_info FAR * png_infop; +typedef png_info FAR * FAR * png_infopp; + +/* Maximum positive integer used in PNG is (2^31)-1 */ +#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL) + +/* These describe the color_type field in png_info. */ +/* color type masks */ +#define PNG_COLOR_MASK_PALETTE 1 +#define PNG_COLOR_MASK_COLOR 2 +#define PNG_COLOR_MASK_ALPHA 4 + +/* color types. Note that not all combinations are legal */ +#define PNG_COLOR_TYPE_GRAY 0 +#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) +#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) +#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) +#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) +/* aliases */ +#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA +#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA + +/* This is for compression type. PNG 1.0-1.2 only define the single type. */ +#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ +#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE + +/* This is for filter type. PNG 1.0-1.2 only define the single type. */ +#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ +#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ +#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE + +/* These are for the interlacing type. These values should NOT be changed. */ +#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ +#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ +#define PNG_INTERLACE_LAST 2 /* Not a valid value */ + +/* These are for the oFFs chunk. These values should NOT be changed. */ +#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ +#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ +#define PNG_OFFSET_LAST 2 /* Not a valid value */ + +/* These are for the pCAL chunk. These values should NOT be changed. */ +#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ +#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ +#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ +#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ +#define PNG_EQUATION_LAST 4 /* Not a valid value */ + +/* These are for the sCAL chunk. These values should NOT be changed. */ +#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ +#define PNG_SCALE_METER 1 /* meters per pixel */ +#define PNG_SCALE_RADIAN 2 /* radians per pixel */ +#define PNG_SCALE_LAST 3 /* Not a valid value */ + +/* These are for the pHYs chunk. These values should NOT be changed. */ +#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ +#define PNG_RESOLUTION_METER 1 /* pixels/meter */ +#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ + +/* These are for the sRGB chunk. These values should NOT be changed. */ +#define PNG_sRGB_INTENT_PERCEPTUAL 0 +#define PNG_sRGB_INTENT_RELATIVE 1 +#define PNG_sRGB_INTENT_SATURATION 2 +#define PNG_sRGB_INTENT_ABSOLUTE 3 +#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ + +/* This is for text chunks */ +#define PNG_KEYWORD_MAX_LENGTH 79 + +/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ +#define PNG_MAX_PALETTE_LENGTH 256 + +/* These determine if an ancillary chunk's data has been successfully read + * from the PNG header, or if the application has filled in the corresponding + * data in the info_struct to be written into the output file. The values + * of the PNG_INFO_ defines should NOT be changed. + */ +#define PNG_INFO_gAMA 0x0001 +#define PNG_INFO_sBIT 0x0002 +#define PNG_INFO_cHRM 0x0004 +#define PNG_INFO_PLTE 0x0008 +#define PNG_INFO_tRNS 0x0010 +#define PNG_INFO_bKGD 0x0020 +#define PNG_INFO_hIST 0x0040 +#define PNG_INFO_pHYs 0x0080 +#define PNG_INFO_oFFs 0x0100 +#define PNG_INFO_tIME 0x0200 +#define PNG_INFO_pCAL 0x0400 +#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ + +/* This is used for the transformation routines, as some of them + * change these values for the row. It also should enable using + * the routines for other purposes. + */ +typedef struct png_row_info_struct +{ + png_uint_32 width; /* width of row */ + png_uint_32 rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_byte pixel_depth; /* bits per pixel (depth * channels) */ +} png_row_info; + +typedef png_row_info FAR * png_row_infop; +typedef png_row_info FAR * FAR * png_row_infopp; + +/* These are the function types for the I/O functions and for the functions + * that allow the user to override the default I/O functions with his or her + * own. The png_error_ptr type should match that of user-supplied warning + * and error functions, while the png_rw_ptr type should match that of the + * user read/write data functions. + */ +typedef struct png_struct_def png_struct; +typedef png_struct FAR * png_structp; + +typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); +typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); +typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); +typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, + int)); +typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, + int)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp,png_infop)); +typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, + png_uint_32, int)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, + png_row_infop, png_bytep)); +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) +typedef int (PNGAPI *png_user_chunk_ptr) + PNGARG((png_structp, png_unknown_chunkp)); +#endif +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); +#endif + +/* Transform masks for the high-level interface */ +#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ +#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ +#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ +#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ +#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ +#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ +#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ +#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ +#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ +#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ +#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ +#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ + +/* Flags for MNG supported features */ +#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 +#define PNG_FLAG_MNG_FILTER_64 0x04 +#define PNG_ALL_MNG_FEATURES 0x05 + +typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); +typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); + +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application, except to store + * the jmp_buf. + */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmpbuf; /* used in png_error */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ + png_error_ptr warning_fn; /* function for printing warnings */ + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + z_stream zstream; /* pointer to decompression structure (below) */ + png_bytep zbuf; /* buffer for zlib */ + png_size_t zbuf_size; /* size of zbuf */ + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_uint_32 rowbytes; /* size of row in bytes */ + png_uint_32 irowbytes; /* size of current interlaced row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row */ + png_bytep row_buf; /* buffer to save current (unfiltered) row */ + png_bytep sub_row; /* buffer to save "sub" row when filtering */ + png_bytep up_row; /* buffer to save "up" row when filtering */ + png_bytep avg_row; /* buffer to save "avg" row when filtering */ + png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ + png_row_info row_info; /* used for transformation routines */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + png_uint_16 num_trans; /* number of transparency values */ + png_byte chunk_name[5]; /* null-terminated name of current chunk */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ + png_byte usr_channels; /* channels at start of write */ + png_byte sig_bytes; /* magic bytes read/written from start of file */ + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +#ifdef PNG_LEGACY_SUPPORTED + png_byte filler; /* filler byte for pixel expansion */ +#else + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif +#endif + +#if defined(PNG_bKGD_SUPPORTED) + png_byte background_gamma_type; +# ifdef PNG_FLOATING_POINT_SUPPORTED + float background_gamma; +# endif + png_color_16 background; /* background color in screen gamma space */ +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_color_16 background_1; /* background normalized to gamma 1.0 */ +#endif +#endif /* PNG_bKGD_SUPPORTED */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_flush_ptr output_flush_fn;/* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float gamma; /* file gamma value */ + float screen_gamma; /* screen gamma value (display_exponent) */ +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans; /* transparency values for paletted files */ + png_color_16 trans_values; /* transparency values for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after each prog. row is decoded*/ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +# if defined(PNG_TEXT_SUPPORTED) + png_size_t current_text_size; /* current size of text input data */ + png_size_t current_text_left; /* how much text left to read in input */ + png_charp current_text; /* current text chunk buffer */ + png_charp current_text_ptr; /* current location in current_text */ +# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* for the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + png_bytep palette_lookup; /* lookup table for dithering */ + png_bytep dither_index; /* index translation for palette files */ +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) + png_uint_16p hist; /* histogram */ +#endif + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_charp time_buffer; /* String to hold RFC 1123 time text */ +#endif + +/* New members added in libpng-1.0.6 */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing*/ +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) + png_voidp user_chunk_ptr; + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + int num_chunk_list; + png_bytep chunk_list; +#endif + +/* New members added in libpng-1.0.3 */ +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_byte rgb_to_gray_status; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ + defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* changed from png_byte to png_uint_32 at version 1.2.0 */ +#ifdef PNG_1_0_X + png_byte mng_features_permitted; +#else + png_uint_32 mng_features_permitted; +#endif /* PNG_1_0_X */ +#endif + +/* New member added in libpng-1.0.7 */ +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_fixed_point int_gamma; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_byte filter_type; +#endif + +#if defined(PNG_1_0_X) || (defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)) +/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ + png_uint_32 row_buf_size; +#endif + +/* New members added in libpng-1.2.0 */ +#if !defined(PNG_1_0_X) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) + png_byte mmx_bitdepth_threshold; + png_uint_32 mmx_rowbytes_threshold; + png_uint_32 asm_flags; +#endif + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions*/ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +/* New member added in libpng-1.0.13 and 1.2.0 */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* The following three members were added at version 1.0.14 and 1.2.4 */ + png_bytep dither_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is */ + /* in the palette */ + png_bytep palette_to_index; /* which original index points to this */ + /* palette color */ +#endif + +}; + + +/* This prevents a compiler error in png.c if png.c and png.h are both at + version 1.2.5 + */ +typedef png_structp version_1_2_5; + +typedef png_struct FAR * FAR * png_structpp; + +/* Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng.txt for the + * full explanation, see example.c for the summary. This just provides + * a simple one line description of the use of each function. + */ + +/* Returns the version number of the library */ +extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); + +/* Tell lib we have already handled the first magic bytes. + * Handling more than 8 bytes from the beginning of the file is an error. + */ +extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, + int num_bytes)); + +/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a + * PNG file. Returns zero if the supplied bytes match the 8-byte PNG + * signature, and non-zero otherwise. Having num_to_check == 0 or + * start > 7 will always fail (ie return non-zero). + */ +extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, + png_size_t num_to_check)); + +/* Simple signature checking function. This is the same as calling + * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). + */ +extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); + +/* Allocate and initialize png_ptr struct for reading, and any other memory. */ +extern PNG_EXPORT(png_structp,png_create_read_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +/* Allocate and initialize png_ptr struct for writing, and any other memory */ +extern PNG_EXPORT(png_structp,png_create_write_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) + PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_compression_buffer_size) + PNGARG((png_structp png_ptr, png_uint_32 size)); + +/* Reset the compression stream */ +extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); + +/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_structp,png_create_read_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +extern PNG_EXPORT(png_structp,png_create_write_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +#endif + +/* Write a PNG chunk - size, type, (optional) data, CRC. */ +extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_bytep data, png_size_t length)); + +/* Write the start of a PNG chunk - length and chunk name. */ +extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_uint_32 length)); + +/* Write the data of a PNG chunk started with png_write_chunk_start(). */ +extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ +extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); + +/* Allocate and initialize the info structure */ +extern PNG_EXPORT(png_infop,png_create_info_struct) + PNGARG((png_structp png_ptr)); + +/* Initialize the info structure (old interface - DEPRECATED) */ +extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); +/* PDFlb GmbH +#undef png_info_init +#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info)); +*/ +extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, + png_size_t png_info_struct_size)); + +/* Writes all the PNG information before the image. */ +extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read the information before the actual image data. */ +extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) + PNGARG((png_structp png_ptr, png_timep ptime)); +#endif + +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ +#if defined(PNG_WRITE_tIME_SUPPORTED) +/* convert from a struct tm to png_time */ +extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, + struct tm FAR * ttime)); + +/* convert from time_t to png_time. Uses gmtime() */ +extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, + time_t ttime)); +#endif /* PNG_WRITE_tIME_SUPPORTED */ +#endif /* _WIN32_WCE */ + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ +extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Use blue, green, red order for pixels. */ +extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* Expand the grayscale to 24-bit RGB if necessary. */ +extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* Reduce RGB to grayscale. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, + int error_action, double red, double green )); +#endif +extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green )); +extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp + png_ptr)); +#endif + +extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, + png_colorp palette)); + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte to 24-bit RGB images. */ +extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +/* The values of the PNG_FILLER_ defines should NOT be changed */ +#define PNG_FILLER_BEFORE 0 +#define PNG_FILLER_AFTER 1 +#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swap bytes in 16-bit depth files. */ +extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ +extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) ||defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Swap packing order of pixels in bytes. */ +extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Converts files to legal bit depths. */ +extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, + png_color_8p true_bits)); +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Have the code handle the interlacing. Returns the number of passes. */ +extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +/* Invert monochrome files */ +extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Handle alpha and tRNS by replacing with a background color. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)); +#endif +#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +#define PNG_BACKGROUND_GAMMA_SCREEN 1 +#define PNG_BACKGROUND_GAMMA_FILE 2 +#define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip the second byte of information from a 16-bit depth file. */ +extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +/*Turn on dithering, and reduce the palette to the number of colors available.*/ +extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_uint_16p histogram, int full_dither)); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Handle gamma correction. Screen_gamma=(display_exponent) */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, + double screen_gamma, double default_file_gamma)); +#endif +#endif + +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ +/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ +extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, + int empty_plte_permitted)); +#endif + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +/* Set how many lines between output flushes - 0 for no flushing */ +extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); +/* Flush the current PNG output buffer */ +extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); +#endif + +/* optional update palette with requested transformations */ +extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); + +/* optional call to update the users info structure */ +extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read one or more rows of image data. */ +extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); + +/* read a row of data. */ +extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, + png_bytep row, + png_bytep display_row)); + +/* read the whole image into memory at once. */ +extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* write a row of image data */ +extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, + png_bytep row)); + +/* write a few rows of image data */ +extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_uint_32 num_rows)); + +/* write the image data */ +extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* writes the end of the PNG file. */ +extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read the end of the PNG file. */ +extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* free any memory associated with the png_info_struct */ +extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, + png_infopp info_ptr_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp + png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); + +/* free all memory used by the read (old method - NOT DLL EXPORTED) */ +extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, + png_infop end_info_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_write_struct) + PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); + +/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ +extern void png_write_destroy PNGARG((png_structp png_ptr)); + +/* set the libpng method of handling chunk CRC errors */ +extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, + int crit_action, int ancil_action)); + +/* Values for png_set_crc_action() to say how to handle CRC errors in + * ancillary and critical chunks, and whether to use the data contained + * therein. Note that it is impossible to "discard" data in a critical + * chunk. For versions prior to 0.90, the action was always error/quit, + * whereas in version 0.90 and later, the action for CRC errors in ancillary + * chunks is warn/discard. These values should NOT be changed. + * + * value action:critical action:ancillary + */ +#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ +#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ +#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ +#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ +#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ +#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ + +/* These functions give the user control over the scan-line filtering in + * libpng and the compression methods used by zlib. These functions are + * mainly useful for testing, as the defaults should work with most users. + * Those users who are tight on memory or want faster performance at the + * expense of compression can modify them. See the compression library + * header file (zlib.h) for an explination of the compression functions. + */ + +/* set the filtering method(s) used by libpng. Currently, the only valid + * value for "method" is 0. + */ +extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, + int filters)); + +/* Flags for png_set_filter() to say which filters to use. The flags + * are chosen so that they don't conflict with real filter types + * below, in case they are supplied instead of the #defined constants. + * These values should NOT be changed. + */ +#define PNG_NO_FILTERS 0x00 +#define PNG_FILTER_NONE 0x08 +#define PNG_FILTER_SUB 0x10 +#define PNG_FILTER_UP 0x20 +#define PNG_FILTER_AVG 0x40 +#define PNG_FILTER_PAETH 0x80 +#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ + PNG_FILTER_AVG | PNG_FILTER_PAETH) + +/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. + * These defines should NOT be changed. + */ +#define PNG_FILTER_VALUE_NONE 0 +#define PNG_FILTER_VALUE_SUB 1 +#define PNG_FILTER_VALUE_UP 2 +#define PNG_FILTER_VALUE_AVG 3 +#define PNG_FILTER_VALUE_PAETH 4 +#define PNG_FILTER_VALUE_LAST 5 + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ +/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ + * defines, either the default (minimum-sum-of-absolute-differences), or + * the experimental method (weighted-minimum-sum-of-absolute-differences). + * + * Weights are factors >= 1.0, indicating how important it is to keep the + * filter type consistent between rows. Larger numbers mean the current + * filter is that many times as likely to be the same as the "num_weights" + * previous filters. This is cumulative for each previous row with a weight. + * There needs to be "num_weights" values in "filter_weights", or it can be + * NULL if the weights aren't being specified. Weights have no influence on + * the selection of the first row filter. Well chosen weights can (in theory) + * improve the compression for a given image. + * + * Costs are factors >= 1.0 indicating the relative decoding costs of a + * filter type. Higher costs indicate more decoding expense, and are + * therefore less likely to be selected over a filter with lower computational + * costs. There needs to be a value in "filter_costs" for each valid filter + * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't + * setting the costs. Costs try to improve the speed of decompression without + * unduly increasing the compressed image size. + * + * A negative weight or cost indicates the default value is to be used, and + * values in the range [0.0, 1.0) indicate the value is to remain unchanged. + * The default values for both weights and costs are currently 1.0, but may + * change if good general weighting/cost heuristics can be found. If both + * the weights and costs are set to 1.0, this degenerates the WEIGHTED method + * to the UNWEIGHTED method, but with added encoding time/computation. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, + int heuristic_method, int num_weights, png_doublep filter_weights, + png_doublep filter_costs)); +#endif +#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ + +/* Heuristic used for row filter selection. These defines should NOT be + * changed. + */ +#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ +#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ +#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ +#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ + +/* Set the library compression level. Currently, valid values range from + * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 + * (0 - no compression, 9 - "maximal" compression). Note that tests have + * shown that zlib compression levels 3-6 usually perform as well as level 9 + * for PNG images, and do considerably fewer caclulations. In the future, + * these values may not correspond directly to the zlib compression levels. + */ +extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, + int level)); + +extern PNG_EXPORT(void,png_set_compression_mem_level) + PNGARG((png_structp png_ptr, int mem_level)); + +extern PNG_EXPORT(void,png_set_compression_strategy) + PNGARG((png_structp png_ptr, int strategy)); + +extern PNG_EXPORT(void,png_set_compression_window_bits) + PNGARG((png_structp png_ptr, int window_bits)); + +extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, + int method)); + +/* These next functions are called for input/output, memory, and error + * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, + * and call standard C I/O routines such as fread(), fwrite(), and + * fprintf(). These functions can be made to use other I/O routines + * at run time for those applications that need to handle I/O in a + * different manner by calling png_set_???_fn(). See libpng.txt for + * more information. + */ + +#if !defined(PNG_NO_STDIO) +/* Initialize the input/output for the PNG file to the default functions. */ +extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr,png_FILE_p fp)); +#endif + +/* Replace the (error and abort), and warning functions with user + * supplied functions. If no messages are to be printed you must still + * write and use replacement functions. The replacement error_fn should + * still do a longjmp to the last setjmp location if you are using this + * method of error handling. If error_fn or warning_fn is NULL, the + * default function will be used. + */ + +extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); + +/* Return the user pointer associated with the error functions */ +extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); + +/* Replace the default data output functions with a user supplied one(s). + * If buffered output is not used, then output_flush_fn can be set to NULL. + * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time + * output_flush_fn will be ignored (and thus can be NULL). + */ +extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); + +/* Replace the default data input function with a user supplied one. */ +extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr read_data_fn)); + +/* Return the user pointer associated with the I/O functions */ +extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, + png_read_status_ptr read_row_fn)); + +extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_USER_MEM_SUPPORTED +/* Replace the default memory allocation functions with user supplied one(s). */ +extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +/* Return the user pointer associated with the memory functions */ +extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr read_user_transform_fn)); +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr write_user_transform_fn)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp + png_ptr, png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); +/* Return the user pointer associated with the user transform functions */ +extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp + png_ptr)); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +/* Sets the function callbacks for the push reader, and a pointer to a + * user-defined structure available to the callback functions. + */ +extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, + png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn)); + +/* returns the user pointer associated with the push read functions */ +extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) + PNGARG((png_structp png_ptr)); + +/* function to be called when data becomes available */ +extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); + +/* function that combines rows. Not very much different than the + * png_combine_row() call. Is this even used????? + */ +extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, + png_bytep old_row, png_bytep new_row)); +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, + png_uint_32 size)); + +#if defined(PNG_1_0_X) +# define png_malloc_warn png_malloc +#else +/* Added at libpng version 1.2.4 */ +extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, + png_uint_32 size)); +#endif + +/* frees a pointer allocated by png_malloc() */ +extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); + +#if defined(PNG_1_0_X) +/* Function to allocate memory for zlib. */ +extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, + uInt size)); + +/* Function to free memory for zlib */ +extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); +#endif + +/* Free data that was allocated internally */ +extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 free_me, int num)); +#ifdef PNG_FREE_ME_SUPPORTED +/* Reassign responsibility for freeing existing data, whether allocated + * by libpng or by the application */ +extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, + png_infop info_ptr, int freer, png_uint_32 mask)); +#endif +/* assignments for png_data_freer */ +#define PNG_DESTROY_WILL_FREE_DATA 1 +#define PNG_SET_WILL_FREE_DATA 1 +#define PNG_USER_WILL_FREE_DATA 2 +/* Flags for png_ptr->free_me and info_ptr->free_me */ +#define PNG_FREE_HIST 0x0008 +#define PNG_FREE_ICCP 0x0010 +#define PNG_FREE_SPLT 0x0020 +#define PNG_FREE_ROWS 0x0040 +#define PNG_FREE_PCAL 0x0080 +#define PNG_FREE_SCAL 0x0100 +#define PNG_FREE_UNKN 0x0200 +#define PNG_FREE_LIST 0x0400 +#define PNG_FREE_PLTE 0x1000 +#define PNG_FREE_TRNS 0x2000 +#define PNG_FREE_TEXT 0x4000 +#define PNG_FREE_ALL 0x7fff +#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ + +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, + png_uint_32 size)); +extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, + png_voidp ptr)); +#endif + +extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, + png_voidp s1, png_voidp s2, png_uint_32 size)); + +extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, + png_voidp s1, int value, png_uint_32 size)); + +#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ +extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, + int check)); +#endif /* USE_FAR_KEYWORD */ + +/* Fatal error in PNG image of libpng - can't continue */ +extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); + +/* The same, but the chunk name is prepended to the error string. */ +extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, + png_const_charp error_message)); + +/* Non-fatal error in libpng. Can continue, but may have a problem. */ +extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +/* Non-fatal error in libpng, chunk name is prepended to message. */ +extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +/* The png_set_ functions are for storing values in the png_info_struct. + * Similarly, the png_get_ calls are used to read values from the + * png_info_struct, either storing the parameters in the passed variables, or + * setting pointers into the png_info_struct where the data is stored. The + * png_get_ functions return a non-zero value if the data was available + * in info_ptr, or return zero and do not change any of the parameters if the + * data was not available. + * + * These functions should be used instead of directly accessing png_info + * to avoid problems with future changes in the size and internal layout of + * png_info_struct. + */ +/* Returns "flag" if chunk data is valid in info_ptr. */ +extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 flag)); + +/* Returns number of bytes needed to hold a transformed row. */ +extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* Returns row_pointers, which is an array of pointers to scanlines that was +returned from png_read_png(). */ +extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, +png_infop info_ptr)); +/* Set row_pointers, which is an array of pointers to scanlines for use +by png_write_png(). */ +extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers)); +#endif + +/* Returns number of color channels in image. */ +extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Returns image width in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image height in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image bit_depth. */ +extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image color_type. */ +extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image filter_type. */ +extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image interlace_type. */ +extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image compression_type. */ +extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image resolution in pixels per meter, from pHYs chunk data. */ +extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns pixel aspect ratio, computed from pHYs chunk data. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +#endif + +/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ +extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +/* Returns pointer to signature string read from PNG header */ +extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p *background)); +#endif + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p background)); +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point + *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point + *int_blue_x, png_fixed_point *int_blue_y)); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double white_x, double white_y, double red_x, + double red_y, double green_x, double green_y, double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *file_gamma)); +#endif +extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_file_gamma)); +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double file_gamma)); +#endif +extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p *hist)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p hist)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); + +extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, + int *unit_type)); +#endif + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, + int *type, int *nparams, png_charp *units, png_charpp *params)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_charp units, png_charpp params)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp *palette, int *num_palette)); + +extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp palette, int num_palette)); + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p *sig_bit)); +#endif + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p sig_bit)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *intent)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen)); + /* Note to maintainer: profile should be png_bytepp */ +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tpp entries)); +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) +/* png_get_text also returns the number of text chunks in *num_text */ +extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp *text_ptr, int *num_text)); +#endif + +/* + * Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + +#if defined(PNG_TEXT_SUPPORTED) +extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep *mod_time)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep mod_time)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep *trans, int *num_trans, + png_color_16p *trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep trans, int num_trans, + png_color_16p trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +#endif + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, double *width, double *height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED */ + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, double width, double height)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); +#endif +#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* provide a list of chunks and how they are to be handled, if the built-in + handling or default unknown chunk handling is not desired. Any chunks not + listed will be handled in the default manner. The IHDR and IEND chunks + must not be listed. + keep = 0: follow default behavour + = 1: do not keep + = 2: keep only if safe-to-copy + = 3: keep even if unsafe-to-copy +*/ +extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp + png_ptr, int keep, png_bytep chunk_list, int num_chunks)); +extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); +extern PNG_EXPORT(void, png_set_unknown_chunk_location) + PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); +extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp + png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); +#endif +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep + chunk_name)); +#endif + +/* Png_free_data() will turn off the "valid" flag for anything it frees. + If you need to turn it off for a chunk that your application has freed, + you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ +extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, + png_infop info_ptr, int mask)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* The "params" pointer is currently not used and is for future expansion. */ +extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +#endif + +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + */ +#ifdef PNG_DEBUG +#if (PNG_DEBUG > 0) +#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +#include +#if (PNG_DEBUG > 1) +#define png_debug(l,m) _RPT0(_CRT_WARN,m) +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) +#endif +#else /* PNG_DEBUG_FILE || !_MSC_VER */ +#ifndef PNG_DEBUG_FILE +#define PNG_DEBUG_FILE stderr +#endif /* PNG_DEBUG_FILE */ +#if (PNG_DEBUG > 1) +#define png_debug(l,m) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ +} +#define png_debug1(l,m,p1) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ +} +#define png_debug2(l,m,p1,p2) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ +} +#endif /* (PNG_DEBUG > 1) */ +#endif /* _MSC_VER */ +#endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +#define png_debug(l, m) +#endif +#ifndef png_debug1 +#define png_debug1(l, m, p1) +#endif +#ifndef png_debug2 +#define png_debug2(l, m, p1, p2) +#endif + +extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); + +extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_version) + PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); + +#ifdef PNG_MNG_FEATURES_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp + png_ptr, png_uint_32 mng_features_permitted)); +#endif + +/* Added to version 1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ +#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 +#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 +#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 +#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 +#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 +#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 +#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ + +#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ + | PNG_ASM_FLAG_MMX_READ_INTERLACE \ + | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ + | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ + | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ + | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) +#define PNG_MMX_WRITE_FLAGS ( 0 ) + +#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ + | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ + | PNG_MMX_READ_FLAGS \ + | PNG_MMX_WRITE_FLAGS ) + +#define PNG_SELECT_READ 1 +#define PNG_SELECT_WRITE 2 + + +#if !defined(PNG_1_0_X) +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) + PNGARG((int flag_select, int *compilerID)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) + PNGARG((int flag_select)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_asm_flags) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) + PNGARG((png_structp png_ptr)); + +/* pngget.c */ +extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) + PNGARG((png_structp png_ptr)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_asm_flags) + PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); + +/* pngset.c */ +extern PNG_EXPORT(void,png_set_mmx_thresholds) + PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold)); + +#endif /* PNG_1_0_X */ +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + +#if !defined(PNG_1_0_X) +/* png.c, pnggccrd.c, or pngvcrd.c */ +extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); + +/* Strip the prepended error numbers ("#nnn ") from error and warning + * messages before passing them to the error or warning handler. */ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp + png_ptr, png_uint_32 strip_mode)); +#endif +#endif /* PNG_1_0_X */ + +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs*/ + +#define PNG_HEADER_VERSION_STRING \ + " libpng version 1.2.5 - October 3, 2002 (header)\n" + +#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +/* With these routines we avoid an integer divide, which will be slower on + * most machines. However, it does take more operations than the corresponding + * divide method, so it may be slower on a few RISC systems. There are two + * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. + * + * Note that the rounding factors are NOT supposed to be the same! 128 and + * 32768 are correct for the NODIV code; 127 and 32767 are correct for the + * standard method. + * + * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] + */ + + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 - \ + (png_uint_16)(alpha)) + (png_uint_16)128); \ + (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } + +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(png_uint_32)(65535L - \ + (png_uint_32)(alpha)) + (png_uint_32)32768L); \ + (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } + +#else /* standard method using integer division */ + +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + (png_uint_16)127) / 255) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ + (png_uint_32)32767) / (png_uint_32)65535L) + +#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ + +/* These next functions are used internally in the code. They generally + * shouldn't be used unless you are writing code to add or replace some + * functionality in libpng. More information about most functions can + * be found in the files where the functions are located. + */ + +#if defined(PNG_INTERNAL) + +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. + */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_HAVE_IDAT 0x04 +#define PNG_AFTER_IDAT 0x08 +#define PNG_HAVE_IEND 0x10 +#define PNG_HAVE_gAMA 0x20 +#define PNG_HAVE_cHRM 0x40 +#define PNG_HAVE_sRGB 0x80 +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 + +/* flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_DITHER 0x0040 +#define PNG_BACKGROUND 0x0080 +#define PNG_BACKGROUND_EXPAND 0x0100 + /* 0x0200 unused */ +#define PNG_16_TO_8 0x0400 +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000L +#define PNG_PACKSWAP 0x10000L +#define PNG_SWAP_ALPHA 0x20000L +#define PNG_STRIP_ALPHA 0x40000L +#define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L +#define PNG_RGB_TO_GRAY_ERR 0x200000L +#define PNG_RGB_TO_GRAY_WARN 0x400000L +#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ + +/* flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_SHIFT 8 +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_SHIFT 3 +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 +#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 +#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 +#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 +#define PNG_FLAG_ZLIB_FINISHED 0x0020 +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_FREE_PLTE 0x1000 +#define PNG_FLAG_FREE_TRNS 0x2000 +#define PNG_FLAG_FREE_HIST 0x4000 +#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L +#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L +#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L + +/* For use in png_set_keep_unknown, png_handle_as_unknown */ +#define HANDLE_CHUNK_AS_DEFAULT 0 +#define HANDLE_CHUNK_NEVER 1 +#define HANDLE_CHUNK_IF_SAFE 2 +#define HANDLE_CHUNK_ALWAYS 3 + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* save typing and make code easier to understand */ +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* place to hold the signature string for a PNG file. */ +#ifdef PNG_USE_GLOBAL_ARRAYS + PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; +#else +#define png_sig png_sig_bytes(NULL) +#endif +#endif /* PNG_NO_EXTERN */ + +/* Constant strings for known chunk types. If you need to add a chunk, + * define the name here, and add an invocation of the macro in png.c and + * wherever it's needed. + */ +#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} +#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} +#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} +#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} +#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} +#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} +#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} +#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} +#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} +#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} +#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} +#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} +#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} +#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} +#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} +#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} +#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} +#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} +#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} +#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} + +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; +#endif /* PNG_USE_GLOBAL_ARRAYS */ + + +/* Inline macros to do direct reads of bytes from the input buffer. These + * require that you are using an architecture that uses PNG byte ordering + * (MSB first) and supports unaligned data storage. I think that PowerPC + * in big-endian mode and 680x0 are the only ones that will support this. + * The x86 line of processors definitely do not. The png_get_int_32() + * routine also assumes we are using two's complement format for negative + * values, which is almost certainly true. + */ +#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) +# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) +# define png_get_int_32(buf) ( *((png_int_32p) (buf))) +# endif +# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) +# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) +#else +# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) +PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf)); +# endif +PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf)); +PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf)); +#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ + +/* Initialize png_ptr struct for reading, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_read_struct instead). + */ +extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); +#undef png_read_init +#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, sizeof(png_struct)); +extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Initialize png_ptr struct for writing, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_write_struct instead). + */ +extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); +#undef png_write_init +#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, sizeof(png_struct)); +extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Allocate memory for an internal libpng struct */ +PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); + +/* Free memory from internal libpng struct */ +PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); + +PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr + malloc_fn, png_voidp mem_ptr)); +PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, + png_free_ptr free_fn, png_voidp mem_ptr)); + +/* Free any memory that info_ptr points to and reset struct. */ +PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#ifndef PNG_1_0_X +/* Function to allocate memory for zlib. */ +PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); + +/* Function to free memory for zlib */ +PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); + +/* Next four functions are used internally as callbacks. PNGAPI is required + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ + +PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif + +PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +#if !defined(PNG_NO_STDIO) +PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); +#endif +#endif +#else /* PNG_1_0_X */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +#endif +#endif /* PNG_1_0_X */ + +/* Reset the CRC variable */ +PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); + +/* Write the "data" buffer to whatever output you are using. */ +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, + png_size_t length)); + +/* Decompress data in a chunk that uses compression */ +#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_charp chunkdata, png_size_t chunklength, + png_size_t prefix_length, png_size_t *data_length)); +#endif + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, + png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +#endif + + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). + * The only currently known PNG chunks that use signed numbers are + * the ancillary extension chunks, oFFs and pCAL. + */ +PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i)); + +#if defined(PNG_WRITE_pCAL_SUPPORTED) || defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i)); +#endif + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i)); + +/* simple function to write the signature */ +PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); + +/* write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, + png_uint_32 height, + int bit_depth, int color_type, int compression_method, int filter_method, + int interlace_method)); + +PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, + png_uint_32 num_pal)); + +PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, + png_fixed_point file_gamma)); +#endif +#endif + +#if defined(PNG_WRITE_sBIT_SUPPORTED) +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, + int color_type)); +#endif + +#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, + double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_WRITE_sRGB_SUPPORTED) +PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, + int intent)); +#endif + +#if defined(PNG_WRITE_iCCP_SUPPORTED) +PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, + png_charp name, int compression_type, + png_charp profile, int proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, + png_sPLT_tp palette)); +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, + png_color_16p values, int number, int color_type)); +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, + png_color_16p values, int color_type)); +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, + int num_hist)); +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, + png_charp key, png_charpp new_key)); +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len)); +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len, int compression)); +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, + int compression, png_charp key, png_charp lang, png_charp lang_key, + png_charp text)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ +PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, + png_int_32 x_offset, png_int_32 y_offset, int unit_type)); +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, + png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params)); +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type)); +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, + png_timep mod_time)); +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, + int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, + int unit, png_charp width, png_charp height)); +#endif +#endif +#endif + +/* Called when finished processing a row of data */ +PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); + +/* Internal use only. Called before first row of data */ +PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#endif + +/* combine a row of data, dealing with alpha, etc. if requested */ +PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, + int mask)); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +/* expand an interlaced row */ +/* OLD pre-1.0.9 interface: +PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations)); + */ +PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* grab pixels out of a row for an interlaced pass */ +PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass)); +#endif + +/* unfilter a row */ +PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); + +/* Choose the best filter to use and filter the row data */ +PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, + png_row_infop row_info)); + +/* Write out the filtered row. */ +PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, + png_bytep filtered_row)); +/* finish a row while reading, dealing with interlacing passes, etc. */ +PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); + +/* initialize the row buffers, etc. */ +PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); +/* optional call to update the users info structure */ +PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* these are the functions that do the transformations */ +#if defined(PNG_READ_FILLER_SUPPORTED) +PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) ||defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop + row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p sig_bits)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, + png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); + +# if defined(PNG_CORRECT_PALETTE_SUPPORTED) +PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette)); +# endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) +PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth)); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p bit_depth)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background, + png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift)); +#else +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background)); +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift)); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, + png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); +PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, + png_bytep row, png_color_16p trans_value)); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* decode the IHDR chunk */ +PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); + +#if defined(PNG_READ_bKGD_SUPPORTED) +PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_gAMA_SUPPORTED) +PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_iCCP_SUPPORTED) +extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sPLT_SUPPORTED) +extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_sRGB_SUPPORTED) +PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tRNS_SUPPORTED) +PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); + +PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, + png_bytep chunk_name)); + +/* handle the transformations for reading and writing */ +PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); + +PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, + png_uint_32 length)); +PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); +PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) +/* png.c */ /* PRIVATE */ +PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); +#endif +/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#endif /* PNG_INTERNAL */ + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +/* do not put anything past this line */ +#endif /* PNG_H */ diff --git a/src/libs/pdflib/libs/png/pngasmrd.h b/src/libs/pdflib/libs/png/pngasmrd.h new file mode 100644 index 0000000000..79f8cb61ea --- /dev/null +++ b/src/libs/pdflib/libs/png/pngasmrd.h @@ -0,0 +1,13 @@ +/* PDFlib GmbH cvsid: $Id: pngasmrd.h,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngasmrd.h - assembler version of utilities to read a PNG file + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 2002 Glenn Randers-Pehrson + * + */ + +/* This file is obsolete in libpng-1.0.9 and later; its contents now appear + * at the end of pngconf.h. + */ diff --git a/src/libs/pdflib/libs/png/pngconf.h b/src/libs/pdflib/libs/png/pngconf.h new file mode 100644 index 0000000000..356890556c --- /dev/null +++ b/src/libs/pdflib/libs/png/pngconf.h @@ -0,0 +1,1656 @@ +/* PDFlib GmbH cvsid: $Id: pngconf.h,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngconf.h - machine configurable file for libpng + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* Any machine specific code is near the front of this file, so if you + * are configuring libpng for a machine, you may want to read the section + * starting here down to where it starts to typedef png_color, png_text, + * and png_info. + */ + +#ifndef PNGCONF_H +#define PNGCONF_H + +#define PNG_STATIC /* PDFlib GmbH: always create a static lib under Cygwin */ + +#define PNG_PREFIX /* PDFlib GmbH: use private function names */ +#define PNG_USER_MEM_SUPPORTED /* PDFlib GmbH: allow private alloc functions */ +#define PNG_NO_WRITE_SUPPORTED /* PDFlib GmbH: we don't need write support */ +#define PNG_NO_ERROR_NUMBERS /* PDFlib GmbH: we don't need this */ + +/* PDFlib GmbH: prefix public PNG names with pdf_ */ +/* Make sure to observe the limit of 31 characters for function names! */ +#ifdef PNG_PREFIX +#define png_IDAT pdf_png_IDAT +#define png_IEND pdf_png_IEND +#define png_IHDR pdf_png_IHDR +#define png_PLTE pdf_png_PLTE +#define png_access_version_number pdf_png_access_version_number +#define png_bKGD pdf_png_bKGD +#define png_cHRM pdf_png_cHRM +#define png_calculate_crc pdf_png_calculate_crc +#define png_check_sig pdf_png_check_sig +#define png_convert_to_rfc1123 pdf_png_convert_to_rfc1123 +#define png_create_info_struct pdf_png_create_info_struct +#define png_data_freer pdf_png_data_freer +#define png_destroy_info_struct pdf_png_destroy_info_struct +#define png_free_data pdf_png_free_data +#define png_gAMA pdf_png_gAMA +#define png_get_copyright pdf_png_get_copyright +#define png_get_header_ver pdf_png_get_header_ver +#define png_get_header_version pdf_png_get_header_version +#define png_get_io_ptr pdf_png_get_io_ptr +#define png_get_libpng_ver pdf_png_get_libpng_ver +#define png_hIST pdf_png_hIST +#define png_handle_as_unknown pdf_png_handle_as_unknown +#define png_iCCP pdf_png_iCCP +#define png_iTXt pdf_png_iTXt +#define png_info_destroy pdf_png_info_destroy +#define png_info_init pdf_png_info_init +#define png_info_init_3 pdf_png_info_init_3 +#define png_init_io pdf_png_init_io +#define png_init_mmx_flags pdf_png_init_mmx_flags +#define png_libpng_ver pdf_png_libpng_ver +#define png_mmx_support pdf_png_mmx_support +#define png_oFFs pdf_png_oFFs +#define png_pCAL pdf_png_pCAL +#define png_pHYs pdf_png_pHYs +#define png_pass_dsp_mask pdf_png_pass_dsp_mask +#define png_pass_inc pdf_png_pass_inc +#define png_pass_mask pdf_png_pass_mask +#define png_pass_start pdf_png_pass_start +#define png_pass_yinc pdf_png_pass_yinc +#define png_pass_ystart pdf_png_pass_ystart +#define png_reset_crc pdf_png_reset_crc +#define png_reset_zstream pdf_png_reset_zstream +#define png_sBIT pdf_png_sBIT +#define png_sCAL pdf_png_sCAL +#define png_sPLT pdf_png_sPLT +#define png_sRGB pdf_png_sRGB +#define png_set_sig_bytes pdf_png_set_sig_bytes +#define png_sig pdf_png_sig +#define png_sig_cmp pdf_png_sig_cmp +#define png_tEXt pdf_png_tEXt +#define png_tIME pdf_png_tIME +#define png_tRNS pdf_png_tRNS +#define png_zTXt pdf_png_zTXt +#define png_zalloc pdf_png_zalloc +#define png_zfree pdf_png_zfree +#define png_permit_empty_plte pdf_png_permit_empty_plte +#define png_permit_mng_features pdf_png_permit_mng_features +#define png_set_IHDR pdf_png_set_IHDR +#define png_set_PLTE pdf_png_set_PLTE +#define png_set_asm_flags pdf_png_set_asm_flags +#define png_set_bKGD pdf_png_set_bKGD +#define png_set_cHRM pdf_png_set_cHRM +#define png_set_cHRM_fixed pdf_png_set_cHRM_fixed + +/* Note: function name shortened to facilitate porting */ +#define png_set_compression_buffer_size pdf_png_set_comp_buffer_size + +#define png_set_gAMA pdf_png_set_gAMA +#define png_set_gAMA_fixed pdf_png_set_gAMA_fixed +#define png_set_hIST pdf_png_set_hIST +#define png_set_iCCP pdf_png_set_iCCP +#define png_set_invalid pdf_png_set_invalid +#define png_set_keep_unknown_chunks pdf_png_set_keep_unknown_chunks +#define png_set_mmx_thresholds pdf_png_set_mmx_thresholds +#define png_set_oFFs pdf_png_set_oFFs +#define png_set_pCAL pdf_png_set_pCAL +#define png_set_pHYs pdf_png_set_pHYs +#define png_set_read_user_chunk_fn pdf_png_set_read_user_chunk_fn +#define png_set_rows pdf_png_set_rows +#define png_set_sBIT pdf_png_set_sBIT +#define png_set_sCAL pdf_png_set_sCAL +#define png_set_sPLT pdf_png_set_sPLT +#define png_set_sRGB pdf_png_set_sRGB +#define png_set_sRGB_gAMA_and_cHRM pdf_png_set_sRGB_gAMA_and_cHRM +#define png_set_tIME pdf_png_set_tIME +#define png_set_tRNS pdf_png_set_tRNS +#define png_set_text pdf_png_set_text +#define png_set_text_2 pdf_png_set_text_2 + +/* Note: function name shortened to facilitate porting */ +#define png_set_unknown_chunk_location pdf_png_set_unk_chunk_location + +#define png_set_unknown_chunks pdf_png_set_unknown_chunks +#define png_get_IHDR pdf_png_get_IHDR +#define png_get_PLTE pdf_png_get_PLTE +#define png_get_asm_flagmask pdf_png_get_asm_flagmask +#define png_get_asm_flags pdf_png_get_asm_flags +#define png_get_bKGD pdf_png_get_bKGD +#define png_get_bit_depth pdf_png_get_bit_depth +#define png_get_cHRM pdf_png_get_cHRM +#define png_get_cHRM_fixed pdf_png_get_cHRM_fixed +#define png_get_channels pdf_png_get_channels +#define png_get_color_type pdf_png_get_color_type + +/* Note: function name shortened to facilitate porting */ +#define png_get_compression_buffer_size pdf_png_get_comp_buffer_size + +#define png_get_compression_type pdf_png_get_compression_type +#define png_get_filter_type pdf_png_get_filter_type +#define png_get_gAMA pdf_png_get_gAMA +#define png_get_gAMA_fixed pdf_png_get_gAMA_fixed +#define png_get_hIST pdf_png_get_hIST +#define png_get_iCCP pdf_png_get_iCCP +#define png_get_image_height pdf_png_get_image_height +#define png_get_image_width pdf_png_get_image_width +#define png_get_interlace_type pdf_png_get_interlace_type + +/* Note: function name shortened to facilitate porting */ +#define png_get_mmx_bitdepth_threshold pdf_png_get_mmx_bitdpth_thresh + +#define png_get_mmx_flagmask pdf_png_get_mmx_flagmask + +/* Note: function name shortened to facilitate porting */ +#define png_get_mmx_rowbytes_threshold pdf_png_get_mmx_rowbytes_thresh + +#define png_get_oFFs pdf_png_get_oFFs +#define png_get_pCAL pdf_png_get_pCAL +#define png_get_pHYs pdf_png_get_pHYs +#define png_get_pixel_aspect_ratio pdf_png_get_pixel_aspect_ratio +#define png_get_pixels_per_meter pdf_png_get_pixels_per_meter +#define png_get_rgb_to_gray_status pdf_png_get_rgb_to_gray_status +#define png_get_rowbytes pdf_png_get_rowbytes +#define png_get_rows pdf_png_get_rows +#define png_get_sBIT pdf_png_get_sBIT +#define png_get_sCAL pdf_png_get_sCAL +#define png_get_sPLT pdf_png_get_sPLT +#define png_get_sRGB pdf_png_get_sRGB +#define png_get_signature pdf_png_get_signature +#define png_get_tIME pdf_png_get_tIME +#define png_get_tRNS pdf_png_get_tRNS +#define png_get_text pdf_png_get_text +#define png_get_unknown_chunks pdf_png_get_unknown_chunks +#define png_get_user_chunk_ptr pdf_png_get_user_chunk_ptr +#define png_get_valid pdf_png_get_valid +#define png_get_x_offset_microns pdf_png_get_x_offset_microns +#define png_get_x_offset_pixels pdf_png_get_x_offset_pixels +#define png_get_x_pixels_per_meter pdf_png_get_x_pixels_per_meter +#define png_get_y_offset_microns pdf_png_get_y_offset_microns +#define png_get_y_offset_pixels pdf_png_get_y_offset_pixels +#define png_get_y_pixels_per_meter pdf_png_get_y_pixels_per_meter +#define png_check_chunk_name pdf_png_check_chunk_name +#define png_combine_row pdf_png_combine_row +#define png_crc_error pdf_png_crc_error +#define png_crc_finish pdf_png_crc_finish +#define png_crc_read pdf_png_crc_read +#define png_decompress_chunk pdf_png_decompress_chunk +#define png_do_read_interlace pdf_png_do_read_interlace +#define png_get_int_32 pdf_png_get_int_32 +#define png_get_uint_16 pdf_png_get_uint_16 +#define png_get_uint_32 pdf_png_get_uint_32 +#define png_handle_IEND pdf_png_handle_IEND +#define png_handle_IHDR pdf_png_handle_IHDR +#define png_handle_PLTE pdf_png_handle_PLTE +#define png_handle_bKGD pdf_png_handle_bKGD +#define png_handle_cHRM pdf_png_handle_cHRM +#define png_handle_gAMA pdf_png_handle_gAMA +#define png_handle_hIST pdf_png_handle_hIST +#define png_handle_iCCP pdf_png_handle_iCCP +#define png_handle_oFFs pdf_png_handle_oFFs +#define png_handle_pCAL pdf_png_handle_pCAL +#define png_handle_pHYs pdf_png_handle_pHYs +#define png_handle_sBIT pdf_png_handle_sBIT +#define png_handle_sCAL pdf_png_handle_sCAL +#define png_handle_sPLT pdf_png_handle_sPLT +#define png_handle_sRGB pdf_png_handle_sRGB +#define png_handle_tEXt pdf_png_handle_tEXt +#define png_handle_tIME pdf_png_handle_tIME +#define png_handle_tRNS pdf_png_handle_tRNS +#define png_handle_unknown pdf_png_handle_unknown +#define png_handle_zTXt pdf_png_handle_zTXt +#define png_read_filter_row pdf_png_read_filter_row +#define png_read_finish_row pdf_png_read_finish_row +#define png_read_start_row pdf_png_read_start_row +#define png_do_bgr pdf_png_do_bgr +#define png_do_invert pdf_png_do_invert +#define png_do_packswap pdf_png_do_packswap +#define png_do_strip_filler pdf_png_do_strip_filler +#define png_do_swap pdf_png_do_swap +#define png_get_user_transform_ptr pdf_png_get_user_transform_ptr +#define png_set_bgr pdf_png_set_bgr +#define png_set_filler pdf_png_set_filler +#define png_set_interlace_handling pdf_png_set_interlace_handling +#define png_set_invert_alpha pdf_png_set_invert_alpha +#define png_set_invert_mono pdf_png_set_invert_mono +#define png_set_packing pdf_png_set_packing +#define png_set_packswap pdf_png_set_packswap +#define png_set_shift pdf_png_set_shift +#define png_set_swap pdf_png_set_swap +#define png_set_swap_alpha pdf_png_set_swap_alpha +#define png_set_user_transform_info pdf_png_set_user_transform_info +#define png_create_read_struct pdf_png_create_read_struct +#define png_create_read_struct_2 pdf_png_create_read_struct_2 +#define png_destroy_read_struct pdf_png_destroy_read_struct +#define png_read_destroy pdf_png_read_destroy +#define png_read_end pdf_png_read_end +#define png_read_image pdf_png_read_image +#define png_read_info pdf_png_read_info +#define png_read_init pdf_png_read_init +#define png_read_init_2 pdf_png_read_init_2 +#define png_read_init_3 pdf_png_read_init_3 +#define png_read_png pdf_png_read_png +#define png_read_row pdf_png_read_row +#define png_read_rows pdf_png_read_rows +#define png_read_update_info pdf_png_read_update_info +#define png_set_read_status_fn pdf_png_set_read_status_fn +#define png_start_read_image pdf_png_start_read_image +#define png_default_read_data pdf_png_default_read_data +#define png_read_data pdf_png_read_data +#define png_set_read_fn pdf_png_set_read_fn +#define png_build_gamma_table pdf_png_build_gamma_table +#define png_build_grayscale_palette pdf_png_build_grayscale_palette +#define png_do_background pdf_png_do_background +#define png_do_chop pdf_png_do_chop +#define png_do_dither pdf_png_do_dither +#define png_do_expand pdf_png_do_expand +#define png_do_expand_palette pdf_png_do_expand_palette +#define png_do_gamma pdf_png_do_gamma +#define png_do_gray_to_rgb pdf_png_do_gray_to_rgb +#define png_do_read_filler pdf_png_do_read_filler +#define png_do_read_intrapixel pdf_png_do_read_intrapixel +#define png_do_read_invert_alpha pdf_png_do_read_invert_alpha +#define png_do_read_swap_alpha pdf_png_do_read_swap_alpha +#define png_do_read_transformations pdf_png_do_read_transformations +#define png_do_rgb_to_gray pdf_png_do_rgb_to_gray +#define png_do_unpack pdf_png_do_unpack +#define png_do_unshift pdf_png_do_unshift + +/* Note: function name shortened to facilitate porting */ +#define png_init_read_transformations pdf_png_init_read_transforms + +#define png_read_transform_info pdf_png_read_transform_info +#define png_set_background pdf_png_set_background +#define png_set_crc_action pdf_png_set_crc_action +#define png_set_dither pdf_png_set_dither +#define png_set_expand pdf_png_set_expand +#define png_set_gamma pdf_png_set_gamma +#define png_set_gray_1_2_4_to_8 pdf_png_set_gray_1_2_4_to_8 +#define png_set_gray_to_rgb pdf_png_set_gray_to_rgb +#define png_set_palette_to_rgb pdf_png_set_palette_to_rgb + +/* Note: function name shortened to facilitate porting */ +#define png_set_read_user_transform_fn pdf_png_set_read_user_trans_fn + +#define png_set_rgb_to_gray pdf_png_set_rgb_to_gray +#define png_set_rgb_to_gray_fixed pdf_png_set_rgb_to_gray_fixed +#define png_set_strip_16 pdf_png_set_strip_16 +#define png_set_strip_alpha pdf_png_set_strip_alpha +#define png_set_tRNS_to_alpha pdf_png_set_tRNS_to_alpha +#define png_create_struct pdf_png_create_struct +#define png_create_struct_2 pdf_png_create_struct_2 +#define png_destroy_struct pdf_png_destroy_struct +#define png_destroy_struct_2 pdf_png_destroy_struct_2 +#define png_free pdf_png_free +#define png_free_default pdf_png_free_default +#define png_get_mem_ptr pdf_png_get_mem_ptr +#define png_malloc pdf_png_malloc +#define png_malloc_default pdf_png_malloc_default +#define png_malloc_warn pdf_png_malloc_warn +#define png_memcpy_check pdf_png_memcpy_check +#define png_memset_check pdf_png_memset_check +#define png_set_mem_fn pdf_png_set_mem_fn +#define png_chunk_error pdf_png_chunk_error +#define png_chunk_warning pdf_png_chunk_warning +#define png_error pdf_png_error +#define png_get_error_ptr pdf_png_get_error_ptr +#define png_set_error_fn pdf_png_set_error_fn +#define png_set_strip_error_numbers pdf_png_set_strip_error_numbers +#define png_warning pdf_png_warning +#endif /* PNG_PREFIX */ + +/* This is the size of the compression buffer, and thus the size of + * an IDAT chunk. Make this whatever size you feel is best for your + * machine. One of these will be allocated per png_struct. When this + * is full, it writes the data to the disk, and does some other + * calculations. Making this an extremely small size will slow + * the library down, but you may want to experiment to determine + * where it becomes significant, if you are concerned with memory + * usage. Note that zlib allocates at least 32Kb also. For readers, + * this describes the size of the buffer available to read the data in. + * Unless this gets smaller than the size of a row (compressed), + * it should not make much difference how big this is. + */ + +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif + +/* Enable if you want a write-only libpng */ + +#ifndef PNG_NO_READ_SUPPORTED +# define PNG_READ_SUPPORTED +#endif + +/* Enable if you want a read-only libpng */ + +#ifndef PNG_NO_WRITE_SUPPORTED +# define PNG_WRITE_SUPPORTED +#endif + +/* Enabled by default in 1.2.0. You can disable this if you don't need to + support PNGs that are embedded in MNG datastreams */ +#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) +# ifndef PNG_MNG_FEATURES_SUPPORTED +# define PNG_MNG_FEATURES_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_FLOATING_POINT_SUPPORTED +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FLOATING_POINT_SUPPORTED +# endif +#endif + +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. +#define PNG_MAX_MALLOC_64K + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +/* Special munging to support doing things the 'cygwin' way: + * 'Normal' png-on-win32 defines/defaults: + * PNG_BUILD_DLL -- building dll + * PNG_USE_DLL -- building an application, linking to dll + * (no define) -- building static library, or building an + * application and linking to the static lib + * 'Cygwin' defines/defaults: + * PNG_BUILD_DLL -- (ignored) building the dll + * (no define) -- (ignored) building an application, linking to the dll + * PNG_STATIC -- (ignored) building the static lib, or building an + * application that links to the static lib. + * ALL_STATIC -- (ignored) building various static libs, or building an + * application that links to the static libs. + * Thus, + * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and + * this bit of #ifdefs will define the 'correct' config variables based on + * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but + * unnecessary. + * + * Also, the precedence order is: + * ALL_STATIC (since we can't #undef something outside our namespace) + * PNG_BUILD_DLL + * PNG_STATIC + * (nothing) == PNG_USE_DLL + * + * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent + * of auto-import in binutils, we no longer need to worry about + * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, + * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes + * to __declspec() stuff. However, we DO need to worry about + * PNG_BUILD_DLL and PNG_STATIC because those change some defaults + * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. + */ +#if defined(__CYGWIN__) +# if defined(ALL_STATIC) +# if defined(PNG_BUILD_DLL) +# undef PNG_BUILD_DLL +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# if !defined(PNG_STATIC) +# define PNG_STATIC +# endif +# else +# if defined (PNG_BUILD_DLL) +# if defined(PNG_STATIC) +# undef PNG_STATIC +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# else +# if defined(PNG_STATIC) +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# else +# if !defined(PNG_USE_DLL) +# define PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# endif +# endif +# endif +#endif + +/* This protects us against compilers that run on a windowing system + * and thus don't have or would rather us not use the stdio types: + * stdin, stdout, and stderr. The only one currently used is stderr + * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will + * prevent these from being compiled and used. #defining PNG_NO_STDIO + * will also prevent these, plus will prevent the entire set of stdio + * macros and functions (FILE *, printf, etc.) from being compiled and used, + * unless (PNG_DEBUG > 0) has been #defined. + * + * #define PNG_NO_CONSOLE_IO + * #define PNG_NO_STDIO + */ + +#if defined(_WIN32_WCE) +# include + /* Console I/O functions are not supported on WindowsCE */ +# define PNG_NO_CONSOLE_IO +# ifdef PNG_DEBUG +# undef PNG_DEBUG +# endif +#endif + +#ifdef PNG_BUILD_DLL +# ifndef PNG_CONSOLE_IO_SUPPORTED +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# endif +#endif + +# ifdef PNG_NO_STDIO +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# include +# endif +# endif +# else +# if !defined(_WIN32_WCE) +/* "stdio.h" functions are not supported on WindowsCE */ +# include +# endif +# endif + +/* This macro protects us against machines that don't have function + * prototypes (ie K&R style headers). If your compiler does not handle + * function prototypes, define this macro and use the included ansi2knr. + * I've always been able to use _NO_PROTO as the indicator, but you may + * need to drag the empty declaration out in front of here, or change the + * ifdef to suit your own needs. + */ +#ifndef PNGARG + +#ifdef OF /* zlib prototype munger */ +# define PNGARG(arglist) OF(arglist) +#else + +#ifdef _NO_PROTO +# define PNGARG(arglist) () +# ifndef PNG_TYPECAST_NULL +# define PNG_TYPECAST_NULL +# endif +#else +# define PNGARG(arglist) arglist +#endif /* _NO_PROTO */ + +#endif /* OF */ + +#endif /* PNGARG */ + +/* Try to determine if we are compiling on a Mac. Note that testing for + * just __MWERKS__ is not good enough, because the Codewarrior is now used + * on non-Mac platforms. + */ +#ifndef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) +# define MACOS +# endif +#endif + +/* enough people need this for various reasons to include it here */ +/* PDFlib GmbH: not needed +#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) +# include +#endif +*/ + +#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) +# define PNG_SETJMP_SUPPORTED +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This is an attempt to force a single setjmp behaviour on Linux. If + * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + */ + +# ifdef __linux__ +# ifdef _BSD_SOURCE +# define PNG_SAVE_BSD_SOURCE +# undef _BSD_SOURCE +# endif +/* PDFlib GmbH: not necceary +# ifdef _SETJMP_H + __png.h__ already includes setjmp.h; + __dont__ include it again.; +# endif +*/ +# endif /* __linux__ */ + + /* include setjmp.h for error handling */ +# include + +# ifdef __linux__ +# ifdef PNG_SAVE_BSD_SOURCE +# define _BSD_SOURCE +# undef PNG_SAVE_BSD_SOURCE +# endif +# endif /* __linux__ */ +#endif /* PNG_SETJMP_SUPPORTED */ + +#ifdef BSD +# include +#else +# include +#endif + +/* Other defines for things like memory and the like can go here. */ +#ifdef PNG_INTERNAL + +#include + +/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which + * aren't usually used outside the library (as far as I know), so it is + * debatable if they should be exported at all. In the future, when it is + * possible to have run-time registry of chunk-handling functions, some of + * these will be made available again. +#define PNG_EXTERN extern + */ +#define PNG_EXTERN + +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) +# if defined(MACOS) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include +# endif +# else +# include +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include +# endif +#endif + +/* Codewarrior on NT has linking problems without this. */ +#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) +# define PNG_ALWAYS_EXTERN +#endif + +/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not + * stdlib.h like it should (I think). Or perhaps this is a C++ + * "feature"? + */ +#ifdef __TURBOC__ +# include +# include "alloc.h" +#endif + +#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ + defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) +# include +#endif + +/* This controls how fine the dithering gets. As this allocates + * a largish chunk of memory (32K), those who are not as concerned + * with dithering quality can decrease some or all of these. + */ +#ifndef PNG_DITHER_RED_BITS +# define PNG_DITHER_RED_BITS 5 +#endif +#ifndef PNG_DITHER_GREEN_BITS +# define PNG_DITHER_GREEN_BITS 5 +#endif +#ifndef PNG_DITHER_BLUE_BITS +# define PNG_DITHER_BLUE_BITS 5 +#endif + +/* This controls how fine the gamma correction becomes when you + * are only interested in 8 bits anyway. Increasing this value + * results in more memory being used, and more pow() functions + * being called to fill in the gamma tables. Don't set this value + * less then 8, and even that may not work (I haven't tested it). + */ + +#ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +#endif + +/* This controls how much a difference in gamma we can tolerate before + * we actually start doing gamma conversion. + */ +#ifndef PNG_GAMMA_THRESHOLD +# define PNG_GAMMA_THRESHOLD 0.05 +#endif + +#endif /* PNG_INTERNAL */ + +/* The following uses const char * instead of char * for error + * and warning message functions, so some compilers won't complain. + * If you do not want to use const, define PNG_NO_CONST here. + */ + +#ifndef PNG_NO_CONST +# define PNG_CONST const +#else +# define PNG_CONST +#endif + +/* The following defines give you the ability to remove code from the + * library that you will not be using. I wish I could figure out how to + * automate this, but I can't do that without making it seriously hard + * on the users. So if you are not using an ability, change the #define + * to and #undef, and that part of the library will not be compiled. If + * your linker can't find a function, you may want to make sure the + * ability is defined here. Some of these depend upon some others being + * defined. I haven't figured out all the interactions here, so you may + * have to experiment awhile to get everything to compile. If you are + * creating or using a shared library, you probably shouldn't touch this, + * as it will affect the size of the structures, and this will cause bad + * things to happen if the library and/or application ever change. + */ + +/* Any features you will not be using can be undef'ed here */ + +/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user + * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS + * on the compile line, then pick and choose which ones to define without + * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED + * if you only want to have a png-compliant reader/writer but don't need + * any of the extra transformations. This saves about 80 kbytes in a + * typical installation of the library. (PNG_NO_* form added in version + * 1.0.1c, for consistency) + */ + +/* The size of the png_text structure changed in libpng-1.0.6 when + * iTXt is supported. It is turned off by default, to support old apps + * that malloc the png_text structure instead of calling png_set_text() + * and letting libpng malloc it. It will be turned on by default in + * libpng-1.3.0. + */ + +#ifndef PNG_iTXt_SUPPORTED +# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) +# define PNG_NO_READ_iTXt +# endif +# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) +# define PNG_NO_WRITE_iTXt +# endif +#endif + +/* The following support, added after version 1.0.0, can be turned off here en + * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility + * with old applications that require the length of png_struct and png_info + * to remain unchanged. + */ + +#ifdef PNG_LEGACY_SUPPORTED +# define PNG_NO_FREE_ME +# define PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_NO_READ_USER_CHUNKS +# define PNG_NO_READ_iCCP +# define PNG_NO_WRITE_iCCP +# define PNG_NO_READ_iTXt +# define PNG_NO_WRITE_iTXt +# define PNG_NO_READ_sCAL +# define PNG_NO_WRITE_sCAL +# define PNG_NO_READ_sPLT +# define PNG_NO_WRITE_sPLT +# define PNG_NO_INFO_IMAGE +# define PNG_NO_READ_RGB_TO_GRAY +# define PNG_NO_READ_USER_TRANSFORM +# define PNG_NO_WRITE_USER_TRANSFORM +# define PNG_NO_USER_MEM +# define PNG_NO_READ_EMPTY_PLTE +# define PNG_NO_MNG_FEATURES +# define PNG_NO_FIXED_POINT_SUPPORTED +#endif + +/* Ignore attempt to turn off both floating and fixed point support */ +#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ + !defined(PNG_NO_FIXED_POINT_SUPPORTED) +# define PNG_FIXED_POINT_SUPPORTED +#endif + +#ifndef PNG_NO_FREE_ME +# define PNG_FREE_ME_SUPPORTED +#endif + +#if defined(PNG_READ_SUPPORTED) + +#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_TRANSFORMS) +# define PNG_READ_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_READ_EXPAND +# define PNG_READ_EXPAND_SUPPORTED +# endif +# ifndef PNG_NO_READ_SHIFT +# define PNG_READ_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACK +# define PNG_READ_PACK_SUPPORTED +# endif +# ifndef PNG_NO_READ_BGR +# define PNG_READ_BGR_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP +# define PNG_READ_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACKSWAP +# define PNG_READ_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT +# define PNG_READ_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_READ_DITHER +# define PNG_READ_DITHER_SUPPORTED +# endif +# ifndef PNG_NO_READ_BACKGROUND +# define PNG_READ_BACKGROUND_SUPPORTED +# endif +# ifndef PNG_NO_READ_16_TO_8 +# define PNG_READ_16_TO_8_SUPPORTED +# endif +# ifndef PNG_NO_READ_FILLER +# define PNG_READ_FILLER_SUPPORTED +# endif +# ifndef PNG_NO_READ_GAMMA +# define PNG_READ_GAMMA_SUPPORTED +# endif +# ifndef PNG_NO_READ_GRAY_TO_RGB +# define PNG_READ_GRAY_TO_RGB_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP_ALPHA +# define PNG_READ_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT_ALPHA +# define PNG_READ_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_STRIP_ALPHA +# define PNG_READ_STRIP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_USER_TRANSFORM +# define PNG_READ_USER_TRANSFORM_SUPPORTED +# endif +# ifndef PNG_NO_READ_RGB_TO_GRAY +# define PNG_READ_RGB_TO_GRAY_SUPPORTED +# endif +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_PROGRESSIVE_READ) && \ + !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ +# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ +#endif /* about interlacing capability! You'll */ + /* still have interlacing unless you change the following line: */ + +#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ + +#ifndef PNG_NO_READ_COMPOSITE_NODIV +# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ +# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ +# endif +#endif + +/* Deprecated, will be removed from version 2.0.0. + Use PNG_MNG_FEATURES_SUPPORTED instead. */ +#ifndef PNG_NO_READ_EMPTY_PLTE +# define PNG_READ_EMPTY_PLTE_SUPPORTED +#endif + +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_WRITE_SUPPORTED) + +# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_TRANSFORMS) +# define PNG_WRITE_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_WRITE_SHIFT +# define PNG_WRITE_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACK +# define PNG_WRITE_PACK_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_BGR +# define PNG_WRITE_BGR_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_SWAP +# define PNG_WRITE_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACKSWAP +# define PNG_WRITE_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT +# define PNG_WRITE_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_FILLER +# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ +# endif +# ifndef PNG_NO_WRITE_SWAP_ALPHA +# define PNG_WRITE_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT_ALPHA +# define PNG_WRITE_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_USER_TRANSFORM +# define PNG_WRITE_USER_TRANSFORM_SUPPORTED +# endif +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +# ifndef PNG_NO_USER_TRANSFORM_PTR +# define PNG_USER_TRANSFORM_PTR_SUPPORTED +# endif +#endif + +#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant + encoders, but can cause trouble + if left undefined */ + +#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#endif + +#ifndef PNG_1_0_X +#ifndef PNG_NO_ERROR_NUMBERS +#define PNG_ERROR_NUMBERS_SUPPORTED +#endif +#endif /* PNG_1_0_X */ + +#ifndef PNG_NO_WRITE_FLUSH +# define PNG_WRITE_FLUSH_SUPPORTED +#endif + +/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ +#ifndef PNG_NO_WRITE_EMPTY_PLTE +# define PNG_WRITE_EMPTY_PLTE_SUPPORTED +#endif + +#endif /* PNG_WRITE_SUPPORTED */ + +#ifndef PNG_NO_STDIO +# define PNG_TIME_RFC1123_SUPPORTED +#endif + +/* This adds extra functions in pngget.c for accessing data from the + * info pointer (added in version 0.99) + * png_get_image_width() + * png_get_image_height() + * png_get_bit_depth() + * png_get_color_type() + * png_get_compression_type() + * png_get_filter_type() + * png_get_interlace_type() + * png_get_pixel_aspect_ratio() + * png_get_pixels_per_meter() + * png_get_x_offset_pixels() + * png_get_y_offset_pixels() + * png_get_x_offset_microns() + * png_get_y_offset_microns() + */ +#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) +# define PNG_EASY_ACCESS_SUPPORTED +#endif + +/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 + even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) +# ifndef PNG_ASSEMBLER_CODE_SUPPORTED +# define PNG_ASSEMBLER_CODE_SUPPORTED +# endif +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_MMX_CODE_SUPPORTED +# endif +#endif + +/* If you are sure that you don't need thread safety and you are compiling + with PNG_USE_PNGCCRD for an MMX application, you can define this for + faster execution. See pnggccrd.c. +#define PNG_THREAD_UNSAFE_OK +*/ + +#if !defined(PNG_1_0_X) +#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) +# define PNG_USER_MEM_SUPPORTED +#endif +#endif /* PNG_1_0_X */ + +/* These are currently experimental features, define them if you want */ + +/* very little testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# endif +#endif +*/ + +/* This is only for PowerPC big-endian and 680x0 systems */ +/* some testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED +# define PNG_READ_BIG_ENDIAN_SUPPORTED +# endif +#endif +*/ + +/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ +/* +#define PNG_NO_POINTER_INDEXING +*/ + +/* These functions are turned off by default, as they will be phased out. */ +/* +#define PNG_USELESS_TESTS_SUPPORTED +#define PNG_CORRECT_PALETTE_SUPPORTED +*/ + +/* Any chunks you are not interested in, you can undef here. The + * ones that allocate memory may be expecially important (hIST, + * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info + * a bit smaller. + */ + +#if defined(PNG_READ_SUPPORTED) && \ + !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_ANCILLARY_CHUNKS) +# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#if defined(PNG_WRITE_SUPPORTED) && \ + !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) +# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_READ_TEXT +# define PNG_NO_READ_iTXt +# define PNG_NO_READ_tEXt +# define PNG_NO_READ_zTXt +#endif +#ifndef PNG_NO_READ_bKGD +# define PNG_READ_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +#endif +#ifndef PNG_NO_READ_cHRM +# define PNG_READ_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +#endif +#ifndef PNG_NO_READ_gAMA +# define PNG_READ_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +#endif +#ifndef PNG_NO_READ_hIST +# define PNG_READ_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +#endif +#ifndef PNG_NO_READ_iCCP +# define PNG_READ_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +#endif +#ifndef PNG_NO_READ_iTXt +# ifndef PNG_READ_iTXt_SUPPORTED +# define PNG_READ_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_READ_oFFs +# define PNG_READ_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +#endif +#ifndef PNG_NO_READ_pCAL +# define PNG_READ_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_sCAL +# define PNG_READ_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_pHYs +# define PNG_READ_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +#endif +#ifndef PNG_NO_READ_sBIT +# define PNG_READ_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sPLT +# define PNG_READ_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sRGB +# define PNG_READ_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +#endif +#ifndef PNG_NO_READ_tEXt +# define PNG_READ_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_tIME +# define PNG_READ_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +#endif +#ifndef PNG_NO_READ_tRNS +# define PNG_READ_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +#endif +#ifndef PNG_NO_READ_zTXt +# define PNG_READ_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#if !defined(PNG_NO_READ_USER_CHUNKS) && \ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# define PNG_READ_USER_CHUNKS_SUPPORTED +# define PNG_USER_CHUNKS_SUPPORTED +# ifdef PNG_NO_READ_UNKNOWN_CHUNKS +# undef PNG_NO_READ_UNKNOWN_CHUNKS +# endif +# ifdef PNG_NO_HANDLE_AS_UNKNOWN +# undef PNG_NO_HANDLE_AS_UNKNOWN +# endif +#endif +#ifndef PNG_NO_READ_OPT_PLTE +# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ +#endif /* optional PLTE chunk in RGB and RGBA images */ +#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ + defined(PNG_READ_zTXt_SUPPORTED) +# define PNG_READ_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +#endif + +#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ + +#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_WRITE_TEXT +# define PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_tEXt +# define PNG_NO_WRITE_zTXt +#endif +#ifndef PNG_NO_WRITE_bKGD +# define PNG_WRITE_bKGD_SUPPORTED +# ifndef PNG_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_cHRM +# define PNG_WRITE_cHRM_SUPPORTED +# ifndef PNG_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_gAMA +# define PNG_WRITE_gAMA_SUPPORTED +# ifndef PNG_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_hIST +# define PNG_WRITE_hIST_SUPPORTED +# ifndef PNG_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iCCP +# define PNG_WRITE_iCCP_SUPPORTED +# ifndef PNG_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iTXt +# ifndef PNG_WRITE_iTXt_SUPPORTED +# define PNG_WRITE_iTXt_SUPPORTED +# endif +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_oFFs +# define PNG_WRITE_oFFs_SUPPORTED +# ifndef PNG_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pCAL +# define PNG_WRITE_pCAL_SUPPORTED +# ifndef PNG_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sCAL +# define PNG_WRITE_sCAL_SUPPORTED +# ifndef PNG_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pHYs +# define PNG_WRITE_pHYs_SUPPORTED +# ifndef PNG_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sBIT +# define PNG_WRITE_sBIT_SUPPORTED +# ifndef PNG_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sPLT +# define PNG_WRITE_sPLT_SUPPORTED +# ifndef PNG_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sRGB +# define PNG_WRITE_sRGB_SUPPORTED +# ifndef PNG_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tEXt +# define PNG_WRITE_tEXt_SUPPORTED +# ifndef PNG_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tIME +# define PNG_WRITE_tIME_SUPPORTED +# ifndef PNG_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tRNS +# define PNG_WRITE_tRNS_SUPPORTED +# ifndef PNG_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_zTXt +# define PNG_WRITE_zTXt_SUPPORTED +# ifndef PNG_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +# endif +#endif +#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ + defined(PNG_WRITE_zTXt_SUPPORTED) +# define PNG_WRITE_TEXT_SUPPORTED +# ifndef PNG_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +# endif +#endif + +#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ + +/* Turn this off to disable png_read_png() and + * png_write_png() and leave the row_pointers member + * out of the info structure. + */ +#ifndef PNG_NO_INFO_IMAGE +# define PNG_INFO_IMAGE_SUPPORTED +#endif + +/* need the time information for reading tIME chunks */ +#if defined(PNG_tIME_SUPPORTED) +# if !defined(_WIN32_WCE) + /* "time.h" functions are not supported on WindowsCE */ +# include +# endif +#endif + +/* Some typedefs to get us started. These should be safe on most of the + * common platforms. The typedefs should be at least as large as the + * numbers suggest (a png_uint_32 must be at least 32 bits long), but they + * don't have to be exactly that size. Some compilers dislike passing + * unsigned shorts as function parameters, so you may be better off using + * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may + * want to have unsigned int for png_uint_32 instead of unsigned long. + */ + +typedef unsigned long png_uint_32; +typedef long png_int_32; +typedef unsigned short png_uint_16; +typedef short png_int_16; +typedef unsigned char png_byte; + +/* This is usually size_t. It is typedef'ed just in case you need it to + change (I'm not sure if you will or not, so I thought I'd be safe) */ +typedef size_t png_size_t; + +/* The following is needed for medium model support. It cannot be in the + * PNG_INTERNAL section. Needs modification for other compilers besides + * MSC. Model independent support declares all arrays and pointers to be + * large using the far keyword. The zlib version used must also support + * model independent data. As of version zlib 1.0.4, the necessary changes + * have been made in zlib. The USE_FAR_KEYWORD define triggers other + * changes that are needed. (Tim Wegner) + */ + +/* Separate compiler dependencies (problem here is that zlib.h always + defines FAR. (SJT) */ +#ifdef __BORLANDC__ +# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) +# define LDATA 1 +# else +# define LDATA 0 +# endif + /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ +# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) +# define PNG_MAX_MALLOC_64K +# if (LDATA != 1) +# ifndef FAR +# define FAR __far +# endif +# define USE_FAR_KEYWORD +# endif /* LDATA != 1 */ + /* Possibly useful for moving data out of default segment. + * Uncomment it if you want. Could also define FARDATA as + * const if your compiler supports it. (SJT) +# define FARDATA FAR + */ +# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ +#endif /* __BORLANDC__ */ + + +/* Suggest testing for specific compiler first before testing for + * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, + * making reliance oncertain keywords suspect. (SJT) + */ + +/* MSC Medium model */ +#if defined(FAR) +# if defined(M_I86MM) +# define USE_FAR_KEYWORD +# define FARDATA FAR +# include +# endif +#endif + +/* SJT: default case */ +#ifndef FAR +# define FAR +#endif + +/* At this point FAR is always defined */ +#ifndef FARDATA +# define FARDATA +#endif + +/* Typedef for floating-point numbers that are converted + to fixed-point with a multiple of 100,000, e.g., int_gamma */ +typedef png_int_32 png_fixed_point; + +/* Add typedefs for pointers */ +typedef void FAR * png_voidp; +typedef png_byte FAR * png_bytep; +typedef png_uint_32 FAR * png_uint_32p; +typedef png_int_32 FAR * png_int_32p; +typedef png_uint_16 FAR * png_uint_16p; +typedef png_int_16 FAR * png_int_16p; +typedef PNG_CONST char FAR * png_const_charp; +typedef char FAR * png_charp; +typedef png_fixed_point FAR * png_fixed_point_p; + +#ifndef PNG_NO_STDIO +/* PDFlib GmbH: not used +#if defined(_WIN32_WCE) +typedef HANDLE png_FILE_p; +#else +*/ +typedef FILE * png_FILE_p; +/* #endif PDFlib GmbH: */ +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * png_doublep; +#endif + +/* Pointers to pointers; i.e. arrays */ +typedef png_byte FAR * FAR * png_bytepp; +typedef png_uint_32 FAR * FAR * png_uint_32pp; +typedef png_int_32 FAR * FAR * png_int_32pp; +typedef png_uint_16 FAR * FAR * png_uint_16pp; +typedef png_int_16 FAR * FAR * png_int_16pp; +typedef PNG_CONST char FAR * FAR * png_const_charpp; +typedef char FAR * FAR * png_charpp; +typedef png_fixed_point FAR * FAR * png_fixed_point_pp; +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * FAR * png_doublepp; +#endif + +/* Pointers to pointers to pointers; i.e., pointer to array */ +typedef char FAR * FAR * FAR * png_charppp; + +/* libpng typedefs for types in zlib. If zlib changes + * or another compression library is used, then change these. + * Eliminates need to change all the source files. + */ +typedef charf * png_zcharp; +typedef charf * FAR * png_zcharpp; +typedef z_stream FAR * png_zstreamp; + +/* + * Define PNG_BUILD_DLL if the module being built is a Windows + * LIBPNG DLL. + * + * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. + * It is equivalent to Microsoft predefined macro _DLL that is + * automatically defined when you compile using the share + * version of the CRT (C Run-Time library) + * + * The cygwin mods make this behavior a little different: + * Define PNG_BUILD_DLL if you are building a dll for use with cygwin + * Define PNG_STATIC if you are building a static library for use with cygwin, + * -or- if you are building an application that you want to link to the + * static library. + * PNG_USE_DLL is defined by default (no user action needed) unless one of + * the other flags is defined. + */ + +#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) +# define PNG_DLL +#endif +/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. + * When building a static lib, default to no GLOBAL ARRAYS, but allow + * command-line override + */ +#if defined(__CYGWIN__) +# if !defined(PNG_STATIC) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +# else +# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# endif +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +#endif + +/* Do not use global arrays (helps with building DLL's) + * They are no longer used in libpng itself, since version 1.0.5c, + * but might be required for some pre-1.0.5c applications. + */ +#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) +# define PNG_USE_LOCAL_ARRAYS +# else +# define PNG_USE_GLOBAL_ARRAYS +# endif +#endif + +#if defined(__CYGWIN__) +# undef PNGAPI +# define PNGAPI __cdecl +# undef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", + * you may get warnings regarding the linkage of png_zalloc and png_zfree. + * Don't ignore those warnings; you must also reset the default calling + * convention in your compiler to match your PNGAPI, and you must build + * zlib and your applications the same way you build libpng. + */ + +#ifndef PNGAPI + +#if defined(__MINGW32__) && !defined(PNG_MODULEDEF) +# ifndef PNG_NO_MODULEDEF +# define PNG_NO_MODULEDEF +# endif +#endif + +#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) +# define PNG_IMPEXP +#endif + +#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ + (( defined(_Windows) || defined(_WINDOWS) || \ + defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) + +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGAPI __cdecl +# else +/* PDFlib GmbH: new */ +# if defined(_WIN32_WCE) +# define PNGAPI /* */ +# elif !defined(OS390) && !defined(MVS) +# define PNGAPI __cdecl +# else +# define PNGAPI /* */ +# endif +/* PDFlib GmbH: end */ +/* # define PNGAPI _cdecl +PDFlib GmbH: old */ +# endif + +# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ + 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) +# define PNG_IMPEXP +# endif + +# if !defined(PNG_IMPEXP) + +# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol +# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol + + /* Borland/Microsoft */ +# if defined(_MSC_VER) || defined(__BORLANDC__) +# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) +# define PNG_EXPORT PNG_EXPORT_TYPE1 +# else +# define PNG_EXPORT PNG_EXPORT_TYPE2 +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __export +# else +# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in + VC++ */ +# endif /* Exists in Borland C++ for + C++ classes (== huge) */ +# endif +# endif + +# if !defined(PNG_IMPEXP) +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __declspec(dllexport) +# else +# define PNG_IMPEXP __declspec(dllimport) +# endif +# endif +# endif /* PNG_IMPEXP */ +#else /* !(DLL || non-cygwin WINDOWS) */ +# if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__) +# define PNGAPI _System +# define PNG_IMPEXP +# else +# if 0 /* ... other platforms, with other meanings */ +# else +# define PNGAPI +# define PNG_IMPEXP +# endif +# endif +#endif +#endif + +#ifndef PNGAPI +# define PNGAPI +#endif +#ifndef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +#ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type +# endif +#endif + +/* User may want to use these so they are not in PNG_INTERNAL. Any library + * functions that are passed far data must be model independent. + */ + +#ifndef PNG_ABORT +# define PNG_ABORT() abort() +#endif + +#ifdef PNG_SETJMP_SUPPORTED +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) +#endif + +#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ +/* use this to make far-to-near assignments */ +# define CHECK 1 +# define NOCHECK 0 +# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) +# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) +# define png_strcpy _fstrcpy +# define png_strlen _fstrlen +# define png_memcmp _fmemcmp /* SJT: added */ +# define png_memcpy _fmemcpy +# define png_memset _fmemset +#else /* use the usual functions */ +# define CVT_PTR(ptr) (ptr) +# define CVT_PTR_NOCHECK(ptr) (ptr) +# define png_strcpy strcpy +# define png_strlen strlen +# define png_memcmp memcmp /* SJT: added */ +# define png_memcpy memcpy +# define png_memset memset +#endif +/* End of memory model independent support */ + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536 +#endif + +#ifdef PNG_READ_SUPPORTED +/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ +#if defined(PNG_INTERNAL) + +/* These are the default thresholds before the MMX code kicks in; if either + * rowbytes or bitdepth is below the threshold, plain C code is used. These + * can be overridden at runtime via the png_set_mmx_thresholds() call in + * libpng 1.2.0 and later. The values below were chosen by Intel. + */ + +#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT +# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ +#endif +#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT +# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ +#endif + +/* Set this in the makefile for VC++ on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGVCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif + +/* Set this in the makefile for gcc/as on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGGCCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif +/* - see pnggccrd.c for info about what is currently enabled */ + +#endif /* PNG_INTERNAL */ +#endif /* PNG_READ_SUPPORTED */ + +#endif /* PNGCONF_H */ + diff --git a/src/libs/pdflib/libs/png/pngerror.c b/src/libs/pdflib/libs/png/pngerror.c new file mode 100644 index 0000000000..4dd1b3ec6e --- /dev/null +++ b/src/libs/pdflib/libs/png/pngerror.c @@ -0,0 +1,292 @@ +/* PDFlib GmbH cvsid: $Id: pngerror.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngerror.c - stub functions for i/o and memory allocation + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file provides a location for all error handling. Users who + * need special error handling are expected to write replacement functions + * and use png_set_error_fn() to use those functions. See the instructions + * at each function. + */ + +#define PNG_INTERNAL +#include "png.h" + +static void /* PRIVATE */ +png_default_error PNGARG((png_structp png_ptr, + png_const_charp error_message)); +static void /* PRIVATE */ +png_default_warning PNGARG((png_structp png_ptr, + png_const_charp warning_message)); + +/* This function is called whenever there is a fatal error. This function + * should not be changed. If there is a need to handle errors differently, + * you should supply a replacement error function and use png_set_error_fn() + * to replace the error function at run-time. + */ +void PNGAPI +png_error(png_structp png_ptr, png_const_charp error_message) +{ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + char msg[16]; + if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) + { + int offset = 0; + if (*error_message == '#') + { + for (offset=1; offset<15; offset++) + if (*(error_message+offset) == ' ') + break; + if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) + { + int i; + for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) + { + msg[0]='0'; + msg[1]='\0'; + error_message=msg; + } + } + } +#endif + if (png_ptr->error_fn != NULL) + (*(png_ptr->error_fn))(png_ptr, error_message); + + /* if the following returns or doesn't exist, use the default function, + which will not return */ + png_default_error(png_ptr, error_message); +} + +/* This function is called whenever there is a non-fatal error. This function + * should not be changed. If there is a need to handle warnings differently, + * you should supply a replacement warning function and use + * png_set_error_fn() to replace the warning function at run-time. + */ +void PNGAPI +png_warning(png_structp png_ptr, png_const_charp warning_message) +{ + int offset = 0; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) +#endif + { + if (*warning_message == '#') + { + for (offset=1; offset<15; offset++) + if (*(warning_message+offset) == ' ') + break; + } + } + if (png_ptr->warning_fn != NULL) + (*(png_ptr->warning_fn))(png_ptr, + (png_const_charp)(warning_message+offset)); + else + png_default_warning(png_ptr, (png_const_charp)(warning_message+offset)); +} + +/* These utilities are used internally to build an error message that relates + * to the current chunk. The chunk name comes from png_ptr->chunk_name, + * this is used to prefix the message. The message is limited in length + * to 63 bytes, the name characters are output as hex digits wrapped in [] + * if the character is invalid. + */ +#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97)) +static PNG_CONST char png_digit[16] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', + 'F' }; + +static void /* PRIVATE */ +png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp + error_message) +{ + int iout = 0, iin = 0; + + while (iin < 4) + { + int c = png_ptr->chunk_name[iin++]; + if (isnonalpha(c)) + { + buffer[iout++] = '['; + buffer[iout++] = png_digit[(c & 0xf0) >> 4]; + buffer[iout++] = png_digit[c & 0x0f]; + buffer[iout++] = ']'; + } + else + { + buffer[iout++] = (png_byte)c; + } + } + + if (error_message == NULL) + buffer[iout] = 0; + else + { + buffer[iout++] = ':'; + buffer[iout++] = ' '; + png_memcpy(buffer+iout, error_message, 64); + buffer[iout+63] = 0; + } +} + +void PNGAPI +png_chunk_error(png_structp png_ptr, png_const_charp error_message) +{ + char msg[18+64]; + png_format_buffer(png_ptr, msg, error_message); + png_error(png_ptr, msg); +} + +void PNGAPI +png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) +{ + char msg[18+64]; + png_format_buffer(png_ptr, msg, warning_message); + png_warning(png_ptr, msg); +} + +/* This is the default error handling function. Note that replacements for + * this function MUST NOT RETURN, or the program will likely crash. This + * function is used by default, or if the program supplies NULL for the + * error function pointer in png_set_error_fn(). + */ +static void /* PRIVATE */ +png_default_error(png_structp png_ptr, png_const_charp error_message) +{ +#ifndef PNG_NO_CONSOLE_IO +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + if (*error_message == '#') + { + int offset; + char error_number[16]; + for (offset=0; offset<15; offset++) + { + error_number[offset] = *(error_message+offset+1); + if (*(error_message+offset) == ' ') + break; + } + if((offset > 1) && (offset < 15)) + { + error_number[offset-1]='\0'; + fprintf(stderr, "libpng error no. %s: %s\n", error_number, + error_message+offset); + } + else + fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); + } + else +#endif + fprintf(stderr, "libpng error: %s\n", error_message); +#else + if (error_message) + /* make compiler happy */ ; +#endif + +#ifdef PNG_SETJMP_SUPPORTED +# ifdef USE_FAR_KEYWORD + { + jmp_buf jmpbuf; + png_memcpy(jmpbuf,png_ptr->jmpbuf,sizeof(jmp_buf)); + longjmp(jmpbuf, 1); + } +# else + longjmp(png_ptr->jmpbuf, 1); +# endif +#else + if (png_ptr) + /* make compiler happy */ ; + PNG_ABORT(); +#endif +} + +/* This function is called when there is a warning, but the library thinks + * it can continue anyway. Replacement functions don't have to do anything + * here if you don't want them to. In the default configuration, png_ptr is + * not used, but it is passed in case it may be useful. + */ +static void /* PRIVATE */ +png_default_warning(png_structp png_ptr, png_const_charp warning_message) +{ +#ifndef PNG_NO_CONSOLE_IO +# ifdef PNG_ERROR_NUMBERS_SUPPORTED + if (*warning_message == '#') + { + int offset; + char warning_number[16]; + for (offset=0; offset<15; offset++) + { + warning_number[offset]=*(warning_message+offset+1); + if (*(warning_message+offset) == ' ') + break; + } + if((offset > 1) && (offset < 15)) + { + warning_number[offset-1]='\0'; + fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, + warning_message+offset); + } + else + fprintf(stderr, "libpng warning: %s\n", warning_message); + } + else +# endif + fprintf(stderr, "libpng warning: %s\n", warning_message); +#else + if (warning_message) + /* appease compiler */ ; +#endif + if (png_ptr) + return; +} + +/* This function is called when the application wants to use another method + * of handling errors and warnings. Note that the error function MUST NOT + * return to the calling routine or serious problems will occur. The return + * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) + */ +void PNGAPI +png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warning_fn) +{ + png_ptr->error_ptr = error_ptr; + png_ptr->error_fn = error_fn; + png_ptr->warning_fn = warning_fn; +} + + +/* This function returns a pointer to the error_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy and png_read_destroy are called. + */ +png_voidp PNGAPI +png_get_error_ptr(png_structp png_ptr) +{ + return ((png_voidp)png_ptr->error_ptr); +} + + +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +void PNGAPI +png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) +{ + if(png_ptr != NULL) + { + png_ptr->flags &= + ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); + } +} +#endif diff --git a/src/libs/pdflib/libs/png/pngget.c b/src/libs/pdflib/libs/png/pngget.c new file mode 100644 index 0000000000..e8e6191434 --- /dev/null +++ b/src/libs/pdflib/libs/png/pngget.c @@ -0,0 +1,928 @@ +/* PDFlib GmbH cvsid: $Id: pngget.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngget.c - retrieval of values from info struct + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +#define PNG_INTERNAL +#include "png.h" + +png_uint_32 PNGAPI +png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->valid & flag); + else + return(0); +} + +png_uint_32 PNGAPI +png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->rowbytes); + else + return(0); +} + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +png_bytepp PNGAPI +png_get_rows(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->row_pointers); + else + return(0); +} +#endif + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* easy access to info, added in libpng-0.99 */ +png_uint_32 PNGAPI +png_get_image_width(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->width; + } + return (0); +} + +png_uint_32 PNGAPI +png_get_image_height(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->height; + } + return (0); +} + +png_byte PNGAPI +png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->bit_depth; + } + return (0); +} + +png_byte PNGAPI +png_get_color_type(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->color_type; + } + return (0); +} + +png_byte PNGAPI +png_get_filter_type(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->filter_type; + } + return (0); +} + +png_byte PNGAPI +png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->interlace_type; + } + return (0); +} + +png_byte PNGAPI +png_get_compression_type(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + { + return info_ptr->compression_type; + } + return (0); +} + +png_uint_32 PNGAPI +png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + return (0); + else return (info_ptr->x_pixels_per_unit); + } +#else + return (0); +#endif + return (0); +} + +png_uint_32 PNGAPI +png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + return (0); + else return (info_ptr->y_pixels_per_unit); + } +#else + return (0); +#endif + return (0); +} + +png_uint_32 PNGAPI +png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); + if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || + info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) + return (0); + else return (info_ptr->x_pixels_per_unit); + } +#else + return (0); +#endif + return (0); +} + +#ifdef PNG_FLOATING_POINT_SUPPORTED +float PNGAPI +png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) + { + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); + if (info_ptr->x_pixels_per_unit == 0) + return ((float)0.0); + else + return ((float)((float)info_ptr->y_pixels_per_unit + /(float)info_ptr->x_pixels_per_unit)); + } +#else + return (0.0); +#endif + return ((float)0.0); +} +#endif + +png_int_32 PNGAPI +png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + return (0); + else return (info_ptr->x_offset); + } +#else + return (0); +#endif + return (0); +} + +png_int_32 PNGAPI +png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + return (0); + else return (info_ptr->y_offset); + } +#else + return (0); +#endif + return (0); +} + +png_int_32 PNGAPI +png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + return (0); + else return (info_ptr->x_offset); + } +#else + return (0); +#endif + return (0); +} + +png_int_32 PNGAPI +png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) +#if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) + { + png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); + if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + return (0); + else return (info_ptr->y_offset); + } +#else + return (0); +#endif + return (0); +} + +#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) +png_uint_32 PNGAPI +png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +{ + return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); +} + +png_uint_32 PNGAPI +png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +{ + return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); +} + +png_uint_32 PNGAPI +png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) +{ + return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) + *.0254 +.5)); +} + +float PNGAPI +png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) +{ + return ((float)png_get_x_offset_microns(png_ptr, info_ptr) + *.00003937); +} + +float PNGAPI +png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) +{ + return ((float)png_get_y_offset_microns(png_ptr, info_ptr) + *.00003937); +} + +#if defined(PNG_pHYs_SUPPORTED) +png_uint_32 PNGAPI +png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +{ + png_uint_32 retval = 0; + + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) + { + png_debug1(1, "in %s retrieval function\n", "pHYs"); + if (res_x != NULL) + { + *res_x = info_ptr->x_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + if (res_y != NULL) + { + *res_y = info_ptr->y_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + if (unit_type != NULL) + { + *unit_type = (int)info_ptr->phys_unit_type; + retval |= PNG_INFO_pHYs; + if(*unit_type == 1) + { + if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); + if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); + } + } + } + return (retval); +} +#endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ + +/* png_get_channels really belongs in here, too, but it's been around longer */ + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +png_byte PNGAPI +png_get_channels(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->channels); + else + return (0); +} + +png_bytep PNGAPI +png_get_signature(png_structp png_ptr, png_infop info_ptr) +{ + if (png_ptr != NULL && info_ptr != NULL) + return(info_ptr->signature); + else + return (NULL); +} + +#if defined(PNG_bKGD_SUPPORTED) +png_uint_32 PNGAPI +png_get_bKGD(png_structp png_ptr, png_infop info_ptr, + png_color_16p *background) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) + && background != NULL) + { + png_debug1(1, "in %s retrieval function\n", "bKGD"); + *background = &(info_ptr->background); + return (PNG_INFO_bKGD); + } + return (0); +} +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cHRM(png_structp png_ptr, png_infop info_ptr, + double *white_x, double *white_y, double *red_x, double *red_y, + double *green_x, double *green_y, double *blue_x, double *blue_y) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) + { + png_debug1(1, "in %s retrieval function\n", "cHRM"); + if (white_x != NULL) + *white_x = (double)info_ptr->x_white; + if (white_y != NULL) + *white_y = (double)info_ptr->y_white; + if (red_x != NULL) + *red_x = (double)info_ptr->x_red; + if (red_y != NULL) + *red_y = (double)info_ptr->y_red; + if (green_x != NULL) + *green_x = (double)info_ptr->x_green; + if (green_y != NULL) + *green_y = (double)info_ptr->y_green; + if (blue_x != NULL) + *blue_x = (double)info_ptr->x_blue; + if (blue_y != NULL) + *blue_y = (double)info_ptr->y_blue; + return (PNG_INFO_cHRM); + } + return (0); +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, + png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, + png_fixed_point *blue_x, png_fixed_point *blue_y) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) + { + png_debug1(1, "in %s retrieval function\n", "cHRM"); + if (white_x != NULL) + *white_x = info_ptr->int_x_white; + if (white_y != NULL) + *white_y = info_ptr->int_y_white; + if (red_x != NULL) + *red_x = info_ptr->int_x_red; + if (red_y != NULL) + *red_y = info_ptr->int_y_red; + if (green_x != NULL) + *green_x = info_ptr->int_x_green; + if (green_y != NULL) + *green_y = info_ptr->int_y_green; + if (blue_x != NULL) + *blue_x = info_ptr->int_x_blue; + if (blue_y != NULL) + *blue_y = info_ptr->int_y_blue; + return (PNG_INFO_cHRM); + } + return (0); +} +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) + && file_gamma != NULL) + { + png_debug1(1, "in %s retrieval function\n", "gAMA"); + *file_gamma = (double)info_ptr->gamma; + return (PNG_INFO_gAMA); + } + return (0); +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point *int_file_gamma) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) + && int_file_gamma != NULL) + { + png_debug1(1, "in %s retrieval function\n", "gAMA"); + *int_file_gamma = info_ptr->int_gamma; + return (PNG_INFO_gAMA); + } + return (0); +} +#endif +#endif + +#if defined(PNG_sRGB_SUPPORTED) +png_uint_32 PNGAPI +png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) + && file_srgb_intent != NULL) + { + png_debug1(1, "in %s retrieval function\n", "sRGB"); + *file_srgb_intent = (int)info_ptr->srgb_intent; + return (PNG_INFO_sRGB); + } + return (0); +} +#endif + +#if defined(PNG_iCCP_SUPPORTED) +png_uint_32 PNGAPI +png_get_iCCP(png_structp png_ptr, png_infop info_ptr, + png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) + && name != NULL && profile != NULL && proflen != NULL) + { + png_debug1(1, "in %s retrieval function\n", "iCCP"); + *name = info_ptr->iccp_name; + *profile = info_ptr->iccp_profile; + /* compression_type is a dummy so the API won't have to change + if we introduce multiple compression types later. */ + *proflen = (int)info_ptr->iccp_proflen; + *compression_type = (int)info_ptr->iccp_compression; + return (PNG_INFO_iCCP); + } + return (0); +} +#endif + +#if defined(PNG_sPLT_SUPPORTED) +png_uint_32 PNGAPI +png_get_sPLT(png_structp png_ptr, png_infop info_ptr, + png_sPLT_tpp spalettes) +{ + if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) + *spalettes = info_ptr->splt_palettes; + return ((png_uint_32)info_ptr->splt_palettes_num); +} +#endif + +#if defined(PNG_hIST_SUPPORTED) +png_uint_32 PNGAPI +png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) + && hist != NULL) + { + png_debug1(1, "in %s retrieval function\n", "hIST"); + *hist = info_ptr->hist; + return (PNG_INFO_hIST); + } + return (0); +} +#endif + +png_uint_32 PNGAPI +png_get_IHDR(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *width, png_uint_32 *height, int *bit_depth, + int *color_type, int *interlace_type, int *compression_type, + int *filter_type) + +{ + if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && + bit_depth != NULL && color_type != NULL) + { + int pixel_depth, channels; + png_uint_32 rowbytes_per_pixel; + + png_debug1(1, "in %s retrieval function\n", "IHDR"); + *width = info_ptr->width; + *height = info_ptr->height; + *bit_depth = info_ptr->bit_depth; + if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) + png_error(png_ptr, "Invalid bit depth"); + *color_type = info_ptr->color_type; + if (info_ptr->color_type > 6) + png_error(png_ptr, "Invalid color type"); + if (compression_type != NULL) + *compression_type = info_ptr->compression_type; + if (filter_type != NULL) + *filter_type = info_ptr->filter_type; + if (interlace_type != NULL) + *interlace_type = info_ptr->interlace_type; + + /* check for potential overflow of rowbytes */ + if (*color_type == PNG_COLOR_TYPE_PALETTE) + channels = 1; + else if (*color_type & PNG_COLOR_MASK_COLOR) + channels = 3; + else + channels = 1; + if (*color_type & PNG_COLOR_MASK_ALPHA) + channels++; + pixel_depth = *bit_depth * channels; + rowbytes_per_pixel = (pixel_depth + 7) >> 3; + if (width == 0 || *width > PNG_MAX_UINT) + png_error(png_ptr, "Invalid image width"); + if (height == 0 || *height > PNG_MAX_UINT) + png_error(png_ptr, "Invalid image height"); + if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64) + { + png_error(png_ptr, + "Width too large for libpng to process image data."); + } + return (1); + } + return (0); +} + +#if defined(PNG_oFFs_SUPPORTED) +png_uint_32 PNGAPI +png_get_oFFs(png_structp png_ptr, png_infop info_ptr, + png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) + && offset_x != NULL && offset_y != NULL && unit_type != NULL) + { + png_debug1(1, "in %s retrieval function\n", "oFFs"); + *offset_x = info_ptr->x_offset; + *offset_y = info_ptr->y_offset; + *unit_type = (int)info_ptr->offset_unit_type; + return (PNG_INFO_oFFs); + } + return (0); +} +#endif + +#if defined(PNG_pCAL_SUPPORTED) +png_uint_32 PNGAPI +png_get_pCAL(png_structp png_ptr, png_infop info_ptr, + png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, + png_charp *units, png_charpp *params) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) + && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && + nparams != NULL && units != NULL && params != NULL) + { + png_debug1(1, "in %s retrieval function\n", "pCAL"); + *purpose = info_ptr->pcal_purpose; + *X0 = info_ptr->pcal_X0; + *X1 = info_ptr->pcal_X1; + *type = (int)info_ptr->pcal_type; + *nparams = (int)info_ptr->pcal_nparams; + *units = info_ptr->pcal_units; + *params = info_ptr->pcal_params; + return (PNG_INFO_pCAL); + } + return (0); +} +#endif + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_sCAL(png_structp png_ptr, png_infop info_ptr, + int *unit, double *width, double *height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL)) + { + *unit = info_ptr->scal_unit; + *width = info_ptr->scal_pixel_width; + *height = info_ptr->scal_pixel_height; + return (PNG_INFO_sCAL); + } + return(0); +} +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, + int *unit, png_charpp width, png_charpp height) +{ + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_sCAL)) + { + *unit = info_ptr->scal_unit; + *width = info_ptr->scal_s_width; + *height = info_ptr->scal_s_height; + return (PNG_INFO_sCAL); + } + return(0); +} +#endif +#endif +#endif + +#if defined(PNG_pHYs_SUPPORTED) +png_uint_32 PNGAPI +png_get_pHYs(png_structp png_ptr, png_infop info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) +{ + png_uint_32 retval = 0; + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs)) + { + png_debug1(1, "in %s retrieval function\n", "pHYs"); + if (res_x != NULL) + { + *res_x = info_ptr->x_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + if (res_y != NULL) + { + *res_y = info_ptr->y_pixels_per_unit; + retval |= PNG_INFO_pHYs; + } + if (unit_type != NULL) + { + *unit_type = (int)info_ptr->phys_unit_type; + retval |= PNG_INFO_pHYs; + } + } + return (retval); +} +#endif + +png_uint_32 PNGAPI +png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, + int *num_palette) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) + && palette != NULL) + { + png_debug1(1, "in %s retrieval function\n", "PLTE"); + *palette = info_ptr->palette; + *num_palette = info_ptr->num_palette; + png_debug1(3, "num_palette = %d\n", *num_palette); + return (PNG_INFO_PLTE); + } + return (0); +} + +#if defined(PNG_sBIT_SUPPORTED) +png_uint_32 PNGAPI +png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) + && sig_bit != NULL) + { + png_debug1(1, "in %s retrieval function\n", "sBIT"); + *sig_bit = &(info_ptr->sig_bit); + return (PNG_INFO_sBIT); + } + return (0); +} +#endif + +#if defined(PNG_TEXT_SUPPORTED) +png_uint_32 PNGAPI +png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, + int *num_text) +{ + if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) + { + png_debug1(1, "in %s retrieval function\n", + (png_ptr->chunk_name[0] == '\0' ? "text" + : (png_const_charp)png_ptr->chunk_name)); + if (text_ptr != NULL) + *text_ptr = info_ptr->text; + if (num_text != NULL) + *num_text = info_ptr->num_text; + return ((png_uint_32)info_ptr->num_text); + } + if (num_text != NULL) + *num_text = 0; + return(0); +} +#endif + +#if defined(PNG_tIME_SUPPORTED) +png_uint_32 PNGAPI +png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) +{ + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) + && mod_time != NULL) + { + png_debug1(1, "in %s retrieval function\n", "tIME"); + *mod_time = &(info_ptr->mod_time); + return (PNG_INFO_tIME); + } + return (0); +} +#endif + +#if defined(PNG_tRNS_SUPPORTED) +png_uint_32 PNGAPI +png_get_tRNS(png_structp png_ptr, png_infop info_ptr, + png_bytep *trans, int *num_trans, png_color_16p *trans_values) +{ + png_uint_32 retval = 0; + if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) + { + png_debug1(1, "in %s retrieval function\n", "tRNS"); + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (trans != NULL) + { + *trans = info_ptr->trans; + retval |= PNG_INFO_tRNS; + } + if (trans_values != NULL) + *trans_values = &(info_ptr->trans_values); + } + else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ + { + if (trans_values != NULL) + { + *trans_values = &(info_ptr->trans_values); + retval |= PNG_INFO_tRNS; + } + if(trans != NULL) + *trans = NULL; + } + if(num_trans != NULL) + { + *num_trans = info_ptr->num_trans; + retval |= PNG_INFO_tRNS; + } + } + return (retval); +} +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +png_uint_32 PNGAPI +png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, + png_unknown_chunkpp unknowns) +{ + if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) + *unknowns = info_ptr->unknown_chunks; + return ((png_uint_32)info_ptr->unknown_chunks_num); +} +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +png_byte PNGAPI +png_get_rgb_to_gray_status (png_structp png_ptr) +{ + return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); +} +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) +png_voidp PNGAPI +png_get_user_chunk_ptr(png_structp png_ptr) +{ + return (png_ptr? png_ptr->user_chunk_ptr : NULL); +} +#endif + + +png_uint_32 PNGAPI +png_get_compression_buffer_size(png_structp png_ptr) +{ + return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); +} + + +#ifndef PNG_1_0_X +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +/* this function was added to libpng 1.2.0 and should exist by default */ +png_uint_32 PNGAPI +png_get_asm_flags (png_structp png_ptr) +{ + return (png_uint_32)(png_ptr? png_ptr->asm_flags : 0L); +} + +/* this function was added to libpng 1.2.0 and should exist by default */ +png_uint_32 PNGAPI +png_get_asm_flagmask (int flag_select) +{ + png_uint_32 settable_asm_flags = 0; + + if (flag_select & PNG_SELECT_READ) + settable_asm_flags |= + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | + PNG_ASM_FLAG_MMX_READ_INTERLACE | + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; + /* no non-MMX flags yet */ + +#if 0 + /* GRR: no write-flags yet, either, but someday... */ + if (flag_select & PNG_SELECT_WRITE) + settable_asm_flags |= + PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; +#endif /* 0 */ + + return settable_asm_flags; /* _theoretically_ settable capabilities only */ +} +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ +/* this function was added to libpng 1.2.0 */ +png_uint_32 PNGAPI +png_get_mmx_flagmask (int flag_select, int *compilerID) +{ + png_uint_32 settable_mmx_flags = 0; + + if (flag_select & PNG_SELECT_READ) + settable_mmx_flags |= + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | + PNG_ASM_FLAG_MMX_READ_INTERLACE | + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ; +#if 0 + /* GRR: no MMX write support yet, but someday... */ + if (flag_select & PNG_SELECT_WRITE) + settable_mmx_flags |= + PNG_ASM_FLAG_MMX_WRITE_ [whatever] ; +#endif /* 0 */ + + if (compilerID != NULL) { +#ifdef PNG_USE_PNGVCRD + *compilerID = 1; /* MSVC */ +#else +#ifdef PNG_USE_PNGGCCRD + *compilerID = 2; /* gcc/gas */ +#else + *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ +#endif +#endif + } + + return settable_mmx_flags; /* _theoretically_ settable capabilities only */ +} + +/* this function was added to libpng 1.2.0 */ +png_byte PNGAPI +png_get_mmx_bitdepth_threshold (png_structp png_ptr) +{ + return (png_byte)(png_ptr? png_ptr->mmx_bitdepth_threshold : 0); +} + +/* this function was added to libpng 1.2.0 */ +png_uint_32 PNGAPI +png_get_mmx_rowbytes_threshold (png_structp png_ptr) +{ + return (png_uint_32)(png_ptr? png_ptr->mmx_rowbytes_threshold : 0L); +} +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ +#endif /* PNG_1_0_X */ diff --git a/src/libs/pdflib/libs/png/pngmem.c b/src/libs/pdflib/libs/png/pngmem.c new file mode 100644 index 0000000000..e3cb407cdf --- /dev/null +++ b/src/libs/pdflib/libs/png/pngmem.c @@ -0,0 +1,567 @@ +/* PDFlib GmbH cvsid: $Id: pngmem.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngmem.c - stub functions for memory allocation + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file provides a location for all memory allocation. Users who + * need special memory handling are expected to supply replacement + * functions for png_malloc() and png_free(), and to use + * png_create_read_struct_2() and png_create_write_struct_2() to + * identify the replacement functions. + */ + +#define PNG_INTERNAL +#include "png.h" + +/* Borland DOS special memory handler */ +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* if you change this, be sure to change the one in png.h also */ + +/* Allocate memory for a png_struct. The malloc and memset can be replaced + by a single call to calloc() if this is thought to improve performance. */ +png_voidp /* PRIVATE */ +png_create_struct(int type) +{ +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); +} + +/* Alternate version of png_create_struct, for use with user-defined malloc. */ +png_voidp /* PRIVATE */ +png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + png_size_t size; + png_voidp struct_ptr; + + if (type == PNG_STRUCT_INFO) + size = sizeof(png_info); + else if (type == PNG_STRUCT_PNG) + size = sizeof(png_struct); + else + return (png_get_copyright()); + +#ifdef PNG_USER_MEM_SUPPORTED + if(malloc_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); + } + else +#endif /* PNG_USER_MEM_SUPPORTED */ + struct_ptr = (png_voidp)farmalloc(size)); + if (struct_ptr != NULL) + png_memset(struct_ptr, 0, size); + return (struct_ptr); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct(png_voidp struct_ptr) +{ +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, + png_voidp mem_ptr) +{ +#endif + if (struct_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + if(free_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + (*(free_fn))(png_ptr, struct_ptr); + return; + } +#endif /* PNG_USER_MEM_SUPPORTED */ + farfree (struct_ptr); + } +} + +/* Allocate memory. For reasonable files, size should never exceed + * 64K. However, zlib may allocate more then 64K if you don't tell + * it not to. See zconf.h and png.h for more information. zlib does + * need to allocate exactly 64K, so whatever you call here must + * have the ability to do that. + * + * Borland seems to have a problem in DOS mode for exactly 64K. + * It gives you a segment with an offset of 8 (perhaps to store its + * memory stuff). zlib doesn't like this at all, so we have to + * detect and deal with it. This code should not be needed in + * Windows or OS/2 modes, and only in 16 bit mode. This code has + * been updated by Alexander Lehmann for version 0.89 to waste less + * memory. + * + * Note that we can't use png_size_t for the "size" declaration, + * since on some systems a png_size_t is a 16-bit quantity, and as a + * result, we would be truncating potentially larger memory requests + * (which should cause a fatal error) and introducing major problems. + */ + +png_voidp PNGAPI +png_malloc(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; + + if (png_ptr == NULL || size == 0) + return (NULL); + +#ifdef PNG_USER_MEM_SUPPORTED + if(png_ptr->malloc_fn != NULL) + { + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of memory!"); + return (ret); + } + else + return png_malloc_default(png_ptr, size); +} + +png_voidp PNGAPI +png_malloc_default(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; +#endif /* PNG_USER_MEM_SUPPORTED */ + +#ifdef PNG_MAX_MALLOC_64K + if (size > (png_uint_32)65536L) + png_error(png_ptr, "Cannot Allocate > 64K"); +#endif + + if (size == (png_uint_32)65536L) + { + if (png_ptr->offset_table == NULL) + { + /* try to see if we need to do any of this fancy stuff */ + ret = farmalloc(size); + if (ret == NULL || ((png_size_t)ret & 0xffff)) + { + int num_blocks; + png_uint_32 total_size; + png_bytep table; + int i; + png_byte huge * hptr; + + if (ret != NULL) + { + farfree(ret); + ret = NULL; + } + + if(png_ptr->zlib_window_bits > 14) + num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); + else + num_blocks = 1; + if (png_ptr->zlib_mem_level >= 7) + num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); + else + num_blocks++; + + total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; + + table = farmalloc(total_size); + + if (table == NULL) + { + if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ + else + png_warning(png_ptr, "Out Of Memory."); + return (NULL); + } + + if ((png_size_t)table & 0xfff0) + { + if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, + "Farmalloc didn't return normalized pointer"); + else + png_warning(png_ptr, + "Farmalloc didn't return normalized pointer"); + return (NULL); + } + + png_ptr->offset_table = table; + png_ptr->offset_table_ptr = farmalloc(num_blocks * + sizeof (png_bytep)); + + if (png_ptr->offset_table_ptr == NULL) + { + if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ + else + png_warning(png_ptr, "Out Of memory."); + return (NULL); + } + + hptr = (png_byte huge *)table; + if ((png_size_t)hptr & 0xf) + { + hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); + hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ + } + for (i = 0; i < num_blocks; i++) + { + png_ptr->offset_table_ptr[i] = (png_bytep)hptr; + hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ + } + + png_ptr->offset_table_number = num_blocks; + png_ptr->offset_table_count = 0; + png_ptr->offset_table_count_free = 0; + } + } + + if (png_ptr->offset_table_count >= png_ptr->offset_table_number) + { + if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ + else + png_warning(png_ptr, "Out of Memory."); + return (NULL); + } + + ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; + } + else + ret = farmalloc(size); + + if (ret == NULL) + { + if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ + else + png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ + } + + return (ret); +} + +/* free a pointer allocated by png_malloc(). In the default + configuration, png_ptr is not used, but is passed in case it + is needed. If ptr is NULL, return without taking any action. */ +void PNGAPI +png_free(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL || ptr == NULL) + return; + +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr->free_fn != NULL) + { + (*(png_ptr->free_fn))(png_ptr, ptr); + return; + } + else png_free_default(png_ptr, ptr); +} + +void PNGAPI +png_free_default(png_structp png_ptr, png_voidp ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + + if (png_ptr->offset_table != NULL) + { + int i; + + for (i = 0; i < png_ptr->offset_table_count; i++) + { + if (ptr == png_ptr->offset_table_ptr[i]) + { + ptr = NULL; + png_ptr->offset_table_count_free++; + break; + } + } + if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) + { + farfree(png_ptr->offset_table); + farfree(png_ptr->offset_table_ptr); + png_ptr->offset_table = NULL; + png_ptr->offset_table_ptr = NULL; + } + } + + if (ptr != NULL) + { + farfree(ptr); + } +} + +#else /* Not the Borland DOS special memory handler */ + +/* Allocate memory for a png_struct or a png_info. The malloc and + memset can be replaced by a single call to calloc() if this is thought + to improve performance noticably. */ +png_voidp /* PRIVATE */ +png_create_struct(int type) +{ +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); +} + +/* Allocate memory for a png_struct or a png_info. The malloc and + memset can be replaced by a single call to calloc() if this is thought + to improve performance noticably. */ +png_voidp /* PRIVATE */ +png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + png_size_t size; + png_voidp struct_ptr; + + if (type == PNG_STRUCT_INFO) + size = sizeof(png_info); + else if (type == PNG_STRUCT_PNG) + size = sizeof(png_struct); + else + return (NULL); + +#ifdef PNG_USER_MEM_SUPPORTED + if(malloc_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + struct_ptr = (*(malloc_fn))(png_ptr, size); + if (struct_ptr != NULL) + png_memset(struct_ptr, 0, size); + return (struct_ptr); + } +#endif /* PNG_USER_MEM_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(__FLAT__) + if ((struct_ptr = (png_voidp)farmalloc(size)) != NULL) +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + if ((struct_ptr = (png_voidp)halloc(size,1)) != NULL) +# else + if ((struct_ptr = (png_voidp)malloc(size)) != NULL) +# endif +#endif + { + png_memset(struct_ptr, 0, size); + } + + return (struct_ptr); +} + + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct(png_voidp struct_ptr) +{ +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); +} + +/* Free memory allocated by a png_create_struct() call */ +void /* PRIVATE */ +png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, + png_voidp mem_ptr) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + if (struct_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + if(free_fn != NULL) + { + png_struct dummy_struct; + png_structp png_ptr = &dummy_struct; + png_ptr->mem_ptr=mem_ptr; + (*(free_fn))(png_ptr, struct_ptr); + return; + } +#endif /* PNG_USER_MEM_SUPPORTED */ +#if defined(__TURBOC__) && !defined(__FLAT__) + farfree(struct_ptr); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + hfree(struct_ptr); +# else + free(struct_ptr); +# endif +#endif + } +} + +/* Allocate memory. For reasonable files, size should never exceed + 64K. However, zlib may allocate more then 64K if you don't tell + it not to. See zconf.h and png.h for more information. zlib does + need to allocate exactly 64K, so whatever you call here must + have the ability to do that. */ + +png_voidp PNGAPI +png_malloc(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; + + if (png_ptr == NULL || size == 0) + return (NULL); + +#ifdef PNG_USER_MEM_SUPPORTED + if(png_ptr->malloc_fn != NULL) + { + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory!"); + return (ret); + } + else + return (png_malloc_default(png_ptr, size)); +} + +png_voidp PNGAPI +png_malloc_default(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ret; +#endif /* PNG_USER_MEM_SUPPORTED */ + +#ifdef PNG_MAX_MALLOC_64K + if (size > (png_uint_32)65536L) + { + if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Cannot Allocate > 64K"); + else + return NULL; + } +#endif + +#if defined(__TURBOC__) && !defined(__FLAT__) + ret = farmalloc(size); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + ret = halloc(size, 1); +# else + ret = malloc((size_t)size); +# endif +#endif + + if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) + png_error(png_ptr, "Out of Memory"); + + return (ret); +} + +/* Free a pointer allocated by png_malloc(). If ptr is NULL, return + without taking any action. */ +void PNGAPI +png_free(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL || ptr == NULL) + return; + +#ifdef PNG_USER_MEM_SUPPORTED + if (png_ptr->free_fn != NULL) + { + (*(png_ptr->free_fn))(png_ptr, ptr); + return; + } + else png_free_default(png_ptr, ptr); +} +void PNGAPI +png_free_default(png_structp png_ptr, png_voidp ptr) +{ + if (png_ptr == NULL || ptr == NULL) + return; + +#endif /* PNG_USER_MEM_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(__FLAT__) + farfree(ptr); +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + hfree(ptr); +# else + free(ptr); +# endif +#endif +} + +#endif /* Not Borland DOS special memory handler */ + +#if defined(PNG_1_0_X) +# define png_malloc_warn png_malloc +#else +/* This function was added at libpng version 1.2.3. The png_malloc_warn() + * function will issue a png_warning and return NULL instead of issuing a + * png_error, if it fails to allocate the requested memory. + */ +png_voidp PNGAPI +png_malloc_warn(png_structp png_ptr, png_uint_32 size) +{ + png_voidp ptr; + png_uint_32 save_flags=png_ptr->flags; + + png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; + ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); + png_ptr->flags=save_flags; + return(ptr); +} +#endif + +png_voidp PNGAPI +png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, + png_uint_32 length) +{ + png_size_t size; + + size = (png_size_t)length; + if ((png_uint_32)size != length) + png_error(png_ptr,"Overflow in png_memcpy_check."); + + return(png_memcpy (s1, s2, size)); +} + +png_voidp PNGAPI +png_memset_check (png_structp png_ptr, png_voidp s1, int value, + png_uint_32 length) +{ + png_size_t size; + + size = (png_size_t)length; + if ((png_uint_32)size != length) + png_error(png_ptr,"Overflow in png_memset_check."); + + return (png_memset (s1, value, size)); + +} + +#ifdef PNG_USER_MEM_SUPPORTED +/* This function is called when the application wants to use another method + * of allocating and freeing memory. + */ +void PNGAPI +png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr + malloc_fn, png_free_ptr free_fn) +{ + png_ptr->mem_ptr = mem_ptr; + png_ptr->malloc_fn = malloc_fn; + png_ptr->free_fn = free_fn; +} + +/* This function returns a pointer to the mem_ptr associated with the user + * functions. The application should free any memory associated with this + * pointer before png_write_destroy and png_read_destroy are called. + */ +png_voidp PNGAPI +png_get_mem_ptr(png_structp png_ptr) +{ + return ((png_voidp)png_ptr->mem_ptr); +} +#endif /* PNG_USER_MEM_SUPPORTED */ diff --git a/src/libs/pdflib/libs/png/pngread.c b/src/libs/pdflib/libs/png/pngread.c new file mode 100644 index 0000000000..274ed53764 --- /dev/null +++ b/src/libs/pdflib/libs/png/pngread.c @@ -0,0 +1,1431 @@ +/* PDFlib GmbH cvsid: $Id: pngread.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngread.c - read a PNG file + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file contains routines that an application calls directly to + * read a PNG file or stream. + */ + +#define PNG_INTERNAL +#include "png.h" + +/* Create a PNG structure for reading, and allocate any memory needed. */ +png_structp PNGAPI +png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn) +{ + +#ifdef PNG_USER_MEM_SUPPORTED + return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, + warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); +} + +/* Alternate create PNG structure for reading, and allocate any memory needed.*/ +png_structp PNGAPI +png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn) +{ +#endif /* PNG_USER_MEM_SUPPORTED */ + + png_structp png_ptr; + +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + + int i; + + png_debug(1, "in png_create_read_struct\n"); +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, + (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); +#else + png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); +#endif + if (png_ptr == NULL) + return (NULL); + +#if !defined(PNG_1_0_X) +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED + png_init_mmx_flags(png_ptr); /* 1.2.0 addition */ +#endif +#endif /* PNG_1_0_X */ + +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_ptr->jmpbuf)) +#endif + { + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf=NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, + (png_free_ptr)free_fn, (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif + return (NULL); + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); +#endif +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); +#endif + + png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); + + i=0; + do + { + if(user_png_ver[i] != png_libpng_ver[i]) + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; + } while (png_libpng_ver[i++]); + + if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) + { + /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so + * we must recompile any applications that use any older library version. + * For versions after libpng 1.0, we will be compatible, so we need + * only check the first digit. + */ + if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || + (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || + (user_png_ver[0] == '0' && user_png_ver[2] < '9')) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[80]; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); +#endif +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "Incompatible libpng version in application and library"); + } + } + + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + png_ptr->zstream.zalloc = png_zalloc; + png_ptr->zstream.zfree = png_zfree; + png_ptr->zstream.opaque = (voidpf)png_ptr; + + switch (inflateInit(&png_ptr->zstream)) + { + case Z_OK: /* Do nothing */ break; + case Z_MEM_ERROR: + case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; + case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; + default: png_error(png_ptr, "Unknown zlib error"); + } + + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); + +#ifdef PNG_SETJMP_SUPPORTED +/* Applications that neglect to set up their own setjmp() and then encounter + a png_error() will longjmp here. Since the jmpbuf is then meaningless we + abort instead of returning. */ +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) + PNG_ABORT(); + png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf)); +#else + if (setjmp(png_ptr->jmpbuf)) + PNG_ABORT(); +#endif +#endif + return (png_ptr); +} + +/* Initialize PNG structure for reading, and allocate any memory needed. + This interface is deprecated in favour of the png_create_read_struct(), + and it will eventually disappear. */ +/* PDFlib GmbH: the messy hack below would fool our pdf_ prefixes. */ +#if 0 +#undef png_read_init +void PNGAPI +png_read_init(png_structp png_ptr) +{ + /* We only come here via pre-1.0.7-compiled applications */ + png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); +} +#endif + +void PNGAPI +png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size, png_size_t png_info_size) +{ + /* We only come here via pre-1.0.12-compiled applications */ +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + if(sizeof(png_struct) > png_struct_size || sizeof(png_info) > png_info_size) + { + char msg[80]; + png_ptr->warning_fn=NULL; + if (user_png_ver) + { + sprintf(msg, "Application was compiled with png.h from libpng-%.20s", + user_png_ver); + png_warning(png_ptr, msg); + } + sprintf(msg, "Application is running with png.c from libpng-%.20s", + png_libpng_ver); + png_warning(png_ptr, msg); + } +#endif + if(sizeof(png_struct) > png_struct_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The png struct allocated by the application for reading is too small."); + } + if(sizeof(png_info) > png_info_size) + { + png_ptr->error_fn=NULL; +#ifdef PNG_ERROR_NUMBERS_SUPPORTED + png_ptr->flags=0; +#endif + png_error(png_ptr, + "The info struct allocated by application for reading is too small."); + } + png_read_init_3(&png_ptr, user_png_ver, png_struct_size); +} + +void PNGAPI +png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, + png_size_t png_struct_size) +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; /* to save current jump buffer */ +#endif + + int i=0; + + png_structp png_ptr=*ptr_ptr; + + do + { + if(user_png_ver[i] != png_libpng_ver[i]) + { +#ifdef PNG_LEGACY_SUPPORTED + png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; +#else + png_ptr->warning_fn=NULL; + png_warning(png_ptr, + "Application uses deprecated png_read_init() and should be recompiled."); + break; +#endif + } + } while (png_libpng_ver[i++]); + + png_debug(1, "in png_read_init_3\n"); + +#ifdef PNG_SETJMP_SUPPORTED + /* save jump buffer and error functions */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); +#endif + + if(sizeof(png_struct) > png_struct_size) + { + png_destroy_struct(png_ptr); + *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); + png_ptr = *ptr_ptr; + } + + /* reset all variables to 0 */ + png_memset(png_ptr, 0, sizeof (png_struct)); + +#ifdef PNG_SETJMP_SUPPORTED + /* restore jump buffer */ + png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); +#endif + + /* initialize zbuf - compression buffer */ + png_ptr->zbuf_size = PNG_ZBUF_SIZE; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); + png_ptr->zstream.zalloc = png_zalloc; + png_ptr->zstream.zfree = png_zfree; + png_ptr->zstream.opaque = (voidpf)png_ptr; + + switch (inflateInit(&png_ptr->zstream)) + { + case Z_OK: /* Do nothing */ break; + case Z_MEM_ERROR: + case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; + case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; + default: png_error(png_ptr, "Unknown zlib error"); + } + + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); +} + +/* Read the information before the actual image data. This has been + * changed in v0.90 to allow reading a file that already has the magic + * bytes read from the stream. You can tell libpng how many bytes have + * been read from the beginning of the stream (up to the maximum of 8) + * via png_set_sig_bytes(), and we will only check the remaining bytes + * here. The application can then have access to the signature bytes we + * read if it is determined that this isn't a valid PNG file. + */ +void PNGAPI +png_read_info(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_read_info\n"); + /* If we haven't checked all of the PNG signature bytes, do so now. */ + if (png_ptr->sig_bytes < 8) + { + png_size_t num_checked = png_ptr->sig_bytes, + num_to_check = 8 - num_checked; + + png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); + png_ptr->sig_bytes = 8; + + if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) + { + if (num_checked < 4 && + png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) + png_error(png_ptr, "Not a PNG file"); + else + png_error(png_ptr, "PNG file corrupted by ASCII conversion"); + } + if (num_checked < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; + } + + for(;;) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#if defined(PNG_READ_bKGD_SUPPORTED) + PNG_bKGD; +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + PNG_cHRM; +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + PNG_gAMA; +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + PNG_hIST; +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + PNG_iCCP; +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + PNG_iTXt; +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + PNG_oFFs; +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + PNG_pCAL; +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + PNG_pHYs; +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + PNG_sBIT; +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + PNG_sCAL; +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + PNG_sPLT; +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + PNG_sRGB; +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + PNG_tEXt; +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + PNG_tIME; +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + PNG_tRNS; +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + PNG_zTXt; +#endif +#endif /* PNG_GLOBAL_ARRAYS */ + png_byte chunk_length[4]; + png_uint_32 length; + + png_read_data(png_ptr, chunk_length, 4); + length = png_get_uint_32(chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + + png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, + length); + + if (length > PNG_MAX_UINT) + png_error(png_ptr, "Invalid chunk length."); + + /* This should be a binary subdivision search or a hash for + * matching the chunk name rather than a linear search. + */ + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + png_handle_IHDR(png_ptr, info_ptr, length); + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + png_handle_IEND(png_ptr, info_ptr, length); +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + { + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + png_ptr->mode |= PNG_HAVE_IDAT; + png_handle_unknown(png_ptr, info_ptr, length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_ptr->mode |= PNG_HAVE_PLTE; + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + break; + } + } +#endif + else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_handle_PLTE(png_ptr, info_ptr, length); + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); + + png_ptr->idat_size = length; + png_ptr->mode |= PNG_HAVE_IDAT; + break; + } +#if defined(PNG_READ_bKGD_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + png_handle_bKGD(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + png_handle_cHRM(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + png_handle_gAMA(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + png_handle_hIST(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + png_handle_oFFs(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + png_handle_pCAL(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + png_handle_sCAL(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + png_handle_pHYs(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + png_handle_sBIT(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + png_handle_sRGB(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + png_handle_iCCP(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + png_handle_sPLT(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + png_handle_tEXt(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + png_handle_tIME(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + png_handle_tRNS(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + png_handle_zTXt(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + png_handle_iTXt(png_ptr, info_ptr, length); +#endif + else + png_handle_unknown(png_ptr, info_ptr, length); + } +} + +/* optional call to update the users info_ptr structure */ +void PNGAPI +png_read_update_info(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_read_update_info\n"); + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + png_read_start_row(png_ptr); + else + png_warning(png_ptr, + "Ignoring extra png_read_update_info() call; row buffer not reallocated"); + png_read_transform_info(png_ptr, info_ptr); +} + +/* Initialize palette, background, etc, after transformations + * are set, but before any reading takes place. This allows + * the user to obtain a gamma-corrected palette, for example. + * If the user doesn't call this, we will do it ourselves. + */ +void PNGAPI +png_start_read_image(png_structp png_ptr) +{ + png_debug(1, "in png_start_read_image\n"); + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + png_read_start_row(png_ptr); +} + +void PNGAPI +png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; + const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; + const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; +#endif + int ret; + png_debug2(1, "in png_read_row (row %lu, pass %d)\n", + png_ptr->row_number, png_ptr->pass); + if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) + png_read_start_row(png_ptr); + if (png_ptr->row_number == 0 && png_ptr->pass == 0) + { + /* check for transforms that have been set but were defined out */ +#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_MONO) + png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) + if (png_ptr->transformations & PNG_FILLER) + png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_PACKSWAP_SUPPORTED)&&!defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) + if (png_ptr->transformations & PNG_PACK) + png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) + if (png_ptr->transformations & PNG_SHIFT) + png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) + if (png_ptr->transformations & PNG_BGR) + png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); +#endif +#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); +#endif + } + +#if defined(PNG_READ_INTERLACING_SUPPORTED) + /* if interlaced and we do not need a new row, combine row and return */ + if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) + { + switch (png_ptr->pass) + { + case 0: + if (png_ptr->row_number & 0x07) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 1: + if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 2: + if ((png_ptr->row_number & 0x07) != 4) + { + if (dsp_row != NULL && (png_ptr->row_number & 4)) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 3: + if ((png_ptr->row_number & 3) || png_ptr->width < 3) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 4: + if ((png_ptr->row_number & 3) != 2) + { + if (dsp_row != NULL && (png_ptr->row_number & 2)) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 5: + if ((png_ptr->row_number & 1) || png_ptr->width < 2) + { + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + png_read_finish_row(png_ptr); + return; + } + break; + case 6: + if (!(png_ptr->row_number & 1)) + { + png_read_finish_row(png_ptr); + return; + } + break; + } + } +#endif + + if (!(png_ptr->mode & PNG_HAVE_IDAT)) + png_error(png_ptr, "Invalid attempt to read row data"); + + png_ptr->zstream.next_out = png_ptr->row_buf; + png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; + do + { + if (!(png_ptr->zstream.avail_in)) + { + while (!png_ptr->idat_size) + { + png_byte chunk_length[4]; + + png_crc_finish(png_ptr, 0); + + png_read_data(png_ptr, chunk_length, 4); + png_ptr->idat_size = png_get_uint_32(chunk_length); + + if (png_ptr->idat_size > PNG_MAX_UINT) + png_error(png_ptr, "Invalid chunk length."); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + png_error(png_ptr, "Not enough image data"); + } + png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_in = png_ptr->zbuf; + if (png_ptr->zbuf_size > png_ptr->idat_size) + png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; + png_crc_read(png_ptr, png_ptr->zbuf, + (png_size_t)png_ptr->zstream.avail_in); + png_ptr->idat_size -= png_ptr->zstream.avail_in; + } + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret == Z_STREAM_END) + { + if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || + png_ptr->idat_size) + png_error(png_ptr, "Extra compressed data"); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + if (ret != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : + "Decompression error"); + + } while (png_ptr->zstream.avail_out); + + png_ptr->row_info.color_type = png_ptr->color_type; + png_ptr->row_info.width = png_ptr->iwidth; + png_ptr->row_info.channels = png_ptr->channels; + png_ptr->row_info.bit_depth = png_ptr->bit_depth; + png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; + png_ptr->row_info.rowbytes = ((png_ptr->row_info.width * + (png_uint_32)png_ptr->row_info.pixel_depth + 7) >> 3); + + if(png_ptr->row_buf[0]) + png_read_filter_row(png_ptr, &(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->prev_row + 1, + (int)(png_ptr->row_buf[0])); + + png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, + png_ptr->rowbytes + 1); + +#if defined(PNG_MNG_FEATURES_SUPPORTED) + if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) + { + /* Intrapixel differencing */ + png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); + } +#endif + + if (png_ptr->transformations) + png_do_read_transformations(png_ptr); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) + /* blow up interlaced rows to full size */ + if (png_ptr->interlaced && + (png_ptr->transformations & PNG_INTERLACE)) + { + if (png_ptr->pass < 6) +/* old interface (pre-1.0.9): + png_do_read_interlace(&(png_ptr->row_info), + png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + */ + png_do_read_interlace(png_ptr); + + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, + png_pass_dsp_mask[png_ptr->pass]); + if (row != NULL) + png_combine_row(png_ptr, row, + png_pass_mask[png_ptr->pass]); + } + else +#endif + { + if (row != NULL) + png_combine_row(png_ptr, row, 0xff); + if (dsp_row != NULL) + png_combine_row(png_ptr, dsp_row, 0xff); + } + png_read_finish_row(png_ptr); + + if (png_ptr->read_row_fn != NULL) + (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); +} + +/* Read one or more rows of image data. If the image is interlaced, + * and png_set_interlace_handling() has been called, the rows need to + * contain the contents of the rows from the previous pass. If the + * image has alpha or transparency, and png_handle_alpha()[*] has been + * called, the rows contents must be initialized to the contents of the + * screen. + * + * "row" holds the actual image, and pixels are placed in it + * as they arrive. If the image is displayed after each pass, it will + * appear to "sparkle" in. "display_row" can be used to display a + * "chunky" progressive image, with finer detail added as it becomes + * available. If you do not want this "chunky" display, you may pass + * NULL for display_row. If you do not want the sparkle display, and + * you have not called png_handle_alpha(), you may pass NULL for rows. + * If you have called png_handle_alpha(), and the image has either an + * alpha channel or a transparency chunk, you must provide a buffer for + * rows. In this case, you do not have to provide a display_row buffer + * also, but you may. If the image is not interlaced, or if you have + * not called png_set_interlace_handling(), the display_row buffer will + * be ignored, so pass NULL to it. + * + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.5 + */ + +void PNGAPI +png_read_rows(png_structp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows) +{ + png_uint_32 i; + png_bytepp rp; + png_bytepp dp; + + png_debug(1, "in png_read_rows\n"); + rp = row; + dp = display_row; + if (rp != NULL && dp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep rptr = *rp++; + png_bytep dptr = *dp++; + + png_read_row(png_ptr, rptr, dptr); + } + else if(rp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep rptr = *rp; + png_read_row(png_ptr, rptr, png_bytep_NULL); + rp++; + } + else if(dp != NULL) + for (i = 0; i < num_rows; i++) + { + png_bytep dptr = *dp; + png_read_row(png_ptr, png_bytep_NULL, dptr); + dp++; + } +} + +/* Read the entire image. If the image has an alpha channel or a tRNS + * chunk, and you have called png_handle_alpha()[*], you will need to + * initialize the image to the current image that PNG will be overlaying. + * We set the num_rows again here, in case it was incorrectly set in + * png_read_start_row() by a call to png_read_update_info() or + * png_start_read_image() if png_set_interlace_handling() wasn't called + * prior to either of these functions like it should have been. You can + * only call this function once. If you desire to have an image for + * each pass of a interlaced image, use png_read_rows() instead. + * + * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.5 + */ +void PNGAPI +png_read_image(png_structp png_ptr, png_bytepp image) +{ + png_uint_32 i,image_height; + int pass, j; + png_bytepp rp; + + png_debug(1, "in png_read_image\n"); + +#ifdef PNG_READ_INTERLACING_SUPPORTED + pass = png_set_interlace_handling(png_ptr); +#else + if (png_ptr->interlaced) + png_error(png_ptr, + "Cannot read interlaced image -- interlace handler disabled."); + pass = 1; +#endif + + + image_height=png_ptr->height; + png_ptr->num_rows = image_height; /* Make sure this is set correctly */ + + for (j = 0; j < pass; j++) + { + rp = image; + for (i = 0; i < image_height; i++) + { + png_read_row(png_ptr, *rp, png_bytep_NULL); + rp++; + } + } +} + +/* Read the end of the PNG file. Will not read past the end of the + * file, will verify the end is accurate, and will read any comments + * or time information at the end of the file, if info is not NULL. + */ +void PNGAPI +png_read_end(png_structp png_ptr, png_infop info_ptr) +{ + png_byte chunk_length[4]; + png_uint_32 length; + + png_debug(1, "in png_read_end\n"); + png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ + + do + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IHDR; + PNG_IDAT; + PNG_IEND; + PNG_PLTE; +#if defined(PNG_READ_bKGD_SUPPORTED) + PNG_bKGD; +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + PNG_cHRM; +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + PNG_gAMA; +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + PNG_hIST; +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + PNG_iCCP; +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + PNG_iTXt; +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + PNG_oFFs; +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + PNG_pCAL; +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + PNG_pHYs; +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + PNG_sBIT; +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + PNG_sCAL; +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + PNG_sPLT; +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + PNG_sRGB; +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + PNG_tEXt; +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + PNG_tIME; +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + PNG_tRNS; +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + PNG_zTXt; +#endif +#endif /* PNG_GLOBAL_ARRAYS */ + + png_read_data(png_ptr, chunk_length, 4); + length = png_get_uint_32(chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + + png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); + + if (length > PNG_MAX_UINT) + png_error(png_ptr, "Invalid chunk length."); + + if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + png_handle_IHDR(png_ptr, info_ptr, length); + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + png_handle_IEND(png_ptr, info_ptr, length); +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED + else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + { + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) + png_error(png_ptr, "Too many IDAT's found"); + } + else + png_ptr->mode |= PNG_AFTER_IDAT; + png_handle_unknown(png_ptr, info_ptr, length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_ptr->mode |= PNG_HAVE_PLTE; + } +#endif + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + { + /* Zero length IDATs are legal after the last IDAT has been + * read, but not after other chunks have been read. + */ + if (length > 0 || png_ptr->mode & PNG_AFTER_IDAT) + png_error(png_ptr, "Too many IDAT's found"); + png_crc_finish(png_ptr, length); + } + else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + png_handle_PLTE(png_ptr, info_ptr, length); +#if defined(PNG_READ_bKGD_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + png_handle_bKGD(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_cHRM_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + png_handle_cHRM(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_gAMA_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + png_handle_gAMA(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_hIST_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + png_handle_hIST(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_oFFs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + png_handle_oFFs(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_pCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + png_handle_pCAL(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sCAL_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + png_handle_sCAL(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_pHYs_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + png_handle_pHYs(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sBIT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + png_handle_sBIT(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sRGB_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + png_handle_sRGB(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_iCCP_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + png_handle_iCCP(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_sPLT_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + png_handle_sPLT(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tEXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + png_handle_tEXt(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tIME_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + png_handle_tIME(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_tRNS_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + png_handle_tRNS(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + png_handle_zTXt(png_ptr, info_ptr, length); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) + else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + png_handle_iTXt(png_ptr, info_ptr, length); +#endif + else + png_handle_unknown(png_ptr, info_ptr, length); + } while (!(png_ptr->mode & PNG_HAVE_IEND)); +} + +/* free all memory used by the read */ +void PNGAPI +png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, + png_infopp end_info_ptr_ptr) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL, end_info_ptr = NULL; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn = NULL; + png_voidp mem_ptr = NULL; +#endif + + png_debug(1, "in png_destroy_read_struct\n"); + if (png_ptr_ptr != NULL) + png_ptr = *png_ptr_ptr; + + if (info_ptr_ptr != NULL) + info_ptr = *info_ptr_ptr; + + if (end_info_ptr_ptr != NULL) + end_info_ptr = *end_info_ptr_ptr; + +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; + mem_ptr = png_ptr->mem_ptr; +#endif + + png_read_destroy(png_ptr, info_ptr, end_info_ptr); + + if (info_ptr != NULL) + { +#if defined(PNG_TEXT_SUPPORTED) + png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); +#endif + +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)info_ptr); +#endif + *info_ptr_ptr = NULL; + } + + if (end_info_ptr != NULL) + { +#if defined(PNG_READ_TEXT_SUPPORTED) + png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); +#endif +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)end_info_ptr); +#endif + *end_info_ptr_ptr = NULL; + } + + if (png_ptr != NULL) + { +#ifdef PNG_USER_MEM_SUPPORTED + png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); +#else + png_destroy_struct((png_voidp)png_ptr); +#endif + *png_ptr_ptr = NULL; + } +} + +/* free all memory used by the read (old method) */ +void /* PRIVATE */ +png_read_destroy(png_structp png_ptr, png_infop info_ptr,png_infop end_info_ptr) +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf tmp_jmp; +#endif + png_error_ptr error_fn; + png_error_ptr warning_fn; + png_voidp error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_free_ptr free_fn; + png_voidp mem_ptr; /* PDFlib GmbH: was missing */ +#endif + + png_debug(1, "in png_read_destroy\n"); + if (info_ptr != NULL) + png_info_destroy(png_ptr, info_ptr); + + if (end_info_ptr != NULL) + png_info_destroy(png_ptr, end_info_ptr); + + png_free(png_ptr, png_ptr->zbuf); + png_free(png_ptr, png_ptr->big_row_buf); + png_free(png_ptr, png_ptr->prev_row); +#if defined(PNG_READ_DITHER_SUPPORTED) + png_free(png_ptr, png_ptr->palette_lookup); + png_free(png_ptr, png_ptr->dither_index); +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) + png_free(png_ptr, png_ptr->gamma_table); +#endif +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + png_free(png_ptr, png_ptr->gamma_from_1); + png_free(png_ptr, png_ptr->gamma_to_1); +#endif +#ifdef PNG_FREE_ME_SUPPORTED + if (png_ptr->free_me & PNG_FREE_PLTE) + png_zfree(png_ptr, png_ptr->palette); + png_ptr->free_me &= ~PNG_FREE_PLTE; +#else + if (png_ptr->flags & PNG_FLAG_FREE_PLTE) + png_zfree(png_ptr, png_ptr->palette); + png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; +#endif +#if defined(PNG_tRNS_SUPPORTED) || \ + defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED + if (png_ptr->free_me & PNG_FREE_TRNS) + png_free(png_ptr, png_ptr->trans); + png_ptr->free_me &= ~PNG_FREE_TRNS; +#else + if (png_ptr->flags & PNG_FLAG_FREE_TRNS) + png_free(png_ptr, png_ptr->trans); + png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; +#endif +#endif +#if defined(PNG_READ_hIST_SUPPORTED) +#ifdef PNG_FREE_ME_SUPPORTED + if (png_ptr->free_me & PNG_FREE_HIST) + png_free(png_ptr, png_ptr->hist); + png_ptr->free_me &= ~PNG_FREE_HIST; +#else + if (png_ptr->flags & PNG_FLAG_FREE_HIST) + png_free(png_ptr, png_ptr->hist); + png_ptr->flags &= ~PNG_FLAG_FREE_HIST; +#endif +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->gamma_16_table != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_table[i]); + } + png_free(png_ptr, png_ptr->gamma_16_table); + } +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_from_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_from_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_from_1); + } + if (png_ptr->gamma_16_to_1 != NULL) + { + int i; + int istop = (1 << (8 - png_ptr->gamma_shift)); + for (i = 0; i < istop; i++) + { + png_free(png_ptr, png_ptr->gamma_16_to_1[i]); + } + png_free(png_ptr, png_ptr->gamma_16_to_1); + } +#endif +#endif +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_free(png_ptr, png_ptr->time_buffer); +#endif + + inflateEnd(&png_ptr->zstream); +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_free(png_ptr, png_ptr->save_buffer); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +#ifdef PNG_TEXT_SUPPORTED + png_free(png_ptr, png_ptr->current_text); +#endif /* PNG_TEXT_SUPPORTED */ +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + + /* Save the important info out of the png_struct, in case it is + * being used again. + */ +#ifdef PNG_SETJMP_SUPPORTED + png_memcpy(tmp_jmp, png_ptr->jmpbuf, sizeof (jmp_buf)); +#endif + + error_fn = png_ptr->error_fn; + warning_fn = png_ptr->warning_fn; + error_ptr = png_ptr->error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + free_fn = png_ptr->free_fn; + mem_ptr = png_ptr->mem_ptr; /* PDFlib GmbH: was missing */ +#endif + + png_memset(png_ptr, 0, sizeof (png_struct)); + + png_ptr->error_fn = error_fn; + png_ptr->warning_fn = warning_fn; + png_ptr->error_ptr = error_ptr; +#ifdef PNG_USER_MEM_SUPPORTED + png_ptr->free_fn = free_fn; + png_ptr->mem_ptr = mem_ptr; /* PDFlib GmbH: was missing */ +#endif + +#ifdef PNG_SETJMP_SUPPORTED + png_memcpy(png_ptr->jmpbuf, tmp_jmp, sizeof (jmp_buf)); +#endif + +} + +void PNGAPI +png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) +{ + png_ptr->read_row_fn = read_row_fn; +} + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +void PNGAPI +png_read_png(png_structp png_ptr, png_infop info_ptr, + int transforms, + voidp params) +{ + int row; + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) + /* invert the alpha channel from opacity to transparency */ + if (transforms & PNG_TRANSFORM_INVERT_ALPHA) + png_set_invert_alpha(png_ptr); +#endif + + /* The call to png_read_info() gives us all of the information from the + * PNG file before the first IDAT (image data chunk). + */ + png_read_info(png_ptr, info_ptr); + + /* -------------- image transformations start here ------------------- */ + +#if defined(PNG_READ_16_TO_8_SUPPORTED) + /* tell libpng to strip 16 bit/color files down to 8 bits/color */ + if (transforms & PNG_TRANSFORM_STRIP_16) + png_set_strip_16(png_ptr); +#endif + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) + /* Strip alpha bytes from the input data without combining with the + * background (not recommended). + */ + if (transforms & PNG_TRANSFORM_STRIP_ALPHA) + png_set_strip_alpha(png_ptr); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) + /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single + * byte into separate bytes (useful for paletted and grayscale images). + */ + if (transforms & PNG_TRANSFORM_PACKING) + png_set_packing(png_ptr); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + /* Change the order of packed pixels to least significant bit first + * (not useful if you are using png_set_packing). */ + if (transforms & PNG_TRANSFORM_PACKSWAP) + png_set_packswap(png_ptr); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) + /* Expand paletted colors into true RGB triplets + * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel + * Expand paletted or RGB images with transparency to full alpha + * channels so the data will be available as RGBA quartets. + */ + if (transforms & PNG_TRANSFORM_EXPAND) + if ((png_ptr->bit_depth < 8) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || + (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) + png_set_expand(png_ptr); +#endif + + /* We don't handle background color or gamma transformation or dithering. */ + +#if defined(PNG_READ_INVERT_SUPPORTED) + /* invert monochrome files to have 0 as white and 1 as black */ + if (transforms & PNG_TRANSFORM_INVERT_MONO) + png_set_invert_mono(png_ptr); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) + /* If you want to shift the pixel values from the range [0,255] or + * [0,65535] to the original [0,7] or [0,31], or whatever range the + * colors were originally in: + */ + if ((transforms & PNG_TRANSFORM_SHIFT) + && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) + { + png_color_8p sig_bit; + + png_get_sBIT(png_ptr, info_ptr, &sig_bit); + png_set_shift(png_ptr, sig_bit); + } +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) + /* flip the RGB pixels to BGR (or RGBA to BGRA) */ + if (transforms & PNG_TRANSFORM_BGR) + png_set_bgr(png_ptr); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) + /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ + if (transforms & PNG_TRANSFORM_SWAP_ALPHA) + png_set_swap_alpha(png_ptr); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) + /* swap bytes of 16 bit files to least significant byte first */ + if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) + png_set_swap(png_ptr); +#endif + + /* We don't handle adding filler bytes */ + + /* Optional call to gamma correct and add the background to the palette + * and update info structure. REQUIRED if you are expecting libpng to + * update the palette for you (i.e., you selected such a transform above). + */ + png_read_update_info(png_ptr, info_ptr); + + /* -------------- image transformations end here ------------------- */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); +#endif + if(info_ptr->row_pointers == NULL) + { + info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, + info_ptr->height * sizeof(png_bytep)); +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_ROWS; +#endif + for (row = 0; row < (int)info_ptr->height; row++) + { + info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, + png_get_rowbytes(png_ptr, info_ptr)); + } + } + + png_read_image(png_ptr, info_ptr->row_pointers); + info_ptr->valid |= PNG_INFO_IDAT; + + /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + png_read_end(png_ptr, info_ptr); + + if(transforms == 0 || params == NULL) + /* quiet compiler warnings */ return; + +} +#endif diff --git a/src/libs/pdflib/libs/png/pngrio.c b/src/libs/pdflib/libs/png/pngrio.c new file mode 100644 index 0000000000..07b85ba8cb --- /dev/null +++ b/src/libs/pdflib/libs/png/pngrio.c @@ -0,0 +1,168 @@ +/* PDFlib GmbH cvsid: $Id: pngrio.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngrio.c - functions for data input + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file provides a location for all input. Users who need + * special handling are expected to write a function that has the same + * arguments as this and performs a similar function, but that possibly + * has a different input method. Note that you shouldn't change this + * function, but rather write a replacement function and then make + * libpng use it at run time with png_set_read_fn(...). + */ + +#define PNG_INTERNAL +#include "png.h" + +/* Read the data from whatever input you are using. The default routine + reads from a file pointer. Note that this routine sometimes gets called + with very small lengths, so you should implement some kind of simple + buffering if you are using unbuffered reads. This should never be asked + to read more then 64K on a 16 bit machine. */ +void /* PRIVATE */ +png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_debug1(4,"reading %d bytes\n", (int)length); + if (png_ptr->read_data_fn != NULL) + (*(png_ptr->read_data_fn))(png_ptr, data, length); + else + png_error(png_ptr, "Call to NULL read function"); +} + +#if !defined(PNG_NO_STDIO) +/* This is the function that does the actual reading of data. If you are + not reading from a standard C stream, you should create a replacement + read_data function and use it at run time with png_set_read_fn(), rather + than changing the library. */ +#ifndef USE_FAR_KEYWORD +void PNGAPI +png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + /* fread() returns 0 on error, so it is OK to store this in a png_size_t + * instead of an int, which is what fread() actually returns. + */ +/* PDFlib GmbH: +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) + check = 0; +#else +*/ + check = (png_size_t)fread(data, (png_size_t)1, length, + (png_FILE_p)png_ptr->io_ptr); +/* #endif PDFlib GmbH: */ + + if (check != length) + png_error(png_ptr, "Read Error"); +} +#else +/* this is the model-independent version. Since the standard I/O library + can't handle far buffers in the medium and small models, we have to copy + the data. +*/ + +#define NEAR_BUF_SIZE 1024 +#define MIN(a,b) (a <= b ? a : b) + +static void /* PRIVATE */ +png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + int check; + png_byte *n_data; + png_FILE_p io_ptr; + + /* Check if data really is near. If so, use usual code. */ + n_data = (png_byte *)CVT_PTR_NOCHECK(data); + io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); + if ((png_bytep)n_data == data) + { +/* PDFlib GmbH: +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) + check = 0; +#else +*/ + check = fread(n_data, 1, length, io_ptr); +/* #endif PDFlib GmbH: */ + } + else + { + png_byte buf[NEAR_BUF_SIZE]; + png_size_t read, remaining, err; + check = 0; + remaining = length; + do + { + read = MIN(NEAR_BUF_SIZE, remaining); +/* PDFlib GmbH: +#if defined(_WIN32_WCE) + if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) + err = 0; +#else +*/ + err = fread(buf, (png_size_t)1, read, io_ptr); +/* #endif PDFlib GmbH: */ + png_memcpy(data, buf, read); /* copy far buffer to near buffer */ + if(err != read) + break; + else + check += err; + data += read; + remaining -= read; + } + while (remaining != 0); + } + if ((png_uint_32)check != (png_uint_32)length) + png_error(png_ptr, "read Error"); +} +#endif +#endif + +/* This function allows the application to supply a new input function + for libpng if standard C streams aren't being used. + + This function takes as its arguments: + png_ptr - pointer to a png input data structure + io_ptr - pointer to user supplied structure containing info about + the input functions. May be NULL. + read_data_fn - pointer to a new input function that takes as its + arguments a pointer to a png_struct, a pointer to + a location where input data can be stored, and a 32-bit + unsigned int that is the number of bytes to be read. + To exit and output any fatal error messages the new write + function should call png_error(png_ptr, "Error msg"). */ +void PNGAPI +png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, + png_rw_ptr read_data_fn) +{ + png_ptr->io_ptr = io_ptr; + +#if !defined(PNG_NO_STDIO) + if (read_data_fn != NULL) + png_ptr->read_data_fn = read_data_fn; + else + png_ptr->read_data_fn = png_default_read_data; +#else + png_ptr->read_data_fn = read_data_fn; +#endif + + /* It is an error to write to a read device */ + if (png_ptr->write_data_fn != NULL) + { + png_ptr->write_data_fn = NULL; + png_warning(png_ptr, + "It's an error to set both read_data_fn and write_data_fn in the "); + png_warning(png_ptr, + "same structure. Resetting write_data_fn to NULL."); + } + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_ptr->output_flush_fn = NULL; +#endif +} diff --git a/src/libs/pdflib/libs/png/pngrtran.c b/src/libs/pdflib/libs/png/pngrtran.c new file mode 100644 index 0000000000..ccfd9f89c7 --- /dev/null +++ b/src/libs/pdflib/libs/png/pngrtran.c @@ -0,0 +1,4176 @@ +/* PDFlib GmbH cvsid: $Id: pngrtran.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngrtran.c - transforms the data in a row for PNG readers + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file contains functions optionally called by an application + * in order to tell libpng how to handle data when reading a PNG. + * Transformations that are used in both reading and writing are + * in pngtrans.c. + */ + +#define PNG_INTERNAL +#include "png.h" + +/* Set the action on getting a CRC error for an ancillary or critical chunk. */ +void PNGAPI +png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) +{ + png_debug(1, "in png_set_crc_action\n"); + /* Tell libpng how we react to CRC errors in critical chunks */ + switch (crit_action) + { + case PNG_CRC_NO_CHANGE: /* leave setting as is */ + break; + case PNG_CRC_WARN_USE: /* warn/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; + break; + case PNG_CRC_QUIET_USE: /* quiet/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | + PNG_FLAG_CRC_CRITICAL_IGNORE; + break; + case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ + png_warning(png_ptr, "Can't discard critical data on CRC error."); + case PNG_CRC_ERROR_QUIT: /* error/quit */ + case PNG_CRC_DEFAULT: + default: + png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; + break; + } + + switch (ancil_action) + { + case PNG_CRC_NO_CHANGE: /* leave setting as is */ + break; + case PNG_CRC_WARN_USE: /* warn/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; + break; + case PNG_CRC_QUIET_USE: /* quiet/use data */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | + PNG_FLAG_CRC_ANCILLARY_NOWARN; + break; + case PNG_CRC_ERROR_QUIT: /* error/quit */ + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; + break; + case PNG_CRC_WARN_DISCARD: /* warn/discard data */ + case PNG_CRC_DEFAULT: + default: + png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; + break; + } +} + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +/* handle alpha and tRNS via a background color */ +void PNGAPI +png_set_background(png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma) +{ + png_debug(1, "in png_set_background\n"); + if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) + { + png_warning(png_ptr, "Application must supply a known background gamma"); + return; + } + + png_ptr->transformations |= PNG_BACKGROUND; + png_memcpy(&(png_ptr->background), background_color, sizeof(png_color_16)); + png_ptr->background_gamma = (float)background_gamma; + png_ptr->background_gamma_type = (png_byte)(background_gamma_code); + png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); + + /* Note: if need_expand is set and color_type is either RGB or RGB_ALPHA + * (in which case need_expand is superfluous anyway), the background color + * might actually be gray yet not be flagged as such. This is not a problem + * for the current code, which uses PNG_BACKGROUND_IS_GRAY only to + * decide when to do the png_do_gray_to_rgb() transformation. + */ + if ((need_expand && !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) || + (!need_expand && background_color->red == background_color->green && + background_color->red == background_color->blue)) + png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; +} +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip 16 bit depth files to 8 bit depth */ +void PNGAPI +png_set_strip_16(png_structp png_ptr) +{ + png_debug(1, "in png_set_strip_16\n"); + png_ptr->transformations |= PNG_16_TO_8; +} +#endif + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +void PNGAPI +png_set_strip_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_strip_alpha\n"); + png_ptr->transformations |= PNG_STRIP_ALPHA; +} +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Dither file to 8 bit. Supply a palette, the current number + * of elements in the palette, the maximum number of elements + * allowed, and a histogram if possible. If the current number + * of colors is greater then the maximum number, the palette will be + * modified to fit in the maximum number. "full_dither" indicates + * whether we need a dithering cube set up for RGB images, or if we + * simply are reducing the number of colors in a paletted image. + */ + +typedef struct png_dsort_struct +{ + struct png_dsort_struct FAR * next; + png_byte left; + png_byte right; +} png_dsort; +typedef png_dsort FAR * png_dsortp; +typedef png_dsort FAR * FAR * png_dsortpp; + +void PNGAPI +png_set_dither(png_structp png_ptr, png_colorp palette, + int num_palette, int maximum_colors, png_uint_16p histogram, + int full_dither) +{ + png_debug(1, "in png_set_dither\n"); + png_ptr->transformations |= PNG_DITHER; + + if (!full_dither) + { + int i; + + png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * sizeof (png_byte))); + for (i = 0; i < num_palette; i++) + png_ptr->dither_index[i] = (png_byte)i; + } + + if (num_palette > maximum_colors) + { + if (histogram != NULL) + { + /* This is easy enough, just throw out the least used colors. + Perhaps not the best solution, but good enough. */ + + int i; + + /* initialize an array to sort colors */ + png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * sizeof (png_byte))); + + /* initialize the dither_sort array */ + for (i = 0; i < num_palette; i++) + png_ptr->dither_sort[i] = (png_byte)i; + + /* Find the least used palette entries by starting a + bubble sort, and running it until we have sorted + out enough colors. Note that we don't care about + sorting all the colors, just finding which are + least used. */ + + for (i = num_palette - 1; i >= maximum_colors; i--) + { + int done; /* to stop early if the list is pre-sorted */ + int j; + + done = 1; + for (j = 0; j < i; j++) + { + if (histogram[png_ptr->dither_sort[j]] + < histogram[png_ptr->dither_sort[j + 1]]) + { + png_byte t; + + t = png_ptr->dither_sort[j]; + png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; + png_ptr->dither_sort[j + 1] = t; + done = 0; + } + } + if (done) + break; + } + + /* swap the palette around, and set up a table, if necessary */ + if (full_dither) + { + int j = num_palette; + + /* put all the useful colors within the max, but don't + move the others */ + for (i = 0; i < maximum_colors; i++) + { + if ((int)png_ptr->dither_sort[i] >= maximum_colors) + { + do + j--; + while ((int)png_ptr->dither_sort[j] >= maximum_colors); + palette[i] = palette[j]; + } + } + } + else + { + int j = num_palette; + + /* move all the used colors inside the max limit, and + develop a translation table */ + for (i = 0; i < maximum_colors; i++) + { + /* only move the colors we need to */ + if ((int)png_ptr->dither_sort[i] >= maximum_colors) + { + png_color tmp_color; + + do + j--; + while ((int)png_ptr->dither_sort[j] >= maximum_colors); + + tmp_color = palette[j]; + palette[j] = palette[i]; + palette[i] = tmp_color; + /* indicate where the color went */ + png_ptr->dither_index[j] = (png_byte)i; + png_ptr->dither_index[i] = (png_byte)j; + } + } + + /* find closest color for those colors we are not using */ + for (i = 0; i < num_palette; i++) + { + if ((int)png_ptr->dither_index[i] >= maximum_colors) + { + int min_d, k, min_k, d_index; + + /* find the closest color to one we threw out */ + d_index = png_ptr->dither_index[i]; + min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); + for (k = 1, min_k = 0; k < maximum_colors; k++) + { + int d; + + d = PNG_COLOR_DIST(palette[d_index], palette[k]); + + if (d < min_d) + { + min_d = d; + min_k = k; + } + } + /* point to closest color */ + png_ptr->dither_index[i] = (png_byte)min_k; + } + } + } + png_free(png_ptr, png_ptr->dither_sort); + png_ptr->dither_sort=NULL; + } + else + { + /* This is much harder to do simply (and quickly). Perhaps + we need to go through a median cut routine, but those + don't always behave themselves with only a few colors + as input. So we will just find the closest two colors, + and throw out one of them (chosen somewhat randomly). + [We don't understand this at all, so if someone wants to + work on improving it, be our guest - AED, GRP] + */ + int i; + int max_d; + int num_new_palette; + png_dsortp t; + png_dsortpp hash; + + t=NULL; + + /* initialize palette index arrays */ + png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * sizeof (png_byte))); + png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, + (png_uint_32)(num_palette * sizeof (png_byte))); + + /* initialize the sort array */ + for (i = 0; i < num_palette; i++) + { + png_ptr->index_to_palette[i] = (png_byte)i; + png_ptr->palette_to_index[i] = (png_byte)i; + } + + hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * + sizeof (png_dsortp))); + for (i = 0; i < 769; i++) + hash[i] = NULL; +/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */ + + num_new_palette = num_palette; + + /* initial wild guess at how far apart the farthest pixel + pair we will be eliminating will be. Larger + numbers mean more areas will be allocated, Smaller + numbers run the risk of not saving enough data, and + having to do this all over again. + + I have not done extensive checking on this number. + */ + max_d = 96; + + while (num_new_palette > maximum_colors) + { + for (i = 0; i < num_new_palette - 1; i++) + { + int j; + + for (j = i + 1; j < num_new_palette; j++) + { + int d; + + d = PNG_COLOR_DIST(palette[i], palette[j]); + + if (d <= max_d) + { + + t = (png_dsortp)png_malloc_warn(png_ptr, + (png_uint_32)(sizeof(png_dsort))); + if (t == NULL) + break; + t->next = hash[d]; + t->left = (png_byte)i; + t->right = (png_byte)j; + hash[d] = t; + } + } + if (t == NULL) + break; + } + + if (t != NULL) + for (i = 0; i <= max_d; i++) + { + if (hash[i] != NULL) + { + png_dsortp p; + + for (p = hash[i]; p; p = p->next) + { + if ((int)png_ptr->index_to_palette[p->left] + < num_new_palette && + (int)png_ptr->index_to_palette[p->right] + < num_new_palette) + { + int j, next_j; + + if (num_new_palette & 0x01) + { + j = p->left; + next_j = p->right; + } + else + { + j = p->right; + next_j = p->left; + } + + num_new_palette--; + palette[png_ptr->index_to_palette[j]] + = palette[num_new_palette]; + if (!full_dither) + { + int k; + + for (k = 0; k < num_palette; k++) + { + if (png_ptr->dither_index[k] == + png_ptr->index_to_palette[j]) + png_ptr->dither_index[k] = + png_ptr->index_to_palette[next_j]; + if ((int)png_ptr->dither_index[k] == + num_new_palette) + png_ptr->dither_index[k] = + png_ptr->index_to_palette[j]; + } + } + + png_ptr->index_to_palette[png_ptr->palette_to_index + [num_new_palette]] = png_ptr->index_to_palette[j]; + png_ptr->palette_to_index[png_ptr->index_to_palette[j]] + = png_ptr->palette_to_index[num_new_palette]; + + png_ptr->index_to_palette[j] =(png_byte)num_new_palette; + png_ptr->palette_to_index[num_new_palette] =(png_byte)j; + } + if (num_new_palette <= maximum_colors) + break; + } + if (num_new_palette <= maximum_colors) + break; + } + } + + for (i = 0; i < 769; i++) + { + if (hash[i] != NULL) + { + png_dsortp p = hash[i]; + while (p) + { + t = p->next; + png_free(png_ptr, p); + p = t; + } + } + hash[i] = 0; + } + max_d += 96; + } + png_free(png_ptr, hash); + png_free(png_ptr, png_ptr->palette_to_index); + png_free(png_ptr, png_ptr->index_to_palette); + png_ptr->palette_to_index=NULL; + png_ptr->index_to_palette=NULL; + } + num_palette = maximum_colors; + } + if (png_ptr->palette == NULL) + { + png_ptr->palette = palette; + } + png_ptr->num_palette = (png_uint_16)num_palette; + + if (full_dither) + { + int i; + png_bytep distance; + int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + + PNG_DITHER_BLUE_BITS; + int num_red = (1 << PNG_DITHER_RED_BITS); + int num_green = (1 << PNG_DITHER_GREEN_BITS); + int num_blue = (1 << PNG_DITHER_BLUE_BITS); + png_size_t num_entries = ((png_size_t)1 << total_bits); + + png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, + (png_uint_32)(num_entries * sizeof (png_byte))); + + png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte)); + + distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * + sizeof(png_byte))); + + png_memset(distance, 0xff, num_entries * sizeof(png_byte)); + + for (i = 0; i < num_palette; i++) + { + int ir, ig, ib; + int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); + int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); + int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); + + for (ir = 0; ir < num_red; ir++) + { + int dr = abs(ir - r); + int index_r =(ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); + + for (ig = 0; ig < num_green; ig++) + { + int dg = abs(ig - g); + int dt = dr + dg; + int dm = ((dr > dg) ? dr : dg); + int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); + + for (ib = 0; ib < num_blue; ib++) + { + int d_index = index_g | ib; + int db = abs(ib - b); + int dmax = ((dm > db) ? dm : db); + int d = dmax + dt + db; + + if (d < (int)distance[d_index]) + { + distance[d_index] = (png_byte)d; + png_ptr->palette_lookup[d_index] = (png_byte)i; + } + } + } + } + } + + png_free(png_ptr, distance); + } +} +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) +/* Transform the image from the file_gamma to the screen_gamma. We + * only do transformations on images where the file_gamma and screen_gamma + * are not close reciprocals, otherwise it slows things down slightly, and + * also needlessly introduces small errors. + * + * We will turn off gamma transformation later if no semitransparent entries + * are present in the tRNS array for palette images. We can't do it here + * because we don't necessarily have the tRNS chunk yet. + */ +void PNGAPI +png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) +{ + png_debug(1, "in png_set_gamma\n"); + if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) + png_ptr->transformations |= PNG_GAMMA; + png_ptr->gamma = (float)file_gamma; + png_ptr->screen_gamma = (float)scrn_gamma; +} +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expand paletted images to RGB, expand grayscale images of + * less than 8-bit depth to 8-bit depth, and expand tRNS chunks + * to alpha channels. + */ +void PNGAPI +png_set_expand(png_structp png_ptr) +{ + png_debug(1, "in png_set_expand\n"); + png_ptr->transformations |= PNG_EXPAND; +} + +/* GRR 19990627: the following three functions currently are identical + * to png_set_expand(). However, it is entirely reasonable that someone + * might wish to expand an indexed image to RGB but *not* expand a single, + * fully transparent palette entry to a full alpha channel--perhaps instead + * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace + * the transparent color with a particular RGB value, or drop tRNS entirely. + * IOW, a future version of the library may make the transformations flag + * a bit more fine-grained, with separate bits for each of these three + * functions. + * + * More to the point, these functions make it obvious what libpng will be + * doing, whereas "expand" can (and does) mean any number of things. + */ + +/* Expand paletted images to RGB. */ +void PNGAPI +png_set_palette_to_rgb(png_structp png_ptr) +{ + png_debug(1, "in png_set_expand\n"); + png_ptr->transformations |= PNG_EXPAND; +} + +/* Expand grayscale images of less than 8-bit depth to 8 bits. */ +void PNGAPI +png_set_gray_1_2_4_to_8(png_structp png_ptr) +{ + png_debug(1, "in png_set_expand\n"); + png_ptr->transformations |= PNG_EXPAND; +} + +/* Expand tRNS chunks to alpha channels. */ +void PNGAPI +png_set_tRNS_to_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_expand\n"); + png_ptr->transformations |= PNG_EXPAND; +} +#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +void PNGAPI +png_set_gray_to_rgb(png_structp png_ptr) +{ + png_debug(1, "in png_set_gray_to_rgb\n"); + png_ptr->transformations |= PNG_GRAY_TO_RGB; +} +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) +/* Convert a RGB image to a grayscale of the same width. This allows us, + * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. + */ + +void PNGAPI +png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, + double green) +{ + int red_fixed = (int)((float)red*100000.0 + 0.5); + int green_fixed = (int)((float)green*100000.0 + 0.5); + png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); +} +#endif + +void PNGAPI +png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, + png_fixed_point red, png_fixed_point green) +{ + png_debug(1, "in png_set_rgb_to_gray\n"); + switch(error_action) + { + case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; + break; + case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; + break; + case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; + } + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) +#if defined(PNG_READ_EXPAND_SUPPORTED) + png_ptr->transformations |= PNG_EXPAND; +#else + { + png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); + png_ptr->transformations &= ~PNG_RGB_TO_GRAY; + } +#endif + { + png_uint_16 red_int, green_int; + if(red < 0 || green < 0) + { + red_int = 6968; /* .212671 * 32768 + .5 */ + green_int = 23434; /* .715160 * 32768 + .5 */ + } + else if(red + green < 100000L) + { + red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); + green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); + } + else + { + png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); + red_int = 6968; + green_int = 23434; + } + png_ptr->rgb_to_gray_red_coeff = red_int; + png_ptr->rgb_to_gray_green_coeff = green_int; + png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); + } +} +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +void PNGAPI +png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr + read_user_transform_fn) +{ + png_debug(1, "in png_set_read_user_transform_fn\n"); +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_ptr->transformations |= PNG_USER_TRANSFORM; + png_ptr->read_user_transform_fn = read_user_transform_fn; +#endif +#ifdef PNG_LEGACY_SUPPORTED + if(read_user_transform_fn) + png_warning(png_ptr, + "This version of libpng does not support user transforms"); +#endif +} +#endif + +/* Initialize everything needed for the read. This includes modifying + * the palette. + */ +void /* PRIVATE */ +png_init_read_transformations(png_structp png_ptr) +{ + png_debug(1, "in png_init_read_transformations\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if(png_ptr != NULL) +#endif + { +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED)\ + || defined(PNG_READ_GAMMA_SUPPORTED) + int color_type = png_ptr->color_type; +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) + if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && + (png_ptr->transformations & PNG_EXPAND)) + { + if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ + { + /* expand background chunk. */ + switch (png_ptr->bit_depth) + { + case 1: + png_ptr->background.gray *= (png_uint_16)0xff; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + break; + case 2: + png_ptr->background.gray *= (png_uint_16)0x55; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + break; + case 4: + png_ptr->background.gray *= (png_uint_16)0x11; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + break; + case 8: + case 16: + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + break; + } + } + else if (color_type == PNG_COLOR_TYPE_PALETTE) + { + png_ptr->background.red = + png_ptr->palette[png_ptr->background.index].red; + png_ptr->background.green = + png_ptr->palette[png_ptr->background.index].green; + png_ptr->background.blue = + png_ptr->palette[png_ptr->background.index].blue; + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_ALPHA) + { +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (!(png_ptr->transformations & PNG_EXPAND)) +#endif + { + /* invert the alpha channel (in tRNS) unless the pixels are + going to be expanded, in which case leave it for later */ + int i,istop; + istop=(int)png_ptr->num_trans; + for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); + } + } +#endif + + } + } +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) + png_ptr->background_1 = png_ptr->background; +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) + + if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) + && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) + < PNG_GAMMA_THRESHOLD)) + { + int i,k; + k=0; + for (i=0; inum_trans; i++) + { + if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) + k=1; /* partial transparency is present */ + } + if (k == 0) + png_ptr->transformations &= (~PNG_GAMMA); + } + + if (png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) + { + png_build_gamma_table(png_ptr); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) + { + if (color_type == PNG_COLOR_TYPE_PALETTE) + { + /* could skip if no transparency and + */ + png_color back, back_1; + png_colorp palette = png_ptr->palette; + int num_palette = png_ptr->num_palette; + int i; + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) + { + back.red = png_ptr->gamma_table[png_ptr->background.red]; + back.green = png_ptr->gamma_table[png_ptr->background.green]; + back.blue = png_ptr->gamma_table[png_ptr->background.blue]; + + back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; + back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; + back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; + } + else + { + double g, gs; + + switch (png_ptr->background_gamma_type) + { + case PNG_BACKGROUND_GAMMA_SCREEN: + g = (png_ptr->screen_gamma); + gs = 1.0; + break; + case PNG_BACKGROUND_GAMMA_FILE: + g = 1.0 / (png_ptr->gamma); + gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + break; + case PNG_BACKGROUND_GAMMA_UNIQUE: + g = 1.0 / (png_ptr->background_gamma); + gs = 1.0 / (png_ptr->background_gamma * + png_ptr->screen_gamma); + break; + default: + g = 1.0; /* back_1 */ + gs = 1.0; /* back */ + } + + if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) + { + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + } + else + { + back.red = (png_byte)(pow( + (double)png_ptr->background.red/255, gs) * 255.0 + .5); + back.green = (png_byte)(pow( + (double)png_ptr->background.green/255, gs) * 255.0 + .5); + back.blue = (png_byte)(pow( + (double)png_ptr->background.blue/255, gs) * 255.0 + .5); + } + + back_1.red = (png_byte)(pow( + (double)png_ptr->background.red/255, g) * 255.0 + .5); + back_1.green = (png_byte)(pow( + (double)png_ptr->background.green/255, g) * 255.0 + .5); + back_1.blue = (png_byte)(pow( + (double)png_ptr->background.blue/255, g) * 255.0 + .5); + } + for (i = 0; i < num_palette; i++) + { + if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) + { + if (png_ptr->trans[i] == 0) + { + palette[i] = back; + } + else /* if (png_ptr->trans[i] != 0xff) */ + { + png_byte v, w; + + v = png_ptr->gamma_to_1[palette[i].red]; + png_composite(w, v, png_ptr->trans[i], back_1.red); + palette[i].red = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[palette[i].green]; + png_composite(w, v, png_ptr->trans[i], back_1.green); + palette[i].green = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[palette[i].blue]; + png_composite(w, v, png_ptr->trans[i], back_1.blue); + palette[i].blue = png_ptr->gamma_from_1[w]; + } + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } + /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ + else + /* color_type != PNG_COLOR_TYPE_PALETTE */ + { + double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); + double g = 1.0; + double gs = 1.0; + + switch (png_ptr->background_gamma_type) + { + case PNG_BACKGROUND_GAMMA_SCREEN: + g = (png_ptr->screen_gamma); + gs = 1.0; + break; + case PNG_BACKGROUND_GAMMA_FILE: + g = 1.0 / (png_ptr->gamma); + gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + break; + case PNG_BACKGROUND_GAMMA_UNIQUE: + g = 1.0 / (png_ptr->background_gamma); + gs = 1.0 / (png_ptr->background_gamma * + png_ptr->screen_gamma); + break; + } + + png_ptr->background_1.gray = (png_uint_16)(pow( + (double)png_ptr->background.gray / m, g) * m + .5); + png_ptr->background.gray = (png_uint_16)(pow( + (double)png_ptr->background.gray / m, gs) * m + .5); + + if ((png_ptr->background.red != png_ptr->background.green) || + (png_ptr->background.red != png_ptr->background.blue) || + (png_ptr->background.red != png_ptr->background.gray)) + { + /* RGB or RGBA with color background */ + png_ptr->background_1.red = (png_uint_16)(pow( + (double)png_ptr->background.red / m, g) * m + .5); + png_ptr->background_1.green = (png_uint_16)(pow( + (double)png_ptr->background.green / m, g) * m + .5); + png_ptr->background_1.blue = (png_uint_16)(pow( + (double)png_ptr->background.blue / m, g) * m + .5); + png_ptr->background.red = (png_uint_16)(pow( + (double)png_ptr->background.red / m, gs) * m + .5); + png_ptr->background.green = (png_uint_16)(pow( + (double)png_ptr->background.green / m, gs) * m + .5); + png_ptr->background.blue = (png_uint_16)(pow( + (double)png_ptr->background.blue / m, gs) * m + .5); + } + else + { + /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ + png_ptr->background_1.red = png_ptr->background_1.green + = png_ptr->background_1.blue = png_ptr->background_1.gray; + png_ptr->background.red = png_ptr->background.green + = png_ptr->background.blue = png_ptr->background.gray; + } + } + } + else + /* transformation does not include PNG_BACKGROUND */ +#endif /* PNG_READ_BACKGROUND_SUPPORTED */ + if (color_type == PNG_COLOR_TYPE_PALETTE) + { + png_colorp palette = png_ptr->palette; + int num_palette = png_ptr->num_palette; + int i; + + for (i = 0; i < num_palette; i++) + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + else +#endif +#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + /* No GAMMA transformation */ + if ((png_ptr->transformations & PNG_BACKGROUND) && + (color_type == PNG_COLOR_TYPE_PALETTE)) + { + int i; + int istop = (int)png_ptr->num_trans; + png_color back; + png_colorp palette = png_ptr->palette; + + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + + for (i = 0; i < istop; i++) + { + if (png_ptr->trans[i] == 0) + { + palette[i] = back; + } + else if (png_ptr->trans[i] != 0xff) + { + /* The png_composite() macro is defined in png.h */ + png_composite(palette[i].red, palette[i].red, + png_ptr->trans[i], back.red); + png_composite(palette[i].green, palette[i].green, + png_ptr->trans[i], back.green); + png_composite(palette[i].blue, palette[i].blue, + png_ptr->trans[i], back.blue); + } + } + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED */ + +#if defined(PNG_READ_SHIFT_SUPPORTED) + if ((png_ptr->transformations & PNG_SHIFT) && + (color_type == PNG_COLOR_TYPE_PALETTE)) + { + png_uint_16 i; + png_uint_16 istop = png_ptr->num_palette; + int sr = 8 - png_ptr->sig_bit.red; + int sg = 8 - png_ptr->sig_bit.green; + int sb = 8 - png_ptr->sig_bit.blue; + + if (sr < 0 || sr > 8) + sr = 0; + if (sg < 0 || sg > 8) + sg = 0; + if (sb < 0 || sb > 8) + sb = 0; + for (i = 0; i < istop; i++) + { + png_ptr->palette[i].red >>= sr; + png_ptr->palette[i].green >>= sg; + png_ptr->palette[i].blue >>= sb; + } + } +#endif /* PNG_READ_SHIFT_SUPPORTED */ + } +#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ + && !defined(PNG_READ_BACKGROUND_SUPPORTED) + if(png_ptr) + return; +#endif +} + +/* Modify the info structure to reflect the transformations. The + * info should be updated so a PNG file could be written with it, + * assuming the transformations result in valid PNG data. + */ +void /* PRIVATE */ +png_read_transform_info(png_structp png_ptr, png_infop info_ptr) +{ + png_debug(1, "in png_read_transform_info\n"); +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (png_ptr->transformations & PNG_EXPAND) + { + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (png_ptr->num_trans) + info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; + else + info_ptr->color_type = PNG_COLOR_TYPE_RGB; + info_ptr->bit_depth = 8; + info_ptr->num_trans = 0; + } + else + { + if (png_ptr->num_trans) + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; + if (info_ptr->bit_depth < 8) + info_ptr->bit_depth = 8; + info_ptr->num_trans = 0; + } + } +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) + { + info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; + info_ptr->num_trans = 0; + info_ptr->background = png_ptr->background; + } +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->transformations & PNG_GAMMA) + { +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->gamma = png_ptr->gamma; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = png_ptr->int_gamma; +#endif + } +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) + if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) + info_ptr->bit_depth = 8; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + if (png_ptr->transformations & PNG_DITHER) + { + if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || + (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && + png_ptr->palette_lookup && info_ptr->bit_depth == 8) + { + info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; + } + } +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) + if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) + info_ptr->bit_depth = 8; +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + if (png_ptr->transformations & PNG_GRAY_TO_RGB) + info_ptr->color_type |= PNG_COLOR_MASK_COLOR; +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & PNG_RGB_TO_GRAY) + info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; +#endif + + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + info_ptr->channels = 1; + else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) + info_ptr->channels = 3; + else + info_ptr->channels = 1; + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_STRIP_ALPHA) + info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; +#endif + + if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) + info_ptr->channels++; + +#if defined(PNG_READ_FILLER_SUPPORTED) + /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ + if ((png_ptr->transformations & PNG_FILLER) && + ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || + (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) + { + info_ptr->channels++; +#if 0 /* if adding a true alpha channel not just filler */ + info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; +#endif + } +#endif + +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ +defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + if(png_ptr->transformations & PNG_USER_TRANSFORM) + { + if(info_ptr->bit_depth < png_ptr->user_transform_depth) + info_ptr->bit_depth = png_ptr->user_transform_depth; + if(info_ptr->channels < png_ptr->user_transform_channels) + info_ptr->channels = png_ptr->user_transform_channels; + } +#endif + + info_ptr->pixel_depth = (png_byte)(info_ptr->channels * + info_ptr->bit_depth); + info_ptr->rowbytes = ((info_ptr->width * info_ptr->pixel_depth + 7) >> 3); + +#if !defined(PNG_READ_EXPAND_SUPPORTED) + if(png_ptr) + return; +#endif +} + +/* Transform the row. The order of transformations is significant, + * and is very touchy. If you add a transformation, take care to + * decide how it fits in with the other transformations here. + */ +void /* PRIVATE */ +png_do_read_transformations(png_structp png_ptr) +{ + png_debug(1, "in png_do_read_transformations\n"); +#if !defined(PNG_USELESS_TESTS_SUPPORTED) + if (png_ptr->row_buf == NULL) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char msg[50]; + + sprintf(msg, "NULL row buffer for row %ld, pass %d", png_ptr->row_number, + png_ptr->pass); + png_error(png_ptr, msg); +#else + png_error(png_ptr, "NULL row buffer"); +#endif + } +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (png_ptr->transformations & PNG_EXPAND) + { + if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) + { + png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->palette, png_ptr->trans, png_ptr->num_trans); + } + else + { + if (png_ptr->num_trans) + png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->trans_values)); + else + png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, + NULL); + } + } +#endif + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_STRIP_ALPHA) + png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + PNG_FLAG_FILLER_AFTER); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & PNG_RGB_TO_GRAY) + { + int rgb_error = + png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf +1); + if(rgb_error) + { + png_ptr->rgb_to_gray_status=1; + if(png_ptr->transformations == PNG_RGB_TO_GRAY_WARN) + png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); + if(png_ptr->transformations == PNG_RGB_TO_GRAY_ERR) + png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); + } + } +#endif + +/* +From Andreas Dilger e-mail to png-implement, 26 March 1998: + + In most cases, the "simple transparency" should be done prior to doing + gray-to-RGB, or you will have to test 3x as many bytes to check if a + pixel is transparent. You would also need to make sure that the + transparency information is upgraded to RGB. + + To summarize, the current flow is: + - Gray + simple transparency -> compare 1 or 2 gray bytes and composite + with background "in place" if transparent, + convert to RGB if necessary + - Gray + alpha -> composite with gray background and remove alpha bytes, + convert to RGB if necessary + + To support RGB backgrounds for gray images we need: + - Gray + simple transparency -> convert to RGB + simple transparency, compare + 3 or 6 bytes and composite with background + "in place" if transparent (3x compare/pixel + compared to doing composite with gray bkgrnd) + - Gray + alpha -> convert to RGB + alpha, composite with background and + remove alpha bytes (3x float operations/pixel + compared with composite on gray background) + + Greg's change will do this. The reason it wasn't done before is for + performance, as this increases the per-pixel operations. If we would check + in advance if the background was gray or RGB, and position the gray-to-RGB + transform appropriately, then it would save a lot of work/time. + */ + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + /* if gray -> RGB, do so now only if background is non-gray; else do later + * for performance reasons */ + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && + !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) + png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if ((png_ptr->transformations & PNG_BACKGROUND) && + ((png_ptr->num_trans != 0 ) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) + png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->trans_values), &(png_ptr->background) +#if defined(PNG_READ_GAMMA_SUPPORTED) + , &(png_ptr->background_1), + png_ptr->gamma_table, png_ptr->gamma_from_1, + png_ptr->gamma_to_1, png_ptr->gamma_16_table, + png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, + png_ptr->gamma_shift +#endif +); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) + if ((png_ptr->transformations & PNG_GAMMA) && +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + !((png_ptr->transformations & PNG_BACKGROUND) && + ((png_ptr->num_trans != 0) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && +#endif + (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) + png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->gamma_table, png_ptr->gamma_16_table, + png_ptr->gamma_shift); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) + if (png_ptr->transformations & PNG_16_TO_8) + png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + if (png_ptr->transformations & PNG_DITHER) + { + png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, + png_ptr->palette_lookup, png_ptr->dither_index); + if(png_ptr->row_info.rowbytes == (png_uint_32)0) + png_error(png_ptr, "png_do_dither returned rowbytes=0"); + } +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_MONO) + png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) + if (png_ptr->transformations & PNG_SHIFT) + png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, + &(png_ptr->shift)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) + if (png_ptr->transformations & PNG_PACK) + png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) + if (png_ptr->transformations & PNG_BGR) + png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + /* if gray -> RGB, do so now only if we did not do so above */ + if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && + (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) + png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) + if (png_ptr->transformations & PNG_FILLER) + png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, + (png_uint_32)png_ptr->filler, png_ptr->flags); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_INVERT_ALPHA) + png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_ALPHA) + png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + if (png_ptr->transformations & PNG_USER_TRANSFORM) + { + if(png_ptr->read_user_transform_fn != NULL) + (*(png_ptr->read_user_transform_fn)) /* user read transform function */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + if(png_ptr->user_transform_depth) + png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; + if(png_ptr->user_transform_channels) + png_ptr->row_info.channels = png_ptr->user_transform_channels; +#endif + png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * + png_ptr->row_info.channels); + png_ptr->row_info.rowbytes = (png_ptr->row_info.width * + png_ptr->row_info.pixel_depth+7)>>3; + } +#endif + +} + +#if defined(PNG_READ_PACK_SUPPORTED) +/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, + * without changing the actual values. Thus, if you had a row with + * a bit depth of 1, you would end up with bytes that only contained + * the numbers 0 or 1. If you would rather they contain 0 and 255, use + * png_do_shift() after this. + */ +void /* PRIVATE */ +png_do_unpack(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_unpack\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && row_info->bit_depth < 8) +#else + if (row_info->bit_depth < 8) +#endif + { + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + switch (row_info->bit_depth) + { + case 1: + { + png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x01); + if (shift == 7) + { + shift = 0; + sp--; + } + else + shift++; + + dp--; + } + break; + } + case 2: + { + + png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x03); + if (shift == 6) + { + shift = 0; + sp--; + } + else + shift += 2; + + dp--; + } + break; + } + case 4: + { + png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); + png_bytep dp = row + (png_size_t)row_width - 1; + png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); + for (i = 0; i < row_width; i++) + { + *dp = (png_byte)((*sp >> shift) & 0x0f); + if (shift == 4) + { + shift = 0; + sp--; + } + else + shift = 4; + + dp--; + } + break; + } + } + row_info->bit_depth = 8; + row_info->pixel_depth = (png_byte)(8 * row_info->channels); + row_info->rowbytes = row_width * row_info->channels; + } +} +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +/* Reverse the effects of png_do_shift. This routine merely shifts the + * pixels back to their significant bits values. Thus, if you have + * a row of bit depth 8, but only 5 are significant, this will shift + * the values back to 0 through 31. + */ +void /* PRIVATE */ +png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) +{ + png_debug(1, "in png_do_unshift\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && sig_bits != NULL && +#endif + row_info->color_type != PNG_COLOR_TYPE_PALETTE) + { + int shift[4]; + int channels = 0; + int c; + png_uint_16 value = 0; + png_uint_32 row_width = row_info->width; + + if (row_info->color_type & PNG_COLOR_MASK_COLOR) + { + shift[channels++] = row_info->bit_depth - sig_bits->red; + shift[channels++] = row_info->bit_depth - sig_bits->green; + shift[channels++] = row_info->bit_depth - sig_bits->blue; + } + else + { + shift[channels++] = row_info->bit_depth - sig_bits->gray; + } + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + { + shift[channels++] = row_info->bit_depth - sig_bits->alpha; + } + + for (c = 0; c < channels; c++) + { + if (shift[c] <= 0) + shift[c] = 0; + else + value = 1; + } + + if (!value) + return; + + switch (row_info->bit_depth) + { + case 2: + { + png_bytep bp; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + + for (bp = row, i = 0; i < istop; i++) + { + *bp >>= 1; + *bp++ &= 0x55; + } + break; + } + case 4: + { + png_bytep bp = row; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | + (png_byte)((int)0xf >> shift[0])); + + for (i = 0; i < istop; i++) + { + *bp >>= shift[0]; + *bp++ &= mask; + } + break; + } + case 8: + { + png_bytep bp = row; + png_uint_32 i; + png_uint_32 istop = row_width * channels; + + for (i = 0; i < istop; i++) + { + *bp++ >>= shift[i%channels]; + } + break; + } + case 16: + { + png_bytep bp = row; + png_uint_32 i; + png_uint_32 istop = channels * row_width; + + for (i = 0; i < istop; i++) + { + value = (png_uint_16)((*bp << 8) + *(bp + 1)); + value >>= shift[i%channels]; + *bp++ = (png_byte)(value >> 8); + *bp++ = (png_byte)(value & 0xff); + } + break; + } + } + } +} +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* chop rows of bit depth 16 down to 8 */ +void /* PRIVATE */ +png_do_chop(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_chop\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL && row_info->bit_depth == 16) +#else + if (row_info->bit_depth == 16) +#endif + { + png_bytep sp = row; + png_bytep dp = row; + png_uint_32 i; + png_uint_32 istop = row_info->width * row_info->channels; + + for (i = 0; i> 8)) >> 8; + * + * Approximate calculation with shift/add instead of multiply/divide: + * *dp = ((((png_uint_32)(*sp) << 8) | + * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; + * + * What we actually do to avoid extra shifting and conversion: + */ + + *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); +#else + /* Simply discard the low order byte */ + *dp = *sp; +#endif + } + row_info->bit_depth = 8; + row_info->pixel_depth = (png_byte)(8 * row_info->channels); + row_info->rowbytes = row_info->width * row_info->channels; + } +} +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +void /* PRIVATE */ +png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_swap_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + png_uint_32 row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + /* This converts from RGBA to ARGB */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save; + } + } + /* This converts from RRGGBBAA to AARRGGBB */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save[2]; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save[0] = *(--sp); + save[1] = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save[0]; + *(--dp) = save[1]; + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + /* This converts from GA to AG */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save; + } + } + /* This converts from GGAA to AAGG */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_byte save[2]; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + save[0] = *(--sp); + save[1] = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = save[0]; + *(--dp) = save[1]; + } + } + } + } +} +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +void /* PRIVATE */ +png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_invert_alpha\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + png_uint_32 row_width = row_info->width; + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + /* This inverts the alpha channel in RGBA */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: +*/ + sp-=3; + dp=sp; + } + } + /* This inverts the alpha channel in RRGGBBAA */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); + +/* This does nothing: + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + We can replace it with: +*/ + sp-=6; + dp=sp; + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + /* This inverts the alpha channel in GA */ + if (row_info->bit_depth == 8) + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = *(--sp); + } + } + /* This inverts the alpha channel in GGAA */ + else + { + png_bytep sp = row + row_info->rowbytes; + png_bytep dp = sp; + png_uint_32 i; + + for (i = 0; i < row_width; i++) + { + *(--dp) = (png_byte)(255 - *(--sp)); + *(--dp) = (png_byte)(255 - *(--sp)); +/* + *(--dp) = *(--sp); + *(--dp) = *(--sp); +*/ + sp-=2; + dp=sp; + } + } + } + } +} +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) +/* Add filler channel if we have RGB color */ +void /* PRIVATE */ +png_do_read_filler(png_row_infop row_info, png_bytep row, + png_uint_32 filler, png_uint_32 flags) +{ + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + png_byte hi_filler = (png_byte)((filler>>8) & 0xff); + png_byte lo_filler = (png_byte)(filler & 0xff); + + png_debug(1, "in png_do_read_filler\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + if(row_info->bit_depth == 8) + { + /* This changes the data from G to GX */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + png_bytep sp = row + (png_size_t)row_width; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 1; i < row_width; i++) + { + *(--dp) = lo_filler; + *(--dp) = *(--sp); + } + *(--dp) = lo_filler; + row_info->channels = 2; + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + /* This changes the data from G to XG */ + else + { + png_bytep sp = row + (png_size_t)row_width; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = lo_filler; + } + row_info->channels = 2; + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + } + else if(row_info->bit_depth == 16) + { + /* This changes the data from GG to GGXX */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + png_bytep sp = row + (png_size_t)row_width; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 1; i < row_width; i++) + { + *(--dp) = hi_filler; + *(--dp) = lo_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = hi_filler; + *(--dp) = lo_filler; + row_info->channels = 2; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + /* This changes the data from GG to XXGG */ + else + { + png_bytep sp = row + (png_size_t)row_width; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = hi_filler; + *(--dp) = lo_filler; + } + row_info->channels = 2; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + } + } /* COLOR_TYPE == GRAY */ + else if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + if(row_info->bit_depth == 8) + { + /* This changes the data from RGB to RGBX */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + png_bytep sp = row + (png_size_t)row_width * 3; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 1; i < row_width; i++) + { + *(--dp) = lo_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = lo_filler; + row_info->channels = 4; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + /* This changes the data from RGB to XRGB */ + else + { + png_bytep sp = row + (png_size_t)row_width * 3; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = lo_filler; + } + row_info->channels = 4; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + } + } + else if(row_info->bit_depth == 16) + { + /* This changes the data from RRGGBB to RRGGBBXX */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + png_bytep sp = row + (png_size_t)row_width * 3; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 1; i < row_width; i++) + { + *(--dp) = hi_filler; + *(--dp) = lo_filler; + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + } + *(--dp) = hi_filler; + *(--dp) = lo_filler; + row_info->channels = 4; + row_info->pixel_depth = 64; + row_info->rowbytes = row_width * 8; + } + /* This changes the data from RRGGBB to XXRRGGBB */ + else + { + png_bytep sp = row + (png_size_t)row_width * 3; + png_bytep dp = sp + (png_size_t)row_width; + for (i = 0; i < row_width; i++) + { + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = *(--sp); + *(--dp) = hi_filler; + *(--dp) = lo_filler; + } + row_info->channels = 4; + row_info->pixel_depth = 64; + row_info->rowbytes = row_width * 8; + } + } + } /* COLOR_TYPE == RGB */ +} +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* expand grayscale files to RGB, with or without alpha */ +void /* PRIVATE */ +png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) +{ + png_uint_32 i; + png_uint_32 row_width = row_info->width; + + png_debug(1, "in png_do_gray_to_rgb\n"); + if (row_info->bit_depth >= 8 && +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + !(row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + if (row_info->bit_depth == 8) + { + png_bytep sp = row + (png_size_t)row_width - 1; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(dp--) = *sp; + *(dp--) = *sp; + *(dp--) = *(sp--); + } + } + else + { + png_bytep sp = row + (png_size_t)row_width * 2 - 1; + png_bytep dp = sp + (png_size_t)row_width * 4; + for (i = 0; i < row_width; i++) + { + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *(sp--); + *(dp--) = *(sp--); + } + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (row_info->bit_depth == 8) + { + png_bytep sp = row + (png_size_t)row_width * 2 - 1; + png_bytep dp = sp + (png_size_t)row_width * 2; + for (i = 0; i < row_width; i++) + { + *(dp--) = *(sp--); + *(dp--) = *sp; + *(dp--) = *sp; + *(dp--) = *(sp--); + } + } + else + { + png_bytep sp = row + (png_size_t)row_width * 4 - 1; + png_bytep dp = sp + (png_size_t)row_width * 4; + for (i = 0; i < row_width; i++) + { + *(dp--) = *(sp--); + *(dp--) = *(sp--); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *sp; + *(dp--) = *(sp - 1); + *(dp--) = *(sp--); + *(dp--) = *(sp--); + } + } + } + row_info->channels += (png_byte)2; + row_info->color_type |= PNG_COLOR_MASK_COLOR; + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = ((row_width * + row_info->pixel_depth + 7) >> 3); + } +} +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* reduce RGB files to grayscale, with or without alpha + * using the equation given in Poynton's ColorFAQ at + * + * Copyright (c) 1998-01-04 Charles Poynton poynton@inforamp.net + * + * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + * + * We approximate this with + * + * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + * + * which can be expressed with integers as + * + * Y = (6969 * R + 23434 * G + 2365 * B)/32768 + * + * The calculation is to be done in a linear colorspace. + * + * Other integer coefficents can be used via png_set_rgb_to_gray(). + */ +int /* PRIVATE */ +png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) + +{ + png_uint_32 i; + + png_uint_32 row_width = row_info->width; + int rgb_error = 0; + + png_debug(1, "in png_do_rgb_to_gray\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; + png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; + png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + + for (i = 0; i < row_width; i++) + { + png_byte red = png_ptr->gamma_to_1[*(sp++)]; + png_byte green = png_ptr->gamma_to_1[*(sp++)]; + png_byte blue = png_ptr->gamma_to_1[*(sp++)]; + if(red != green || red != blue) + { + rgb_error |= 1; + *(dp++) = png_ptr->gamma_from_1[ + (rc*red+gc*green+bc*blue)>>15]; + } + else + *(dp++) = *(sp-1); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + if(red != green || red != blue) + { + rgb_error |= 1; + *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); + } + else + *(dp++) = *(sp-1); + } + } + } + + else /* RGB bit_depth == 16 */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_to_1 != NULL && + png_ptr->gamma_16_from_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, w; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red == green && red == blue) + w = red; + else + { + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> + png_ptr->gamma_shift][red>>8]; + png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff)>> + png_ptr->gamma_shift][green>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> + png_ptr->gamma_shift][blue>>8]; + png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 + + bc*blue_1)>>15); + w = png_ptr->gamma_16_from_1[(gray16&0xff) >> + png_ptr->gamma_shift][gray16 >> 8]; + rgb_error |= 1; + } + + *(dp++) = (png_byte)((w>>8) & 0xff); + *(dp++) = (png_byte)(w & 0xff); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, gray16; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red != green || red != blue) + rgb_error |= 1; + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); + *(dp++) = (png_byte)((gray16>>8) & 0xff); + *(dp++) = (png_byte)(gray16 & 0xff); + } + } + } + } + if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_byte red = png_ptr->gamma_to_1[*(sp++)]; + png_byte green = png_ptr->gamma_to_1[*(sp++)]; + png_byte blue = png_ptr->gamma_to_1[*(sp++)]; + if(red != green || red != blue) + rgb_error |= 1; + *(dp++) = png_ptr->gamma_from_1 + [(rc*red + gc*green + bc*blue)>>15]; + *(dp++) = *(sp++); /* alpha */ + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_byte red = *(sp++); + png_byte green = *(sp++); + png_byte blue = *(sp++); + if(red != green || red != blue) + rgb_error |= 1; + *(dp++) = (png_byte)((gc*red + gc*green + bc*blue)>>8); + *(dp++) = *(sp++); /* alpha */ + } + } + } + else /* RGBA bit_depth == 16 */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->gamma_16_to_1 != NULL && + png_ptr->gamma_16_from_1 != NULL) + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, w; + + red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; + + if(red == green && red == blue) + w = red; + else + { + png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> + png_ptr->gamma_shift][red>>8]; + png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff)>> + png_ptr->gamma_shift][green>>8]; + png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> + png_ptr->gamma_shift][blue>>8]; + png_uint_16 gray16 = (png_uint_16)((rc * red_1 + + gc * green_1 + bc * blue_1)>>15); + w = png_ptr->gamma_16_from_1[(gray16&0xff) >> + png_ptr->gamma_shift][gray16 >> 8]; + rgb_error |= 1; + } + + *(dp++) = (png_byte)((w>>8) & 0xff); + *(dp++) = (png_byte)(w & 0xff); + *(dp++) = *(sp++); /* alpha */ + *(dp++) = *(sp++); + } + } + else +#endif + { + png_bytep sp = row; + png_bytep dp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 red, green, blue, gray16; + red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; + if(red != green || red != blue) + rgb_error |= 1; + gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); + *(dp++) = (png_byte)((gray16>>8) & 0xff); + *(dp++) = (png_byte)(gray16 & 0xff); + *(dp++) = *(sp++); /* alpha */ + *(dp++) = *(sp++); + } + } + } + } + row_info->channels -= (png_byte)2; + row_info->color_type &= ~PNG_COLOR_MASK_COLOR; + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = ((row_width * + row_info->pixel_depth + 7) >> 3); + } + return rgb_error; +} +#endif + +/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth + * large of png_color. This lets grayscale images be treated as + * paletted. Most useful for gamma correction and simplification + * of code. + */ +void PNGAPI +png_build_grayscale_palette(int bit_depth, png_colorp palette) +{ + int num_palette; + int color_inc; + int i; + int v; + + png_debug(1, "in png_do_build_grayscale_palette\n"); + if (palette == NULL) + return; + + switch (bit_depth) + { + case 1: + num_palette = 2; + color_inc = 0xff; + break; + case 2: + num_palette = 4; + color_inc = 0x55; + break; + case 4: + num_palette = 16; + color_inc = 0x11; + break; + case 8: + num_palette = 256; + color_inc = 1; + break; + default: + num_palette = 0; + color_inc = 0; + break; + } + + for (i = 0, v = 0; i < num_palette; i++, v += color_inc) + { + palette[i].red = (png_byte)v; + palette[i].green = (png_byte)v; + palette[i].blue = (png_byte)v; + } +} + +/* This function is currently unused. Do we really need it? */ +#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) +void /* PRIVATE */ +png_correct_palette(png_structp png_ptr, png_colorp palette, + int num_palette) +{ + png_debug(1, "in png_correct_palette\n"); +#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ + defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) + if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) + { + png_color back, back_1; + + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) + { + back.red = png_ptr->gamma_table[png_ptr->background.red]; + back.green = png_ptr->gamma_table[png_ptr->background.green]; + back.blue = png_ptr->gamma_table[png_ptr->background.blue]; + + back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; + back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; + back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; + } + else + { + double g; + + g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); + + if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || + fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) + { + back.red = png_ptr->background.red; + back.green = png_ptr->background.green; + back.blue = png_ptr->background.blue; + } + else + { + back.red = + (png_byte)(pow((double)png_ptr->background.red/255, g) * + 255.0 + 0.5); + back.green = + (png_byte)(pow((double)png_ptr->background.green/255, g) * + 255.0 + 0.5); + back.blue = + (png_byte)(pow((double)png_ptr->background.blue/255, g) * + 255.0 + 0.5); + } + + g = 1.0 / png_ptr->background_gamma; + + back_1.red = + (png_byte)(pow((double)png_ptr->background.red/255, g) * + 255.0 + 0.5); + back_1.green = + (png_byte)(pow((double)png_ptr->background.green/255, g) * + 255.0 + 0.5); + back_1.blue = + (png_byte)(pow((double)png_ptr->background.blue/255, g) * + 255.0 + 0.5); + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_uint_32 i; + + for (i = 0; i < (png_uint_32)num_palette; i++) + { + if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) + { + palette[i] = back; + } + else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) + { + png_byte v, w; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; + png_composite(w, v, png_ptr->trans[i], back_1.red); + palette[i].red = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; + png_composite(w, v, png_ptr->trans[i], back_1.green); + palette[i].green = png_ptr->gamma_from_1[w]; + + v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; + png_composite(w, v, png_ptr->trans[i], back_1.blue); + palette[i].blue = png_ptr->gamma_from_1[w]; + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } + else + { + int i; + + for (i = 0; i < num_palette; i++) + { + if (palette[i].red == (png_byte)png_ptr->trans_values.gray) + { + palette[i] = back; + } + else + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } + } + } + else +#endif +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (png_ptr->transformations & PNG_GAMMA) + { + int i; + + for (i = 0; i < num_palette; i++) + { + palette[i].red = png_ptr->gamma_table[palette[i].red]; + palette[i].green = png_ptr->gamma_table[palette[i].green]; + palette[i].blue = png_ptr->gamma_table[palette[i].blue]; + } + } +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + else +#endif +#endif +#if defined(PNG_READ_BACKGROUND_SUPPORTED) + if (png_ptr->transformations & PNG_BACKGROUND) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_color back; + + back.red = (png_byte)png_ptr->background.red; + back.green = (png_byte)png_ptr->background.green; + back.blue = (png_byte)png_ptr->background.blue; + + for (i = 0; i < (int)png_ptr->num_trans; i++) + { + if (png_ptr->trans[i] == 0) + { + palette[i].red = back.red; + palette[i].green = back.green; + palette[i].blue = back.blue; + } + else if (png_ptr->trans[i] != 0xff) + { + png_composite(palette[i].red, png_ptr->palette[i].red, + png_ptr->trans[i], back.red); + png_composite(palette[i].green, png_ptr->palette[i].green, + png_ptr->trans[i], back.green); + png_composite(palette[i].blue, png_ptr->palette[i].blue, + png_ptr->trans[i], back.blue); + } + } + } + else /* assume grayscale palette (what else could it be?) */ + { + int i; + + for (i = 0; i < num_palette; i++) + { + if (i == (png_byte)png_ptr->trans_values.gray) + { + palette[i].red = (png_byte)png_ptr->background.red; + palette[i].green = (png_byte)png_ptr->background.green; + palette[i].blue = (png_byte)png_ptr->background.blue; + } + } + } + } +#endif +} +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Replace any alpha or transparency with the supplied background color. + * "background" is already in the screen gamma, while "background_1" is + * at a gamma of 1.0. Paletted files have already been taken care of. + */ +void /* PRIVATE */ +png_do_background(png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background +#if defined(PNG_READ_GAMMA_SUPPORTED) + , png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift +#endif + ) +{ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + int shift; + + png_debug(1, "in png_do_background\n"); + if (background != NULL && +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || + (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) + { + switch (row_info->color_type) + { + case PNG_COLOR_TYPE_GRAY: + { + switch (row_info->bit_depth) + { + case 1: + { + sp = row; + shift = 7; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x01) + == trans_values->gray) + { + *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + if (!shift) + { + shift = 7; + sp++; + } + else + shift--; + } + break; + } + case 2: + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_table != NULL) + { + sp = row; + shift = 6; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x03) + == trans_values->gray) + { + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + else + { + png_byte p = (png_byte)((*sp >> shift) & 0x03); + png_byte g = (png_byte)((gamma_table [p | (p << 2) | + (p << 4) | (p << 6)] >> 6) & 0x03); + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(g << shift); + } + if (!shift) + { + shift = 6; + sp++; + } + else + shift -= 2; + } + } + else +#endif + { + sp = row; + shift = 6; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x03) + == trans_values->gray) + { + *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + if (!shift) + { + shift = 6; + sp++; + } + else + shift -= 2; + } + } + break; + } + case 4: + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_table != NULL) + { + sp = row; + shift = 4; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x0f) + == trans_values->gray) + { + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + else + { + png_byte p = (png_byte)((*sp >> shift) & 0x0f); + png_byte g = (png_byte)((gamma_table[p | + (p << 4)] >> 4) & 0x0f); + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(g << shift); + } + if (!shift) + { + shift = 4; + sp++; + } + else + shift -= 4; + } + } + else +#endif + { + sp = row; + shift = 4; + for (i = 0; i < row_width; i++) + { + if ((png_uint_16)((*sp >> shift) & 0x0f) + == trans_values->gray) + { + *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *sp |= (png_byte)(background->gray << shift); + } + if (!shift) + { + shift = 4; + sp++; + } + else + shift -= 4; + } + } + break; + } + case 8: + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_table != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp++) + { + if (*sp == trans_values->gray) + { + *sp = (png_byte)background->gray; + } + else + { + *sp = gamma_table[*sp]; + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp++) + { + if (*sp == trans_values->gray) + { + *sp = (png_byte)background->gray; + } + } + } + break; + } + case 16: + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_16 != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 2) + { + png_uint_16 v; + + v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + if (v == trans_values->gray) + { + /* background is already in screen gamma */ + *sp = (png_byte)((background->gray >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->gray & 0xff); + } + else + { + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 2) + { + png_uint_16 v; + + v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + if (v == trans_values->gray) + { + *sp = (png_byte)((background->gray >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->gray & 0xff); + } + } + } + break; + } + } + break; + } + case PNG_COLOR_TYPE_RGB: + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_table != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 3) + { + if (*sp == trans_values->red && + *(sp + 1) == trans_values->green && + *(sp + 2) == trans_values->blue) + { + *sp = (png_byte)background->red; + *(sp + 1) = (png_byte)background->green; + *(sp + 2) = (png_byte)background->blue; + } + else + { + *sp = gamma_table[*sp]; + *(sp + 1) = gamma_table[*(sp + 1)]; + *(sp + 2) = gamma_table[*(sp + 2)]; + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 3) + { + if (*sp == trans_values->red && + *(sp + 1) == trans_values->green && + *(sp + 2) == trans_values->blue) + { + *sp = (png_byte)background->red; + *(sp + 1) = (png_byte)background->green; + *(sp + 2) = (png_byte)background->blue; + } + } + } + } + else /* if (row_info->bit_depth == 16) */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_16 != NULL) + { + sp = row; + for (i = 0; i < row_width; i++, sp += 6) + { + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); + if (r == trans_values->red && g == trans_values->green && + b == trans_values->blue) + { + /* background is already in screen gamma */ + *sp = (png_byte)((background->red >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->red & 0xff); + *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(sp + 3) = (png_byte)(background->green & 0xff); + *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(sp + 5) = (png_byte)(background->blue & 0xff); + } + else + { + png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; + *(sp + 2) = (png_byte)((v >> 8) & 0xff); + *(sp + 3) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; + *(sp + 4) = (png_byte)((v >> 8) & 0xff); + *(sp + 5) = (png_byte)(v & 0xff); + } + } + } + else +#endif + { + sp = row; + for (i = 0; i < row_width; i++, sp += 6) + { + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); + png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); + + if (r == trans_values->red && g == trans_values->green && + b == trans_values->blue) + { + *sp = (png_byte)((background->red >> 8) & 0xff); + *(sp + 1) = (png_byte)(background->red & 0xff); + *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(sp + 3) = (png_byte)(background->green & 0xff); + *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(sp + 5) = (png_byte)(background->blue & 0xff); + } + } + } + } + break; + } + case PNG_COLOR_TYPE_GRAY_ALPHA: + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_to_1 != NULL && gamma_from_1 != NULL && + gamma_table != NULL) + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 2, dp++) + { + png_uint_16 a = *(sp + 1); + + if (a == 0xff) + { + *dp = gamma_table[*sp]; + } + else if (a == 0) + { + /* background is already in screen gamma */ + *dp = (png_byte)background->gray; + } + else + { + png_byte v, w; + + v = gamma_to_1[*sp]; + png_composite(w, v, a, background_1->gray); + *dp = gamma_from_1[w]; + } + } + } + else +#endif + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 2, dp++) + { + png_byte a = *(sp + 1); + + if (a == 0xff) + { + *dp = *sp; + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) + { + *dp = (png_byte)background->gray; + } + else + { + png_composite(*dp, *sp, a, background_1->gray); + } +#else + *dp = (png_byte)background->gray; +#endif + } + } + } + else /* if (png_ptr->bit_depth == 16) */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_16 != NULL && gamma_16_from_1 != NULL && + gamma_16_to_1 != NULL) + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 2) + { + png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + + if (a == (png_uint_16)0xffff) + { + png_uint_16 v; + + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) +#else + else +#endif + { + /* background is already in screen gamma */ + *dp = (png_byte)((background->gray >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->gray & 0xff); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else + { + png_uint_16 g, v, w; + + g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; + png_composite_16(v, g, a, background_1->gray); + w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; + *dp = (png_byte)((w >> 8) & 0xff); + *(dp + 1) = (png_byte)(w & 0xff); + } +#endif + } + } + else +#endif + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 2) + { + png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); + if (a == (png_uint_16)0xffff) + { + png_memcpy(dp, sp, 2); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else if (a == 0) +#else + else +#endif + { + *dp = (png_byte)((background->gray >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->gray & 0xff); + } +#if defined(PNG_READ_GAMMA_SUPPORTED) + else + { + png_uint_16 g, v; + + g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_composite_16(v, g, a, background_1->gray); + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + } +#endif + } + } + } + break; + } + case PNG_COLOR_TYPE_RGB_ALPHA: + { + if (row_info->bit_depth == 8) + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_to_1 != NULL && gamma_from_1 != NULL && + gamma_table != NULL) + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 3) + { + png_byte a = *(sp + 3); + + if (a == 0xff) + { + *dp = gamma_table[*sp]; + *(dp + 1) = gamma_table[*(sp + 1)]; + *(dp + 2) = gamma_table[*(sp + 2)]; + } + else if (a == 0) + { + /* background is already in screen gamma */ + *dp = (png_byte)background->red; + *(dp + 1) = (png_byte)background->green; + *(dp + 2) = (png_byte)background->blue; + } + else + { + png_byte v, w; + + v = gamma_to_1[*sp]; + png_composite(w, v, a, background_1->red); + *dp = gamma_from_1[w]; + v = gamma_to_1[*(sp + 1)]; + png_composite(w, v, a, background_1->green); + *(dp + 1) = gamma_from_1[w]; + v = gamma_to_1[*(sp + 2)]; + png_composite(w, v, a, background_1->blue); + *(dp + 2) = gamma_from_1[w]; + } + } + } + else +#endif + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 4, dp += 3) + { + png_byte a = *(sp + 3); + + if (a == 0xff) + { + *dp = *sp; + *(dp + 1) = *(sp + 1); + *(dp + 2) = *(sp + 2); + } + else if (a == 0) + { + *dp = (png_byte)background->red; + *(dp + 1) = (png_byte)background->green; + *(dp + 2) = (png_byte)background->blue; + } + else + { + png_composite(*dp, *sp, a, background->red); + png_composite(*(dp + 1), *(sp + 1), a, + background->green); + png_composite(*(dp + 2), *(sp + 2), a, + background->blue); + } + } + } + } + else /* if (row_info->bit_depth == 16) */ + { +#if defined(PNG_READ_GAMMA_SUPPORTED) + if (gamma_16 != NULL && gamma_16_from_1 != NULL && + gamma_16_to_1 != NULL) + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 8, dp += 6) + { + png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) + << 8) + (png_uint_16)(*(sp + 7))); + if (a == (png_uint_16)0xffff) + { + png_uint_16 v; + + v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; + *(dp + 2) = (png_byte)((v >> 8) & 0xff); + *(dp + 3) = (png_byte)(v & 0xff); + v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; + *(dp + 4) = (png_byte)((v >> 8) & 0xff); + *(dp + 5) = (png_byte)(v & 0xff); + } + else if (a == 0) + { + /* background is already in screen gamma */ + *dp = (png_byte)((background->red >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->red & 0xff); + *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(dp + 3) = (png_byte)(background->green & 0xff); + *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(dp + 5) = (png_byte)(background->blue & 0xff); + } + else + { + png_uint_16 v, w, x; + + v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; + png_composite_16(w, v, a, background_1->red); + x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + *dp = (png_byte)((x >> 8) & 0xff); + *(dp + 1) = (png_byte)(x & 0xff); + v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; + png_composite_16(w, v, a, background_1->green); + x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; + *(dp + 2) = (png_byte)((x >> 8) & 0xff); + *(dp + 3) = (png_byte)(x & 0xff); + v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; + png_composite_16(w, v, a, background_1->blue); + x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; + *(dp + 4) = (png_byte)((x >> 8) & 0xff); + *(dp + 5) = (png_byte)(x & 0xff); + } + } + } + else +#endif + { + sp = row; + dp = row; + for (i = 0; i < row_width; i++, sp += 8, dp += 6) + { + png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) + << 8) + (png_uint_16)(*(sp + 7))); + if (a == (png_uint_16)0xffff) + { + png_memcpy(dp, sp, 6); + } + else if (a == 0) + { + *dp = (png_byte)((background->red >> 8) & 0xff); + *(dp + 1) = (png_byte)(background->red & 0xff); + *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); + *(dp + 3) = (png_byte)(background->green & 0xff); + *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); + *(dp + 5) = (png_byte)(background->blue & 0xff); + } + else + { + png_uint_16 v; + + png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); + png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) + + *(sp + 3)); + png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + + *(sp + 5)); + + png_composite_16(v, r, a, background->red); + *dp = (png_byte)((v >> 8) & 0xff); + *(dp + 1) = (png_byte)(v & 0xff); + png_composite_16(v, g, a, background->green); + *(dp + 2) = (png_byte)((v >> 8) & 0xff); + *(dp + 3) = (png_byte)(v & 0xff); + png_composite_16(v, b, a, background->blue); + *(dp + 4) = (png_byte)((v >> 8) & 0xff); + *(dp + 5) = (png_byte)(v & 0xff); + } + } + } + } + break; + } + } + + if (row_info->color_type & PNG_COLOR_MASK_ALPHA) + { + row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; + row_info->channels--; + row_info->pixel_depth = (png_byte)(row_info->channels * + row_info->bit_depth); + row_info->rowbytes = ((row_width * + row_info->pixel_depth + 7) >> 3); + } + } +} +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Gamma correct the image, avoiding the alpha channel. Make sure + * you do this after you deal with the transparency issue on grayscale + * or RGB images. If your bit depth is 8, use gamma_table, if it + * is 16, use gamma_16_table and gamma_shift. Build these with + * build_gamma_table(). + */ +void /* PRIVATE */ +png_do_gamma(png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift) +{ + png_bytep sp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_gamma\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + ((row_info->bit_depth <= 8 && gamma_table != NULL) || + (row_info->bit_depth == 16 && gamma_16_table != NULL))) + { + switch (row_info->color_type) + { + case PNG_COLOR_TYPE_RGB: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + } + } + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v; + + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + } + } + break; + } + case PNG_COLOR_TYPE_RGB_ALPHA: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + *sp = gamma_table[*sp]; + sp++; + sp++; + } + } + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 4; + } + } + break; + } + case PNG_COLOR_TYPE_GRAY_ALPHA: + { + if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp += 2; + } + } + else /* if (row_info->bit_depth == 16) */ + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 4; + } + } + break; + } + case PNG_COLOR_TYPE_GRAY: + { + if (row_info->bit_depth == 2) + { + sp = row; + for (i = 0; i < row_width; i += 4) + { + int a = *sp & 0xc0; + int b = *sp & 0x30; + int c = *sp & 0x0c; + int d = *sp & 0x03; + + *sp = (png_byte)( + ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) &0xc0)| + ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) &0x30)| + ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) &0x0c)| + ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); + sp++; + } + } + if (row_info->bit_depth == 4) + { + sp = row; + for (i = 0; i < row_width; i += 2) + { + int msb = *sp & 0xf0; + int lsb = *sp & 0x0f; + + *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) + | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); + sp++; + } + } + else if (row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++) + { + *sp = gamma_table[*sp]; + sp++; + } + } + else if (row_info->bit_depth == 16) + { + sp = row; + for (i = 0; i < row_width; i++) + { + png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; + *sp = (png_byte)((v >> 8) & 0xff); + *(sp + 1) = (png_byte)(v & 0xff); + sp += 2; + } + } + break; + } + } + } +} +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expands a palette row to an RGB or RGBA row depending + * upon whether you supply trans and num_trans. + */ +void /* PRIVATE */ +png_do_expand_palette(png_row_infop row_info, png_bytep row, + png_colorp palette, png_bytep trans, int num_trans) +{ + int shift, value; + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_expand_palette\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (row_info->bit_depth < 8) + { + switch (row_info->bit_depth) + { + case 1: + { + sp = row + (png_size_t)((row_width - 1) >> 3); + dp = row + (png_size_t)row_width - 1; + shift = 7 - (int)((row_width + 7) & 0x07); + for (i = 0; i < row_width; i++) + { + if ((*sp >> shift) & 0x01) + *dp = 1; + else + *dp = 0; + if (shift == 7) + { + shift = 0; + sp--; + } + else + shift++; + + dp--; + } + break; + } + case 2: + { + sp = row + (png_size_t)((row_width - 1) >> 2); + dp = row + (png_size_t)row_width - 1; + shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x03; + *dp = (png_byte)value; + if (shift == 6) + { + shift = 0; + sp--; + } + else + shift += 2; + + dp--; + } + break; + } + case 4: + { + sp = row + (png_size_t)((row_width - 1) >> 1); + dp = row + (png_size_t)row_width - 1; + shift = (int)((row_width & 0x01) << 2); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x0f; + *dp = (png_byte)value; + if (shift == 4) + { + shift = 0; + sp--; + } + else + shift += 4; + + dp--; + } + break; + } + } + row_info->bit_depth = 8; + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + switch (row_info->bit_depth) + { + case 8: + { + if (trans != NULL) + { + sp = row + (png_size_t)row_width - 1; + dp = row + (png_size_t)(row_width << 2) - 1; + + for (i = 0; i < row_width; i++) + { + if ((int)(*sp) >= num_trans) + *dp-- = 0xff; + else + *dp-- = trans[*sp]; + *dp-- = palette[*sp].blue; + *dp-- = palette[*sp].green; + *dp-- = palette[*sp].red; + sp--; + } + row_info->bit_depth = 8; + row_info->pixel_depth = 32; + row_info->rowbytes = row_width * 4; + row_info->color_type = 6; + row_info->channels = 4; + } + else + { + sp = row + (png_size_t)row_width - 1; + dp = row + (png_size_t)(row_width * 3) - 1; + + for (i = 0; i < row_width; i++) + { + *dp-- = palette[*sp].blue; + *dp-- = palette[*sp].green; + *dp-- = palette[*sp].red; + sp--; + } + row_info->bit_depth = 8; + row_info->pixel_depth = 24; + row_info->rowbytes = row_width * 3; + row_info->color_type = 2; + row_info->channels = 3; + } + break; + } + } + } +} + +/* If the bit depth < 8, it is expanded to 8. Also, if the + * transparency value is supplied, an alpha channel is built. + */ +void /* PRIVATE */ +png_do_expand(png_row_infop row_info, png_bytep row, + png_color_16p trans_value) +{ + int shift, value; + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_expand\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); + + if (row_info->bit_depth < 8) + { + switch (row_info->bit_depth) + { + case 1: + { + gray = (png_uint_16)(gray*0xff); + sp = row + (png_size_t)((row_width - 1) >> 3); + dp = row + (png_size_t)row_width - 1; + shift = 7 - (int)((row_width + 7) & 0x07); + for (i = 0; i < row_width; i++) + { + if ((*sp >> shift) & 0x01) + *dp = 0xff; + else + *dp = 0; + if (shift == 7) + { + shift = 0; + sp--; + } + else + shift++; + + dp--; + } + break; + } + case 2: + { + gray = (png_uint_16)(gray*0x55); + sp = row + (png_size_t)((row_width - 1) >> 2); + dp = row + (png_size_t)row_width - 1; + shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x03; + *dp = (png_byte)(value | (value << 2) | (value << 4) | + (value << 6)); + if (shift == 6) + { + shift = 0; + sp--; + } + else + shift += 2; + + dp--; + } + break; + } + case 4: + { + gray = (png_uint_16)(gray*0x11); + sp = row + (png_size_t)((row_width - 1) >> 1); + dp = row + (png_size_t)row_width - 1; + shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); + for (i = 0; i < row_width; i++) + { + value = (*sp >> shift) & 0x0f; + *dp = (png_byte)(value | (value << 4)); + if (shift == 4) + { + shift = 0; + sp--; + } + else + shift = 4; + + dp--; + } + break; + } + } + row_info->bit_depth = 8; + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + + if (trans_value != NULL) + { + if (row_info->bit_depth == 8) + { + sp = row + (png_size_t)row_width - 1; + dp = row + (png_size_t)(row_width << 1) - 1; + for (i = 0; i < row_width; i++) + { + if (*sp == gray) + *dp-- = 0; + else + *dp-- = 0xff; + *dp-- = *sp--; + } + } + else if (row_info->bit_depth == 16) + { + sp = row + row_info->rowbytes - 1; + dp = row + (row_info->rowbytes << 1) - 1; + for (i = 0; i < row_width; i++) + { + if (((png_uint_16)*(sp) | + ((png_uint_16)*(sp - 1) << 8)) == gray) + { + *dp-- = 0; + *dp-- = 0; + } + else + { + *dp-- = 0xff; + *dp-- = 0xff; + } + *dp-- = *sp--; + *dp-- = *sp--; + } + } + row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; + row_info->channels = 2; + row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); + row_info->rowbytes = + ((row_width * row_info->pixel_depth) >> 3); + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) + { + if (row_info->bit_depth == 8) + { + sp = row + (png_size_t)row_info->rowbytes - 1; + dp = row + (png_size_t)(row_width << 2) - 1; + for (i = 0; i < row_width; i++) + { + if (*(sp - 2) == trans_value->red && + *(sp - 1) == trans_value->green && + *(sp - 0) == trans_value->blue) + *dp-- = 0; + else + *dp-- = 0xff; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + } + } + else if (row_info->bit_depth == 16) + { + sp = row + row_info->rowbytes - 1; + dp = row + (png_size_t)(row_width << 3) - 1; + for (i = 0; i < row_width; i++) + { + if ((((png_uint_16)*(sp - 4) | + ((png_uint_16)*(sp - 5) << 8)) == trans_value->red) && + (((png_uint_16)*(sp - 2) | + ((png_uint_16)*(sp - 3) << 8)) == trans_value->green) && + (((png_uint_16)*(sp - 0) | + ((png_uint_16)*(sp - 1) << 8)) == trans_value->blue)) + { + *dp-- = 0; + *dp-- = 0; + } + else + { + *dp-- = 0xff; + *dp-- = 0xff; + } + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + *dp-- = *sp--; + } + } + row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; + row_info->channels = 4; + row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); + row_info->rowbytes = + ((row_width * row_info->pixel_depth) >> 3); + } + } +} +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +void /* PRIVATE */ +png_do_dither(png_row_infop row_info, png_bytep row, + png_bytep palette_lookup, png_bytep dither_lookup) +{ + png_bytep sp, dp; + png_uint_32 i; + png_uint_32 row_width=row_info->width; + + png_debug(1, "in png_do_dither\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB && + palette_lookup && row_info->bit_depth == 8) + { + int r, g, b, p; + sp = row; + dp = row; + for (i = 0; i < row_width; i++) + { + r = *sp++; + g = *sp++; + b = *sp++; + + /* this looks real messy, but the compiler will reduce + it down to a reasonable formula. For example, with + 5 bits per color, we get: + p = (((r >> 3) & 0x1f) << 10) | + (((g >> 3) & 0x1f) << 5) | + ((b >> 3) & 0x1f); + */ + p = (((r >> (8 - PNG_DITHER_RED_BITS)) & + ((1 << PNG_DITHER_RED_BITS) - 1)) << + (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | + (((g >> (8 - PNG_DITHER_GREEN_BITS)) & + ((1 << PNG_DITHER_GREEN_BITS) - 1)) << + (PNG_DITHER_BLUE_BITS)) | + ((b >> (8 - PNG_DITHER_BLUE_BITS)) & + ((1 << PNG_DITHER_BLUE_BITS) - 1)); + + *dp++ = palette_lookup[p]; + } + row_info->color_type = PNG_COLOR_TYPE_PALETTE; + row_info->channels = 1; + row_info->pixel_depth = row_info->bit_depth; + row_info->rowbytes = + ((row_width * row_info->pixel_depth + 7) >> 3); + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && + palette_lookup != NULL && row_info->bit_depth == 8) + { + int r, g, b, p; + sp = row; + dp = row; + for (i = 0; i < row_width; i++) + { + r = *sp++; + g = *sp++; + b = *sp++; + sp++; + + p = (((r >> (8 - PNG_DITHER_RED_BITS)) & + ((1 << PNG_DITHER_RED_BITS) - 1)) << + (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | + (((g >> (8 - PNG_DITHER_GREEN_BITS)) & + ((1 << PNG_DITHER_GREEN_BITS) - 1)) << + (PNG_DITHER_BLUE_BITS)) | + ((b >> (8 - PNG_DITHER_BLUE_BITS)) & + ((1 << PNG_DITHER_BLUE_BITS) - 1)); + + *dp++ = palette_lookup[p]; + } + row_info->color_type = PNG_COLOR_TYPE_PALETTE; + row_info->channels = 1; + row_info->pixel_depth = row_info->bit_depth; + row_info->rowbytes = + ((row_width * row_info->pixel_depth + 7) >> 3); + } + else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && + dither_lookup && row_info->bit_depth == 8) + { + sp = row; + for (i = 0; i < row_width; i++, sp++) + { + *sp = dither_lookup[*sp]; + } + } + } +} +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +#if defined(PNG_READ_GAMMA_SUPPORTED) +static int png_gamma_shift[] = + {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0}; + +/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit + * tables, we don't make a full table if we are reducing to 8-bit in + * the future. Note also how the gamma_16 tables are segmented so that + * we don't need to allocate > 64K chunks for a full 16-bit table. + */ +void /* PRIVATE */ +png_build_gamma_table(png_structp png_ptr) +{ + png_debug(1, "in png_build_gamma_table\n"); + if(png_ptr->gamma != 0.0) + { + if (png_ptr->bit_depth <= 8) + { + int i; + double g; + + if (png_ptr->screen_gamma > .000001) + g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + else + g = 1.0; + + png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + } + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) + { + + g = 1.0 / (png_ptr->gamma); + + png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + } + + + png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + + if(png_ptr->screen_gamma > 0.000001) + g = 1.0 / png_ptr->screen_gamma; + else + g = png_ptr->gamma; /* probably doing rgb_to_gray */ + + for (i = 0; i < 256; i++) + { + png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, + g) * 255.0 + .5); + + } + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ + } + else + { + double g; + int i, j, shift, num; + int sig_bit; + png_uint_32 ig; + + if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit = (int)png_ptr->sig_bit.red; + if ((int)png_ptr->sig_bit.green > sig_bit) + sig_bit = png_ptr->sig_bit.green; + if ((int)png_ptr->sig_bit.blue > sig_bit) + sig_bit = png_ptr->sig_bit.blue; + } + else + { + sig_bit = (int)png_ptr->sig_bit.gray; + } + + if (sig_bit > 0) + shift = 16 - sig_bit; + else + shift = 0; + + if (png_ptr->transformations & PNG_16_TO_8) + { + if (shift < (16 - PNG_MAX_GAMMA_8)) + shift = (16 - PNG_MAX_GAMMA_8); + } + + if (shift > 8) + shift = 8; + if (shift < 0) + shift = 0; + + png_ptr->gamma_shift = (png_byte)shift; + + num = (1 << (8 - shift)); + + if (png_ptr->screen_gamma > .000001) + g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + else + g = 1.0; + + png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * sizeof (png_uint_16p))); + + if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) + { + double fin, fout; + png_uint_32 last, max; + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * sizeof (png_uint_16))); + } + + g = 1.0 / g; + last = 0; + for (i = 0; i < 256; i++) + { + fout = ((double)i + 0.5) / 256.0; + fin = pow(fout, g); + max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); + while (last <= max) + { + png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] + [(int)(last >> (8 - shift))] = (png_uint_16)( + (png_uint_16)i | ((png_uint_16)i << 8)); + last++; + } + } + while (last < ((png_uint_32)num << 8)) + { + png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] + [(int)(last >> (8 - shift))] = (png_uint_16)65535L; + last++; + } + } + else + { + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * sizeof (png_uint_16))); + + ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_table[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + } + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) + { + + g = 1.0 / (png_ptr->gamma); + + png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * sizeof (png_uint_16p ))); + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * sizeof (png_uint_16))); + + ig = (((png_uint_32)i * + (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_to_1[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + + if(png_ptr->screen_gamma > 0.000001) + g = 1.0 / png_ptr->screen_gamma; + else + g = png_ptr->gamma; /* probably doing rgb_to_gray */ + + png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, + (png_uint_32)(num * sizeof (png_uint_16p))); + + for (i = 0; i < num; i++) + { + png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(256 * sizeof (png_uint_16))); + + ig = (((png_uint_32)i * + (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) + { + png_ptr->gamma_16_from_1[i][j] = + (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / + 65535.0, g) * 65535.0 + .5); + } + } + } +#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ + } + } +} +#endif +/* To do: install integer version of png_build_gamma_table here */ +#endif + +#if defined(PNG_MNG_FEATURES_SUPPORTED) +/* undoes intrapixel differencing */ +void /* PRIVATE */ +png_do_read_intrapixel(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_read_intrapixel\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + int bytes_per_pixel; + png_uint_32 row_width = row_info->width; + if (row_info->bit_depth == 8) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 3; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 4; + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); + *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); + } + } + else if (row_info->bit_depth == 16) + { + png_bytep rp; + png_uint_32 i; + + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + bytes_per_pixel = 6; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + bytes_per_pixel = 8; + else + return; + + for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) + { + png_uint_32 s0=*(rp )<<8 | *(rp+1); + png_uint_32 s1=*(rp+2)<<8 | *(rp+3); + png_uint_32 s2=*(rp+4)<<8 | *(rp+5); + png_uint_32 red=(65536+s0+s1)&0xffff; + png_uint_32 blue=(65536+s2+s1)&0xffff; + *(rp ) = (png_byte)((red>>8)&0xff); + *(rp+1) = (png_byte)(red&0xff); + *(rp+4) = (png_byte)((blue>>8)&0xff); + *(rp+5) = (png_byte)(blue&0xff); + } + } + } +} +#endif /* PNG_MNG_FEATURES_SUPPORTED */ diff --git a/src/libs/pdflib/libs/png/pngrutil.c b/src/libs/pdflib/libs/png/pngrutil.c new file mode 100644 index 0000000000..6dcafdcb70 --- /dev/null +++ b/src/libs/pdflib/libs/png/pngrutil.c @@ -0,0 +1,3104 @@ +/* PDFlib GmbH cvsid: $Id: pngrutil.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngrutil.c - utilities to read a PNG file + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This file contains routines that are only called from within + * libpng itself during the course of reading an image. + */ + +#define PNG_INTERNAL +#include "png.h" + +#if 0 /* PDFlib GmbH: */ +#if defined(_WIN32_WCE) +/* strtod() function is not supported on WindowsCE */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +__inline double strtod(const char *nptr, char **endptr) +{ + double result = 0; + int len; + wchar_t *str, *end; + + len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); + str = (wchar_t *)malloc(len * sizeof(wchar_t)); + if ( NULL != str ) + { + MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); + result = wcstod(str, &end); + len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); + *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); + free(str); + } + return result; +} +# endif +#endif +#endif /* PDFlib GmbH: */ + +#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED +/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ +png_uint_32 /* PRIVATE */ +png_get_uint_32(png_bytep buf) +{ + png_uint_32 i = ((png_uint_32)(*buf) << 24) + + ((png_uint_32)(*(buf + 1)) << 16) + + ((png_uint_32)(*(buf + 2)) << 8) + + (png_uint_32)(*(buf + 3)); + + return (i); +} + +#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED) +/* Grab a signed 32-bit integer from a buffer in big-endian format. The + * data is stored in the PNG file in two's complement format, and it is + * assumed that the machine format for signed integers is the same. */ +png_int_32 /* PRIVATE */ +png_get_int_32(png_bytep buf) +{ + png_int_32 i = ((png_int_32)(*buf) << 24) + + ((png_int_32)(*(buf + 1)) << 16) + + ((png_int_32)(*(buf + 2)) << 8) + + (png_int_32)(*(buf + 3)); + + return (i); +} +#endif /* PNG_READ_pCAL_SUPPORTED */ + +/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ +png_uint_16 /* PRIVATE */ +png_get_uint_16(png_bytep buf) +{ + png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + + (png_uint_16)(*(buf + 1))); + + return (i); +} +#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ + +/* Read data, and (optionally) run it through the CRC. */ +void /* PRIVATE */ +png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) +{ + png_read_data(png_ptr, buf, length); + png_calculate_crc(png_ptr, buf, length); +} + +/* Optionally skip data and then check the CRC. Depending on whether we + are reading a ancillary or critical chunk, and how the program has set + things up, we may calculate the CRC on the data and print a message. + Returns '1' if there was a CRC error, '0' otherwise. */ +int /* PRIVATE */ +png_crc_finish(png_structp png_ptr, png_uint_32 skip) +{ + png_size_t i; + png_size_t istop = png_ptr->zbuf_size; + + for (i = (png_size_t)skip; i > istop; i -= istop) + { + png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); + } + if (i) + { + png_crc_read(png_ptr, png_ptr->zbuf, i); + } + + if (png_crc_error(png_ptr)) + { + if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ + !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || + (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ + (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) + { + png_chunk_warning(png_ptr, "CRC error"); + } + else + { + png_chunk_error(png_ptr, "CRC error"); + } + return (1); + } + + return (0); +} + +/* Compare the CRC stored in the PNG file with that calculated by libpng from + the data it has read thus far. */ +int /* PRIVATE */ +png_crc_error(png_structp png_ptr) +{ + png_byte crc_bytes[4]; + png_uint_32 crc; + int need_crc = 1; + + if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ + { + if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == + (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) + need_crc = 0; + } + else /* critical */ + { + if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) + need_crc = 0; + } + + png_read_data(png_ptr, crc_bytes, 4); + + if (need_crc) + { + crc = png_get_uint_32(crc_bytes); + return ((int)(crc != png_ptr->crc)); + } + else + return (0); +} + +#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ + defined(PNG_READ_iCCP_SUPPORTED) +/* + * Decompress trailing data in a chunk. The assumption is that chunkdata + * points at an allocated area holding the contents of a chunk with a + * trailing compressed part. What we get back is an allocated area + * holding the original prefix part and an uncompressed version of the + * trailing part (the malloc area passed in is freed). + */ +png_charp /* PRIVATE */ +png_decompress_chunk(png_structp png_ptr, int comp_type, + png_charp chunkdata, png_size_t chunklength, + png_size_t prefix_size, png_size_t *newlength) +{ + static char msg[] = "Error decoding compressed text"; + png_charp text = NULL; + png_size_t text_size; + + if (comp_type == PNG_COMPRESSION_TYPE_BASE) + { + int ret = Z_OK; + png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); + png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + + text_size = 0; + text = NULL; + + while (png_ptr->zstream.avail_in) + { + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret != Z_OK && ret != Z_STREAM_END) + { + if (png_ptr->zstream.msg != NULL) + png_warning(png_ptr, png_ptr->zstream.msg); + else + png_warning(png_ptr, msg); + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + + if (text == NULL) + { + text_size = prefix_size + sizeof(msg) + 1; + text = (png_charp)png_malloc_warn(png_ptr, text_size); + if (text == NULL) + { + png_free(png_ptr,chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk"); + } + png_memcpy(text, chunkdata, prefix_size); + } + + text[text_size - 1] = 0x00; + + /* Copy what we can of the error message into the text chunk */ + text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); + text_size = sizeof(msg) > text_size ? text_size : sizeof(msg); + png_memcpy(text + prefix_size, msg, text_size + 1); + break; + } + if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) + { + if (text == NULL) + { + text_size = prefix_size + + png_ptr->zbuf_size - png_ptr->zstream.avail_out; + text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); + if (text == NULL) + { + png_free(png_ptr,chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk."); + } + png_memcpy(text + prefix_size, png_ptr->zbuf, + text_size - prefix_size); + png_memcpy(text, chunkdata, prefix_size); + *(text + text_size) = 0x00; + } + else + { + png_charp tmp; + + tmp = text; + text = (png_charp)png_malloc_warn(png_ptr, + (png_uint_32)(text_size + + png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); + if (text == NULL) + { + png_free(png_ptr, tmp); + png_free(png_ptr, chunkdata); + png_error(png_ptr,"Not enough memory to decompress chunk.."); + } + png_memcpy(text, tmp, text_size); + png_free(png_ptr, tmp); + png_memcpy(text + text_size, png_ptr->zbuf, + (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); + text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; + *(text + text_size) = 0x00; + } + if (ret == Z_STREAM_END) + break; + else + { + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; + } + } + } + if (ret != Z_STREAM_END) + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char umsg[50]; + + if (ret == Z_BUF_ERROR) + sprintf(umsg,"Buffer error in compressed datastream in %s chunk", + png_ptr->chunk_name); + else if (ret == Z_DATA_ERROR) + sprintf(umsg,"Data error in compressed datastream in %s chunk", + png_ptr->chunk_name); + else + sprintf(umsg,"Incomplete compressed datastream in %s chunk", + png_ptr->chunk_name); + png_warning(png_ptr, umsg); +#else + png_warning(png_ptr, + "Incomplete compressed datastream in chunk other than IDAT"); +#endif + text_size=prefix_size; + if (text == NULL) + { + text = (png_charp)png_malloc_warn(png_ptr, text_size+1); + if (text == NULL) + { + png_free(png_ptr, chunkdata); + png_error(png_ptr,"Not enough memory for text."); + } + png_memcpy(text, chunkdata, prefix_size); + } + *(text + text_size) = 0x00; + } + + inflateReset(&png_ptr->zstream); + png_ptr->zstream.avail_in = 0; + + png_free(png_ptr, chunkdata); + chunkdata = text; + *newlength=text_size; + } + else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ + { +#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) + char umsg[50]; + + sprintf(umsg, "Unknown zTXt compression type %d", comp_type); + png_warning(png_ptr, umsg); +#else + png_warning(png_ptr, "Unknown zTXt compression type"); +#endif + + *(chunkdata + prefix_size) = 0x00; + *newlength=prefix_size; + } + + return chunkdata; +} +#endif + +/* read and check the IDHR chunk */ +void /* PRIVATE */ +png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[13]; + png_uint_32 width, height; + int bit_depth, color_type, compression_type, filter_type; + int interlace_type; + + png_debug(1, "in png_handle_IHDR\n"); + + if (png_ptr->mode & PNG_HAVE_IHDR) + png_error(png_ptr, "Out of place IHDR"); + + /* check the length */ + if (length != 13) + png_error(png_ptr, "Invalid IHDR chunk"); + + png_ptr->mode |= PNG_HAVE_IHDR; + + png_crc_read(png_ptr, buf, 13); + png_crc_finish(png_ptr, 0); + + width = png_get_uint_32(buf); + height = png_get_uint_32(buf + 4); + bit_depth = buf[8]; + color_type = buf[9]; + compression_type = buf[10]; + filter_type = buf[11]; + interlace_type = buf[12]; + + + /* set internal variables */ + png_ptr->width = width; + png_ptr->height = height; + png_ptr->bit_depth = (png_byte)bit_depth; + png_ptr->interlaced = (png_byte)interlace_type; + png_ptr->color_type = (png_byte)color_type; +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_ptr->filter_type = (png_byte)filter_type; +#endif + + /* find number of channels */ + switch (png_ptr->color_type) + { + case PNG_COLOR_TYPE_GRAY: + case PNG_COLOR_TYPE_PALETTE: + png_ptr->channels = 1; + break; + case PNG_COLOR_TYPE_RGB: + png_ptr->channels = 3; + break; + case PNG_COLOR_TYPE_GRAY_ALPHA: + png_ptr->channels = 2; + break; + case PNG_COLOR_TYPE_RGB_ALPHA: + png_ptr->channels = 4; + break; + } + + /* set up other useful info */ + png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * + png_ptr->channels); + png_ptr->rowbytes = ((png_ptr->width * + (png_uint_32)png_ptr->pixel_depth + 7) >> 3); + png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); + png_debug1(3,"channels = %d\n", png_ptr->channels); + png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); + png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, + color_type, interlace_type, compression_type, filter_type); +} + +/* read and check the palette */ +void /* PRIVATE */ +png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_color palette[PNG_MAX_PALETTE_LENGTH]; + int num, i; +#ifndef PNG_NO_POINTER_INDEXING + png_colorp pal_ptr; +#endif + + png_debug(1, "in png_handle_PLTE\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before PLTE"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid PLTE after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + png_error(png_ptr, "Duplicate PLTE chunk"); + + png_ptr->mode |= PNG_HAVE_PLTE; + + if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) + { + png_warning(png_ptr, + "Ignoring PLTE chunk in grayscale PNG"); + png_crc_finish(png_ptr, length); + return; + } +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) + { + png_crc_finish(png_ptr, length); + return; + } +#endif + + if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) + { + if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) + { + png_warning(png_ptr, "Invalid palette chunk"); + png_crc_finish(png_ptr, length); + return; + } + else + { + png_error(png_ptr, "Invalid palette chunk"); + } + } + + num = (int)length / 3; + +#ifndef PNG_NO_POINTER_INDEXING + for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) + { + png_byte buf[3]; + + png_crc_read(png_ptr, buf, 3); + pal_ptr->red = buf[0]; + pal_ptr->green = buf[1]; + pal_ptr->blue = buf[2]; + } +#else + for (i = 0; i < num; i++) + { + png_byte buf[3]; + + png_crc_read(png_ptr, buf, 3); + /* don't depend upon png_color being any order */ + palette[i].red = buf[0]; + palette[i].green = buf[1]; + palette[i].blue = buf[2]; + } +#endif + + /* If we actually NEED the PLTE chunk (ie for a paletted image), we do + whatever the normal CRC configuration tells us. However, if we + have an RGB image, the PLTE can be considered ancillary, so + we will act as though it is. */ +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) +#endif + { + png_crc_finish(png_ptr, 0); + } +#if !defined(PNG_READ_OPT_PLTE_SUPPORTED) + else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ + { + /* If we don't want to use the data from an ancillary chunk, + we have two options: an error abort, or a warning and we + ignore the data in this chunk (which should be OK, since + it's considered ancillary for a RGB or RGBA image). */ + if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) + { + if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) + { + png_chunk_error(png_ptr, "CRC error"); + } + else + { + png_chunk_warning(png_ptr, "CRC error"); + return; + } + } + /* Otherwise, we (optionally) emit a warning and use the chunk. */ + else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) + { + png_chunk_warning(png_ptr, "CRC error"); + } + } +#endif + + png_set_PLTE(png_ptr, info_ptr, palette, num); + +#if defined(PNG_READ_tRNS_SUPPORTED) + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) + { + if (png_ptr->num_trans > (png_uint_16)num) + { + png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); + png_ptr->num_trans = (png_uint_16)num; + } + if (info_ptr->num_trans > (png_uint_16)num) + { + png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); + info_ptr->num_trans = (png_uint_16)num; + } + } + } +#endif + +} + +void /* PRIVATE */ +png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_debug(1, "in png_handle_IEND\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) + { + png_error(png_ptr, "No image in file"); + + info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */ + } + + png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); + + if (length != 0) + { + png_warning(png_ptr, "Incorrect IEND chunk length"); + } + png_crc_finish(png_ptr, length); +} + +#if defined(PNG_READ_gAMA_SUPPORTED) +void /* PRIVATE */ +png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_fixed_point igamma; +#ifdef PNG_FLOATING_POINT_SUPPORTED + float file_gamma; +#endif + png_byte buf[4]; + + png_debug(1, "in png_handle_gAMA\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before gAMA"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid gAMA after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place gAMA chunk"); + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) +#if defined(PNG_READ_sRGB_SUPPORTED) + && !(info_ptr->valid & PNG_INFO_sRGB) +#endif + ) + { + png_warning(png_ptr, "Duplicate gAMA chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 4) + { + png_warning(png_ptr, "Incorrect gAMA chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 4); + if (png_crc_finish(png_ptr, 0)) + return; + + igamma = (png_fixed_point)png_get_uint_32(buf); + /* check for zero gamma */ + if (igamma == 0) + { + png_warning(png_ptr, + "Ignoring gAMA chunk with gamma=0"); + return; + } + +#if defined(PNG_READ_sRGB_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sRGB) + if(igamma < 45000L || igamma > 46000L) + { + png_warning(png_ptr, + "Ignoring incorrect gAMA value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO + fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); +#endif + return; + } +#endif /* PNG_READ_sRGB_SUPPORTED */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + file_gamma = (float)igamma / (float)100000.0; +# ifdef PNG_READ_GAMMA_SUPPORTED + png_ptr->gamma = file_gamma; +# endif + png_set_gAMA(png_ptr, info_ptr, file_gamma); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_gAMA_fixed(png_ptr, info_ptr, igamma); +#endif +} +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +void /* PRIVATE */ +png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_size_t truelen; + png_byte buf[4]; + + png_debug(1, "in png_handle_sBIT\n"); + + buf[0] = buf[1] = buf[2] = buf[3] = 0; + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sBIT"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sBIT after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + { + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place sBIT chunk"); + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) + { + png_warning(png_ptr, "Duplicate sBIT chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + truelen = 3; + else + truelen = (png_size_t)png_ptr->channels; + + if (length != truelen) + { + png_warning(png_ptr, "Incorrect sBIT chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, truelen); + if (png_crc_finish(png_ptr, 0)) + return; + + if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + { + png_ptr->sig_bit.red = buf[0]; + png_ptr->sig_bit.green = buf[1]; + png_ptr->sig_bit.blue = buf[2]; + png_ptr->sig_bit.alpha = buf[3]; + } + else + { + png_ptr->sig_bit.gray = buf[0]; + png_ptr->sig_bit.red = buf[0]; + png_ptr->sig_bit.green = buf[0]; + png_ptr->sig_bit.blue = buf[0]; + png_ptr->sig_bit.alpha = buf[1]; + } + png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); +} +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +void /* PRIVATE */ +png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[4]; +#ifdef PNG_FLOATING_POINT_SUPPORTED + float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; +#endif + png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, + int_y_green, int_x_blue, int_y_blue; + + png_uint_32 uint_x, uint_y; + + png_debug(1, "in png_handle_cHRM\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before cHRM"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid cHRM after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Missing PLTE before cHRM"); + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) +#if defined(PNG_READ_sRGB_SUPPORTED) + && !(info_ptr->valid & PNG_INFO_sRGB) +#endif + ) + { + png_warning(png_ptr, "Duplicate cHRM chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 32) + { + png_warning(png_ptr, "Incorrect cHRM chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM white point"); + png_crc_finish(png_ptr, 24); + return; + } + int_x_white = (png_fixed_point)uint_x; + int_y_white = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM red point"); + png_crc_finish(png_ptr, 16); + return; + } + int_x_red = (png_fixed_point)uint_x; + int_y_red = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM green point"); + png_crc_finish(png_ptr, 8); + return; + } + int_x_green = (png_fixed_point)uint_x; + int_y_green = (png_fixed_point)uint_y; + + png_crc_read(png_ptr, buf, 4); + uint_x = png_get_uint_32(buf); + + png_crc_read(png_ptr, buf, 4); + uint_y = png_get_uint_32(buf); + + if (uint_x > 80000L || uint_y > 80000L || + uint_x + uint_y > 100000L) + { + png_warning(png_ptr, "Invalid cHRM blue point"); + png_crc_finish(png_ptr, 0); + return; + } + int_x_blue = (png_fixed_point)uint_x; + int_y_blue = (png_fixed_point)uint_y; + +#ifdef PNG_FLOATING_POINT_SUPPORTED + white_x = (float)int_x_white / (float)100000.0; + white_y = (float)int_y_white / (float)100000.0; + red_x = (float)int_x_red / (float)100000.0; + red_y = (float)int_y_red / (float)100000.0; + green_x = (float)int_x_green / (float)100000.0; + green_y = (float)int_y_green / (float)100000.0; + blue_x = (float)int_x_blue / (float)100000.0; + blue_y = (float)int_y_blue / (float)100000.0; +#endif + +#if defined(PNG_READ_sRGB_SUPPORTED) + if (info_ptr->valid & PNG_INFO_sRGB) + { + if (abs(int_x_white - 31270L) > 1000 || + abs(int_y_white - 32900L) > 1000 || + abs(int_x_red - 64000L) > 1000 || + abs(int_y_red - 33000L) > 1000 || + abs(int_x_green - 30000L) > 1000 || + abs(int_y_green - 60000L) > 1000 || + abs(int_x_blue - 15000L) > 1000 || + abs(int_y_blue - 6000L) > 1000) + { + + png_warning(png_ptr, + "Ignoring incorrect cHRM value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO +#ifdef PNG_FLOATING_POINT_SUPPORTED + fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", + white_x, white_y, red_x, red_y); + fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", + green_x, green_y, blue_x, blue_y); +#else + fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", + int_x_white, int_y_white, int_x_red, int_y_red); + fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", + int_x_green, int_y_green, int_x_blue, int_y_blue); +#endif +#endif /* PNG_NO_CONSOLE_IO */ + } + png_crc_finish(png_ptr, 0); + return; + } +#endif /* PNG_READ_sRGB_SUPPORTED */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_cHRM(png_ptr, info_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_cHRM_fixed(png_ptr, info_ptr, + int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, + int_y_green, int_x_blue, int_y_blue); +#endif + if (png_crc_finish(png_ptr, 0)) + return; +} +#endif + +#if defined(PNG_READ_sRGB_SUPPORTED) +void /* PRIVATE */ +png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + int intent; + png_byte buf[1]; + + png_debug(1, "in png_handle_sRGB\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sRGB"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sRGB after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place sRGB chunk"); + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) + { + png_warning(png_ptr, "Duplicate sRGB chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 1) + { + png_warning(png_ptr, "Incorrect sRGB chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 1); + if (png_crc_finish(png_ptr, 0)) + return; + + intent = buf[0]; + /* check for bad intent */ + if (intent >= PNG_sRGB_INTENT_LAST) + { + png_warning(png_ptr, "Unknown sRGB intent"); + return; + } + +#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) + if ((info_ptr->valid & PNG_INFO_gAMA)) + { + int igamma; +#ifdef PNG_FIXED_POINT_SUPPORTED + igamma=(int)info_ptr->int_gamma; +#else +# ifdef PNG_FLOATING_POINT_SUPPORTED + igamma=(int)(info_ptr->gamma * 100000.); +# endif +#endif + if(igamma < 45000L || igamma > 46000L) + { + png_warning(png_ptr, + "Ignoring incorrect gAMA value when sRGB is also present"); +#ifndef PNG_NO_CONSOLE_IO +# ifdef PNG_FIXED_POINT_SUPPORTED + fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); +# else +# ifdef PNG_FLOATING_POINT_SUPPORTED + fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); +# endif +# endif +#endif + } + } +#endif /* PNG_READ_gAMA_SUPPORTED */ + +#ifdef PNG_READ_cHRM_SUPPORTED +#ifdef PNG_FIXED_POINT_SUPPORTED + if (info_ptr->valid & PNG_INFO_cHRM) + if (abs(info_ptr->int_x_white - 31270L) > 1000 || + abs(info_ptr->int_y_white - 32900L) > 1000 || + abs(info_ptr->int_x_red - 64000L) > 1000 || + abs(info_ptr->int_y_red - 33000L) > 1000 || + abs(info_ptr->int_x_green - 30000L) > 1000 || + abs(info_ptr->int_y_green - 60000L) > 1000 || + abs(info_ptr->int_x_blue - 15000L) > 1000 || + abs(info_ptr->int_y_blue - 6000L) > 1000) + { + png_warning(png_ptr, + "Ignoring incorrect cHRM value when sRGB is also present"); + } +#endif /* PNG_FIXED_POINT_SUPPORTED */ +#endif /* PNG_READ_cHRM_SUPPORTED */ + + png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); +} +#endif /* PNG_READ_sRGB_SUPPORTED */ + +#if defined(PNG_READ_iCCP_SUPPORTED) +void /* PRIVATE */ +png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +/* Note: this does not properly handle chunks that are > 64K under DOS */ +{ + png_charp chunkdata; + png_byte compression_type; + png_bytep pC; + png_charp profile; + png_uint_32 skip = 0; + png_uint_32 profile_size = 0; + png_uint_32 profile_length = 0; + png_size_t slength, prefix_length, data_length; + + png_debug(1, "in png_handle_iCCP\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before iCCP"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid iCCP after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->mode & PNG_HAVE_PLTE) + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Out of place iCCP chunk"); + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) + { + png_warning(png_ptr, "Duplicate iCCP chunk"); + png_crc_finish(png_ptr, length); + return; + } + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "iCCP chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + chunkdata = (png_charp)png_malloc(png_ptr, length + 1); + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + + if (png_crc_finish(png_ptr, skip)) + { + png_free(png_ptr, chunkdata); + return; + } + + chunkdata[slength] = 0x00; + + for (profile = chunkdata; *profile; profile++) + /* empty loop to find end of name */ ; + + ++profile; + + /* there should be at least one zero (the compression type byte) + following the separator, and we should be on it */ + if ( profile >= chunkdata + slength) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Malformed iCCP chunk"); + return; + } + + /* compression_type should always be zero */ + compression_type = *profile++; + if (compression_type) + { + png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); + compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 + wrote nonzero) */ + } + + prefix_length = profile - chunkdata; + chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, + slength, prefix_length, &data_length); + + profile_length = data_length - prefix_length; + + if ( prefix_length > data_length || profile_length < 4) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Profile size field missing from iCCP chunk"); + return; + } + + /* Check the profile_size recorded in the first 32 bits of the ICC profile */ + pC = (png_bytep)(chunkdata+prefix_length); + profile_size = ((*(pC ))<<24) | + ((*(pC+1))<<16) | + ((*(pC+2))<< 8) | + ((*(pC+3)) ); + + if(profile_size < profile_length) + profile_length = profile_size; + + if(profile_size > profile_length) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Ignoring truncated iCCP profile.\n"); + return; + } + + png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, + chunkdata + prefix_length, profile_length); + png_free(png_ptr, chunkdata); +} +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_sPLT_SUPPORTED) +void /* PRIVATE */ +png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +/* Note: this does not properly handle chunks that are > 64K under DOS */ +{ + png_bytep chunkdata; + png_bytep entry_start; + png_sPLT_t new_palette; +#ifdef PNG_NO_POINTER_INDEXING + png_sPLT_entryp pp; +#endif + int data_length, entry_size, i; + png_uint_32 skip = 0; + png_size_t slength; + + png_debug(1, "in png_handle_sPLT\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sPLT"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sPLT after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "sPLT chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + + if (png_crc_finish(png_ptr, skip)) + { + png_free(png_ptr, chunkdata); + return; + } + + chunkdata[slength] = 0x00; + + for (entry_start = chunkdata; *entry_start; entry_start++) + /* empty loop to find end of name */ ; + ++entry_start; + + /* a sample depth should follow the separator, and we should be on it */ + if (entry_start > chunkdata + slength) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "malformed sPLT chunk"); + return; + } + + new_palette.depth = *entry_start++; + entry_size = (new_palette.depth == 8 ? 6 : 10); + data_length = (slength - (entry_start - chunkdata)); + + /* integrity-check the data length */ + if (data_length % entry_size) + { + png_free(png_ptr, chunkdata); + png_warning(png_ptr, "sPLT chunk has bad length"); + return; + } + + new_palette.nentries = data_length / entry_size; + new_palette.entries = (png_sPLT_entryp)png_malloc( + png_ptr, new_palette.nentries * sizeof(png_sPLT_entry)); + +#ifndef PNG_NO_POINTER_INDEXING + for (i = 0; i < new_palette.nentries; i++) + { + png_sPLT_entryp pp = new_palette.entries + i; + + if (new_palette.depth == 8) + { + pp->red = *entry_start++; + pp->green = *entry_start++; + pp->blue = *entry_start++; + pp->alpha = *entry_start++; + } + else + { + pp->red = png_get_uint_16(entry_start); entry_start += 2; + pp->green = png_get_uint_16(entry_start); entry_start += 2; + pp->blue = png_get_uint_16(entry_start); entry_start += 2; + pp->alpha = png_get_uint_16(entry_start); entry_start += 2; + } + pp->frequency = png_get_uint_16(entry_start); entry_start += 2; + } +#else + pp = new_palette.entries; + for (i = 0; i < new_palette.nentries; i++) + { + + if (new_palette.depth == 8) + { + pp[i].red = *entry_start++; + pp[i].green = *entry_start++; + pp[i].blue = *entry_start++; + pp[i].alpha = *entry_start++; + } + else + { + pp[i].red = png_get_uint_16(entry_start); entry_start += 2; + pp[i].green = png_get_uint_16(entry_start); entry_start += 2; + pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; + pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; + } + pp->frequency = png_get_uint_16(entry_start); entry_start += 2; + } +#endif + + /* discard all chunk data except the name and stash that */ + new_palette.name = (png_charp)chunkdata; + + png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); + + png_free(png_ptr, chunkdata); + png_free(png_ptr, new_palette.entries); +} +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_tRNS_SUPPORTED) +void /* PRIVATE */ +png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; + + png_debug(1, "in png_handle_tRNS\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before tRNS"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid tRNS after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) + { + png_warning(png_ptr, "Duplicate tRNS chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (!(png_ptr->mode & PNG_HAVE_PLTE)) + { + /* Should be an error, but we can cope with it */ + png_warning(png_ptr, "Missing PLTE before tRNS"); + } + else if (length > (png_uint_32)png_ptr->num_palette) + { + png_warning(png_ptr, "Incorrect tRNS chunk length"); + png_crc_finish(png_ptr, length); + return; + } + if (length == 0) + { + png_warning(png_ptr, "Zero length tRNS chunk"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, readbuf, (png_size_t)length); + png_ptr->num_trans = (png_uint_16)length; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + png_byte buf[6]; + + if (length != 6) + { + png_warning(png_ptr, "Incorrect tRNS chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, (png_size_t)length); + png_ptr->num_trans = 1; + png_ptr->trans_values.red = png_get_uint_16(buf); + png_ptr->trans_values.green = png_get_uint_16(buf + 2); + png_ptr->trans_values.blue = png_get_uint_16(buf + 4); + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + png_byte buf[6]; + + if (length != 2) + { + png_warning(png_ptr, "Incorrect tRNS chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 2); + png_ptr->num_trans = 1; + png_ptr->trans_values.gray = png_get_uint_16(buf); + } + else + { + png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_crc_finish(png_ptr, 0)) + return; + + png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, + &(png_ptr->trans_values)); +} +#endif + +#if defined(PNG_READ_bKGD_SUPPORTED) +void /* PRIVATE */ +png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_size_t truelen; + png_byte buf[6]; + + png_debug(1, "in png_handle_bKGD\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before bKGD"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid bKGD after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + { + png_warning(png_ptr, "Missing PLTE before bKGD"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) + { + png_warning(png_ptr, "Duplicate bKGD chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + truelen = 1; + else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) + truelen = 6; + else + truelen = 2; + + if (length != truelen) + { + png_warning(png_ptr, "Incorrect bKGD chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, truelen); + if (png_crc_finish(png_ptr, 0)) + return; + + /* We convert the index value into RGB components so that we can allow + * arbitrary RGB values for background when we have transparency, and + * so it is easy to determine the RGB values of the background color + * from the info_ptr struct. */ + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + png_ptr->background.index = buf[0]; + if(info_ptr->num_palette) + { + if(buf[0] > info_ptr->num_palette) + { + png_warning(png_ptr, "Incorrect bKGD chunk index value"); + return; + } + png_ptr->background.red = + (png_uint_16)png_ptr->palette[buf[0]].red; + png_ptr->background.green = + (png_uint_16)png_ptr->palette[buf[0]].green; + png_ptr->background.blue = + (png_uint_16)png_ptr->palette[buf[0]].blue; + } + } + else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ + { + png_ptr->background.red = + png_ptr->background.green = + png_ptr->background.blue = + png_ptr->background.gray = png_get_uint_16(buf); + } + else + { + png_ptr->background.red = png_get_uint_16(buf); + png_ptr->background.green = png_get_uint_16(buf + 2); + png_ptr->background.blue = png_get_uint_16(buf + 4); + } + + png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); +} +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +void /* PRIVATE */ +png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + int num, i; + png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; + + png_debug(1, "in png_handle_hIST\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before hIST"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid hIST after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (!(png_ptr->mode & PNG_HAVE_PLTE)) + { + png_warning(png_ptr, "Missing PLTE before hIST"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) + { + png_warning(png_ptr, "Duplicate hIST chunk"); + png_crc_finish(png_ptr, length); + return; + } + + num = (int)length / 2 ; + if (num != png_ptr->num_palette) + { + png_warning(png_ptr, "Incorrect hIST chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + for (i = 0; i < num; i++) + { + png_byte buf[2]; + + png_crc_read(png_ptr, buf, 2); + readbuf[i] = png_get_uint_16(buf); + } + + if (png_crc_finish(png_ptr, 0)) + return; + + png_set_hIST(png_ptr, info_ptr, readbuf); +} +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +void /* PRIVATE */ +png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[9]; + png_uint_32 res_x, res_y; + int unit_type; + + png_debug(1, "in png_handle_pHYs\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before pHYs"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid pHYs after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) + { + png_warning(png_ptr, "Duplicate pHYs chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 9) + { + png_warning(png_ptr, "Incorrect pHYs chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 9); + if (png_crc_finish(png_ptr, 0)) + return; + + res_x = png_get_uint_32(buf); + res_y = png_get_uint_32(buf + 4); + unit_type = buf[8]; + png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); +} +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +void /* PRIVATE */ +png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[9]; + png_int_32 offset_x, offset_y; + int unit_type; + + png_debug(1, "in png_handle_oFFs\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before oFFs"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid oFFs after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) + { + png_warning(png_ptr, "Duplicate oFFs chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (length != 9) + { + png_warning(png_ptr, "Incorrect oFFs chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 9); + if (png_crc_finish(png_ptr, 0)) + return; + + offset_x = png_get_int_32(buf); + offset_y = png_get_int_32(buf + 4); + unit_type = buf[8]; + png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); +} +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +/* read the pCAL chunk (described in the PNG Extensions document) */ +void /* PRIVATE */ +png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_charp purpose; + png_int_32 X0, X1; + png_byte type, nparams; + png_charp buf, units, endptr; + png_charpp params; + png_size_t slength; + int i; + + png_debug(1, "in png_handle_pCAL\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before pCAL"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid pCAL after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) + { + png_warning(png_ptr, "Duplicate pCAL chunk"); + png_crc_finish(png_ptr, length); + return; + } + + png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", + length + 1); + purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (purpose == NULL) + { + png_warning(png_ptr, "No memory for pCAL purpose."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)purpose, slength); + + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, purpose); + return; + } + + purpose[slength] = 0x00; /* null terminate the last string */ + + png_debug(3, "Finding end of pCAL purpose string\n"); + for (buf = purpose; *buf; buf++) + /* empty loop */ ; + + endptr = purpose + slength; + + /* We need to have at least 12 bytes after the purpose string + in order to get the parameter information. */ + if (endptr <= buf + 12) + { + png_warning(png_ptr, "Invalid pCAL data"); + png_free(png_ptr, purpose); + return; + } + + png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); + X0 = png_get_int_32((png_bytep)buf+1); + X1 = png_get_int_32((png_bytep)buf+5); + type = buf[9]; + nparams = buf[10]; + units = buf + 11; + + png_debug(3, "Checking pCAL equation type and number of parameters\n"); + /* Check that we have the right number of parameters for known + equation types. */ + if ((type == PNG_EQUATION_LINEAR && nparams != 2) || + (type == PNG_EQUATION_BASE_E && nparams != 3) || + (type == PNG_EQUATION_ARBITRARY && nparams != 3) || + (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) + { + png_warning(png_ptr, "Invalid pCAL parameters for equation type"); + png_free(png_ptr, purpose); + return; + } + else if (type >= PNG_EQUATION_LAST) + { + png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); + } + + for (buf = units; *buf; buf++) + /* Empty loop to move past the units string. */ ; + + png_debug(3, "Allocating pCAL parameters array\n"); + params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams + *sizeof(png_charp))) ; + if (params == NULL) + { + png_free(png_ptr, purpose); + png_warning(png_ptr, "No memory for pCAL params."); + return; + } + + /* Get pointers to the start of each parameter string. */ + for (i = 0; i < (int)nparams; i++) + { + buf++; /* Skip the null string terminator from previous parameter. */ + + png_debug1(3, "Reading pCAL parameter %d\n", i); + for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) + /* Empty loop to move past each parameter string */ ; + + /* Make sure we haven't run out of data yet */ + if (buf > endptr) + { + png_warning(png_ptr, "Invalid pCAL data"); + png_free(png_ptr, purpose); + png_free(png_ptr, params); + return; + } + } + + png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, + units, params); + + png_free(png_ptr, purpose); + png_free(png_ptr, params); +} +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +/* read the sCAL chunk */ +void /* PRIVATE */ +png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_charp buffer, ep; +#ifdef PNG_FLOATING_POINT_SUPPORTED + double width, height; + png_charp vp; +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_charp swidth, sheight; +#endif +#endif + png_size_t slength; + + png_debug(1, "in png_handle_sCAL\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before sCAL"); + else if (png_ptr->mode & PNG_HAVE_IDAT) + { + png_warning(png_ptr, "Invalid sCAL after IDAT"); + png_crc_finish(png_ptr, length); + return; + } + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) + { + png_warning(png_ptr, "Duplicate sCAL chunk"); + png_crc_finish(png_ptr, length); + return; + } + + png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", + length + 1); + buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (buffer == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk"); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)buffer, slength); + + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, buffer); + return; + } + + buffer[slength] = 0x00; /* null terminate the last string */ + + ep = buffer + 1; /* skip unit byte */ + +#ifdef PNG_FLOATING_POINT_SUPPORTED + width = strtod(ep, &vp); + if (*vp) + { + png_warning(png_ptr, "malformed width string in sCAL chunk"); + return; + } +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); + if (swidth == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); + return; + } + png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); +#endif +#endif + + for (ep = buffer; *ep; ep++) + /* empty loop */ ; + ep++; + +#ifdef PNG_FLOATING_POINT_SUPPORTED + height = strtod(ep, &vp); + if (*vp) + { + png_warning(png_ptr, "malformed height string in sCAL chunk"); + return; + } +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); + if (swidth == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); + return; + } + png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); +#endif +#endif + + if (buffer + slength < ep +#ifdef PNG_FLOATING_POINT_SUPPORTED + || width <= 0. || height <= 0. +#endif + ) + { + png_warning(png_ptr, "Invalid sCAL data"); + png_free(png_ptr, buffer); +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, swidth); + png_free(png_ptr, sheight); +#endif + return; + } + + +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); +#endif +#endif + + png_free(png_ptr, buffer); +#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) + png_free(png_ptr, swidth); + png_free(png_ptr, sheight); +#endif +} +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +void /* PRIVATE */ +png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_byte buf[7]; + png_time mod_time; + + png_debug(1, "in png_handle_tIME\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Out of place tIME chunk"); + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) + { + png_warning(png_ptr, "Duplicate tIME chunk"); + png_crc_finish(png_ptr, length); + return; + } + + if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; + + if (length != 7) + { + png_warning(png_ptr, "Incorrect tIME chunk length"); + png_crc_finish(png_ptr, length); + return; + } + + png_crc_read(png_ptr, buf, 7); + if (png_crc_finish(png_ptr, 0)) + return; + + mod_time.second = buf[6]; + mod_time.minute = buf[5]; + mod_time.hour = buf[4]; + mod_time.day = buf[3]; + mod_time.month = buf[2]; + mod_time.year = png_get_uint_16(buf); + + png_set_tIME(png_ptr, info_ptr, &mod_time); +} +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +/* Note: this does not properly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_textp text_ptr; + png_charp key; + png_charp text; + png_uint_32 skip = 0; + png_size_t slength; + int ret; + + png_debug(1, "in png_handle_tEXt\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before tEXt"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "tEXt chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + + key = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (key == NULL) + { + png_warning(png_ptr, "No memory to process text chunk."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)key, slength); + + if (png_crc_finish(png_ptr, skip)) + { + png_free(png_ptr, key); + return; + } + + key[slength] = 0x00; + + for (text = key; *text; text++) + /* empty loop to find end of key */ ; + + if (text != key + slength) + text++; + + text_ptr =(png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr, "Not enough memory to process text chunk."); + png_free(png_ptr, key); + return; + } + text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; + text_ptr->key = key; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; + text_ptr->itxt_length = 0; +#endif + text_ptr->text = text; + text_ptr->text_length = png_strlen(text); + + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, key); + png_free(png_ptr, text_ptr); + if (ret) + png_warning(png_ptr, "Insufficient memory to process text chunk."); +} +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +/* note: this does not correctly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_textp text_ptr; + png_charp chunkdata; + png_charp text; + int comp_type; + int ret; + png_size_t slength, prefix_len, data_len; + + png_debug(1, "in png_handle_zTXt\n"); + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before zTXt"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; + +#ifdef PNG_MAX_MALLOC_64K + /* We will no doubt have problems with chunks even half this size, but + there is no hard and fast rule to tell us where to stop. */ + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr,"zTXt chunk too large to fit in memory"); + png_crc_finish(png_ptr, length); + return; + } +#endif + + chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (chunkdata == NULL) + { + png_warning(png_ptr,"Out of memory processing zTXt chunk."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, chunkdata); + return; + } + + chunkdata[slength] = 0x00; + + for (text = chunkdata; *text; text++) + /* empty loop */ ; + + /* zTXt must have some text after the chunkdataword */ + if (text == chunkdata + slength) + { + comp_type = PNG_TEXT_COMPRESSION_NONE; + png_warning(png_ptr, "Zero length zTXt chunk"); + } + else + { + comp_type = *(++text); + if (comp_type != PNG_TEXT_COMPRESSION_zTXt) + { + png_warning(png_ptr, "Unknown compression type in zTXt chunk"); + comp_type = PNG_TEXT_COMPRESSION_zTXt; + } + text++; /* skip the compression_method byte */ + } + prefix_len = text - chunkdata; + + chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, + (png_size_t)length, prefix_len, &data_len); + + text_ptr =(png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr,"Not enough memory to process zTXt chunk."); + png_free(png_ptr, chunkdata); + return; + } + text_ptr->compression = comp_type; + text_ptr->key = chunkdata; +#ifdef PNG_iTXt_SUPPORTED + text_ptr->lang = NULL; + text_ptr->lang_key = NULL; + text_ptr->itxt_length = 0; +#endif + text_ptr->text = chunkdata + prefix_len; + text_ptr->text_length = data_len; + + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, text_ptr); + png_free(png_ptr, chunkdata); + if (ret) + png_error(png_ptr, "Insufficient memory to store zTXt chunk."); +} +#endif + +#if defined(PNG_READ_iTXt_SUPPORTED) +/* note: this does not correctly handle chunks that are > 64K under DOS */ +void /* PRIVATE */ +png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_textp text_ptr; + png_charp chunkdata; + png_charp key, lang, text, lang_key; + int comp_flag; + int comp_type = 0; + int ret; + png_size_t slength, prefix_len, data_len; + + png_debug(1, "in png_handle_iTXt\n"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before iTXt"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + png_ptr->mode |= PNG_AFTER_IDAT; + +#ifdef PNG_MAX_MALLOC_64K + /* We will no doubt have problems with chunks even half this size, but + there is no hard and fast rule to tell us where to stop. */ + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr,"iTXt chunk too large to fit in memory"); + png_crc_finish(png_ptr, length); + return; + } +#endif + + chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (chunkdata == NULL) + { + png_warning(png_ptr, "No memory to process iTXt chunk."); + return; + } + slength = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + if (png_crc_finish(png_ptr, 0)) + { + png_free(png_ptr, chunkdata); + return; + } + + chunkdata[slength] = 0x00; + + for (lang = chunkdata; *lang; lang++) + /* empty loop */ ; + lang++; /* skip NUL separator */ + + /* iTXt must have a language tag (possibly empty), two compression bytes, + translated keyword (possibly empty), and possibly some text after the + keyword */ + + if (lang >= chunkdata + slength) + { + comp_flag = PNG_TEXT_COMPRESSION_NONE; + png_warning(png_ptr, "Zero length iTXt chunk"); + } + else + { + comp_flag = *lang++; + comp_type = *lang++; + } + + for (lang_key = lang; *lang_key; lang_key++) + /* empty loop */ ; + lang_key++; /* skip NUL separator */ + + for (text = lang_key; *text; text++) + /* empty loop */ ; + text++; /* skip NUL separator */ + + prefix_len = text - chunkdata; + + key=chunkdata; + if (comp_flag) + chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, + (size_t)length, prefix_len, &data_len); + else + data_len=png_strlen(chunkdata + prefix_len); + text_ptr =(png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text)); + if (text_ptr == NULL) + { + png_warning(png_ptr,"Not enough memory to process iTXt chunk."); + png_free(png_ptr, chunkdata); + return; + } + text_ptr->compression = (int)comp_flag + 1; + text_ptr->lang_key = chunkdata+(lang_key-key); + text_ptr->lang = chunkdata+(lang-key); + text_ptr->itxt_length = data_len; + text_ptr->text_length = 0; + text_ptr->key = chunkdata; + text_ptr->text = chunkdata + prefix_len; + + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + + png_free(png_ptr, text_ptr); + png_free(png_ptr, chunkdata); + if (ret) + png_error(png_ptr, "Insufficient memory to store iTXt chunk."); +} +#endif + +/* This function is called when we haven't found a handler for a + chunk. If there isn't a problem with the chunk itself (ie bad + chunk name, CRC, or a critical chunk), the chunk is silently ignored + -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which + case it will be saved away to be written out later. */ +void /* PRIVATE */ +png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) +{ + png_uint_32 skip = 0; + + png_debug(1, "in png_handle_unknown\n"); + + if (png_ptr->mode & PNG_HAVE_IDAT) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ + png_ptr->mode |= PNG_AFTER_IDAT; + } + + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + + if (!(png_ptr->chunk_name[0] & 0x20)) + { +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + HANDLE_CHUNK_ALWAYS +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + && png_ptr->read_user_chunk_fn == NULL +#endif + ) +#endif + png_chunk_error(png_ptr, "unknown critical chunk"); + } + +#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) + if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) + { + png_unknown_chunk chunk; + +#ifdef PNG_MAX_MALLOC_64K + if (length > (png_uint_32)65535L) + { + png_warning(png_ptr, "unknown chunk too large to fit in memory"); + skip = length - (png_uint_32)65535L; + length = (png_uint_32)65535L; + } +#endif + png_strcpy((png_charp)chunk.name, (png_charp)png_ptr->chunk_name); + chunk.data = (png_bytep)png_malloc(png_ptr, length); + chunk.size = (png_size_t)length; + png_crc_read(png_ptr, (png_bytep)chunk.data, length); +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + if(png_ptr->read_user_chunk_fn != NULL) + { + /* callback to user unknown chunk handler */ + if ((*(png_ptr->read_user_chunk_fn)) (png_ptr, &chunk) <= 0) + { + if (!(png_ptr->chunk_name[0] & 0x20)) + if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + HANDLE_CHUNK_ALWAYS) + { + png_free(png_ptr, chunk.data); + png_chunk_error(png_ptr, "unknown critical chunk"); + } + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + } + } + else +#endif + png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1); + png_free(png_ptr, chunk.data); + } + else +#endif + skip = length; + + png_crc_finish(png_ptr, skip); + +#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) + info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */ +#endif +} + +/* This function is called to verify that a chunk name is valid. + This function can't have the "critical chunk check" incorporated + into it, since in the future we will need to be able to call user + functions to handle unknown critical chunks after we check that + the chunk name itself is valid. */ + +#define isnonalpha(c) ((c) < 41 || (c) > 122 || ((c) > 90 && (c) < 97)) + +void /* PRIVATE */ +png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) +{ + png_debug(1, "in png_check_chunk_name\n"); + if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || + isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) + { + png_chunk_error(png_ptr, "invalid chunk type"); + } +} + +/* Combines the row recently read in with the existing pixels in the + row. This routine takes care of alpha and transparency if requested. + This routine also handles the two methods of progressive display + of interlaced images, depending on the mask value. + The mask value describes which pixels are to be combined with + the row. The pattern always repeats every 8 pixels, so just 8 + bits are needed. A one indicates the pixel is to be combined, + a zero indicates the pixel is to be skipped. This is in addition + to any alpha or transparency value associated with the pixel. If + you want all pixels to be combined, pass 0xff (255) in mask. */ +#ifndef PNG_HAVE_ASSEMBLER_COMBINE_ROW +void /* PRIVATE */ +png_combine_row(png_structp png_ptr, png_bytep row, int mask) +{ + png_debug(1,"in png_combine_row\n"); + if (mask == 0xff) + { + png_memcpy(row, png_ptr->row_buf + 1, + (png_size_t)((png_ptr->width * + png_ptr->row_info.pixel_depth + 7) >> 3)); + } + else + { + switch (png_ptr->row_info.pixel_depth) + { + case 1: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_inc, s_start, s_end; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 7; + s_inc = 1; + } + else +#endif + { + s_start = 7; + s_end = 0; + s_inc = -1; + } + + shift = s_start; + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + int value; + + value = (*sp >> shift) & 0x01; + *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + case 2: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_start, s_end, s_inc; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + int value; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 6; + s_inc = 2; + } + else +#endif + { + s_start = 6; + s_end = 0; + s_inc = -2; + } + + shift = s_start; + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0x03; + *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + case 4: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + int s_start, s_end, s_inc; + int m = 0x80; + int shift; + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + int value; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 4; + s_inc = 4; + } + else +#endif + { + s_start = 4; + s_end = 0; + s_inc = -4; + } + shift = s_start; + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0xf; + *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + default: + { + png_bytep sp = png_ptr->row_buf + 1; + png_bytep dp = row; + png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + png_uint_32 i; + png_uint_32 row_width = png_ptr->width; + png_byte m = 0x80; + + + for (i = 0; i < row_width; i++) + { + if (m & mask) + { + png_memcpy(dp, sp, pixel_bytes); + } + + sp += pixel_bytes; + dp += pixel_bytes; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + } + } +} +#endif /* !PNG_HAVE_ASSEMBLER_COMBINE_ROW */ + +#ifdef PNG_READ_INTERLACING_SUPPORTED +#ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */ +/* OLD pre-1.0.9 interface: +void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, + png_uint_32 transformations) + */ +void /* PRIVATE */ +png_do_read_interlace(png_structp png_ptr) +{ + png_row_infop row_info = &(png_ptr->row_info); + png_bytep row = png_ptr->row_buf + 1; + int pass = png_ptr->pass; + png_uint_32 transformations = png_ptr->transformations; +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif + + png_debug(1,"in png_do_read_interlace (stock C version)\n"); + if (row != NULL && row_info != NULL) + { + png_uint_32 final_width; + + final_width = row_info->width * png_pass_inc[pass]; + + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); + png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); + int sshift, dshift; + int s_start, s_end, s_inc; + int jstop = png_pass_inc[pass]; + png_byte v; + png_uint_32 i; + int j; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)((row_info->width + 7) & 0x07); + dshift = (int)((final_width + 7) & 0x07); + s_start = 7; + s_end = 0; + s_inc = -1; + } + else +#endif + { + sshift = 7 - (int)((row_info->width + 7) & 0x07); + dshift = 7 - (int)((final_width + 7) & 0x07); + s_start = 0; + s_end = 7; + s_inc = 1; + } + + for (i = 0; i < row_info->width; i++) + { + v = (png_byte)((*sp >> sshift) & 0x01); + for (j = 0; j < jstop; j++) + { + *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + case 2: + { + png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); + png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); + int sshift, dshift; + int s_start, s_end, s_inc; + int jstop = png_pass_inc[pass]; + png_uint_32 i; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)(((row_info->width + 3) & 0x03) << 1); + dshift = (int)(((final_width + 3) & 0x03) << 1); + s_start = 6; + s_end = 0; + s_inc = -2; + } + else +#endif + { + sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); + dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); + s_start = 0; + s_end = 6; + s_inc = 2; + } + + for (i = 0; i < row_info->width; i++) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0x03); + for (j = 0; j < jstop; j++) + { + *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + case 4: + { + png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); + png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + int jstop = png_pass_inc[pass]; + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)(((row_info->width + 1) & 0x01) << 2); + dshift = (int)(((final_width + 1) & 0x01) << 2); + s_start = 4; + s_end = 0; + s_inc = -4; + } + else +#endif + { + sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); + dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); + s_start = 0; + s_end = 4; + s_inc = 4; + } + + for (i = 0; i < row_info->width; i++) + { + png_byte v = (png_byte)((*sp >> sshift) & 0xf); + int j; + + for (j = 0; j < jstop; j++) + { + *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + default: + { + png_size_t pixel_bytes = (row_info->pixel_depth >> 3); + png_bytep sp =row + (png_size_t)(row_info->width - 1) * pixel_bytes; + png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; + + int jstop = png_pass_inc[pass]; + png_uint_32 i; + + for (i = 0; i < row_info->width; i++) + { + png_byte v[8]; + int j; + + png_memcpy(v, sp, pixel_bytes); + for (j = 0; j < jstop; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sp -= pixel_bytes; + } + break; + } + } + row_info->width = final_width; + row_info->rowbytes = ((final_width * + (png_uint_32)row_info->pixel_depth + 7) >> 3); + } +#if !defined(PNG_READ_PACKSWAP_SUPPORTED) + transformations = transformations; /* silence compiler warning */ +#endif +} +#endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */ +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + +#ifndef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +void /* PRIVATE */ +png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, + png_bytep prev_row, int filter) +{ + png_debug(1, "in png_read_filter_row\n"); + png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + case PNG_FILTER_VALUE_SUB: + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_UP: + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_bytep rp = row; + png_bytep pp = prev_row; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_AVG: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) / 2 )) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + (int)(*pp++ + *lp++) / 2 ) & 0xff); + rp++; + } + break; + } + case PNG_FILTER_VALUE_PAETH: + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop=row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) /* use leftover rp,pp */ + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + break; + } + default: + png_warning(png_ptr, "Ignoring bad adaptive filter type"); + *row=0; + break; + } +} +#endif /* !PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */ + +void /* PRIVATE */ +png_read_finish_row(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* start of interlace block */ + const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* start of interlace block in the y direction */ + const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* offset to next interlace block in the y direction */ + const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif + + png_debug(1, "in png_read_finish_row\n"); + png_ptr->row_number++; + if (png_ptr->row_number < png_ptr->num_rows) + return; + + if (png_ptr->interlaced) + { + png_ptr->row_number = 0; + png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + do + { + png_ptr->pass++; + if (png_ptr->pass >= 7) + break; + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + png_ptr->irowbytes = ((png_ptr->iwidth * + (png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1; + + if (!(png_ptr->transformations & PNG_INTERLACE)) + { + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; + if (!(png_ptr->num_rows)) + continue; + } + else /* if (png_ptr->transformations & PNG_INTERLACE) */ + break; + } while (png_ptr->iwidth == 0); + + if (png_ptr->pass < 7) + return; + } + + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) + { +#ifdef PNG_USE_LOCAL_ARRAYS + PNG_IDAT; +#endif + char extra; + int ret; + + png_ptr->zstream.next_out = (Byte *)&extra; + png_ptr->zstream.avail_out = (uInt)1; + for(;;) + { + if (!(png_ptr->zstream.avail_in)) + { + while (!png_ptr->idat_size) + { + png_byte chunk_length[4]; + + png_crc_finish(png_ptr, 0); + + png_read_data(png_ptr, chunk_length, 4); + png_ptr->idat_size = png_get_uint_32(chunk_length); + + png_reset_crc(png_ptr); + png_crc_read(png_ptr, png_ptr->chunk_name, 4); + if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) + png_error(png_ptr, "Not enough image data"); + + } + png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; + png_ptr->zstream.next_in = png_ptr->zbuf; + if (png_ptr->zbuf_size > png_ptr->idat_size) + png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; + png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); + png_ptr->idat_size -= png_ptr->zstream.avail_in; + } + ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); + if (ret == Z_STREAM_END) + { + if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || + png_ptr->idat_size) + png_warning(png_ptr, "Extra compressed data"); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + if (ret != Z_OK) + png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : + "Decompression Error"); + + if (!(png_ptr->zstream.avail_out)) + { + png_warning(png_ptr, "Extra compressed data."); + png_ptr->mode |= PNG_AFTER_IDAT; + png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; + break; + } + + } + png_ptr->zstream.avail_out = 0; + } + + if (png_ptr->idat_size || png_ptr->zstream.avail_in) + png_warning(png_ptr, "Extra compression data"); + + inflateReset(&png_ptr->zstream); + + png_ptr->mode |= PNG_AFTER_IDAT; +} + +void /* PRIVATE */ +png_read_start_row(png_structp png_ptr) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + + /* start of interlace block */ + const int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; + + /* offset to next interlace block */ + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + + /* start of interlace block in the y direction */ + const int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; + + /* offset to next interlace block in the y direction */ + const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; +#endif + + int max_pixel_depth; + png_uint_32 row_bytes; + + png_debug(1, "in png_read_start_row\n"); + png_ptr->zstream.avail_in = 0; + png_init_read_transformations(png_ptr); + if (png_ptr->interlaced) + { + if (!(png_ptr->transformations & PNG_INTERLACE)) + png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - + png_pass_ystart[0]) / png_pass_yinc[0]; + else + png_ptr->num_rows = png_ptr->height; + + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + row_bytes = ((png_ptr->iwidth * + (png_uint_32)png_ptr->pixel_depth + 7) >> 3) +1; + png_ptr->irowbytes = (png_size_t)row_bytes; + if((png_uint_32)png_ptr->irowbytes != row_bytes) + png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); + } + else + { + png_ptr->num_rows = png_ptr->height; + png_ptr->iwidth = png_ptr->width; + png_ptr->irowbytes = png_ptr->rowbytes + 1; + } + max_pixel_depth = png_ptr->pixel_depth; + +#if defined(PNG_READ_PACK_SUPPORTED) + if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) + max_pixel_depth = 8; +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) + if (png_ptr->transformations & PNG_EXPAND) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (png_ptr->num_trans) + max_pixel_depth = 32; + else + max_pixel_depth = 24; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + if (max_pixel_depth < 8) + max_pixel_depth = 8; + if (png_ptr->num_trans) + max_pixel_depth *= 2; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + if (png_ptr->num_trans) + { + max_pixel_depth *= 4; + max_pixel_depth /= 3; + } + } + } +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) + if (png_ptr->transformations & (PNG_FILLER)) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + max_pixel_depth = 32; + else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + if (max_pixel_depth <= 8) + max_pixel_depth = 16; + else + max_pixel_depth = 32; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + if (max_pixel_depth <= 32) + max_pixel_depth = 32; + else + max_pixel_depth = 64; + } + } +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) + if (png_ptr->transformations & PNG_GRAY_TO_RGB) + { + if ( +#if defined(PNG_READ_EXPAND_SUPPORTED) + (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || +#endif +#if defined(PNG_READ_FILLER_SUPPORTED) + (png_ptr->transformations & (PNG_FILLER)) || +#endif + png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { + if (max_pixel_depth <= 16) + max_pixel_depth = 32; + else + max_pixel_depth = 64; + } + else + { + if (max_pixel_depth <= 8) + { + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + max_pixel_depth = 32; + else + max_pixel_depth = 24; + } + else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + max_pixel_depth = 64; + else + max_pixel_depth = 48; + } + } +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ +defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + if(png_ptr->transformations & PNG_USER_TRANSFORM) + { + int user_pixel_depth=png_ptr->user_transform_depth* + png_ptr->user_transform_channels; + if(user_pixel_depth > max_pixel_depth) + max_pixel_depth=user_pixel_depth; + } +#endif + + /* align the width on the next larger 8 pixels. Mainly used + for interlacing */ + row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); + /* calculate the maximum bytes needed, adding a byte and a pixel + for safety's sake */ + row_bytes = ((row_bytes * (png_uint_32)max_pixel_depth + 7) >> 3) + + 1 + ((max_pixel_depth + 7) >> 3); +#ifdef PNG_MAX_MALLOC_64K + if (row_bytes > (png_uint_32)65536L) + png_error(png_ptr, "This image requires a row greater than 64KB"); +#endif + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); + png_ptr->row_buf = png_ptr->big_row_buf+32; +#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) + png_ptr->row_buf_size = row_bytes; +#endif + +#ifdef PNG_MAX_MALLOC_64K + if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) + png_error(png_ptr, "This image requires a row greater than 64KB"); +#endif + png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( + png_ptr->rowbytes + 1)); + + png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + + png_debug1(3, "width = %lu,\n", png_ptr->width); + png_debug1(3, "height = %lu,\n", png_ptr->height); + png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); + png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); + png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); + png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); + + png_ptr->flags |= PNG_FLAG_ROW_INIT; +} diff --git a/src/libs/pdflib/libs/png/pngset.c b/src/libs/pdflib/libs/png/pngset.c new file mode 100644 index 0000000000..c5f9b17edf --- /dev/null +++ b/src/libs/pdflib/libs/png/pngset.c @@ -0,0 +1,1161 @@ +/* PDFlib GmbH cvsid: $Id: pngset.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngset.c - storage of image information into info struct + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * The functions here are used during reads to store data from the file + * into the info struct, and during writes to store application data + * into the info struct for writing into the file. This abstracts the + * info struct and allows us to change the structure in the future. + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_bKGD_SUPPORTED) +void PNGAPI +png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) +{ + png_debug1(1, "in %s storage function\n", "bKGD"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_memcpy(&(info_ptr->background), background, sizeof(png_color_16)); + info_ptr->valid |= PNG_INFO_bKGD; +} +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_cHRM(png_structp png_ptr, png_infop info_ptr, + double white_x, double white_y, double red_x, double red_y, + double green_x, double green_y, double blue_x, double blue_y) +{ + png_debug1(1, "in %s storage function\n", "cHRM"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (white_x < 0.0 || white_y < 0.0 || + red_x < 0.0 || red_y < 0.0 || + green_x < 0.0 || green_y < 0.0 || + blue_x < 0.0 || blue_y < 0.0) + { + png_warning(png_ptr, + "Ignoring attempt to set negative chromaticity value"); + return; + } + if (white_x > 21474.83 || white_y > 21474.83 || + red_x > 21474.83 || red_y > 21474.83 || + green_x > 21474.83 || green_y > 21474.83 || + blue_x > 21474.83 || blue_y > 21474.83) + { + png_warning(png_ptr, + "Ignoring attempt to set chromaticity value exceeding 21474.83"); + return; + } + + info_ptr->x_white = (float)white_x; + info_ptr->y_white = (float)white_y; + info_ptr->x_red = (float)red_x; + info_ptr->y_red = (float)red_y; + info_ptr->x_green = (float)green_x; + info_ptr->y_green = (float)green_y; + info_ptr->x_blue = (float)blue_x; + info_ptr->y_blue = (float)blue_y; +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); + info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); + info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); + info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); + info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); + info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); + info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); + info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); +#endif + info_ptr->valid |= PNG_INFO_cHRM; +} +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, + png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, + png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, + png_fixed_point blue_x, png_fixed_point blue_y) +{ + png_debug1(1, "in %s storage function\n", "cHRM"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (white_x < 0 || white_y < 0 || + red_x < 0 || red_y < 0 || + green_x < 0 || green_y < 0 || + blue_x < 0 || blue_y < 0) + { + png_warning(png_ptr, + "Ignoring attempt to set negative chromaticity value"); + return; + } + if (white_x > (double) PNG_MAX_UINT || white_y > (double) PNG_MAX_UINT || + red_x > (double) PNG_MAX_UINT || red_y > (double) PNG_MAX_UINT || + green_x > (double) PNG_MAX_UINT || green_y > (double) PNG_MAX_UINT || + blue_x > (double) PNG_MAX_UINT || blue_y > (double) PNG_MAX_UINT) + { + png_warning(png_ptr, + "Ignoring attempt to set chromaticity value exceeding 21474.83"); + return; + } + info_ptr->int_x_white = white_x; + info_ptr->int_y_white = white_y; + info_ptr->int_x_red = red_x; + info_ptr->int_y_red = red_y; + info_ptr->int_x_green = green_x; + info_ptr->int_y_green = green_y; + info_ptr->int_x_blue = blue_x; + info_ptr->int_y_blue = blue_y; +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->x_white = (float)(white_x/100000.); + info_ptr->y_white = (float)(white_y/100000.); + info_ptr->x_red = (float)( red_x/100000.); + info_ptr->y_red = (float)( red_y/100000.); + info_ptr->x_green = (float)(green_x/100000.); + info_ptr->y_green = (float)(green_y/100000.); + info_ptr->x_blue = (float)( blue_x/100000.); + info_ptr->y_blue = (float)( blue_y/100000.); +#endif + info_ptr->valid |= PNG_INFO_cHRM; +} +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) +{ + double tgamma; + png_debug1(1, "in %s storage function\n", "gAMA"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* Check for overflow */ + if (file_gamma > 21474.83) + { + png_warning(png_ptr, "Limiting gamma to 21474.83"); + tgamma=21474.83; + } + else + tgamma=file_gamma; + info_ptr->gamma = (float)tgamma; +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = (int)(tgamma*100000.+.5); +#endif + info_ptr->valid |= PNG_INFO_gAMA; + if(tgamma == 0.0) + png_warning(png_ptr, "Setting gamma=0"); +} +#endif +void PNGAPI +png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point + int_gamma) +{ + png_fixed_point tgamma; + + png_debug1(1, "in %s storage function\n", "gAMA"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (int_gamma > (png_fixed_point) PNG_MAX_UINT) + { + png_warning(png_ptr, "Limiting gamma to 21474.83"); + tgamma=PNG_MAX_UINT; + } + else + { + if (int_gamma < 0) + { + png_warning(png_ptr, "Setting negative gamma to zero"); + tgamma=0; + } + else + tgamma=int_gamma; + } +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->gamma = (float)(tgamma/100000.); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + info_ptr->int_gamma = tgamma; +#endif + info_ptr->valid |= PNG_INFO_gAMA; + if(tgamma == 0) + png_warning(png_ptr, "Setting gamma=0"); +} +#endif + +#if defined(PNG_hIST_SUPPORTED) +void PNGAPI +png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) +{ + int i; + + png_debug1(1, "in %s storage function\n", "hIST"); + if (png_ptr == NULL || info_ptr == NULL) + return; + if (info_ptr->num_palette == 0) + { + png_warning(png_ptr, + "Palette size 0, hIST allocation skipped."); + return; + } + +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); +#endif + /* Changed from info->num_palette to 256 in version 1.2.1 */ + png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, + (png_uint_32)(256 * sizeof (png_uint_16))); + if (png_ptr->hist == NULL) + { + png_warning(png_ptr, "Insufficient memory for hIST chunk data."); + return; + } + + for (i = 0; i < info_ptr->num_palette; i++) + png_ptr->hist[i] = hist[i]; + info_ptr->hist = png_ptr->hist; + info_ptr->valid |= PNG_INFO_hIST; + +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_HIST; +#else + png_ptr->flags |= PNG_FLAG_FREE_HIST; +#endif +} +#endif + +void PNGAPI +png_set_IHDR(png_structp png_ptr, png_infop info_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) +{ + int rowbytes_per_pixel; + png_debug1(1, "in %s storage function\n", "IHDR"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* check for width and height valid values */ + if (width == 0 || height == 0) + png_error(png_ptr, "Image width or height is zero in IHDR"); + if (width > PNG_MAX_UINT || height > PNG_MAX_UINT) + png_error(png_ptr, "Invalid image size in IHDR"); + + /* check other values */ + if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && + bit_depth != 8 && bit_depth != 16) + png_error(png_ptr, "Invalid bit depth in IHDR"); + + if (color_type < 0 || color_type == 1 || + color_type == 5 || color_type > 6) + png_error(png_ptr, "Invalid color type in IHDR"); + + if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || + ((color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) + png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); + + if (interlace_type >= PNG_INTERLACE_LAST) + png_error(png_ptr, "Unknown interlace method in IHDR"); + + if (compression_type != PNG_COMPRESSION_TYPE_BASE) + png_error(png_ptr, "Unknown compression method in IHDR"); + +#if defined(PNG_MNG_FEATURES_SUPPORTED) + /* Accept filter_method 64 (intrapixel differencing) only if + * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and + * 2. Libpng did not read a PNG signature (this filter_method is only + * used in PNG datastreams that are embedded in MNG datastreams) and + * 3. The application called png_permit_mng_features with a mask that + * included PNG_FLAG_MNG_FILTER_64 and + * 4. The filter_method is 64 and + * 5. The color_type is RGB or RGBA + */ + if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) + png_warning(png_ptr,"MNG features are not allowed in a PNG datastream\n"); + if(filter_type != PNG_FILTER_TYPE_BASE) + { + if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && + ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA))) + png_error(png_ptr, "Unknown filter method in IHDR"); + if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) + png_warning(png_ptr, "Invalid filter method in IHDR"); + } +#else + if(filter_type != PNG_FILTER_TYPE_BASE) + png_error(png_ptr, "Unknown filter method in IHDR"); +#endif + + info_ptr->width = width; + info_ptr->height = height; + info_ptr->bit_depth = (png_byte)bit_depth; + info_ptr->color_type =(png_byte) color_type; + info_ptr->compression_type = (png_byte)compression_type; + info_ptr->filter_type = (png_byte)filter_type; + info_ptr->interlace_type = (png_byte)interlace_type; + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + info_ptr->channels = 1; + else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) + info_ptr->channels = 3; + else + info_ptr->channels = 1; + if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) + info_ptr->channels++; + info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); + + /* check for overflow */ + rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3; + if ( width > PNG_MAX_UINT/rowbytes_per_pixel - 64) + { + png_warning(png_ptr, + "Width too large to process image data; rowbytes will overflow."); + info_ptr->rowbytes = (png_size_t)0; + } + else + info_ptr->rowbytes = (info_ptr->width * info_ptr->pixel_depth + 7) >> 3; +} + +#if defined(PNG_oFFs_SUPPORTED) +void PNGAPI +png_set_oFFs(png_structp png_ptr, png_infop info_ptr, + png_int_32 offset_x, png_int_32 offset_y, int unit_type) +{ + png_debug1(1, "in %s storage function\n", "oFFs"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->x_offset = offset_x; + info_ptr->y_offset = offset_y; + info_ptr->offset_unit_type = (png_byte)unit_type; + info_ptr->valid |= PNG_INFO_oFFs; +} +#endif + +#if defined(PNG_pCAL_SUPPORTED) +void PNGAPI +png_set_pCAL(png_structp png_ptr, png_infop info_ptr, + png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params) +{ + png_uint_32 length; + int i; + + png_debug1(1, "in %s storage function\n", "pCAL"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + length = png_strlen(purpose) + 1; + png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); + info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->pcal_purpose == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL purpose."); + return; + } + png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); + + png_debug(3, "storing X0, X1, type, and nparams in info\n"); + info_ptr->pcal_X0 = X0; + info_ptr->pcal_X1 = X1; + info_ptr->pcal_type = (png_byte)type; + info_ptr->pcal_nparams = (png_byte)nparams; + + length = png_strlen(units) + 1; + png_debug1(3, "allocating units for info (%lu bytes)\n", length); + info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->pcal_units == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL units."); + return; + } + png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); + + info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, + (png_uint_32)((nparams + 1) * sizeof(png_charp))); + if (info_ptr->pcal_params == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL params."); + return; + } + + info_ptr->pcal_params[nparams] = NULL; + + for (i = 0; i < nparams; i++) + { + length = png_strlen(params[i]) + 1; + png_debug2(3,"allocating parameter %d for info (%lu bytes)\n", i, length); + info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); + if (info_ptr->pcal_params[i] == NULL) + { + png_warning(png_ptr, "Insufficient memory for pCAL parameter."); + return; + } + png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); + } + + info_ptr->valid |= PNG_INFO_pCAL; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_PCAL; +#endif +} +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_sCAL(png_structp png_ptr, png_infop info_ptr, + int unit, double width, double height) +{ + png_debug1(1, "in %s storage function\n", "sCAL"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->scal_unit = (png_byte)unit; + info_ptr->scal_pixel_width = width; + info_ptr->scal_pixel_height = height; + + info_ptr->valid |= PNG_INFO_sCAL; +} +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +void PNGAPI +png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, + int unit, png_charp swidth, png_charp sheight) +{ + png_uint_32 length; + + png_debug1(1, "in %s storage function\n", "sCAL"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->scal_unit = (png_byte)unit; + + length = png_strlen(swidth) + 1; + png_debug1(3, "allocating unit for info (%d bytes)\n", length); + info_ptr->scal_s_width = (png_charp)png_malloc(png_ptr, length); + png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); + + length = png_strlen(sheight) + 1; + png_debug1(3, "allocating unit for info (%d bytes)\n", length); + info_ptr->scal_s_height = (png_charp)png_malloc(png_ptr, length); + png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); + + info_ptr->valid |= PNG_INFO_sCAL; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_SCAL; +#endif +} +#endif +#endif +#endif + +#if defined(PNG_pHYs_SUPPORTED) +void PNGAPI +png_set_pHYs(png_structp png_ptr, png_infop info_ptr, + png_uint_32 res_x, png_uint_32 res_y, int unit_type) +{ + png_debug1(1, "in %s storage function\n", "pHYs"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->x_pixels_per_unit = res_x; + info_ptr->y_pixels_per_unit = res_y; + info_ptr->phys_unit_type = (png_byte)unit_type; + info_ptr->valid |= PNG_INFO_pHYs; +} +#endif + +void PNGAPI +png_set_PLTE(png_structp png_ptr, png_infop info_ptr, + png_colorp palette, int num_palette) +{ + + png_debug1(1, "in %s storage function\n", "PLTE"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* + * It may not actually be necessary to set png_ptr->palette here; + * we do it for backward compatibility with the way the png_handle_tRNS + * function used to do the allocation. + */ +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); +#endif + /* Changed in libpng-1.2.1 to allocate 256 instead of num_palette entries, + in case of an invalid PNG file that has too-large sample values. */ + png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)256, + sizeof (png_color)); + if (png_ptr->palette == NULL) + png_error(png_ptr, "Unable to malloc palette"); + png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color)); + info_ptr->palette = png_ptr->palette; + info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; + +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_PLTE; +#else + png_ptr->flags |= PNG_FLAG_FREE_PLTE; +#endif + + info_ptr->valid |= PNG_INFO_PLTE; +} + +#if defined(PNG_sBIT_SUPPORTED) +void PNGAPI +png_set_sBIT(png_structp png_ptr, png_infop info_ptr, + png_color_8p sig_bit) +{ + png_debug1(1, "in %s storage function\n", "sBIT"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_memcpy(&(info_ptr->sig_bit), sig_bit, sizeof (png_color_8)); + info_ptr->valid |= PNG_INFO_sBIT; +} +#endif + +#if defined(PNG_sRGB_SUPPORTED) +void PNGAPI +png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) +{ + png_debug1(1, "in %s storage function\n", "sRGB"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + info_ptr->srgb_intent = (png_byte)intent; + info_ptr->valid |= PNG_INFO_sRGB; +} + +void PNGAPI +png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, + int intent) +{ +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + float file_gamma; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_fixed_point int_file_gamma; +#endif +#endif +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, + int_green_y, int_blue_x, int_blue_y; +#endif +#endif + png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + png_set_sRGB(png_ptr, info_ptr, intent); + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED + file_gamma = (float).45455; + png_set_gAMA(png_ptr, info_ptr, file_gamma); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + int_file_gamma = 45455L; + png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FIXED_POINT_SUPPORTED + int_white_x = 31270L; + int_white_y = 32900L; + int_red_x = 64000L; + int_red_y = 33000L; + int_green_x = 30000L; + int_green_y = 60000L; + int_blue_x = 15000L; + int_blue_y = 6000L; + + png_set_cHRM_fixed(png_ptr, info_ptr, + int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, + int_blue_x, int_blue_y); +#endif +#ifdef PNG_FLOATING_POINT_SUPPORTED + white_x = (float).3127; + white_y = (float).3290; + red_x = (float).64; + red_y = (float).33; + green_x = (float).30; + green_y = (float).60; + blue_x = (float).15; + blue_y = (float).06; + + png_set_cHRM(png_ptr, info_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); +#endif +#endif +} +#endif + + +#if defined(PNG_iCCP_SUPPORTED) +void PNGAPI +png_set_iCCP(png_structp png_ptr, png_infop info_ptr, + png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen) +{ + png_charp new_iccp_name; + png_charp new_iccp_profile; + + png_debug1(1, "in %s storage function\n", "iCCP"); + if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) + return; + + new_iccp_name = (png_charp)png_malloc(png_ptr, png_strlen(name)+1); + png_strcpy(new_iccp_name, name); + new_iccp_profile = (png_charp)png_malloc(png_ptr, proflen); + png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); + + png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); + + info_ptr->iccp_proflen = proflen; + info_ptr->iccp_name = new_iccp_name; + info_ptr->iccp_profile = new_iccp_profile; + /* Compression is always zero but is here so the API and info structure + * does not have to change if we introduce multiple compression types */ + info_ptr->iccp_compression = (png_byte)compression_type; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_ICCP; +#endif + info_ptr->valid |= PNG_INFO_iCCP; +} +#endif + +#if defined(PNG_TEXT_SUPPORTED) +void PNGAPI +png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, + int num_text) +{ + int ret; + ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); + if (ret) + png_error(png_ptr, "Insufficient memory to store text"); +} + +int /* PRIVATE */ +png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, + int num_text) +{ + int i; + + png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? + "text" : (png_const_charp)png_ptr->chunk_name)); + + if (png_ptr == NULL || info_ptr == NULL || num_text == 0) + return(0); + + /* Make sure we have enough space in the "text" array in info_struct + * to hold all of the incoming text_ptr objects. + */ + if (info_ptr->num_text + num_text > info_ptr->max_text) + { + if (info_ptr->text != NULL) + { + png_textp old_text; + int old_max; + + old_max = info_ptr->max_text; + info_ptr->max_text = info_ptr->num_text + num_text + 8; + old_text = info_ptr->text; + info_ptr->text = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)(info_ptr->max_text * sizeof (png_text))); + if (info_ptr->text == NULL) + { + png_free(png_ptr, old_text); + return(1); + } + png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * + sizeof(png_text))); + png_free(png_ptr, old_text); + } + else + { + info_ptr->max_text = num_text + 8; + info_ptr->num_text = 0; + info_ptr->text = (png_textp)png_malloc_warn(png_ptr, + (png_uint_32)(info_ptr->max_text * sizeof (png_text))); + if (info_ptr->text == NULL) + return(1); +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_TEXT; +#endif + } + png_debug1(3, "allocated %d entries for info_ptr->text\n", + info_ptr->max_text); + } + for (i = 0; i < num_text; i++) + { + png_size_t text_length,key_len; + png_size_t lang_len,lang_key_len; + png_textp textp = &(info_ptr->text[info_ptr->num_text]); + + if (text_ptr[i].key == NULL) + continue; + + key_len = png_strlen(text_ptr[i].key); + + if(text_ptr[i].compression <= 0) + { + lang_len = 0; + lang_key_len = 0; + } + else +#ifdef PNG_iTXt_SUPPORTED + { + /* set iTXt data */ + if (text_ptr[i].lang != NULL) + lang_len = png_strlen(text_ptr[i].lang); + else + lang_len = 0; + if (text_ptr[i].lang_key != NULL) + lang_key_len = png_strlen(text_ptr[i].lang_key); + else + lang_key_len = 0; + } +#else + { + png_warning(png_ptr, "iTXt chunk not supported."); + continue; + } +#endif + + if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') + { + text_length = 0; +#ifdef PNG_iTXt_SUPPORTED + if(text_ptr[i].compression > 0) + textp->compression = PNG_ITXT_COMPRESSION_NONE; + else +#endif + textp->compression = PNG_TEXT_COMPRESSION_NONE; + } + else + { + text_length = png_strlen(text_ptr[i].text); + textp->compression = text_ptr[i].compression; + } + + textp->key = (png_charp)png_malloc_warn(png_ptr, + (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); + if (textp->key == NULL) + return(1); + png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", + (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), + (int)textp->key); + + png_memcpy(textp->key, text_ptr[i].key, + (png_size_t)(key_len)); + *(textp->key+key_len) = '\0'; +#ifdef PNG_iTXt_SUPPORTED + if (text_ptr[i].compression > 0) + { + textp->lang=textp->key + key_len + 1; + png_memcpy(textp->lang, text_ptr[i].lang, lang_len); + *(textp->lang+lang_len) = '\0'; + textp->lang_key=textp->lang + lang_len + 1; + png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); + *(textp->lang_key+lang_key_len) = '\0'; + textp->text=textp->lang_key + lang_key_len + 1; + } + else +#endif + { +#ifdef PNG_iTXt_SUPPORTED + textp->lang=NULL; + textp->lang_key=NULL; +#endif + textp->text=textp->key + key_len + 1; + } + if(text_length) + png_memcpy(textp->text, text_ptr[i].text, + (png_size_t)(text_length)); + *(textp->text+text_length) = '\0'; + +#ifdef PNG_iTXt_SUPPORTED + if(textp->compression > 0) + { + textp->text_length = 0; + textp->itxt_length = text_length; + } + else +#endif + { + textp->text_length = text_length; +#ifdef PNG_iTXt_SUPPORTED + textp->itxt_length = 0; +#endif + } + info_ptr->text[info_ptr->num_text]= *textp; + info_ptr->num_text++; + png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); + } + return(0); +} +#endif + +#if defined(PNG_tIME_SUPPORTED) +void PNGAPI +png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) +{ + png_debug1(1, "in %s storage function\n", "tIME"); + if (png_ptr == NULL || info_ptr == NULL || + (png_ptr->mode & PNG_WROTE_tIME)) + return; + + png_memcpy(&(info_ptr->mod_time), mod_time, sizeof (png_time)); + info_ptr->valid |= PNG_INFO_tIME; +} +#endif + +#if defined(PNG_tRNS_SUPPORTED) +void PNGAPI +png_set_tRNS(png_structp png_ptr, png_infop info_ptr, + png_bytep trans, int num_trans, png_color_16p trans_values) +{ + png_debug1(1, "in %s storage function\n", "tRNS"); + if (png_ptr == NULL || info_ptr == NULL) + return; + + if (trans != NULL) + { + /* + * It may not actually be necessary to set png_ptr->trans here; + * we do it for backward compatibility with the way the png_handle_tRNS + * function used to do the allocation. + */ +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); +#endif + /* Changed from num_trans to 256 in version 1.2.1 */ + png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, + (png_uint_32)256); + png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_TRNS; +#else + png_ptr->flags |= PNG_FLAG_FREE_TRNS; +#endif + } + + if (trans_values != NULL) + { + png_memcpy(&(info_ptr->trans_values), trans_values, + sizeof(png_color_16)); + if (num_trans == 0) + num_trans = 1; + } + info_ptr->num_trans = (png_uint_16)num_trans; + info_ptr->valid |= PNG_INFO_tRNS; +} +#endif + +#if defined(PNG_sPLT_SUPPORTED) +void PNGAPI +png_set_sPLT(png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries) +{ + png_sPLT_tp np; + int i; + + np = (png_sPLT_tp)png_malloc_warn(png_ptr, + (info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t)); + if (np == NULL) + { + png_warning(png_ptr, "No memory for sPLT palettes."); + return; + } + + png_memcpy(np, info_ptr->splt_palettes, + info_ptr->splt_palettes_num * sizeof(png_sPLT_t)); + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes=NULL; + + for (i = 0; i < nentries; i++) + { + png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; + png_sPLT_tp from = entries + i; + + to->name = (png_charp)png_malloc(png_ptr, + png_strlen(from->name) + 1); + png_strcpy(to->name, from->name); + to->entries = (png_sPLT_entryp)png_malloc(png_ptr, + from->nentries * sizeof(png_sPLT_t)); + png_memcpy(to->entries, from->entries, + from->nentries * sizeof(png_sPLT_t)); + to->nentries = from->nentries; + to->depth = from->depth; + } + + info_ptr->splt_palettes = np; + info_ptr->splt_palettes_num += nentries; + info_ptr->valid |= PNG_INFO_sPLT; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_SPLT; +#endif +} +#endif /* PNG_sPLT_SUPPORTED */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +void PNGAPI +png_set_unknown_chunks(png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) +{ + png_unknown_chunkp np; + int i; + + if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) + return; + + np = (png_unknown_chunkp)png_malloc_warn(png_ptr, + (info_ptr->unknown_chunks_num + num_unknowns) * + sizeof(png_unknown_chunk)); + if (np == NULL) + { + png_warning(png_ptr, "Out of memory while processing unknown chunk."); + return; + } + + png_memcpy(np, info_ptr->unknown_chunks, + info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk)); + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks=NULL; + + for (i = 0; i < num_unknowns; i++) + { + png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; + png_unknown_chunkp from = unknowns + i; + + png_strcpy((png_charp)to->name, (png_charp)from->name); + to->data = (png_bytep)png_malloc(png_ptr, from->size); + if (to->data == NULL) + png_warning(png_ptr,"Out of memory while processing unknown chunk."); + else + { + png_memcpy(to->data, from->data, from->size); + to->size = from->size; + + /* note our location in the read or write sequence */ + to->location = (png_byte)(png_ptr->mode & 0xff); + } + } + + info_ptr->unknown_chunks = np; + info_ptr->unknown_chunks_num += num_unknowns; +#ifdef PNG_FREE_ME_SUPPORTED + info_ptr->free_me |= PNG_FREE_UNKN; +#endif +} +void PNGAPI +png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, + int chunk, int location) +{ + if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < + (int)info_ptr->unknown_chunks_num) + info_ptr->unknown_chunks[chunk].location = (png_byte)location; +} +#endif + +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +void PNGAPI +png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) +{ + /* This function is deprecated in favor of png_permit_mng_features() + and will be removed from libpng-2.0.0 */ + png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); + if (png_ptr == NULL) + return; + png_ptr->mng_features_permitted = (png_byte) + ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | + ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); +} +#endif + +#if defined(PNG_MNG_FEATURES_SUPPORTED) +png_uint_32 PNGAPI +png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) +{ + png_debug(1, "in png_permit_mng_features\n"); + if (png_ptr == NULL) + return (png_uint_32)0; + png_ptr->mng_features_permitted = + (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); + return (png_uint_32)png_ptr->mng_features_permitted; +} +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +void PNGAPI +png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep + chunk_list, int num_chunks) +{ + png_bytep new_list, p; + int i, old_num_chunks; + if (num_chunks == 0) + { + if(keep == HANDLE_CHUNK_ALWAYS || keep == HANDLE_CHUNK_IF_SAFE) + png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + else + png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + + if(keep == HANDLE_CHUNK_ALWAYS) + png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; + else + png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; + return; + } + if (chunk_list == NULL) + return; + old_num_chunks=png_ptr->num_chunk_list; + new_list=(png_bytep)png_malloc(png_ptr, + (png_uint_32)(5*(num_chunks+old_num_chunks))); + if(png_ptr->chunk_list != NULL) + { + png_memcpy(new_list, png_ptr->chunk_list, + (png_size_t)(5*old_num_chunks)); + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + } + png_memcpy(new_list+5*old_num_chunks, chunk_list, + (png_size_t)(5*num_chunks)); + for (p=new_list+5*old_num_chunks+4, i=0; inum_chunk_list=old_num_chunks+num_chunks; + png_ptr->chunk_list=new_list; +#ifdef PNG_FREE_ME_SUPPORTED + png_ptr->free_me |= PNG_FREE_LIST; +#endif +} +#endif + +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) +void PNGAPI +png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, + png_user_chunk_ptr read_user_chunk_fn) +{ + png_debug(1, "in png_set_read_user_chunk_fn\n"); + png_ptr->read_user_chunk_fn = read_user_chunk_fn; + png_ptr->user_chunk_ptr = user_chunk_ptr; +} +#endif + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +void PNGAPI +png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) +{ + png_debug1(1, "in %s storage function\n", "rows"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) + png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); + info_ptr->row_pointers = row_pointers; + if(row_pointers) + info_ptr->valid |= PNG_INFO_IDAT; +} +#endif + +void PNGAPI +png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) +{ + if(png_ptr->zbuf) + png_free(png_ptr, png_ptr->zbuf); + png_ptr->zbuf_size = (png_size_t)size; + png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); + png_ptr->zstream.next_out = png_ptr->zbuf; + png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; +} + +void PNGAPI +png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) +{ + if (png_ptr && info_ptr) + info_ptr->valid &= ~(mask); +} + + +#ifndef PNG_1_0_X +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +/* this function was added to libpng 1.2.0 and should always exist by default */ +void PNGAPI +png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) +{ + png_uint_32 settable_asm_flags; + png_uint_32 settable_mmx_flags; + + settable_mmx_flags = +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW | +#endif +#ifdef PNG_HAVE_ASSEMBLER_READ_INTERLACE + PNG_ASM_FLAG_MMX_READ_INTERLACE | +#endif +#ifdef PNG_HAVE_ASSEMBLER_READ_FILTER_ROW + PNG_ASM_FLAG_MMX_READ_FILTER_SUB | + PNG_ASM_FLAG_MMX_READ_FILTER_UP | + PNG_ASM_FLAG_MMX_READ_FILTER_AVG | + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH | +#endif + 0; + + /* could be some non-MMX ones in the future, but not currently: */ + settable_asm_flags = settable_mmx_flags; + + if (!(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) || + !(png_ptr->asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)) + { + /* clear all MMX flags if MMX isn't supported */ + settable_asm_flags &= ~settable_mmx_flags; + png_ptr->asm_flags &= ~settable_mmx_flags; + } + + /* we're replacing the settable bits with those passed in by the user, + * so first zero them out of the master copy, then logical-OR in the + * allowed subset that was requested */ + + png_ptr->asm_flags &= ~settable_asm_flags; /* zero them */ + png_ptr->asm_flags |= (asm_flags & settable_asm_flags); /* set them */ +} +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ + +#ifdef PNG_ASSEMBLER_CODE_SUPPORTED +/* this function was added to libpng 1.2.0 */ +void PNGAPI +png_set_mmx_thresholds (png_structp png_ptr, + png_byte mmx_bitdepth_threshold, + png_uint_32 mmx_rowbytes_threshold) +{ + png_ptr->mmx_bitdepth_threshold = mmx_bitdepth_threshold; + png_ptr->mmx_rowbytes_threshold = mmx_rowbytes_threshold; +} +#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ +#endif /* ?PNG_1_0_X */ diff --git a/src/libs/pdflib/libs/png/pngtrans.c b/src/libs/pdflib/libs/png/pngtrans.c new file mode 100644 index 0000000000..34be99419e --- /dev/null +++ b/src/libs/pdflib/libs/png/pngtrans.c @@ -0,0 +1,641 @@ +/* PDFlib GmbH cvsid: $Id: pngtrans.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +/* pngtrans.c - transforms the data in a row (used by both readers and writers) + * + * libpng 1.2.5 - October 3, 2002 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2002 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* turn on BGR-to-RGB mapping */ +void PNGAPI +png_set_bgr(png_structp png_ptr) +{ + png_debug(1, "in png_set_bgr\n"); + png_ptr->transformations |= PNG_BGR; +} +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* turn on 16 bit byte swapping */ +void PNGAPI +png_set_swap(png_structp png_ptr) +{ + png_debug(1, "in png_set_swap\n"); + if (png_ptr->bit_depth == 16) + png_ptr->transformations |= PNG_SWAP_BYTES; +} +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* turn on pixel packing */ +void PNGAPI +png_set_packing(png_structp png_ptr) +{ + png_debug(1, "in png_set_packing\n"); + if (png_ptr->bit_depth < 8) + { + png_ptr->transformations |= PNG_PACK; + png_ptr->usr_bit_depth = 8; + } +} +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* turn on packed pixel swapping */ +void PNGAPI +png_set_packswap(png_structp png_ptr) +{ + png_debug(1, "in png_set_packswap\n"); + if (png_ptr->bit_depth < 8) + png_ptr->transformations |= PNG_PACKSWAP; +} +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +void PNGAPI +png_set_shift(png_structp png_ptr, png_color_8p true_bits) +{ + png_debug(1, "in png_set_shift\n"); + png_ptr->transformations |= PNG_SHIFT; + png_ptr->shift = *true_bits; +} +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +int PNGAPI +png_set_interlace_handling(png_structp png_ptr) +{ + png_debug(1, "in png_set_interlace handling\n"); + if (png_ptr->interlaced) + { + png_ptr->transformations |= PNG_INTERLACE; + return (7); + } + + return (1); +} +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte on read, or remove a filler or alpha byte on write. + * The filler type has changed in v0.95 to allow future 2-byte fillers + * for 48-bit input data, as well as to avoid problems with some compilers + * that don't like bytes as parameters. + */ +void PNGAPI +png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) +{ + png_debug(1, "in png_set_filler\n"); + png_ptr->transformations |= PNG_FILLER; + png_ptr->filler = (png_byte)filler; + if (filler_loc == PNG_FILLER_AFTER) + png_ptr->flags |= PNG_FLAG_FILLER_AFTER; + else + png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; + + /* This should probably go in the "do_filler" routine. + * I attempted to do that in libpng-1.0.1a but that caused problems + * so I restored it in libpng-1.0.2a + */ + + if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) + { + png_ptr->usr_channels = 4; + } + + /* Also I added this in libpng-1.0.2a (what happens when we expand + * a less-than-8-bit grayscale to GA? */ + + if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) + { + png_ptr->usr_channels = 2; + } +} +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +void PNGAPI +png_set_swap_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_swap_alpha\n"); + png_ptr->transformations |= PNG_SWAP_ALPHA; +} +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +void PNGAPI +png_set_invert_alpha(png_structp png_ptr) +{ + png_debug(1, "in png_set_invert_alpha\n"); + png_ptr->transformations |= PNG_INVERT_ALPHA; +} +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +void PNGAPI +png_set_invert_mono(png_structp png_ptr) +{ + png_debug(1, "in png_set_invert_mono\n"); + png_ptr->transformations |= PNG_INVERT_MONO; +} + +/* invert monochrome grayscale data */ +void /* PRIVATE */ +png_do_invert(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_invert\n"); + /* This test removed from libpng version 1.0.13 and 1.2.0: + * if (row_info->bit_depth == 1 && + */ +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row == NULL || row_info == NULL) + return; +#endif + if (row_info->color_type == PNG_COLOR_TYPE_GRAY) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(~(*rp)); + rp++; + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + row_info->bit_depth == 8) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + + for (i = 0; i < istop; i+=2) + { + *rp = (png_byte)(~(*rp)); + rp+=2; + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && + row_info->bit_depth == 16) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + + for (i = 0; i < istop; i+=4) + { + *rp = (png_byte)(~(*rp)); + *(rp+1) = (png_byte)(~(*(rp+1))); + rp+=4; + } + } +} +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* swaps byte order on 16 bit depth images */ +void /* PRIVATE */ +png_do_swap(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_swap\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->bit_depth == 16) + { + png_bytep rp = row; + png_uint_32 i; + png_uint_32 istop= row_info->width * row_info->channels; + + for (i = 0; i < istop; i++, rp += 2) + { + png_byte t = *rp; + *rp = *(rp + 1); + *(rp + 1) = t; + } + } +} +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) +static png_byte onebppswaptable[256] = { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, + 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, + 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, + 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, + 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, + 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, + 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, + 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, + 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, + 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, + 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, + 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, + 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, + 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, + 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, + 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, + 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF +}; + +static png_byte twobppswaptable[256] = { + 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, + 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, + 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, + 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, + 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, + 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, + 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, + 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, + 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, + 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, + 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, + 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, + 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, + 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, + 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, + 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, + 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, + 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, + 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, + 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, + 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, + 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, + 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, + 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, + 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, + 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, + 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, + 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, + 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, + 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, + 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, + 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF +}; + +static png_byte fourbppswaptable[256] = { + 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, + 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, + 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, + 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, + 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, + 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, + 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, + 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, + 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, + 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, + 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, + 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, + 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, + 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, + 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, + 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, + 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, + 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, + 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, + 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, + 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, + 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, + 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, + 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, + 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, + 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, + 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, + 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, + 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, + 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, + 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, + 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF +}; + +/* swaps pixel packing order within bytes */ +void /* PRIVATE */ +png_do_packswap(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_packswap\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + row_info->bit_depth < 8) + { + png_bytep rp, end, table; + + end = row + row_info->rowbytes; + + if (row_info->bit_depth == 1) + table = onebppswaptable; + else if (row_info->bit_depth == 2) + table = twobppswaptable; + else if (row_info->bit_depth == 4) + table = fourbppswaptable; + else + return; + + for (rp = row; rp < end; rp++) + *rp = table[*rp]; + } +} +#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +/* remove filler or alpha byte(s) */ +void /* PRIVATE */ +png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) +{ + png_debug(1, "in png_do_strip_filler\n"); +#if defined(PNG_USELESS_TESTS_SUPPORTED) + if (row != NULL && row_info != NULL) +#endif + { +/* + if (row_info->color_type == PNG_COLOR_TYPE_RGB || + row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) +*/ + png_bytep sp=row; + png_bytep dp=row; + png_uint_32 row_width=row_info->width; + png_uint_32 i; + + if (row_info->channels == 4) + { + if (row_info->bit_depth == 8) + { + /* This converts from RGBX or RGBA to RGB */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + dp+=3; sp+=4; + for (i = 1; i < row_width; i++) + { + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + sp++; + } + } + /* This converts from XRGB or ARGB to RGB */ + else + { + for (i = 0; i < row_width; i++) + { + sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 24; + row_info->rowbytes = row_width * 3; + } + else /* if (row_info->bit_depth == 16) */ + { + if (flags & PNG_FLAG_FILLER_AFTER) + { + /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ + sp += 8; dp += 6; + for (i = 1; i < row_width; i++) + { + /* This could be (although png_memcpy is probably slower): + png_memcpy(dp, sp, 6); + sp += 8; + dp += 6; + */ + + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + sp += 2; + } + } + else + { + /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ + for (i = 0; i < row_width; i++) + { + /* This could be (although png_memcpy is probably slower): + png_memcpy(dp, sp, 6); + sp += 8; + dp += 6; + */ + + sp+=2; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 48; + row_info->rowbytes = row_width * 6; + } + row_info->channels = 3; + row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; + } +/* + else if (row_info->color_type == PNG_COLOR_TYPE_GRAY || + row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) +*/ + else if (row_info->channels == 2) + { + if (row_info->bit_depth == 8) + { + /* This converts from GX or GA to G */ + if (flags & PNG_FLAG_FILLER_AFTER) + { + for (i = 0; i < row_width; i++) + { + *dp++ = *sp++; + sp++; + } + } + /* This converts from XG or AG to G */ + else + { + for (i = 0; i < row_width; i++) + { + sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 8; + row_info->rowbytes = row_width; + } + else /* if (row_info->bit_depth == 16) */ + { + if (flags & PNG_FLAG_FILLER_AFTER) + { + /* This converts from GGXX or GGAA to GG */ + sp += 4; dp += 2; + for (i = 1; i < row_width; i++) + { + *dp++ = *sp++; + *dp++ = *sp++; + sp += 2; + } + } + else + { + /* This converts from XXGG or AAGG to GG */ + for (i = 0; i < row_width; i++) + { + sp += 2; + *dp++ = *sp++; + *dp++ = *sp++; + } + } + row_info->pixel_depth = 16; + row_info->rowbytes = row_width * 2; + } + row_info->channels = 1; + row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; + } + } +} +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* swaps red and blue bytes within a pixel */ +void /* PRIVATE */ +png_do_bgr(png_row_infop row_info, png_bytep row) +{ + png_debug(1, "in png_do_bgr\n"); + if ( +#if defined(PNG_USELESS_TESTS_SUPPORTED) + row != NULL && row_info != NULL && +#endif + (row_info->color_type & PNG_COLOR_MASK_COLOR)) + { + png_uint_32 row_width = row_info->width; + if (row_info->bit_depth == 8) + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 3) + { + png_byte save = *rp; + *rp = *(rp + 2); + *(rp + 2) = save; + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 4) + { + png_byte save = *rp; + *rp = *(rp + 2); + *(rp + 2) = save; + } + } + } + else if (row_info->bit_depth == 16) + { + if (row_info->color_type == PNG_COLOR_TYPE_RGB) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 6) + { + png_byte save = *rp; + *rp = *(rp + 4); + *(rp + 4) = save; + save = *(rp + 1); + *(rp + 1) = *(rp + 5); + *(rp + 5) = save; + } + } + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { + png_bytep rp; + png_uint_32 i; + + for (i = 0, rp = row; i < row_width; i++, rp += 8) + { + png_byte save = *rp; + *rp = *(rp + 4); + *(rp + 4) = save; + save = *(rp + 1); + *(rp + 1) = *(rp + 5); + *(rp + 5) = save; + } + } + } + } +} +#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +void PNGAPI +png_set_user_transform_info(png_structp png_ptr, png_voidp + user_transform_ptr, int user_transform_depth, int user_transform_channels) +{ + png_debug(1, "in png_set_user_transform_info\n"); +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + png_ptr->user_transform_ptr = user_transform_ptr; + png_ptr->user_transform_depth = (png_byte)user_transform_depth; + png_ptr->user_transform_channels = (png_byte)user_transform_channels; +#else + if(user_transform_ptr || user_transform_depth || user_transform_channels) + png_warning(png_ptr, + "This version of libpng does not support user transform info"); +#endif +} +#endif + +/* This function returns a pointer to the user_transform_ptr associated with + * the user transform functions. The application should free any memory + * associated with this pointer before png_write_destroy and png_read_destroy + * are called. + */ +png_voidp PNGAPI +png_get_user_transform_ptr(png_structp png_ptr) +{ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) + return ((png_voidp)png_ptr->user_transform_ptr); +#else + if(png_ptr) + return (NULL); + return (NULL); +#endif +} diff --git a/src/libs/pdflib/libs/png/pngvcrd.c b/src/libs/pdflib/libs/png/pngvcrd.c new file mode 100644 index 0000000000..9a315ec401 --- /dev/null +++ b/src/libs/pdflib/libs/png/pngvcrd.c @@ -0,0 +1,3856 @@ +/* pngvcrd.c - mixed C/assembler version of utilities to read a PNG file + * + * For Intel x86 CPU and Microsoft Visual C++ compiler + * + * libpng 1.0.8 - July 24, 2000 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson + * Copyright (c) 1998, Intel Corporation + * + * Contributed by Nirav Chhatrapati, Intel Corporation, 1998 + * Interface to libpng contributed by Gilles Vollant, 1999 + * + */ + +/* $Id: pngvcrd.c,v 1.1 2004/10/06 17:46:50 laplace Exp $ */ + +#define PNG_INTERNAL +#include "png.h" + +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_USE_PNGVCRD) + +/* + One of these might need to be defined. +#define DISABLE_PNGVCRD_COMBINE +#define DISABLE_PNGVCRD_INTERLACE +*/ + +static int mmx_supported=2; + +void /* PRIVATE */ +png_read_filter_row_c(png_structp png_ptr, png_row_infop row_info, + png_bytep row, png_bytep prev_row, int filter); + +static int mmxsupport() +{ + int mmx_supported_local = 0; + _asm { + push ebx //CPUID will trash these + push ecx + push edx + pushfd //Save Eflag to stack + pop eax //Get Eflag from stack into eax + mov ecx, eax //Make another copy of Eflag in ecx + xor eax, 0x200000 //Toggle ID bit in Eflag [i.e. bit(21)] + push eax //Save modified Eflag back to stack + + popfd //Restored modified value back to Eflag reg + pushfd //Save Eflag to stack + pop eax //Get Eflag from stack + xor eax, ecx //Compare the new Eflag with the original Eflag + jz NOT_SUPPORTED //If the same, CPUID instruction is not supported, + //skip following instructions and jump to + //NOT_SUPPORTED label + + xor eax, eax //Set eax to zero + + _asm _emit 0x0f //CPUID instruction (two bytes opcode) + _asm _emit 0xa2 + + cmp eax, 1 //make sure eax return non-zero value + jl NOT_SUPPORTED //If eax is zero, mmx not supported + + xor eax, eax //set eax to zero + inc eax //Now increment eax to 1. This instruction is + //faster than the instruction "mov eax, 1" + + _asm _emit 0x0f //CPUID instruction + _asm _emit 0xa2 + + and edx, 0x00800000 //mask out all bits but mmx bit(24) + cmp edx, 0 // 0 = mmx not supported + jz NOT_SUPPORTED // non-zero = Yes, mmx IS supported + + mov mmx_supported_local, 1 //set return value to 1 + +NOT_SUPPORTED: + mov eax, mmx_supported_local //move return value to eax + pop edx //CPUID trashed these + pop ecx + pop ebx + } + + //mmx_supported_local=0; // test code for force don't support MMX + //printf("MMX : %u (1=MMX supported)\n",mmx_supported_local); + + return mmx_supported_local; +} + +/* Combines the row recently read in with the previous row. + This routine takes care of alpha and transparency if requested. + This routine also handles the two methods of progressive display + of interlaced images, depending on the mask value. + The mask value describes which pixels are to be combined with + the row. The pattern always repeats every 8 pixels, so just 8 + bits are needed. A one indicates the pixel is to be combined; a + zero indicates the pixel is to be skipped. This is in addition + to any alpha or transparency value associated with the pixel. If + you want all pixels to be combined, pass 0xff (255) in mask. */ + +/* Use this routine for x86 platform - uses faster MMX routine if machine + supports MMX */ + +void /* PRIVATE */ +png_combine_row(png_structp png_ptr, png_bytep row, int mask) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif +#ifdef DISABLE_PNGVCRD_COMBINE + int save_mmx_supported = mmx_supported; +#endif + + png_debug(1,"in png_combine_row_asm\n"); + +#ifdef DISABLE_PNGVCRD_COMBINE + if ((png_ptr->transformations & PNG_INTERLACE) && png_ptr->pass != 6) + mmx_supported = 0; + else +#endif + if (mmx_supported == 2) + mmx_supported = mmxsupport(); + + if (mask == 0xff) + { + png_memcpy(row, png_ptr->row_buf + 1, + (png_size_t)((png_ptr->width * png_ptr->row_info.pixel_depth + 7) >> 3)); + } + /* GRR: add "else if (mask == 0)" case? + * or does png_combine_row() not even get called in that case? */ + else + { + switch (png_ptr->row_info.pixel_depth) + { + case 1: + { + png_bytep sp; + png_bytep dp; + int s_inc, s_start, s_end; + int m; + int shift; + png_uint_32 i; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 7; + s_inc = 1; + } + else +#endif + { + s_start = 7; + s_end = 0; + s_inc = -1; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + int value; + + value = (*sp >> shift) & 0x1; + *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 2: + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 6; + s_inc = 2; + } + else +#endif + { + s_start = 6; + s_end = 0; + s_inc = -2; + } + + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0x3; + *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 4: + { + png_bytep sp; + png_bytep dp; + int s_start, s_end, s_inc; + int m; + int shift; + png_uint_32 i; + int value; + + sp = png_ptr->row_buf + 1; + dp = row; + m = 0x80; +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (png_ptr->transformations & PNG_PACKSWAP) + { + s_start = 0; + s_end = 4; + s_inc = 4; + } + else +#endif + { + s_start = 4; + s_end = 0; + s_inc = -4; + } + shift = s_start; + + for (i = 0; i < png_ptr->width; i++) + { + if (m & mask) + { + value = (*sp >> shift) & 0xf; + *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); + *dp |= (png_byte)(value << shift); + } + + if (shift == s_end) + { + shift = s_start; + sp++; + dp++; + } + else + shift += s_inc; + if (m == 1) + m = 0x80; + else + m >>= 1; + } + break; + } + + case 8: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int m; + int diff, unmask; + + __int64 mask0=0x0102040810204080; + + if (mmx_supported) + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + m = 0x80; + unmask = ~mask; + len = png_ptr->width &~7; //reduce to multiple of 8 + diff = png_ptr->width & 7; //amount lost + + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + + pand mm0,mm7 //nonzero if keep byte + pcmpeqb mm0,mm6 //zeros->1s, v versa + + mov ecx,len //load length of line (pixels) + mov esi,srcptr //load source + mov ebx,dstptr //load dest + cmp ecx,0 //lcr + je mainloop8end + +mainloop8: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + pandn mm6,[ebx] + por mm4,mm6 + movq [ebx],mm4 + + add esi,8 //inc by 8 bytes processed + add ebx,8 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop8 +mainloop8end: + + mov ecx,diff + cmp ecx,0 + jz end8 + + mov edx,mask + sal edx,24 //make low byte the high byte + +secondloop8: + sal edx,1 //move high bit to CF + jnc skip8 //if CF = 0 + mov al,[esi] + mov [ebx],al +skip8: + inc esi + inc ebx + + dec ecx + jnz secondloop8 +end8: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 8 bpp + + case 16: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + __int64 mask1=0x0101020204040808, + mask0=0x1010202040408080; + + if (mmx_supported) + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + movq mm1,mask1 + + pand mm0,mm7 + pand mm1,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + + mov ecx,len //load length of line + mov esi,srcptr //load source + mov ebx,dstptr //load dest + cmp ecx,0 //lcr + jz mainloop16end + +mainloop16: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + add esi,16 //inc by 16 bytes processed + add ebx,16 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop16 + +mainloop16end: + mov ecx,diff + cmp ecx,0 + jz end16 + + mov edx,mask + sal edx,24 //make low byte the high byte +secondloop16: + sal edx,1 //move high bit to CF + jnc skip16 //if CF = 0 + mov ax,[esi] + mov [ebx],ax +skip16: + add esi,2 + add ebx,2 + + dec ecx + jnz secondloop16 +end16: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 16 bpp + + case 24: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask2=0x0101010202020404, //24bpp + mask1=0x0408080810101020, + mask0=0x2020404040808080; + + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + + if (mmx_supported) + { + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + + mov ecx,len //load length of line + mov esi,srcptr //load source + mov ebx,dstptr //load dest + cmp ecx,0 + jz mainloop24end + +mainloop24: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm4,mm2 + movq mm7,[ebx+16] + pandn mm4,mm7 + por mm6,mm4 + movq [ebx+16],mm6 + + add esi,24 //inc by 24 bytes processed + add ebx,24 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop24 + +mainloop24end: + mov ecx,diff + cmp ecx,0 + jz end24 + + mov edx,mask + sal edx,24 //make low byte the high byte +secondloop24: + sal edx,1 //move high bit to CF + jnc skip24 //if CF = 0 + mov ax,[esi] + mov [ebx],ax + xor eax,eax + mov al,[esi+2] + mov [ebx+2],al +skip24: + add esi,3 + add ebx,3 + + dec ecx + jnz secondloop24 + +end24: + emms + } + } + else /* mmx not supported - use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 24 bpp + + case 32: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask3=0x0101010102020202, //32bpp + mask2=0x0404040408080808, + mask1=0x1010101020202020, + mask0=0x4040404080808080; + + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + + if (mmx_supported) + { + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + movq mm3,mask3 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + pand mm3,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + pcmpeqb mm3,mm6 + + mov ecx,len //load length of line + mov esi,srcptr //load source + mov ebx,dstptr //load dest + + cmp ecx,0 //lcr + jz mainloop32end + +mainloop32: + movq mm4,[esi] + pand mm4,mm0 + movq mm6,mm0 + movq mm7,[ebx] + pandn mm6,mm7 + por mm4,mm6 + movq [ebx],mm4 + + movq mm5,[esi+8] + pand mm5,mm1 + movq mm7,mm1 + movq mm6,[ebx+8] + pandn mm7,mm6 + por mm5,mm7 + movq [ebx+8],mm5 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm4,mm2 + movq mm7,[ebx+16] + pandn mm4,mm7 + por mm6,mm4 + movq [ebx+16],mm6 + + movq mm7,[esi+24] + pand mm7,mm3 + movq mm5,mm3 + movq mm4,[ebx+24] + pandn mm5,mm4 + por mm7,mm5 + movq [ebx+24],mm7 + + add esi,32 //inc by 32 bytes processed + add ebx,32 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop32 + +mainloop32end: + mov ecx,diff + cmp ecx,0 + jz end32 + + mov edx,mask + sal edx,24 //make low byte the high byte +secondloop32: + sal edx,1 //move high bit to CF + jnc skip32 //if CF = 0 + mov eax,[esi] + mov [ebx],eax +skip32: + add esi,4 + add ebx,4 + + dec ecx + jnz secondloop32 + +end32: + emms + } + } + else /* mmx _not supported - Use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 32 bpp + + case 48: + { + png_bytep srcptr; + png_bytep dstptr; + png_uint_32 len; + int unmask, diff; + + __int64 mask5=0x0101010101010202, + mask4=0x0202020204040404, + mask3=0x0404080808080808, + mask2=0x1010101010102020, + mask1=0x2020202040404040, + mask0=0x4040808080808080; + + if (mmx_supported) + { + srcptr = png_ptr->row_buf + 1; + dstptr = row; + + unmask = ~mask; + len = (png_ptr->width)&~7; + diff = (png_ptr->width)&7; + _asm + { + movd mm7, unmask //load bit pattern + psubb mm6,mm6 //zero mm6 + punpcklbw mm7,mm7 + punpcklwd mm7,mm7 + punpckldq mm7,mm7 //fill register with 8 masks + + movq mm0,mask0 + movq mm1,mask1 + movq mm2,mask2 + movq mm3,mask3 + movq mm4,mask4 + movq mm5,mask5 + + pand mm0,mm7 + pand mm1,mm7 + pand mm2,mm7 + pand mm3,mm7 + pand mm4,mm7 + pand mm5,mm7 + + pcmpeqb mm0,mm6 + pcmpeqb mm1,mm6 + pcmpeqb mm2,mm6 + pcmpeqb mm3,mm6 + pcmpeqb mm4,mm6 + pcmpeqb mm5,mm6 + + mov ecx,len //load length of line + mov esi,srcptr //load source + mov ebx,dstptr //load dest + + cmp ecx,0 + jz mainloop48end + +mainloop48: + movq mm7,[esi] + pand mm7,mm0 + movq mm6,mm0 + pandn mm6,[ebx] + por mm7,mm6 + movq [ebx],mm7 + + movq mm6,[esi+8] + pand mm6,mm1 + movq mm7,mm1 + pandn mm7,[ebx+8] + por mm6,mm7 + movq [ebx+8],mm6 + + movq mm6,[esi+16] + pand mm6,mm2 + movq mm7,mm2 + pandn mm7,[ebx+16] + por mm6,mm7 + movq [ebx+16],mm6 + + movq mm7,[esi+24] + pand mm7,mm3 + movq mm6,mm3 + pandn mm6,[ebx+24] + por mm7,mm6 + movq [ebx+24],mm7 + + movq mm6,[esi+32] + pand mm6,mm4 + movq mm7,mm4 + pandn mm7,[ebx+32] + por mm6,mm7 + movq [ebx+32],mm6 + + movq mm7,[esi+40] + pand mm7,mm5 + movq mm6,mm5 + pandn mm6,[ebx+40] + por mm7,mm6 + movq [ebx+40],mm7 + + add esi,48 //inc by 32 bytes processed + add ebx,48 + sub ecx,8 //dec by 8 pixels processed + + ja mainloop48 +mainloop48end: + + mov ecx,diff + cmp ecx,0 + jz end48 + + mov edx,mask + sal edx,24 //make low byte the high byte + +secondloop48: + sal edx,1 //move high bit to CF + jnc skip48 //if CF = 0 + mov eax,[esi] + mov [ebx],eax +skip48: + add esi,4 + add ebx,4 + + dec ecx + jnz secondloop48 + +end48: + emms + } + } + else /* mmx _not supported - Use modified C routine */ + { + register unsigned int incr1, initial_val, final_val; + png_size_t pixel_bytes; + png_uint_32 i; + register int disp = png_pass_inc[png_ptr->pass]; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + srcptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dstptr = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dstptr, srcptr, pixel_bytes); + srcptr += incr1; + dstptr += incr1; + } + } /* end of else */ + + break; + } // end 48 bpp + + default: + { + png_bytep sptr; + png_bytep dp; + png_size_t pixel_bytes; + int offset_table[7] = {0, 4, 0, 2, 0, 1, 0}; + unsigned int i; + register int disp = png_pass_inc[png_ptr->pass]; // get the offset + register unsigned int incr1, initial_val, final_val; + + pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); + sptr = png_ptr->row_buf + 1 + offset_table[png_ptr->pass]* + pixel_bytes; + dp = row + offset_table[png_ptr->pass]*pixel_bytes; + initial_val = offset_table[png_ptr->pass]*pixel_bytes; + final_val = png_ptr->width*pixel_bytes; + incr1 = (disp)*pixel_bytes; + for (i = initial_val; i < final_val; i += incr1) + { + png_memcpy(dp, sptr, pixel_bytes); + sptr += incr1; + dp += incr1; + } + break; + } + } /* end switch (png_ptr->row_info.pixel_depth) */ + } /* end if (non-trivial mask) */ + +#ifdef DISABLE_PNGVCRD_COMBINE + mmx_supported = save_mmx_supported; +#endif + +} /* end png_combine_row() */ + + +#if defined(PNG_READ_INTERLACING_SUPPORTED) + +void /* PRIVATE */ +png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, + png_uint_32 transformations) +{ +#ifdef PNG_USE_LOCAL_ARRAYS + const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; +#endif +#ifdef DISABLE_PNGVCRD_INTERLACE + int save_mmx_supported = mmx_supported; +#endif + + png_debug(1,"in png_do_read_interlace\n"); + +#ifdef DISABLE_PNGVCRD_INTERLACE + /* In libpng versions 1.0.3a through 1.0.4d, + * a sign error in the post-MMX cleanup code for each pixel_depth resulted + * in bad pixels at the beginning of some rows of some images, and also + * (due to out-of-range memory reads and writes) caused heap corruption + * when compiled with MSVC 6.0. The error was fixed in version 1.0.4e, + * and the code appears to work completely correctly, so it is enabled + * by default. + */ + if (1) /* all passes caused a heap problem in the old code */ + mmx_supported = 0; + else +#endif + if (mmx_supported == 2) + mmx_supported = mmxsupport(); + + if (row != NULL && row_info != NULL) + { + png_uint_32 final_width; + + final_width = row_info->width * png_pass_inc[pass]; + + switch (row_info->pixel_depth) + { + case 1: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_byte v; + png_uint_32 i; + int j; + + sp = row + (png_size_t)((row_info->width - 1) >> 3); + dp = row + (png_size_t)((final_width - 1) >> 3); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (int)((row_info->width + 7) & 7); + dshift = (int)((final_width + 7) & 7); + s_start = 7; + s_end = 0; + s_inc = -1; + } + else +#endif + { + sshift = 7 - (int)((row_info->width + 7) & 7); + dshift = 7 - (int)((final_width + 7) & 7); + s_start = 0; + s_end = 7; + s_inc = 1; + } + + for (i = row_info->width; i; i--) + { + v = (png_byte)((*sp >> sshift) & 0x1); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 2: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 2); + dp = row + (png_size_t)((final_width - 1) >> 2); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 3) & 3) << 1); + dshift = (png_size_t)(((final_width + 3) & 3) << 1); + s_start = 6; + s_end = 0; + s_inc = -2; + } + else +#endif + { + sshift = (png_size_t)((3 - ((row_info->width + 3) & 3)) << 1); + dshift = (png_size_t)((3 - ((final_width + 3) & 3)) << 1); + s_start = 0; + s_end = 6; + s_inc = 2; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0x3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + case 4: + { + png_bytep sp, dp; + int sshift, dshift; + int s_start, s_end, s_inc; + png_uint_32 i; + + sp = row + (png_size_t)((row_info->width - 1) >> 1); + dp = row + (png_size_t)((final_width - 1) >> 1); +#if defined(PNG_READ_PACKSWAP_SUPPORTED) + if (transformations & PNG_PACKSWAP) + { + sshift = (png_size_t)(((row_info->width + 1) & 1) << 2); + dshift = (png_size_t)(((final_width + 1) & 1) << 2); + s_start = 4; + s_end = 0; + s_inc = -4; + } + else +#endif + { + sshift = (png_size_t)((1 - ((row_info->width + 1) & 1)) << 2); + dshift = (png_size_t)((1 - ((final_width + 1) & 1)) << 2); + s_start = 0; + s_end = 4; + s_inc = 4; + } + + for (i = row_info->width; i; i--) + { + png_byte v; + int j; + + v = (png_byte)((*sp >> sshift) & 0xf); + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); + *dp |= (png_byte)(v << dshift); + if (dshift == s_end) + { + dshift = s_start; + dp--; + } + else + dshift += s_inc; + } + if (sshift == s_end) + { + sshift = s_start; + sp--; + } + else + sshift += s_inc; + } + break; + } + + default: // This is the place where the routine is modified + { + __int64 const4 = 0x0000000000FFFFFF; + // __int64 const5 = 0x000000FFFFFF0000; // unused... + __int64 const6 = 0x00000000000000FF; + png_bytep sptr, dp; + png_uint_32 i; + png_size_t pixel_bytes; + int width = row_info->width; + + pixel_bytes = (row_info->pixel_depth >> 3); + + sptr = row + (width - 1) * pixel_bytes; + dp = row + (final_width - 1) * pixel_bytes; + // New code by Nirav Chhatrapati - Intel Corporation + // sign fix by GRR + // NOTE: there is NO MMX code for 48-bit and 64-bit images + + if (mmx_supported) // use MMX routine if machine supports it + { + if (pixel_bytes == 3) + { + if (((pass == 0) || (pass == 1)) && width) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width + sub edi, 21 // (png_pass_inc[pass] - 1)*pixel_bytes +loop_pass0: + movd mm0, [esi] ; X X X X X v2 v1 v0 + pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 + movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 + psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 + movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 + psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 + psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 + por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 + por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 + movq mm3, mm0 ; v2 v1 v0 v2 v1 v0 v2 v1 + psllq mm0, 16 ; v0 v2 v1 v0 v2 v1 0 0 + movq mm4, mm3 ; v2 v1 v0 v2 v1 v0 v2 v1 + punpckhdq mm3, mm0 ; v0 v2 v1 v0 v2 v1 v0 v2 + movq [edi+16] , mm4 + psrlq mm0, 32 ; 0 0 0 0 v0 v2 v1 v0 + movq [edi+8] , mm3 + punpckldq mm0, mm4 ; v1 v0 v2 v1 v0 v2 v1 v0 + sub esi, 3 + movq [edi], mm0 + sub edi, 24 + //sub esi, 3 + dec ecx + jnz loop_pass0 + EMMS + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width + sub edi, 9 // (png_pass_inc[pass] - 1)*pixel_bytes +loop_pass2: + movd mm0, [esi] ; X X X X X v2 v1 v0 + pand mm0, const4 ; 0 0 0 0 0 v2 v1 v0 + movq mm1, mm0 ; 0 0 0 0 0 v2 v1 v0 + psllq mm0, 16 ; 0 0 0 v2 v1 v0 0 0 + movq mm2, mm0 ; 0 0 0 v2 v1 v0 0 0 + psllq mm0, 24 ; v2 v1 v0 0 0 0 0 0 + psrlq mm1, 8 ; 0 0 0 0 0 0 v2 v1 + por mm0, mm2 ; v2 v1 v0 v2 v1 v0 0 0 + por mm0, mm1 ; v2 v1 v0 v2 v1 v0 v2 v1 + movq [edi+4], mm0 ; move to memory + psrlq mm0, 16 ; 0 0 v2 v1 v0 v2 v1 v0 + movd [edi], mm0 ; move to memory + sub esi, 3 + sub edi, 12 + dec ecx + jnz loop_pass2 + EMMS + } + } + else if (width) /* && ((pass == 4) || (pass == 5)) */ + { + int width_mmx = ((width >> 1) << 1) - 8; + if (width_mmx < 0) + width_mmx = 0; + width -= width_mmx; // 8 or 9 pix, 24 or 27 bytes + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 3 + sub edi, 9 +loop_pass4: + movq mm0, [esi] ; X X v2 v1 v0 v5 v4 v3 + movq mm7, mm0 ; X X v2 v1 v0 v5 v4 v3 + movq mm6, mm0 ; X X v2 v1 v0 v5 v4 v3 + psllq mm0, 24 ; v1 v0 v5 v4 v3 0 0 0 + pand mm7, const4 ; 0 0 0 0 0 v5 v4 v3 + psrlq mm6, 24 ; 0 0 0 X X v2 v1 v0 + por mm0, mm7 ; v1 v0 v5 v4 v3 v5 v4 v3 + movq mm5, mm6 ; 0 0 0 X X v2 v1 v0 + psllq mm6, 8 ; 0 0 X X v2 v1 v0 0 + movq [edi], mm0 ; move quad to memory + psrlq mm5, 16 ; 0 0 0 0 0 X X v2 + pand mm5, const6 ; 0 0 0 0 0 0 0 v2 + por mm6, mm5 ; 0 0 X X v2 v1 v0 v2 + movd [edi+8], mm6 ; move double to memory + sub esi, 6 + sub edi, 12 + sub ecx, 2 + jnz loop_pass4 + EMMS + } + } + + sptr -= width_mmx*3; + dp -= width_mmx*6; + for (i = width; i; i--) + { + png_byte v[8]; + int j; + + png_memcpy(v, sptr, 3); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 3); + dp -= 3; + } + sptr -= 3; + } + } + } /* end of pixel_bytes == 3 */ + + else if (pixel_bytes == 1) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 31 + sub esi, 3 +loop1_pass0: + movd mm0, [esi] ; X X X X v0 v1 v2 v3 + movq mm1, mm0 ; X X X X v0 v1 v2 v3 + punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + movq mm2, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + movq mm3, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + punpckldq mm0, mm0 ; v3 v3 v3 v3 v3 v3 v3 v3 + punpckhdq mm3, mm3 ; v2 v2 v2 v2 v2 v2 v2 v2 + movq [edi], mm0 ; move to memory v3 + punpckhwd mm2, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 + movq [edi+8], mm3 ; move to memory v2 + movq mm4, mm2 ; v0 v0 v0 v0 v1 v1 v1 v1 + punpckldq mm2, mm2 ; v1 v1 v1 v1 v1 v1 v1 v1 + punpckhdq mm4, mm4 ; v0 v0 v0 v0 v0 v0 v0 v0 + movq [edi+16], mm2 ; move to memory v1 + movq [edi+24], mm4 ; move to memory v0 + sub esi, 4 + sub edi, 32 + sub ecx, 4 + jnz loop1_pass0 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*8; + for (i = width; i; i--) + { + int j; + + /* I simplified this part in version 1.0.4e + * here and in several other instances where + * pixel_bytes == 1 -- GR-P + * + * Original code: + * + * png_byte v[8]; + * png_memcpy(v, sptr, pixel_bytes); + * for (j = 0; j < png_pass_inc[pass]; j++) + * { + * png_memcpy(dp, v, pixel_bytes); + * dp -= pixel_bytes; + * } + * sptr -= pixel_bytes; + * + * Replacement code is in the next three lines: + */ + + for (j = 0; j < png_pass_inc[pass]; j++) + *dp-- = *sptr; + sptr--; + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 2) << 2); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 15 + sub esi, 3 +loop1_pass2: + movd mm0, [esi] ; X X X X v0 v1 v2 v3 + punpcklbw mm0, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + punpcklwd mm0, mm0 ; v2 v2 v2 v2 v3 v3 v3 v3 + punpckhwd mm1, mm1 ; v0 v0 v0 v0 v1 v1 v1 v1 + movq [edi], mm0 ; move to memory v2 and v3 + sub esi, 4 + movq [edi+8], mm1 ; move to memory v1 and v0 + sub edi, 16 + sub ecx, 4 + jnz loop1_pass2 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*4; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + sptr --; + } + } + else if (width) /* && ((pass == 4) || (pass == 5))) */ + { + int width_mmx = ((width >> 3) << 3); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub edi, 15 + sub esi, 7 +loop1_pass4: + movq mm0, [esi] ; v0 v1 v2 v3 v4 v5 v6 v7 + movq mm1, mm0 ; v0 v1 v2 v3 v4 v5 v6 v7 + punpcklbw mm0, mm0 ; v4 v4 v5 v5 v6 v6 v7 v7 + //movq mm1, mm0 ; v0 v0 v1 v1 v2 v2 v3 v3 + punpckhbw mm1, mm1 ;v0 v0 v1 v1 v2 v2 v3 v3 + movq [edi+8], mm1 ; move to memory v0 v1 v2 and v3 + sub esi, 8 + movq [edi], mm0 ; move to memory v4 v5 v6 and v7 + //sub esi, 4 + sub edi, 16 + sub ecx, 8 + jnz loop1_pass4 + EMMS + } + } + + sptr -= width_mmx; + dp -= width_mmx*2; + for (i = width; i; i--) + { + int j; + + for (j = 0; j < png_pass_inc[pass]; j++) + { + *dp-- = *sptr; + } + sptr --; + } + } + } /* end of pixel_bytes == 1 */ + + else if (pixel_bytes == 2) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1); + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 30 +loop2_pass0: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 + punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi + 16], mm1 + movq [edi + 24], mm1 + sub esi, 4 + sub edi, 32 + sub ecx, 2 + jnz loop2_pass0 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*16 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 14 +loop2_pass2: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + movq mm1, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + punpckldq mm0, mm0 ; v3 v2 v3 v2 v3 v2 v3 v2 + punpckhdq mm1, mm1 ; v1 v0 v1 v0 v1 v0 v1 v0 + movq [edi], mm0 + sub esi, 4 + movq [edi + 8], mm1 + //sub esi, 4 + sub edi, 16 + sub ecx, 2 + jnz loop2_pass2 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*8 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + else if (width) // pass == 4 or 5 + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 2 + sub edi, 6 +loop2_pass4: + movd mm0, [esi] ; X X X X v1 v0 v3 v2 + punpcklwd mm0, mm0 ; v1 v0 v1 v0 v3 v2 v3 v2 + sub esi, 4 + movq [edi], mm0 + sub edi, 8 + sub ecx, 2 + jnz loop2_pass4 + EMMS + } + } + + sptr -= (width_mmx*2 - 2); // sign fixed + dp -= (width_mmx*4 - 2); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 2; + png_memcpy(v, sptr, 2); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 2; + png_memcpy(dp, v, 2); + } + } + } + } /* end of pixel_bytes == 2 */ + + else if (pixel_bytes == 4) + { + if (((pass == 0) || (pass == 1)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 60 +loop4_pass0: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi + 16], mm0 + movq [edi + 24], mm0 + movq [edi+32], mm1 + movq [edi + 40], mm1 + movq [edi+ 48], mm1 + sub esi, 8 + movq [edi + 56], mm1 + sub edi, 64 + sub ecx, 2 + jnz loop4_pass0 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*32 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (((pass == 2) || (pass == 3)) && width) + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 28 +loop4_pass2: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + movq [edi + 8], mm0 + movq [edi+16], mm1 + movq [edi + 24], mm1 + sub esi, 8 + sub edi, 32 + sub ecx, 2 + jnz loop4_pass2 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*16 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + else if (width) // pass == 4 or 5 + { + int width_mmx = ((width >> 1) << 1) ; + width -= width_mmx; + if (width_mmx) + { + _asm + { + mov esi, sptr + mov edi, dp + mov ecx, width_mmx + sub esi, 4 + sub edi, 12 +loop4_pass4: + movq mm0, [esi] ; v3 v2 v1 v0 v7 v6 v5 v4 + movq mm1, mm0 ; v3 v2 v1 v0 v7 v6 v5 v4 + punpckldq mm0, mm0 ; v7 v6 v5 v4 v7 v6 v5 v4 + punpckhdq mm1, mm1 ; v3 v2 v1 v0 v3 v2 v1 v0 + movq [edi], mm0 + sub esi, 8 + movq [edi + 8], mm1 + sub edi, 16 + sub ecx, 2 + jnz loop4_pass4 + EMMS + } + } + + sptr -= (width_mmx*4 - 4); // sign fixed + dp -= (width_mmx*8 - 4); // sign fixed + for (i = width; i; i--) + { + png_byte v[8]; + int j; + sptr -= 4; + png_memcpy(v, sptr, 4); + for (j = 0; j < png_pass_inc[pass]; j++) + { + dp -= 4; + png_memcpy(dp, v, 4); + } + } + } + + } /* end of pixel_bytes == 4 */ + + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, 6); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, 6); + dp -= 6; + } + sptr -= 6; + } + } /* end of pixel_bytes == 6 */ + + else + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr-= pixel_bytes; + } + } + } /* end of mmx_supported */ + + else /* MMX not supported: use modified C code - takes advantage + * of inlining of memcpy for a constant */ + { + if (pixel_bytes == 1) + { + for (i = width; i; i--) + { + int j; + for (j = 0; j < png_pass_inc[pass]; j++) + *dp-- = *sptr; + sptr--; + } + } + else if (pixel_bytes == 3) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 2) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 4) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else if (pixel_bytes == 6) + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + else + { + for (i = width; i; i--) + { + png_byte v[8]; + int j; + png_memcpy(v, sptr, pixel_bytes); + for (j = 0; j < png_pass_inc[pass]; j++) + { + png_memcpy(dp, v, pixel_bytes); + dp -= pixel_bytes; + } + sptr -= pixel_bytes; + } + } + + } /* end of MMX not supported */ + break; + } + } /* end switch (row_info->pixel_depth) */ + + row_info->width = final_width; + row_info->rowbytes = ((final_width * + (png_uint_32)row_info->pixel_depth + 7) >> 3); + } + +#ifdef DISABLE_PNGVCRD_INTERLACE + mmx_supported = save_mmx_supported; +#endif +} + +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + + +// These variables are utilized in the functions below. They are declared +// globally here to ensure alignment on 8-byte boundaries. + +union uAll { + __int64 use; + double align; +} LBCarryMask = {0x0101010101010101}, + HBClearMask = {0x7f7f7f7f7f7f7f7f}, + ActiveMask, ActiveMask2, ActiveMaskEnd, ShiftBpp, ShiftRem; + + +// Optimized code for PNG Average filter decoder +void /* PRIVATE */ +png_read_filter_row_mmx_avg(png_row_infop row_info, png_bytep row + , png_bytep prev_row) +{ + int bpp; + png_uint_32 FullLength; + png_uint_32 MMXLength; + //png_uint_32 len; + int diff; + + bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel + FullLength = row_info->rowbytes; // # of bytes to filter + _asm { + // Init address pointers and offset + mov edi, row // edi ==> Avg(x) + xor ebx, ebx // ebx ==> x + mov edx, edi + mov esi, prev_row // esi ==> Prior(x) + sub edx, bpp // edx ==> Raw(x-bpp) + + xor eax, eax + // Compute the Raw value for the first bpp bytes + // Raw(x) = Avg(x) + (Prior(x)/2) +davgrlp: + mov al, [esi + ebx] // Load al with Prior(x) + inc ebx + shr al, 1 // divide by 2 + add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx + cmp ebx, bpp + mov [edi+ebx-1], al // Write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + jb davgrlp + // get # of bytes to alignment + mov diff, edi // take start of row + add diff, ebx // add bpp + add diff, 0xf // add 7 + 8 to incr past alignment boundary + and diff, 0xfffffff8 // mask to alignment boundary + sub diff, edi // subtract from start ==> value ebx at alignment + jz davggo + // fix alignment + // Compute the Raw value for the bytes upto the alignment boundary + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + xor ecx, ecx +davglp1: + xor eax, eax + mov cl, [esi + ebx] // load cl with Prior(x) + mov al, [edx + ebx] // load al with Raw(x-bpp) + add ax, cx + inc ebx + shr ax, 1 // divide by 2 + add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx + cmp ebx, diff // Check if at alignment boundary + mov [edi+ebx-1], al // Write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + jb davglp1 // Repeat until at alignment boundary +davggo: + mov eax, FullLength + mov ecx, eax + sub eax, ebx // subtract alignment fix + and eax, 0x00000007 // calc bytes over mult of 8 + sub ecx, eax // drop over bytes from original length + mov MMXLength, ecx + } // end _asm block + // Now do the math for the rest of the row + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000000000ffffff; + ShiftBpp.use = 24; // == 3 * 8 + ShiftRem.use = 40; // == 64 - 24 + _asm { + // Re-init address pointers and offset + movq mm7, ActiveMask + mov ebx, diff // ebx ==> x = offset to alignment boundary + movq mm5, LBCarryMask + mov edi, row // edi ==> Avg(x) + movq mm4, HBClearMask + mov esi, prev_row // esi ==> Prior(x) + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes + // (we correct position in loop below) +davg3lp: + movq mm0, [edi + ebx] // Load mm0 with Avg(x) + // Add (Prev_row/2) to Average + movq mm3, mm5 + psrlq mm2, ShiftRem // Correct position Raw(x-bpp) data + movq mm1, [esi + ebx] // Load mm1 with Prior(x) + movq mm6, mm7 + pand mm3, mm1 // get lsb for each prev_row byte + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 3-5 + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + + // Add 3rd active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover the last two + // bytes + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + // Data only needs to be shifted once here to + // get the correct x-bpp offset. + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + add ebx, 8 + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + + // Now ready to write back to memory + movq [edi + ebx - 8], mm0 + // Move updated Raw(x) to use as Raw(x-bpp) for next loop + cmp ebx, MMXLength + movq mm2, mm0 // mov updated Raw(x) to mm2 + jb davg3lp + } // end _asm block + } + break; + + case 6: + case 4: + case 7: + case 5: + { + ActiveMask.use = 0xffffffffffffffff; // use shift below to clear + // appropriate inactive bytes + ShiftBpp.use = bpp << 3; + ShiftRem.use = 64 - ShiftBpp.use; + _asm { + movq mm4, HBClearMask + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + // Load ActiveMask and clear all bytes except for 1st active group + movq mm7, ActiveMask + mov edi, row // edi ==> Avg(x) + psrlq mm7, ShiftRem + mov esi, prev_row // esi ==> Prior(x) + movq mm6, mm7 + movq mm5, LBCarryMask + psllq mm6, ShiftBpp // Create mask for 2nd active group + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes + // (we correct position in loop below) +davg4lp: + movq mm0, [edi + ebx] + psrlq mm2, ShiftRem // shift data to position correctly + movq mm1, [esi + ebx] + // Add (Prev_row/2) to Average + movq mm3, mm5 + pand mm3, mm1 // get lsb for each prev_row byte + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm7 // Leave only Active Group 1 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + add ebx, 8 + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active + // byte + cmp ebx, MMXLength + // Now ready to write back to memory + movq [edi + ebx - 8], mm0 + // Prep Raw(x-bpp) for next loop + movq mm2, mm0 // mov updated Raws to mm2 + jb davg4lp + } // end _asm block + } + break; + case 2: + { + ActiveMask.use = 0x000000000000ffff; + ShiftBpp.use = 24; // == 3 * 8 + ShiftRem.use = 40; // == 64 - 24 + _asm { + // Load ActiveMask + movq mm7, ActiveMask + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + movq mm5, LBCarryMask + mov edi, row // edi ==> Avg(x) + movq mm4, HBClearMask + mov esi, prev_row // esi ==> Prior(x) + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes + // (we correct position in loop below) +davg2lp: + movq mm0, [edi + ebx] + psllq mm2, ShiftRem // shift data to position correctly + movq mm1, [esi + ebx] + // Add (Prev_row/2) to Average + movq mm3, mm5 + pand mm3, mm1 // get lsb for each prev_row byte + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + movq mm6, mm7 + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + // Add 1st active group (Raw(x-bpp)/2) to Average with LBCarry + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 1 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte + // Add 2nd active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 2 & 3 + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte + + // Add rdd active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 4 & 5 + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + // Data only needs to be shifted once here to + // get the correct x-bpp offset. + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte + + // Add 4th active group (Raw(x-bpp)/2) to Average with LBCarry + psllq mm6, ShiftBpp // shift the mm6 mask to cover bytes 6 & 7 + movq mm2, mm0 // mov updated Raws to mm2 + psllq mm2, ShiftBpp // shift data to position correctly + // Data only needs to be shifted once here to + // get the correct x-bpp offset. + add ebx, 8 + movq mm1, mm3 // now use mm1 for getting LBCarrys + pand mm1, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 (Only valid for active group) + psrlq mm2, 1 // divide raw bytes by 2 + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm2, mm1 // add LBCarrys to (Raw(x-bpp)/2) for each byte + pand mm2, mm6 // Leave only Active Group 2 bytes to add to Avg + paddb mm0, mm2 // add (Raw/2) + LBCarrys to Avg for each Active byte + + cmp ebx, MMXLength + // Now ready to write back to memory + movq [edi + ebx - 8], mm0 + // Prep Raw(x-bpp) for next loop + movq mm2, mm0 // mov updated Raws to mm2 + jb davg2lp + } // end _asm block + } + break; + + case 1: // bpp == 1 + { + _asm { + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + mov edi, row // edi ==> Avg(x) + cmp ebx, FullLength // Test if offset at end of array + jnb davg1end + // Do Paeth decode for remaining bytes + mov esi, prev_row // esi ==> Prior(x) + mov edx, edi + xor ecx, ecx // zero ecx before using cl & cx in loop below + sub edx, bpp // edx ==> Raw(x-bpp) +davg1lp: + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + xor eax, eax + mov cl, [esi + ebx] // load cl with Prior(x) + mov al, [edx + ebx] // load al with Raw(x-bpp) + add ax, cx + inc ebx + shr ax, 1 // divide by 2 + add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx + cmp ebx, FullLength // Check if at end of array + mov [edi+ebx-1], al // Write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + jb davg1lp +davg1end: + } // end _asm block + } + return; + + case 8: // bpp == 8 + { + _asm { + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + movq mm5, LBCarryMask + mov edi, row // edi ==> Avg(x) + movq mm4, HBClearMask + mov esi, prev_row // esi ==> Prior(x) + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm2, [edi + ebx - 8] // Load previous aligned 8 bytes + // (NO NEED to correct position in loop below) +davg8lp: + movq mm0, [edi + ebx] + movq mm3, mm5 + movq mm1, [esi + ebx] + add ebx, 8 + pand mm3, mm1 // get lsb for each prev_row byte + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm3, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 + psrlq mm2, 1 // divide raw bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm3 // add LBCarrys to Avg for each byte + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + paddb mm0, mm2 // add (Raw/2) to Avg for each byte + cmp ebx, MMXLength + movq [edi + ebx - 8], mm0 + movq mm2, mm0 // reuse as Raw(x-bpp) + jb davg8lp + } // end _asm block + } + break; + default: // bpp greater than 8 + { + _asm { + movq mm5, LBCarryMask + // Re-init address pointers and offset + mov ebx, diff // ebx ==> x = offset to alignment boundary + mov edi, row // edi ==> Avg(x) + movq mm4, HBClearMask + mov edx, edi + mov esi, prev_row // esi ==> Prior(x) + sub edx, bpp // edx ==> Raw(x-bpp) +davgAlp: + movq mm0, [edi + ebx] + movq mm3, mm5 + movq mm1, [esi + ebx] + pand mm3, mm1 // get lsb for each prev_row byte + movq mm2, [edx + ebx] + psrlq mm1, 1 // divide prev_row bytes by 2 + pand mm3, mm2 // get LBCarrys for each byte where both + // lsb's were == 1 + psrlq mm2, 1 // divide raw bytes by 2 + pand mm1, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm3 // add LBCarrys to Avg for each byte + pand mm2, mm4 // clear invalid bit 7 of each byte + paddb mm0, mm1 // add (Prev_row/2) to Avg for each byte + add ebx, 8 + paddb mm0, mm2 // add (Raw/2) to Avg for each byte + cmp ebx, MMXLength + movq [edi + ebx - 8], mm0 + jb davgAlp + } // end _asm block + } + break; + } // end switch ( bpp ) + + _asm { + // MMX acceleration complete now do clean-up + // Check if any remaining bytes left to decode + mov ebx, MMXLength // ebx ==> x = offset bytes remaining after MMX + mov edi, row // edi ==> Avg(x) + cmp ebx, FullLength // Test if offset at end of array + jnb davgend + // Do Paeth decode for remaining bytes + mov esi, prev_row // esi ==> Prior(x) + mov edx, edi + xor ecx, ecx // zero ecx before using cl & cx in loop below + sub edx, bpp // edx ==> Raw(x-bpp) +davglp2: + // Raw(x) = Avg(x) + ((Raw(x-bpp) + Prior(x))/2) + xor eax, eax + mov cl, [esi + ebx] // load cl with Prior(x) + mov al, [edx + ebx] // load al with Raw(x-bpp) + add ax, cx + inc ebx + shr ax, 1 // divide by 2 + add al, [edi+ebx-1] // Add Avg(x); -1 to offset inc ebx + cmp ebx, FullLength // Check if at end of array + mov [edi+ebx-1], al // Write back Raw(x); + // mov does not affect flags; -1 to offset inc ebx + jb davglp2 +davgend: + emms // End MMX instructions; prep for possible FP instrs. + } // end _asm block +} + +// Optimized code for PNG Paeth filter decoder +void /* PRIVATE */ +png_read_filter_row_mmx_paeth(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + png_uint_32 FullLength; + png_uint_32 MMXLength; + //png_uint_32 len; + int bpp; + int diff; + //int ptemp; + int patemp, pbtemp, pctemp; + + bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel + FullLength = row_info->rowbytes; // # of bytes to filter + _asm + { + xor ebx, ebx // ebx ==> x offset + mov edi, row + xor edx, edx // edx ==> x-bpp offset + mov esi, prev_row + xor eax, eax + + // Compute the Raw value for the first bpp bytes + // Note: the formula works out to be always + // Paeth(x) = Raw(x) + Prior(x) where x < bpp +dpthrlp: + mov al, [edi + ebx] + add al, [esi + ebx] + inc ebx + cmp ebx, bpp + mov [edi + ebx - 1], al + jb dpthrlp + // get # of bytes to alignment + mov diff, edi // take start of row + add diff, ebx // add bpp + xor ecx, ecx + add diff, 0xf // add 7 + 8 to incr past alignment boundary + and diff, 0xfffffff8 // mask to alignment boundary + sub diff, edi // subtract from start ==> value ebx at alignment + jz dpthgo + // fix alignment +dpthlp1: + xor eax, eax + // pav = p - a = (a + b - c) - a = b - c + mov al, [esi + ebx] // load Prior(x) into al + mov cl, [esi + edx] // load Prior(x-bpp) into cl + sub eax, ecx // subtract Prior(x-bpp) + mov patemp, eax // Save pav for later use + xor eax, eax + // pbv = p - b = (a + b - c) - b = a - c + mov al, [edi + edx] // load Raw(x-bpp) into al + sub eax, ecx // subtract Prior(x-bpp) + mov ecx, eax + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + add eax, patemp // pcv = pav + pbv + // pc = abs(pcv) + test eax, 0x80000000 + jz dpthpca + neg eax // reverse sign of neg values +dpthpca: + mov pctemp, eax // save pc for later use + // pb = abs(pbv) + test ecx, 0x80000000 + jz dpthpba + neg ecx // reverse sign of neg values +dpthpba: + mov pbtemp, ecx // save pb for later use + // pa = abs(pav) + mov eax, patemp + test eax, 0x80000000 + jz dpthpaa + neg eax // reverse sign of neg values +dpthpaa: + mov patemp, eax // save pa for later use + // test if pa <= pb + cmp eax, ecx + jna dpthabb + // pa > pb; now test if pb <= pc + cmp ecx, pctemp + jna dpthbbc + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthpaeth +dpthbbc: + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + mov cl, [esi + ebx] // load Prior(x) into cl + jmp dpthpaeth +dpthabb: + // pa <= pb; now test if pa <= pc + cmp eax, pctemp + jna dpthabc + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthpaeth +dpthabc: + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + mov cl, [edi + edx] // load Raw(x-bpp) into cl +dpthpaeth: + inc ebx + inc edx + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + add [edi + ebx - 1], cl + cmp ebx, diff + jb dpthlp1 +dpthgo: + mov ecx, FullLength + mov eax, ecx + sub eax, ebx // subtract alignment fix + and eax, 0x00000007 // calc bytes over mult of 8 + sub ecx, eax // drop over bytes from original length + mov MMXLength, ecx + } // end _asm block + // Now do the math for the rest of the row + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000000000ffffff; + ActiveMaskEnd.use = 0xffff000000000000; + ShiftBpp.use = 24; // == bpp(3) * 8 + ShiftRem.use = 40; // == 64 - 24 + _asm + { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] +dpth3lp: + psrlq mm1, ShiftRem // shift last 3 bytes to 1st 3 bytes + movq mm2, [esi + ebx] // load b=Prior(x) + punpcklbw mm1, mm0 // Unpack High bytes of a + movq mm3, [esi+ebx-8] // Prep c=Prior(x-bpp) bytes + punpcklbw mm2, mm0 // Unpack High bytes of b + psrlq mm3, ShiftRem // shift last 3 bytes to 1st 3 bytes + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + punpcklbw mm3, mm0 // Unpack High bytes of c + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx] // load c=Prior(x-bpp) + pand mm7, ActiveMask + movq mm2, mm3 // load b=Prior(x) step 1 + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + punpcklbw mm3, mm0 // Unpack High bytes of c + movq [edi + ebx], mm7 // write back updated value + movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) + // Now do Paeth for 2nd set of bytes (3-5) + psrlq mm2, ShiftBpp // load b=Prior(x) step 2 + punpcklbw mm1, mm0 // Unpack High bytes of a + pxor mm7, mm7 + punpcklbw mm2, mm0 // Unpack High bytes of b + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + psubw mm5, mm3 + psubw mm4, mm3 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = + // pav + pbv = pbv + pav + movq mm6, mm5 + paddw mm6, mm4 + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm5 // Create mask pbv bytes < 0 + pcmpgtw mm7, mm4 // Create mask pav bytes < 0 + pand mm0, mm5 // Only pbv bytes < 0 in mm0 + pand mm7, mm4 // Only pav bytes < 0 in mm7 + psubw mm5, mm0 + psubw mm4, mm7 + psubw mm5, mm0 + psubw mm4, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + movq mm2, [esi + ebx] // load b=Prior(x) + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, mm2 // load c=Prior(x-bpp) step 1 + pand mm7, ActiveMask + punpckhbw mm2, mm0 // Unpack High bytes of b + psllq mm7, ShiftBpp // Shift bytes to 2nd group of 3 bytes + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + psllq mm3, ShiftBpp // load c=Prior(x-bpp) step 2 + movq [edi + ebx], mm7 // write back updated value + movq mm1, mm7 + punpckhbw mm3, mm0 // Unpack High bytes of c + psllq mm1, ShiftBpp // Shift bytes + // Now mm1 will be used as Raw(x-bpp) + // Now do Paeth for 3rd, and final, set of bytes (6-7) + pxor mm7, mm7 + punpckhbw mm1, mm0 // Unpack High bytes of a + psubw mm4, mm3 + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + pxor mm0, mm0 + paddw mm6, mm5 + + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + pandn mm0, mm1 + pandn mm7, mm4 + paddw mm0, mm2 + paddw mm7, mm5 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm1, mm1 + packuswb mm1, mm7 + // Step ebx to next set of 8 bytes and repeat loop til done + add ebx, 8 + pand mm1, ActiveMaskEnd + paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) + + cmp ebx, MMXLength + pxor mm0, mm0 // pxor does not affect flags + movq [edi + ebx - 8], mm1 // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + // mm3 ready to be used as Prior(x-bpp) next loop + jb dpth3lp + } // end _asm block + } + break; + + case 6: + case 7: + case 5: + { + ActiveMask.use = 0x00000000ffffffff; + ActiveMask2.use = 0xffffffff00000000; + ShiftBpp.use = bpp << 3; // == bpp * 8 + ShiftRem.use = 64 - ShiftBpp.use; + _asm + { + mov ebx, diff + mov edi, row + mov esi, prev_row + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] + pxor mm0, mm0 +dpth6lp: + // Must shift to position Raw(x-bpp) data + psrlq mm1, ShiftRem + // Do first set of 4 bytes + movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes + punpcklbw mm1, mm0 // Unpack Low bytes of a + movq mm2, [esi + ebx] // load b=Prior(x) + punpcklbw mm2, mm0 // Unpack Low bytes of b + // Must shift to position Prior(x-bpp) data + psrlq mm3, ShiftRem + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + punpcklbw mm3, mm0 // Unpack Low bytes of c + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx - 8] // load c=Prior(x-bpp) + pand mm7, ActiveMask + psrlq mm3, ShiftRem + movq mm2, [esi + ebx] // load b=Prior(x) step 1 + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + movq mm6, mm2 + movq [edi + ebx], mm7 // write back updated value + movq mm1, [edi+ebx-8] + psllq mm6, ShiftBpp + movq mm5, mm7 + psrlq mm1, ShiftRem + por mm3, mm6 + psllq mm5, ShiftBpp + punpckhbw mm3, mm0 // Unpack High bytes of c + por mm1, mm5 + // Do second set of 4 bytes + punpckhbw mm2, mm0 // Unpack High bytes of b + punpckhbw mm1, mm0 // Unpack High bytes of a + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + // Step ex to next set of 8 bytes and repeat loop til done + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + jb dpth6lp + } // end _asm block + } + break; + + case 4: + { + ActiveMask.use = 0x00000000ffffffff; + _asm { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] // Only time should need to read + // a=Raw(x-bpp) bytes +dpth4lp: + // Do first set of 4 bytes + movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes + punpckhbw mm1, mm0 // Unpack Low bytes of a + movq mm2, [esi + ebx] // load b=Prior(x) + punpcklbw mm2, mm0 // Unpack High bytes of b + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + punpckhbw mm3, mm0 // Unpack High bytes of c + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi + ebx] // load c=Prior(x-bpp) + pand mm7, ActiveMask + movq mm2, mm3 // load b=Prior(x) step 1 + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + punpcklbw mm3, mm0 // Unpack High bytes of c + movq [edi + ebx], mm7 // write back updated value + movq mm1, mm7 // Now mm1 will be used as Raw(x-bpp) + // Do second set of 4 bytes + punpckhbw mm2, mm0 // Unpack Low bytes of b + punpcklbw mm1, mm0 // Unpack Low bytes of a + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + // Step ex to next set of 8 bytes and repeat loop til done + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + jb dpth4lp + } // end _asm block + } + break; + case 8: // bpp == 8 + { + ActiveMask.use = 0x00000000ffffffff; + _asm { + mov ebx, diff + mov edi, row + mov esi, prev_row + pxor mm0, mm0 + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] // Only time should need to read + // a=Raw(x-bpp) bytes +dpth8lp: + // Do first set of 4 bytes + movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes + punpcklbw mm1, mm0 // Unpack Low bytes of a + movq mm2, [esi + ebx] // load b=Prior(x) + punpcklbw mm2, mm0 // Unpack Low bytes of b + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + punpcklbw mm3, mm0 // Unpack Low bytes of c + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + paddw mm7, mm3 + pxor mm0, mm0 + packuswb mm7, mm1 + movq mm3, [esi+ebx-8] // read c=Prior(x-bpp) bytes + pand mm7, ActiveMask + movq mm2, [esi + ebx] // load b=Prior(x) + paddb mm7, [edi + ebx] // add Paeth predictor with Raw(x) + punpckhbw mm3, mm0 // Unpack High bytes of c + movq [edi + ebx], mm7 // write back updated value + movq mm1, [edi+ebx-8] // read a=Raw(x-bpp) bytes + + // Do second set of 4 bytes + punpckhbw mm2, mm0 // Unpack High bytes of b + punpckhbw mm1, mm0 // Unpack High bytes of a + // pav = p - a = (a + b - c) - a = b - c + movq mm4, mm2 + // pbv = p - b = (a + b - c) - b = a - c + movq mm5, mm1 + psubw mm4, mm3 + pxor mm7, mm7 + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + movq mm6, mm4 + psubw mm5, mm3 + // pa = abs(p-a) = abs(pav) + // pb = abs(p-b) = abs(pbv) + // pc = abs(p-c) = abs(pcv) + pcmpgtw mm0, mm4 // Create mask pav bytes < 0 + paddw mm6, mm5 + pand mm0, mm4 // Only pav bytes < 0 in mm7 + pcmpgtw mm7, mm5 // Create mask pbv bytes < 0 + psubw mm4, mm0 + pand mm7, mm5 // Only pbv bytes < 0 in mm0 + psubw mm4, mm0 + psubw mm5, mm7 + pxor mm0, mm0 + pcmpgtw mm0, mm6 // Create mask pcv bytes < 0 + pand mm0, mm6 // Only pav bytes < 0 in mm7 + psubw mm5, mm7 + psubw mm6, mm0 + // test pa <= pb + movq mm7, mm4 + psubw mm6, mm0 + pcmpgtw mm7, mm5 // pa > pb? + movq mm0, mm7 + // use mm7 mask to merge pa & pb + pand mm5, mm7 + // use mm0 mask copy to merge a & b + pand mm2, mm0 + pandn mm7, mm4 + pandn mm0, mm1 + paddw mm7, mm5 + paddw mm0, mm2 + // test ((pa <= pb)? pa:pb) <= pc + pcmpgtw mm7, mm6 // pab > pc? + pxor mm1, mm1 + pand mm3, mm7 + pandn mm7, mm0 + pxor mm1, mm1 + paddw mm7, mm3 + pxor mm0, mm0 + // Step ex to next set of 8 bytes and repeat loop til done + add ebx, 8 + packuswb mm1, mm7 + paddb mm1, [edi + ebx - 8] // add Paeth predictor with Raw(x) + cmp ebx, MMXLength + movq [edi + ebx - 8], mm1 // write back updated value + // mm1 will be used as Raw(x-bpp) next loop + jb dpth8lp + } // end _asm block + } + break; + + case 1: // bpp = 1 + case 2: // bpp = 2 + default: // bpp > 8 + { + _asm { + mov ebx, diff + cmp ebx, FullLength + jnb dpthdend + mov edi, row + mov esi, prev_row + // Do Paeth decode for remaining bytes + mov edx, ebx + xor ecx, ecx // zero ecx before using cl & cx in loop below + sub edx, bpp // Set edx = ebx - bpp +dpthdlp: + xor eax, eax + // pav = p - a = (a + b - c) - a = b - c + mov al, [esi + ebx] // load Prior(x) into al + mov cl, [esi + edx] // load Prior(x-bpp) into cl + sub eax, ecx // subtract Prior(x-bpp) + mov patemp, eax // Save pav for later use + xor eax, eax + // pbv = p - b = (a + b - c) - b = a - c + mov al, [edi + edx] // load Raw(x-bpp) into al + sub eax, ecx // subtract Prior(x-bpp) + mov ecx, eax + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + add eax, patemp // pcv = pav + pbv + // pc = abs(pcv) + test eax, 0x80000000 + jz dpthdpca + neg eax // reverse sign of neg values +dpthdpca: + mov pctemp, eax // save pc for later use + // pb = abs(pbv) + test ecx, 0x80000000 + jz dpthdpba + neg ecx // reverse sign of neg values +dpthdpba: + mov pbtemp, ecx // save pb for later use + // pa = abs(pav) + mov eax, patemp + test eax, 0x80000000 + jz dpthdpaa + neg eax // reverse sign of neg values +dpthdpaa: + mov patemp, eax // save pa for later use + // test if pa <= pb + cmp eax, ecx + jna dpthdabb + // pa > pb; now test if pb <= pc + cmp ecx, pctemp + jna dpthdbbc + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthdpaeth +dpthdbbc: + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + mov cl, [esi + ebx] // load Prior(x) into cl + jmp dpthdpaeth +dpthdabb: + // pa <= pb; now test if pa <= pc + cmp eax, pctemp + jna dpthdabc + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthdpaeth +dpthdabc: + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + mov cl, [edi + edx] // load Raw(x-bpp) into cl +dpthdpaeth: + inc ebx + inc edx + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + add [edi + ebx - 1], cl + cmp ebx, FullLength + jb dpthdlp +dpthdend: + } // end _asm block + } + return; // No need to go further with this one + } // end switch ( bpp ) + _asm + { + // MMX acceleration complete now do clean-up + // Check if any remaining bytes left to decode + mov ebx, MMXLength + cmp ebx, FullLength + jnb dpthend + mov edi, row + mov esi, prev_row + // Do Paeth decode for remaining bytes + mov edx, ebx + xor ecx, ecx // zero ecx before using cl & cx in loop below + sub edx, bpp // Set edx = ebx - bpp +dpthlp2: + xor eax, eax + // pav = p - a = (a + b - c) - a = b - c + mov al, [esi + ebx] // load Prior(x) into al + mov cl, [esi + edx] // load Prior(x-bpp) into cl + sub eax, ecx // subtract Prior(x-bpp) + mov patemp, eax // Save pav for later use + xor eax, eax + // pbv = p - b = (a + b - c) - b = a - c + mov al, [edi + edx] // load Raw(x-bpp) into al + sub eax, ecx // subtract Prior(x-bpp) + mov ecx, eax + // pcv = p - c = (a + b - c) -c = (a - c) + (b - c) = pav + pbv + add eax, patemp // pcv = pav + pbv + // pc = abs(pcv) + test eax, 0x80000000 + jz dpthpca2 + neg eax // reverse sign of neg values +dpthpca2: + mov pctemp, eax // save pc for later use + // pb = abs(pbv) + test ecx, 0x80000000 + jz dpthpba2 + neg ecx // reverse sign of neg values +dpthpba2: + mov pbtemp, ecx // save pb for later use + // pa = abs(pav) + mov eax, patemp + test eax, 0x80000000 + jz dpthpaa2 + neg eax // reverse sign of neg values +dpthpaa2: + mov patemp, eax // save pa for later use + // test if pa <= pb + cmp eax, ecx + jna dpthabb2 + // pa > pb; now test if pb <= pc + cmp ecx, pctemp + jna dpthbbc2 + // pb > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthpaeth2 +dpthbbc2: + // pb <= pc; Raw(x) = Paeth(x) + Prior(x) + mov cl, [esi + ebx] // load Prior(x) into cl + jmp dpthpaeth2 +dpthabb2: + // pa <= pb; now test if pa <= pc + cmp eax, pctemp + jna dpthabc2 + // pa > pc; Raw(x) = Paeth(x) + Prior(x-bpp) + mov cl, [esi + edx] // load Prior(x-bpp) into cl + jmp dpthpaeth2 +dpthabc2: + // pa <= pc; Raw(x) = Paeth(x) + Raw(x-bpp) + mov cl, [edi + edx] // load Raw(x-bpp) into cl +dpthpaeth2: + inc ebx + inc edx + // Raw(x) = (Paeth(x) + Paeth_Predictor( a, b, c )) mod 256 + add [edi + ebx - 1], cl + cmp ebx, FullLength + jb dpthlp2 +dpthend: + emms // End MMX instructions; prep for possible FP instrs. + } // end _asm block +} + +// Optimized code for PNG Sub filter decoder +void /* PRIVATE */ +png_read_filter_row_mmx_sub(png_row_infop row_info, png_bytep row) +{ + //int test; + int bpp; + png_uint_32 FullLength; + png_uint_32 MMXLength; + int diff; + + bpp = (row_info->pixel_depth + 7) >> 3; // Get # bytes per pixel + FullLength = row_info->rowbytes - bpp; // # of bytes to filter + _asm { + mov edi, row + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp + xor eax, eax + // get # of bytes to alignment + mov diff, edi // take start of row + add diff, 0xf // add 7 + 8 to incr past + // alignment boundary + xor ebx, ebx + and diff, 0xfffffff8 // mask to alignment boundary + sub diff, edi // subtract from start ==> value + // ebx at alignment + jz dsubgo + // fix alignment +dsublp1: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, diff + jb dsublp1 +dsubgo: + mov ecx, FullLength + mov edx, ecx + sub edx, ebx // subtract alignment fix + and edx, 0x00000007 // calc bytes over mult of 8 + sub ecx, edx // drop over bytes from length + mov MMXLength, ecx + } // end _asm block + + // Now do the math for the rest of the row + switch ( bpp ) + { + case 3: + { + ActiveMask.use = 0x0000ffffff000000; + ShiftBpp.use = 24; // == 3 * 8 + ShiftRem.use = 40; // == 64 - 24 + _asm { + mov edi, row + movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp + movq mm6, mm7 + mov ebx, diff + psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active + // byte group + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] +dsub3lp: + psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes + // no need for mask; shift clears inactive bytes + // Add 1st active group + movq mm0, [edi+ebx] + paddb mm0, mm1 + // Add 2nd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm7 // mask to use only 2nd active group + paddb mm0, mm1 + // Add 3rd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm6 // mask to use only 3rd active group + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 // Write updated Raws back to array + // Prep for doing 1st add at top of loop + movq mm1, mm0 + jb dsub3lp + } // end _asm block + } + break; + + case 1: + { + // Placed here just in case this is a duplicate of the + // non-MMX code for the SUB filter in png_read_filter_row above + // + // png_bytep rp; + // png_bytep lp; + // png_uint_32 i; + // bpp = (row_info->pixel_depth + 7) >> 3; + // for (i = (png_uint_32)bpp, rp = row + bpp, lp = row; + // i < row_info->rowbytes; i++, rp++, lp++) + // { + // *rp = (png_byte)(((int)(*rp) + (int)(*lp)) & 0xff); + // } + _asm { + mov ebx, diff + mov edi, row + cmp ebx, FullLength + jnb dsub1end + mov esi, edi // lp = row + xor eax, eax + add edi, bpp // rp = row + bpp +dsub1lp: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, FullLength + jb dsub1lp +dsub1end: + } // end _asm block + } + return; + + case 6: + case 7: + case 4: + case 5: + { + ShiftBpp.use = bpp << 3; + ShiftRem.use = 64 - ShiftBpp.use; + _asm { + mov edi, row + mov ebx, diff + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] +dsub4lp: + psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes + // no need for mask; shift clears inactive bytes + movq mm0, [edi+ebx] + paddb mm0, mm1 + // Add 2nd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + // there is no need for any mask + // since shift clears inactive bits/bytes + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 + movq mm1, mm0 // Prep for doing 1st add at top of loop + jb dsub4lp + } // end _asm block + } + break; + + case 2: + { + ActiveMask.use = 0x00000000ffff0000; + ShiftBpp.use = 16; // == 2 * 8 + ShiftRem.use = 48; // == 64 - 16 + _asm { + movq mm7, ActiveMask // Load ActiveMask for 2nd active byte group + mov ebx, diff + movq mm6, mm7 + mov edi, row + psllq mm6, ShiftBpp // Move mask in mm6 to cover 3rd active + // byte group + mov esi, edi // lp = row + movq mm5, mm6 + add edi, bpp // rp = row + bpp + psllq mm5, ShiftBpp // Move mask in mm5 to cover 4th active + // byte group + // PRIME the pump (load the first Raw(x-bpp) data set + movq mm1, [edi+ebx-8] +dsub2lp: + // Add 1st active group + psrlq mm1, ShiftRem // Shift data for adding 1st bpp bytes + // no need for mask; shift clears inactive + // bytes + movq mm0, [edi+ebx] + paddb mm0, mm1 + // Add 2nd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm7 // mask to use only 2nd active group + paddb mm0, mm1 + // Add 3rd active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm6 // mask to use only 3rd active group + paddb mm0, mm1 + // Add 4th active group + movq mm1, mm0 // mov updated Raws to mm1 + psllq mm1, ShiftBpp // shift data to position correctly + pand mm1, mm5 // mask to use only 4th active group + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 // Write updated Raws back to array + movq mm1, mm0 // Prep for doing 1st add at top of loop + jb dsub2lp + } // end _asm block + } + break; + case 8: + { + _asm { + mov edi, row + mov ebx, diff + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp + mov ecx, MMXLength + movq mm7, [edi+ebx-8] // PRIME the pump (load the first + // Raw(x-bpp) data set + and ecx, 0x0000003f // calc bytes over mult of 64 +dsub8lp: + movq mm0, [edi+ebx] // Load Sub(x) for 1st 8 bytes + paddb mm0, mm7 + movq mm1, [edi+ebx+8] // Load Sub(x) for 2nd 8 bytes + movq [edi+ebx], mm0 // Write Raw(x) for 1st 8 bytes + // Now mm0 will be used as Raw(x-bpp) for + // the 2nd group of 8 bytes. This will be + // repeated for each group of 8 bytes with + // the 8th group being used as the Raw(x-bpp) + // for the 1st group of the next loop. + paddb mm1, mm0 + movq mm2, [edi+ebx+16] // Load Sub(x) for 3rd 8 bytes + movq [edi+ebx+8], mm1 // Write Raw(x) for 2nd 8 bytes + paddb mm2, mm1 + movq mm3, [edi+ebx+24] // Load Sub(x) for 4th 8 bytes + movq [edi+ebx+16], mm2 // Write Raw(x) for 3rd 8 bytes + paddb mm3, mm2 + movq mm4, [edi+ebx+32] // Load Sub(x) for 5th 8 bytes + movq [edi+ebx+24], mm3 // Write Raw(x) for 4th 8 bytes + paddb mm4, mm3 + movq mm5, [edi+ebx+40] // Load Sub(x) for 6th 8 bytes + movq [edi+ebx+32], mm4 // Write Raw(x) for 5th 8 bytes + paddb mm5, mm4 + movq mm6, [edi+ebx+48] // Load Sub(x) for 7th 8 bytes + movq [edi+ebx+40], mm5 // Write Raw(x) for 6th 8 bytes + paddb mm6, mm5 + movq mm7, [edi+ebx+56] // Load Sub(x) for 8th 8 bytes + movq [edi+ebx+48], mm6 // Write Raw(x) for 7th 8 bytes + add ebx, 64 + paddb mm7, mm6 + cmp ebx, ecx + movq [edi+ebx-8], mm7 // Write Raw(x) for 8th 8 bytes + jb dsub8lp + cmp ebx, MMXLength + jnb dsub8lt8 +dsub8lpA: + movq mm0, [edi+ebx] + add ebx, 8 + paddb mm0, mm7 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 // use -8 to offset early add to ebx + movq mm7, mm0 // Move calculated Raw(x) data to mm1 to + // be the new Raw(x-bpp) for the next loop + jb dsub8lpA +dsub8lt8: + } // end _asm block + } + break; + + default: // bpp greater than 8 bytes + { + _asm { + mov ebx, diff + mov edi, row + mov esi, edi // lp = row + add edi, bpp // rp = row + bpp +dsubAlp: + movq mm0, [edi+ebx] + movq mm1, [esi+ebx] + add ebx, 8 + paddb mm0, mm1 + cmp ebx, MMXLength + movq [edi+ebx-8], mm0 // mov does not affect flags; -8 to offset + // add ebx + jb dsubAlp + } // end _asm block + } + break; + + } // end switch ( bpp ) + + _asm { + mov ebx, MMXLength + mov edi, row + cmp ebx, FullLength + jnb dsubend + mov esi, edi // lp = row + xor eax, eax + add edi, bpp // rp = row + bpp +dsublp2: + mov al, [esi+ebx] + add [edi+ebx], al + inc ebx + cmp ebx, FullLength + jb dsublp2 +dsubend: + emms // End MMX instructions; prep for possible FP instrs. + } // end _asm block +} + +// Optimized code for PNG Up filter decoder +void /* PRIVATE */ +png_read_filter_row_mmx_up(png_row_infop row_info, png_bytep row, + png_bytep prev_row) +{ + png_uint_32 len; + len = row_info->rowbytes; // # of bytes to filter + _asm { + mov edi, row + // get # of bytes to alignment + mov ecx, edi + xor ebx, ebx + add ecx, 0x7 + xor eax, eax + and ecx, 0xfffffff8 + mov esi, prev_row + sub ecx, edi + jz dupgo + // fix alignment +duplp1: + mov al, [edi+ebx] + add al, [esi+ebx] + inc ebx + cmp ebx, ecx + mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx + jb duplp1 +dupgo: + mov ecx, len + mov edx, ecx + sub edx, ebx // subtract alignment fix + and edx, 0x0000003f // calc bytes over mult of 64 + sub ecx, edx // drop over bytes from length + // Unrolled loop - use all MMX registers and interleave to reduce + // number of branch instructions (loops) and reduce partial stalls +duploop: + movq mm1, [esi+ebx] + movq mm0, [edi+ebx] + movq mm3, [esi+ebx+8] + paddb mm0, mm1 + movq mm2, [edi+ebx+8] + movq [edi+ebx], mm0 + paddb mm2, mm3 + movq mm5, [esi+ebx+16] + movq [edi+ebx+8], mm2 + movq mm4, [edi+ebx+16] + movq mm7, [esi+ebx+24] + paddb mm4, mm5 + movq mm6, [edi+ebx+24] + movq [edi+ebx+16], mm4 + paddb mm6, mm7 + movq mm1, [esi+ebx+32] + movq [edi+ebx+24], mm6 + movq mm0, [edi+ebx+32] + movq mm3, [esi+ebx+40] + paddb mm0, mm1 + movq mm2, [edi+ebx+40] + movq [edi+ebx+32], mm0 + paddb mm2, mm3 + movq mm5, [esi+ebx+48] + movq [edi+ebx+40], mm2 + movq mm4, [edi+ebx+48] + movq mm7, [esi+ebx+56] + paddb mm4, mm5 + movq mm6, [edi+ebx+56] + movq [edi+ebx+48], mm4 + add ebx, 64 + paddb mm6, mm7 + cmp ebx, ecx + movq [edi+ebx-8], mm6 // (+56)movq does not affect flags; + // -8 to offset add ebx + jb duploop + + cmp edx, 0 // Test for bytes over mult of 64 + jz dupend + + + // 2 lines added by lcreeve@netins.net + // (mail 11 Jul 98 in png-implement list) + cmp edx, 8 //test for less than 8 bytes + jb duplt8 + + + add ecx, edx + and edx, 0x00000007 // calc bytes over mult of 8 + sub ecx, edx // drop over bytes from length + jz duplt8 + // Loop using MMX registers mm0 & mm1 to update 8 bytes simultaneously +duplpA: + movq mm1, [esi+ebx] + movq mm0, [edi+ebx] + add ebx, 8 + paddb mm0, mm1 + cmp ebx, ecx + movq [edi+ebx-8], mm0 // movq does not affect flags; -8 to offset add ebx + jb duplpA + cmp edx, 0 // Test for bytes over mult of 8 + jz dupend +duplt8: + xor eax, eax + add ecx, edx // move over byte count into counter + // Loop using x86 registers to update remaining bytes +duplp2: + mov al, [edi + ebx] + add al, [esi + ebx] + inc ebx + cmp ebx, ecx + mov [edi + ebx-1], al // mov does not affect flags; -1 to offset inc ebx + jb duplp2 +dupend: + // Conversion of filtered row completed + emms // End MMX instructions; prep for possible FP instrs. + } // end _asm block +} + + +// Optimized png_read_filter_row routines +void /* PRIVATE */ +png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep + row, png_bytep prev_row, int filter) +{ +#ifdef PNG_DEBUG + char filnm[6]; +#endif +#define UseMMX 1 + + if (mmx_supported == 2) + mmx_supported = mmxsupport(); + + if (!mmx_supported) + { + png_read_filter_row_c(png_ptr, row_info, row, prev_row, filter); + return ; + } + +#ifdef PNG_DEBUG + png_debug(1, "in png_read_filter_row\n"); +# if (UseMMX == 1) + png_debug1(0,"%s, ", "MMX"); +# else + png_debug1(0,"%s, ", "x86"); +# endif + switch (filter) + { + case 0: sprintf(filnm, "None "); + break; + case 1: sprintf(filnm, "Sub "); + break; + case 2: sprintf(filnm, "Up "); + break; + case 3: sprintf(filnm, "Avg "); + break; + case 4: sprintf(filnm, "Paeth"); + break; + default: sprintf(filnm, "Unknw"); + break; + } + png_debug2(0,"row=%5d, %s, ", png_ptr->row_number, filnm); + png_debug2(0, "pd=%2d, b=%d, ", (int)row_info->pixel_depth, + (int)((row_info->pixel_depth + 7) >> 3)); + png_debug1(0,"len=%8d, ", row_info->rowbytes); +#endif + + switch (filter) + { + case PNG_FILTER_VALUE_NONE: + break; + case PNG_FILTER_VALUE_SUB: + { +#if (UseMMX == 1) + if ((row_info->pixel_depth > 8) && + (row_info->rowbytes >= 128) ) + { + png_read_filter_row_mmx_sub(row_info, row); + } + else +#endif + { + png_uint_32 i; + png_uint_32 istop = row_info->rowbytes; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_bytep rp = row + bpp; + png_bytep lp = row; + + for (i = bpp; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); + rp++; + } + } //end !UseMMX + break; + } + case PNG_FILTER_VALUE_UP: + { +#if (UseMMX == 1) + if ((row_info->pixel_depth > 8) && + (row_info->rowbytes >= 128) ) + { + png_read_filter_row_mmx_up(row_info, row, prev_row); + } //end if UseMMX + else +#endif + { + png_bytep rp; + png_bytep pp; + png_uint_32 i; + for (i = 0, rp = row, pp = prev_row; + i < row_info->rowbytes; i++, rp++, pp++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp)) & 0xff); + } + } //end !UseMMX + break; + } + case PNG_FILTER_VALUE_AVG: + { +#if (UseMMX == 1) + if ((row_info->pixel_depth > 8) && + (row_info->rowbytes >= 128) ) + { + png_read_filter_row_mmx_avg(row_info, row, prev_row); + } //end if UseMMX + else +#endif + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop = row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++) >> 1)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) + { + *rp = (png_byte)(((int)(*rp) + + ((int)(*pp++ + *lp++) >> 1)) & 0xff); + rp++; + } + } //end !UseMMX + break; + } + case PNG_FILTER_VALUE_PAETH: + { +#if (UseMMX == 1) + if ((row_info->pixel_depth > 8) && + (row_info->rowbytes >= 128) ) + { + png_read_filter_row_mmx_paeth(row_info, row, prev_row); + } //end if UseMMX + else +#endif + { + png_uint_32 i; + png_bytep rp = row; + png_bytep pp = prev_row; + png_bytep lp = row; + png_bytep cp = prev_row; + png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; + png_uint_32 istop=row_info->rowbytes - bpp; + + for (i = 0; i < bpp; i++) + { + *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); + rp++; + } + + for (i = 0; i < istop; i++) // use leftover rp,pp + { + int a, b, c, pa, pb, pc, p; + + a = *lp++; + b = *pp++; + c = *cp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + /* + if (pa <= pb && pa <= pc) + p = a; + else if (pb <= pc) + p = b; + else + p = c; + */ + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *rp = (png_byte)(((int)(*rp) + p) & 0xff); + rp++; + } + } //end !UseMMX + break; + } + default: + png_warning(png_ptr, "Ignoring bad adaptive filter type"); + *row=0; + break; + } +} +#endif diff --git a/src/libs/pdflib/libs/tiff/Jamfile b/src/libs/pdflib/libs/tiff/Jamfile new file mode 100644 index 0000000000..62064eaf5a --- /dev/null +++ b/src/libs/pdflib/libs/tiff/Jamfile @@ -0,0 +1,38 @@ +SubDir OBOS_TOP src libs pdflib libs tiff ; + +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs pdcore ] ; +SubDirHdrs [ FDirName $(OBOS_TOP) src libs pdflib libs flate ] ; + +UseLibraryHeaders pdflib ; + +StaticLibrary pdf : + tif_auxx.c + tif_close.c + tif_codec.c + tif_compress.c + tif_dir.c + tif_dirinfo.c + tif_dirread.c + tif_dumpmode.c + tif_error.c + tif_fax3.c + tif_fax3sm.c + tif_getimage.c + tif_luv.c + tif_lzw.c + tif_next.c + tif_open.c + tif_packbits.c + tif_predict.c + tif_read.c + tif_strip.c + tif_swab.c + tif_thunder.c + tif_tile.c + tif_unix.c + tif_version.c + tif_warning.c + tif_zip.c +: STATIC_LIBRARY_DIR +; + diff --git a/src/libs/pdflib/libs/tiff/Makefile b/src/libs/pdflib/libs/tiff/Makefile new file mode 100644 index 0000000000..f72a5e908f --- /dev/null +++ b/src/libs/pdflib/libs/tiff/Makefile @@ -0,0 +1,91 @@ +# Makefile for tifflib +# This generates a libtool convenience library +# $Id: Makefile,v 1.1 2004/10/06 17:46:51 laplace Exp $ + +top_builddir = ../.. + +include ../../config/mkcommon.inc + +LIBNAME = $(TIFFLIBLINK) +INCLUDES = $(PDCORELIBINC) $(FLATELIBINC) + +SRC = \ + $(srcdir)/tif_auxx.c \ + $(srcdir)/tif_close.c \ + $(srcdir)/tif_codec.c \ + $(srcdir)/tif_compress.c \ + $(srcdir)/tif_dir.c \ + $(srcdir)/tif_dirinfo.c \ + $(srcdir)/tif_dirread.c \ + $(srcdir)/tif_dumpmode.c \ + $(srcdir)/tif_error.c \ + $(srcdir)/tif_fax3.c \ + $(srcdir)/tif_fax3sm.c \ + $(srcdir)/tif_getimage.c \ + $(srcdir)/tif_luv.c \ + $(srcdir)/tif_lzw.c \ + $(srcdir)/tif_next.c \ + $(srcdir)/tif_open.c \ + $(srcdir)/tif_packbits.c \ + $(srcdir)/tif_predict.c \ + $(srcdir)/tif_read.c \ + $(srcdir)/tif_strip.c \ + $(srcdir)/tif_swab.c \ + $(srcdir)/tif_tile.c \ + $(srcdir)/tif_unix.c \ + $(srcdir)/tif_version.c \ + $(srcdir)/tif_warning.c \ + $(srcdir)/tif_zip.c + +# unused modules +# $(srcdir)/tif_dirwrite.c \ +# $(srcdir)/tif_flush.c \ +# $(srcdir)/tif_jpeg.c \ +# $(srcdir)/tif_ojeg.c \ +# $(srcdir)/tif_pixarlog.c \ +# $(srcdir)/tif_print.c \ +# $(srcdir)/tif_thunder.c \ +# $(srcdir)/tif_write.c + + +OBJS = \ + $(srcdir)/tif_auxx$(LO) \ + $(srcdir)/tif_close$(LO) \ + $(srcdir)/tif_codec$(LO) \ + $(srcdir)/tif_compress$(LO) \ + $(srcdir)/tif_dir$(LO) \ + $(srcdir)/tif_dirinfo$(LO) \ + $(srcdir)/tif_dirread$(LO) \ + $(srcdir)/tif_dumpmode$(LO) \ + $(srcdir)/tif_error$(LO) \ + $(srcdir)/tif_fax3$(LO) \ + $(srcdir)/tif_fax3sm$(LO) \ + $(srcdir)/tif_getimage$(LO) \ + $(srcdir)/tif_luv$(LO) \ + $(srcdir)/tif_lzw$(LO) \ + $(srcdir)/tif_next$(LO) \ + $(srcdir)/tif_open$(LO) \ + $(srcdir)/tif_packbits$(LO) \ + $(srcdir)/tif_predict$(LO) \ + $(srcdir)/tif_read$(LO) \ + $(srcdir)/tif_strip$(LO) \ + $(srcdir)/tif_swab$(LO) \ + $(srcdir)/tif_tile$(LO) \ + $(srcdir)/tif_unix$(LO) \ + $(srcdir)/tif_version$(LO) \ + $(srcdir)/tif_warning$(LO) \ + $(srcdir)/tif_zip$(LO) + +# unused modules +# $(srcdir)/tif_dirwrite$(LO) \ +# $(srcdir)/tif_flush$(LO) \ +# $(srcdir)/tif_jpeg.c \ +# $(srcdir)/tif_ojeg.c \ +# $(srcdir)/tif_print$(LO) \ +# $(srcdir)/tif_pixarlog$(LO) \ +# $(srcdir)/tif_thunder$(LO) \ +# $(srcdir)/tif_write$(LO) + +include ../../config/mklibs.inc + +# Automatically generated dependencies diff --git a/src/libs/pdflib/libs/tiff/port.h b/src/libs/pdflib/libs/tiff/port.h new file mode 100644 index 0000000000..79f04b04ad --- /dev/null +++ b/src/libs/pdflib/libs/tiff/port.h @@ -0,0 +1,226 @@ +/* PDFlib GmbH cvsid: $Id: port.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +#ifndef TIFF_PORT_H +#define TIFF_PORT_H 1 + +/* not used: PDFlib GmbH: +#define HOST_FILLORDER FILLORDER_LSB2MSB +*/ +#define HOST_BIGENDIAN 1 + +#include /* PDFlib GmbH: */ +#include +#include +#include + +/* PDFlib GmbH: */ +#if !defined(_WIN32_WCE) +#if defined(WIN32) || defined(OS2) +#include +#include +#else +#include /* TODO: fix me */ +#endif +#endif /* _WIN32_CE */ + +typedef unsigned char tif_char; +typedef unsigned short tif_short; +typedef unsigned int tif_int; +typedef unsigned long tif_long; + + +/* PDFlib GmbH: */ +/* + * This maze of checks controls defines or not the + * target system has BSD-style typdedefs declared in + * an include file and/or whether or not to include + * to get the SEEK_* definitions. Some + * additional includes are also done to pull in the + * appropriate definitions we're looking for. + */ +#if (defined macintosh || defined __POWERPC__ || \ + defined __CFM68K__ || defined __MC68K__) && \ + !defined MAC && !defined __BEOS__ +# define MAC +#endif + +#if defined(WIN32) || defined(OS2) +# define BSDTYPES +#elif defined(MAC) +# define BSDTYPES +# ifndef HAVE_UNISTD_H /* PDFlib GmbH: avoid warning on OS X */ +# define HAVE_UNISTD_H 0 +# endif +#else +# include +#endif + + +typedef double dblparam_t; + +#undef INLINE /* PDFlib GmbH */ +#define INLINE /* */ + +#define GLOBALDATA(TYPE,NAME) extern TYPE NAME + +/* to allow the use of PDFlib inside of programs using TIFFlib themselves */ +/* Make sure to observe the limit of 31 characters for function names! */ +#define LogL10fromY pdf_LogL10fromY +#define LogL10toY pdf_LogL10toY +#define LogL16fromY pdf_LogL16fromY +#define LogL16toY pdf_LogL16toY +#define LogLuv24fromXYZ pdf_LogLuv24fromXYZ +#define LogLuv24toXYZ pdf_LogLuv24toXYZ +#define LogLuv32fromXYZ pdf_LogLuv32fromXYZ +#define LogLuv32toXYZ pdf_LogLuv32toXYZ +#define TIFFCheckTile pdf_TIFFCheckTile +#define TIFFClientOpen pdf_TIFFClientOpen +#define TIFFClose pdf_TIFFClose +#define TIFFComputeStrip pdf_TIFFComputeStrip +#define TIFFComputeTile pdf_TIFFComputeTile +#define TIFFCreateDirectory pdf_TIFFCreateDirectory +#define TIFFCurrentDirectory pdf_TIFFCurrentDirectory +#define TIFFCurrentRow pdf_TIFFCurrentRow +#define TIFFCurrentStrip pdf_TIFFCurrentStrip +#define TIFFCurrentTile pdf_TIFFCurrentTile +#define TIFFDefaultDirectory pdf_TIFFDefaultDirectory +#define TIFFDefaultStripSize pdf_TIFFDefaultStripSize +#define TIFFDefaultTileSize pdf_TIFFDefaultTileSize +#define TIFFError pdf_TIFFError +#define TIFFFaxBlackCodes pdf_TIFFFaxBlackCodes +#define TIFFFaxBlackTable pdf_TIFFFaxBlackTable +#define TIFFFaxMainTable pdf_TIFFFaxMainTable +#define TIFFFaxWhiteCodes pdf_TIFFFaxWhiteCodes +#define TIFFFaxWhiteTable pdf_TIFFFaxWhiteTable +#define TIFFFdOpen pdf_TIFFFdOpen +#define TIFFFileName pdf_TIFFFileName +#define TIFFFindCODEC pdf_TIFFFindCODEC +#define TIFFFlush pdf_TIFFFlush +#define TIFFFlushData pdf_TIFFFlushData +#define TIFFFlushData1 pdf_TIFFFlushData1 +#define TIFFFreeDirectory pdf_TIFFFreeDirectory +#define TIFFGetBitRevTable pdf_TIFFGetBitRevTable +#define TIFFGetField pdf_TIFFGetField +#define TIFFGetFieldDefaulted pdf_TIFFGetFieldDefaulted +#define TIFFGetMode pdf_TIFFGetMode +#define TIFFGetVersion pdf_TIFFGetVersion +#define TIFFInitCCITTFax3 pdf_TIFFInitCCITTFax3 +#define TIFFInitCCITTFax4 pdf_TIFFInitCCITTFax4 +#define TIFFInitCCITTRLE pdf_TIFFInitCCITTRLE +#define TIFFInitCCITTRLEW pdf_TIFFInitCCITTRLEW +#define TIFFInitDumpMode pdf_TIFFInitDumpMode +#define TIFFInitLZW pdf_TIFFInitLZW +#define TIFFInitNeXT pdf_TIFFInitNeXT +#define TIFFInitPackBits pdf_TIFFInitPackBits +#define TIFFInitSGILog pdf_TIFFInitSGILog +#define TIFFInitZIP pdf_TIFFInitZIP +#define TIFFIsByteSwapped pdf_TIFFIsByteSwapped +#define TIFFIsMSB2LSB pdf_TIFFIsMSB2LSB +#define TIFFIsTiled pdf_TIFFIsTiled +#define TIFFIsUpSampled pdf_TIFFIsUpSampled +#define TIFFNumberOfStrips pdf_TIFFNumberOfStrips +#define TIFFNumberOfTiles pdf_TIFFNumberOfTiles +#define TIFFOpen pdf_TIFFOpen +#define TIFFPredictorInit pdf_TIFFPredictorInit +#define TIFFPrintDirectory pdf_TIFFPrintDirectory +#define TIFFRGBAImageBegin pdf_TIFFRGBAImageBegin +#define TIFFRGBAImageEnd pdf_TIFFRGBAImageEnd +#define TIFFRGBAImageGet pdf_TIFFRGBAImageGet +#define TIFFRGBAImageOK pdf_TIFFRGBAImageOK +#define TIFFRasterScanlineSize pdf_TIFFRasterScanlineSize +#define TIFFReadBufferSetup pdf_TIFFReadBufferSetup +#define TIFFReadDirectory pdf_TIFFReadDirectory +#define TIFFReadEncodedStrip pdf_TIFFReadEncodedStrip +#define TIFFReadEncodedTile pdf_TIFFReadEncodedTile +#define TIFFReadRGBAImage pdf_TIFFReadRGBAImage +#define TIFFReadRGBAStrip pdf_TIFFReadRGBAStrip +#define TIFFReadRGBATile pdf_TIFFReadRGBATile +#define TIFFReadRawStrip pdf_TIFFReadRawStrip +#define TIFFReadRawTile pdf_TIFFReadRawTile +#define TIFFReadScanline pdf_TIFFReadScanline +#define TIFFReadTile pdf_TIFFReadTile +#define TIFFReassignTagToIgnore pdf_TIFFReassignTagToIgnore +#define TIFFReverseBits pdf_TIFFReverseBits +#define TIFFRewriteDirectory pdf_TIFFRewriteDirectory +#define TIFFScanlineSize pdf_TIFFScanlineSize +#define TIFFSetCompressionScheme pdf_TIFFSetCompressionScheme +#define TIFFSetDirectory pdf_TIFFSetDirectory +#define TIFFSetErrorHandler pdf_TIFFSetErrorHandler +#define TIFFSetField pdf_TIFFSetField +#define TIFFSetTagExtender pdf_TIFFSetTagExtender +#define TIFFSetWarningHandler pdf_TIFFSetWarningHandler +#define TIFFSetWriteOffset pdf_TIFFSetWriteOffset +#define TIFFStripSize pdf_TIFFStripSize +#define TIFFSwabArrayOfDouble pdf_TIFFSwabArrayOfDouble +#define TIFFSwabArrayOfLong pdf_TIFFSwabArrayOfLong +#define TIFFSwabArrayOfShort pdf_TIFFSwabArrayOfShort +#define TIFFSwabDouble pdf_TIFFSwabDouble +#define TIFFSwabLong pdf_TIFFSwabLong +#define TIFFSwabShort pdf_TIFFSwabShort +#define TIFFTileRowSize pdf_TIFFTileRowSize +#define TIFFTileSize pdf_TIFFTileSize +#define TIFFVGetField pdf_TIFFVGetField +#define TIFFVGetFieldDefaulted pdf_TIFFVGetFieldDefaulted +#define TIFFVSetField pdf_TIFFVSetField +#define TIFFVStripSize pdf_TIFFVStripSize +#define TIFFVTileSize pdf_TIFFVTileSize +#define TIFFWarning pdf_TIFFWarning +#define TIFFWriteBufferSetup pdf_TIFFWriteBufferSetup +#define TIFFWriteCheck pdf_TIFFWriteCheck +#define TIFFWriteDirectory pdf_TIFFWriteDirectory +#define TIFFWriteEncodedStrip pdf_TIFFWriteEncodedStrip +#define TIFFWriteEncodedTile pdf_TIFFWriteEncodedTile +#define TIFFWriteRawStrip pdf_TIFFWriteRawStrip +#define TIFFWriteRawTile pdf_TIFFWriteRawTile +#define TIFFWriteScanline pdf_TIFFWriteScanline +#define TIFFWriteTile pdf_TIFFWriteTile +#define XYZtoRGB24 pdf_XYZtoRGB24 +#define _TIFFBuiltinCODECS pdf__TIFFBuiltinCODECS +#define _TIFFDefaultStripSize pdf__TIFFDefaultStripSize +#define _TIFFDefaultTileSize pdf__TIFFDefaultTileSize +#define _TIFFFax3fillruns pdf__TIFFFax3fillruns +#define _TIFFFieldWithTag pdf__TIFFFieldWithTag +#define _TIFFFindFieldInfo pdf__TIFFFindFieldInfo +#define _TIFFMergeFieldInfo pdf__TIFFMergeFieldInfo +#define _TIFFNoPostDecode pdf__TIFFNoPostDecode +#define _TIFFNoPreCode pdf__TIFFNoPreCode +#define _TIFFNoRowDecode pdf__TIFFNoRowDecode +#define _TIFFNoRowEncode pdf__TIFFNoRowEncode +#define _TIFFNoSeek pdf__TIFFNoSeek +#define _TIFFNoStripDecode pdf__TIFFNoStripDecode +#define _TIFFNoStripEncode pdf__TIFFNoStripEncode +#define _TIFFNoTileDecode pdf__TIFFNoTileDecode +#define _TIFFNoTileEncode pdf__TIFFNoTileEncode +#define _TIFFPrintFieldInfo pdf__TIFFPrintFieldInfo +#define _TIFFSampleToTagType pdf__TIFFSampleToTagType + +/* Note: function name shortened to facilitate porting */ +#define _TIFFSetDefaultCompressionState pdf__TIFFSetDefaultCompState + +#define _TIFFSetupFieldInfo pdf__TIFFSetupFieldInfo +#define _TIFFSwab16BitData pdf__TIFFSwab16BitData +#define _TIFFSwab32BitData pdf__TIFFSwab32BitData +#define _TIFFSwab64BitData pdf__TIFFSwab64BitData +#define _TIFFerrorHandler pdf__TIFFerrorHandler +#define _TIFFfree pdf__TIFFfree +#define _TIFFgetMode pdf__TIFFgetMode +#define _TIFFmalloc pdf__TIFFmalloc +#define _TIFFmemcmp pdf__TIFFmemcmp +#define _TIFFmemcpy pdf__TIFFmemcpy +#define _TIFFmemset pdf__TIFFmemset +#define _TIFFprintAscii pdf__TIFFprintAscii +#define _TIFFprintAsciiTag pdf__TIFFprintAsciiTag +#define _TIFFrealloc pdf__TIFFrealloc +#define _TIFFsetByteArray pdf__TIFFsetByteArray +#define _TIFFsetDoubleArray pdf__TIFFsetDoubleArray +#define _TIFFsetFloatArray pdf__TIFFsetFloatArray +#define _TIFFsetLongArray pdf__TIFFsetLongArray +#define _TIFFsetNString pdf__TIFFsetNString +#define _TIFFsetShortArray pdf__TIFFsetShortArray +#define _TIFFsetString pdf__TIFFsetString +#define _TIFFwarningHandler pdf__TIFFwarningHandler +#define tiffDataWidth pdf_tiffDataWidth +#define uv_decode pdf_uv_decode +#define uv_encode pdf_uv_encode + +#endif diff --git a/src/libs/pdflib/libs/tiff/t4.h b/src/libs/pdflib/libs/tiff/t4.h new file mode 100644 index 0000000000..c71c948f1c --- /dev/null +++ b/src/libs/pdflib/libs/tiff/t4.h @@ -0,0 +1,285 @@ +/* PDFlib GmbH cvsid: $Id: t4.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _T4_ +#define _T4_ +/* + * CCITT T.4 1D Huffman runlength codes and + * related definitions. Given the small sizes + * of these tables it does not seem + * worthwhile to make code & length 8 bits. + */ +typedef struct tableentry { + unsigned short length; /* bit length of g3 code */ + unsigned short code; /* g3 code */ + short runlen; /* run length in bits */ +} tableentry; + +#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ + +/* status values returned instead of a run length */ +#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ +#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ +#define G3CODE_EOF -3 /* end of input data */ +#define G3CODE_INCOMP -4 /* incomplete run code */ + +/* + * Note that these tables are ordered such that the + * index into the table is known to be either the + * run length, or (run length / 64) + a fixed offset. + * + * NB: The G3CODE_INVALID entries are only used + * during state generation (see mkg3states.c). + */ +#ifdef G3CODES +const tableentry TIFFFaxWhiteCodes[] = { + { 8, 0x35, 0 }, /* 0011 0101 */ + { 6, 0x7, 1 }, /* 0001 11 */ + { 4, 0x7, 2 }, /* 0111 */ + { 4, 0x8, 3 }, /* 1000 */ + { 4, 0xB, 4 }, /* 1011 */ + { 4, 0xC, 5 }, /* 1100 */ + { 4, 0xE, 6 }, /* 1110 */ + { 4, 0xF, 7 }, /* 1111 */ + { 5, 0x13, 8 }, /* 1001 1 */ + { 5, 0x14, 9 }, /* 1010 0 */ + { 5, 0x7, 10 }, /* 0011 1 */ + { 5, 0x8, 11 }, /* 0100 0 */ + { 6, 0x8, 12 }, /* 0010 00 */ + { 6, 0x3, 13 }, /* 0000 11 */ + { 6, 0x34, 14 }, /* 1101 00 */ + { 6, 0x35, 15 }, /* 1101 01 */ + { 6, 0x2A, 16 }, /* 1010 10 */ + { 6, 0x2B, 17 }, /* 1010 11 */ + { 7, 0x27, 18 }, /* 0100 111 */ + { 7, 0xC, 19 }, /* 0001 100 */ + { 7, 0x8, 20 }, /* 0001 000 */ + { 7, 0x17, 21 }, /* 0010 111 */ + { 7, 0x3, 22 }, /* 0000 011 */ + { 7, 0x4, 23 }, /* 0000 100 */ + { 7, 0x28, 24 }, /* 0101 000 */ + { 7, 0x2B, 25 }, /* 0101 011 */ + { 7, 0x13, 26 }, /* 0010 011 */ + { 7, 0x24, 27 }, /* 0100 100 */ + { 7, 0x18, 28 }, /* 0011 000 */ + { 8, 0x2, 29 }, /* 0000 0010 */ + { 8, 0x3, 30 }, /* 0000 0011 */ + { 8, 0x1A, 31 }, /* 0001 1010 */ + { 8, 0x1B, 32 }, /* 0001 1011 */ + { 8, 0x12, 33 }, /* 0001 0010 */ + { 8, 0x13, 34 }, /* 0001 0011 */ + { 8, 0x14, 35 }, /* 0001 0100 */ + { 8, 0x15, 36 }, /* 0001 0101 */ + { 8, 0x16, 37 }, /* 0001 0110 */ + { 8, 0x17, 38 }, /* 0001 0111 */ + { 8, 0x28, 39 }, /* 0010 1000 */ + { 8, 0x29, 40 }, /* 0010 1001 */ + { 8, 0x2A, 41 }, /* 0010 1010 */ + { 8, 0x2B, 42 }, /* 0010 1011 */ + { 8, 0x2C, 43 }, /* 0010 1100 */ + { 8, 0x2D, 44 }, /* 0010 1101 */ + { 8, 0x4, 45 }, /* 0000 0100 */ + { 8, 0x5, 46 }, /* 0000 0101 */ + { 8, 0xA, 47 }, /* 0000 1010 */ + { 8, 0xB, 48 }, /* 0000 1011 */ + { 8, 0x52, 49 }, /* 0101 0010 */ + { 8, 0x53, 50 }, /* 0101 0011 */ + { 8, 0x54, 51 }, /* 0101 0100 */ + { 8, 0x55, 52 }, /* 0101 0101 */ + { 8, 0x24, 53 }, /* 0010 0100 */ + { 8, 0x25, 54 }, /* 0010 0101 */ + { 8, 0x58, 55 }, /* 0101 1000 */ + { 8, 0x59, 56 }, /* 0101 1001 */ + { 8, 0x5A, 57 }, /* 0101 1010 */ + { 8, 0x5B, 58 }, /* 0101 1011 */ + { 8, 0x4A, 59 }, /* 0100 1010 */ + { 8, 0x4B, 60 }, /* 0100 1011 */ + { 8, 0x32, 61 }, /* 0011 0010 */ + { 8, 0x33, 62 }, /* 0011 0011 */ + { 8, 0x34, 63 }, /* 0011 0100 */ + { 5, 0x1B, 64 }, /* 1101 1 */ + { 5, 0x12, 128 }, /* 1001 0 */ + { 6, 0x17, 192 }, /* 0101 11 */ + { 7, 0x37, 256 }, /* 0110 111 */ + { 8, 0x36, 320 }, /* 0011 0110 */ + { 8, 0x37, 384 }, /* 0011 0111 */ + { 8, 0x64, 448 }, /* 0110 0100 */ + { 8, 0x65, 512 }, /* 0110 0101 */ + { 8, 0x68, 576 }, /* 0110 1000 */ + { 8, 0x67, 640 }, /* 0110 0111 */ + { 9, 0xCC, 704 }, /* 0110 0110 0 */ + { 9, 0xCD, 768 }, /* 0110 0110 1 */ + { 9, 0xD2, 832 }, /* 0110 1001 0 */ + { 9, 0xD3, 896 }, /* 0110 1001 1 */ + { 9, 0xD4, 960 }, /* 0110 1010 0 */ + { 9, 0xD5, 1024 }, /* 0110 1010 1 */ + { 9, 0xD6, 1088 }, /* 0110 1011 0 */ + { 9, 0xD7, 1152 }, /* 0110 1011 1 */ + { 9, 0xD8, 1216 }, /* 0110 1100 0 */ + { 9, 0xD9, 1280 }, /* 0110 1100 1 */ + { 9, 0xDA, 1344 }, /* 0110 1101 0 */ + { 9, 0xDB, 1408 }, /* 0110 1101 1 */ + { 9, 0x98, 1472 }, /* 0100 1100 0 */ + { 9, 0x99, 1536 }, /* 0100 1100 1 */ + { 9, 0x9A, 1600 }, /* 0100 1101 0 */ + { 6, 0x18, 1664 }, /* 0110 00 */ + { 9, 0x9B, 1728 }, /* 0100 1101 1 */ + { 11, 0x8, 1792 }, /* 0000 0001 000 */ + { 11, 0xC, 1856 }, /* 0000 0001 100 */ + { 11, 0xD, 1920 }, /* 0000 0001 101 */ + { 12, 0x12, 1984 }, /* 0000 0001 0010 */ + { 12, 0x13, 2048 }, /* 0000 0001 0011 */ + { 12, 0x14, 2112 }, /* 0000 0001 0100 */ + { 12, 0x15, 2176 }, /* 0000 0001 0101 */ + { 12, 0x16, 2240 }, /* 0000 0001 0110 */ + { 12, 0x17, 2304 }, /* 0000 0001 0111 */ + { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ + { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ + { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ + { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ + { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ + { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ + { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ + { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ + { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ +}; + +const tableentry TIFFFaxBlackCodes[] = { + { 10, 0x37, 0 }, /* 0000 1101 11 */ + { 3, 0x2, 1 }, /* 010 */ + { 2, 0x3, 2 }, /* 11 */ + { 2, 0x2, 3 }, /* 10 */ + { 3, 0x3, 4 }, /* 011 */ + { 4, 0x3, 5 }, /* 0011 */ + { 4, 0x2, 6 }, /* 0010 */ + { 5, 0x3, 7 }, /* 0001 1 */ + { 6, 0x5, 8 }, /* 0001 01 */ + { 6, 0x4, 9 }, /* 0001 00 */ + { 7, 0x4, 10 }, /* 0000 100 */ + { 7, 0x5, 11 }, /* 0000 101 */ + { 7, 0x7, 12 }, /* 0000 111 */ + { 8, 0x4, 13 }, /* 0000 0100 */ + { 8, 0x7, 14 }, /* 0000 0111 */ + { 9, 0x18, 15 }, /* 0000 1100 0 */ + { 10, 0x17, 16 }, /* 0000 0101 11 */ + { 10, 0x18, 17 }, /* 0000 0110 00 */ + { 10, 0x8, 18 }, /* 0000 0010 00 */ + { 11, 0x67, 19 }, /* 0000 1100 111 */ + { 11, 0x68, 20 }, /* 0000 1101 000 */ + { 11, 0x6C, 21 }, /* 0000 1101 100 */ + { 11, 0x37, 22 }, /* 0000 0110 111 */ + { 11, 0x28, 23 }, /* 0000 0101 000 */ + { 11, 0x17, 24 }, /* 0000 0010 111 */ + { 11, 0x18, 25 }, /* 0000 0011 000 */ + { 12, 0xCA, 26 }, /* 0000 1100 1010 */ + { 12, 0xCB, 27 }, /* 0000 1100 1011 */ + { 12, 0xCC, 28 }, /* 0000 1100 1100 */ + { 12, 0xCD, 29 }, /* 0000 1100 1101 */ + { 12, 0x68, 30 }, /* 0000 0110 1000 */ + { 12, 0x69, 31 }, /* 0000 0110 1001 */ + { 12, 0x6A, 32 }, /* 0000 0110 1010 */ + { 12, 0x6B, 33 }, /* 0000 0110 1011 */ + { 12, 0xD2, 34 }, /* 0000 1101 0010 */ + { 12, 0xD3, 35 }, /* 0000 1101 0011 */ + { 12, 0xD4, 36 }, /* 0000 1101 0100 */ + { 12, 0xD5, 37 }, /* 0000 1101 0101 */ + { 12, 0xD6, 38 }, /* 0000 1101 0110 */ + { 12, 0xD7, 39 }, /* 0000 1101 0111 */ + { 12, 0x6C, 40 }, /* 0000 0110 1100 */ + { 12, 0x6D, 41 }, /* 0000 0110 1101 */ + { 12, 0xDA, 42 }, /* 0000 1101 1010 */ + { 12, 0xDB, 43 }, /* 0000 1101 1011 */ + { 12, 0x54, 44 }, /* 0000 0101 0100 */ + { 12, 0x55, 45 }, /* 0000 0101 0101 */ + { 12, 0x56, 46 }, /* 0000 0101 0110 */ + { 12, 0x57, 47 }, /* 0000 0101 0111 */ + { 12, 0x64, 48 }, /* 0000 0110 0100 */ + { 12, 0x65, 49 }, /* 0000 0110 0101 */ + { 12, 0x52, 50 }, /* 0000 0101 0010 */ + { 12, 0x53, 51 }, /* 0000 0101 0011 */ + { 12, 0x24, 52 }, /* 0000 0010 0100 */ + { 12, 0x37, 53 }, /* 0000 0011 0111 */ + { 12, 0x38, 54 }, /* 0000 0011 1000 */ + { 12, 0x27, 55 }, /* 0000 0010 0111 */ + { 12, 0x28, 56 }, /* 0000 0010 1000 */ + { 12, 0x58, 57 }, /* 0000 0101 1000 */ + { 12, 0x59, 58 }, /* 0000 0101 1001 */ + { 12, 0x2B, 59 }, /* 0000 0010 1011 */ + { 12, 0x2C, 60 }, /* 0000 0010 1100 */ + { 12, 0x5A, 61 }, /* 0000 0101 1010 */ + { 12, 0x66, 62 }, /* 0000 0110 0110 */ + { 12, 0x67, 63 }, /* 0000 0110 0111 */ + { 10, 0xF, 64 }, /* 0000 0011 11 */ + { 12, 0xC8, 128 }, /* 0000 1100 1000 */ + { 12, 0xC9, 192 }, /* 0000 1100 1001 */ + { 12, 0x5B, 256 }, /* 0000 0101 1011 */ + { 12, 0x33, 320 }, /* 0000 0011 0011 */ + { 12, 0x34, 384 }, /* 0000 0011 0100 */ + { 12, 0x35, 448 }, /* 0000 0011 0101 */ + { 13, 0x6C, 512 }, /* 0000 0011 0110 0 */ + { 13, 0x6D, 576 }, /* 0000 0011 0110 1 */ + { 13, 0x4A, 640 }, /* 0000 0010 0101 0 */ + { 13, 0x4B, 704 }, /* 0000 0010 0101 1 */ + { 13, 0x4C, 768 }, /* 0000 0010 0110 0 */ + { 13, 0x4D, 832 }, /* 0000 0010 0110 1 */ + { 13, 0x72, 896 }, /* 0000 0011 1001 0 */ + { 13, 0x73, 960 }, /* 0000 0011 1001 1 */ + { 13, 0x74, 1024 }, /* 0000 0011 1010 0 */ + { 13, 0x75, 1088 }, /* 0000 0011 1010 1 */ + { 13, 0x76, 1152 }, /* 0000 0011 1011 0 */ + { 13, 0x77, 1216 }, /* 0000 0011 1011 1 */ + { 13, 0x52, 1280 }, /* 0000 0010 1001 0 */ + { 13, 0x53, 1344 }, /* 0000 0010 1001 1 */ + { 13, 0x54, 1408 }, /* 0000 0010 1010 0 */ + { 13, 0x55, 1472 }, /* 0000 0010 1010 1 */ + { 13, 0x5A, 1536 }, /* 0000 0010 1101 0 */ + { 13, 0x5B, 1600 }, /* 0000 0010 1101 1 */ + { 13, 0x64, 1664 }, /* 0000 0011 0010 0 */ + { 13, 0x65, 1728 }, /* 0000 0011 0010 1 */ + { 11, 0x8, 1792 }, /* 0000 0001 000 */ + { 11, 0xC, 1856 }, /* 0000 0001 100 */ + { 11, 0xD, 1920 }, /* 0000 0001 101 */ + { 12, 0x12, 1984 }, /* 0000 0001 0010 */ + { 12, 0x13, 2048 }, /* 0000 0001 0011 */ + { 12, 0x14, 2112 }, /* 0000 0001 0100 */ + { 12, 0x15, 2176 }, /* 0000 0001 0101 */ + { 12, 0x16, 2240 }, /* 0000 0001 0110 */ + { 12, 0x17, 2304 }, /* 0000 0001 0111 */ + { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ + { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ + { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ + { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ + { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ + { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ + { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ + { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ + { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ +}; +#else +extern const tableentry TIFFFaxWhiteCodes[]; +extern const tableentry TIFFFaxBlackCodes[]; +#endif +#endif /* _T4_ */ diff --git a/src/libs/pdflib/libs/tiff/tif_auxx.c b/src/libs/pdflib/libs/tiff/tif_auxx.c new file mode 100644 index 0000000000..171cd0cdbc --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_auxx.c @@ -0,0 +1,206 @@ +/* PDFlib GmbH cvsid: $Id: tif_auxx.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1991-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Auxiliary Support Routines. + */ +#include "tiffiop.h" + +#ifdef COLORIMETRY_SUPPORT +#include + +static void +TIFFDefaultTransferFunction(TIFF* tif, TIFFDirectory* td) +{ + uint16 **tf = td->td_transferfunction; + long i, n = 1<td_bitspersample; + + tf[0] = (uint16 *)_TIFFmalloc(tif, n * sizeof (uint16)); + tf[0][0] = 0; + for (i = 1; i < n; i++) { + double t = (double)i/((double) n-1.); + tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5); + } + if (td->td_samplesperpixel - td->td_extrasamples > 1) { + tf[1] = (uint16 *)_TIFFmalloc(tif, n * sizeof (uint16)); + _TIFFmemcpy(tf[1], tf[0], n * sizeof (uint16)); + tf[2] = (uint16 *)_TIFFmalloc(tif, n * sizeof (uint16)); + _TIFFmemcpy(tf[2], tf[0], n * sizeof (uint16)); + } +} + +static void +TIFFDefaultRefBlackWhite(TIFF* tif, TIFFDirectory* td) +{ + int i; + + td->td_refblackwhite = (float *)_TIFFmalloc(tif, 6*sizeof (float)); + for (i = 0; i < 3; i++) { + td->td_refblackwhite[2*i+0] = 0; + td->td_refblackwhite[2*i+1] =(float)((1L<td_bitspersample)-1L); + } +} +#endif + +/* + * Like TIFFGetField, but return any default + * value if the tag is not present in the directory. + * + * NB: We use the value in the directory, rather than + * explcit values so that defaults exist only one + * place in the library -- in TIFFDefaultDirectory. + */ +int +TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (TIFFVGetField(tif, tag, ap)) + return (1); + switch (tag) { + case TIFFTAG_SUBFILETYPE: + *va_arg(ap, uint32 *) = td->td_subfiletype; + return (1); + case TIFFTAG_BITSPERSAMPLE: + *va_arg(ap, uint16 *) = td->td_bitspersample; + return (1); + case TIFFTAG_THRESHHOLDING: + *va_arg(ap, uint16 *) = td->td_threshholding; + return (1); + case TIFFTAG_FILLORDER: + *va_arg(ap, uint16 *) = td->td_fillorder; + return (1); + case TIFFTAG_ORIENTATION: + *va_arg(ap, uint16 *) = td->td_orientation; + return (1); + case TIFFTAG_SAMPLESPERPIXEL: + *va_arg(ap, uint16 *) = td->td_samplesperpixel; + return (1); + case TIFFTAG_ROWSPERSTRIP: + *va_arg(ap, uint32 *) = td->td_rowsperstrip; + return (1); + case TIFFTAG_MINSAMPLEVALUE: + *va_arg(ap, uint16 *) = td->td_minsamplevalue; + return (1); + case TIFFTAG_MAXSAMPLEVALUE: + *va_arg(ap, uint16 *) = td->td_maxsamplevalue; + return (1); + case TIFFTAG_PLANARCONFIG: + *va_arg(ap, uint16 *) = td->td_planarconfig; + return (1); + case TIFFTAG_RESOLUTIONUNIT: + *va_arg(ap, uint16 *) = td->td_resolutionunit; + return (1); +#ifdef CMYK_SUPPORT + case TIFFTAG_DOTRANGE: + *va_arg(ap, uint16 *) = 0; + *va_arg(ap, uint16 *) = (1<td_bitspersample)-1; + return (1); + case TIFFTAG_INKSET: + *va_arg(ap, uint16 *) = td->td_inkset; + return (1); + case TIFFTAG_NUMBEROFINKS: + *va_arg(ap, uint16 *) = td->td_ninks; + return (1); +#endif + case TIFFTAG_EXTRASAMPLES: + *va_arg(ap, uint16 *) = td->td_extrasamples; + *va_arg(ap, uint16 **) = td->td_sampleinfo; + return (1); + case TIFFTAG_MATTEING: + *va_arg(ap, uint16 *) = + (td->td_extrasamples == 1 && + td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); + return (1); + case TIFFTAG_TILEDEPTH: + *va_arg(ap, uint32 *) = td->td_tiledepth; + return (1); + case TIFFTAG_DATATYPE: + *va_arg(ap, uint16 *) = td->td_sampleformat-1; + return (1); + case TIFFTAG_SAMPLEFORMAT: + *va_arg(ap, uint16 *) = td->td_sampleformat; + return(1); + case TIFFTAG_IMAGEDEPTH: + *va_arg(ap, uint32 *) = td->td_imagedepth; + return (1); +#ifdef YCBCR_SUPPORT + case TIFFTAG_YCBCRCOEFFICIENTS: + if (!td->td_ycbcrcoeffs) { + td->td_ycbcrcoeffs = (float *) + _TIFFmalloc(tif, 3*sizeof (float)); + /* defaults are from CCIR Recommendation 601-1 */ + td->td_ycbcrcoeffs[0] = 0.299f; + td->td_ycbcrcoeffs[1] = 0.587f; + td->td_ycbcrcoeffs[2] = 0.114f; + } + *va_arg(ap, float **) = td->td_ycbcrcoeffs; + return (1); + case TIFFTAG_YCBCRSUBSAMPLING: + *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1]; + return (1); + case TIFFTAG_YCBCRPOSITIONING: + *va_arg(ap, uint16 *) = td->td_ycbcrpositioning; + return (1); +#endif +#ifdef COLORIMETRY_SUPPORT + case TIFFTAG_TRANSFERFUNCTION: + if (!td->td_transferfunction[0]) + TIFFDefaultTransferFunction(tif, td); + *va_arg(ap, uint16 **) = td->td_transferfunction[0]; + if (td->td_samplesperpixel - td->td_extrasamples > 1) { + *va_arg(ap, uint16 **) = td->td_transferfunction[1]; + *va_arg(ap, uint16 **) = td->td_transferfunction[2]; + } + return (1); + case TIFFTAG_REFERENCEBLACKWHITE: + if (!td->td_refblackwhite) + TIFFDefaultRefBlackWhite(tif, td); + *va_arg(ap, float **) = td->td_refblackwhite; + return (1); +#endif + } + return (0); +} + +/* + * Like TIFFGetField, but return any default + * value if the tag is not present in the directory. + */ +int +TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) +{ + int ok; + va_list ap; + + va_start(ap, tag); + ok = TIFFVGetFieldDefaulted(tif, tag, ap); + va_end(ap); + return (ok); +} diff --git a/src/libs/pdflib/libs/tiff/tif_close.c b/src/libs/pdflib/libs/tiff/tif_close.c new file mode 100644 index 0000000000..f99b5d0b70 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_close.c @@ -0,0 +1,53 @@ +/* PDFlib GmbH cvsid: $Id: tif_close.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + */ +#include "tiffiop.h" + +void +TIFFClose(TIFF* tif) +{ +#ifdef PDFLIB_TIFFWRITE_SUPPORT + if (tif->tif_mode != O_RDONLY) + /* + * Flush buffered data and directory (if dirty). + */ + TIFFFlush(tif); +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + + (*tif->tif_cleanup)(tif); + TIFFFreeDirectory(tif); + if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) + _TIFFfree(tif, tif->tif_rawdata); + if (isMapped(tif)) + TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size); + (void) TIFFCloseFile(tif); + if (tif->tif_fieldinfo) + _TIFFfree(tif, tif->tif_fieldinfo); + _TIFFfree(tif, tif); +} diff --git a/src/libs/pdflib/libs/tiff/tif_codec.c b/src/libs/pdflib/libs/tiff/tif_codec.c new file mode 100644 index 0000000000..116affe421 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_codec.c @@ -0,0 +1,119 @@ +/* PDFlib GmbH cvsid: $Id: tif_codec.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * Builtin Compression Scheme Configuration Support. + */ +#include "tiffiop.h" + +static int NotConfigured(TIFF*, int); + +#ifndef LZW_SUPPORT +#define TIFFInitLZW NotConfigured +#endif +#ifndef PACKBITS_SUPPORT +#define TIFFInitPackbits NotConfigured +#endif +#ifndef THUNDER_SUPPORT +#define TIFFInitThunderScan NotConfigured +#endif +#ifndef NEXT_SUPPORT +#define TIFFInitNeXT NotConfigured +#endif +#ifndef JPEG_SUPPORT +#define TIFFInitJPEG NotConfigured +#endif +#ifndef OJPEG_SUPPORT +#define TIFFInitOJPEG NotConfigured +#endif +#ifndef CCITT_SUPPORT +#define TIFFInitCCITTRLE NotConfigured +#define TIFFInitCCITTRLEW NotConfigured +#define TIFFInitCCITTFax3 NotConfigured +#define TIFFInitCCITTFax4 NotConfigured +#endif +#ifndef JBIG_SUPPORT +#define TIFFInitJBIG NotConfigured +#endif +#ifndef ZIP_SUPPORT +#define TIFFInitZIP NotConfigured +#endif +#ifndef PIXARLOG_SUPPORT +#define TIFFInitPixarLog NotConfigured +#endif +#ifndef LOGLUV_SUPPORT +#define TIFFInitSGILog NotConfigured +#endif + +/* + * Compression schemes statically built into the library. + */ +#ifdef VMS +const TIFFCodec _TIFFBuiltinCODECS[] = { +#else +TIFFCodec _TIFFBuiltinCODECS[] = { +#endif + { "None", COMPRESSION_NONE, TIFFInitDumpMode }, + { "LZW", COMPRESSION_LZW, TIFFInitLZW }, + { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, + { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, + { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, + { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, + { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG }, + { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, + { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, + { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, + { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, + { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, + { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, + { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP }, + { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, + { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, + { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, + { NULL } +}; + +static int +_notConfigured(TIFF* tif) +{ + const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); + + TIFFError(tif->tif_name, + "%s compression support is not configured", c->name); + return (0); +} + +static int +NotConfigured(TIFF* tif, int scheme) +{ + (void) scheme; + + tif->tif_setupdecode = _notConfigured; + tif->tif_setupencode = _notConfigured; + return (1); +} diff --git a/src/libs/pdflib/libs/tiff/tif_compress.c b/src/libs/pdflib/libs/tiff/tif_compress.c new file mode 100644 index 0000000000..313a6c97d1 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_compress.c @@ -0,0 +1,235 @@ +/* PDFlib GmbH cvsid: $Id: tif_compress.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * Compression Scheme Configuration Support. + */ +#include "tiffiop.h" + +static int +TIFFNoEncode(TIFF* tif, char* method) +{ + const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); + + if (c) { + if (! strncmp(c->name, "LZW", 3) ){ + TIFFError(tif->tif_name, +"%s %s encoding is no longer implemented due to Unisys patent enforcement", + c->name, method); + } else { + TIFFError(tif->tif_name, "%s %s encoding is not implemented", + c->name, method); + } + } + else { + TIFFError(tif->tif_name, + "Compression scheme %u %s encoding is not implemented", + tif->tif_dir.td_compression, method); + } + return (-1); +} + +int +_TIFFNoRowEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +{ + (void) pp; (void) cc; (void) s; + return (TIFFNoEncode(tif, "scanline")); +} + +int +_TIFFNoStripEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +{ + (void) pp; (void) cc; (void) s; + return (TIFFNoEncode(tif, "strip")); +} + +int +_TIFFNoTileEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +{ + (void) pp; (void) cc; (void) s; + return (TIFFNoEncode(tif, "tile")); +} + +static int +TIFFNoDecode(TIFF* tif, char* method) +{ + const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); + + if (c) + TIFFError(tif->tif_name, "%s %s decoding is not implemented", + c->name, method); + else + TIFFError(tif->tif_name, + "Compression scheme %u %s decoding is not implemented", + tif->tif_dir.td_compression, method); + return (-1); +} + +int +_TIFFNoRowDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +{ + (void) pp; (void) cc; (void) s; + return (TIFFNoDecode(tif, "scanline")); +} + +int +_TIFFNoStripDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +{ + (void) pp; (void) cc; (void) s; + return (TIFFNoDecode(tif, "strip")); +} + +int +_TIFFNoTileDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +{ + (void) pp; (void) cc; (void) s; + return (TIFFNoDecode(tif, "tile")); +} + +int +_TIFFNoSeek(TIFF* tif, uint32 off) +{ + (void) off; + TIFFError(tif->tif_name, + "Compression algorithm does not support random access"); + return (0); +} + +int +_TIFFNoPreCode(TIFF* tif, tsample_t s) +{ + (void) tif; (void) s; + return (1); +} + +static int _TIFFtrue(TIFF* tif) { (void) tif; return (1); } +static void _TIFFvoid(TIFF* tif) { (void) tif; } + +void +_TIFFSetDefaultCompressionState(TIFF* tif) +{ + tif->tif_setupdecode = _TIFFtrue; + tif->tif_predecode = _TIFFNoPreCode; + tif->tif_decoderow = _TIFFNoRowDecode; + tif->tif_decodestrip = _TIFFNoStripDecode; + tif->tif_decodetile = _TIFFNoTileDecode; + tif->tif_setupencode = _TIFFtrue; + tif->tif_preencode = _TIFFNoPreCode; + tif->tif_postencode = _TIFFtrue; + tif->tif_encoderow = _TIFFNoRowEncode; + tif->tif_encodestrip = _TIFFNoStripEncode; + tif->tif_encodetile = _TIFFNoTileEncode; + tif->tif_close = _TIFFvoid; + tif->tif_seek = _TIFFNoSeek; + tif->tif_cleanup = _TIFFvoid; + tif->tif_defstripsize = _TIFFDefaultStripSize; + tif->tif_deftilesize = _TIFFDefaultTileSize; + tif->tif_flags &= ~TIFF_NOBITREV; +} + +int +TIFFSetCompressionScheme(TIFF* tif, int scheme) +{ + const TIFFCodec *c = TIFFFindCODEC((uint16) scheme); + + _TIFFSetDefaultCompressionState(tif); + /* + * Don't treat an unknown compression scheme as an error. + * This permits applications to open files with data that + * the library does not have builtin support for, but which + * may still be meaningful. + */ + return (c ? (*c->init)(tif, scheme) : 1); +} + +/* + * Other compression schemes may be registered. Registered + * schemes can also override the builtin versions provided + * by this library. + */ +typedef struct _codec { + struct _codec* next; + TIFFCodec* info; +} codec_t; +static codec_t* registeredCODECS = NULL; + +const TIFFCodec* +TIFFFindCODEC(uint16 scheme) +{ + const TIFFCodec* c; + codec_t* cd; + + for (cd = registeredCODECS; cd; cd = cd->next) + if (cd->info->scheme == scheme) + return ((const TIFFCodec*) cd->info); + for (c = _TIFFBuiltinCODECS; c->name; c++) + if (c->scheme == scheme) + return (c); + return ((const TIFFCodec*) 0); +} + +#ifdef PDF_used +TIFFCodec* +TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) +{ + codec_t* cd = (codec_t*) + _TIFFmalloc(tif, sizeof(codec_t)+ sizeof(TIFFCodec)+strlen(name)+1); + + if (cd != NULL) { + cd->info = (TIFFCodec*) ((tidata_t) cd + sizeof (codec_t)); + cd->info->name = (char*) + ((tidata_t) cd->info + sizeof (TIFFCodec)); + strcpy(cd->info->name, name); + cd->info->scheme = scheme; + cd->info->init = init; + cd->next = registeredCODECS; + registeredCODECS = cd; + } else + TIFFError("TIFFRegisterCODEC", + "No space to register compression scheme %s", name); + return (cd->info); +} +#endif + +#ifdef PDF_used +void +TIFFUnRegisterCODEC(TIFFCodec* c) +{ + codec_t* cd; + codec_t** pcd; + + for (pcd = ®isteredCODECS; (cd = *pcd); pcd = &cd->next) + if (cd->info == c) { + *pcd = cd->next; + _TIFFfree(tif, cd); + return; + } + TIFFError("TIFFUnRegisterCODEC", + "Cannot remove compression scheme %s; not registered", c->name); +} +#endif diff --git a/src/libs/pdflib/libs/tiff/tif_dir.c b/src/libs/pdflib/libs/tiff/tif_dir.c new file mode 100644 index 0000000000..cb51c37bb7 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_dir.c @@ -0,0 +1,1318 @@ +/* PDFlib GmbH cvsid: $Id: tif_dir.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Directory Tag Get & Set Routines. + * (and also some miscellaneous stuff) + */ +#include "tiffiop.h" + +/* + * These are used in the backwards compatibility code... + */ +#define DATATYPE_VOID 0 /* !untyped data */ +#define DATATYPE_INT 1 /* !signed integer data */ +#define DATATYPE_UINT 2 /* !unsigned integer data */ +#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ + +void _TIFFsetNString(TIFF* tif, char** cpp, char* cp, long n); + +void +_TIFFsetByteArray(TIFF* tif, void** vpp, void* vp, long n) +{ + if (*vpp) + _TIFFfree(tif, *vpp), *vpp = 0; + if (vp && (*vpp = (void*) _TIFFmalloc(tif, n))) + _TIFFmemcpy(*vpp, vp, n); +} +void _TIFFsetString(TIFF* tif, char** cpp, char* cp) + { _TIFFsetByteArray(tif, (void**) cpp, (void*) cp, (long) (strlen(cp)+1)); } +void _TIFFsetNString(TIFF* tif, char** cpp, char* cp, long n) + { _TIFFsetByteArray(tif, (void**) cpp, (void*) cp, n); } +void _TIFFsetShortArray(TIFF* tif, uint16** wpp, uint16* wp, long n) + { _TIFFsetByteArray(tif, (void**) wpp, (void*) wp, n*sizeof (uint16)); } +void _TIFFsetLongArray(TIFF* tif, uint32** lpp, uint32* lp, long n) + { _TIFFsetByteArray(tif, (void**) lpp, (void*) lp, n*sizeof (uint32)); } +void _TIFFsetFloatArray(TIFF* tif, float** fpp, float* fp, long n) + { _TIFFsetByteArray(tif, (void**) fpp, (void*) fp, n*sizeof (float)); } +void _TIFFsetDoubleArray(TIFF* tif, double** dpp, double* dp, long n) + { _TIFFsetByteArray(tif, (void**) dpp, (void*) dp, n*sizeof (double)); } + +/* + * Install extra samples information. + */ +static int +setExtraSamples(TIFF* tif, TIFFDirectory* td, va_list ap, int* v) +{ + uint16* va; + int i; + + *v = va_arg(ap, int); + if ((uint16) *v > td->td_samplesperpixel) + return (0); + va = va_arg(ap, uint16*); + if (*v > 0 && va == NULL) /* typically missing param */ + return (0); + for (i = 0; i < *v; i++) + if (va[i] > EXTRASAMPLE_UNASSALPHA) + return (0); + td->td_extrasamples = (uint16) *v; + _TIFFsetShortArray(tif, &td->td_sampleinfo, va, td->td_extrasamples); + return (1); +} + +#ifdef CMYK_SUPPORT +static int +checkInkNamesString(TIFF* tif, int slen, const char* s) +{ + TIFFDirectory* td = &tif->tif_dir; + int i = td->td_samplesperpixel; + + if (slen > 0) { + const char* ep = s+slen; + const char* cp = s; + for (; i > 0; i--) { + for (; *cp != '\0'; cp++) + if (cp >= ep) + goto bad; + cp++; /* skip \0 */ + } + return (cp-s); + } +bad: + TIFFError("TIFFSetField", + "%s: Invalid InkNames value; expecting %d names, found %d", + tif->tif_name, + td->td_samplesperpixel, + td->td_samplesperpixel-i); + return (0); +} +#endif + +static int +_TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) +{ + TIFFDirectory* td = &tif->tif_dir; + int status = 1; + uint32 v32; + int i, v; + double d; + char* s; + + switch (tag) { + case TIFFTAG_SUBFILETYPE: + td->td_subfiletype = va_arg(ap, uint32); + break; + case TIFFTAG_IMAGEWIDTH: + td->td_imagewidth = va_arg(ap, uint32); + break; + case TIFFTAG_IMAGELENGTH: + td->td_imagelength = va_arg(ap, uint32); + break; + case TIFFTAG_BITSPERSAMPLE: + td->td_bitspersample = (uint16) va_arg(ap, int); + /* + * If the data require post-decoding processing + * to byte-swap samples, set it up here. Note + * that since tags are required to be ordered, + * compression code can override this behaviour + * in the setup method if it wants to roll the + * post decoding work in with its normal work. + */ + if (tif->tif_flags & TIFF_SWAB) { + if (td->td_bitspersample == 16) + tif->tif_postdecode = _TIFFSwab16BitData; + else if (td->td_bitspersample == 32) + tif->tif_postdecode = _TIFFSwab32BitData; + else if (td->td_bitspersample == 64) + tif->tif_postdecode = _TIFFSwab64BitData; + } + break; + case TIFFTAG_COMPRESSION: + v = va_arg(ap, int) & 0xffff; + /* + * If we're changing the compression scheme, + * the notify the previous module so that it + * can cleanup any state it's setup. + */ + if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { + if (td->td_compression == v) + break; + (*tif->tif_cleanup)(tif); + tif->tif_flags &= ~TIFF_CODERSETUP; + } + /* + * Setup new compression routine state. + */ + if( (status = TIFFSetCompressionScheme(tif, v)) != 0 ) + td->td_compression = v; + else + status = 0; + break; + case TIFFTAG_PHOTOMETRIC: + td->td_photometric = (uint16) va_arg(ap, int); + break; + case TIFFTAG_THRESHHOLDING: + td->td_threshholding = (uint16) va_arg(ap, int); + break; + case TIFFTAG_FILLORDER: + v = va_arg(ap, int); + if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) + goto badvalue; + td->td_fillorder = (uint16) v; + break; + case TIFFTAG_DOCUMENTNAME: + _TIFFsetString(tif, &td->td_documentname, va_arg(ap, char*)); + break; + case TIFFTAG_ARTIST: + _TIFFsetString(tif, &td->td_artist, va_arg(ap, char*)); + break; + case TIFFTAG_DATETIME: + _TIFFsetString(tif, &td->td_datetime, va_arg(ap, char*)); + break; + case TIFFTAG_HOSTCOMPUTER: + _TIFFsetString(tif, &td->td_hostcomputer, va_arg(ap, char*)); + break; + case TIFFTAG_IMAGEDESCRIPTION: + _TIFFsetString(tif, &td->td_imagedescription,va_arg(ap, char*)); + break; + case TIFFTAG_MAKE: + _TIFFsetString(tif, &td->td_make, va_arg(ap, char*)); + break; + case TIFFTAG_MODEL: + _TIFFsetString(tif, &td->td_model, va_arg(ap, char*)); + break; + case TIFFTAG_SOFTWARE: + _TIFFsetString(tif, &td->td_software, va_arg(ap, char*)); + break; + case TIFFTAG_COPYRIGHT: + _TIFFsetString(tif, &td->td_copyright, va_arg(ap, char*)); + break; + case TIFFTAG_ORIENTATION: + v = va_arg(ap, int); + if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) { + TIFFWarning(tif->tif_name, + "Bad value %ld for \"%s\" tag ignored", + v, _TIFFFieldWithTag(tif, tag)->field_name); + } else + td->td_orientation = (uint16) v; + break; + case TIFFTAG_SAMPLESPERPIXEL: + /* XXX should cross check -- e.g. if pallette, then 1 */ + v = va_arg(ap, int); + if (v == 0) + goto badvalue; + td->td_samplesperpixel = (uint16) v; + break; + case TIFFTAG_ROWSPERSTRIP: + v32 = va_arg(ap, uint32); + if (v32 == 0) + goto badvalue32; + td->td_rowsperstrip = v32; + if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { + td->td_tilelength = v32; + td->td_tilewidth = td->td_imagewidth; + } + break; + case TIFFTAG_MINSAMPLEVALUE: + td->td_minsamplevalue = (uint16) va_arg(ap, int); + break; + case TIFFTAG_MAXSAMPLEVALUE: + td->td_maxsamplevalue = (uint16) va_arg(ap, int); + break; + case TIFFTAG_SMINSAMPLEVALUE: + td->td_sminsamplevalue = (double) va_arg(ap, dblparam_t); + break; + case TIFFTAG_SMAXSAMPLEVALUE: + td->td_smaxsamplevalue = (double) va_arg(ap, dblparam_t); + break; + case TIFFTAG_XRESOLUTION: + td->td_xresolution = (float) va_arg(ap, dblparam_t); + break; + case TIFFTAG_YRESOLUTION: + td->td_yresolution = (float) va_arg(ap, dblparam_t); + break; + case TIFFTAG_PLANARCONFIG: + v = va_arg(ap, int); + if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) + goto badvalue; + td->td_planarconfig = (uint16) v; + break; + case TIFFTAG_PAGENAME: + _TIFFsetString(tif, &td->td_pagename, va_arg(ap, char*)); + break; + case TIFFTAG_XPOSITION: + td->td_xposition = (float) va_arg(ap, dblparam_t); + break; + case TIFFTAG_YPOSITION: + td->td_yposition = (float) va_arg(ap, dblparam_t); + break; + case TIFFTAG_RESOLUTIONUNIT: + v = va_arg(ap, int); + if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) + goto badvalue; + td->td_resolutionunit = (uint16) v; + break; + case TIFFTAG_PAGENUMBER: + td->td_pagenumber[0] = (uint16) va_arg(ap, int); + td->td_pagenumber[1] = (uint16) va_arg(ap, int); + break; + case TIFFTAG_HALFTONEHINTS: + td->td_halftonehints[0] = (uint16) va_arg(ap, int); + td->td_halftonehints[1] = (uint16) va_arg(ap, int); + break; + case TIFFTAG_COLORMAP: + v32 = (uint32)(1L<td_bitspersample); + _TIFFsetShortArray(tif, &td->td_colormap[0], + va_arg(ap, uint16*),v32); + _TIFFsetShortArray(tif, &td->td_colormap[1], + va_arg(ap, uint16*),v32); + _TIFFsetShortArray(tif, &td->td_colormap[2], + va_arg(ap, uint16*),v32); + break; + case TIFFTAG_EXTRASAMPLES: + if (!setExtraSamples(tif, td, ap, &v)) + goto badvalue; + break; + case TIFFTAG_MATTEING: + td->td_extrasamples = (uint16) (va_arg(ap, int) != 0); + if (td->td_extrasamples) { + uint16 sv = EXTRASAMPLE_ASSOCALPHA; + _TIFFsetShortArray(tif, &td->td_sampleinfo, &sv, 1); + } + break; + case TIFFTAG_TILEWIDTH: + v32 = va_arg(ap, uint32); + if (v32 % 16) { + if (tif->tif_mode != O_RDONLY) + goto badvalue32; + TIFFWarning(tif->tif_name, + "Nonstandard tile width %d, convert file", v32); + } + td->td_tilewidth = v32; + tif->tif_flags |= TIFF_ISTILED; + break; + case TIFFTAG_TILELENGTH: + v32 = va_arg(ap, uint32); + if (v32 % 16) { + if (tif->tif_mode != O_RDONLY) + goto badvalue32; + TIFFWarning(tif->tif_name, + "Nonstandard tile length %d, convert file", v32); + } + td->td_tilelength = v32; + tif->tif_flags |= TIFF_ISTILED; + break; + case TIFFTAG_TILEDEPTH: + v32 = va_arg(ap, uint32); + if (v32 == 0) + goto badvalue32; + td->td_tiledepth = v32; + break; + case TIFFTAG_DATATYPE: + v = va_arg(ap, int); + switch (v) { + case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; + case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; + case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break; + case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; + default: goto badvalue; + } + td->td_sampleformat = (uint16) v; + break; + case TIFFTAG_SAMPLEFORMAT: + v = va_arg(ap, int); + if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) + goto badvalue; + td->td_sampleformat = (uint16) v; + break; + case TIFFTAG_IMAGEDEPTH: + td->td_imagedepth = va_arg(ap, uint32); + break; + case TIFFTAG_STONITS: + d = va_arg(ap, dblparam_t); + if (d <= 0.) + goto badvaluedbl; + td->td_stonits = d; + break; + + /* Begin Pixar Tags */ + case TIFFTAG_PIXAR_IMAGEFULLWIDTH: + td->td_imagefullwidth = va_arg(ap, uint32); + break; + case TIFFTAG_PIXAR_IMAGEFULLLENGTH: + td->td_imagefulllength = va_arg(ap, uint32); + break; + case TIFFTAG_PIXAR_TEXTUREFORMAT: + _TIFFsetString(tif, &td->td_textureformat, va_arg(ap, char*)); + break; + case TIFFTAG_PIXAR_WRAPMODES: + _TIFFsetString(tif, &td->td_wrapmodes, va_arg(ap, char*)); + break; + case TIFFTAG_PIXAR_FOVCOT: + td->td_fovcot = (float) va_arg(ap, dblparam_t); + break; + case TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN: + _TIFFsetFloatArray(tif, &td->td_matrixWorldToScreen, + va_arg(ap, float*), 16); + break; + case TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA: + _TIFFsetFloatArray(tif, &td->td_matrixWorldToCamera, + va_arg(ap, float*), 16); + break; + /* End Pixar Tags */ + +#if SUBIFD_SUPPORT + case TIFFTAG_SUBIFD: + if ((tif->tif_flags & TIFF_INSUBIFD) == 0) { + td->td_nsubifd = (uint16) va_arg(ap, int); + _TIFFsetLongArray(tif,&td->td_subifd,va_arg(ap,uint32*), + (long) td->td_nsubifd); + } else { + TIFFError(tif->tif_name, "Sorry, cannot nest SubIFDs"); + status = 0; + } + break; +#endif +#ifdef YCBCR_SUPPORT + case TIFFTAG_YCBCRCOEFFICIENTS: + _TIFFsetFloatArray(tif,&td->td_ycbcrcoeffs,va_arg(ap,float*),3); + break; + case TIFFTAG_YCBCRPOSITIONING: + td->td_ycbcrpositioning = (uint16) va_arg(ap, int); + break; + case TIFFTAG_YCBCRSUBSAMPLING: + td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, int); + td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, int); + break; +#endif +#ifdef COLORIMETRY_SUPPORT + case TIFFTAG_WHITEPOINT: + _TIFFsetFloatArray(tif,&td->td_whitepoint,va_arg(ap,float*),2); + break; + case TIFFTAG_PRIMARYCHROMATICITIES: + _TIFFsetFloatArray(tif,&td->td_primarychromas, + va_arg(ap,float*),6); + break; + case TIFFTAG_TRANSFERFUNCTION: + v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; + for (i = 0; i < v; i++) + _TIFFsetShortArray(tif, &td->td_transferfunction[i], + va_arg(ap, uint16*), 1L<td_bitspersample); + break; + case TIFFTAG_REFERENCEBLACKWHITE: + /* XXX should check for null range */ + _TIFFsetFloatArray(tif, &td->td_refblackwhite, + va_arg(ap, float*),6); + break; +#endif +#ifdef CMYK_SUPPORT + case TIFFTAG_INKSET: + td->td_inkset = (uint16) va_arg(ap, int); + break; + case TIFFTAG_DOTRANGE: + /* XXX should check for null range */ + td->td_dotrange[0] = (uint16) va_arg(ap, int); + td->td_dotrange[1] = (uint16) va_arg(ap, int); + break; + case TIFFTAG_INKNAMES: + i = va_arg(ap, int); + s = va_arg(ap, char*); + i = checkInkNamesString(tif, i, s); + status = i > 0; + if( i > 0 ) { + _TIFFsetNString(tif, &td->td_inknames, s, i); + td->td_inknameslen = i; + } + break; + case TIFFTAG_NUMBEROFINKS: + td->td_ninks = (uint16) va_arg(ap, int); + break; + case TIFFTAG_TARGETPRINTER: + _TIFFsetString(tif, &td->td_targetprinter, va_arg(ap, char*)); + break; +#endif +#ifdef ICC_SUPPORT + case TIFFTAG_ICCPROFILE: + td->td_profileLength = (uint32) va_arg(ap, uint32); + _TIFFsetByteArray(tif, &td->td_profileData, va_arg(ap, void*), + td->td_profileLength); + break; +#endif +#ifdef PHOTOSHOP_SUPPORT + case TIFFTAG_PHOTOSHOP: + td->td_photoshopLength = (uint32) va_arg(ap, uint32); + _TIFFsetByteArray(tif, &td->td_photoshopData, va_arg(ap, void*), + td->td_photoshopLength); + break; +#endif +#ifdef IPTC_SUPPORT + case TIFFTAG_RICHTIFFIPTC: + td->td_richtiffiptcLength = (uint32) va_arg(ap, uint32); +#ifdef PHOTOSHOP_SUPPORT + _TIFFsetLongArray (tif, (uint32**)&td->td_richtiffiptcData, + va_arg(ap, uint32*), + td->td_richtiffiptcLength); +#else + _TIFFsetByteArray(tif, &td->td_photoshopData, va_arg(ap, void*), + td->td_photoshopLength); +#endif + break; +#endif + default: + /* + * This can happen if multiple images are open with + * different codecs which have private tags. The + * global tag information table may then have tags + * that are valid for one file but not the other. + * If the client tries to set a tag that is not valid + * for the image's codec then we'll arrive here. This + * happens, for example, when tiffcp is used to convert + * between compression schemes and codec-specific tags + * are blindly copied. + */ + TIFFError("TIFFSetField", + "%s: Invalid %stag \"%s\" (not supported by codec)", + tif->tif_name, isPseudoTag(tag) ? "pseduo-" : "", + _TIFFFieldWithTag(tif, tag)->field_name); + status = 0; + break; + } + if (status) { + TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); + tif->tif_flags |= TIFF_DIRTYDIRECT; + } + va_end(ap); + return (status); +badvalue: + TIFFError(tif->tif_name, "%d: Bad value for \"%s\"", v, + _TIFFFieldWithTag(tif, tag)->field_name); + va_end(ap); + return (0); +badvalue32: + TIFFError(tif->tif_name, "%ld: Bad value for \"%s\"", v32, + _TIFFFieldWithTag(tif, tag)->field_name); + va_end(ap); + return (0); +badvaluedbl: + TIFFError(tif->tif_name, "%f: Bad value for \"%s\"", d, + _TIFFFieldWithTag(tif, tag)->field_name); + va_end(ap); + return (0); +} + +/* + * Return 1/0 according to whether or not + * it is permissible to set the tag's value. + * Note that we allow ImageLength to be changed + * so that we can append and extend to images. + * Any other tag may not be altered once writing + * has commenced, unless its value has no effect + * on the format of the data that is written. + */ +static int +OkToChangeTag(TIFF* tif, ttag_t tag) +{ + const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); + if (!fip) { /* unknown tag */ + TIFFError("TIFFSetField", "%s: Unknown %stag %u", + tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); + return (0); + } + if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) && + !fip->field_oktochange) { + /* + * Consult info table to see if tag can be changed + * after we've started writing. We only allow changes + * to those tags that don't/shouldn't affect the + * compression and/or format of the data. + */ + TIFFError("TIFFSetField", + "%s: Cannot modify tag \"%s\" while writing", + tif->tif_name, fip->field_name); + return (0); + } + return (1); +} + +/* + * Record the value of a field in the + * internal directory structure. The + * field will be written to the file + * when/if the directory structure is + * updated. + */ +int +TIFFSetField(TIFF* tif, ttag_t tag, ...) +{ + va_list ap; + int status; + + va_start(ap, tag); + status = TIFFVSetField(tif, tag, ap); + va_end(ap); + return (status); +} + +/* + * Like TIFFSetField, but taking a varargs + * parameter list. This routine is useful + * for building higher-level interfaces on + * top of the library. + */ +int +TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) +{ + return OkToChangeTag(tif, tag) ? + (*tif->tif_vsetfield)(tif, tag, ap) : 0; +} + +static int +_TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) +{ + TIFFDirectory* td = &tif->tif_dir; + + switch (tag) { + case TIFFTAG_SUBFILETYPE: + *va_arg(ap, uint32*) = td->td_subfiletype; + break; + case TIFFTAG_IMAGEWIDTH: + *va_arg(ap, uint32*) = td->td_imagewidth; + break; + case TIFFTAG_IMAGELENGTH: + *va_arg(ap, uint32*) = td->td_imagelength; + break; + case TIFFTAG_BITSPERSAMPLE: + *va_arg(ap, uint16*) = td->td_bitspersample; + break; + case TIFFTAG_COMPRESSION: + *va_arg(ap, uint16*) = td->td_compression; + break; + case TIFFTAG_PHOTOMETRIC: + *va_arg(ap, uint16*) = td->td_photometric; + break; + case TIFFTAG_THRESHHOLDING: + *va_arg(ap, uint16*) = td->td_threshholding; + break; + case TIFFTAG_FILLORDER: + *va_arg(ap, uint16*) = td->td_fillorder; + break; + case TIFFTAG_DOCUMENTNAME: + *va_arg(ap, char**) = td->td_documentname; + break; + case TIFFTAG_ARTIST: + *va_arg(ap, char**) = td->td_artist; + break; + case TIFFTAG_DATETIME: + *va_arg(ap, char**) = td->td_datetime; + break; + case TIFFTAG_HOSTCOMPUTER: + *va_arg(ap, char**) = td->td_hostcomputer; + break; + case TIFFTAG_IMAGEDESCRIPTION: + *va_arg(ap, char**) = td->td_imagedescription; + break; + case TIFFTAG_MAKE: + *va_arg(ap, char**) = td->td_make; + break; + case TIFFTAG_MODEL: + *va_arg(ap, char**) = td->td_model; + break; + case TIFFTAG_SOFTWARE: + *va_arg(ap, char**) = td->td_software; + break; + case TIFFTAG_COPYRIGHT: + *va_arg(ap, char**) = td->td_copyright; + break; + case TIFFTAG_ORIENTATION: + *va_arg(ap, uint16*) = td->td_orientation; + break; + case TIFFTAG_SAMPLESPERPIXEL: + *va_arg(ap, uint16*) = td->td_samplesperpixel; + break; + case TIFFTAG_ROWSPERSTRIP: + *va_arg(ap, uint32*) = td->td_rowsperstrip; + break; + case TIFFTAG_MINSAMPLEVALUE: + *va_arg(ap, uint16*) = td->td_minsamplevalue; + break; + case TIFFTAG_MAXSAMPLEVALUE: + *va_arg(ap, uint16*) = td->td_maxsamplevalue; + break; + case TIFFTAG_SMINSAMPLEVALUE: + *va_arg(ap, double*) = td->td_sminsamplevalue; + break; + case TIFFTAG_SMAXSAMPLEVALUE: + *va_arg(ap, double*) = td->td_smaxsamplevalue; + break; + case TIFFTAG_XRESOLUTION: + *va_arg(ap, float*) = td->td_xresolution; + break; + case TIFFTAG_YRESOLUTION: + *va_arg(ap, float*) = td->td_yresolution; + break; + case TIFFTAG_PLANARCONFIG: + *va_arg(ap, uint16*) = td->td_planarconfig; + break; + case TIFFTAG_XPOSITION: + *va_arg(ap, float*) = td->td_xposition; + break; + case TIFFTAG_YPOSITION: + *va_arg(ap, float*) = td->td_yposition; + break; + case TIFFTAG_PAGENAME: + *va_arg(ap, char**) = td->td_pagename; + break; + case TIFFTAG_RESOLUTIONUNIT: + *va_arg(ap, uint16*) = td->td_resolutionunit; + break; + case TIFFTAG_PAGENUMBER: + *va_arg(ap, uint16*) = td->td_pagenumber[0]; + *va_arg(ap, uint16*) = td->td_pagenumber[1]; + break; + case TIFFTAG_HALFTONEHINTS: + *va_arg(ap, uint16*) = td->td_halftonehints[0]; + *va_arg(ap, uint16*) = td->td_halftonehints[1]; + break; + case TIFFTAG_COLORMAP: + *va_arg(ap, uint16**) = td->td_colormap[0]; + *va_arg(ap, uint16**) = td->td_colormap[1]; + *va_arg(ap, uint16**) = td->td_colormap[2]; + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_TILEOFFSETS: + *va_arg(ap, uint32**) = td->td_stripoffset; + break; + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEBYTECOUNTS: + *va_arg(ap, uint32**) = td->td_stripbytecount; + break; + case TIFFTAG_MATTEING: + *va_arg(ap, uint16*) = + (td->td_extrasamples == 1 && + td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); + break; + case TIFFTAG_EXTRASAMPLES: + *va_arg(ap, uint16*) = td->td_extrasamples; + *va_arg(ap, uint16**) = td->td_sampleinfo; + break; + case TIFFTAG_TILEWIDTH: + *va_arg(ap, uint32*) = td->td_tilewidth; + break; + case TIFFTAG_TILELENGTH: + *va_arg(ap, uint32*) = td->td_tilelength; + break; + case TIFFTAG_TILEDEPTH: + *va_arg(ap, uint32*) = td->td_tiledepth; + break; + case TIFFTAG_DATATYPE: + switch (td->td_sampleformat) { + case SAMPLEFORMAT_UINT: + *va_arg(ap, uint16*) = DATATYPE_UINT; + break; + case SAMPLEFORMAT_INT: + *va_arg(ap, uint16*) = DATATYPE_INT; + break; + case SAMPLEFORMAT_IEEEFP: + *va_arg(ap, uint16*) = DATATYPE_IEEEFP; + break; + case SAMPLEFORMAT_VOID: + *va_arg(ap, uint16*) = DATATYPE_VOID; + break; + } + break; + case TIFFTAG_SAMPLEFORMAT: + *va_arg(ap, uint16*) = td->td_sampleformat; + break; + case TIFFTAG_IMAGEDEPTH: + *va_arg(ap, uint32*) = td->td_imagedepth; + break; + case TIFFTAG_STONITS: + *va_arg(ap, double*) = td->td_stonits; + break; +#if SUBIFD_SUPPORT + case TIFFTAG_SUBIFD: + *va_arg(ap, uint16*) = td->td_nsubifd; + *va_arg(ap, uint32**) = td->td_subifd; + break; +#endif +#ifdef YCBCR_SUPPORT + case TIFFTAG_YCBCRCOEFFICIENTS: + *va_arg(ap, float**) = td->td_ycbcrcoeffs; + break; + case TIFFTAG_YCBCRPOSITIONING: + *va_arg(ap, uint16*) = td->td_ycbcrpositioning; + break; + case TIFFTAG_YCBCRSUBSAMPLING: + *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; + break; +#endif +#ifdef COLORIMETRY_SUPPORT + case TIFFTAG_WHITEPOINT: + *va_arg(ap, float**) = td->td_whitepoint; + break; + case TIFFTAG_PRIMARYCHROMATICITIES: + *va_arg(ap, float**) = td->td_primarychromas; + break; + case TIFFTAG_TRANSFERFUNCTION: + *va_arg(ap, uint16**) = td->td_transferfunction[0]; + if (td->td_samplesperpixel - td->td_extrasamples > 1) { + *va_arg(ap, uint16**) = td->td_transferfunction[1]; + *va_arg(ap, uint16**) = td->td_transferfunction[2]; + } + break; + case TIFFTAG_REFERENCEBLACKWHITE: + *va_arg(ap, float**) = td->td_refblackwhite; + break; +#endif +#ifdef CMYK_SUPPORT + case TIFFTAG_INKSET: + *va_arg(ap, uint16*) = td->td_inkset; + break; + case TIFFTAG_DOTRANGE: + *va_arg(ap, uint16*) = td->td_dotrange[0]; + *va_arg(ap, uint16*) = td->td_dotrange[1]; + break; + case TIFFTAG_INKNAMES: + *va_arg(ap, char**) = td->td_inknames; + break; + case TIFFTAG_NUMBEROFINKS: + *va_arg(ap, uint16*) = td->td_ninks; + break; + case TIFFTAG_TARGETPRINTER: + *va_arg(ap, char**) = td->td_targetprinter; + break; +#endif +#ifdef ICC_SUPPORT + case TIFFTAG_ICCPROFILE: + *va_arg(ap, uint32*) = td->td_profileLength; + *va_arg(ap, void**) = td->td_profileData; + break; +#endif +#ifdef PHOTOSHOP_SUPPORT + case TIFFTAG_PHOTOSHOP: + *va_arg(ap, uint32*) = td->td_photoshopLength; + *va_arg(ap, void**) = td->td_photoshopData; + break; +#endif +#ifdef IPTC_SUPPORT + case TIFFTAG_RICHTIFFIPTC: + *va_arg(ap, uint32*) = td->td_richtiffiptcLength; + *va_arg(ap, void**) = td->td_richtiffiptcData; + break; +#endif + /* Begin Pixar Tags */ + case TIFFTAG_PIXAR_IMAGEFULLWIDTH: + *va_arg(ap, uint32*) = td->td_imagefullwidth; + break; + case TIFFTAG_PIXAR_IMAGEFULLLENGTH: + *va_arg(ap, uint32*) = td->td_imagefulllength; + break; + case TIFFTAG_PIXAR_TEXTUREFORMAT: + *va_arg(ap, char**) = td->td_textureformat; + break; + case TIFFTAG_PIXAR_WRAPMODES: + *va_arg(ap, char**) = td->td_wrapmodes; + break; + case TIFFTAG_PIXAR_FOVCOT: + *va_arg(ap, float*) = td->td_fovcot; + break; + case TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN: + *va_arg(ap, float**) = td->td_matrixWorldToScreen; + break; + case TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA: + *va_arg(ap, float**) = td->td_matrixWorldToCamera; + break; + /* End Pixar Tags */ + + default: + /* + * This can happen if multiple images are open with + * different codecs which have private tags. The + * global tag information table may then have tags + * that are valid for one file but not the other. + * If the client tries to get a tag that is not valid + * for the image's codec then we'll arrive here. + */ + TIFFError("TIFFGetField", + "%s: Invalid %stag \"%s\" (not supported by codec)", + tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", + _TIFFFieldWithTag(tif, tag)->field_name); + break; + } + return (1); +} + +/* + * Return the value of a field in the + * internal directory structure. + */ +int +TIFFGetField(TIFF* tif, ttag_t tag, ...) +{ + int status; + va_list ap; + + va_start(ap, tag); + status = TIFFVGetField(tif, tag, ap); + va_end(ap); + return (status); +} + +/* + * Like TIFFGetField, but taking a varargs + * parameter list. This routine is useful + * for building higher-level interfaces on + * top of the library. + */ +int +TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) +{ + const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); + return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ? + (*tif->tif_vgetfield)(tif, tag, ap) : 0); +} + +#define CleanupField(member) { \ + if (td->member) { \ + _TIFFfree(tif, td->member); \ + td->member = 0; \ + } \ +} + +/* + * Release storage associated with a directory. + */ +void +TIFFFreeDirectory(TIFF* tif) +{ + register TIFFDirectory *td = &tif->tif_dir; + + CleanupField(td_colormap[0]); + CleanupField(td_colormap[1]); + CleanupField(td_colormap[2]); + CleanupField(td_documentname); + CleanupField(td_artist); + CleanupField(td_datetime); + CleanupField(td_hostcomputer); + CleanupField(td_imagedescription); + CleanupField(td_make); + CleanupField(td_model); + CleanupField(td_software); + CleanupField(td_copyright); + CleanupField(td_pagename); + CleanupField(td_sampleinfo); +#if SUBIFD_SUPPORT + CleanupField(td_subifd); +#endif +#ifdef YCBCR_SUPPORT + CleanupField(td_ycbcrcoeffs); +#endif +#ifdef CMYK_SUPPORT + CleanupField(td_inknames); + CleanupField(td_targetprinter); +#endif +#ifdef COLORIMETRY_SUPPORT + CleanupField(td_whitepoint); + CleanupField(td_primarychromas); + CleanupField(td_refblackwhite); + CleanupField(td_transferfunction[0]); + CleanupField(td_transferfunction[1]); + CleanupField(td_transferfunction[2]); +#endif +#ifdef ICC_SUPPORT + CleanupField(td_profileData); +#endif +#ifdef PHOTOSHOP_SUPPORT + CleanupField(td_photoshopData); +#endif +#ifdef IPTC_SUPPORT + CleanupField(td_richtiffiptcData); +#endif + CleanupField(td_stripoffset); + CleanupField(td_stripbytecount); + /* Begin Pixar Tags */ + CleanupField(td_textureformat); + CleanupField(td_wrapmodes); + CleanupField(td_matrixWorldToScreen); + CleanupField(td_matrixWorldToCamera); + /* End Pixar Tags */ +} +#undef CleanupField + +/* + * Client Tag extension support (from Niles Ritter). + */ +static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL; + +TIFFExtendProc +TIFFSetTagExtender(TIFFExtendProc extender) +{ + TIFFExtendProc prev = _TIFFextender; + _TIFFextender = extender; + return (prev); +} + +/* #ifdef PDF_UNUSED */ +/* + * Setup for a new directory. Should we automatically call + * TIFFWriteDirectory() if the current one is dirty? + * + * The newly created directory will not exist on the file till + * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called. + */ +int +TIFFCreateDirectory(TIFF* tif) +{ + TIFFDefaultDirectory(tif); + tif->tif_diroff = 0; + tif->tif_nextdiroff = 0; + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (tstrip_t) -1; + + return 0; +} +/* #endif */ + +/* + * Setup a default directory structure. + */ +int +TIFFDefaultDirectory(TIFF* tif) +{ + register TIFFDirectory* td = &tif->tif_dir; + + _TIFFSetupFieldInfo(tif); + _TIFFmemset(td, 0, sizeof (*td)); + td->td_fillorder = FILLORDER_MSB2LSB; + td->td_bitspersample = 1; + td->td_threshholding = THRESHHOLD_BILEVEL; + td->td_orientation = ORIENTATION_TOPLEFT; + td->td_samplesperpixel = 1; + td->td_rowsperstrip = (uint32) -1; + td->td_tilewidth = (uint32) -1; + td->td_tilelength = (uint32) -1; + td->td_tiledepth = 1; + td->td_resolutionunit = RESUNIT_INCH; + td->td_sampleformat = SAMPLEFORMAT_UINT; + td->td_imagedepth = 1; +#ifdef YCBCR_SUPPORT + td->td_ycbcrsubsampling[0] = 2; + td->td_ycbcrsubsampling[1] = 2; + td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; +#endif +#ifdef CMYK_SUPPORT + td->td_inkset = INKSET_CMYK; + td->td_ninks = 4; +#endif + tif->tif_postdecode = _TIFFNoPostDecode; + tif->tif_vsetfield = _TIFFVSetField; + tif->tif_vgetfield = _TIFFVGetField; + tif->tif_printdir = NULL; + /* + * Give client code a chance to install their own + * tag extensions & methods, prior to compression overloads. + */ + if (_TIFFextender) + (*_TIFFextender)(tif); + (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + /* + * NB: The directory is marked dirty as a result of setting + * up the default compression scheme. However, this really + * isn't correct -- we want TIFF_DIRTYDIRECT to be set only + * if the user does something. We could just do the setup + * by hand, but it seems better to use the normal mechanism + * (i.e. TIFFSetField). + */ + tif->tif_flags &= ~TIFF_DIRTYDIRECT; + + /* + * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19 + * we clear the ISTILED flag when setting up a new directory. + * Should we also be clearing stuff like INSUBIFD? + */ + tif->tif_flags &= ~TIFF_ISTILED; + + return (1); +} + +static int +TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off) +{ + static const char module[] = "TIFFAdvanceDirectory"; + uint16 dircount; + if (isMapped(tif)) + { + toff_t poff=*nextdir; + if (poff+sizeof(uint16) > tif->tif_size) + { + TIFFError(module, "%s: Error fetching directory count", + tif->tif_name); + return (0); + } + _TIFFmemcpy(&dircount, tif->tif_base+poff, sizeof (uint16)); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + poff+=sizeof (uint16)+dircount*sizeof (TIFFDirEntry); + if (off != NULL) + *off = poff; + if (((toff_t) (poff+sizeof (uint32))) > tif->tif_size) + { + TIFFError(module, "%s: Error fetching directory link", + tif->tif_name); + return (0); + } + _TIFFmemcpy(nextdir, tif->tif_base+poff, sizeof (uint32)); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(nextdir); + return (1); + } + else + { + if (!SeekOK(tif, *nextdir) || + !ReadOK(tif, &dircount, sizeof (uint16))) { + TIFFError(module, "%s: Error fetching directory count", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + if (off != NULL) + *off = TIFFSeekFile(tif, + dircount*sizeof (TIFFDirEntry), SEEK_CUR); + else + (void) TIFFSeekFile(tif, + dircount*sizeof (TIFFDirEntry), SEEK_CUR); + if (!ReadOK(tif, nextdir, sizeof (uint32))) { + TIFFError(module, "%s: Error fetching directory link", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(nextdir); + return (1); + } +} + +#ifdef PDF_UNUSED +/* + * Count the number of directories in a file. + */ +tdir_t +TIFFNumberOfDirectories(TIFF* tif) +{ + toff_t nextdir = tif->tif_header.tiff_diroff; + tdir_t n = 0; + + while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL)) + n++; + return (n); +} +#endif + +/* + * Set the n-th directory as the current directory. + * NB: Directories are numbered starting at 0. + */ +int +TIFFSetDirectory(TIFF* tif, tdir_t dirn) +{ + toff_t nextdir; + tdir_t n; + + nextdir = tif->tif_header.tiff_diroff; + for (n = dirn; n > 0 && nextdir != 0; n--) + if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) + return (0); + tif->tif_nextdiroff = nextdir; + /* + * Set curdir to the actual directory index. The + * -1 is because TIFFReadDirectory will increment + * tif_curdir after successfully reading the directory. + */ + tif->tif_curdir = (dirn - n) - 1; + return (TIFFReadDirectory(tif)); +} + +#ifdef PDF_UNUSED +/* + * Set the current directory to be the directory + * located at the specified file offset. This interface + * is used mainly to access directories linked with + * the SubIFD tag (e.g. thumbnail images). + */ +int +TIFFSetSubDirectory(TIFF* tif, uint32 diroff) +{ + tif->tif_nextdiroff = diroff; + return (TIFFReadDirectory(tif)); +} + +/* + * Return file offset of the current directory. + */ +uint32 +TIFFCurrentDirOffset(TIFF* tif) +{ + return (tif->tif_diroff); +} + +/* + * Return an indication of whether or not we are + * at the last directory in the file. + */ +int +TIFFLastDirectory(TIFF* tif) +{ + return (tif->tif_nextdiroff == 0); +} + +/* + * Unlink the specified directory from the directory chain. + */ +int +TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn) +{ + static const char module[] = "TIFFUnlinkDirectory"; + toff_t nextdir; + toff_t off; + tdir_t n; + + if (tif->tif_mode == O_RDONLY) { + TIFFError(module, "Can not unlink directory in read-only file"); + return (0); + } + /* + * Go to the directory before the one we want + * to unlink and nab the offset of the link + * field we'll need to patch. + */ + nextdir = tif->tif_header.tiff_diroff; + off = sizeof (uint16) + sizeof (uint16); + for (n = dirn-1; n > 0; n--) { + if (nextdir == 0) { + TIFFError(module, "Directory %d does not exist", dirn); + return (0); + } + if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) + return (0); + } + /* + * Advance to the directory to be unlinked and fetch + * the offset of the directory that follows. + */ + if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) + return (0); + /* + * Go back and patch the link field of the preceding + * directory to point to the offset of the directory + * that follows. + */ + (void) TIFFSeekFile(tif, off, SEEK_SET); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextdir); + if (!WriteOK(tif, &nextdir, sizeof (uint32))) { + TIFFError(module, "Error writing directory link"); + return (0); + } + /* + * Leave directory state setup safely. We don't have + * facilities for doing inserting and removing directories, + * so it's safest to just invalidate everything. This + * means that the caller can only append to the directory + * chain. + */ + (*tif->tif_cleanup)(tif); + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { + _TIFFfree(tif, tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawcc = 0; + } + tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE); + TIFFFreeDirectory(tif); + TIFFDefaultDirectory(tif); + tif->tif_diroff = 0; /* force link on next write */ + tif->tif_nextdiroff = 0; /* next write must be at end */ + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (tstrip_t) -1; + return (1); +} +#endif + +/* [BFC] + * + * Author: Bruce Cameron + * + * Set a table of tags that are to be replaced during directory process by the + * 'IGNORE' state - or return TRUE/FALSE for the requested tag such that + * 'ReadDirectory' can use the stored information. + */ +int +TIFFReassignTagToIgnore (enum TIFFIgnoreSense task, int TIFFtagID) +{ + static int TIFFignoretags [FIELD_LAST]; + static int tagcount = 0 ; + int i; /* Loop index */ + int j; /* Loop index */ + + switch (task) + { + case TIS_STORE: + if ( tagcount < (FIELD_LAST - 1) ) + { + for ( j = 0 ; j < tagcount ; ++j ) + { /* Do not add duplicate tag */ + if ( TIFFignoretags [j] == TIFFtagID ) + return (TRUE) ; + } + TIFFignoretags [tagcount++] = TIFFtagID ; + return (TRUE) ; + } + break ; + + case TIS_EXTRACT: + for ( i = 0 ; i < tagcount ; ++i ) + { + if ( TIFFignoretags [i] == TIFFtagID ) + return (TRUE) ; + } + break; + + case TIS_EMPTY: + tagcount = 0 ; /* Clear the list */ + return (TRUE) ; + + default: + break; + } + + return (FALSE); +} diff --git a/src/libs/pdflib/libs/tiff/tif_dir.h b/src/libs/pdflib/libs/tiff/tif_dir.h new file mode 100644 index 0000000000..1be57c38da --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_dir.h @@ -0,0 +1,270 @@ +/* PDFlib GmbH cvsid: $Id: tif_dir.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFFDIR_ +#define _TIFFDIR_ +/* + * ``Library-private'' Directory-related Definitions. + */ + +/* + * Internal format of a TIFF directory entry. + */ +typedef struct { +#define FIELD_SETLONGS 3 + /* bit vector of fields that are set */ + tif_long td_fieldsset[FIELD_SETLONGS]; + + uint32 td_imagewidth, td_imagelength, td_imagedepth; + uint32 td_tilewidth, td_tilelength, td_tiledepth; + uint32 td_subfiletype; + uint16 td_bitspersample; + uint16 td_sampleformat; + uint16 td_compression; + uint16 td_photometric; + uint16 td_threshholding; + uint16 td_fillorder; + uint16 td_orientation; + uint16 td_samplesperpixel; + uint32 td_rowsperstrip; + uint16 td_minsamplevalue, td_maxsamplevalue; + double td_sminsamplevalue, td_smaxsamplevalue; + float td_xresolution, td_yresolution; + uint16 td_resolutionunit; + uint16 td_planarconfig; + float td_xposition, td_yposition; + uint16 td_pagenumber[2]; + uint16* td_colormap[3]; + uint16 td_halftonehints[2]; + uint16 td_extrasamples; + uint16* td_sampleinfo; + double td_stonits; + char* td_documentname; + char* td_artist; + char* td_datetime; + char* td_hostcomputer; + char* td_imagedescription; + char* td_make; + char* td_model; + char* td_software; + char* td_copyright; + char* td_pagename; + tstrip_t td_stripsperimage; + tstrip_t td_nstrips; /* size of offset & bytecount arrays */ + uint32* td_stripoffset; + uint32* td_stripbytecount; +#if SUBIFD_SUPPORT + uint16 td_nsubifd; + uint32* td_subifd; +#endif +#ifdef YCBCR_SUPPORT + float* td_ycbcrcoeffs; + uint16 td_ycbcrsubsampling[2]; + uint16 td_ycbcrpositioning; +#endif +#ifdef COLORIMETRY_SUPPORT + float* td_whitepoint; + float* td_primarychromas; + float* td_refblackwhite; + uint16* td_transferfunction[3]; +#endif +#ifdef CMYK_SUPPORT + uint16 td_inkset; + uint16 td_ninks; + uint16 td_dotrange[2]; + int td_inknameslen; + char* td_inknames; + char* td_targetprinter; +#endif +#ifdef ICC_SUPPORT + uint32 td_profileLength; + void *td_profileData; +#endif +#ifdef PHOTOSHOP_SUPPORT + uint32 td_photoshopLength; + void *td_photoshopData; +#endif +#ifdef IPTC_SUPPORT + uint32 td_richtiffiptcLength; + void *td_richtiffiptcData; +#endif + /* Begin Pixar Tag values. */ + uint32 td_imagefullwidth, td_imagefulllength; + char* td_textureformat; + char* td_wrapmodes; + float td_fovcot; + float* td_matrixWorldToScreen; + float* td_matrixWorldToCamera; + /* End Pixar Tag Values. */ +} TIFFDirectory; + +/* + * Field flags used to indicate fields that have + * been set in a directory, and to reference fields + * when manipulating a directory. + */ + +/* + * FIELD_IGNORE is used to signify tags that are to + * be processed but otherwise ignored. This permits + * antiquated tags to be quietly read and discarded. + * Note that a bit *is* allocated for ignored tags; + * this is understood by the directory reading logic + * which uses this fact to avoid special-case handling + */ +#define FIELD_IGNORE 0 + +/* multi-item fields */ +#define FIELD_IMAGEDIMENSIONS 1 +#define FIELD_TILEDIMENSIONS 2 +#define FIELD_RESOLUTION 3 +#define FIELD_POSITION 4 + +/* single-item fields */ +#define FIELD_SUBFILETYPE 5 +#define FIELD_BITSPERSAMPLE 6 +#define FIELD_COMPRESSION 7 +#define FIELD_PHOTOMETRIC 8 +#define FIELD_THRESHHOLDING 9 +#define FIELD_FILLORDER 10 +#define FIELD_DOCUMENTNAME 11 +#define FIELD_IMAGEDESCRIPTION 12 +#define FIELD_MAKE 13 +#define FIELD_MODEL 14 +#define FIELD_ORIENTATION 15 +#define FIELD_SAMPLESPERPIXEL 16 +#define FIELD_ROWSPERSTRIP 17 +#define FIELD_MINSAMPLEVALUE 18 +#define FIELD_MAXSAMPLEVALUE 19 +#define FIELD_PLANARCONFIG 20 +#define FIELD_PAGENAME 21 +#define FIELD_RESOLUTIONUNIT 22 +#define FIELD_PAGENUMBER 23 +#define FIELD_STRIPBYTECOUNTS 24 +#define FIELD_STRIPOFFSETS 25 +#define FIELD_COLORMAP 26 +#define FIELD_ARTIST 27 +#define FIELD_DATETIME 28 +#define FIELD_HOSTCOMPUTER 29 +#define FIELD_SOFTWARE 30 +#define FIELD_EXTRASAMPLES 31 +#define FIELD_SAMPLEFORMAT 32 +#define FIELD_SMINSAMPLEVALUE 33 +#define FIELD_SMAXSAMPLEVALUE 34 +#define FIELD_IMAGEDEPTH 35 +#define FIELD_TILEDEPTH 36 +#define FIELD_HALFTONEHINTS 37 +#define FIELD_YCBCRCOEFFICIENTS 38 +#define FIELD_YCBCRSUBSAMPLING 39 +#define FIELD_YCBCRPOSITIONING 40 +#define FIELD_REFBLACKWHITE 41 +#define FIELD_WHITEPOINT 42 +#define FIELD_PRIMARYCHROMAS 43 +#define FIELD_TRANSFERFUNCTION 44 +#define FIELD_INKSET 45 +#define FIELD_INKNAMES 46 +#define FIELD_DOTRANGE 47 +#define FIELD_TARGETPRINTER 48 +#define FIELD_SUBIFD 49 +#define FIELD_NUMBEROFINKS 50 +#define FIELD_ICCPROFILE 51 +#define FIELD_PHOTOSHOP 52 +#define FIELD_RICHTIFFIPTC 53 +#define FIELD_STONITS 54 +/* Begin PIXAR */ +#define FIELD_IMAGEFULLWIDTH 55 +#define FIELD_IMAGEFULLLENGTH 56 +#define FIELD_TEXTUREFORMAT 57 +#define FIELD_WRAPMODES 58 +#define FIELD_FOVCOT 59 +#define FIELD_MATRIX_WORLDTOSCREEN 60 +#define FIELD_MATRIX_WORLDTOCAMERA 61 +#define FIELD_COPYRIGHT 62 +/* end of support for well-known tags; codec-private tags follow */ +#define FIELD_CODEC 63 /* base of codec-private tags */ +/* + * Pseudo-tags don't normally need field bits since they + * are not written to an output file (by definition). + * The library also has express logic to always query a + * codec for a pseudo-tag so allocating a field bit for + * one is a waste. If codec wants to promote the notion + * of a pseudo-tag being ``set'' or ``unset'' then it can + * do using internal state flags without polluting the + * field bit space defined for real tags. + */ +#define FIELD_PSEUDO 0 + +#define FIELD_LAST (32*FIELD_SETLONGS-1) + +#define TIFFExtractData(tif, type, v) \ + ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ + ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \ + (v) & (tif)->tif_typemask[type])) +#define TIFFInsertData(tif, type, v) \ + ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ + ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \ + (v) & (tif)->tif_typemask[type])) + +typedef struct { + ttag_t field_tag; /* field's tag */ + short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ + short field_writecount; /* write count/TIFF_VARIABLE */ + TIFFDataType field_type; /* type of associated data */ + tif_short field_bit; /* bit in fieldsset bit vector */ + tif_char field_oktochange; /* if true, can change while writing */ + tif_char field_passcount; /* if true, pass dir count on set */ + char *field_name; /* ASCII name */ +} TIFFFieldInfo; + +#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ +#define TIFF_VARIABLE -1 /* marker for variable length tags */ +#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ +#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ + +extern const int tiffDataWidth[]; /* table of tag datatype widths */ + +#define BITn(n) (((tif_long)1L)<<((n)&0x1f)) +#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) +#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) +#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) +#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) + +#define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) +#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) + +#if defined(__cplusplus) +extern "C" { +#endif +extern void _TIFFSetupFieldInfo(TIFF*); +extern void _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); +extern void _TIFFPrintFieldInfo(TIFF*, FILE*); +extern const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); +extern const TIFFFieldInfo* _TIFFFieldWithTag(TIFF*, ttag_t); +extern TIFFDataType _TIFFSampleToTagType(TIFF*); +#if defined(__cplusplus) +} +#endif +#endif /* _TIFFDIR_ */ diff --git a/src/libs/pdflib/libs/tiff/tif_dirinfo.c b/src/libs/pdflib/libs/tiff/tif_dirinfo.c new file mode 100644 index 0000000000..ce50f64515 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_dirinfo.c @@ -0,0 +1,413 @@ +/* PDFlib GmbH cvsid: $Id: tif_dirinfo.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Core Directory Tag Support. + */ +#include "tiffiop.h" +#include + +/* + * NB: NB: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG. + * If a tag can have both LONG and SHORT types + * then the LONG must be placed before the SHORT for + * writing to work properly. + * + * NOTE: The second field (field_readcount) and third field (field_writecount) + * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3) + * and TIFFTAG_SPP (-2). The macros should be used but would throw off + * the formatting of the code, so please interprete the -1, -2 and -3 + * values accordingly. + */ +#ifndef VMS +static +#endif +const TIFFFieldInfo tiffFieldInfo[] = { + { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, FIELD_SUBFILETYPE, + TRUE, FALSE, "SubfileType" }, +/* XXX SHORT for compatibility w/ old versions of the library */ + { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, + TRUE, FALSE, "SubfileType" }, + { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, + TRUE, FALSE, "OldSubfileType" }, + { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, + FALSE, FALSE, "ImageWidth" }, + { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, + FALSE, FALSE, "ImageWidth" }, + { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, + TRUE, FALSE, "ImageLength" }, + { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, + TRUE, FALSE, "ImageLength" }, + { TIFFTAG_BITSPERSAMPLE, -1,-1, TIFF_SHORT, FIELD_BITSPERSAMPLE, + FALSE, FALSE, "BitsPerSample" }, + { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, FIELD_COMPRESSION, + FALSE, FALSE, "Compression" }, + { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, FIELD_PHOTOMETRIC, + FALSE, FALSE, "PhotometricInterpretation" }, + { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, FIELD_THRESHHOLDING, + TRUE, FALSE, "Threshholding" }, + { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, + TRUE, FALSE, "CellWidth" }, + { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, + TRUE, FALSE, "CellLength" }, + { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, FIELD_FILLORDER, + FALSE, FALSE, "FillOrder" }, + { TIFFTAG_DOCUMENTNAME, -1,-1, TIFF_ASCII, FIELD_DOCUMENTNAME, + TRUE, FALSE, "DocumentName" }, + { TIFFTAG_IMAGEDESCRIPTION, -1,-1, TIFF_ASCII, FIELD_IMAGEDESCRIPTION, + TRUE, FALSE, "ImageDescription" }, + { TIFFTAG_MAKE, -1,-1, TIFF_ASCII, FIELD_MAKE, + TRUE, FALSE, "Make" }, + { TIFFTAG_MODEL, -1,-1, TIFF_ASCII, FIELD_MODEL, + TRUE, FALSE, "Model" }, + { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_LONG, FIELD_STRIPOFFSETS, + FALSE, FALSE, "StripOffsets" }, + { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_SHORT, FIELD_STRIPOFFSETS, + FALSE, FALSE, "StripOffsets" }, + { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, FIELD_ORIENTATION, + FALSE, FALSE, "Orientation" }, + { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, FIELD_SAMPLESPERPIXEL, + FALSE, FALSE, "SamplesPerPixel" }, + { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, FIELD_ROWSPERSTRIP, + FALSE, FALSE, "RowsPerStrip" }, + { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_SHORT, FIELD_ROWSPERSTRIP, + FALSE, FALSE, "RowsPerStrip" }, + { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, + FALSE, FALSE, "StripByteCounts" }, + { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, + FALSE, FALSE, "StripByteCounts" }, + { TIFFTAG_MINSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MINSAMPLEVALUE, + TRUE, FALSE, "MinSampleValue" }, + { TIFFTAG_MAXSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MAXSAMPLEVALUE, + TRUE, FALSE, "MaxSampleValue" }, + { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, + FALSE, FALSE, "XResolution" }, + { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, + FALSE, FALSE, "YResolution" }, + { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, FIELD_PLANARCONFIG, + FALSE, FALSE, "PlanarConfiguration" }, + { TIFFTAG_PAGENAME, -1,-1, TIFF_ASCII, FIELD_PAGENAME, + TRUE, FALSE, "PageName" }, + { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, + TRUE, FALSE, "XPosition" }, + { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, + TRUE, FALSE, "YPosition" }, + { TIFFTAG_FREEOFFSETS, -1,-1, TIFF_LONG, FIELD_IGNORE, + FALSE, FALSE, "FreeOffsets" }, + { TIFFTAG_FREEBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_IGNORE, + FALSE, FALSE, "FreeByteCounts" }, + { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, + TRUE, FALSE, "GrayResponseUnit" }, + { TIFFTAG_GRAYRESPONSECURVE,-1,-1, TIFF_SHORT, FIELD_IGNORE, + TRUE, FALSE, "GrayResponseCurve" }, + { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, FIELD_RESOLUTIONUNIT, + FALSE, FALSE, "ResolutionUnit" }, + { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, FIELD_PAGENUMBER, + TRUE, FALSE, "PageNumber" }, + { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, + TRUE, FALSE, "ColorResponseUnit" }, +#ifdef COLORIMETRY_SUPPORT + { TIFFTAG_TRANSFERFUNCTION, -1,-1, TIFF_SHORT, FIELD_TRANSFERFUNCTION, + TRUE, FALSE, "TransferFunction" }, +#endif + { TIFFTAG_SOFTWARE, -1,-1, TIFF_ASCII, FIELD_SOFTWARE, + TRUE, FALSE, "Software" }, + { TIFFTAG_DATETIME, 20,20, TIFF_ASCII, FIELD_DATETIME, + TRUE, FALSE, "DateTime" }, + { TIFFTAG_ARTIST, -1,-1, TIFF_ASCII, FIELD_ARTIST, + TRUE, FALSE, "Artist" }, + { TIFFTAG_HOSTCOMPUTER, -1,-1, TIFF_ASCII, FIELD_HOSTCOMPUTER, + TRUE, FALSE, "HostComputer" }, +#ifdef COLORIMETRY_SUPPORT + { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL,FIELD_WHITEPOINT, + TRUE, FALSE, "WhitePoint" }, + { TIFFTAG_PRIMARYCHROMATICITIES,6,6,TIFF_RATIONAL,FIELD_PRIMARYCHROMAS, + TRUE, FALSE, "PrimaryChromaticities" }, +#endif + { TIFFTAG_COLORMAP, -1,-1, TIFF_SHORT, FIELD_COLORMAP, + TRUE, FALSE, "ColorMap" }, + { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, FIELD_HALFTONEHINTS, + TRUE, FALSE, "HalftoneHints" }, + { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, + FALSE, FALSE, "TileWidth" }, + { TIFFTAG_TILEWIDTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, + FALSE, FALSE, "TileWidth" }, + { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, + FALSE, FALSE, "TileLength" }, + { TIFFTAG_TILELENGTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, + FALSE, FALSE, "TileLength" }, + { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG, FIELD_STRIPOFFSETS, + FALSE, FALSE, "TileOffsets" }, + { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, + FALSE, FALSE, "TileByteCounts" }, + { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, + FALSE, FALSE, "TileByteCounts" }, +#ifdef TIFFTAG_SUBIFD + { TIFFTAG_SUBIFD, -1,-1, TIFF_LONG, FIELD_SUBIFD, + TRUE, TRUE, "SubIFD" }, +#endif +#ifdef CMYK_SUPPORT /* 6.0 CMYK tags */ + { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, FIELD_INKSET, + FALSE, FALSE, "InkSet" }, + { TIFFTAG_INKNAMES, -1,-1, TIFF_ASCII, FIELD_INKNAMES, + TRUE, TRUE, "InkNames" }, + { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, FIELD_NUMBEROFINKS, + TRUE, FALSE, "NumberOfInks" }, + { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, FIELD_DOTRANGE, + FALSE, FALSE, "DotRange" }, + { TIFFTAG_DOTRANGE, 2, 2, TIFF_BYTE, FIELD_DOTRANGE, + FALSE, FALSE, "DotRange" }, + { TIFFTAG_TARGETPRINTER, -1,-1, TIFF_ASCII, FIELD_TARGETPRINTER, + TRUE, FALSE, "TargetPrinter" }, +#endif + { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_SHORT, FIELD_EXTRASAMPLES, + FALSE, FALSE, "ExtraSamples" }, +/* XXX for bogus Adobe Photoshop v2.5 files */ + { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_BYTE, FIELD_EXTRASAMPLES, + FALSE, FALSE, "ExtraSamples" }, + { TIFFTAG_SAMPLEFORMAT, -1,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, + FALSE, FALSE, "SampleFormat" }, + { TIFFTAG_SMINSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMINSAMPLEVALUE, + TRUE, FALSE, "SMinSampleValue" }, + { TIFFTAG_SMAXSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMAXSAMPLEVALUE, + TRUE, FALSE, "SMaxSampleValue" }, +#ifdef YCBCR_SUPPORT /* 6.0 YCbCr tags */ + { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, FIELD_YCBCRCOEFFICIENTS, + FALSE, FALSE, "YCbCrCoefficients" }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, FIELD_YCBCRSUBSAMPLING, + FALSE, FALSE, "YCbCrSubsampling" }, + { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING, + FALSE, FALSE, "YCbCrPositioning" }, +#endif +#ifdef COLORIMETRY_SUPPORT + { TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_RATIONAL, FIELD_REFBLACKWHITE, + TRUE, FALSE, "ReferenceBlackWhite" }, +/* XXX temporarily accept LONG for backwards compatibility */ + { TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_LONG, FIELD_REFBLACKWHITE, + TRUE, FALSE, "ReferenceBlackWhite" }, +#endif +/* begin SGI tags */ + { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, FIELD_EXTRASAMPLES, + FALSE, FALSE, "Matteing" }, + { TIFFTAG_DATATYPE, -2,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, + FALSE, FALSE, "DataType" }, + { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, FIELD_IMAGEDEPTH, + FALSE, FALSE, "ImageDepth" }, + { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDEPTH, + FALSE, FALSE, "ImageDepth" }, + { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, FIELD_TILEDEPTH, + FALSE, FALSE, "TileDepth" }, + { TIFFTAG_TILEDEPTH, 1, 1, TIFF_SHORT, FIELD_TILEDEPTH, + FALSE, FALSE, "TileDepth" }, +/* end SGI tags */ +/* begin Pixar tags */ + { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEFULLWIDTH, + TRUE, FALSE, "ImageFullWidth" }, + { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEFULLLENGTH, + TRUE, FALSE, "ImageFullLength" }, + { TIFFTAG_PIXAR_TEXTUREFORMAT, -1,-1, TIFF_ASCII, FIELD_TEXTUREFORMAT, + TRUE, FALSE, "TextureFormat" }, + { TIFFTAG_PIXAR_WRAPMODES, -1,-1, TIFF_ASCII, FIELD_WRAPMODES, + TRUE, FALSE, "TextureWrapModes" }, + { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, FIELD_FOVCOT, + TRUE, FALSE, "FieldOfViewCotan" }, + { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16,16, TIFF_FLOAT, + FIELD_MATRIX_WORLDTOSCREEN, TRUE, FALSE, "MatrixWorldToScreen" }, + { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16,16, TIFF_FLOAT, + FIELD_MATRIX_WORLDTOCAMERA, TRUE, FALSE, "MatrixWorldToCamera" }, + { TIFFTAG_COPYRIGHT, -1,-1, TIFF_ASCII, FIELD_COPYRIGHT, + TRUE, FALSE, "Copyright" }, +/* end Pixar tags */ +#ifdef IPTC_SUPPORT +#ifdef PHOTOSHOP_SUPPORT + { TIFFTAG_RICHTIFFIPTC, -1,-1, TIFF_LONG, FIELD_RICHTIFFIPTC, + FALSE, TRUE, "RichTIFFIPTC" }, +#else + { TIFFTAG_RICHTIFFIPTC, -1,-3, TIFF_UNDEFINED, FIELD_RICHTIFFIPTC, + FALSE, TRUE, "RichTIFFIPTC" }, +#endif +#endif +#ifdef PHOTOSHOP_SUPPORT + { TIFFTAG_PHOTOSHOP, -1,-3, TIFF_BYTE, FIELD_PHOTOSHOP, + FALSE, TRUE, "Photoshop" }, +#endif +#ifdef ICC_SUPPORT + { TIFFTAG_ICCPROFILE, -1,-3, TIFF_UNDEFINED, FIELD_ICCPROFILE, + FALSE, TRUE, "ICC Profile" }, +#endif + { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, FIELD_STONITS, + FALSE, FALSE, "StoNits" }, +}; +#define N(a) (sizeof (a) / sizeof (a[0])) + +void +_TIFFSetupFieldInfo(TIFF* tif) +{ + if (tif->tif_fieldinfo) { + _TIFFfree(tif, tif->tif_fieldinfo); + tif->tif_nfields = 0; + } + _TIFFMergeFieldInfo(tif, tiffFieldInfo, N(tiffFieldInfo)); +} + +static int +tagCompare(const void* a, const void* b) +{ + const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a; + const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b; + /* NB: be careful of return values for 16-bit platforms */ + if (ta->field_tag != tb->field_tag) + return (ta->field_tag < tb->field_tag ? -1 : 1); + else + return (tb->field_type < ta->field_type ? -1 : 1); +} + +void +_TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n) +{ + TIFFFieldInfo** tp; + int i; + + if (tif->tif_nfields > 0) { + tif->tif_fieldinfo = (TIFFFieldInfo**) + _TIFFrealloc(tif, tif->tif_fieldinfo, + (tif->tif_nfields+n) * sizeof (TIFFFieldInfo*)); + } else { + tif->tif_fieldinfo = (TIFFFieldInfo**) + _TIFFmalloc(tif, n * sizeof (TIFFFieldInfo*)); + } + tp = &tif->tif_fieldinfo[tif->tif_nfields]; + for (i = 0; i < n; i++) + tp[i] = (TIFFFieldInfo*) &info[i]; /* XXX */ + /* + * NB: the core tags are presumed sorted correctly. + */ + if (tif->tif_nfields > 0) + qsort(tif->tif_fieldinfo, (size_t) (tif->tif_nfields += n), + sizeof (TIFFFieldInfo*), tagCompare); + else + tif->tif_nfields += n; +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +void +_TIFFPrintFieldInfo(TIFF* tif, FILE* fd) +{ + int i; + + fprintf(fd, "%s: \n", tif->tif_name); + for (i = 0; i < tif->tif_nfields; i++) { + const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; + fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n" + , i + , (unsigned long) fip->field_tag + , fip->field_readcount, fip->field_writecount + , fip->field_type + , fip->field_bit + , fip->field_oktochange ? "TRUE" : "FALSE" + , fip->field_passcount ? "TRUE" : "FALSE" + , fip->field_name + ); + } +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +const int tiffDataWidth[] = { + 1, /* nothing */ + 1, /* TIFF_BYTE */ + 1, /* TIFF_ASCII */ + 2, /* TIFF_SHORT */ + 4, /* TIFF_LONG */ + 8, /* TIFF_RATIONAL */ + 1, /* TIFF_SBYTE */ + 1, /* TIFF_UNDEFINED */ + 2, /* TIFF_SSHORT */ + 4, /* TIFF_SLONG */ + 8, /* TIFF_SRATIONAL */ + 4, /* TIFF_FLOAT */ + 8, /* TIFF_DOUBLE */ +}; + +/* + * Return nearest TIFFDataType to the sample type of an image. + */ +TIFFDataType +_TIFFSampleToTagType(TIFF* tif) +{ + int bps = (int) TIFFhowmany(tif->tif_dir.td_bitspersample, 8); + + switch (tif->tif_dir.td_sampleformat) { + case SAMPLEFORMAT_IEEEFP: + return (bps == 4 ? TIFF_FLOAT : TIFF_DOUBLE); + case SAMPLEFORMAT_INT: + return (bps <= 1 ? TIFF_SBYTE : + bps <= 2 ? TIFF_SSHORT : TIFF_SLONG); + case SAMPLEFORMAT_UINT: + return (bps <= 1 ? TIFF_BYTE : + bps <= 2 ? TIFF_SHORT : TIFF_LONG); + case SAMPLEFORMAT_VOID: + return (TIFF_UNDEFINED); + } + /*NOTREACHED*/ + return (TIFF_UNDEFINED); +} + +const TIFFFieldInfo* +_TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt) +{ + static const TIFFFieldInfo *last = NULL; + int i, n; + + if (last && last->field_tag == tag && + (dt == TIFF_ANY || dt == last->field_type)) + return (last); + /* NB: if table gets big, use sorted search (e.g. binary search) */ + for (i = 0, n = tif->tif_nfields; i < n; i++) { + const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; + if (fip->field_tag == tag && + (dt == TIFF_ANY || fip->field_type == dt)) + return (last = fip); + } + return ((const TIFFFieldInfo *)0); +} + +#include +#include + +const TIFFFieldInfo* +_TIFFFieldWithTag(TIFF* tif, ttag_t tag) +{ + const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); + if (!fip) { + TIFFError("TIFFFieldWithTag", + "Internal error, unknown tag 0x%x", (tif_int) tag); + assert(fip != NULL); + /*NOTREACHED*/ + } + return (fip); +} diff --git a/src/libs/pdflib/libs/tiff/tif_dirread.c b/src/libs/pdflib/libs/tiff/tif_dirread.c new file mode 100644 index 0000000000..960e5b19ed --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_dirread.c @@ -0,0 +1,1383 @@ +/* PDFlib GmbH cvsid: $Id: tif_dirread.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Directory Read Support Routines. + */ +#include "tiffiop.h" + +#define IGNORE 0 /* tag placeholder used below */ + +#if HAVE_IEEEFP +#define TIFFCvtIEEEFloatToNative(tif, n, fp) +#define TIFFCvtIEEEDoubleToNative(tif, n, dp) +#else +extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); +extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); +#endif + +static void EstimateStripByteCounts(TIFF*, TIFFDirEntry*, uint16); +static void MissingRequired(TIFF*, const char*); +static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); +static tsize_t TIFFFetchData(TIFF*, TIFFDirEntry*, char*); +static tsize_t TIFFFetchString(TIFF*, TIFFDirEntry*, char*); +static float TIFFFetchRational(TIFF*, TIFFDirEntry*); +static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*); +static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, int*); +static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*); +static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*); +static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**); +static int TIFFFetchExtraSamples(TIFF*, TIFFDirEntry*); +static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*); +static float TIFFFetchFloat(TIFF*, TIFFDirEntry*); +static int TIFFFetchFloatArray(TIFF*, TIFFDirEntry*, float*); +static int TIFFFetchDoubleArray(TIFF*, TIFFDirEntry*, double*); +static int TIFFFetchAnyArray(TIFF*, TIFFDirEntry*, double*); +static int TIFFFetchShortPair(TIFF*, TIFFDirEntry*); +static void ChopUpSingleUncompressedStrip(TIFF*); + +static char * +CheckMalloc(TIFF* tif, tsize_t n, const char* what) +{ + char *cp = (char*)_TIFFmalloc(tif, n); + if (cp == NULL) + TIFFError(tif->tif_name, "No space %s", what); + return (cp); +} + +/* + * Read the next TIFF directory from a file + * and convert it to the internal format. + * We read directories sequentially. + */ +int +TIFFReadDirectory(TIFF* tif) +{ + register TIFFDirEntry* dp; + register int n; + register TIFFDirectory* td; + TIFFDirEntry* dir; + int iv; + long v; + double dv; + const TIFFFieldInfo* fip; + int fix; + uint16 dircount; + toff_t nextdiroff; + char* cp; + int diroutoforderwarning = 0; + + tif->tif_diroff = tif->tif_nextdiroff; + if (tif->tif_diroff == 0) /* no more directories */ + return (0); + /* + * Cleanup any previous compression state. + */ + (*tif->tif_cleanup)(tif); + tif->tif_curdir++; + nextdiroff = 0; + if (!isMapped(tif)) { + if (!SeekOK(tif, tif->tif_diroff)) { + TIFFError(tif->tif_name, + "Seek error accessing TIFF directory"); + return (0); + } + if (!ReadOK(tif, &dircount, sizeof (uint16))) { + TIFFError(tif->tif_name, + "Can not read TIFF directory count"); + return (0); + } + + /* + * PDFlib GmbH: EFAX (*.jfx) files have a dircount of 0, + * and cannot be processed by TIFFlib. + */ + if (dircount == 0) + return (0); + + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + dir = (TIFFDirEntry *)CheckMalloc(tif, + dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); + if (dir == NULL) + return (0); + if (!ReadOK(tif, dir, dircount*sizeof (TIFFDirEntry))) { + TIFFError(tif->tif_name, "Can not read TIFF directory"); + goto bad; + } + /* + * Read offset to next directory for sequential scans. + */ + (void) ReadOK(tif, &nextdiroff, ((tsize_t) sizeof (uint32))); + } else { + toff_t off = tif->tif_diroff; + + if (off + sizeof (uint16) > tif->tif_size) { + TIFFError(tif->tif_name, + "Can not read TIFF directory count"); + return (0); + } else + _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof(uint16)); + off += sizeof (uint16); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + dir = (TIFFDirEntry *)CheckMalloc(tif, + dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); + if (dir == NULL) + return (0); + if (off + dircount*sizeof (TIFFDirEntry) > tif->tif_size) { + TIFFError(tif->tif_name, "Can not read TIFF directory"); + goto bad; + } else + _TIFFmemcpy(dir, tif->tif_base + off, + dircount*sizeof (TIFFDirEntry)); + off += dircount* sizeof (TIFFDirEntry); + if (off + sizeof (uint32) <= tif->tif_size) + _TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof(uint32)); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextdiroff); + tif->tif_nextdiroff = nextdiroff; + + tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ + /* + * Setup default value and then make a pass over + * the fields to check type and tag information, + * and to extract info required to size data + * structures. A second pass is made afterwards + * to read in everthing not taken in the first pass. + */ + td = &tif->tif_dir; + /* free any old stuff and reinit */ + TIFFFreeDirectory(tif); + TIFFDefaultDirectory(tif); + /* + * Electronic Arts writes gray-scale TIFF files + * without a PlanarConfiguration directory entry. + * Thus we setup a default value here, even though + * the TIFF spec says there is no default value. + */ + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + + /* + * Sigh, we must make a separate pass through the + * directory for the following reason: + * + * We must process the Compression tag in the first pass + * in order to merge in codec-private tag definitions (otherwise + * we may get complaints about unknown tags). However, the + * Compression tag may be dependent on the SamplesPerPixel + * tag value because older TIFF specs permited Compression + * to be written as a SamplesPerPixel-count tag entry. + * Thus if we don't first figure out the correct SamplesPerPixel + * tag value then we may end up ignoring the Compression tag + * value because it has an incorrect count value (if the + * true value of SamplesPerPixel is not 1). + * + * It sure would have been nice if Aldus had really thought + * this stuff through carefully. + */ + for (dp = dir, n = dircount; n > 0; n--, dp++) { + if (tif->tif_flags & TIFF_SWAB) { + TIFFSwabArrayOfShort(&dp->tdir_tag, 2); + TIFFSwabArrayOfLong(&dp->tdir_count, 2); + } + if (dp->tdir_tag == TIFFTAG_SAMPLESPERPIXEL) { + if (!TIFFFetchNormalTag(tif, dp)) + goto bad; + dp->tdir_tag = IGNORE; + } + } + /* + * First real pass over the directory. + */ + fix = 0; + for (dp = dir, n = dircount; n > 0; n--, dp++) { + + /* + * Find the field information entry for this tag. + * Added check for tags to ignore ... [BFC] + */ + if( TIFFReassignTagToIgnore(TIS_EXTRACT, dp->tdir_tag) ) + dp->tdir_tag = IGNORE; + + if (dp->tdir_tag == IGNORE) + continue; + + /* + * Silicon Beach (at least) writes unordered + * directory tags (violating the spec). Handle + * it here, but be obnoxious (maybe they'll fix it?). + */ + if (dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) { + if (!diroutoforderwarning) { + TIFFWarning(tif->tif_name, + "invalid TIFF directory; tags are not sorted in ascending order"); + diroutoforderwarning = 1; + } + fix = 0; /* O(n^2) */ + } + while (fix < tif->tif_nfields && + tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) + fix++; + if (fix == tif->tif_nfields || + tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { + TIFFWarning(tif->tif_name, + "unknown field with tag %d (0x%x) ignored", + dp->tdir_tag, dp->tdir_tag); + dp->tdir_tag = IGNORE; + fix = 0; /* restart search */ + continue; + } + /* + * Null out old tags that we ignore. + */ + if (tif->tif_fieldinfo[fix]->field_bit == FIELD_IGNORE) { + ignore: + dp->tdir_tag = IGNORE; + continue; + } + /* + * Check data type. + */ + fip = tif->tif_fieldinfo[fix]; + while (dp->tdir_type != (tif_short) fip->field_type) { + if (fip->field_type == TIFF_ANY) /* wildcard */ + break; + fip++, fix++; + if (fix == tif->tif_nfields || + fip->field_tag != dp->tdir_tag) { + TIFFWarning(tif->tif_name, + "wrong data type %d for \"%s\"; tag ignored", + dp->tdir_type, fip[-1].field_name); + goto ignore; + } + } + /* + * Check count if known in advance. + */ + if (fip->field_readcount != TIFF_VARIABLE) { + uint32 expected = (fip->field_readcount == TIFF_SPP) ? + (uint32) td->td_samplesperpixel : + (uint32) fip->field_readcount; + if (!CheckDirCount(tif, dp, expected)) + goto ignore; + } + + switch (dp->tdir_tag) { + case TIFFTAG_COMPRESSION: + /* + * The 5.0 spec says the Compression tag has + * one value, while earlier specs say it has + * one value per sample. Because of this, we + * accept the tag if one value is supplied. + */ + if (dp->tdir_count == 1) { + v = TIFFExtractData(tif, + dp->tdir_type, dp->tdir_offset); + if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) + goto bad; + break; + } + if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || + !TIFFSetField(tif, dp->tdir_tag, iv)) + goto bad; + dp->tdir_tag = IGNORE; + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEOFFSETS: + case TIFFTAG_TILEBYTECOUNTS: + TIFFSetFieldBit(tif, fip->field_bit); + break; + case TIFFTAG_IMAGEWIDTH: + case TIFFTAG_IMAGELENGTH: + case TIFFTAG_IMAGEDEPTH: + case TIFFTAG_TILELENGTH: + case TIFFTAG_TILEWIDTH: + case TIFFTAG_TILEDEPTH: + case TIFFTAG_PLANARCONFIG: + case TIFFTAG_ROWSPERSTRIP: + if (!TIFFFetchNormalTag(tif, dp)) + goto bad; + dp->tdir_tag = IGNORE; + break; + case TIFFTAG_EXTRASAMPLES: + (void) TIFFFetchExtraSamples(tif, dp); + dp->tdir_tag = IGNORE; + break; + } + } + + /* + * Allocate directory structure and setup defaults. + */ + if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { + MissingRequired(tif, "ImageLength"); + goto bad; + } + if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { + MissingRequired(tif, "PlanarConfiguration"); + goto bad; + } + /* + * Setup appropriate structures (by strip or by tile) + */ + if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { + td->td_nstrips = TIFFNumberOfStrips(tif); + td->td_tilewidth = td->td_imagewidth; + td->td_tilelength = td->td_rowsperstrip; + td->td_tiledepth = td->td_imagedepth; + tif->tif_flags &= ~TIFF_ISTILED; + } else { + td->td_nstrips = TIFFNumberOfTiles(tif); + tif->tif_flags |= TIFF_ISTILED; + } + td->td_stripsperimage = td->td_nstrips; + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + td->td_stripsperimage /= td->td_samplesperpixel; + if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { + MissingRequired(tif, + isTiled(tif) ? "TileOffsets" : "StripOffsets"); + goto bad; + } + + /* + * Second pass: extract other information. + */ + for (dp = dir, n = dircount; n > 0; n--, dp++) { + if (dp->tdir_tag == IGNORE) + continue; + switch (dp->tdir_tag) { + case TIFFTAG_MINSAMPLEVALUE: + case TIFFTAG_MAXSAMPLEVALUE: + case TIFFTAG_BITSPERSAMPLE: + /* + * The 5.0 spec says the Compression tag has + * one value, while earlier specs say it has + * one value per sample. Because of this, we + * accept the tag if one value is supplied. + * + * The MinSampleValue, MaxSampleValue and + * BitsPerSample tags are supposed to be written + * as one value/sample, but some vendors incorrectly + * write one value only -- so we accept that + * as well (yech). + */ + if (dp->tdir_count == 1) { + v = TIFFExtractData(tif, + dp->tdir_type, dp->tdir_offset); + if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) + goto bad; + break; + } + /* fall thru... */ + case TIFFTAG_DATATYPE: + case TIFFTAG_SAMPLEFORMAT: + if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || + !TIFFSetField(tif, dp->tdir_tag, iv)) + goto bad; + break; + case TIFFTAG_SMINSAMPLEVALUE: + case TIFFTAG_SMAXSAMPLEVALUE: + if (!TIFFFetchPerSampleAnys(tif, dp, &dv) || + !TIFFSetField(tif, dp->tdir_tag, dv)) + goto bad; + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_TILEOFFSETS: + if (!TIFFFetchStripThing(tif, dp, + td->td_nstrips, &td->td_stripoffset)) + goto bad; + break; + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEBYTECOUNTS: + if (!TIFFFetchStripThing(tif, dp, + td->td_nstrips, &td->td_stripbytecount)) + goto bad; + break; + case TIFFTAG_COLORMAP: + case TIFFTAG_TRANSFERFUNCTION: + /* + * TransferFunction can have either 1x or 3x data + * values; Colormap can have only 3x items. + */ + v = 1L<td_bitspersample; + if (dp->tdir_tag == TIFFTAG_COLORMAP || + dp->tdir_count != (uint32) v) { + if (!CheckDirCount(tif, dp, (uint32)(3*v))) + break; + } + v *= sizeof (uint16); + cp = CheckMalloc(tif, dp->tdir_count * sizeof (uint16), + "to read \"TransferFunction\" tag"); + if (cp != NULL) { + if (TIFFFetchData(tif, dp, cp)) { + /* + * This deals with there being only + * one array to apply to all samples. + */ + uint32 c = + (uint32)1 << td->td_bitspersample; + if (dp->tdir_count == c) + v = 0; + TIFFSetField(tif, dp->tdir_tag, + cp, cp+v, cp+2*v); + } + _TIFFfree(tif, cp); + } + break; + case TIFFTAG_PAGENUMBER: + case TIFFTAG_HALFTONEHINTS: + case TIFFTAG_YCBCRSUBSAMPLING: + case TIFFTAG_DOTRANGE: + (void) TIFFFetchShortPair(tif, dp); + break; +#ifdef COLORIMETRY_SUPPORT + case TIFFTAG_REFERENCEBLACKWHITE: + (void) TIFFFetchRefBlackWhite(tif, dp); + break; +#endif +/* BEGIN REV 4.0 COMPATIBILITY */ + case TIFFTAG_OSUBFILETYPE: + v = 0; + switch (TIFFExtractData(tif, dp->tdir_type, + dp->tdir_offset)) { + case OFILETYPE_REDUCEDIMAGE: + v = FILETYPE_REDUCEDIMAGE; + break; + case OFILETYPE_PAGE: + v = FILETYPE_PAGE; + break; + } + if (v) + (void) TIFFSetField(tif, + TIFFTAG_SUBFILETYPE, (int)v); + break; +/* END REV 4.0 COMPATIBILITY */ + default: + (void) TIFFFetchNormalTag(tif, dp); + break; + } + } + /* + * Verify Palette image has a Colormap. + */ + if (td->td_photometric == PHOTOMETRIC_PALETTE && + !TIFFFieldSet(tif, FIELD_COLORMAP)) { + MissingRequired(tif, "Colormap"); + goto bad; + } + /* + * Attempt to deal with a missing StripByteCounts tag. + */ + if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { + /* + * Some manufacturers violate the spec by not giving + * the size of the strips. In this case, assume there + * is one uncompressed strip of data. + */ + if ((td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_nstrips > 1) || + (td->td_planarconfig == PLANARCONFIG_SEPARATE && + td->td_nstrips != td->td_samplesperpixel)) { + MissingRequired(tif, "StripByteCounts"); + goto bad; + } + TIFFWarning(tif->tif_name, +"TIFF directory is missing required \"%s\" field, calculating from imagelength", + _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); + EstimateStripByteCounts(tif, dir, dircount); +#define BYTECOUNTLOOKSBAD \ + ((td->td_stripbytecount[0] == 0 && td->td_stripoffset[0] != 0) || \ + (td->td_compression == COMPRESSION_NONE && \ + td->td_stripbytecount[0] > TIFFGetFileSize(tif) - td->td_stripoffset[0])) + } else if (td->td_nstrips == 1 && BYTECOUNTLOOKSBAD) { + /* + * Plexus (and others) sometimes give a value + * of zero for a tag when they don't know what + * the correct value is! Try and handle the + * simple case of estimating the size of a one + * strip image. + */ + TIFFWarning(tif->tif_name, + "Bogus \"%s\" field, ignoring and calculating from imagelength", + _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); + EstimateStripByteCounts(tif, dir, dircount); + } + if (dir) + _TIFFfree(tif, (char *)dir); + if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) + td->td_maxsamplevalue = (uint16)((1L<td_bitspersample)-1); + /* + * Setup default compression scheme. + */ + if (!TIFFFieldSet(tif, FIELD_COMPRESSION)) + TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + /* + * Some manufacturers make life difficult by writing + * large amounts of uncompressed data as a single strip. + * This is contrary to the recommendations of the spec. + * The following makes an attempt at breaking such images + * into strips closer to the recommended 8k bytes. A + * side effect, however, is that the RowsPerStrip tag + * value may be changed. + */ + if (td->td_nstrips == 1 && td->td_compression == COMPRESSION_NONE && + (tif->tif_flags & (TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP) + ChopUpSingleUncompressedStrip(tif); + /* + * Reinitialize i/o since we are starting on a new directory. + */ + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (tstrip_t) -1; + tif->tif_col = (uint32) -1; + tif->tif_curtile = (ttile_t) -1; + tif->tif_tilesize = TIFFTileSize(tif); + tif->tif_scanlinesize = TIFFScanlineSize(tif); + return (1); +bad: + if (dir) + _TIFFfree(tif, dir); + return (0); +} + +static void +EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) +{ + register TIFFDirEntry *dp; + register TIFFDirectory *td = &tif->tif_dir; + uint16 i; + + if (td->td_stripbytecount) + _TIFFfree(tif, td->td_stripbytecount); + td->td_stripbytecount = (uint32*) + CheckMalloc(tif, td->td_nstrips * sizeof (uint32), + "for \"StripByteCounts\" array"); + if (td->td_compression != COMPRESSION_NONE) { + uint32 space = (uint32)(sizeof (TIFFHeader) + + sizeof (uint16) + + (dircount * sizeof (TIFFDirEntry)) + + sizeof (uint32)); + toff_t filesize = TIFFGetFileSize(tif); + uint16 n; + + /* calculate amount of space used by indirect values */ + for (dp = dir, n = dircount; n > 0; n--, dp++) { + uint32 cc = dp->tdir_count*tiffDataWidth[dp->tdir_type]; + if (cc > sizeof (uint32)) + space += cc; + } + space = filesize - space; + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + space /= td->td_samplesperpixel; + for (i = 0; i < td->td_nstrips; i++) + td->td_stripbytecount[i] = space; + /* + * This gross hack handles the case were the offset to + * the last strip is past the place where we think the strip + * should begin. Since a strip of data must be contiguous, + * it's safe to assume that we've overestimated the amount + * of data in the strip and trim this number back accordingly. + */ + i--; + if (((toff_t)(td->td_stripoffset[i]+td->td_stripbytecount[i])) + > filesize) + td->td_stripbytecount[i] = + filesize - td->td_stripoffset[i]; + } else { + uint32 rowbytes = TIFFScanlineSize(tif); + uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; + for (i = 0; i < td->td_nstrips; i++) + td->td_stripbytecount[i] = rowbytes*rowsperstrip; + } + TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); + if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) + td->td_rowsperstrip = td->td_imagelength; +} + +static void +MissingRequired(TIFF* tif, const char* tagname) +{ + TIFFError(tif->tif_name, + "TIFF directory is missing required \"%s\" field", tagname); +} + +/* + * Check the count field of a directory + * entry against a known value. The caller + * is expected to skip/ignore the tag if + * there is a mismatch. + */ +static int +CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) +{ + if (count != dir->tdir_count) { + TIFFWarning(tif->tif_name, + "incorrect count for field \"%s\" (%lu, expecting %lu); tag ignored", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, + dir->tdir_count, count); + return (0); + } + return (1); +} + +/* + * Fetch a contiguous directory item. + */ +static tsize_t +TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp) +{ + int w = tiffDataWidth[dir->tdir_type]; + tsize_t cc = dir->tdir_count * w; + + if (!isMapped(tif)) { + if (!SeekOK(tif, dir->tdir_offset)) + goto bad; + if (!ReadOK(tif, cp, cc)) + goto bad; + } else { + if (dir->tdir_offset + cc > tif->tif_size) + goto bad; + _TIFFmemcpy(cp, tif->tif_base + dir->tdir_offset, cc); + } + if (tif->tif_flags & TIFF_SWAB) { + switch (dir->tdir_type) { + case TIFF_SHORT: + case TIFF_SSHORT: + TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); + break; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); + break; + case TIFF_DOUBLE: + TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); + break; + } + } + return (cc); +bad: + TIFFError(tif->tif_name, "Error fetching data for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + return ((tsize_t) 0); +} + +/* + * Fetch an ASCII item from the file. + */ +static tsize_t +TIFFFetchString(TIFF* tif, TIFFDirEntry* dir, char* cp) +{ + if (dir->tdir_count <= 4) { + uint32 l = dir->tdir_offset; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&l); + _TIFFmemcpy(cp, &l, dir->tdir_count); + return (1); + } + return (TIFFFetchData(tif, dir, cp)); +} + +/* + * Convert numerator+denominator to float. + */ +static int +cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv) +{ + if (denom == 0) { + TIFFError(tif->tif_name, + "%s: Rational with zero denominator (num = %lu)", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num); + return (0); + } else { + if (dir->tdir_type == TIFF_RATIONAL) + *rv = ((float)num / (float)denom); + else + *rv = ((float)(int32)num / (float)(int32)denom); + return (1); + } +} + +/* + * Fetch a rational item from the file + * at offset off and return the value + * as a floating point number. + */ +static float +TIFFFetchRational(TIFF* tif, TIFFDirEntry* dir) +{ + uint32 l[2]; + float v; + + return (!TIFFFetchData(tif, dir, (char *)l) || + !cvtRational(tif, dir, l[0], l[1], &v) ? 1.0f : v); +} + +/* + * Fetch a single floating point value + * from the offset field and return it + * as a native float. + */ +static float +TIFFFetchFloat(TIFF* tif, TIFFDirEntry* dir) +{ + long l = TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); + float v = *(float*) &l; + TIFFCvtIEEEFloatToNative(tif, 1, &v); + return (v); +} + +/* + * Fetch an array of BYTE or SBYTE values. + */ +static int +TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) +{ + if (dir->tdir_count <= 4) { + /* + * Extract data from offset field. + */ + if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { + switch (dir->tdir_count) { + case 4: v[3] = (uint16)(dir->tdir_offset & 0xff); + case 3: v[2] = (uint16)((dir->tdir_offset >> 8) & 0xff); + case 2: v[1] = (uint16)((dir->tdir_offset >> 16) & 0xff); + case 1: v[0] = (uint16)(dir->tdir_offset >> 24); + } + } else { + switch (dir->tdir_count) { + case 4: v[3] = (uint16)(dir->tdir_offset >> 24); + case 3: v[2] = (uint16)((dir->tdir_offset >> 16) & 0xff); + case 2: v[1] = (uint16)((dir->tdir_offset >> 8) & 0xff); + case 1: v[0] = (uint16)(dir->tdir_offset & 0xff); + } + } + return (1); + } else + return (TIFFFetchData(tif, dir, (char*) v) != 0); /* XXX */ +} + +/* + * Fetch an array of SHORT or SSHORT values. + */ +static int +TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) +{ + if (dir->tdir_count <= 2) { + if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { + switch (dir->tdir_count) { + case 2: v[1] = (uint16) (dir->tdir_offset & 0xffff); + case 1: v[0] = (uint16) (dir->tdir_offset >> 16); + } + } else { + switch (dir->tdir_count) { + case 2: v[1] = (uint16) (dir->tdir_offset >> 16); + case 1: v[0] = (uint16) (dir->tdir_offset & 0xffff); + } + } + return (1); + } else + return (TIFFFetchData(tif, dir, (char *)v) != 0); +} + +/* + * Fetch a pair of SHORT or BYTE values. + */ +static int +TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir) +{ + uint16 v[2]; + int ok = 0; + + switch (dir->tdir_type) { + case TIFF_SHORT: + case TIFF_SSHORT: + ok = TIFFFetchShortArray(tif, dir, v); + break; + case TIFF_BYTE: + case TIFF_SBYTE: + ok = TIFFFetchByteArray(tif, dir, v); + break; + } + if (ok) + TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); + return (ok); +} + +/* + * Fetch an array of LONG or SLONG values. + */ +static int +TIFFFetchLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v) +{ + if (dir->tdir_count == 1) { + v[0] = dir->tdir_offset; + return (1); + } else + return (TIFFFetchData(tif, dir, (char*) v) != 0); +} + +/* + * Fetch an array of RATIONAL or SRATIONAL values. + */ +static int +TIFFFetchRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v) +{ + int ok = 0; + uint32* l; + + l = (uint32*)CheckMalloc(tif, + dir->tdir_count*tiffDataWidth[dir->tdir_type], + "to fetch array of rationals"); + if (l) { + if (TIFFFetchData(tif, dir, (char *)l)) { + uint32 i; + for (i = 0; i < dir->tdir_count; i++) { + ok = cvtRational(tif, dir, + l[2*i+0], l[2*i+1], &v[i]); + if (!ok) + break; + } + } + _TIFFfree(tif, (char *)l); + } + return (ok); +} + +/* + * Fetch an array of FLOAT values. + */ +static int +TIFFFetchFloatArray(TIFF* tif, TIFFDirEntry* dir, float* v) +{ + + if (dir->tdir_count == 1) { + v[0] = *(float*) &dir->tdir_offset; + TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); + return (1); + } else if (TIFFFetchData(tif, dir, (char*) v)) { + TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); + return (1); + } else + return (0); +} + +/* + * Fetch an array of DOUBLE values. + */ +static int +TIFFFetchDoubleArray(TIFF* tif, TIFFDirEntry* dir, double* v) +{ + if (TIFFFetchData(tif, dir, (char*) v)) { + TIFFCvtIEEEDoubleToNative(tif, dir->tdir_count, v); + return (1); + } else + return (0); +} + +/* + * Fetch an array of ANY values. The actual values are + * returned as doubles which should be able hold all the + * types. Yes, there really should be an tany_t to avoid + * this potential non-portability ... Note in particular + * that we assume that the double return value vector is + * large enough to read in any fundamental type. We use + * that vector as a buffer to read in the base type vector + * and then convert it in place to double (from end + * to front of course). + */ +static int +TIFFFetchAnyArray(TIFF* tif, TIFFDirEntry* dir, double* v) +{ + int i; + + switch (dir->tdir_type) { + case TIFF_BYTE: + case TIFF_SBYTE: + if (!TIFFFetchByteArray(tif, dir, (uint16*) v)) + return (0); + if (dir->tdir_type == TIFF_BYTE) { + uint16* vp = (uint16*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } else { + int16* vp = (int16*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_SHORT: + case TIFF_SSHORT: + if (!TIFFFetchShortArray(tif, dir, (uint16*) v)) + return (0); + if (dir->tdir_type == TIFF_SHORT) { + uint16* vp = (uint16*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } else { + int16* vp = (int16*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_LONG: + case TIFF_SLONG: + if (!TIFFFetchLongArray(tif, dir, (uint32*) v)) + return (0); + if (dir->tdir_type == TIFF_LONG) { + uint32* vp = (uint32*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } else { + int32* vp = (int32*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + if (!TIFFFetchRationalArray(tif, dir, (float*) v)) + return (0); + { float* vp = (float*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_FLOAT: + if (!TIFFFetchFloatArray(tif, dir, (float*) v)) + return (0); + { float* vp = (float*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_DOUBLE: + return (TIFFFetchDoubleArray(tif, dir, (double*) v)); + default: + /* TIFF_NOTYPE */ + /* TIFF_ASCII */ + /* TIFF_UNDEFINED */ + TIFFError(tif->tif_name, + "Cannot read TIFF_ANY type %d for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + return (0); + } + return (1); +} + +/* + * Fetch a tag that is not handled by special case code. + */ +static int +TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp) +{ + static const char mesg[] = "to fetch tag value"; + int ok = 0; + const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dp->tdir_tag); + + if (dp->tdir_count > 1) { /* array of values */ + char* cp = NULL; + + switch (dp->tdir_type) { + case TIFF_BYTE: + case TIFF_SBYTE: + /* NB: always expand BYTE values to shorts */ + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (uint16), mesg); + ok = cp && TIFFFetchByteArray(tif, dp, (uint16*) cp); + break; + case TIFF_SHORT: + case TIFF_SSHORT: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (uint16), mesg); + ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp); + break; + case TIFF_LONG: + case TIFF_SLONG: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (uint32), mesg); + ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (float), mesg); + ok = cp && TIFFFetchRationalArray(tif, dp, (float*) cp); + break; + case TIFF_FLOAT: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (float), mesg); + ok = cp && TIFFFetchFloatArray(tif, dp, (float*) cp); + break; + case TIFF_DOUBLE: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (double), mesg); + ok = cp && TIFFFetchDoubleArray(tif, dp, (double*) cp); + break; + case TIFF_ASCII: + case TIFF_UNDEFINED: /* bit of a cheat... */ + /* + * Some vendors write strings w/o the trailing + * NULL byte, so always append one just in case. + */ + cp = CheckMalloc(tif, dp->tdir_count+1, mesg); + if( (ok = (cp && TIFFFetchString(tif, dp, cp))) != 0 ) + cp[dp->tdir_count] = '\0'; /* XXX */ + break; + } + if (ok) { + ok = (fip->field_passcount ? + TIFFSetField(tif, dp->tdir_tag, dp->tdir_count, cp) + : TIFFSetField(tif, dp->tdir_tag, cp)); + } + if (cp != NULL) + _TIFFfree(tif, cp); + } else if (CheckDirCount(tif, dp, 1)) { /* singleton value */ + switch (dp->tdir_type) { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + /* + * If the tag is also acceptable as a LONG or SLONG + * then TIFFSetField will expect an uint32 parameter + * passed to it (through varargs). Thus, for machines + * where sizeof (int) != sizeof (uint32) we must do + * a careful check here. It's hard to say if this + * is worth optimizing. + * + * NB: We use TIFFFieldWithTag here knowing that + * it returns us the first entry in the table + * for the tag and that that entry is for the + * widest potential data type the tag may have. + */ + { TIFFDataType type = fip->field_type; + if (type != TIFF_LONG && type != TIFF_SLONG) { + uint16 v = (uint16) + TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); + ok = (fip->field_passcount ? + TIFFSetField(tif, dp->tdir_tag, 1, &v) + : TIFFSetField(tif, dp->tdir_tag, v)); + break; + } + } + /* fall thru... */ + case TIFF_LONG: + case TIFF_SLONG: + { uint32 v32 = + TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); + ok = (fip->field_passcount ? + TIFFSetField(tif, dp->tdir_tag, 1, &v32) + : TIFFSetField(tif, dp->tdir_tag, v32)); + } + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + { float v = (dp->tdir_type == TIFF_FLOAT ? + TIFFFetchFloat(tif, dp) + : TIFFFetchRational(tif, dp)); + ok = (fip->field_passcount ? + TIFFSetField(tif, dp->tdir_tag, 1, &v) + : TIFFSetField(tif, dp->tdir_tag, v)); + } + break; + case TIFF_DOUBLE: + { double v; + ok = (TIFFFetchDoubleArray(tif, dp, &v) && + (fip->field_passcount ? + TIFFSetField(tif, dp->tdir_tag, 1, &v) + : TIFFSetField(tif, dp->tdir_tag, v)) + ); + } + break; + case TIFF_ASCII: + case TIFF_UNDEFINED: /* bit of a cheat... */ + { char c[2]; + if( (ok = (TIFFFetchString(tif, dp, c) != 0)) != 0 ){ + c[1] = '\0'; /* XXX paranoid */ + ok = TIFFSetField(tif, dp->tdir_tag, c); + } + } + break; + } + } + return (ok); +} + +#define NITEMS(x) (sizeof (x) / sizeof (x[0])) +/* + * Fetch samples/pixel short values for + * the specified tag and verify that + * all values are the same. + */ +static int +TIFFFetchPerSampleShorts(TIFF* tif, TIFFDirEntry* dir, int* pl) +{ + int samples = tif->tif_dir.td_samplesperpixel; + int status = 0; + + if (CheckDirCount(tif, dir, (uint32) samples)) { + uint16 buf[10]; + uint16* v = buf; + + if (samples > (int)NITEMS(buf)) + v=(uint16*) _TIFFmalloc(tif, samples * sizeof (uint16)); + if (TIFFFetchShortArray(tif, dir, v)) { + int i; + for (i = 1; i < samples; i++) + if (v[i] != v[0]) { + TIFFError(tif->tif_name, + "Cannot handle different per-sample values for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + goto bad; + } + *pl = v[0]; + status = 1; + } + bad: + if (v != buf) + _TIFFfree(tif, (char*) v); + } + return (status); +} + +/* + * Fetch samples/pixel ANY values for + * the specified tag and verify that + * all values are the same. + */ +static int +TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl) +{ + int samples = (int) tif->tif_dir.td_samplesperpixel; + int status = 0; + + if (CheckDirCount(tif, dir, (uint32) samples)) { + double buf[10]; + double* v = buf; + + if (samples > (int)NITEMS(buf)) + v=(double*) _TIFFmalloc(tif, samples * sizeof (double)); + if (TIFFFetchAnyArray(tif, dir, v)) { + int i; + for (i = 1; i < samples; i++) + if (v[i] != v[0]) { + TIFFError(tif->tif_name, + "Cannot handle different per-sample values for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + goto bad; + } + *pl = v[0]; + status = 1; + } + bad: + if (v != buf) + _TIFFfree(tif, v); + } + return (status); +} +#undef NITEMS + +/* + * Fetch a set of offsets or lengths. + * While this routine says "strips", + * in fact it's also used for tiles. + */ +static int +TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp) +{ + register uint32* lp; + int status; + + if (!CheckDirCount(tif, dir, (uint32) nstrips)) + return (0); + /* + * Allocate space for strip information. + */ + if (*lpp == NULL && + (*lpp = (uint32 *)CheckMalloc(tif, + nstrips * sizeof (uint32), "for strip array")) == NULL) + return (0); + lp = *lpp; + if (dir->tdir_type == (int)TIFF_SHORT) { + /* + * Handle uint16->uint32 expansion. + */ + uint16* dp = (uint16*) CheckMalloc(tif, + dir->tdir_count* sizeof (uint16), "to fetch strip tag"); + if (dp == NULL) + return (0); + if( (status = TIFFFetchShortArray(tif, dir, dp)) != 0 ) { + register uint16* wp = dp; + while (nstrips-- > 0) + *lp++ = *wp++; + } + _TIFFfree(tif, (char*) dp); + } else + status = TIFFFetchLongArray(tif, dir, lp); + return (status); +} + +#define NITEMS(x) (sizeof (x) / sizeof (x[0])) +/* + * Fetch and set the ExtraSamples tag. + */ +static int +TIFFFetchExtraSamples(TIFF* tif, TIFFDirEntry* dir) +{ + uint16 buf[10]; + uint16* v = buf; + int status; + + if (dir->tdir_count > NITEMS(buf)) + v=(uint16*) _TIFFmalloc(tif, dir->tdir_count * sizeof (uint16)); + if (dir->tdir_type == TIFF_BYTE) + status = TIFFFetchByteArray(tif, dir, v); + else + status = TIFFFetchShortArray(tif, dir, v); + if (status) + status = TIFFSetField(tif, dir->tdir_tag, dir->tdir_count, v); + if (v != buf) + _TIFFfree(tif, (char*) v); + return (status); +} +#undef NITEMS + +#ifdef COLORIMETRY_SUPPORT +/* + * Fetch and set the RefBlackWhite tag. + */ +static int +TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir) +{ + static const char mesg[] = "for \"ReferenceBlackWhite\" array"; + char* cp; + int ok; + + if (dir->tdir_type == TIFF_RATIONAL) + return (TIFFFetchNormalTag(tif, dir)); + /* + * Handle LONG's for backward compatibility. + */ + cp = CheckMalloc(tif, dir->tdir_count * sizeof (uint32), mesg); + if( (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) != 0) { + float* fp = (float*) + CheckMalloc(tif, dir->tdir_count * sizeof (float), mesg); + if( (ok = (fp != NULL)) != 0 ) { + uint32 i; + for (i = 0; i < dir->tdir_count; i++) + fp[i] = (float)((uint32*) cp)[i]; + ok = TIFFSetField(tif, dir->tdir_tag, fp); + _TIFFfree(tif, (char*) fp); + } + } + if (cp) + _TIFFfree(tif, cp); + return (ok); +} +#endif + +/* + * Replace a single strip (tile) of uncompressed data by + * multiple strips (tiles), each approximately 8Kbytes. + * This is useful for dealing with large images or + * for dealing with machines with a limited amount + * memory. + */ +static void +ChopUpSingleUncompressedStrip(TIFF* tif) +{ + register TIFFDirectory *td = &tif->tif_dir; + uint32 bytecount = td->td_stripbytecount[0]; + uint32 offset = td->td_stripoffset[0]; + tsize_t rowbytes = TIFFVTileSize(tif, 1), stripbytes; + tstrip_t strip, nstrips, rowsperstrip; + uint32* newcounts; + uint32* newoffsets; + + /* + * Make the rows hold at least one + * scanline, but fill 8k if possible. + */ + if (rowbytes > 8192) { + stripbytes = rowbytes; + rowsperstrip = 1; + } else { + rowsperstrip = 8192 / rowbytes; + stripbytes = rowbytes * rowsperstrip; + } + /* never increase the number of strips in an image */ + if (rowsperstrip >= td->td_rowsperstrip) + return; + nstrips = (tstrip_t) TIFFhowmany(bytecount, stripbytes); + newcounts = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32), + "for chopped \"StripByteCounts\" array"); + newoffsets = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32), + "for chopped \"StripOffsets\" array"); + if (newcounts == NULL || newoffsets == NULL) { + /* + * Unable to allocate new strip information, give + * up and use the original one strip information. + */ + if (newcounts != NULL) + _TIFFfree(tif, newcounts); + if (newoffsets != NULL) + _TIFFfree(tif, newoffsets); + return; + } + /* + * Fill the strip information arrays with + * new bytecounts and offsets that reflect + * the broken-up format. + */ + for (strip = 0; strip < nstrips; strip++) { + if (stripbytes > (tsize_t) bytecount) + stripbytes = bytecount; + newcounts[strip] = stripbytes; + newoffsets[strip] = offset; + offset += stripbytes; + bytecount -= stripbytes; + } + /* + * Replace old single strip info with multi-strip info. + */ + td->td_stripsperimage = td->td_nstrips = nstrips; + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + + _TIFFfree(tif, td->td_stripbytecount); + _TIFFfree(tif, td->td_stripoffset); + td->td_stripbytecount = newcounts; + td->td_stripoffset = newoffsets; +} diff --git a/src/libs/pdflib/libs/tiff/tif_dumpmode.c b/src/libs/pdflib/libs/tiff/tif_dumpmode.c new file mode 100644 index 0000000000..ee36b0ed3b --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_dumpmode.c @@ -0,0 +1,122 @@ +/* PDFlib GmbH cvsid: $Id: tif_dumpmode.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * "Null" Compression Algorithm Support. + */ +#include "tiffiop.h" +#include + +/* + * Encode a hunk of pixels. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +{ + (void) s; + while (cc > 0) { + tsize_t n; + + n = cc; + if (tif->tif_rawcc + n > tif->tif_rawdatasize) + n = tif->tif_rawdatasize - tif->tif_rawcc; + + assert( n > 0 ); + + /* + * Avoid copy if client has setup raw + * data buffer to avoid extra copy. + */ + if (tif->tif_rawcp != pp) + _TIFFmemcpy(tif->tif_rawcp, pp, n); + tif->tif_rawcp += n; + tif->tif_rawcc += n; + pp += n; + cc -= n; + if (tif->tif_rawcc >= tif->tif_rawdatasize && + !TIFFFlushData1(tif)) + return (-1); + } + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Decode a hunk of pixels. + */ +static int +DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +{ + (void) s; + if (tif->tif_rawcc < cc) { + TIFFError(tif->tif_name, + "DumpModeDecode: Not enough data for scanline %d", + tif->tif_row); + return (0); + } + /* + * Avoid copy if client has setup raw + * data buffer to avoid extra copy. + */ + if (tif->tif_rawcp != buf) + _TIFFmemcpy(buf, tif->tif_rawcp, cc); + tif->tif_rawcp += cc; + tif->tif_rawcc -= cc; + return (1); +} + +/* + * Seek forwards nrows in the current strip. + */ +static int +DumpModeSeek(TIFF* tif, uint32 nrows) +{ + tif->tif_rawcp += nrows * tif->tif_scanlinesize; + tif->tif_rawcc -= nrows * tif->tif_scanlinesize; + return (1); +} + +/* + * Initialize dump mode. + */ +int +TIFFInitDumpMode(TIFF* tif, int scheme) +{ + (void) scheme; + tif->tif_decoderow = DumpModeDecode; + tif->tif_decodestrip = DumpModeDecode; + tif->tif_decodetile = DumpModeDecode; +#ifdef PDFLIB_TIFFWRITE_SUPPORT + tif->tif_encoderow = DumpModeEncode; + tif->tif_encodestrip = DumpModeEncode; + tif->tif_encodetile = DumpModeEncode; +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + tif->tif_seek = DumpModeSeek; + return (1); +} diff --git a/src/libs/pdflib/libs/tiff/tif_error.c b/src/libs/pdflib/libs/tiff/tif_error.c new file mode 100644 index 0000000000..d7ef1245eb --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_error.c @@ -0,0 +1,49 @@ +/* PDFlib GmbH cvsid: $Id: tif_error.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + */ +#include "tiffiop.h" + +TIFFErrorHandler +TIFFSetErrorHandler(TIFFErrorHandler handler) +{ + TIFFErrorHandler prev = _TIFFerrorHandler; + _TIFFerrorHandler = handler; + return (prev); +} + +void +TIFFError(const char* module, const char* fmt, ...) +{ + if (_TIFFerrorHandler) { + va_list ap; + va_start(ap, fmt); + (*_TIFFerrorHandler)(module, fmt, ap); + va_end(ap); + } +} diff --git a/src/libs/pdflib/libs/tiff/tif_fax3.c b/src/libs/pdflib/libs/tiff/tif_fax3.c new file mode 100644 index 0000000000..d59ce07339 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_fax3.c @@ -0,0 +1,1578 @@ +/* PDFlib GmbH cvsid: $Id: tif_fax3.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1990-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tiffiop.h" +#ifdef CCITT_SUPPORT +/* + * TIFF Library. + * + * CCITT Group 3 (T.4) and Group 4 (T.6) Compression Support. + * + * This file contains support for decoding and encoding TIFF + * compression algorithms 2, 3, 4, and 32771. + * + * Decoder support is derived, with permission, from the code + * in Frank Cringle's viewfax program; + * Copyright (C) 1990, 1995 Frank D. Cringle. + */ +#include "tif_fax3.h" +#define G3CODES +#include "t4.h" +#include +#include + +/* + * Compression+decompression state blocks are + * derived from this ``base state'' block. + */ +typedef struct { + int rw_mode; /* O_RDONLY for decode, else encode */ + int mode; /* operating mode */ + uint32 rowbytes; /* bytes in a decoded scanline */ + uint32 rowpixels; /* pixels in a scanline */ + + uint16 cleanfaxdata; /* CleanFaxData tag */ + uint32 badfaxrun; /* BadFaxRun tag */ + uint32 badfaxlines; /* BadFaxLines tag */ + uint32 groupoptions; /* Group 3/4 options tag */ + uint32 recvparams; /* encoded Class 2 session params */ + char* subaddress; /* subaddress string */ + uint32 recvtime; /* time spent receiving (secs) */ + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ +} Fax3BaseState; +#define Fax3State(tif) ((Fax3BaseState*) (tif)->tif_data) + +typedef struct { + Fax3BaseState b; + const tif_char* bitmap; /* bit reversal table */ + uint32 data; /* current i/o byte/word */ + int bit; /* current i/o bit in byte */ + int EOLcnt; /* count of EOL codes recognized */ + TIFFFaxFillFunc fill; /* fill routine */ + uint32* runs; /* b&w runs for current/previous row */ + uint32* refruns; /* runs for reference line */ + uint32* curruns; /* runs for current line */ +} Fax3DecodeState; +#define DecoderState(tif) ((Fax3DecodeState*) Fax3State(tif)) + +typedef enum { G3_1D, G3_2D } Ttag; +typedef struct { + Fax3BaseState b; + int data; /* current i/o byte */ + int bit; /* current i/o bit in byte */ + Ttag tag; /* encoding state */ + tif_char*refline; /* reference line for 2d decoding */ + int k; /* #rows left that can be 2d encoded */ + int maxk; /* max #rows that can be 2d encoded */ +} Fax3EncodeState; +#define EncoderState(tif) ((Fax3EncodeState*) Fax3State(tif)) + +#define is2DEncoding(sp) \ + (sp->b.groupoptions & GROUP3OPT_2DENCODING) +#define isAligned(p,t) ((((tif_long)(p)) & (sizeof (t)-1)) == 0) + +/* + * Group 3 and Group 4 Decoding. + */ + +/* + * These macros glue the TIFF library state to + * the state expected by Frank's decoder. + */ +#define DECLARE_STATE(tif, sp, mod) \ + static const char module[] = mod; \ + Fax3DecodeState* sp = DecoderState(tif); \ + int a0; /* reference element */ \ + int lastx = sp->b.rowpixels; /* last element in row */ \ + uint32 BitAcc; /* bit accumulator */ \ + int BitsAvail; /* # valid bits in BitAcc */ \ + int RunLength; /* length of current run */ \ + tif_char* cp; /* next byte of input data */ \ + tif_char* ep; /* end of input data */ \ + uint32* pa; /* place to stuff next run */ \ + uint32* thisrun; /* current row's run array */ \ + int EOLcnt; /* # EOL codes recognized */ \ + const tif_char* bitmap = sp->bitmap;/* input data bit reverser */ \ + const TIFFFaxTabEnt* TabEnt +#define DECLARE_STATE_2D(tif, sp, mod) \ + DECLARE_STATE(tif, sp, mod); \ + int b1; /* next change on prev line */ \ + uint32* pb /* next run in reference line */\ +/* + * Load any state that may be changed during decoding. + */ +#define CACHE_STATE(tif, sp) do { \ + BitAcc = sp->data; \ + BitsAvail = sp->bit; \ + EOLcnt = sp->EOLcnt; \ + cp = (unsigned char*) tif->tif_rawcp; \ + ep = cp + tif->tif_rawcc; \ +} while (0) +/* + * Save state possibly changed during decoding. + */ +#define UNCACHE_STATE(tif, sp) do { \ + sp->bit = BitsAvail; \ + sp->data = BitAcc; \ + sp->EOLcnt = EOLcnt; \ + tif->tif_rawcc -= (tidata_t) cp - tif->tif_rawcp; \ + tif->tif_rawcp = (tidata_t) cp; \ +} while (0) + +/* + * Setup state for decoding a strip. + */ +static int +Fax3PreDecode(TIFF* tif, tsample_t s) +{ + Fax3DecodeState* sp = DecoderState(tif); + + (void) s; + assert(sp != NULL); + sp->bit = 0; /* force initial read */ + sp->data = 0; + sp->EOLcnt = 0; /* force initial scan for EOL */ + /* + * Decoder assumes lsb-to-msb bit order. Note that we select + * this here rather than in Fax3SetupState so that viewers can + * hold the image open, fiddle with the FillOrder tag value, + * and then re-decode the image. Otherwise they'd need to close + * and open the image to get the state reset. + */ + sp->bitmap = + TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB); + if (sp->refruns) { /* init reference line to white */ + sp->refruns[0] = (uint32) sp->b.rowpixels; + sp->refruns[1] = 0; + } + return (1); +} + +/* + * Routine for handling various errors/conditions. + * Note how they are "glued into the decoder" by + * overriding the definitions used by the decoder. + */ + +static void +Fax3Unexpected(const char* module, TIFF* tif, uint32 a0) +{ + TIFFError(module, "%s: Bad code word at scanline %d (x %lu)", + tif->tif_name, tif->tif_row, (tif_long) a0); +} +#define unexpected(table, a0) Fax3Unexpected(module, tif, a0) + +static void +Fax3Extension(const char* module, TIFF* tif, uint32 a0) +{ + TIFFError(module, + "%s: Uncompressed data (not supported) at scanline %d (x %lu)", + tif->tif_name, tif->tif_row, (tif_long) a0); +} +#define extension(a0) Fax3Extension(module, tif, a0) + +static void +Fax3BadLength(const char* module, TIFF* tif, uint32 a0, uint32 lastx) +{ + TIFFWarning(module, "%s: %s at scanline %d (got %lu, expected %lu)", + tif->tif_name, + a0 < lastx ? "Premature EOL" : "Line length mismatch", + tif->tif_row, (tif_long) a0, (tif_long) lastx); +} +#define badlength(a0,lastx) Fax3BadLength(module, tif, a0, lastx) + +static void +Fax3PrematureEOF(const char* module, TIFF* tif, uint32 a0) +{ + TIFFWarning(module, "%s: Premature EOF at scanline %d (x %lu)", + tif->tif_name, tif->tif_row, (tif_long) a0); +} +#define prematureEOF(a0) Fax3PrematureEOF(module, tif, a0) + +#define Nop + +/* + * Decode the requested amount of G3 1D-encoded data. + */ +static int +Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +{ + DECLARE_STATE(tif, sp, "Fax3Decode1D"); + + (void) s; + CACHE_STATE(tif, sp); + thisrun = sp->curruns; + while ((long)occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun; +#ifdef FAX3_DEBUG + printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %d\n", tif->tif_row); + fflush(stdout); +#endif + SYNC_EOL(EOF1D); + EXPAND1D(EOF1Da); + (*sp->fill)(buf, thisrun, pa, lastx); + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; + if (occ != 0) + tif->tif_row++; + continue; + EOF1D: /* premature EOF */ + CLEANUP_RUNS(); + EOF1Da: /* premature EOF */ + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(tif, sp); + return (-1); + } + UNCACHE_STATE(tif, sp); + return (1); +} + +#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } +/* + * Decode the requested amount of G3 2D-encoded data. + */ +static int +Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +{ + DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); + int is1D; /* current line is 1d/2d-encoded */ + + (void) s; + CACHE_STATE(tif, sp); + while ((long)occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun = sp->curruns; +#ifdef FAX3_DEBUG + printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d", + BitAcc, BitsAvail, EOLcnt); +#endif + SYNC_EOL(EOF2D); + NeedBits8(1, EOF2D); + is1D = GetBits(1); /* 1D/2D-encoding tag bit */ + ClrBits(1); +#ifdef FAX3_DEBUG + printf(" %s\n-------------------- %d\n", + is1D ? "1D" : "2D", tif->tif_row); + fflush(stdout); +#endif + pb = sp->refruns; + b1 = *pb++; + if (is1D) + EXPAND1D(EOF2Da); + else + EXPAND2D(EOF2Da); + (*sp->fill)(buf, thisrun, pa, lastx); + SETVAL(0); /* imaginary change for reference */ + SWAP(uint32*, sp->curruns, sp->refruns); + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; + if (occ != 0) + tif->tif_row++; + continue; + EOF2D: /* premature EOF */ + CLEANUP_RUNS(); + EOF2Da: /* premature EOF */ + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(tif, sp); + return (-1); + } + UNCACHE_STATE(tif, sp); + return (1); +} +#undef SWAP + +/* + * The ZERO & FILL macros must handle spans < 2*sizeof(long) bytes. + * For machines with 64-bit longs this is <16 bytes; otherwise + * this is <8 bytes. We optimize the code here to reflect the + * machine characteristics. + */ +#if defined(__alpha) || _MIPS_SZLONG == 64 || \ + defined(__LP64__) || defined(__LP64__) || defined(__arch64__) +#define FILL(n, cp) \ + switch (n) { \ + case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\ + case 12:(cp)[11] = 0xff; case 11:(cp)[10] = 0xff; case 10: (cp)[9] = 0xff;\ + case 9: (cp)[8] = 0xff; case 8: (cp)[7] = 0xff; case 7: (cp)[6] = 0xff;\ + case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; case 4: (cp)[3] = 0xff;\ + case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ + case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ + } +#define ZERO(n, cp) \ + switch (n) { \ + case 15:(cp)[14] = 0; case 14:(cp)[13] = 0; case 13: (cp)[12] = 0; \ + case 12:(cp)[11] = 0; case 11:(cp)[10] = 0; case 10: (cp)[9] = 0; \ + case 9: (cp)[8] = 0; case 8: (cp)[7] = 0; case 7: (cp)[6] = 0; \ + case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; case 4: (cp)[3] = 0; \ + case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ + case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ + } +#else +#define FILL(n, cp) \ + switch (n) { \ + case 7: (cp)[6] = 0xff; case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; \ + case 4: (cp)[3] = 0xff; case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ + case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ + } +#define ZERO(n, cp) \ + switch (n) { \ + case 7: (cp)[6] = 0; case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; \ + case 4: (cp)[3] = 0; case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ + case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ + } +#endif + +/* + * Bit-fill a row according to the white/black + * runs generated during G3/G4 decoding. + */ +void +_TIFFFax3fillruns(tif_char* buf, uint32* runs, uint32* erun, uint32 lastx) +{ + static const unsigned char _fillmasks[] = + { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; + tif_char* cp; + uint32 x, bx, run; + int32 n, nw; + long* lp; + + if ((erun-runs)&1) + *erun++ = 0; + x = 0; + for (; runs < erun; runs += 2) { + run = runs[0]; + if (x+run > lastx || run > lastx ) + run = runs[0] = (uint32) (lastx - x); + if (run) { + cp = buf + (x>>3); + bx = x&7; + if (run > 8-bx) { + if (bx) { /* align to byte boundary */ + *cp++ &= 0xff << (8-bx); + run -= 8-bx; + } + if( (n = run >> 3) != 0 ) { /* multiple bytes to fill */ + if ((n/sizeof (long)) > 1) { + /* + * Align to longword boundary and fill. + */ + for (; n && !isAligned(cp, long); n--) + *cp++ = 0x00; + lp = (long*) cp; + nw = (int32)(n / sizeof (long)); + n -= nw * sizeof (long); + do { + *lp++ = 0L; + } while (--nw); + cp = (tif_char*) lp; + } + ZERO(n, cp); + run &= 7; + } + if (run) + cp[0] &= 0xff >> run; + } else + cp[0] &= ~(_fillmasks[run]>>bx); + x += runs[0]; + } + run = runs[1]; + if (x+run > lastx || run > lastx ) + run = runs[1] = lastx - x; + if (run) { + cp = buf + (x>>3); + bx = x&7; + if (run > 8-bx) { + if (bx) { /* align to byte boundary */ + *cp++ |= 0xff >> bx; + run -= 8-bx; + } + if( (n = run>>3) != 0 ) { /* multiple bytes to fill */ + if ((n/sizeof (long)) > 1) { + /* + * Align to longword boundary and fill. + */ + for (; n && !isAligned(cp, long); n--) + *cp++ = 0xff; + lp = (long*) cp; + nw = (int32)(n / sizeof (long)); + n -= nw * sizeof (long); + do { + *lp++ = -1L; + } while (--nw); + cp = (tif_char*) lp; + } + FILL(n, cp); + run &= 7; + } + if (run) + cp[0] |= 0xff00 >> run; + } else + cp[0] |= _fillmasks[run]>>bx; + x += runs[1]; + } + } + assert(x == lastx); +} +#undef ZERO +#undef FILL + +/* + * Setup G3/G4-related compression/decompression state + * before data is processed. This routine is called once + * per image -- it sets up different state based on whether + * or not decoding or encoding is being done and whether + * 1D- or 2D-encoded data is involved. + */ +static int +Fax3SetupState(TIFF* tif) +{ + TIFFDirectory* td = &tif->tif_dir; + Fax3BaseState* sp = Fax3State(tif); + long rowbytes, rowpixels; + int needsRefLine; + + if (td->td_bitspersample != 1) { + TIFFError(tif->tif_name, + "Bits/sample must be 1 for Group 3/4 encoding/decoding"); + return (0); + } + /* + * Calculate the scanline/tile widths. + */ + if (isTiled(tif)) { + rowbytes = TIFFTileRowSize(tif); + rowpixels = td->td_tilewidth; + } else { + rowbytes = TIFFScanlineSize(tif); + rowpixels = td->td_imagewidth; + } + sp->rowbytes = (uint32) rowbytes; + sp->rowpixels = (uint32) rowpixels; + /* + * Allocate any additional space required for decoding/encoding. + */ + needsRefLine = ( + (sp->groupoptions & GROUP3OPT_2DENCODING) || + td->td_compression == COMPRESSION_CCITTFAX4 + ); + if (sp->rw_mode == O_RDONLY) { /* 1d/2d decoding */ + Fax3DecodeState* dsp = DecoderState(tif); + uint32 nruns = needsRefLine ? + 2*TIFFroundup(rowpixels,32) : rowpixels; + + dsp->runs=(uint32*)_TIFFmalloc(tif,(2*nruns+3)*sizeof(uint32)); + if (dsp->runs == NULL) { + TIFFError("Fax3SetupState", + "%s: No space for Group 3/4 run arrays", + tif->tif_name); + return (0); + } + dsp->curruns = dsp->runs; + if (needsRefLine) + dsp->refruns = dsp->runs + (nruns>>1); + else + dsp->refruns = NULL; + if (is2DEncoding(dsp)) { /* NB: default is 1D routine */ + tif->tif_decoderow = Fax3Decode2D; + tif->tif_decodestrip = Fax3Decode2D; + tif->tif_decodetile = Fax3Decode2D; + } + } else if (needsRefLine) { /* 2d encoding */ + Fax3EncodeState* esp = EncoderState(tif); + /* + * 2d encoding requires a scanline + * buffer for the ``reference line''; the + * scanline against which delta encoding + * is referenced. The reference line must + * be initialized to be ``white'' (done elsewhere). + */ + esp->refline = (tif_char*) _TIFFmalloc(tif, rowbytes); + if (esp->refline == NULL) { + TIFFError("Fax3SetupState", + "%s: No space for Group 3/4 reference line", + tif->tif_name); + return (0); + } + } else /* 1d encoding */ + EncoderState(tif)->refline = NULL; + return (1); +} + +/* + * CCITT Group 3 FAX Encoding. + */ + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +#define Fax3FlushBits(tif, sp) { \ + if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ + (void) TIFFFlushData1(tif); \ + *(tif)->tif_rawcp++ = (sp)->data; \ + (tif)->tif_rawcc++; \ + (sp)->data = 0, (sp)->bit = 8; \ +} +#define _FlushBits(tif) { \ + if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ + (void) TIFFFlushData1(tif); \ + *(tif)->tif_rawcp++ = data; \ + (tif)->tif_rawcc++; \ + data = 0, bit = 8; \ +} +static const int _msbmask[9] = + { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; +#define _PutBits(tif, bits, length) { \ + while (length > bit) { \ + data |= bits >> (length - bit); \ + length -= bit; \ + _FlushBits(tif); \ + } \ + data |= (bits & _msbmask[length]) << (bit - length); \ + bit -= length; \ + if (bit == 0) \ + _FlushBits(tif); \ +} + +/* + * Write a variable-length bit-value to + * the output stream. Values are + * assumed to be at most 16 bits. + */ +static void +Fax3PutBits(TIFF* tif, tif_int bits, tif_int length) +{ + Fax3EncodeState* sp = EncoderState(tif); + tif_int bit = sp->bit; + int data = sp->data; + + _PutBits(tif, bits, length); + + sp->data = data; + sp->bit = bit; +} + +/* + * Write a code to the output stream. + */ +#define putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length) + +#ifdef FAX3_DEBUG +#define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B") +#define DEBUG_PRINT(what,len) { \ + int t; \ + printf("%08X/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ + for (t = length-1; t >= 0; t--) \ + putchar(code & (1<bit; + int data = sp->data; + tif_int code, length; + + while (span >= 2624) { + const tableentry* te = &tab[63 + (2560>>6)]; + code = te->code, length = te->length; +#ifdef FAX3_DEBUG + DEBUG_PRINT("MakeUp", te->runlen); +#endif + _PutBits(tif, code, length); + span -= te->runlen; + } + if (span >= 64) { + const tableentry* te = &tab[63 + (span>>6)]; + assert(te->runlen == 64*(span>>6)); + code = te->code, length = te->length; +#ifdef FAX3_DEBUG + DEBUG_PRINT("MakeUp", te->runlen); +#endif + _PutBits(tif, code, length); + span -= te->runlen; + } + code = tab[span].code, length = tab[span].length; +#ifdef FAX3_DEBUG + DEBUG_PRINT(" Term", tab[span].runlen); +#endif + _PutBits(tif, code, length); + + sp->data = data; + sp->bit = bit; +} + +/* + * Write an EOL code to the output stream. The zero-fill + * logic for byte-aligning encoded scanlines is handled + * here. We also handle writing the tag bit for the next + * scanline when doing 2d encoding. + */ +static void +Fax3PutEOL(TIFF* tif) +{ + Fax3EncodeState* sp = EncoderState(tif); + tif_int bit = sp->bit; + int data = sp->data; + tif_int code, length, tparm; + + if (sp->b.groupoptions & GROUP3OPT_FILLBITS) { + /* + * Force bit alignment so EOL will terminate on + * a byte boundary. That is, force the bit alignment + * to 16-12 = 4 before putting out the EOL code. + */ + int align = 8 - 4; + if (align != sp->bit) { + if (align > sp->bit) + align = sp->bit + (8 - align); + else + align = sp->bit - align; + code = 0; + tparm=align; + _PutBits(tif, 0, tparm); + } + } + code = EOL, length = 12; + if (is2DEncoding(sp)) + code = (code<<1) | (sp->tag == G3_1D), length++; + _PutBits(tif, code, length); + + sp->data = data; + sp->bit = bit; +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Reset encoding state at the start of a strip. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +Fax3PreEncode(TIFF* tif, tsample_t s) +{ + Fax3EncodeState* sp = EncoderState(tif); + + (void) s; + assert(sp != NULL); + sp->bit = 8; + sp->data = 0; + sp->tag = G3_1D; + /* + * This is necessary for Group 4; otherwise it isn't + * needed because the first scanline of each strip ends + * up being copied into the refline. + */ + if (sp->refline) + _TIFFmemset(sp->refline, 0x00, sp->b.rowbytes); + if (is2DEncoding(sp)) { + float res = tif->tif_dir.td_yresolution; + /* + * The CCITT spec says that when doing 2d encoding, you + * should only do it on K consecutive scanlines, where K + * depends on the resolution of the image being encoded + * (2 for <= 200 lpi, 4 for > 200 lpi). Since the directory + * code initializes td_yresolution to 0, this code will + * select a K of 2 unless the YResolution tag is set + * appropriately. (Note also that we fudge a little here + * and use 150 lpi to avoid problems with units conversion.) + */ + if (tif->tif_dir.td_resolutionunit == RESUNIT_CENTIMETER) + res *= 2.54f; /* convert to inches */ + sp->maxk = (res > 150 ? 4 : 2); + sp->k = sp->maxk-1; + } else + sp->k = sp->maxk = 0; + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static const tif_char zeroruns[256] = { + 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0f */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1f */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2f */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 - 0xaf */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 - 0xbf */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 - 0xcf */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 - 0xdf */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 - 0xef */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 - 0xff */ +}; +static const tif_char oneruns[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x0f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 - 0x9f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 - 0xaf */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 - 0xbf */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xc0 - 0xcf */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xd0 - 0xdf */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */ + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, /* 0xf0 - 0xff */ +}; + +/* + * On certain systems it pays to inline + * the routines that find pixel spans. + */ +#ifdef VAXC +static int32 find0span(tif_char*, int32, int32); +static int32 find1span(tif_char*, int32, int32); +#pragma inline(find0span,find1span) +#endif + +/* + * Find a span of ones or zeros using the supplied + * table. The ``base'' of the bit string is supplied + * along with the start+end bit indices. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +INLINE static int32 +find0span(tif_char* bp, int32 bs, int32 be) +{ + int32 bits = be - bs; + int32 n, span; + + bp += bs>>3; + /* + * Check partial byte on lhs. + */ + if (bits > 0 && (n = (bs & 7))) { + span = zeroruns[(*bp << n) & 0xff]; + if (span > 8-n) /* table value too generous */ + span = 8-n; + if (span > bits) /* constrain span to bit range */ + span = bits; + if (n+span < 8) /* doesn't extend to edge of byte */ + return (span); + bits -= span; + bp++; + } else + span = 0; + if (bits >= (int)(2*8*sizeof (long))) { + long* lp; + /* + * Align to longword boundary and check longwords. + */ + while (!isAligned(bp, long)) { + if (*bp != 0x00) + return (span + zeroruns[*bp]); + span += 8, bits -= 8; + bp++; + } + lp = (long*) bp; + while (bits >= (int)(8*sizeof (long)) && *lp == 0) { + span += 8*sizeof (long), bits -= 8*sizeof (long); + lp++; + } + bp = (tif_char*) lp; + } + /* + * Scan full bytes for all 0's. + */ + while (bits >= 8) { + if (*bp != 0x00) /* end of run */ + return (span + zeroruns[*bp]); + span += 8, bits -= 8; + bp++; + } + /* + * Check partial byte on rhs. + */ + if (bits > 0) { + n = zeroruns[*bp]; + span += (n > bits ? bits : n); + } + return (span); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +INLINE static int32 +find1span(tif_char* bp, int32 bs, int32 be) +{ + int32 bits = be - bs; + int32 n, span; + + bp += bs>>3; + /* + * Check partial byte on lhs. + */ + if (bits > 0 && (n = (bs & 7))) { + span = oneruns[(*bp << n) & 0xff]; + if (span > 8-n) /* table value too generous */ + span = 8-n; + if (span > bits) /* constrain span to bit range */ + span = bits; + if (n+span < 8) /* doesn't extend to edge of byte */ + return (span); + bits -= span; + bp++; + } else + span = 0; + if (bits >= (int)(2*8*sizeof (long))) { + long* lp; + /* + * Align to longword boundary and check longwords. + */ + while (!isAligned(bp, long)) { + if (*bp != 0xff) + return (span + oneruns[*bp]); + span += 8, bits -= 8; + bp++; + } + lp = (long*) bp; + while (bits >= (int)(8*sizeof (long)) && *lp == ~0) { + span += 8*sizeof (long), bits -= 8*sizeof (long); + lp++; + } + bp = (tif_char*) lp; + } + /* + * Scan full bytes for all 1's. + */ + while (bits >= 8) { + if (*bp != 0xff) /* end of run */ + return (span + oneruns[*bp]); + span += 8, bits -= 8; + bp++; + } + /* + * Check partial byte on rhs. + */ + if (bits > 0) { + n = oneruns[*bp]; + span += (n > bits ? bits : n); + } + return (span); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Return the offset of the next bit in the range + * [bs..be] that is different from the specified + * color. The end, be, is returned if no such bit + * exists. + */ +#define finddiff(_cp, _bs, _be, _color) \ + (_bs + (_color ? find1span(_cp,_bs,_be) : find0span(_cp,_bs,_be))) +/* + * Like finddiff, but also check the starting bit + * against the end in case start > end. + */ +#define finddiff2(_cp, _bs, _be, _color) \ + (_bs < _be ? finddiff(_cp,_bs,_be,_color) : _be) + +/* + * 1d-encode a row of pixels. The encoding is + * a sequence of all-white or all-black spans + * of pixels encoded with Huffman codes. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +Fax3Encode1DRow(TIFF* tif, tif_char* bp, uint32 bits) +{ + Fax3EncodeState* sp = EncoderState(tif); + int32 span; + uint32 bs = 0; + + for (;;) { + span = find0span(bp, bs, bits); /* white span */ + putspan(tif, span, TIFFFaxWhiteCodes); + bs += span; + if (bs >= bits) + break; + span = find1span(bp, bs, bits); /* black span */ + putspan(tif, span, TIFFFaxBlackCodes); + bs += span; + if (bs >= bits) + break; + } + if (sp->b.mode & (FAXMODE_BYTEALIGN|FAXMODE_WORDALIGN)) { + if (sp->bit != 8) /* byte-align */ + Fax3FlushBits(tif, sp); + if ((sp->b.mode&FAXMODE_WORDALIGN) && + !isAligned(tif->tif_rawcp, uint16)) + Fax3FlushBits(tif, sp); + } + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static const tableentry horizcode = + { 3, 0x1 }; /* 001 */ +static const tableentry passcode = + { 4, 0x1 }; /* 0001 */ +static const tableentry vcodes[7] = { + { 7, 0x03 }, /* 0000 011 */ + { 6, 0x03 }, /* 0000 11 */ + { 3, 0x03 }, /* 011 */ + { 1, 0x1 }, /* 1 */ + { 3, 0x2 }, /* 010 */ + { 6, 0x02 }, /* 0000 10 */ + { 7, 0x02 } /* 0000 010 */ +}; + +/* + * 2d-encode a row of pixels. Consult the CCITT + * documentation for the algorithm. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +Fax3Encode2DRow(TIFF* tif, tif_char* bp, tif_char* rp, uint32 bits) +{ +#define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1) + uint32 a0 = 0; + uint32 a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0)); + uint32 b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0)); + uint32 a2, b2; + + for (;;) { + b2 = finddiff2(rp, b1, bits, PIXEL(rp,b1)); + if (b2 >= a1) { + int32 d = b1 - a1; + if (!(-3 <= d && d <= 3)) { /* horizontal mode */ + a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1)); + putcode(tif, &horizcode); + if (a0+a1 == 0 || PIXEL(bp, a0) == 0) { + putspan(tif, a1-a0, TIFFFaxWhiteCodes); + putspan(tif, a2-a1, TIFFFaxBlackCodes); + } else { + putspan(tif, a1-a0, TIFFFaxBlackCodes); + putspan(tif, a2-a1, TIFFFaxWhiteCodes); + } + a0 = a2; + } else { /* vertical mode */ + putcode(tif, &vcodes[d+3]); + a0 = a1; + } + } else { /* pass mode */ + putcode(tif, &passcode); + a0 = b2; + } + if (a0 >= bits) + break; + a1 = finddiff(bp, a0, bits, PIXEL(bp,a0)); + b1 = finddiff(rp, a0, bits, !PIXEL(bp,a0)); + b1 = finddiff(rp, b1, bits, PIXEL(bp,a0)); + } + return (1); +#undef PIXEL +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Encode a buffer of pixels. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + Fax3EncodeState* sp = EncoderState(tif); + + (void) s; + while ((long)cc > 0) { + if ((sp->b.mode & FAXMODE_NOEOL) == 0) + Fax3PutEOL(tif); + if (is2DEncoding(sp)) { + if (sp->tag == G3_1D) { + if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) + return (0); + sp->tag = G3_2D; + } else { + if (!Fax3Encode2DRow(tif, bp, sp->refline, + sp->b.rowpixels)) + return (0); + sp->k--; + } + if (sp->k == 0) { + sp->tag = G3_1D; + sp->k = sp->maxk-1; + } else + _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); + } else { + if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) + return (0); + } + bp += sp->b.rowbytes; + cc -= sp->b.rowbytes; + if (cc != 0) + tif->tif_row++; + } + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +Fax3PostEncode(TIFF* tif) +{ + Fax3EncodeState* sp = EncoderState(tif); + + if (sp->bit != 8) + Fax3FlushBits(tif, sp); + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +Fax3Close(TIFF* tif) +{ + if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0) { + Fax3EncodeState* sp = EncoderState(tif); + tif_int code = EOL; + tif_int length = 12; + int i; + + if (is2DEncoding(sp)) + code = (code<<1) | (sp->tag == G3_1D), length++; + for (i = 0; i < 6; i++) + Fax3PutBits(tif, code, length); + Fax3FlushBits(tif, sp); + } +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static void +Fax3Cleanup(TIFF* tif) +{ + if (tif->tif_data) { + if (Fax3State(tif)->rw_mode == O_RDONLY) { + Fax3DecodeState* sp = DecoderState(tif); + if (sp->runs) + _TIFFfree(tif, sp->runs); + } else { + Fax3EncodeState* sp = EncoderState(tif); + if (sp->refline) + _TIFFfree(tif, sp->refline); + } + if (Fax3State(tif)->subaddress) + _TIFFfree(tif, Fax3State(tif)->subaddress); + _TIFFfree(tif, tif->tif_data); + tif->tif_data = NULL; + } +} + +#define FIELD_BADFAXLINES (FIELD_CODEC+0) +#define FIELD_CLEANFAXDATA (FIELD_CODEC+1) +#define FIELD_BADFAXRUN (FIELD_CODEC+2) +#define FIELD_RECVPARAMS (FIELD_CODEC+3) +#define FIELD_SUBADDRESS (FIELD_CODEC+4) +#define FIELD_RECVTIME (FIELD_CODEC+5) + +#define FIELD_OPTIONS (FIELD_CODEC+6) + +static const TIFFFieldInfo faxFieldInfo[] = { + { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, FIELD_PSEUDO, + FALSE, FALSE, "FaxMode" }, + { TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, FIELD_PSEUDO, + FALSE, FALSE, "FaxFillFunc" }, + { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, FIELD_BADFAXLINES, + TRUE, FALSE, "BadFaxLines" }, + { TIFFTAG_BADFAXLINES, 1, 1, TIFF_SHORT, FIELD_BADFAXLINES, + TRUE, FALSE, "BadFaxLines" }, + { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, FIELD_CLEANFAXDATA, + TRUE, FALSE, "CleanFaxData" }, + { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_LONG, FIELD_BADFAXRUN, + TRUE, FALSE, "ConsecutiveBadFaxLines" }, + { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_SHORT, FIELD_BADFAXRUN, + TRUE, FALSE, "ConsecutiveBadFaxLines" }, + { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, + TRUE, FALSE, "FaxRecvParams" }, + { TIFFTAG_FAXSUBADDRESS, -1,-1, TIFF_ASCII, FIELD_SUBADDRESS, + TRUE, FALSE, "FaxSubAddress" }, + { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, + TRUE, FALSE, "FaxRecvTime" }, +}; +static const TIFFFieldInfo fax3FieldInfo[] = { + { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, + FALSE, FALSE, "Group3Options" }, +}; +static const TIFFFieldInfo fax4FieldInfo[] = { + { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, + FALSE, FALSE, "Group4Options" }, +}; +#define N(a) (sizeof (a) / sizeof (a[0])) + +static int +Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap) +{ + Fax3BaseState* sp = Fax3State(tif); + + switch (tag) { + case TIFFTAG_FAXMODE: + sp->mode = va_arg(ap, int); + return (1); /* NB: pseudo tag */ + case TIFFTAG_FAXFILLFUNC: + if (sp->rw_mode == O_RDONLY) + DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc); + return (1); /* NB: pseudo tag */ + case TIFFTAG_GROUP3OPTIONS: + case TIFFTAG_GROUP4OPTIONS: + sp->groupoptions = va_arg(ap, uint32); + break; + case TIFFTAG_BADFAXLINES: + sp->badfaxlines = va_arg(ap, uint32); + break; + case TIFFTAG_CLEANFAXDATA: + sp->cleanfaxdata = (uint16) va_arg(ap, int); + break; + case TIFFTAG_CONSECUTIVEBADFAXLINES: + sp->badfaxrun = va_arg(ap, uint32); + break; + case TIFFTAG_FAXRECVPARAMS: + sp->recvparams = va_arg(ap, uint32); + break; + case TIFFTAG_FAXSUBADDRESS: + _TIFFsetString(tif, &sp->subaddress, va_arg(ap, char*)); + break; + case TIFFTAG_FAXRECVTIME: + sp->recvtime = va_arg(ap, uint32); + break; + default: + return (*sp->vsetparent)(tif, tag, ap); + } + TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); + tif->tif_flags |= TIFF_DIRTYDIRECT; + return (1); +} + +static int +Fax3VGetField(TIFF* tif, ttag_t tag, va_list ap) +{ + Fax3BaseState* sp = Fax3State(tif); + + switch (tag) { + case TIFFTAG_FAXMODE: + *va_arg(ap, int*) = sp->mode; + break; + case TIFFTAG_FAXFILLFUNC: + if (sp->rw_mode == O_RDONLY) + *va_arg(ap, TIFFFaxFillFunc*) = DecoderState(tif)->fill; + break; + case TIFFTAG_GROUP3OPTIONS: + case TIFFTAG_GROUP4OPTIONS: + *va_arg(ap, uint32*) = sp->groupoptions; + break; + case TIFFTAG_BADFAXLINES: + *va_arg(ap, uint32*) = sp->badfaxlines; + break; + case TIFFTAG_CLEANFAXDATA: + *va_arg(ap, uint16*) = sp->cleanfaxdata; + break; + case TIFFTAG_CONSECUTIVEBADFAXLINES: + *va_arg(ap, uint32*) = sp->badfaxrun; + break; + case TIFFTAG_FAXRECVPARAMS: + *va_arg(ap, uint32*) = sp->recvparams; + break; + case TIFFTAG_FAXSUBADDRESS: + *va_arg(ap, char**) = sp->subaddress; + break; + case TIFFTAG_FAXRECVTIME: + *va_arg(ap, uint32*) = sp->recvtime; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return (1); +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +Fax3PrintDir(TIFF* tif, FILE* fd, long flags) +{ + Fax3BaseState* sp = Fax3State(tif); + + (void) flags; + if (TIFFFieldSet(tif,FIELD_OPTIONS)) { + const char* sep = " "; + if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) { + fprintf(fd, " Group 4 Options:"); + if (sp->groupoptions & GROUP4OPT_UNCOMPRESSED) + fprintf(fd, "%suncompressed data", sep); + } else { + + fprintf(fd, " Group 3 Options:"); + if (sp->groupoptions & GROUP3OPT_2DENCODING) + fprintf(fd, "%s2-d encoding", sep), sep = "+"; + if (sp->groupoptions & GROUP3OPT_FILLBITS) + fprintf(fd, "%sEOL padding", sep), sep = "+"; + if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) + fprintf(fd, "%suncompressed data", sep); + } + fprintf(fd, " (%lu = 0x%lx)\n", + (tif_long) sp->groupoptions, (tif_long) sp->groupoptions); + } + if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) { + fprintf(fd, " Fax Data:"); + switch (sp->cleanfaxdata) { + case CLEANFAXDATA_CLEAN: + fprintf(fd, " clean"); + break; + case CLEANFAXDATA_REGENERATED: + fprintf(fd, " receiver regenerated"); + break; + case CLEANFAXDATA_UNCLEAN: + fprintf(fd, " uncorrected errors"); + break; + } + fprintf(fd, " (%u = 0x%x)\n", + sp->cleanfaxdata, sp->cleanfaxdata); + } + if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) + fprintf(fd," Bad Fax Lines: %lu\n",(tif_long)sp->badfaxlines); + if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) + fprintf(fd, " Consecutive Bad Fax Lines: %lu\n", + (tif_long) sp->badfaxrun); + if (TIFFFieldSet(tif,FIELD_RECVPARAMS)) + fprintf(fd, " Fax Receive Parameters: %08lx\n", + (tif_long) sp->recvparams); + if (TIFFFieldSet(tif,FIELD_SUBADDRESS)) + fprintf(fd, " Fax SubAddress: %s\n", sp->subaddress); + if (TIFFFieldSet(tif,FIELD_RECVTIME)) + fprintf(fd, " Fax Receive Time: %lu secs\n", + (tif_long) sp->recvtime); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static int +InitCCITTFax3(TIFF* tif) +{ + Fax3BaseState* sp; + + /* + * Allocate state block so tag methods have storage to record values. + */ + if (tif->tif_mode == O_RDONLY) + tif->tif_data = (tidata_t) + _TIFFmalloc(tif, sizeof (Fax3DecodeState)); + else + tif->tif_data = (tidata_t) + _TIFFmalloc(tif, sizeof (Fax3EncodeState)); + + if (tif->tif_data == NULL) { + TIFFError("TIFFInitCCITTFax3", + "%s: No space for state block", tif->tif_name); + return (0); + } + + sp = Fax3State(tif); + sp->rw_mode = tif->tif_mode; + + /* + * Merge codec-specific tag information and + * override parent get/set field methods. + */ + _TIFFMergeFieldInfo(tif, faxFieldInfo, N(faxFieldInfo)); + sp->vgetparent = tif->tif_vgetfield; + tif->tif_vgetfield = Fax3VGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_vsetfield; + tif->tif_vsetfield = Fax3VSetField; /* hook for codec tags */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT + tif->tif_printdir = Fax3PrintDir; /* hook for codec tags */ +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + sp->groupoptions = 0; + sp->recvparams = 0; + sp->subaddress = NULL; + + if (sp->rw_mode == O_RDONLY) { + tif->tif_flags |= TIFF_NOBITREV;/* decoder does bit reversal */ + DecoderState(tif)->runs = NULL; + TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns); + } else + EncoderState(tif)->refline = NULL; + + /* + * Install codec methods. + */ + tif->tif_setupdecode = Fax3SetupState; + tif->tif_predecode = Fax3PreDecode; + tif->tif_decoderow = Fax3Decode1D; + tif->tif_decodestrip = Fax3Decode1D; + tif->tif_decodetile = Fax3Decode1D; + tif->tif_setupencode = Fax3SetupState; +#ifdef PDFLIB_TIFFWRITE_SUPPORT + tif->tif_preencode = Fax3PreEncode; + tif->tif_postencode = Fax3PostEncode; + tif->tif_encoderow = Fax3Encode; + tif->tif_encodestrip = Fax3Encode; + tif->tif_encodetile = Fax3Encode; + tif->tif_close = Fax3Close; +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + tif->tif_cleanup = Fax3Cleanup; + + return (1); +} + +int +TIFFInitCCITTFax3(TIFF* tif, int scheme) +{ + (void) scheme; + + if (InitCCITTFax3(tif)) { + _TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo)); + + /* + * The default format is Class/F-style w/o RTC. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + } else + return (0); +} + +/* + * CCITT Group 4 (T.6) Facsimile-compatible + * Compression Scheme Support. + */ + +#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } +/* + * Decode the requested amount of G4-encoded data. + */ +static int +Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +{ + DECLARE_STATE_2D(tif, sp, "Fax4Decode"); + + (void) s; + CACHE_STATE(tif, sp); + while ((long)occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun = sp->curruns; + pb = sp->refruns; + b1 = *pb++; +#ifdef FAX3_DEBUG + printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %d\n", tif->tif_row); + fflush(stdout); +#endif + EXPAND2D(EOFG4); + if (EOLcnt) + goto EOFG4; + (*sp->fill)(buf, thisrun, pa, lastx); + SETVAL(0); /* imaginary change for reference */ + SWAP(uint32*, sp->curruns, sp->refruns); + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; + if (occ != 0) + tif->tif_row++; + continue; + EOFG4: + NeedBits16( 13, BADG4 ); + BADG4: +#ifdef FAX3_DEBUG + if( GetBits(13) != 0x1001 ) + fputs( "Bad RTC\n", stderr ); +#endif + ClrBits( 13 ); + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(tif, sp); + return (-1); + } + UNCACHE_STATE(tif, sp); + return (1); +} +#undef SWAP + +/* + * Encode the requested amount of data. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + Fax3EncodeState *sp = EncoderState(tif); + + (void) s; + while ((long)cc > 0) { + if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) + return (0); + _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); + bp += sp->b.rowbytes; + cc -= sp->b.rowbytes; + if (cc != 0) + tif->tif_row++; + } + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +Fax4PostEncode(TIFF* tif) +{ + Fax3EncodeState *sp = EncoderState(tif); + + /* terminate strip w/ EOFB */ + Fax3PutBits(tif, EOL, 12); + Fax3PutBits(tif, EOL, 12); + if (sp->bit != 8) + Fax3FlushBits(tif, sp); + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +int +TIFFInitCCITTFax4(TIFF* tif, int scheme) +{ + (void) scheme; + + if (InitCCITTFax3(tif)) { /* reuse G3 support */ + _TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo)); + + tif->tif_decoderow = Fax4Decode; + tif->tif_decodestrip = Fax4Decode; + tif->tif_decodetile = Fax4Decode; +#ifdef PDFLIB_TIFFWRITE_SUPPORT + tif->tif_encoderow = Fax4Encode; + tif->tif_encodestrip = Fax4Encode; + tif->tif_encodetile = Fax4Encode; + tif->tif_postencode = Fax4PostEncode; +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + /* + * Suppress RTC at the end of each strip. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC); + } else + return (0); +} + +/* + * CCITT Group 3 1-D Modified Huffman RLE Compression Support. + * (Compression algorithms 2 and 32771) + */ + +/* + * Decode the requested amount of RLE-encoded data. + */ +static int +Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +{ + DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); + int mode = sp->b.mode; + + (void) s; + CACHE_STATE(tif, sp); + thisrun = sp->curruns; + while ((long)occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun; +#ifdef FAX3_DEBUG + printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %d\n", tif->tif_row); + fflush(stdout); +#endif + EXPAND1D(EOFRLE); + (*sp->fill)(buf, thisrun, pa, lastx); + /* + * Cleanup at the end of the row. + */ + if (mode & FAXMODE_BYTEALIGN) { + int n = BitsAvail - (BitsAvail &~ 7); + ClrBits(n); + } else if (mode & FAXMODE_WORDALIGN) { + int n = BitsAvail - (BitsAvail &~ 15); + ClrBits(n); + if (BitsAvail == 0 && !isAligned(cp, uint16)) + cp++; + } + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; + if (occ != 0) + tif->tif_row++; + continue; + EOFRLE: /* premature EOF */ + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(tif, sp); + return (-1); + } + UNCACHE_STATE(tif, sp); + return (1); +} + +int +TIFFInitCCITTRLE(TIFF* tif, int scheme) +{ + (void) scheme; + + if (InitCCITTFax3(tif)) { /* reuse G3 support */ + tif->tif_decoderow = Fax3DecodeRLE; + tif->tif_decodestrip = Fax3DecodeRLE; + tif->tif_decodetile = Fax3DecodeRLE; + /* + * Suppress RTC+EOLs when encoding and byte-align data. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, + FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_BYTEALIGN); + } else + return (0); +} + +int +TIFFInitCCITTRLEW(TIFF* tif, int scheme) +{ + (void) scheme; + + if (InitCCITTFax3(tif)) { /* reuse G3 support */ + tif->tif_decoderow = Fax3DecodeRLE; + tif->tif_decodestrip = Fax3DecodeRLE; + tif->tif_decodetile = Fax3DecodeRLE; + /* + * Suppress RTC+EOLs when encoding and word-align data. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, + FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_WORDALIGN); + } else + return (0); +} +#endif /* CCITT_SUPPORT */ diff --git a/src/libs/pdflib/libs/tiff/tif_fax3.h b/src/libs/pdflib/libs/tiff/tif_fax3.h new file mode 100644 index 0000000000..7e4de0f466 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_fax3.h @@ -0,0 +1,525 @@ +/* PDFlib GmbH cvsid: $Id: tif_fax3.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1990-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _FAX3_ +#define _FAX3_ +/* + * TIFF Library. + * + * CCITT Group 3 (T.4) and Group 4 (T.6) Decompression Support. + * + * Decoder support is derived, with permission, from the code + * in Frank Cringle's viewfax program; + * Copyright (C) 1990, 1995 Frank D. Cringle. + */ +#include "tiff.h" + +/* + * To override the default routine used to image decoded + * spans one can use the pseduo tag TIFFTAG_FAXFILLFUNC. + * The routine must have the type signature given below; + * for example: + * + * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) + * + * where buf is place to set the bits, runs is the array of b&w run + * lengths (white then black), erun is the last run in the array, and + * lastx is the width of the row in pixels. Fill routines can assume + * the run array has room for at least lastx runs and can overwrite + * data in the run array as needed (e.g. to append zero runs to bring + * the count up to a nice multiple). + */ +typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); + +/* + * The default run filler; made external for other decoders. + */ +#if defined(__cplusplus) +extern "C" { +#endif +extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); +#if defined(__cplusplus) +} +#endif + + +/* finite state machine codes */ +#define S_Null 0 +#define S_Pass 1 +#define S_Horiz 2 +#define S_V0 3 +#define S_VR 4 +#define S_VL 5 +#define S_Ext 6 +#define S_TermW 7 +#define S_TermB 8 +#define S_MakeUpW 9 +#define S_MakeUpB 10 +#define S_MakeUp 11 +#define S_EOL 12 + +typedef struct { /* state table entry */ + unsigned char State; /* see above */ + unsigned char Width; /* width of code in bits */ + uint32 Param; /* unsigned 32-bit run length in bits */ +} TIFFFaxTabEnt; + +extern const TIFFFaxTabEnt TIFFFaxMainTable[]; +extern const TIFFFaxTabEnt TIFFFaxWhiteTable[]; +extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; + +/* + * The following macros define the majority of the G3/G4 decoder + * algorithm using the state tables defined elsewhere. To build + * a decoder you need some setup code and some glue code. Note + * that you may also need/want to change the way the NeedBits* + * macros get input data if, for example, you know the data to be + * decoded is properly aligned and oriented (doing so before running + * the decoder can be a big performance win). + * + * Consult the decoder in the TIFF library for an idea of what you + * need to define and setup to make use of these definitions. + * + * NB: to enable a debugging version of these macros define FAX3_DEBUG + * before including this file. Trace output goes to stdout. + */ + +#ifndef EndOfData +#define EndOfData() (cp >= ep) +#endif +/* + * Need <=8 or <=16 bits of input data. Unlike viewfax we + * cannot use/assume a word-aligned, properly bit swizzled + * input data set because data may come from an arbitrarily + * aligned, read-only source such as a memory-mapped file. + * Note also that the viewfax decoder does not check for + * running off the end of the input data buffer. This is + * possible for G3-encoded data because it prescans the input + * data to count EOL markers, but can cause problems for G4 + * data. In any event, we don't prescan and must watch for + * running out of data since we can't permit the library to + * scan past the end of the input data buffer. + * + * Finally, note that we must handle remaindered data at the end + * of a strip specially. The coder asks for a fixed number of + * bits when scanning for the next code. This may be more bits + * than are actually present in the data stream. If we appear + * to run out of data but still have some number of valid bits + * remaining then we makeup the requested amount with zeros and + * return successfully. If the returned data is incorrect then + * we should be called again and get a premature EOF error; + * otherwise we should get the right answer. + */ +#ifndef NeedBits8 +#define NeedBits8(n,eoflab) do { \ + if (BitsAvail < (n)) { \ + if (EndOfData()) { \ + if (BitsAvail == 0) /* no valid bits */ \ + goto eoflab; \ + BitsAvail = (n); /* pad with zeros */ \ + } else { \ + BitAcc |= ((uint32) bitmap[*cp++])<>= (n); \ +} while (0) + +#ifdef FAX3_DEBUG +static const char* StateNames[] = { + "Null ", + "Pass ", + "Horiz ", + "V0 ", + "VR ", + "VL ", + "Ext ", + "TermW ", + "TermB ", + "MakeUpW", + "MakeUpB", + "MakeUp ", + "EOL ", +}; +#define DEBUG_SHOW putchar(BitAcc & (1 << t) ? '1' : '0') +#define LOOKUP8(wid,tab,eoflab) do { \ + int t; \ + NeedBits8(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ + StateNames[TabEnt->State], TabEnt->Param); \ + for (t = 0; t < TabEnt->Width; t++) \ + DEBUG_SHOW; \ + putchar('\n'); \ + fflush(stdout); \ + ClrBits(TabEnt->Width); \ +} while (0) +#define LOOKUP16(wid,tab,eoflab) do { \ + int t; \ + NeedBits16(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ + StateNames[TabEnt->State], TabEnt->Param); \ + for (t = 0; t < TabEnt->Width; t++) \ + DEBUG_SHOW; \ + putchar('\n'); \ + fflush(stdout); \ + ClrBits(TabEnt->Width); \ +} while (0) + +#define SETVAL(x) do { \ + *pa++ = RunLength + (x); \ + printf("SETVAL: %d\t%d\n", RunLength + (x), a0); \ + a0 += x; \ + RunLength = 0; \ +} while (0) +#else +#define LOOKUP8(wid,tab,eoflab) do { \ + NeedBits8(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + ClrBits(TabEnt->Width); \ +} while (0) +#define LOOKUP16(wid,tab,eoflab) do { \ + NeedBits16(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + ClrBits(TabEnt->Width); \ +} while (0) + +/* + * Append a run to the run length array for the + * current row and reset decoding state. + */ +#define SETVAL(x) do { \ + *pa++ = RunLength + (x); \ + a0 += (x); \ + RunLength = 0; \ +} while (0) +#endif + +/* + * Synchronize input decoding at the start of each + * row by scanning for an EOL (if appropriate) and + * skipping any trash data that might be present + * after a decoding error. Note that the decoding + * done elsewhere that recognizes an EOL only consumes + * 11 consecutive zero bits. This means that if EOLcnt + * is non-zero then we still need to scan for the final flag + * bit that is part of the EOL code. + */ +#define SYNC_EOL(eoflab) do { \ + if (EOLcnt == 0) { \ + for (;;) { \ + NeedBits16(11,eoflab); \ + if (GetBits(11) == 0) \ + break; \ + ClrBits(1); \ + } \ + } \ + for (;;) { \ + NeedBits8(8,eoflab); \ + if (GetBits(8)) \ + break; \ + ClrBits(8); \ + } \ + while (GetBits(1) == 0) \ + ClrBits(1); \ + ClrBits(1); /* EOL bit */ \ + EOLcnt = 0; /* reset EOL counter/flag */ \ +} while (0) + +/* + * Cleanup the array of runs after decoding a row. + * We adjust final runs to insure the user buffer is not + * overwritten and/or undecoded area is white filled. + */ +#define CLEANUP_RUNS() do { \ + if (RunLength) \ + SETVAL(0); \ + if (a0 != lastx) { \ + badlength(a0, lastx); \ + while (a0 > lastx && pa > thisrun) \ + a0 -= *--pa; \ + if (a0 < lastx) { \ + if (a0 < 0) \ + a0 = 0; \ + if ((pa-thisrun)&1) \ + SETVAL(0); \ + SETVAL(lastx - a0); \ + } else if (a0 > lastx) { \ + SETVAL(lastx); \ + SETVAL(0); \ + } \ + } \ +} while (0) + +/* + * Decode a line of 1D-encoded data. + * + * The line expanders are written as macros so that they can be reused + * but still have direct access to the local variables of the "calling" + * function. + * + * Note that unlike the original version we have to explicitly test for + * a0 >= lastx after each black/white run is decoded. This is because + * the original code depended on the input data being zero-padded to + * insure the decoder recognized an EOL before running out of data. + */ +#define EXPAND1D(eoflab) do { \ + for (;;) { \ + for (;;) { \ + LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \ + switch (TabEnt->State) { \ + case S_EOL: \ + EOLcnt = 1; \ + goto done1d; \ + case S_TermW: \ + SETVAL(TabEnt->Param); \ + goto doneWhite1d; \ + case S_MakeUpW: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + unexpected("WhiteTable", a0); \ + goto done1d; \ + } \ + } \ + doneWhite1d: \ + if (a0 >= lastx) \ + goto done1d; \ + for (;;) { \ + LOOKUP16(13, TIFFFaxBlackTable, eof1d); \ + switch (TabEnt->State) { \ + case S_EOL: \ + EOLcnt = 1; \ + goto done1d; \ + case S_TermB: \ + SETVAL(TabEnt->Param); \ + goto doneBlack1d; \ + case S_MakeUpB: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + unexpected("BlackTable", a0); \ + goto done1d; \ + } \ + } \ + doneBlack1d: \ + if (a0 >= lastx) \ + goto done1d; \ + if( *(pa-1) == 0 && *(pa-2) == 0 ) \ + pa -= 2; \ + } \ +eof1d: \ + prematureEOF(a0); \ + CLEANUP_RUNS(); \ + goto eoflab; \ +done1d: \ + CLEANUP_RUNS(); \ +} while (0) + +/* + * Update the value of b1 using the array + * of runs for the reference line. + */ +#define CHECK_b1 do { \ + if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \ + b1 += pb[0] + pb[1]; \ + pb += 2; \ + } \ +} while (0) + +/* + * Expand a row of 2D-encoded data. + */ +#define EXPAND2D(eoflab) do { \ + while (a0 < lastx) { \ + LOOKUP8(7, TIFFFaxMainTable, eof2d); \ + switch (TabEnt->State) { \ + case S_Pass: \ + CHECK_b1; \ + b1 += *pb++; \ + RunLength += b1 - a0; \ + a0 = b1; \ + b1 += *pb++; \ + break; \ + case S_Horiz: \ + if ((pa-thisrun)&1) { \ + for (;;) { /* black first */ \ + LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ + switch (TabEnt->State) { \ + case S_TermB: \ + SETVAL(TabEnt->Param); \ + goto doneWhite2da; \ + case S_MakeUpB: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + goto badBlack2d; \ + } \ + } \ + doneWhite2da:; \ + for (;;) { /* then white */ \ + LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ + switch (TabEnt->State) { \ + case S_TermW: \ + SETVAL(TabEnt->Param); \ + goto doneBlack2da; \ + case S_MakeUpW: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + goto badWhite2d; \ + } \ + } \ + doneBlack2da:; \ + } else { \ + for (;;) { /* white first */ \ + LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ + switch (TabEnt->State) { \ + case S_TermW: \ + SETVAL(TabEnt->Param); \ + goto doneWhite2db; \ + case S_MakeUpW: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + goto badWhite2d; \ + } \ + } \ + doneWhite2db:; \ + for (;;) { /* then black */ \ + LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ + switch (TabEnt->State) { \ + case S_TermB: \ + SETVAL(TabEnt->Param); \ + goto doneBlack2db; \ + case S_MakeUpB: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + goto badBlack2d; \ + } \ + } \ + doneBlack2db:; \ + } \ + CHECK_b1; \ + break; \ + case S_V0: \ + CHECK_b1; \ + SETVAL(b1 - a0); \ + b1 += *pb++; \ + break; \ + case S_VR: \ + CHECK_b1; \ + SETVAL(b1 - a0 + TabEnt->Param); \ + b1 += *pb++; \ + break; \ + case S_VL: \ + CHECK_b1; \ + SETVAL(b1 - a0 - TabEnt->Param); \ + b1 -= *--pb; \ + break; \ + case S_Ext: \ + *pa++ = lastx - a0; \ + extension(a0); \ + goto eol2d; \ + case S_EOL: \ + *pa++ = lastx - a0; \ + NeedBits8(4,eof2d); \ + if (GetBits(4)) \ + unexpected("EOL", a0); \ + ClrBits(4); \ + EOLcnt = 1; \ + goto eol2d; \ + default: \ + badMain2d: \ + unexpected("MainTable", a0); \ + goto eol2d; \ + badBlack2d: \ + unexpected("BlackTable", a0); \ + goto eol2d; \ + badWhite2d: \ + unexpected("WhiteTable", a0); \ + goto eol2d; \ + eof2d: \ + prematureEOF(a0); \ + CLEANUP_RUNS(); \ + goto eoflab; \ + } \ + } \ + if (RunLength) { \ + if (RunLength + a0 < lastx) { \ + /* expect a final V0 */ \ + NeedBits8(1,eof2d); \ + if (!GetBits(1)) \ + goto badMain2d; \ + ClrBits(1); \ + } \ + SETVAL(0); \ + } \ +eol2d: \ + CLEANUP_RUNS(); \ +} while (0) +#endif /* _FAX3_ */ diff --git a/src/libs/pdflib/libs/tiff/tif_fax3sm.c b/src/libs/pdflib/libs/tiff/tif_fax3sm.c new file mode 100644 index 0000000000..fc174068c0 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_fax3sm.c @@ -0,0 +1,2091 @@ +/* WARNING, this file was automatically generated by the + mkg3states program */ + +/* PDFlib GmbH cvsid: $Id: tif_fax3sm.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +#include "tiff.h" +#include "port.h" +#include "tif_fax3.h" + +const TIFFFaxTabEnt TIFFFaxMainTable[128] = +{ + {12, 7, 0}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, + {4, 3, 1}, {3, 1, 0}, {1, 4, 0}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, + {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, {5, 6, 2}, {3, 1, 0}, + {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, + {1, 4, 0}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, + {4, 3, 1}, {3, 1, 0}, {5, 7, 3}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, + {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, {1, 4, 0}, {3, 1, 0}, + {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, + {4, 6, 2}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, + {4, 3, 1}, {3, 1, 0}, {1, 4, 0}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, + {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, {6, 7, 0}, {3, 1, 0}, + {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, + {1, 4, 0}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, + {4, 3, 1}, {3, 1, 0}, {5, 6, 2}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, + {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, {1, 4, 0}, {3, 1, 0}, + {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, + {4, 7, 3}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, + {4, 3, 1}, {3, 1, 0}, {1, 4, 0}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, + {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, {4, 6, 2}, {3, 1, 0}, + {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, {4, 3, 1}, {3, 1, 0}, + {1, 4, 0}, {3, 1, 0}, {5, 3, 1}, {3, 1, 0}, {2, 3, 0}, {3, 1, 0}, + {4, 3, 1}, {3, 1, 0} +}; + +const TIFFFaxTabEnt TIFFFaxWhiteTable[4096] = +{ + {12, 11, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, + {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1472}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, + {9, 9, 1216}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, + {7, 8, 41}, {7, 6, 16}, {9, 9, 960}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, + {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 9, 704}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {11, 11, 1792}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, + {9, 9, 832}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, + {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1600}, {7, 4, 5}, + {7, 8, 44}, {7, 6, 17}, {9, 9, 1344}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, + {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, + {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, {9, 9, 1088}, {7, 4, 6}, + {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, + {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, + {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1536}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, {9, 9, 1280}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, + {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, + {9, 9, 1024}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 9, 768}, {7, 4, 6}, + {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {11, 11, 1856}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, {9, 9, 896}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, + {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1728}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, + {9, 9, 1408}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, + {7, 8, 42}, {7, 6, 16}, {9, 9, 1152}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, + {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, + {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, + {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1472}, {7, 4, 5}, + {7, 8, 43}, {7, 6, 17}, {9, 9, 1216}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, + {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, + {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, {9, 9, 960}, {7, 4, 6}, + {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 9, 704}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {11, 12, 2112}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 40}, {7, 6, 16}, {9, 9, 832}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, + {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, + {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1600}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, {9, 9, 1344}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, + {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, + {9, 9, 1088}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, + {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, + {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1536}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, + {9, 9, 1280}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, + {7, 8, 41}, {7, 6, 16}, {9, 9, 1024}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, + {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 9, 768}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {11, 12, 2368}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, + {9, 9, 896}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, + {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1728}, {7, 4, 5}, + {7, 8, 44}, {7, 6, 17}, {9, 9, 1408}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, + {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, + {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, {9, 9, 1152}, {7, 4, 6}, + {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, + {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, + {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1472}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, {9, 9, 1216}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, + {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, + {9, 9, 960}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 9, 704}, {7, 4, 6}, + {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {11, 12, 1984}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, {9, 9, 832}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, + {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1600}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, + {9, 9, 1344}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, + {7, 8, 42}, {7, 6, 16}, {9, 9, 1088}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, + {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, + {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, + {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1536}, {7, 4, 5}, + {7, 8, 43}, {7, 6, 17}, {9, 9, 1280}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, + {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, + {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, {9, 9, 1024}, {7, 4, 6}, + {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 9, 768}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {11, 11, 1920}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 40}, {7, 6, 16}, {9, 9, 896}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, + {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, + {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1728}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, {9, 9, 1408}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, + {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, + {9, 9, 1152}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, + {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, + {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1472}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, + {9, 9, 1216}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, + {7, 8, 41}, {7, 6, 16}, {9, 9, 960}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, + {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 9, 704}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {11, 12, 2240}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, + {9, 9, 832}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, + {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1600}, {7, 4, 5}, + {7, 8, 44}, {7, 6, 17}, {9, 9, 1344}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, + {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, + {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, {9, 9, 1088}, {7, 4, 6}, + {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, + {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, + {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1536}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, {9, 9, 1280}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, + {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, + {9, 9, 1024}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 9, 768}, {7, 4, 6}, + {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {11, 12, 2496}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, {9, 9, 896}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, + {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1728}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, + {9, 9, 1408}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, + {7, 8, 42}, {7, 6, 16}, {9, 9, 1152}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, + {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {12, 11, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, + {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, + {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1472}, {7, 4, 5}, + {7, 8, 43}, {7, 6, 17}, {9, 9, 1216}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, + {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, + {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, {9, 9, 960}, {7, 4, 6}, + {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 9, 704}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {11, 11, 1792}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 40}, {7, 6, 16}, {9, 9, 832}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, + {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, + {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1600}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, {9, 9, 1344}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, + {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, + {9, 9, 1088}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, + {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, + {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1536}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, + {9, 9, 1280}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, + {7, 8, 41}, {7, 6, 16}, {9, 9, 1024}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, + {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 9, 768}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {11, 11, 1856}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, + {9, 9, 896}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, + {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1728}, {7, 4, 5}, + {7, 8, 44}, {7, 6, 17}, {9, 9, 1408}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, + {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, + {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, {9, 9, 1152}, {7, 4, 6}, + {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, + {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, + {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1472}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, {9, 9, 1216}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, + {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, + {9, 9, 960}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 9, 704}, {7, 4, 6}, + {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {11, 12, 2176}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, {9, 9, 832}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, + {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1600}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, + {9, 9, 1344}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, + {7, 8, 42}, {7, 6, 16}, {9, 9, 1088}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, + {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, + {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, + {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1536}, {7, 4, 5}, + {7, 8, 43}, {7, 6, 17}, {9, 9, 1280}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, + {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, + {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, {9, 9, 1024}, {7, 4, 6}, + {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 9, 768}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {11, 12, 2432}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 40}, {7, 6, 16}, {9, 9, 896}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, + {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, + {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1728}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, {9, 9, 1408}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, + {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, + {9, 9, 1152}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, + {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, + {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1472}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, + {9, 9, 1216}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, + {7, 8, 41}, {7, 6, 16}, {9, 9, 960}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, + {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 9, 704}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {11, 12, 2048}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, + {9, 9, 832}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, + {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1600}, {7, 4, 5}, + {7, 8, 44}, {7, 6, 17}, {9, 9, 1344}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, + {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, + {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, {9, 9, 1088}, {7, 4, 6}, + {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, + {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, + {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1536}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, {9, 9, 1280}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, + {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, + {9, 9, 1024}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 9, 768}, {7, 4, 6}, + {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {11, 11, 1920}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, {9, 9, 896}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, + {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1728}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, + {9, 9, 1408}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, + {7, 8, 42}, {7, 6, 16}, {9, 9, 1152}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, + {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, + {9, 8, 576}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, + {7, 8, 35}, {9, 5, 128}, {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1472}, {7, 4, 5}, + {7, 8, 43}, {7, 6, 17}, {9, 9, 1216}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 29}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, + {7, 8, 61}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, + {7, 8, 59}, {7, 4, 5}, {7, 8, 41}, {7, 6, 16}, {9, 9, 960}, {7, 4, 6}, + {7, 8, 31}, {7, 5, 8}, {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 9, 704}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {11, 12, 2304}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, + {7, 8, 40}, {7, 6, 16}, {9, 9, 832}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, + {7, 8, 56}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 46}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, + {9, 8, 512}, {7, 4, 6}, {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, + {7, 8, 0}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {9, 9, 1600}, {7, 4, 5}, {7, 8, 44}, {7, 6, 17}, {9, 9, 1344}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, + {7, 8, 50}, {7, 6, 14}, {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 48}, {7, 4, 3}, {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, + {9, 9, 1088}, {7, 4, 6}, {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, + {7, 8, 38}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, + {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {0, 0, 0}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, {7, 7, 24}, {7, 6, 14}, + {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 7, 23}, {7, 4, 3}, + {7, 7, 27}, {7, 4, 5}, {7, 8, 39}, {7, 6, 16}, {9, 8, 576}, {7, 4, 6}, + {7, 7, 19}, {7, 5, 8}, {7, 8, 55}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 45}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 8, 53}, {7, 5, 9}, {9, 8, 448}, {7, 4, 6}, {7, 8, 35}, {9, 5, 128}, + {7, 8, 51}, {7, 6, 15}, {7, 8, 63}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {9, 9, 1536}, {7, 4, 5}, {7, 8, 43}, {7, 6, 17}, + {9, 9, 1280}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 29}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, + {7, 8, 33}, {9, 5, 128}, {7, 8, 49}, {7, 6, 14}, {7, 8, 61}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 8, 47}, {7, 4, 3}, {7, 8, 59}, {7, 4, 5}, + {7, 8, 41}, {7, 6, 16}, {9, 9, 1024}, {7, 4, 6}, {7, 8, 31}, {7, 5, 8}, + {7, 8, 57}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 7, 26}, {7, 5, 9}, + {9, 9, 768}, {7, 4, 6}, {7, 8, 37}, {9, 5, 128}, {7, 7, 25}, {7, 6, 15}, + {9, 8, 320}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, + {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, {9, 7, 256}, {7, 4, 6}, + {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {11, 12, 2560}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 6, 12}, {7, 5, 9}, {9, 6, 1664}, {7, 4, 6}, {7, 7, 20}, {9, 5, 128}, + {7, 7, 24}, {7, 6, 14}, {7, 7, 28}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 7, 23}, {7, 4, 3}, {7, 7, 27}, {7, 4, 5}, {7, 8, 40}, {7, 6, 16}, + {9, 9, 896}, {7, 4, 6}, {7, 7, 19}, {7, 5, 8}, {7, 8, 56}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 46}, {7, 4, 3}, + {7, 5, 11}, {7, 4, 5}, {7, 8, 54}, {7, 5, 9}, {9, 8, 512}, {7, 4, 6}, + {7, 8, 36}, {9, 5, 128}, {7, 8, 52}, {7, 6, 15}, {7, 8, 0}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 6, 13}, {7, 4, 3}, {9, 9, 1728}, {7, 4, 5}, + {7, 8, 44}, {7, 6, 17}, {9, 9, 1408}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, + {9, 6, 192}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 8, 30}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, {7, 6, 12}, {7, 5, 9}, + {9, 6, 1664}, {7, 4, 6}, {7, 8, 34}, {9, 5, 128}, {7, 8, 50}, {7, 6, 14}, + {7, 8, 62}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, {7, 8, 48}, {7, 4, 3}, + {7, 8, 60}, {7, 4, 5}, {7, 8, 42}, {7, 6, 16}, {9, 9, 1152}, {7, 4, 6}, + {7, 8, 32}, {7, 5, 8}, {7, 8, 58}, {9, 5, 64}, {7, 5, 10}, {7, 4, 4}, + {7, 4, 2}, {7, 4, 7}, {7, 7, 22}, {7, 4, 3}, {7, 5, 11}, {7, 4, 5}, + {7, 7, 26}, {7, 5, 9}, {9, 8, 640}, {7, 4, 6}, {7, 8, 38}, {9, 5, 128}, + {7, 7, 25}, {7, 6, 15}, {9, 8, 384}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7}, + {7, 6, 13}, {7, 4, 3}, {7, 7, 18}, {7, 4, 5}, {7, 7, 21}, {7, 6, 17}, + {9, 7, 256}, {7, 4, 6}, {7, 6, 1}, {7, 5, 8}, {9, 6, 192}, {9, 5, 64}, + {7, 5, 10}, {7, 4, 4}, {7, 4, 2}, {7, 4, 7} +}; + +const TIFFFaxTabEnt TIFFFaxBlackTable[8192] = +{ + {12, 11, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 18}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 17}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 11, 1792}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 23}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 20}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 25}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 12, 128}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 56}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 30}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 11, 1856}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 57}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 21}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 54}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 52}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 48}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 12, 2112}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 44}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 36}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 12, 384}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 28}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 60}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 40}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 12, 2368}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 16}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 10, 64}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 18}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 17}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 12, 1984}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 50}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 34}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 13, 1664}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 26}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 13, 1408}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 32}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 11, 1920}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 61}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 42}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 13, 1024}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 13, 768}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 62}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 12, 2240}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 46}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 38}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 13, 512}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 19}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 24}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 22}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 12, 2496}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 16}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 10, 64}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {12, 11, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 18}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 17}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 11, 1792}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 23}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 20}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 25}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 12, 192}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 13, 1280}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 31}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 11, 1856}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 58}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 21}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 13, 896}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 13, 640}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 49}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 12, 2176}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 45}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 37}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 12, 448}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 29}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 13, 1536}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 41}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 12, 2432}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 16}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 10, 64}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 18}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 17}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 12, 2048}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 51}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 35}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 12, 320}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 27}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 59}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 33}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 11, 1920}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 12, 256}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 43}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 13, 1152}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 55}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 63}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 12, 2304}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 47}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 39}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 53}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 19}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 24}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 22}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 12, 2560}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 16}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 10, 64}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {12, 11, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 18}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 17}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 11, 1792}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 23}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 20}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 25}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 12, 128}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 56}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 30}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 11, 1856}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 57}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 21}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 54}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 52}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 48}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 12, 2112}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 44}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 36}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 12, 384}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 28}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 60}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 40}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 12, 2368}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 16}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 10, 64}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 18}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 17}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 12, 1984}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 50}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 34}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 13, 1728}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 26}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 13, 1472}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 32}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 11, 1920}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 61}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 42}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 13, 1088}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 13, 832}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 62}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 12, 2240}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 46}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 38}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 13, 576}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 19}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 24}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 22}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 12, 2496}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 16}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 10, 64}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {12, 11, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 18}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 17}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 11, 1792}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 23}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 20}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 25}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 12, 192}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 13, 1344}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 31}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 11, 1856}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 58}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 11, 21}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 13, 960}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 13, 704}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 49}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 12, 2176}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 45}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 37}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 12, 448}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 29}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 13, 1600}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 41}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 12, 2432}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 16}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 10, 64}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 9, 15}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 18}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 10, 17}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 12, 2048}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 51}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 35}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 12, 320}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 27}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 59}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 33}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {11, 11, 1920}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {10, 12, 256}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 43}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {10, 13, 1216}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {0, 0, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 9, 15}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 55}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 63}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {11, 12, 2304}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 12, 47}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 12, 39}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 12, 53}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {0, 0, 0}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 13}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 19}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 11, 24}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 11, 22}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {11, 12, 2560}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 10}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 10, 16}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 10, 0}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {10, 10, 64}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 6, 9}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 7, 11}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 5, 7}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 8, 14}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2}, {8, 6, 8}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, + {8, 4, 5}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, {8, 7, 12}, {8, 2, 3}, + {8, 3, 1}, {8, 2, 2}, {8, 4, 6}, {8, 2, 3}, {8, 3, 4}, {8, 2, 2}, + {8, 5, 7}, {8, 2, 3}, {8, 3, 1}, {8, 2, 2}, {8, 4, 5}, {8, 2, 3}, + {8, 3, 4}, {8, 2, 2} +}; diff --git a/src/libs/pdflib/libs/tiff/tif_getimage.c b/src/libs/pdflib/libs/tiff/tif_getimage.c new file mode 100644 index 0000000000..a6c01e68e4 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_getimage.c @@ -0,0 +1,2422 @@ +/* PDFlib GmbH cvsid: $Id: tif_getimage.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1991-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * Read and return a packed RGBA image. + */ +#include "tiffiop.h" +#include +#include + +static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); +static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); +static int gtStripContig(TIFFRGBAImage*, uint32*, uint32, uint32); +static int gtStripSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); +static int pickTileContigCase(TIFF*, TIFFRGBAImage*); +static int pickTileSeparateCase(TIFF*, TIFFRGBAImage*); + +static const char photoTag[] = "PhotometricInterpretation"; + +/* + * Check the image to see if TIFFReadRGBAImage can deal with it. + * 1/0 is returned according to whether or not the image can + * be handled. If 0 is returned, emsg contains the reason + * why it is being rejected. + */ +int +TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) +{ + TIFFDirectory* td = &tif->tif_dir; + uint16 photometric; + int colorchannels; + + switch (td->td_bitspersample) { + case 1: case 2: case 4: + case 8: case 16: + break; + default: + sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + td->td_bitspersample); + return (0); + } + colorchannels = td->td_samplesperpixel - td->td_extrasamples; + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { + switch (colorchannels) { + case 1: + photometric = PHOTOMETRIC_MINISBLACK; + break; + case 3: + photometric = PHOTOMETRIC_RGB; + break; + default: + sprintf(emsg, "Missing needed %s tag", photoTag); + return (0); + } + } + switch (photometric) { + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_PALETTE: + if (td->td_planarconfig == PLANARCONFIG_CONTIG + && td->td_samplesperpixel != 1 + && td->td_bitspersample < 8 ) { + sprintf(emsg, + "Sorry, can not handle contiguous data with %s=%d, " + "and %s=%d and Bits/Sample=%d", + photoTag, photometric, + "Samples/pixel", td->td_samplesperpixel, + td->td_bitspersample); + return (0); + } + /* + ** We should likely validate that any extra samples are either + ** to be ignored, or are alpha, and if alpha we should try to use + ** them. But for now we won't bother with this. + */ + break; + case PHOTOMETRIC_YCBCR: + if (td->td_planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", + "Planarconfiguration", td->td_planarconfig); + return (0); + } + break; + case PHOTOMETRIC_RGB: + if (colorchannels < 3) { + sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", + "Color channels", colorchannels); + return (0); + } + break; +#ifdef CMYK_SUPPORT + case PHOTOMETRIC_SEPARATED: + if (td->td_inkset != INKSET_CMYK) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "InkSet", td->td_inkset); + return (0); + } + if (td->td_samplesperpixel < 4) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "Samples/pixel", td->td_samplesperpixel); + return (0); + } + break; +#endif + case PHOTOMETRIC_LOGL: + if (td->td_compression != COMPRESSION_SGILOG) { + sprintf(emsg, "Sorry, LogL data must have %s=%d", + "Compression", COMPRESSION_SGILOG); + return (0); + } + break; + case PHOTOMETRIC_LOGLUV: + if (td->td_compression != COMPRESSION_SGILOG && + td->td_compression != COMPRESSION_SGILOG24) { + sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", + "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); + return (0); + } + if (td->td_planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + "Planarconfiguration", td->td_planarconfig); + return (0); + } + break; + default: + sprintf(emsg, "Sorry, can not handle image with %s=%d", + photoTag, photometric); + return (0); + } + return (1); +} + +void +TIFFRGBAImageEnd(TIFF* tif, TIFFRGBAImage* img) +{ + if (img->Map) + _TIFFfree(tif, img->Map), img->Map = NULL; + if (img->BWmap) + _TIFFfree(tif, img->BWmap), img->BWmap = NULL; + if (img->PALmap) + _TIFFfree(tif, img->PALmap), img->PALmap = NULL; + if (img->ycbcr) + _TIFFfree(tif, img->ycbcr), img->ycbcr = NULL; + + if( img->redcmap ) { + _TIFFfree(tif, img->redcmap ); + _TIFFfree(tif, img->greencmap ); + _TIFFfree(tif, img->bluecmap ); + } +} + +static int +isCCITTCompression(TIFF* tif) +{ + uint16 compress; + TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); + return (compress == COMPRESSION_CCITTFAX3 || + compress == COMPRESSION_CCITTFAX4 || + compress == COMPRESSION_CCITTRLE || + compress == COMPRESSION_CCITTRLEW); +} + +int +TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) +{ + uint16* sampleinfo; + uint16 extrasamples; + uint16 planarconfig; + uint16 compress; + int colorchannels; + uint16 *red_orig, *green_orig, *blue_orig; + int n_color; + + /* Initialize to normal values */ + img->row_offset = 0; + img->col_offset = 0; + img->redcmap = NULL; + img->greencmap = NULL; + img->bluecmap = NULL; + + img->tif = tif; + img->stoponerr = stop; + TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample); + switch (img->bitspersample) { + case 1: case 2: case 4: + case 8: case 16: + break; + default: + sprintf(emsg, "Sorry, can not image with %d-bit samples", + img->bitspersample); + return (0); + } + img->alpha = 0; + TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel); + TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, + &extrasamples, &sampleinfo); + if (extrasamples == 1) + switch (sampleinfo[0]) { + case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ + case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ + img->alpha = sampleinfo[0]; + break; + } + colorchannels = img->samplesperpixel - extrasamples; + TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress); + TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig); + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) { + switch (colorchannels) { + case 1: + if (isCCITTCompression(tif)) + img->photometric = PHOTOMETRIC_MINISWHITE; + else + img->photometric = PHOTOMETRIC_MINISBLACK; + break; + case 3: + img->photometric = PHOTOMETRIC_RGB; + break; + default: + sprintf(emsg, "Missing needed %s tag", photoTag); + return (0); + } + } + switch (img->photometric) { + case PHOTOMETRIC_PALETTE: + if (!TIFFGetField(tif, TIFFTAG_COLORMAP, + &red_orig, &green_orig, &blue_orig)) { + TIFFError(TIFFFileName(tif), "Missing required \"Colormap\" tag"); + return (0); + } + + /* copy the colormaps so we can modify them */ + n_color = (1L << img->bitspersample); + img->redcmap = (uint16 *) _TIFFmalloc(tif, sizeof(uint16)*n_color); + img->greencmap = (uint16 *) _TIFFmalloc(tif, sizeof(uint16)*n_color); + img->bluecmap = (uint16 *) _TIFFmalloc(tif, sizeof(uint16)*n_color); + if( !img->redcmap || !img->greencmap || !img->bluecmap ) { + TIFFError(TIFFFileName(tif), "Out of memory for colormap copy"); + return (0); + } + + memcpy( img->redcmap, red_orig, n_color * 2 ); + memcpy( img->greencmap, green_orig, n_color * 2 ); + memcpy( img->bluecmap, blue_orig, n_color * 2 ); + + /* fall thru... */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + if (planarconfig == PLANARCONFIG_CONTIG + && img->samplesperpixel != 1 + && img->bitspersample < 8 ) { + sprintf(emsg, + "Sorry, can not handle contiguous data with %s=%d, " + "and %s=%d and Bits/Sample=%d", + photoTag, img->photometric, + "Samples/pixel", img->samplesperpixel, + img->bitspersample); + return (0); + } + break; + case PHOTOMETRIC_YCBCR: + if (planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", + "Planarconfiguration", planarconfig); + return (0); + } + /* It would probably be nice to have a reality check here. */ + if (planarconfig == PLANARCONFIG_CONTIG) + /* can rely on libjpeg to convert to RGB */ + /* XXX should restore current state on exit */ + switch (compress) { + case COMPRESSION_OJPEG: + case COMPRESSION_JPEG: + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + img->photometric = PHOTOMETRIC_RGB; + break; + + default: + /* do nothing */; + break; + } + break; + case PHOTOMETRIC_RGB: + if (colorchannels < 3) { + sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", + "Color channels", colorchannels); + return (0); + } + break; + case PHOTOMETRIC_SEPARATED: { + uint16 inkset; + TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); + if (inkset != INKSET_CMYK) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "InkSet", inkset); + return (0); + } + if (img->samplesperpixel < 4) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "Samples/pixel", img->samplesperpixel); + return (0); + } + break; + } + case PHOTOMETRIC_LOGL: + if (compress != COMPRESSION_SGILOG) { + sprintf(emsg, "Sorry, LogL data must have %s=%d", + "Compression", COMPRESSION_SGILOG); + return (0); + } + TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); + img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */ + img->bitspersample = 8; + break; + case PHOTOMETRIC_LOGLUV: + if (compress != COMPRESSION_SGILOG && compress != COMPRESSION_SGILOG24){ + sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", + "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); + return (0); + } + if (planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + "Planarconfiguration", planarconfig); + return (0); + } + TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); + img->photometric = PHOTOMETRIC_RGB; /* little white lie */ + img->bitspersample = 8; + break; + default: + sprintf(emsg, "Sorry, can not handle image with %s=%d", + photoTag, img->photometric); + return (0); + } + img->Map = NULL; + img->BWmap = NULL; + img->PALmap = NULL; + img->ycbcr = NULL; + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); + TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); + img->isContig = + !(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1); + if (img->isContig) { + img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig; + (void) pickTileContigCase(tif, img); + } else { + img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate; + (void) pickTileSeparateCase(tif, img); + } + return (1); +} + +int +TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +{ + if (img->get == NULL) { + TIFFError(TIFFFileName(img->tif), "No \"get\" routine setup"); + return (0); + } + if (img->put.any == NULL) { + TIFFError(TIFFFileName(img->tif), + "No \"put\" routine setupl; probably can not handle image format"); + return (0); + } + return (*img->get)(img, raster, w, h); +} + +/* + * Read the specified image into an ABGR-format raster. + */ +int +TIFFReadRGBAImage(TIFF* tif, + uint32 rwidth, uint32 rheight, uint32* raster, int stop) +{ + char emsg[1024]; + TIFFRGBAImage img; + int ok; + + if (TIFFRGBAImageBegin(&img, tif, stop, emsg)) { + /* XXX verify rwidth and rheight against width and height */ + ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth, + rwidth, img.height); + TIFFRGBAImageEnd(tif, &img); + } else { + TIFFError(TIFFFileName(tif), emsg); + ok = 0; + } + return (ok); +} + +static uint32 +setorientation(TIFFRGBAImage* img, uint32 h) +{ + TIFF* tif = img->tif; + uint32 y; + + switch (img->orientation) { + case ORIENTATION_BOTRIGHT: + case ORIENTATION_RIGHTBOT: /* XXX */ + case ORIENTATION_LEFTBOT: /* XXX */ + TIFFWarning(TIFFFileName(tif), "using bottom-left orientation"); + img->orientation = ORIENTATION_BOTLEFT; + /* fall thru... */ + case ORIENTATION_BOTLEFT: + y = 0; + break; + case ORIENTATION_TOPRIGHT: + case ORIENTATION_RIGHTTOP: /* XXX */ + case ORIENTATION_LEFTTOP: /* XXX */ + default: + TIFFWarning(TIFFFileName(tif), "using top-left orientation"); + img->orientation = ORIENTATION_TOPLEFT; + /* fall thru... */ + case ORIENTATION_TOPLEFT: + y = h-1; + break; + } + return (y); +} + +/* + * Get an tile-organized image that has + * PlanarConfiguration contiguous if SamplesPerPixel > 1 + * or + * SamplesPerPixel == 1 + */ +static int +gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +{ + TIFF* tif = img->tif; + tileContigRoutine put = img->put.contig; + uint16 orientation; + uint32 col, row, y, rowstoread, ret = 1; + uint32 pos; + uint32 tw, th; + tif_char* buf; + int32 fromskew, toskew; + uint32 nrow; + + buf = (tif_char*) _TIFFmalloc(tif, TIFFTileSize(tif)); + if (buf == 0) { + TIFFError(TIFFFileName(tif), "No space for tile buffer"); + return (0); + } + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); + y = setorientation(img, h); + orientation = img->orientation; + toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w); + for (row = 0; row < h; row += nrow) + { + rowstoread = th - (row + img->row_offset) % th; + nrow = (row + rowstoread > h ? h - row : rowstoread); + for (col = 0; col < w; col += tw) + { + if (TIFFReadTile(tif, buf, col+img->col_offset, + row+img->row_offset, 0, 0) < 0 && img->stoponerr) + { + ret = 0; + break; + } + + pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); + + if (col + tw > w) + { + /* + * Tile is clipped horizontally. Calculate + * visible portion and skewing factors. + */ + uint32 npix = w - col; + fromskew = tw - npix; + (*put)(img, raster+y*w+col, col, y, + npix, nrow, fromskew, toskew + fromskew, buf + pos); + } + else + { + (*put)(img, raster+y*w+col, col, y, tw, nrow, 0, toskew, + buf + pos); + } + } + + y += (orientation == ORIENTATION_TOPLEFT ? -(int32) nrow : (int32)nrow); + } + _TIFFfree(tif, buf); + return (ret); +} + +/* + * Get an tile-organized image that has + * SamplesPerPixel > 1 + * PlanarConfiguration separated + * We assume that all such images are RGB. + */ +static int +gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +{ + TIFF* tif = img->tif; + tileSeparateRoutine put = img->put.separate; + uint16 orientation; + uint32 col, row, y, rowstoread; + uint32 pos; + uint32 tw, th; + tif_char* buf; + tif_char* r; + tif_char* g; + tif_char* b; + tif_char* a; + tsize_t tilesize; + int32 fromskew, toskew; + int alpha = img->alpha; + uint32 nrow; + int ret = 1; + + tilesize = TIFFTileSize(tif); + buf = (tif_char*) _TIFFmalloc(tif, 4*tilesize); + if (buf == 0) { + TIFFError(TIFFFileName(tif), "No space for tile buffer"); + return (0); + } + r = buf; + g = r + tilesize; + b = g + tilesize; + a = b + tilesize; + if (!alpha) + memset(a, 0xff, tilesize); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); + y = setorientation(img, h); + orientation = img->orientation; + toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w); + for (row = 0; row < h; row += nrow) + { + rowstoread = th - (row + img->row_offset) % th; + nrow = (row + rowstoread > h ? h - row : rowstoread); + for (col = 0; col < w; col += tw) + { + if (TIFFReadTile(tif, r, col+img->col_offset, + row+img->row_offset,0,0) < 0 && img->stoponerr) + { + ret = 0; + break; + } + if (TIFFReadTile(tif, g, col+img->col_offset, + row+img->row_offset,0,1) < 0 && img->stoponerr) + { + ret = 0; + break; + } + if (TIFFReadTile(tif, b, col+img->col_offset, + row+img->row_offset,0,2) < 0 && img->stoponerr) + { + ret = 0; + break; + } + if (alpha && TIFFReadTile(tif,a,col+img->col_offset, + row+img->row_offset,0,3) < 0 && img->stoponerr) + { + ret = 0; + break; + } + + pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); + + if (col + tw > w) + { + /* + * Tile is clipped horizontally. Calculate + * visible portion and skewing factors. + */ + uint32 npix = w - col; + fromskew = tw - npix; + (*put)(img, raster+y*w+col, col, y, + npix, nrow, fromskew, toskew + fromskew, + r + pos, g + pos, b + pos, a + pos); + } + else + { + (*put)(img, raster+y*w+col, col, y, + tw, nrow, 0, toskew, r + pos, g + pos, b + pos, a + pos); + } + } + + y += (orientation == ORIENTATION_TOPLEFT ?-(int32) nrow : (int32) nrow); + } + _TIFFfree(tif, buf); + return (ret); +} + +/* + * Get a strip-organized image that has + * PlanarConfiguration contiguous if SamplesPerPixel > 1 + * or + * SamplesPerPixel == 1 + */ +static int +gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +{ + TIFF* tif = img->tif; + tileContigRoutine put = img->put.contig; + uint16 orientation; + uint32 row, y, nrow, rowstoread; + uint32 pos; + tif_char* buf; + uint32 rowsperstrip; + uint32 imagewidth = img->width; + tsize_t scanline; + int32 fromskew, toskew; + int ret = 1; + + buf = (tif_char*) _TIFFmalloc(tif, TIFFStripSize(tif)); + if (buf == 0) { + TIFFError(TIFFFileName(tif), "No space for strip buffer"); + return (0); + } + y = setorientation(img, h); + orientation = img->orientation; + toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w); + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + scanline = TIFFScanlineSize(tif); + fromskew = (w < imagewidth ? imagewidth - w : 0); + for (row = 0; row < h; row += nrow) + { + rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; + nrow = (row + rowstoread > h ? h - row : rowstoread); + if (TIFFReadEncodedStrip(tif, + TIFFComputeStrip(tif,row+img->row_offset, 0), + buf, + ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 + && img->stoponerr) + { + ret = 0; + break; + } + + pos = ((row + img->row_offset) % rowsperstrip) * scanline; + (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos); + y += (orientation == ORIENTATION_TOPLEFT ?-(int32) nrow : (int32) nrow); + } + _TIFFfree(tif, buf); + return (ret); +} + +/* + * Get a strip-organized image with + * SamplesPerPixel > 1 + * PlanarConfiguration separated + * We assume that all such images are RGB. + */ +static int +gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +{ + TIFF* tif = img->tif; + tileSeparateRoutine put = img->put.separate; + uint16 orientation; + tif_char *buf; + tif_char *r, *g, *b, *a; + uint32 row, y, nrow, rowstoread; + uint32 pos; + tsize_t scanline; + uint32 rowsperstrip, offset_row; + uint32 imagewidth = img->width; + tsize_t stripsize; + int32 fromskew, toskew; + int alpha = img->alpha; + int ret = 1; + + stripsize = TIFFStripSize(tif); + r = buf = (tif_char *)_TIFFmalloc(tif, 4*stripsize); + if (buf == 0) { + TIFFError(TIFFFileName(tif), "No space for tile buffer"); + return (0); + } + g = r + stripsize; + b = g + stripsize; + a = b + stripsize; + if (!alpha) + memset(a, 0xff, stripsize); + y = setorientation(img, h); + orientation = img->orientation; + toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w); + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + scanline = TIFFScanlineSize(tif); + fromskew = (w < imagewidth ? imagewidth - w : 0); + for (row = 0; row < h; row += nrow) + { + rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; + nrow = (row + rowstoread > h ? h - row : rowstoread); + offset_row = row + img->row_offset; + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), + r, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 + && img->stoponerr) + { + ret = 0; + break; + } + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), + g, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 + && img->stoponerr) + { + ret = 0; + break; + } + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), + b, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 + && img->stoponerr) + { + ret = 0; + break; + } + if (alpha && + (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 3), + a, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 + && img->stoponerr)) + { + ret = 0; + break; + } + + pos = ((row + img->row_offset) % rowsperstrip) * scanline; + (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, r + pos, + g + pos, b + pos, a + pos); + y += (orientation == ORIENTATION_TOPLEFT ? -(int32) nrow : (int32)nrow); + } + _TIFFfree(tif, buf); + return (ret); +} + +/* + * The following routines move decoded data returned + * from the TIFF library into rasters filled with packed + * ABGR pixels (i.e. suitable for passing to lrecwrite.) + * + * The routines have been created according to the most + * important cases and optimized. pickTileContigCase and + * pickTileSeparateCase analyze the parameters and select + * the appropriate "put" routine to use. + */ +#define REPEAT8(op) REPEAT4(op); REPEAT4(op) +#define REPEAT4(op) REPEAT2(op); REPEAT2(op) +#define REPEAT2(op) op; op +#define CASE8(x,op) \ + switch (x) { \ + case 7: op; case 6: op; case 5: op; \ + case 4: op; case 3: op; case 2: op; \ + case 1: op; \ + } +#define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; } +#define NOP + +#define UNROLL8(w, op1, op2) { \ + uint32 _x; \ + for (_x = w; _x >= 8; _x -= 8) { \ + op1; \ + REPEAT8(op2); \ + } \ + if (_x > 0) { \ + op1; \ + CASE8(_x,op2); \ + } \ +} +#define UNROLL4(w, op1, op2) { \ + uint32 _x; \ + for (_x = w; _x >= 4; _x -= 4) { \ + op1; \ + REPEAT4(op2); \ + } \ + if (_x > 0) { \ + op1; \ + CASE4(_x,op2); \ + } \ +} +#define UNROLL2(w, op1, op2) { \ + uint32 _x; \ + for (_x = w; _x >= 2; _x -= 2) { \ + op1; \ + REPEAT2(op2); \ + } \ + if (_x) { \ + op1; \ + op2; \ + } \ +} + +#define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } +#define SKEW4(r,g,b,a,skew) { r += skew; g += skew; b += skew; a+= skew; } + +#define A1 ((uint32)(0xffL<<24)) +#define PACK(r,g,b) \ + ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|A1) +#define PACK4(r,g,b,a) \ + ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(a)<<24)) +#define W2B(v) (((v)>>8)&0xff) +#define PACKW(r,g,b) \ + ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|A1) +#define PACKW4(r,g,b,a) \ +((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|((uint32)W2B(a)<<24)) + +#define DECLAREContigPutFunc(name) \ +static void name(\ + TIFFRGBAImage* img, \ + uint32* cp, \ + uint32 x, uint32 y, \ + uint32 w, uint32 h, \ + int32 fromskew, int32 toskew, \ + tif_char* pp \ +) + +/* + * 8-bit palette => colormap/RGB + */ +DECLAREContigPutFunc(put8bitcmaptile) +{ + uint32** PALmap = img->PALmap; + int samplesperpixel = img->samplesperpixel; + + (void) y; + while (h-- > 0) { + for (x = w; x-- > 0;) + { + *cp++ = PALmap[*pp][0]; + pp += samplesperpixel; + } + cp += toskew; + pp += fromskew; + } +} + +/* + * 4-bit palette => colormap/RGB + */ +DECLAREContigPutFunc(put4bitcmaptile) +{ + uint32** PALmap = img->PALmap; + + (void) x; (void) y; + fromskew /= 2; + while (h-- > 0) { + uint32* bw; + UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; + } +} + +/* + * 2-bit palette => colormap/RGB + */ +DECLAREContigPutFunc(put2bitcmaptile) +{ + uint32** PALmap = img->PALmap; + + (void) x; (void) y; + fromskew /= 4; + while (h-- > 0) { + uint32* bw; + UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; + } +} + +/* + * 1-bit palette => colormap/RGB + */ +DECLAREContigPutFunc(put1bitcmaptile) +{ + uint32** PALmap = img->PALmap; + + (void) x; (void) y; + fromskew /= 8; + while (h-- > 0) { + uint32* bw; + UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; + } +} + +/* + * 8-bit greyscale => colormap/RGB + */ +DECLAREContigPutFunc(putgreytile) +{ + int samplesperpixel = img->samplesperpixel; + uint32** BWmap = img->BWmap; + + (void) y; + while (h-- > 0) { + for (x = w; x-- > 0;) + { + *cp++ = BWmap[*pp][0]; + pp += samplesperpixel; + } + cp += toskew; + pp += fromskew; + } +} + +/* + * 16-bit greyscale => colormap/RGB + */ +DECLAREContigPutFunc(put16bitbwtile) +{ + int samplesperpixel = img->samplesperpixel; + uint32** BWmap = img->BWmap; + + (void) y; + while (h-- > 0) { + uint16 *wp = (uint16 *) pp; + + for (x = w; x-- > 0;) + { + /* use high order byte of 16bit value */ + + *cp++ = BWmap[*wp >> 8][0]; + pp += 2 * samplesperpixel; + wp += samplesperpixel; + } + cp += toskew; + pp += fromskew; + } +} + +/* + * 1-bit bilevel => colormap/RGB + */ +DECLAREContigPutFunc(put1bitbwtile) +{ + uint32** BWmap = img->BWmap; + + (void) x; (void) y; + fromskew /= 8; + while (h-- > 0) { + uint32* bw; + UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; + } +} + +/* + * 2-bit greyscale => colormap/RGB + */ +DECLAREContigPutFunc(put2bitbwtile) +{ + uint32** BWmap = img->BWmap; + + (void) x; (void) y; + fromskew /= 4; + while (h-- > 0) { + uint32* bw; + UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; + } +} + +/* + * 4-bit greyscale => colormap/RGB + */ +DECLAREContigPutFunc(put4bitbwtile) +{ + uint32** BWmap = img->BWmap; + + (void) x; (void) y; + fromskew /= 2; + while (h-- > 0) { + uint32* bw; + UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; + } +} + +/* + * 8-bit packed samples, no Map => RGB + */ +DECLAREContigPutFunc(putRGBcontig8bittile) +{ + int samplesperpixel = img->samplesperpixel; + + (void) x; (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + UNROLL8(w, NOP, + *cp++ = PACK(pp[0], pp[1], pp[2]); + pp += samplesperpixel); + cp += toskew; + pp += fromskew; + } +} + +/* + * 8-bit packed samples, w/ Map => RGB + */ +DECLAREContigPutFunc(putRGBcontig8bitMaptile) +{ + TIFFRGBValue* Map = img->Map; + int samplesperpixel = img->samplesperpixel; + + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + for (x = w; x-- > 0;) { + *cp++ = PACK(Map[pp[0]], Map[pp[1]], Map[pp[2]]); + pp += samplesperpixel; + } + pp += fromskew; + cp += toskew; + } +} + +/* + * 8-bit packed samples => RGBA w/ associated alpha + * (known to have Map == NULL) + */ +DECLAREContigPutFunc(putRGBAAcontig8bittile) +{ + int samplesperpixel = img->samplesperpixel; + + (void) x; (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + UNROLL8(w, NOP, + *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]); + pp += samplesperpixel); + cp += toskew; + pp += fromskew; + } +} + +/* + * 8-bit packed samples => RGBA w/ unassociated alpha + * (known to have Map == NULL) + */ +DECLAREContigPutFunc(putRGBUAcontig8bittile) +{ + int samplesperpixel = img->samplesperpixel; + + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + uint32 r, g, b, a; + for (x = w; x-- > 0;) { + a = pp[3]; + r = (pp[0] * a) / 255; + g = (pp[1] * a) / 255; + b = (pp[2] * a) / 255; + *cp++ = PACK4(r,g,b,a); + pp += samplesperpixel; + } + cp += toskew; + pp += fromskew; + } +} + +/* + * 16-bit packed samples => RGB + */ +DECLAREContigPutFunc(putRGBcontig16bittile) +{ + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + for (x = w; x-- > 0;) { + *cp++ = PACKW(wp[0], wp[1], wp[2]); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; + } +} + +/* + * 16-bit packed samples => RGBA w/ associated alpha + * (known to have Map == NULL) + */ +DECLAREContigPutFunc(putRGBAAcontig16bittile) +{ + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + for (x = w; x-- > 0;) { + *cp++ = PACKW4(wp[0], wp[1], wp[2], wp[3]); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; + } +} + +/* + * 16-bit packed samples => RGBA w/ unassociated alpha + * (known to have Map == NULL) + */ +DECLAREContigPutFunc(putRGBUAcontig16bittile) +{ + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + uint32 r,g,b,a; + /* + * We shift alpha down four bits just in case unsigned + * arithmetic doesn't handle the full range. + * We still have plenty of accuracy, since the output is 8 bits. + * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff) + * Since we want r*a * 0xff for eight bit output, + * we divide by (0xffff * 0xfff) / 0xff == 0x10eff. + */ + for (x = w; x-- > 0;) { + a = wp[3] >> 4; + r = (wp[0] * a) / 0x10eff; + g = (wp[1] * a) / 0x10eff; + b = (wp[2] * a) / 0x10eff; + *cp++ = PACK4(r,g,b,a); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; + } +} + +/* + * 8-bit packed CMYK samples w/o Map => RGB + * + * NB: The conversion of CMYK->RGB is *very* crude. + */ +DECLAREContigPutFunc(putRGBcontig8bitCMYKtile) +{ + int samplesperpixel = img->samplesperpixel; + uint16 r, g, b, k; + + (void) x; (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + UNROLL8(w, NOP, + k = 255 - pp[3]; + r = (k*(255-pp[0]))/255; + g = (k*(255-pp[1]))/255; + b = (k*(255-pp[2]))/255; + *cp++ = PACK(r, g, b); + pp += samplesperpixel); + cp += toskew; + pp += fromskew; + } +} + +/* + * 8-bit packed CMYK samples w/Map => RGB + * + * NB: The conversion of CMYK->RGB is *very* crude. + */ +DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) +{ + int samplesperpixel = img->samplesperpixel; + TIFFRGBValue* Map = img->Map; + uint16 r, g, b, k; + + (void) y; + fromskew *= samplesperpixel; + while (h-- > 0) { + for (x = w; x-- > 0;) { + k = 255 - pp[3]; + r = (k*(255-pp[0]))/255; + g = (k*(255-pp[1]))/255; + b = (k*(255-pp[2]))/255; + *cp++ = PACK(Map[r], Map[g], Map[b]); + pp += samplesperpixel; + } + pp += fromskew; + cp += toskew; + } +} + +#define DECLARESepPutFunc(name) \ +static void name(\ + TIFFRGBAImage* img,\ + uint32* cp,\ + uint32 x, uint32 y, \ + uint32 w, uint32 h,\ + int32 fromskew, int32 toskew,\ + tif_char* r, tif_char* g, tif_char* b, tif_char* a\ +) + +/* + * 8-bit unpacked samples => RGB + */ +DECLARESepPutFunc(putRGBseparate8bittile) +{ + (void) img; (void) x; (void) y; (void) a; + while (h-- > 0) { + UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++)); + SKEW(r, g, b, fromskew); + cp += toskew; + } +} + +/* + * 8-bit unpacked samples => RGB + */ +DECLARESepPutFunc(putRGBseparate8bitMaptile) +{ + TIFFRGBValue* Map = img->Map; + + (void) y; (void) a; + while (h-- > 0) { + for (x = w; x > 0; x--) + *cp++ = PACK(Map[*r++], Map[*g++], Map[*b++]); + SKEW(r, g, b, fromskew); + cp += toskew; + } +} + +/* + * 8-bit unpacked samples => RGBA w/ associated alpha + */ +DECLARESepPutFunc(putRGBAAseparate8bittile) +{ + (void) img; (void) x; (void) y; + while (h-- > 0) { + UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++)); + SKEW4(r, g, b, a, fromskew); + cp += toskew; + } +} + +/* + * 8-bit unpacked samples => RGBA w/ unassociated alpha + */ +DECLARESepPutFunc(putRGBUAseparate8bittile) +{ + (void) img; (void) y; + while (h-- > 0) { + uint32 rv, gv, bv, av; + for (x = w; x-- > 0;) { + av = *a++; + rv = (*r++ * av) / 255; + gv = (*g++ * av) / 255; + bv = (*b++ * av) / 255; + *cp++ = PACK4(rv,gv,bv,av); + } + SKEW4(r, g, b, a, fromskew); + cp += toskew; + } +} + +/* + * 16-bit unpacked samples => RGB + */ +DECLARESepPutFunc(putRGBseparate16bittile) +{ + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + + (void) img; (void) y; (void) a; + while (h-- > 0) { + for (x = 0; x < w; x++) + *cp++ = PACKW(*wr++, *wg++, *wb++); + SKEW(wr, wg, wb, fromskew); + cp += toskew; + } +} + +/* + * 16-bit unpacked samples => RGBA w/ associated alpha + */ +DECLARESepPutFunc(putRGBAAseparate16bittile) +{ + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + uint16 *wa = (uint16*) a; + + (void) img; (void) y; + while (h-- > 0) { + for (x = 0; x < w; x++) + *cp++ = PACKW4(*wr++, *wg++, *wb++, *wa++); + SKEW4(wr, wg, wb, wa, fromskew); + cp += toskew; + } +} + +/* + * 16-bit unpacked samples => RGBA w/ unassociated alpha + */ +DECLARESepPutFunc(putRGBUAseparate16bittile) +{ + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + uint16 *wa = (uint16*) a; + + (void) img; (void) y; + while (h-- > 0) { + uint32 vr,vg,vb,va; + /* + * We shift alpha down four bits just in case unsigned + * arithmetic doesn't handle the full range. + * We still have plenty of accuracy, since the output is 8 bits. + * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff) + * Since we want r*a * 0xff for eight bit output, + * we divide by (0xffff * 0xfff) / 0xff == 0x10eff. + */ + for (x = w; x-- > 0;) { + va = *wa++ >> 4; + vr = (*wr++ * va) / 0x10eff; + vg = (*wg++ * va) / 0x10eff; + vb = (*wb++ * va) / 0x10eff; + *cp++ = PACK4(vr,vg,vb,va); + } + SKEW4(wr, wg, wb, wa, fromskew); + cp += toskew; + } +} + +/* + * YCbCr -> RGB conversion and packing routines. The colorspace + * conversion algorithm comes from the IJG v5a code; see below + * for more information on how it works. + */ + +#define YCbCrtoRGB(dst, yc) { \ + int Y = (yc); \ + dst = PACK( \ + clamptab[Y+Crrtab[Cr]], \ + clamptab[Y + (int)((Cbgtab[Cb]+Crgtab[Cr])>>16)], \ + clamptab[Y+Cbbtab[Cb]]); \ +} +#define YCbCrSetup \ + TIFFYCbCrToRGB* ycbcr = img->ycbcr; \ + int* Crrtab = ycbcr->Cr_r_tab; \ + int* Cbbtab = ycbcr->Cb_b_tab; \ + int32* Crgtab = ycbcr->Cr_g_tab; \ + int32* Cbgtab = ycbcr->Cb_g_tab; \ + TIFFRGBValue* clamptab = ycbcr->clamptab + +/* + * 8-bit packed YCbCr samples => RGB + * This function is generic for different sampling sizes, + * and can handle blocks sizes that aren't multiples of the + * sampling size. However, it is substantially less optimized + * than the specific sampling cases. It is used as a fallback + * for difficult blocks. + */ +#ifdef notdef +static void putcontig8bitYCbCrGenericTile( + TIFFRGBAImage* img, + uint32* cp, + uint32 x, uint32 y, + uint32 w, uint32 h, + int32 fromskew, int32 toskew, + tif_char* pp, + int h_group, + int v_group ) + +{ + YCbCrSetup; + + uint32* cp1 = cp+w+toskew; + uint32* cp2 = cp1+w+toskew; + uint32* cp3 = cp2+w+toskew; + int32 incr = 3*w+4*toskew; + int Cb, Cr; + int group_size = v_group * h_group + 2; + + (void) y; + fromskew = (fromskew * group_size) / h_group; + + for( yy = 0; yy < h; yy++ ) + { + tif_char *pp_line; + int y_line_group = yy / v_group; + int y_remainder = yy - y_line_group * v_group; + + pp_line = pp + v_line_group * + + + for( xx = 0; xx < w; xx++ ) + { + Cb = pp + } + } + for (; h >= 4; h -= 4) { + x = w>>2; + do { + Cb = pp[16]; + Cr = pp[17]; + + YCbCrtoRGB(cp [0], pp[ 0]); + YCbCrtoRGB(cp [1], pp[ 1]); + YCbCrtoRGB(cp [2], pp[ 2]); + YCbCrtoRGB(cp [3], pp[ 3]); + YCbCrtoRGB(cp1[0], pp[ 4]); + YCbCrtoRGB(cp1[1], pp[ 5]); + YCbCrtoRGB(cp1[2], pp[ 6]); + YCbCrtoRGB(cp1[3], pp[ 7]); + YCbCrtoRGB(cp2[0], pp[ 8]); + YCbCrtoRGB(cp2[1], pp[ 9]); + YCbCrtoRGB(cp2[2], pp[10]); + YCbCrtoRGB(cp2[3], pp[11]); + YCbCrtoRGB(cp3[0], pp[12]); + YCbCrtoRGB(cp3[1], pp[13]); + YCbCrtoRGB(cp3[2], pp[14]); + YCbCrtoRGB(cp3[3], pp[15]); + + cp += 4, cp1 += 4, cp2 += 4, cp3 += 4; + pp += 18; + } while (--x); + cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; + pp += fromskew; + } +} +#endif + +/* + * 8-bit packed YCbCr samples w/ 4,4 subsampling => RGB + */ +DECLAREContigPutFunc(putcontig8bitYCbCr44tile) +{ + YCbCrSetup; + uint32* cp1 = cp+w+toskew; + uint32* cp2 = cp1+w+toskew; + uint32* cp3 = cp2+w+toskew; + int32 incr = 3*w+4*toskew; + + (void) y; + /* adjust fromskew */ + fromskew = (fromskew * 18) / 4; + if ((h & 3) == 0 && (w & 3) == 0) { + for (; h >= 4; h -= 4) { + x = w>>2; + do { + int Cb = pp[16]; + int Cr = pp[17]; + + YCbCrtoRGB(cp [0], pp[ 0]); + YCbCrtoRGB(cp [1], pp[ 1]); + YCbCrtoRGB(cp [2], pp[ 2]); + YCbCrtoRGB(cp [3], pp[ 3]); + YCbCrtoRGB(cp1[0], pp[ 4]); + YCbCrtoRGB(cp1[1], pp[ 5]); + YCbCrtoRGB(cp1[2], pp[ 6]); + YCbCrtoRGB(cp1[3], pp[ 7]); + YCbCrtoRGB(cp2[0], pp[ 8]); + YCbCrtoRGB(cp2[1], pp[ 9]); + YCbCrtoRGB(cp2[2], pp[10]); + YCbCrtoRGB(cp2[3], pp[11]); + YCbCrtoRGB(cp3[0], pp[12]); + YCbCrtoRGB(cp3[1], pp[13]); + YCbCrtoRGB(cp3[2], pp[14]); + YCbCrtoRGB(cp3[3], pp[15]); + + cp += 4, cp1 += 4, cp2 += 4, cp3 += 4; + pp += 18; + } while (--x); + cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; + pp += fromskew; + } + } else { + while (h > 0) { + for (x = w; x > 0;) { + int Cb = pp[16]; + int Cr = pp[17]; + switch (x) { + default: + switch (h) { + default: YCbCrtoRGB(cp3[3], pp[15]); /* FALLTHROUGH */ + case 3: YCbCrtoRGB(cp2[3], pp[11]); /* FALLTHROUGH */ + case 2: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 3: + switch (h) { + default: YCbCrtoRGB(cp3[2], pp[14]); /* FALLTHROUGH */ + case 3: YCbCrtoRGB(cp2[2], pp[10]); /* FALLTHROUGH */ + case 2: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 2: + switch (h) { + default: YCbCrtoRGB(cp3[1], pp[13]); /* FALLTHROUGH */ + case 3: YCbCrtoRGB(cp2[1], pp[ 9]); /* FALLTHROUGH */ + case 2: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 1: + switch (h) { + default: YCbCrtoRGB(cp3[0], pp[12]); /* FALLTHROUGH */ + case 3: YCbCrtoRGB(cp2[0], pp[ 8]); /* FALLTHROUGH */ + case 2: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + } + if (x < 4) { + cp += x; cp1 += x; cp2 += x; cp3 += x; + x = 0; + } + else { + cp += 4; cp1 += 4; cp2 += 4; cp3 += 4; + x -= 4; + } + pp += 18; + } + if (h <= 4) + break; + h -= 4; + cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; + pp += fromskew; + } + } +} + +/* + * 8-bit packed YCbCr samples w/ 4,2 subsampling => RGB + */ +DECLAREContigPutFunc(putcontig8bitYCbCr42tile) +{ + YCbCrSetup; + uint32* cp1 = cp+w+toskew; + int32 incr = 2*toskew+w; + + (void) y; + fromskew = (fromskew * 10) / 4; + if ((h & 3) == 0 && (w & 1) == 0) { + for (; h >= 2; h -= 2) { + x = w>>2; + do { + int Cb = pp[8]; + int Cr = pp[9]; + + YCbCrtoRGB(cp [0], pp[0]); + YCbCrtoRGB(cp [1], pp[1]); + YCbCrtoRGB(cp [2], pp[2]); + YCbCrtoRGB(cp [3], pp[3]); + YCbCrtoRGB(cp1[0], pp[4]); + YCbCrtoRGB(cp1[1], pp[5]); + YCbCrtoRGB(cp1[2], pp[6]); + YCbCrtoRGB(cp1[3], pp[7]); + + cp += 4, cp1 += 4; + pp += 10; + } while (--x); + cp += incr, cp1 += incr; + pp += fromskew; + } + } else { + while (h > 0) { + for (x = w; x > 0;) { + int Cb = pp[8]; + int Cr = pp[9]; + switch (x) { + default: + switch (h) { + default: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 3: + switch (h) { + default: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 2: + switch (h) { + default: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 1: + switch (h) { + default: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + } + if (x < 4) { + cp += x; cp1 += x; + x = 0; + } + else { + cp += 4; cp1 += 4; + x -= 4; + } + pp += 10; + } + if (h <= 2) + break; + h -= 2; + cp += incr, cp1 += incr; + pp += fromskew; + } + } +} + +/* + * 8-bit packed YCbCr samples w/ 4,1 subsampling => RGB + */ +DECLAREContigPutFunc(putcontig8bitYCbCr41tile) +{ + YCbCrSetup; + + (void) y; + /* XXX adjust fromskew */ + do { + x = w>>2; + do { + int Cb = pp[4]; + int Cr = pp[5]; + + YCbCrtoRGB(cp [0], pp[0]); + YCbCrtoRGB(cp [1], pp[1]); + YCbCrtoRGB(cp [2], pp[2]); + YCbCrtoRGB(cp [3], pp[3]); + + cp += 4; + pp += 6; + } while (--x); + + if( (w&3) != 0 ) + { + int Cb = pp[4]; + int Cr = pp[5]; + + switch( (w&3) ) { + case 3: YCbCrtoRGB(cp [2], pp[2]); + case 2: YCbCrtoRGB(cp [1], pp[1]); + case 1: YCbCrtoRGB(cp [0], pp[0]); + case 0: break; + } + + cp += (w&3); + pp += 6; + } + + cp += toskew; + pp += fromskew; + } while (--h); + +} + +/* + * 8-bit packed YCbCr samples w/ 2,2 subsampling => RGB + */ +DECLAREContigPutFunc(putcontig8bitYCbCr22tile) +{ + YCbCrSetup; + uint32* cp1 = cp+w+toskew; + int32 incr = 2*toskew+w; + + (void) y; + fromskew = (fromskew * 6) / 2; + if ((h & 1) == 0 && (w & 1) == 0) { + for (; h >= 2; h -= 2) { + x = w>>1; + do { + int Cb = pp[4]; + int Cr = pp[5]; + + YCbCrtoRGB(cp [0], pp[0]); + YCbCrtoRGB(cp [1], pp[1]); + YCbCrtoRGB(cp1[0], pp[2]); + YCbCrtoRGB(cp1[1], pp[3]); + + cp += 2, cp1 += 2; + pp += 6; + } while (--x); + cp += incr, cp1 += incr; + pp += fromskew; + } + } else { + while (h > 0) { + for (x = w; x > 0;) { + int Cb = pp[4]; + int Cr = pp[5]; + switch (x) { + default: + switch (h) { + default: YCbCrtoRGB(cp1[1], pp[ 3]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 1: + switch (h) { + default: YCbCrtoRGB(cp1[0], pp[ 2]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + } + if (x < 2) { + cp += x; cp1 += x; + x = 0; + } + else { + cp += 2; cp1 += 2; + x -= 2; + } + pp += 6; + } + if (h <= 2) + break; + h -= 2; + cp += incr, cp1 += incr; + pp += fromskew; + } + } +} + +/* + * 8-bit packed YCbCr samples w/ 2,1 subsampling => RGB + */ +DECLAREContigPutFunc(putcontig8bitYCbCr21tile) +{ + YCbCrSetup; + + (void) y; + fromskew = (fromskew * 4) / 2; + do { + x = w>>1; + do { + int Cb = pp[2]; + int Cr = pp[3]; + + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp[1], pp[1]); + + cp += 2; + pp += 4; + } while (--x); + + if( (w&1) != 0 ) + { + int Cb = pp[2]; + int Cr = pp[3]; + + YCbCrtoRGB(cp [0], pp[0]); + + cp += 1; + pp += 4; + } + + cp += toskew; + pp += fromskew; + } while (--h); +} + +/* + * 8-bit packed YCbCr samples w/ no subsampling => RGB + */ +DECLAREContigPutFunc(putcontig8bitYCbCr11tile) +{ + YCbCrSetup; + + (void) y; + fromskew *= 3; + do { + x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ + do { + int Cb = pp[1]; + int Cr = pp[2]; + + YCbCrtoRGB(*cp++, pp[0]); + + pp += 3; + } while (--x); + cp += toskew; + pp += fromskew; + } while (--h); +} +#undef YCbCrSetup +#undef YCbCrtoRGB + +#define LumaRed coeffs[0] +#define LumaGreen coeffs[1] +#define LumaBlue coeffs[2] +#define SHIFT 16 +#define FIX(x) ((int32)((x) * (1L<RGB conversion tables. The conversion + * is done according to the 6.0 spec: + * + * R = Y + Cr*(2 - 2*LumaRed) + * B = Y + Cb*(2 - 2*LumaBlue) + * G = Y + * - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen + * - LumaRed*Cr*(2-2*LumaRed)/LumaGreen + * + * To avoid floating point arithmetic the fractional constants that + * come out of the equations are represented as fixed point values + * in the range 0...2^16. We also eliminate multiplications by + * pre-calculating possible values indexed by Cb and Cr (this code + * assumes conversion is being done for 8-bit samples). + */ +static void +TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, TIFF* tif) +{ + TIFFRGBValue* clamptab; + float* coeffs; + int i; + + clamptab = (TIFFRGBValue*)( + (tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))); + _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ + ycbcr->clamptab = (clamptab += 256); + for (i = 0; i < 256; i++) + clamptab[i] = i; + _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ + TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs); + _TIFFmemcpy(ycbcr->coeffs, coeffs, 3*sizeof (float)); + { float f1 = 2-2*LumaRed; int32 D1 = FIX(f1); + float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2); + float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3); + float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4); + int x; + + ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); + ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; + ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256); + ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256; + /* + * i is the actual input pixel value in the range 0..255 + * Cb and Cr values are in the range -128..127 (actually + * they are in a range defined by the ReferenceBlackWhite + * tag) so there is some range shifting to do here when + * constructing tables indexed by the raw pixel data. + * + * XXX handle ReferenceBlackWhite correctly to calculate + * Cb/Cr values to use in constructing the tables. + */ + for (i = 0, x = -128; i < 256; i++, x++) { + ycbcr->Cr_r_tab[i] = (int)((D1*x + ONE_HALF)>>SHIFT); + ycbcr->Cb_b_tab[i] = (int)((D3*x + ONE_HALF)>>SHIFT); + ycbcr->Cr_g_tab[i] = D2*x; + ycbcr->Cb_g_tab[i] = D4*x + ONE_HALF; + } + } +} +#undef SHIFT +#undef ONE_HALF +#undef FIX +#undef LumaBlue +#undef LumaGreen +#undef LumaRed + +static tileContigRoutine +initYCbCrConversion(TIFF* tif, TIFFRGBAImage* img) +{ + uint16 hs, vs; + + if (img->ycbcr == NULL) { + img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc(tif, + TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long)) + + 4*256*sizeof (TIFFRGBValue) + + 2*256*sizeof (int) + + 2*256*sizeof (int32) + ); + if (img->ycbcr == NULL) { + TIFFError(TIFFFileName(img->tif), + "No space for YCbCr->RGB conversion state"); + return (NULL); + } + TIFFYCbCrToRGBInit(img->ycbcr, img->tif); + } else { + float* coeffs; + + TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs); + if (_TIFFmemcmp(coeffs, img->ycbcr->coeffs, 3*sizeof (float)) != 0) + TIFFYCbCrToRGBInit(img->ycbcr, img->tif); + } + /* + * The 6.0 spec says that subsampling must be + * one of 1, 2, or 4, and that vertical subsampling + * must always be <= horizontal subsampling; so + * there are only a few possibilities and we just + * enumerate the cases. + */ + TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); + switch ((hs<<4)|vs) { + case 0x44: return ((tileContigRoutine)putcontig8bitYCbCr44tile); + case 0x42: return ((tileContigRoutine)putcontig8bitYCbCr42tile); + case 0x41: return ((tileContigRoutine)putcontig8bitYCbCr41tile); + case 0x22: return ((tileContigRoutine)putcontig8bitYCbCr22tile); + case 0x21: return ((tileContigRoutine)putcontig8bitYCbCr21tile); + case 0x11: return ((tileContigRoutine)putcontig8bitYCbCr11tile); + } + return (NULL); +} + +/* + * Greyscale images with less than 8 bits/sample are handled + * with a table to avoid lots of shifts and masks. The table + * is setup so that put*bwtile (below) can retrieve 8/bitspersample + * pixel values simply by indexing into the table with one + * number. + */ +static int +makebwmap(TIFF* tif, TIFFRGBAImage* img) +{ + TIFFRGBValue* Map = img->Map; + int bitspersample = img->bitspersample; + int nsamples = 8 / bitspersample; + int i; + uint32* p; + + if( nsamples == 0 ) + nsamples = 1; + + img->BWmap = (uint32**) _TIFFmalloc(tif, + 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); + if (img->BWmap == NULL) { + TIFFError(TIFFFileName(img->tif), "No space for B&W mapping table"); + return (0); + } + p = (uint32*)(img->BWmap + 256); + for (i = 0; i < 256; i++) { + TIFFRGBValue c; + img->BWmap[i] = p; + switch (bitspersample) { +#define GREY(x) c = Map[x]; *p++ = PACK(c,c,c); + case 1: + GREY(i>>7); + GREY((i>>6)&1); + GREY((i>>5)&1); + GREY((i>>4)&1); + GREY((i>>3)&1); + GREY((i>>2)&1); + GREY((i>>1)&1); + GREY(i&1); + break; + case 2: + GREY(i>>6); + GREY((i>>4)&3); + GREY((i>>2)&3); + GREY(i&3); + break; + case 4: + GREY(i>>4); + GREY(i&0xf); + break; + case 8: + case 16: + GREY(i); + break; + } +#undef GREY + } + return (1); +} + +/* + * Construct a mapping table to convert from the range + * of the data samples to [0,255] --for display. This + * process also handles inverting B&W images when needed. + */ +static int +setupMap(TIFF* tif, TIFFRGBAImage* img) +{ + int32 x, range; + + range = (int32)((1L<bitspersample)-1); + + /* treat 16 bit the same as eight bit */ + if( img->bitspersample == 16 ) + range = (int32) 255; + + img->Map=(TIFFRGBValue*)_TIFFmalloc(tif,(range+1)*sizeof(TIFFRGBValue)); + if (img->Map == NULL) { + TIFFError(TIFFFileName(img->tif), + "No space for photometric conversion table"); + return (0); + } + if (img->photometric == PHOTOMETRIC_MINISWHITE) { + for (x = 0; x <= range; x++) + img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range); + } else { + for (x = 0; x <= range; x++) + img->Map[x] = (TIFFRGBValue) ((x * 255) / range); + } + if (img->bitspersample <= 16 && + (img->photometric == PHOTOMETRIC_MINISBLACK || + img->photometric == PHOTOMETRIC_MINISWHITE)) { + /* + * Use photometric mapping table to construct + * unpacking tables for samples <= 8 bits. + */ + if (!makebwmap(tif, img)) + return (0); + /* no longer need Map, free it */ + _TIFFfree(tif, img->Map), img->Map = NULL; + } + return (1); +} + +static int +checkcmap(TIFFRGBAImage* img) +{ + uint16* r = img->redcmap; + uint16* g = img->greencmap; + uint16* b = img->bluecmap; + long n = 1L<bitspersample; + + while (n-- > 0) + if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) + return (16); + return (8); +} + +static void +cvtcmap(TIFFRGBAImage* img) +{ + uint16* r = img->redcmap; + uint16* g = img->greencmap; + uint16* b = img->bluecmap; + long i; + + for (i = (1L<bitspersample)-1; i >= 0; i--) { +#define CVT(x) ((uint16)((x)>>8)) + r[i] = CVT(r[i]); + g[i] = CVT(g[i]); + b[i] = CVT(b[i]); +#undef CVT + } +} + +/* + * Palette images with <= 8 bits/sample are handled + * with a table to avoid lots of shifts and masks. The table + * is setup so that put*cmaptile (below) can retrieve 8/bitspersample + * pixel values simply by indexing into the table with one + * number. + */ +static int +makecmap(TIFF* tif, TIFFRGBAImage* img) +{ + int bitspersample = img->bitspersample; + int nsamples = 8 / bitspersample; + uint16* r = img->redcmap; + uint16* g = img->greencmap; + uint16* b = img->bluecmap; + uint32 *p; + int i; + + img->PALmap = (uint32**) _TIFFmalloc(tif, + 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); + if (img->PALmap == NULL) { + TIFFError(TIFFFileName(img->tif), "No space for Palette mapping table"); + return (0); + } + p = (uint32*)(img->PALmap + 256); + for (i = 0; i < 256; i++) { + TIFFRGBValue c; + img->PALmap[i] = p; +#define CMAP(x) c = x; *p++ = PACK(r[c]&0xff, g[c]&0xff, b[c]&0xff); + switch (bitspersample) { + case 1: + CMAP(i>>7); + CMAP((i>>6)&1); + CMAP((i>>5)&1); + CMAP((i>>4)&1); + CMAP((i>>3)&1); + CMAP((i>>2)&1); + CMAP((i>>1)&1); + CMAP(i&1); + break; + case 2: + CMAP(i>>6); + CMAP((i>>4)&3); + CMAP((i>>2)&3); + CMAP(i&3); + break; + case 4: + CMAP(i>>4); + CMAP(i&0xf); + break; + case 8: + CMAP(i); + break; + } +#undef CMAP + } + return (1); +} + +/* + * Construct any mapping table used + * by the associated put routine. + */ +static int +buildMap(TIFF* tif, TIFFRGBAImage* img) +{ + switch (img->photometric) { + case PHOTOMETRIC_RGB: + case PHOTOMETRIC_YCBCR: + case PHOTOMETRIC_SEPARATED: + if (img->bitspersample == 8) + break; + /* fall thru... */ + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_MINISWHITE: + if (!setupMap(tif, img)) + return (0); + break; + case PHOTOMETRIC_PALETTE: + /* + * Convert 16-bit colormap to 8-bit (unless it looks + * like an old-style 8-bit colormap). + */ + if (checkcmap(img) == 16) + cvtcmap(img); + else + TIFFWarning(TIFFFileName(img->tif), "Assuming 8-bit colormap"); + /* + * Use mapping table and colormap to construct + * unpacking tables for samples < 8 bits. + */ + if (img->bitspersample <= 8 && !makecmap(tif, img)) + return (0); + break; + } + return (1); +} + +/* + * Select the appropriate conversion routine for packed data. + */ +static int +pickTileContigCase(TIFF* tif, TIFFRGBAImage* img) +{ + tileContigRoutine put = 0; + + if (buildMap(tif, img)) { + switch (img->photometric) { + case PHOTOMETRIC_RGB: + switch (img->bitspersample) { + case 8: + if (!img->Map) { + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + put = putRGBAAcontig8bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + put = putRGBUAcontig8bittile; + else + put = putRGBcontig8bittile; + } else + put = putRGBcontig8bitMaptile; + break; + case 16: + put = putRGBcontig16bittile; + if (!img->Map) { + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + put = putRGBAAcontig16bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + put = putRGBUAcontig16bittile; + } + break; + } + break; + case PHOTOMETRIC_SEPARATED: + if (img->bitspersample == 8) { + if (!img->Map) + put = putRGBcontig8bitCMYKtile; + else + put = putRGBcontig8bitCMYKMaptile; + } + break; + case PHOTOMETRIC_PALETTE: + switch (img->bitspersample) { + case 8: put = put8bitcmaptile; break; + case 4: put = put4bitcmaptile; break; + case 2: put = put2bitcmaptile; break; + case 1: put = put1bitcmaptile; break; + } + break; + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + switch (img->bitspersample) { + case 16: put = put16bitbwtile; break; + case 8: put = putgreytile; break; + case 4: put = put4bitbwtile; break; + case 2: put = put2bitbwtile; break; + case 1: put = put1bitbwtile; break; + } + break; + case PHOTOMETRIC_YCBCR: + if (img->bitspersample == 8) + put = initYCbCrConversion(tif, img); + break; + } + } + return ((img->put.contig = put) != 0); +} + +/* + * Select the appropriate conversion routine for unpacked data. + * + * NB: we assume that unpacked single channel data is directed + * to the "packed routines. + */ +static int +pickTileSeparateCase(TIFF* tif, TIFFRGBAImage* img) +{ + tileSeparateRoutine put = 0; + + if (buildMap(tif, img)) { + switch (img->photometric) { + case PHOTOMETRIC_RGB: + switch (img->bitspersample) { + case 8: + if (!img->Map) { + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + put = putRGBAAseparate8bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + put = putRGBUAseparate8bittile; + else + put = putRGBseparate8bittile; + } else + put = putRGBseparate8bitMaptile; + break; + case 16: + put = putRGBseparate16bittile; + if (!img->Map) { + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + put = putRGBAAseparate16bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + put = putRGBUAseparate16bittile; + } + break; + } + break; + } + } + return ((img->put.separate = put) != 0); +} + +/* + * Read a whole strip off data from the file, and convert to RGBA form. + * If this is the last strip, then it will only contain the portion of + * the strip that is actually within the image space. The result is + * organized in bottom to top form. + */ + + +int +TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) + +{ + char emsg[1024]; + TIFFRGBAImage img; + int ok; + uint32 rowsperstrip, rows_to_read; + + if( TIFFIsTiled( tif ) ) + { + TIFFError(TIFFFileName(tif), + "Can't use TIFFReadRGBAStrip() with tiled file."); + return (0); + } + + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + if( (row % rowsperstrip) != 0 ) + { + TIFFError(TIFFFileName(tif), + "Row passed to TIFFReadRGBAStrip() must be first in a strip."); + return (0); + } + + if (TIFFRGBAImageBegin(&img, tif, 0, emsg)) { + + img.row_offset = row; + img.col_offset = 0; + + if( row + rowsperstrip > img.height ) + rows_to_read = img.height - row; + else + rows_to_read = rowsperstrip; + + ok = TIFFRGBAImageGet(&img, raster, img.width, rows_to_read ); + + TIFFRGBAImageEnd(tif, &img); + } else { + TIFFError(TIFFFileName(tif), emsg); + ok = 0; + } + + return (ok); +} + +/* + * Read a whole tile off data from the file, and convert to RGBA form. + * The returned RGBA data is organized from bottom to top of tile, + * and may include zeroed areas if the tile extends off the image. + */ + +int +TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) + +{ + char emsg[1024]; + TIFFRGBAImage img; + int ok; + uint32 tile_xsize, tile_ysize; + uint32 read_xsize, read_ysize; + uint32 i_row; + + /* + * Verify that our request is legal - on a tile file, and on a + * tile boundary. + */ + + if( !TIFFIsTiled( tif ) ) + { + TIFFError(TIFFFileName(tif), + "Can't use TIFFReadRGBATile() with stripped file."); + return (0); + } + + TIFFGetFieldDefaulted(tif, TIFFTAG_TILEWIDTH, &tile_xsize); + TIFFGetFieldDefaulted(tif, TIFFTAG_TILELENGTH, &tile_ysize); + if( (col % tile_xsize) != 0 || (row % tile_ysize) != 0 ) + { + TIFFError(TIFFFileName(tif), + "Row/col passed to TIFFReadRGBATile() must be top" + "left corner of a tile."); + return (0); + } + + /* + * Setup the RGBA reader. + */ + + if ( !TIFFRGBAImageBegin(&img, tif, 0, emsg)) { + TIFFError(TIFFFileName(tif), emsg); + return( 0 ); + } + + /* + * The TIFFRGBAImageGet() function doesn't allow us to get off the + * edge of the image, even to fill an otherwise valid tile. So we + * figure out how much we can read, and fix up the tile buffer to + * a full tile configuration afterwards. + */ + + if( row + tile_ysize > img.height ) + read_ysize = img.height - row; + else + read_ysize = tile_ysize; + + if( col + tile_xsize > img.width ) + read_xsize = img.width - col; + else + read_xsize = tile_xsize; + + /* + * Read the chunk of imagery. + */ + + img.row_offset = row; + img.col_offset = col; + + ok = TIFFRGBAImageGet(&img, raster, read_xsize, read_ysize ); + + TIFFRGBAImageEnd(tif, &img); + + /* + * If our read was incomplete we will need to fix up the tile by + * shifting the data around as if a full tile of data is being returned. + * + * This is all the more complicated because the image is organized in + * bottom to top format. + */ + + if( read_xsize == tile_xsize && read_ysize == tile_ysize ) + return( ok ); + + for( i_row = 0; i_row < read_ysize; i_row++ ) + { + memmove( raster + (tile_ysize - i_row - 1) * tile_xsize, + raster + (read_ysize - i_row - 1) * read_xsize, + read_xsize * sizeof(uint32) ); + _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize+read_xsize, + 0, sizeof(uint32) * (tile_xsize - read_xsize) ); + } + + for( i_row = read_ysize; i_row < tile_ysize; i_row++ ) + { + _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize, + 0, sizeof(uint32) * tile_xsize ); + } + + return (ok); +} diff --git a/src/libs/pdflib/libs/tiff/tif_luv.c b/src/libs/pdflib/libs/tiff/tif_luv.c new file mode 100644 index 0000000000..36c939152e --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_luv.c @@ -0,0 +1,1627 @@ +/* PDFlib GmbH cvsid: $Id: tif_luv.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ +/* + * Copyright (c) 1997 Greg Ward Larson + * Copyright (c) 1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler, Greg Larson and Silicon Graphics may not be used in any + * advertising or publicity relating to the software without the specific, + * prior written permission of Sam Leffler, Greg Larson and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER, GREG LARSON OR SILICON GRAPHICS BE LIABLE + * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tiffiop.h" +#ifdef LOGLUV_SUPPORT + +/* + * TIFF Library. + * LogLuv compression support for high dynamic range images. + * + * Contributed by Greg Larson. + * + * LogLuv image support uses the TIFF library to store 16 or 10-bit + * log luminance values with 8 bits each of u and v or a 14-bit index. + * + * The codec can take as input and produce as output 32-bit IEEE float values + * as well as 16-bit integer values. A 16-bit luminance is interpreted + * as a sign bit followed by a 15-bit integer that is converted + * to and from a linear magnitude using the transformation: + * + * L = 2^( (Le+.5)/256 - 64 ) # real from 15-bit + * + * Le = floor( 256*(log2(L) + 64) ) # 15-bit from real + * + * The actual conversion to world luminance units in candelas per sq. meter + * requires an additional multiplier, which is stored in the TIFFTAG_STONITS. + * This value is usually set such that a reasonable exposure comes from + * clamping decoded luminances above 1 to 1 in the displayed image. + * + * The 16-bit values for u and v may be converted to real values by dividing + * each by 32768. (This allows for negative values, which aren't useful as + * far as we know, but are left in case of future improvements in human + * color vision.) + * + * Conversion from (u,v), which is actually the CIE (u',v') system for + * you color scientists, is accomplished by the following transformation: + * + * u = 4*x / (-2*x + 12*y + 3) + * v = 9*y / (-2*x + 12*y + 3) + * + * x = 9*u / (6*u - 16*v + 12) + * y = 4*v / (6*u - 16*v + 12) + * + * This process is greatly simplified by passing 32-bit IEEE floats + * for each of three CIE XYZ coordinates. The codec then takes care + * of conversion to and from LogLuv, though the application is still + * responsible for interpreting the TIFFTAG_STONITS calibration factor. + * + * By definition, a CIE XYZ vector of [1 1 1] corresponds to a neutral white + * point of (x,y)=(1/3,1/3). However, most color systems assume some other + * white point, such as D65, and an absolute color conversion to XYZ then + * to another color space with a different white point may introduce an + * unwanted color cast to the image. It is often desirable, therefore, to + * perform a white point conversion that maps the input white to [1 1 1] + * in XYZ, then record the original white point using the TIFFTAG_WHITEPOINT + * tag value. A decoder that demands absolute color calibration may use + * this white point tag to get back the original colors, but usually it + * will be ignored and the new white point will be used instead that + * matches the output color space. + * + * Pixel information is compressed into one of two basic encodings, depending + * on the setting of the compression tag, which is one of COMPRESSION_SGILOG + * or COMPRESSION_SGILOG24. For COMPRESSION_SGILOG, greyscale data is + * stored as: + * + * 1 15 + * |-+---------------| + * + * COMPRESSION_SGILOG color data is stored as: + * + * 1 15 8 8 + * |-+---------------|--------+--------| + * S Le ue ve + * + * For the 24-bit COMPRESSION_SGILOG24 color format, the data is stored as: + * + * 10 14 + * |----------|--------------| + * Le' Ce + * + * There is no sign bit in the 24-bit case, and the (u,v) chromaticity is + * encoded as an index for optimal color resolution. The 10 log bits are + * defined by the following conversions: + * + * L = 2^((Le'+.5)/64 - 12) # real from 10-bit + * + * Le' = floor( 64*(log2(L) + 12) ) # 10-bit from real + * + * The 10 bits of the smaller format may be converted into the 15 bits of + * the larger format by multiplying by 4 and adding 13314. Obviously, + * a smaller range of magnitudes is covered (about 5 orders of magnitude + * instead of 38), and the lack of a sign bit means that negative luminances + * are not allowed. (Well, they aren't allowed in the real world, either, + * but they are useful for certain types of image processing.) + * + * The desired user format is controlled by the setting the internal + * pseudo tag TIFFTAG_SGILOGDATAFMT to one of: + * SGILOGDATAFMT_FLOAT = IEEE 32-bit float XYZ values + * SGILOGDATAFMT_16BIT = 16-bit integer encodings of logL, u and v + * Raw data i/o is also possible using: + * SGILOGDATAFMT_RAW = 32-bit unsigned integer with encoded pixel + * In addition, the following decoding is provided for ease of display: + * SGILOGDATAFMT_8BIT = 8-bit default RGB gamma-corrected values + * + * For grayscale images, we provide the following data formats: + * SGILOGDATAFMT_FLOAT = IEEE 32-bit float Y values + * SGILOGDATAFMT_16BIT = 16-bit integer w/ encoded luminance + * SGILOGDATAFMT_8BIT = 8-bit gray monitor values + * + * Note that the COMPRESSION_SGILOG applies a simple run-length encoding + * scheme by separating the logL, u and v bytes for each row and applying + * a PackBits type of compression. Since the 24-bit encoding is not + * adaptive, the 32-bit color format takes less space in many cases. + * + * Further control is provided over the conversion from higher-resolution + * formats to final encoded values through the pseudo tag + * TIFFTAG_SGILOGENCODE: + * SGILOGENCODE_NODITHER = do not dither encoded values + * SGILOGENCODE_RANDITHER = apply random dithering during encoding + * + * The default value of this tag is SGILOGENCODE_NODITHER for + * COMPRESSION_SGILOG to maximize run-length encoding and + * SGILOGENCODE_RANDITHER for COMPRESSION_SGILOG24 to turn + * quantization errors into noise. + */ + +#include +#include +#include +#include + +/* + * State block for each open TIFF + * file using LogLuv compression/decompression. + */ +typedef struct logLuvState LogLuvState; + +struct logLuvState { + int user_datafmt; /* user data format */ + int encode_meth; /* encoding method */ + int pixel_size; /* bytes per pixel */ + + tidata_t* tbuf; /* translation buffer */ + int tbuflen; /* buffer length */ + void (*tfunc)(LogLuvState*, tidata_t, int); + + TIFFVSetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ +}; + +#define DecoderState(tif) ((LogLuvState*) (tif)->tif_data) +#ifdef PDFLIB_TIFFWRITE_SUPPORT +#define EncoderState(tif) ((LogLuvState*) (tif)->tif_data) +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#define N(a) (sizeof(a)/sizeof(a[0])) +#define SGILOGDATAFMT_UNKNOWN -1 + +#define MINRUN 4 /* minimum run length */ + +/* + * Decode a string of 16-bit gray pixels. + */ +static int +LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +{ + LogLuvState* sp = DecoderState(tif); + int shft, i, npixels; + tif_char* bp; + int16* tp; + int16 b; + int cc, rc; + + assert(s == 0); + assert(sp != NULL); + + npixels = occ / sp->pixel_size; + + if (sp->user_datafmt == SGILOGDATAFMT_16BIT) + tp = (int16*) op; + else { + assert(sp->tbuflen >= npixels); + tp = (int16*) sp->tbuf; + } + _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); + + bp = (tif_char*) tif->tif_rawcp; + cc = tif->tif_rawcc; + /* get each byte string */ + for (shft = 2*8; (shft -= 8) >= 0; ) { + for (i = 0; i < npixels && cc > 0; ) + if (*bp >= 128) { /* run */ + rc = *bp++ + (2-128); + b = (int16)*bp++ << shft; + cc -= 2; + while (rc--) + tp[i++] |= b; + } else { /* non-run */ + rc = *bp++; /* nul is noop */ + while (--cc && rc--) + tp[i++] |= (int16)*bp++ << shft; + } + if (i != npixels) { + TIFFError(tif->tif_name, + "LogL16Decode: Not enough data at row %d (short %d pixels)", + tif->tif_row, npixels - i); + tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcc = cc; + return (0); + } + } + (*sp->tfunc)(sp, op, npixels); + tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcc = cc; + return (1); +} + +/* + * Decode a string of 24-bit pixels. + */ +static int +LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +{ + LogLuvState* sp = DecoderState(tif); + int cc, i, npixels; + tif_char* bp; + uint32* tp; + + assert(s == 0); + assert(sp != NULL); + + npixels = occ / sp->pixel_size; + + if (sp->user_datafmt == SGILOGDATAFMT_RAW) + tp = (uint32 *)op; + else { + assert(sp->tbuflen >= npixels); + tp = (uint32 *) sp->tbuf; + } + /* copy to array of uint32 */ + bp = (tif_char*) tif->tif_rawcp; + cc = tif->tif_rawcc; + for (i = 0; i < npixels && cc > 0; i++) { + tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2]; + bp += 3; + cc -= 3; + } + tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcc = cc; + if (i != npixels) { + TIFFError(tif->tif_name, + "LogLuvDecode24: Not enough data at row %d (short %d pixels)", + tif->tif_row, npixels - i); + return (0); + } + (*sp->tfunc)(sp, op, npixels); + return (1); +} + +/* + * Decode a string of 32-bit pixels. + */ +static int +LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +{ + LogLuvState* sp; + int shft, i, npixels; + tif_char* bp; + uint32* tp; + uint32 b; + int cc, rc; + + assert(s == 0); + sp = DecoderState(tif); + assert(sp != NULL); + + npixels = occ / sp->pixel_size; + + if (sp->user_datafmt == SGILOGDATAFMT_RAW) + tp = (uint32*) op; + else { + assert(sp->tbuflen >= npixels); + tp = (uint32*) sp->tbuf; + } + _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); + + bp = (tif_char*) tif->tif_rawcp; + cc = tif->tif_rawcc; + /* get each byte string */ + for (shft = 4*8; (shft -= 8) >= 0; ) { + for (i = 0; i < npixels && cc > 0; ) + if (*bp >= 128) { /* run */ + rc = *bp++ + (2-128); + b = (uint32)*bp++ << shft; + cc -= 2; + while (rc--) + tp[i++] |= b; + } else { /* non-run */ + rc = *bp++; /* nul is noop */ + while (--cc && rc--) + tp[i++] |= (uint32)*bp++ << shft; + } + if (i != npixels) { + TIFFError(tif->tif_name, + "LogLuvDecode32: Not enough data at row %d (short %d pixels)", + tif->tif_row, npixels - i); + tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcc = cc; + return (0); + } + } + (*sp->tfunc)(sp, op, npixels); + tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcc = cc; + return (1); +} + +/* + * Decode a strip of pixels. We break it into rows to + * maintain synchrony with the encode algorithm, which + * is row by row. + */ +static int +LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + tsize_t rowlen = TIFFScanlineSize(tif); + + assert(cc%rowlen == 0); + while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) + bp += rowlen, cc -= rowlen; + return (cc == 0); +} + +/* + * Decode a tile of pixels. We break it into rows to + * maintain synchrony with the encode algorithm, which + * is row by row. + */ +static int +LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + tsize_t rowlen = TIFFTileRowSize(tif); + + assert(cc%rowlen == 0); + while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) + bp += rowlen, cc -= rowlen; + return (cc == 0); +} + +/* + * Encode a row of 16-bit pixels. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + LogLuvState* sp = EncoderState(tif); + int shft, i, j, npixels; + tidata_t op; + int16* tp; + int16 b; + int occ, rc=0, mask, beg; + + assert(s == 0); + assert(sp != NULL); + npixels = cc / sp->pixel_size; + + if (sp->user_datafmt == SGILOGDATAFMT_16BIT) + tp = (int16*) bp; + else { + tp = (int16*) sp->tbuf; + assert(sp->tbuflen >= npixels); + (*sp->tfunc)(sp, bp, npixels); + } + /* compress each byte string */ + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + for (shft = 2*8; (shft -= 8) >= 0; ) + for (i = 0; i < npixels; i += rc) { + if (occ < 4) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (-1); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + } + mask = 0xff << shft; /* find next run */ + for (beg = i; beg < npixels; beg += rc) { + b = tp[beg] & mask; + rc = 1; + while (rc < 127+2 && beg+rc < npixels && + (tp[beg+rc] & mask) == b) + rc++; + if (rc >= MINRUN) + break; /* long enough */ + } + if (beg-i > 1 && beg-i < MINRUN) { + b = tp[i] & mask; /* check short run */ + j = i+1; + while ((tp[j++] & mask) == b) + if (j == beg) { + *op++ = 128-2+j-i; + *op++ = b >> shft; + occ -= 2; + i = beg; + break; + } + } + while (i < beg) { /* write out non-run */ + if ((j = beg-i) > 127) j = 127; + if (occ < j+3) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize + - occ; + if (!TIFFFlushData1(tif)) + return (-1); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize + - tif->tif_rawcc; + } + *op++ = j; occ--; + while (j--) { + *op++ = tp[i++] >> shft & 0xff; + occ--; + } + } + if (rc >= MINRUN) { /* write out run */ + *op++ = 128-2+rc; + *op++ = tp[beg] >> shft & 0xff; + occ -= 2; + } else + rc = 0; + } + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + + return (0); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Encode a row of 24-bit pixels. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + LogLuvState* sp = EncoderState(tif); + int i, npixels, occ; + tidata_t op; + uint32* tp; + + assert(s == 0); + assert(sp != NULL); + npixels = cc / sp->pixel_size; + + if (sp->user_datafmt == SGILOGDATAFMT_RAW) + tp = (uint32*) bp; + else { + tp = (uint32*) sp->tbuf; + assert(sp->tbuflen >= npixels); + (*sp->tfunc)(sp, bp, npixels); + } + /* write out encoded pixels */ + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + for (i = npixels; i--; ) { + if (occ < 3) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (-1); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + } + *op++ = (tidataval_t)(*tp >> 16); + *op++ = (tidataval_t)(*tp >> 8 & 0xff); + *op++ = (tidataval_t)(*tp++ & 0xff); + occ -= 3; + } + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + + return (0); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Encode a row of 32-bit pixels. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + LogLuvState* sp = EncoderState(tif); + int shft, i, j, npixels; + tidata_t op; + uint32* tp; + uint32 b; + int occ, rc=0, mask, beg; + + assert(s == 0); + assert(sp != NULL); + + npixels = cc / sp->pixel_size; + + if (sp->user_datafmt == SGILOGDATAFMT_RAW) + tp = (uint32*) bp; + else { + tp = (uint32*) sp->tbuf; + assert(sp->tbuflen >= npixels); + (*sp->tfunc)(sp, bp, npixels); + } + /* compress each byte string */ + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + for (shft = 4*8; (shft -= 8) >= 0; ) + for (i = 0; i < npixels; i += rc) { + if (occ < 4) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (-1); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + } + mask = 0xff << shft; /* find next run */ + for (beg = i; beg < npixels; beg += rc) { + b = tp[beg] & mask; + rc = 1; + while (rc < 127+2 && beg+rc < npixels && + (tp[beg+rc] & mask) == b) + rc++; + if (rc >= MINRUN) + break; /* long enough */ + } + if (beg-i > 1 && beg-i < MINRUN) { + b = tp[i] & mask; /* check short run */ + j = i+1; + while ((tp[j++] & mask) == b) + if (j == beg) { + *op++ =(tidataval_t)(128-2+j-i); + *op++ =(tidataval_t)(b >> shft); + occ -= 2; + i = beg; + break; + } + } + while (i < beg) { /* write out non-run */ + if ((j = beg-i) > 127) j = 127; + if (occ < j+3) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize + - occ; + if (!TIFFFlushData1(tif)) + return (-1); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize + - tif->tif_rawcc; + } + *op++ = j; occ--; + while (j--) { + *op++ = (tidataval_t)(tp[i++] >> shft + & 0xff); + occ--; + } + } + if (rc >= MINRUN) { /* write out run */ + *op++ = 128-2+rc; + *op++ = (tidataval_t)(tp[beg] >> shft & 0xff); + occ -= 2; + } else + rc = 0; + } + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + + return (0); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Encode a strip of pixels. We break it into rows to + * avoid encoding runs across row boundaries. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + tsize_t rowlen = TIFFScanlineSize(tif); + + assert(cc%rowlen == 0); + while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) + bp += rowlen, cc -= rowlen; + return (cc == 0); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Encode a tile of pixels. We break it into rows to + * avoid encoding runs across row boundaries. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +LogLuvEncodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + tsize_t rowlen = TIFFTileRowSize(tif); + + assert(cc%rowlen == 0); + while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) + bp += rowlen, cc -= rowlen; + return (cc == 0); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Encode/Decode functions for converting to and from user formats. + */ + +#include "uvcode.h" + +#ifndef UVSCALE +#define U_NEU 0.210526316 +#define V_NEU 0.473684211 +#define UVSCALE 410. +#endif + +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 +#endif +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif +#define log2(x) ((1./M_LN2)*log(x)) +#define exp2(x) exp(M_LN2*(x)) + +#define itrunc(x,m) ((m)==SGILOGENCODE_NODITHER ? \ + (int)(x) : \ + (int)((x) + rand()*(1./RAND_MAX) - .5)) + +#if !LOGLUV_PUBLIC +static +#endif +double +LogL16toY(int p16) /* compute luminance from 16-bit LogL */ +{ + int Le = p16 & 0x7fff; + double Y; + + if (!Le) + return (0.); + Y = exp(M_LN2/256.*(Le+.5) - M_LN2*64.); + return (!(p16 & 0x8000) ? Y : -Y); +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +#if !LOGLUV_PUBLIC +static +#endif +int +LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */ +{ + if (Y >= 1.8371976e19) + return (0x7fff); + if (Y <= -1.8371976e19) + return (0xffff); + if (Y > 5.4136769e-20) + return itrunc(256.*(log2(Y) + 64.), em); + if (Y < -5.4136769e-20) + return (~0x7fff | itrunc(256.*(log2(-Y) + 64.), em)); + return (0); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static void +L16toY(LogLuvState* sp, tidata_t op, int n) +{ + int16* l16 = (int16*) sp->tbuf; + float* yp = (float*) op; + + while (n-- > 0) + *yp++ = (float)LogL16toY(*l16++); +} + +static void +L16toGry(LogLuvState* sp, tidata_t op, int n) +{ + int16* l16 = (int16*) sp->tbuf; + uint8* gp = (uint8*) op; + + while (n-- > 0) { + double Y = LogL16toY(*l16++); + *gp++ = (Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y)); + } +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +L16fromY(LogLuvState* sp, tidata_t op, int n) +{ + int16* l16 = (int16*) sp->tbuf; + float* yp = (float*) op; + + while (n-- > 0) + *l16++ = LogL16fromY(*yp++, sp->encode_meth); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#if !LOGLUV_PUBLIC +static +#endif +void +XYZtoRGB24(float xyz[3], uint8 rgb[3]) +{ + double r, g, b; + /* assume CCIR-709 primaries */ + r = 2.690*xyz[0] + -1.276*xyz[1] + -0.414*xyz[2]; + g = -1.022*xyz[0] + 1.978*xyz[1] + 0.044*xyz[2]; + b = 0.061*xyz[0] + -0.224*xyz[1] + 1.163*xyz[2]; + /* assume 2.0 gamma for speed */ + /* could use integer sqrt approx., but this is probably faster */ + rgb[0] = (r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r)); + rgb[1] = (g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g)); + rgb[2] = (b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b)); +} + +#if !LOGLUV_PUBLIC +static +#endif +double +LogL10toY(int p10) /* compute luminance from 10-bit LogL */ +{ + if (p10 == 0) + return (0.); + return (exp(M_LN2/64.*(p10+.5) - M_LN2*12.)); +} + +#if !LOGLUV_PUBLIC +static +#endif +int +LogL10fromY(double Y, int em) /* get 10-bit LogL from Y */ +{ + if (Y >= 15.742) + return (0x3ff); + else if (Y <= .00024283) + return (0); + else + return itrunc(64.*(log2(Y) + 12.), em); +} + +#define NANGLES 100 +#define uv2ang(u, v) ( (NANGLES*.499999999/M_PI) \ + * atan2((v)-V_NEU,(u)-U_NEU) + .5*NANGLES ) + +static int +oog_encode(double u, double v) /* encode out-of-gamut chroma */ +{ + static int oog_table[NANGLES]; + static int initialized = 0; + register int i; + + if (!initialized) { /* set up perimeter table */ + double eps[NANGLES], ua, va, ang, epsa; + int ui, vi, ustep; + for (i = NANGLES; i--; ) + eps[i] = 2.; + for (vi = UV_NVS; vi--; ) { + va = UV_VSTART + (vi+.5)*UV_SQSIZ; + ustep = uv_row[vi].nus-1; + if (vi == UV_NVS-1 || vi == 0 || ustep <= 0) + ustep = 1; + for (ui = uv_row[vi].nus-1; ui >= 0; ui -= ustep) { + ua = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ; + ang = uv2ang(ua, va); + i = (int) ang; + epsa = fabs(ang - (i+.5)); + if (epsa < eps[i]) { + oog_table[i] = uv_row[vi].ncum + ui; + eps[i] = epsa; + } + } + } + for (i = NANGLES; i--; ) /* fill any holes */ + if (eps[i] > 1.5) { + int i1, i2; + for (i1 = 1; i1 < NANGLES/2; i1++) + if (eps[(i+i1)%NANGLES] < 1.5) + break; + for (i2 = 1; i2 < NANGLES/2; i2++) + if (eps[(i+NANGLES-i2)%NANGLES] < 1.5) + break; + if (i1 < i2) + oog_table[i] = + oog_table[(i+i1)%NANGLES]; + else + oog_table[i] = + oog_table[(i+NANGLES-i2)%NANGLES]; + } + initialized = 1; + } + i = (int) uv2ang(u, v); /* look up hue angle */ + return (oog_table[i]); +} + +#undef uv2ang +#undef NANGLES + +#if !LOGLUV_PUBLIC +static +#endif +int +uv_encode(double u, double v, int em) /* encode (u',v') coordinates */ +{ + register int vi, ui; + + if (v < UV_VSTART) + return oog_encode(u, v); + vi = itrunc((v - UV_VSTART)*(1./UV_SQSIZ), em); + if (vi >= UV_NVS) + return oog_encode(u, v); + if (u < uv_row[vi].ustart) + return oog_encode(u, v); + ui = itrunc((u - uv_row[vi].ustart)*(1./UV_SQSIZ), em); + if (ui >= uv_row[vi].nus) + return oog_encode(u, v); + + return (uv_row[vi].ncum + ui); +} + +#if !LOGLUV_PUBLIC +static +#endif +int +uv_decode(double *up, double *vp, int c) /* decode (u',v') index */ +{ + int upper, lower; + register int ui, vi; + + if (c < 0 || c >= UV_NDIVS) + return (-1); + lower = 0; /* binary search */ + upper = UV_NVS; + while (upper - lower > 1) { + vi = (lower + upper) >> 1; + ui = c - uv_row[vi].ncum; + if (ui > 0) + lower = vi; + else if (ui < 0) + upper = vi; + else { + lower = vi; + break; + } + } + vi = lower; + ui = c - uv_row[vi].ncum; + *up = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ; + *vp = UV_VSTART + (vi+.5)*UV_SQSIZ; + return (0); +} + +#if !LOGLUV_PUBLIC +static +#endif +void +LogLuv24toXYZ(uint32 p, float XYZ[3]) +{ + int Ce; + double L, u, v, s, x, y; + /* decode luminance */ + L = LogL10toY(p>>14 & 0x3ff); + if (L <= 0.) { + XYZ[0] = XYZ[1] = XYZ[2] = 0.; + return; + } + /* decode color */ + Ce = p & 0x3fff; + if (uv_decode(&u, &v, Ce) < 0) { + u = U_NEU; v = V_NEU; + } + s = 1./(6.*u - 16.*v + 12.); + x = 9.*u * s; + y = 4.*v * s; + /* convert to XYZ */ + XYZ[0] = (float)(x/y * L); + XYZ[1] = (float)L; + XYZ[2] = (float)((1.-x-y)/y * L); +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +#if !LOGLUV_PUBLIC +static +#endif +uint32 +LogLuv24fromXYZ(float XYZ[3], int em) +{ + int Le, Ce; + double u, v, s; + /* encode luminance */ + Le = LogL10fromY(XYZ[1], em); + /* encode color */ + s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2]; + if (!Le || s <= 0.) { + u = U_NEU; + v = V_NEU; + } else { + u = 4.*XYZ[0] / s; + v = 9.*XYZ[1] / s; + } + Ce = uv_encode(u, v, em); + if (Ce < 0) /* never happens */ + Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); + /* combine encodings */ + return (Le << 14 | Ce); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static void +Luv24toXYZ(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + float* xyz = (float*) op; + + while (n-- > 0) { + LogLuv24toXYZ(*luv, xyz); + xyz += 3; + luv++; + } +} + +static void +Luv24toLuv48(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + int16* luv3 = (int16*) op; + + while (n-- > 0) { + double u, v; + + *luv3++ = (int16)((*luv >> 12 & 0xffd) + 13314); + if (uv_decode(&u, &v, *luv&0x3fff) < 0) { + u = U_NEU; + v = V_NEU; + } + *luv3++ = (int16)(u * (1L<<15)); + *luv3++ = (int16)(v * (1L<<15)); + luv++; + } +} + +static void +Luv24toRGB(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + uint8* rgb = (uint8*) op; + + while (n-- > 0) { + float xyz[3]; + + LogLuv24toXYZ(*luv++, xyz); + XYZtoRGB24(xyz, rgb); + rgb += 3; + } +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +Luv24fromXYZ(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + float* xyz = (float*) op; + + while (n-- > 0) { + *luv++ = LogLuv24fromXYZ(xyz, sp->encode_meth); + xyz += 3; + } +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +Luv24fromLuv48(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + int16* luv3 = (int16*) op; + + while (n-- > 0) { + int Le, Ce; + + if (luv3[0] <= 0) + Le = 0; + else if (luv3[0] >= (1<<12)+3314) + Le = (1<<10) - 1; + else if (sp->encode_meth == SGILOGENCODE_NODITHER) + Le = (luv3[0]-3314) >> 2; + else + Le = itrunc(.25*(luv3[0]-3314.), sp->encode_meth); + + Ce = uv_encode((luv[1]+.5)/(1<<15), (luv[2]+.5)/(1<<15), + sp->encode_meth); + if (Ce < 0) /* never happens */ + Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); + *luv++ = (uint32)Le << 14 | Ce; + luv3 += 3; + } +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#if !LOGLUV_PUBLIC +static +#endif +void +LogLuv32toXYZ(uint32 p, float XYZ[3]) +{ + double L, u, v, s, x, y; + /* decode luminance */ + L = LogL16toY((int)p >> 16); + if (L <= 0.) { + XYZ[0] = XYZ[1] = XYZ[2] = 0.; + return; + } + /* decode color */ + u = 1./UVSCALE * ((p>>8 & 0xff) + .5); + v = 1./UVSCALE * ((p & 0xff) + .5); + s = 1./(6.*u - 16.*v + 12.); + x = 9.*u * s; + y = 4.*v * s; + /* convert to XYZ */ + XYZ[0] = (float)(x/y * L); + XYZ[1] = (float)L; + XYZ[2] = (float)((1.-x-y)/y * L); +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +#if !LOGLUV_PUBLIC +static +#endif +uint32 +LogLuv32fromXYZ(float XYZ[3], int em) +{ + unsigned int Le, ue, ve; + double u, v, s; + /* encode luminance */ + Le = (unsigned int)LogL16fromY(XYZ[1], em); + /* encode color */ + s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2]; + if (!Le || s <= 0.) { + u = U_NEU; + v = V_NEU; + } else { + u = 4.*XYZ[0] / s; + v = 9.*XYZ[1] / s; + } + if (u <= 0.) ue = 0; + else ue = itrunc(UVSCALE*u, em); + if (ue > 255) ue = 255; + if (v <= 0.) ve = 0; + else ve = itrunc(UVSCALE*v, em); + if (ve > 255) ve = 255; + /* combine encodings */ + return (Le << 16 | ue << 8 | ve); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static void +Luv32toXYZ(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + float* xyz = (float*) op; + + while (n-- > 0) { + LogLuv32toXYZ(*luv++, xyz); + xyz += 3; + } +} + +static void +Luv32toLuv48(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + int16* luv3 = (int16*) op; + + while (n-- > 0) { + double u, v; + + *luv3++ = (int16)(*luv >> 16); + u = 1./UVSCALE * ((*luv>>8 & 0xff) + .5); + v = 1./UVSCALE * ((*luv & 0xff) + .5); + *luv3++ = (int16)(u * (1L<<15)); + *luv3++ = (int16)(v * (1L<<15)); + luv++; + } +} + +static void +Luv32toRGB(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + uint8* rgb = (uint8*) op; + + while (n-- > 0) { + float xyz[3]; + + LogLuv32toXYZ(*luv++, xyz); + XYZtoRGB24(xyz, rgb); + rgb += 3; + } +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +Luv32fromXYZ(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + float* xyz = (float*) op; + + while (n-- > 0) { + *luv++ = LogLuv32fromXYZ(xyz, sp->encode_meth); + xyz += 3; + } +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +Luv32fromLuv48(LogLuvState* sp, tidata_t op, int n) +{ + uint32* luv = (uint32*) sp->tbuf; + int16* luv3 = (int16*) op; + + if (sp->encode_meth == SGILOGENCODE_NODITHER) { + while (n-- > 0) { + *luv++ = (uint32)luv3[0] << 16 | + (luv3[1]*(uint32)(UVSCALE+.5) >> 7 & 0xff00) | + (luv3[2]*(uint32)(UVSCALE+.5) >> 15 & 0xff); + luv3 += 3; + } + return; + } + while (n-- > 0) { + *luv++ = (uint32)luv3[0] << 16 | + (itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) | + (itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff); + luv3 += 3; + } +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static void +_logLuvNop(LogLuvState* sp, tidata_t op, int n) +{ + (void) sp; (void) op; (void) n; +} + +static int +LogL16GuessDataFmt(TIFFDirectory *td) +{ +#define PACK(s,b,f) (((b)<<6)|((s)<<3)|(f)) + switch (PACK(td->td_samplesperpixel, td->td_bitspersample, + td->td_sampleformat)) { + case PACK(1, 32, SAMPLEFORMAT_IEEEFP): + return (SGILOGDATAFMT_FLOAT); + case PACK(1, 16, SAMPLEFORMAT_VOID): + case PACK(1, 16, SAMPLEFORMAT_INT): + case PACK(1, 16, SAMPLEFORMAT_UINT): + return (SGILOGDATAFMT_16BIT); + case PACK(1, 8, SAMPLEFORMAT_VOID): + case PACK(1, 8, SAMPLEFORMAT_UINT): + return (SGILOGDATAFMT_8BIT); + } +#undef PACK + return (SGILOGDATAFMT_UNKNOWN); +} + +static int +LogL16InitState(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + LogLuvState* sp = DecoderState(tif); + static const char module[] = "LogL16InitState"; + + assert(sp != NULL); + assert(td->td_photometric == PHOTOMETRIC_LOGL); + + /* for some reason, we can't do this in TIFFInitLogL16 */ + if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) + sp->user_datafmt = LogL16GuessDataFmt(td); + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->pixel_size = sizeof (float); + break; + case SGILOGDATAFMT_16BIT: + sp->pixel_size = sizeof (int16); + break; + case SGILOGDATAFMT_8BIT: + sp->pixel_size = sizeof (uint8); + break; + default: + TIFFError(tif->tif_name, + "No support for converting user data format to LogL"); + return (0); + } + sp->tbuflen = td->td_imagewidth * td->td_rowsperstrip; + sp->tbuf = (tidata_t*) _TIFFmalloc(tif, sp->tbuflen * sizeof (int16)); + if (sp->tbuf == NULL) { + TIFFError(module, "%s: No space for SGILog translation buffer", + tif->tif_name); + return (0); + } + return (1); +} + +static int +LogLuvGuessDataFmt(TIFFDirectory *td) +{ + int guess; + + /* + * If the user didn't tell us their datafmt, + * take our best guess from the bitspersample. + */ +#define PACK(a,b) (((a)<<3)|(b)) + switch (PACK(td->td_bitspersample, td->td_sampleformat)) { + case PACK(32, SAMPLEFORMAT_IEEEFP): + guess = SGILOGDATAFMT_FLOAT; + break; + case PACK(32, SAMPLEFORMAT_VOID): + case PACK(32, SAMPLEFORMAT_UINT): + case PACK(32, SAMPLEFORMAT_INT): + guess = SGILOGDATAFMT_RAW; + break; + case PACK(16, SAMPLEFORMAT_VOID): + case PACK(16, SAMPLEFORMAT_INT): + case PACK(16, SAMPLEFORMAT_UINT): + guess = SGILOGDATAFMT_16BIT; + break; + case PACK( 8, SAMPLEFORMAT_VOID): + case PACK( 8, SAMPLEFORMAT_UINT): + guess = SGILOGDATAFMT_8BIT; + break; + default: + guess = SGILOGDATAFMT_UNKNOWN; + break; +#undef PACK + } + /* + * Double-check samples per pixel. + */ + switch (td->td_samplesperpixel) { + case 1: + if (guess != SGILOGDATAFMT_RAW) + guess = SGILOGDATAFMT_UNKNOWN; + break; + case 3: + if (guess == SGILOGDATAFMT_RAW) + guess = SGILOGDATAFMT_UNKNOWN; + break; + default: + guess = SGILOGDATAFMT_UNKNOWN; + break; + } + return (guess); +} + +static int +LogLuvInitState(TIFF* tif) +{ + TIFFDirectory* td = &tif->tif_dir; + LogLuvState* sp = DecoderState(tif); + static const char module[] = "LogLuvInitState"; + + assert(sp != NULL); + assert(td->td_photometric == PHOTOMETRIC_LOGLUV); + + /* for some reason, we can't do this in TIFFInitLogLuv */ + if (td->td_planarconfig != PLANARCONFIG_CONTIG) { + TIFFError(module, + "SGILog compression cannot handle non-contiguous data"); + return (0); + } + if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) + sp->user_datafmt = LogLuvGuessDataFmt(td); + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->pixel_size = 3*sizeof (float); + break; + case SGILOGDATAFMT_16BIT: + sp->pixel_size = 3*sizeof (int16); + break; + case SGILOGDATAFMT_RAW: + sp->pixel_size = sizeof (uint32); + break; + case SGILOGDATAFMT_8BIT: + sp->pixel_size = 3*sizeof (uint8); + break; + default: + TIFFError(tif->tif_name, + "No support for converting user data format to LogLuv"); + return (0); + } + sp->tbuflen = td->td_imagewidth * td->td_rowsperstrip; + sp->tbuf = (tidata_t*) _TIFFmalloc(tif, sp->tbuflen * sizeof (uint32)); + if (sp->tbuf == NULL) { + TIFFError(module, "%s: No space for SGILog translation buffer", + tif->tif_name); + return (0); + } + return (1); +} + +static int +LogLuvSetupDecode(TIFF* tif) +{ + LogLuvState* sp = DecoderState(tif); + TIFFDirectory* td = &tif->tif_dir; + + tif->tif_postdecode = _TIFFNoPostDecode; + switch (td->td_photometric) { + case PHOTOMETRIC_LOGLUV: + if (!LogLuvInitState(tif)) + break; + if (td->td_compression == COMPRESSION_SGILOG24) { + tif->tif_decoderow = LogLuvDecode24; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = Luv24toXYZ; + break; + case SGILOGDATAFMT_16BIT: + sp->tfunc = Luv24toLuv48; + break; + case SGILOGDATAFMT_8BIT: + sp->tfunc = Luv24toRGB; + break; + } + } else { + tif->tif_decoderow = LogLuvDecode32; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = Luv32toXYZ; + break; + case SGILOGDATAFMT_16BIT: + sp->tfunc = Luv32toLuv48; + break; + case SGILOGDATAFMT_8BIT: + sp->tfunc = Luv32toRGB; + break; + } + } + return (1); + case PHOTOMETRIC_LOGL: + if (!LogL16InitState(tif)) + break; + tif->tif_decoderow = LogL16Decode; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = L16toY; + break; + case SGILOGDATAFMT_8BIT: + sp->tfunc = L16toGry; + break; + } + return (1); + default: + TIFFError(tif->tif_name, + "Inappropriate photometric interpretation %d for SGILog compression; %s", + td->td_photometric, "must be either LogLUV or LogL"); + break; + } + return (0); +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +LogLuvSetupEncode(TIFF* tif) +{ + LogLuvState* sp = EncoderState(tif); + TIFFDirectory* td = &tif->tif_dir; + + switch (td->td_photometric) { + case PHOTOMETRIC_LOGLUV: + if (!LogLuvInitState(tif)) + break; + if (td->td_compression == COMPRESSION_SGILOG24) { + tif->tif_encoderow = LogLuvEncode24; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = Luv24fromXYZ; + break; + case SGILOGDATAFMT_16BIT: + sp->tfunc = Luv24fromLuv48; + break; + case SGILOGDATAFMT_RAW: + break; + default: + goto notsupported; + } + } else { + tif->tif_encoderow = LogLuvEncode32; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = Luv32fromXYZ; + break; + case SGILOGDATAFMT_16BIT: + sp->tfunc = Luv32fromLuv48; + break; + case SGILOGDATAFMT_RAW: + break; + default: + goto notsupported; + } + } + break; + case PHOTOMETRIC_LOGL: + if (!LogL16InitState(tif)) + break; + tif->tif_encoderow = LogL16Encode; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = L16fromY; + break; + case SGILOGDATAFMT_16BIT: + break; + default: + goto notsupported; + } + break; + default: + TIFFError(tif->tif_name, + "Inappropriate photometric interpretation %d for SGILog compression; %s", + td->td_photometric, "must be either LogLUV or LogL"); + break; + } + return (1); +notsupported: + TIFFError(tif->tif_name, + "SGILog compression supported only for %s, or raw data", + td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv"); + return (0); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +LogLuvClose(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + + /* + * For consistency, we always want to write out the same + * bitspersample and sampleformat for our TIFF file, + * regardless of the data format being used by the application. + * Since this routine is called after tags have been set but + * before they have been recorded in the file, we reset them here. + */ + td->td_samplesperpixel = + (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3; + td->td_bitspersample = 16; + td->td_sampleformat = SAMPLEFORMAT_INT; +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static void +LogLuvCleanup(TIFF* tif) +{ + LogLuvState* sp = (LogLuvState *)tif->tif_data; + + if (sp) { + if (sp->tbuf) + _TIFFfree(tif, sp->tbuf); + _TIFFfree(tif, sp); + tif->tif_data = NULL; + } +} + +static int +LogLuvVSetField(TIFF* tif, ttag_t tag, va_list ap) +{ + LogLuvState* sp = DecoderState(tif); + int bps, fmt; + + switch (tag) { + case TIFFTAG_SGILOGDATAFMT: + sp->user_datafmt = va_arg(ap, int); + /* + * Tweak the TIFF header so that the rest of libtiff knows what + * size of data will be passed between app and library, and + * assume that the app knows what it is doing and is not + * confused by these header manipulations... + */ + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + bps = 32, fmt = SAMPLEFORMAT_IEEEFP; + break; + case SGILOGDATAFMT_16BIT: + bps = 16, fmt = SAMPLEFORMAT_INT; + break; + case SGILOGDATAFMT_RAW: + bps = 32, fmt = SAMPLEFORMAT_UINT; + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); + break; + case SGILOGDATAFMT_8BIT: + bps = 8, fmt = SAMPLEFORMAT_UINT; + break; + default: + TIFFError(tif->tif_name, + "Unknown data format %d for LogLuv compression", + sp->user_datafmt); + return (0); + } + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps); + TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt); + /* + * Must recalculate sizes should bits/sample change. + */ + tif->tif_tilesize = TIFFTileSize(tif); + tif->tif_scanlinesize = TIFFScanlineSize(tif); + return (1); + case TIFFTAG_SGILOGENCODE: + sp->encode_meth = va_arg(ap, int); + if (sp->encode_meth != SGILOGENCODE_NODITHER && + sp->encode_meth != SGILOGENCODE_RANDITHER) { + TIFFError(tif->tif_name, + "Unknown encoding %d for LogLuv compression", + sp->encode_meth); + return (0); + } + return (1); + default: + return (*sp->vsetparent)(tif, tag, ap); + } +} + +static int +LogLuvVGetField(TIFF* tif, ttag_t tag, va_list ap) +{ + LogLuvState *sp = (LogLuvState *)tif->tif_data; + + switch (tag) { + case TIFFTAG_SGILOGDATAFMT: + *va_arg(ap, int*) = sp->user_datafmt; + return (1); + default: + return (*sp->vgetparent)(tif, tag, ap); + } +} + +static const TIFFFieldInfo LogLuvFieldInfo[] = { + { TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, FIELD_PSEUDO, + TRUE, FALSE, "SGILogDataFmt"}, + { TIFFTAG_SGILOGENCODE, 0, 0, TIFF_SHORT, FIELD_PSEUDO, + TRUE, FALSE, "SGILogEncode"} +}; + +int +TIFFInitSGILog(TIFF* tif, int scheme) +{ + static const char module[] = "TIFFInitSGILog"; + LogLuvState* sp; + + assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG); + + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (tidata_t) _TIFFmalloc(tif, sizeof (LogLuvState)); + if (tif->tif_data == NULL) + goto bad; + sp = (LogLuvState*) tif->tif_data; + _TIFFmemset((tdata_t)sp, 0, sizeof (*sp)); + sp->user_datafmt = SGILOGDATAFMT_UNKNOWN; + sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? + SGILOGENCODE_RANDITHER : SGILOGENCODE_NODITHER; + sp->tfunc = _logLuvNop; + + /* + * Install codec methods. + * NB: tif_decoderow & tif_encoderow are filled + * in at setup time. + */ + tif->tif_setupdecode = LogLuvSetupDecode; + tif->tif_decodestrip = LogLuvDecodeStrip; + tif->tif_decodetile = LogLuvDecodeTile; +#ifdef PDFLIB_TIFFWRITE_SUPPORT + tif->tif_setupencode = LogLuvSetupEncode; + tif->tif_encodestrip = LogLuvEncodeStrip; + tif->tif_encodetile = LogLuvEncodeTile; + tif->tif_close = LogLuvClose; +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + tif->tif_cleanup = LogLuvCleanup; + + /* override SetField so we can handle our private pseudo-tag */ + _TIFFMergeFieldInfo(tif, LogLuvFieldInfo, N(LogLuvFieldInfo)); + sp->vgetparent = tif->tif_vgetfield; + tif->tif_vgetfield = LogLuvVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_vsetfield; + tif->tif_vsetfield = LogLuvVSetField; /* hook for codec tags */ + + return (1); +bad: + TIFFError(module, "%s: No space for LogLuv state block", tif->tif_name); + return (0); +} +#endif /* LOGLUV_SUPPORT */ diff --git a/src/libs/pdflib/libs/tiff/tif_lzw.c b/src/libs/pdflib/libs/tiff/tif_lzw.c new file mode 100644 index 0000000000..15e277c7d3 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_lzw.c @@ -0,0 +1,727 @@ +/* PDFlib GmbH cvsid: $Id: tif_lzw.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tiffiop.h" +#ifdef LZW_SUPPORT +/* + * TIFF Library. + * Rev 5.0 Lempel-Ziv & Welch Compression Support + * + * This code is derived from the compress program whose code is + * derived from software contributed to Berkeley by James A. Woods, + * derived from original work by Spencer Thomas and Joseph Orost. + * + * The original Berkeley copyright notice appears below in its entirety. + */ +#include "tif_predict.h" + +#include +#include + +/* + * NB: The 5.0 spec describes a different algorithm than Aldus + * implements. Specifically, Aldus does code length transitions + * one code earlier than should be done (for real LZW). + * Earlier versions of this library implemented the correct + * LZW algorithm, but emitted codes in a bit order opposite + * to the TIFF spec. Thus, to maintain compatibility w/ Aldus + * we interpret MSB-LSB ordered codes to be images written w/ + * old versions of this library, but otherwise adhere to the + * Aldus "off by one" algorithm. + * + * Future revisions to the TIFF spec are expected to "clarify this issue". + */ +#define LZW_COMPAT /* include backwards compatibility code */ +/* + * Each strip of data is supposed to be terminated by a CODE_EOI. + * If the following #define is included, the decoder will also + * check for end-of-strip w/o seeing this code. This makes the + * library more robust, but also slower. + */ +#define LZW_CHECKEOS /* include checks for strips w/o EOI code */ + +#define MAXCODE(n) ((1L<<(n))-1) +/* + * The TIFF spec specifies that encoded bit + * strings range from 9 to 12 bits. + */ +#define BITS_MIN 9 /* start with 9 bits */ +#define BITS_MAX 12 /* max of 12 bit strings */ +/* predefined codes */ +#define CODE_CLEAR 256 /* code to clear string table */ +#define CODE_EOI 257 /* end-of-information code */ +#define CODE_FIRST 258 /* first free code entry */ +#define CODE_MAX MAXCODE(BITS_MAX) +#define HSIZE 9001L /* 91% occupancy */ +#define HSHIFT (13-8) +#ifdef LZW_COMPAT +/* NB: +1024 is for compatibility with old files */ +#define CSIZE (MAXCODE(BITS_MAX)+1024L) +#else +#define CSIZE (MAXCODE(BITS_MAX)+1L) +#endif + +/* + * State block for each open TIFF file using LZW + * compression/decompression. Note that the predictor + * state block must be first in this data structure. + */ +typedef struct { + TIFFPredictorState predict; /* predictor super class */ + + tif_short nbits; /* # of bits/code */ + tif_short maxcode; /* maximum code for lzw_nbits */ + tif_short free_ent; /* next free entry in hash table */ + long nextdata; /* next bits of i/o */ + long nextbits; /* # of valid bits in lzw_nextdata */ +} LZWBaseState; + +#define lzw_nbits base.nbits +#define lzw_maxcode base.maxcode +#define lzw_free_ent base.free_ent +#define lzw_nextdata base.nextdata +#define lzw_nextbits base.nextbits + +/* + * Decoding-specific state. + */ +typedef struct code_ent { + struct code_ent *next; + tif_short length; /* string len, including this token */ + tif_char value; /* data value */ + tif_char firstchar; /* first token of string */ +} code_t; + +typedef int (*decodeFunc)(TIFF*, tidata_t, tsize_t, tsample_t); + +typedef struct { + LZWBaseState base; + long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ + long dec_restart; /* restart count */ +#ifdef LZW_CHECKEOS + long dec_bitsleft; /* available bits in raw data */ +#endif + decodeFunc dec_decode; /* regular or backwards compatible */ + code_t* dec_codep; /* current recognized code */ + code_t* dec_oldcodep; /* previously recognized code */ + code_t* dec_free_entp; /* next free entry */ + code_t* dec_maxcodep; /* max available entry */ + code_t* dec_codetab; /* kept separate for small machines */ +} LZWDecodeState; + +/* + * Encoding-specific state. + */ +typedef uint16 hcode_t; /* codes fit in 16 bits */ +typedef struct { + long hash; + hcode_t code; +} hash_t; + +typedef struct { + LZWBaseState base; + int enc_oldcode; /* last code encountered */ + long enc_checkpoint; /* point at which to clear table */ +#define CHECK_GAP 10000 /* enc_ratio check interval */ + long enc_ratio; /* current compression ratio */ + long enc_incount; /* (input) data bytes encoded */ + long enc_outcount; /* encoded (output) bytes */ + tidata_t enc_rawlimit; /* bound on tif_rawdata buffer */ + hash_t* enc_hashtab; /* kept separate for small machines */ +} LZWEncodeState; + +#define LZWState(tif) ((LZWBaseState*) (tif)->tif_data) +#define DecoderState(tif) ((LZWDecodeState*) LZWState(tif)) +#define EncoderState(tif) ((LZWEncodeState*) LZWState(tif)) + +static int LZWDecode(TIFF*, tidata_t, tsize_t, tsample_t); +#ifdef LZW_COMPAT +static int LZWDecodeCompat(TIFF*, tidata_t, tsize_t, tsample_t); +#endif +/* PDFlib GmbH: apparently unused, therefore disabled to avoid warning +static void cl_hash(LZWEncodeState*); +*/ + +/* + * LZW Decoder. + */ + +#ifdef LZW_CHECKEOS +/* + * This check shouldn't be necessary because each + * strip is suppose to be terminated with CODE_EOI. + */ +#define NextCode(_tif, _sp, _bp, _code, _get) { \ + if ((_sp)->dec_bitsleft < nbits) { \ + TIFFWarning(_tif->tif_name, \ + "LZWDecode: Strip %d not terminated with EOI code", \ + _tif->tif_curstrip); \ + _code = CODE_EOI; \ + } else { \ + _get(_sp,_bp,_code); \ + (_sp)->dec_bitsleft -= nbits; \ + } \ +} +#else +#define NextCode(tif, sp, bp, code, get) get(sp, bp, code) +#endif + +static int +LZWSetupDecode(TIFF* tif) +{ + LZWDecodeState* sp = DecoderState(tif); + static const char module[] = " LZWSetupDecode"; + int code; + + assert(sp != NULL); + if (sp->dec_codetab == NULL) { + sp->dec_codetab=(code_t*)_TIFFmalloc(tif,CSIZE*sizeof(code_t)); + if (sp->dec_codetab == NULL) { + TIFFError(module, "No space for LZW code table"); + return (0); + } + /* + * Pre-load the table. + */ + code = 255; + do { + sp->dec_codetab[code].value = code; + sp->dec_codetab[code].firstchar = code; + sp->dec_codetab[code].length = 1; + sp->dec_codetab[code].next = NULL; + } while (code--); + } + return (1); +} + +/* + * Setup state for decoding a strip. + */ +static int +LZWPreDecode(TIFF* tif, tsample_t s) +{ + LZWDecodeState *sp = DecoderState(tif); + + (void) s; + assert(sp != NULL); + /* + * Check for old bit-reversed codes. + */ + if (tif->tif_rawdata[0] == 0 && (tif->tif_rawdata[1] & 0x1)) { +#ifdef LZW_COMPAT + if (!sp->dec_decode) { + TIFFWarning(tif->tif_name, + "Old-style LZW codes, convert file"); + /* + * Override default decoding methods with + * ones that deal with the old coding. + * Otherwise the predictor versions set + * above will call the compatibility routines + * through the dec_decode method. + */ + tif->tif_decoderow = LZWDecodeCompat; + tif->tif_decodestrip = LZWDecodeCompat; + tif->tif_decodetile = LZWDecodeCompat; + /* + * If doing horizontal differencing, must + * re-setup the predictor logic since we + * switched the basic decoder methods... + */ + (*tif->tif_setupdecode)(tif); + sp->dec_decode = LZWDecodeCompat; + } + sp->lzw_maxcode = MAXCODE(BITS_MIN); +#else /* !LZW_COMPAT */ + if (!sp->dec_decode) { + TIFFError(tif->tif_name, + "Old-style LZW codes not supported"); + sp->dec_decode = LZWDecode; + } + return (0); +#endif/* !LZW_COMPAT */ + } else { + sp->lzw_maxcode = MAXCODE(BITS_MIN)-1; + sp->dec_decode = LZWDecode; + } + sp->lzw_nbits = BITS_MIN; + sp->lzw_nextbits = 0; + sp->lzw_nextdata = 0; + + sp->dec_restart = 0; + sp->dec_nbitsmask = MAXCODE(BITS_MIN); +#ifdef LZW_CHECKEOS + sp->dec_bitsleft = tif->tif_rawcc << 3; +#endif + sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; + /* + * Zero entries that are not yet filled in. We do + * this to guard against bogus input data that causes + * us to index into undefined entries. If you can + * come up with a way to safely bounds-check input codes + * while decoding then you can remove this operation. + */ + _TIFFmemset(sp->dec_free_entp, 0, (CSIZE-CODE_FIRST)*sizeof (code_t)); + sp->dec_oldcodep = &sp->dec_codetab[-1]; + sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask-1]; + return (1); +} + +/* + * Decode a "hunk of data". + */ +#define GetNextCode(sp, bp, code) { \ + nextdata = (nextdata<<8) | *(bp)++; \ + nextbits += 8; \ + if (nextbits < nbits) { \ + nextdata = (nextdata<<8) | *(bp)++; \ + nextbits += 8; \ + } \ + code = (hcode_t)((nextdata >> (nextbits-nbits)) & nbitsmask); \ + nextbits -= nbits; \ +} + +static void +codeLoop(TIFF* tif) +{ + TIFFError(tif->tif_name, + "LZWDecode: Bogus encoding, loop in the code table; scanline %d", + tif->tif_row); +} + +static int +LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +{ + LZWDecodeState *sp = DecoderState(tif); + char *op = (char*) op0; + long occ = (long) occ0; + char *tp; + tif_char *bp; + hcode_t code; + int len; + long nbits, nextbits, nextdata, nbitsmask; + code_t *codep, *free_entp, *maxcodep, *oldcodep; + + (void) s; + assert(sp != NULL); + /* + * Restart interrupted output operation. + */ + if (sp->dec_restart) { + long residue; + + codep = sp->dec_codep; + residue = codep->length - sp->dec_restart; + if (residue > occ) { + /* + * Residue from previous decode is sufficient + * to satisfy decode request. Skip to the + * start of the decoded string, place decoded + * values in the output buffer, and return. + */ + sp->dec_restart += occ; + do { + codep = codep->next; + } while (--residue > occ && codep); + if (codep) { + tp = op + occ; + do { + *--tp = codep->value; + codep = codep->next; + } while (--occ && codep); + } + return (1); + } + /* + * Residue satisfies only part of the decode request. + */ + op += residue, occ -= residue; + tp = op; + do { + int t; + --tp; + t = codep->value; + codep = codep->next; + *tp = t; + } while (--residue && codep); + sp->dec_restart = 0; + } + + bp = (tif_char *)tif->tif_rawcp; + nbits = sp->lzw_nbits; + nextdata = sp->lzw_nextdata; + nextbits = sp->lzw_nextbits; + nbitsmask = sp->dec_nbitsmask; + oldcodep = sp->dec_oldcodep; + free_entp = sp->dec_free_entp; + maxcodep = sp->dec_maxcodep; + + while (occ > 0) { + NextCode(tif, sp, bp, code, GetNextCode); + if (code == CODE_EOI) + break; + if (code == CODE_CLEAR) { + free_entp = sp->dec_codetab + CODE_FIRST; + nbits = BITS_MIN; + nbitsmask = MAXCODE(BITS_MIN); + maxcodep = sp->dec_codetab + nbitsmask-1; + NextCode(tif, sp, bp, code, GetNextCode); + if (code == CODE_EOI) + break; + *op++ = (char)code, occ--; + oldcodep = sp->dec_codetab + code; + continue; + } + codep = sp->dec_codetab + code; + + /* + * Add the new entry to the code table. + */ + assert(&sp->dec_codetab[0] <= free_entp && free_entp + < &sp->dec_codetab[CSIZE]); + free_entp->next = oldcodep; + free_entp->firstchar = free_entp->next->firstchar; + free_entp->length = free_entp->next->length+1; + free_entp->value = (codep < free_entp) ? + codep->firstchar : free_entp->firstchar; + if (++free_entp > maxcodep) { + if (++nbits > BITS_MAX) /* should not happen */ + nbits = BITS_MAX; + nbitsmask = MAXCODE(nbits); + maxcodep = sp->dec_codetab + nbitsmask-1; + } + oldcodep = codep; + if (code >= 256) { + /* + * Code maps to a string, copy string + * value to output (written in reverse). + */ + if (codep->length > occ) { + /* + * String is too long for decode buffer, + * locate portion that will fit, copy to + * the decode buffer, and setup restart + * logic for the next decoding call. + */ + sp->dec_codep = codep; + do { + codep = codep->next; + } while (codep && codep->length > occ); + if (codep) { + sp->dec_restart = occ; + tp = op + occ; + do { + *--tp = codep->value; + codep = codep->next; + } while (--occ && codep); + if (codep) + codeLoop(tif); + } + break; + } + len = codep->length; + tp = op + len; + do { + int t; + --tp; + t = codep->value; + codep = codep->next; + *tp = t; + } while (codep && tp > op); + if (codep) { + codeLoop(tif); + break; + } + op += len, occ -= len; + } else + *op++ = (char)code, occ--; + } + + tif->tif_rawcp = (tidata_t) bp; + sp->lzw_nbits = (tif_short) nbits; + sp->lzw_nextdata = nextdata; + sp->lzw_nextbits = nextbits; + sp->dec_nbitsmask = nbitsmask; + sp->dec_oldcodep = oldcodep; + sp->dec_free_entp = free_entp; + sp->dec_maxcodep = maxcodep; + + if (occ > 0) { + TIFFError(tif->tif_name, + "LZWDecode: Not enough data at scanline %d (short %d bytes)", + tif->tif_row, occ); + return (0); + } + return (1); +} + +#ifdef LZW_COMPAT +/* + * Decode a "hunk of data" for old images. + */ +#define GetNextCodeCompat(sp, bp, code) { \ + nextdata |= (tif_long) *(bp)++ << nextbits; \ + nextbits += 8; \ + if (nextbits < nbits) { \ + nextdata |= (tif_long) *(bp)++ << nextbits; \ + nextbits += 8; \ + } \ + code = (hcode_t)(nextdata & nbitsmask); \ + nextdata >>= nbits; \ + nextbits -= nbits; \ +} + +static int +LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +{ + LZWDecodeState *sp = DecoderState(tif); + char *op = (char*) op0; + long occ = (long) occ0; + char *tp; + tif_char *bp; + int code, nbits; + long nextbits, nextdata, nbitsmask; + code_t *codep, *free_entp, *maxcodep, *oldcodep; + + (void) s; + assert(sp != NULL); + /* + * Restart interrupted output operation. + */ + if (sp->dec_restart) { + long residue; + + codep = sp->dec_codep; + residue = codep->length - sp->dec_restart; + if (residue > occ) { + /* + * Residue from previous decode is sufficient + * to satisfy decode request. Skip to the + * start of the decoded string, place decoded + * values in the output buffer, and return. + */ + sp->dec_restart += occ; + do { + codep = codep->next; + } while (--residue > occ); + tp = op + occ; + do { + *--tp = codep->value; + codep = codep->next; + } while (--occ); + return (1); + } + /* + * Residue satisfies only part of the decode request. + */ + op += residue, occ -= residue; + tp = op; + do { + *--tp = codep->value; + codep = codep->next; + } while (--residue); + sp->dec_restart = 0; + } + + bp = (tif_char *)tif->tif_rawcp; + nbits = sp->lzw_nbits; + nextdata = sp->lzw_nextdata; + nextbits = sp->lzw_nextbits; + nbitsmask = sp->dec_nbitsmask; + oldcodep = sp->dec_oldcodep; + free_entp = sp->dec_free_entp; + maxcodep = sp->dec_maxcodep; + + while (occ > 0) { + NextCode(tif, sp, bp, code, GetNextCodeCompat); + if (code == CODE_EOI) + break; + if (code == CODE_CLEAR) { + free_entp = sp->dec_codetab + CODE_FIRST; + nbits = BITS_MIN; + nbitsmask = MAXCODE(BITS_MIN); + maxcodep = sp->dec_codetab + nbitsmask; + NextCode(tif, sp, bp, code, GetNextCodeCompat); + if (code == CODE_EOI) + break; + *op++ = code, occ--; + oldcodep = sp->dec_codetab + code; + continue; + } + codep = sp->dec_codetab + code; + + /* + * Add the new entry to the code table. + */ + assert(&sp->dec_codetab[0] <= free_entp && free_entp + < &sp->dec_codetab[CSIZE]); + free_entp->next = oldcodep; + free_entp->firstchar = free_entp->next->firstchar; + free_entp->length = free_entp->next->length+1; + free_entp->value = (codep < free_entp) ? + codep->firstchar : free_entp->firstchar; + if (++free_entp > maxcodep) { + if (++nbits > BITS_MAX) /* should not happen */ + nbits = BITS_MAX; + nbitsmask = MAXCODE(nbits); + maxcodep = sp->dec_codetab + nbitsmask; + } + oldcodep = codep; + if (code >= 256) { + /* + * Code maps to a string, copy string + * value to output (written in reverse). + */ + if (codep->length > occ) { + /* + * String is too long for decode buffer, + * locate portion that will fit, copy to + * the decode buffer, and setup restart + * logic for the next decoding call. + */ + sp->dec_codep = codep; + do { + codep = codep->next; + } while (codep->length > occ); + sp->dec_restart = occ; + tp = op + occ; + do { + *--tp = codep->value; + codep = codep->next; + } while (--occ); + break; + } + op += codep->length, occ -= codep->length; + tp = op; + do { + *--tp = codep->value; + } while( (codep = codep->next) != NULL); + } else + *op++ = code, occ--; + } + + tif->tif_rawcp = (tidata_t) bp; + sp->lzw_nbits = nbits; + sp->lzw_nextdata = nextdata; + sp->lzw_nextbits = nextbits; + sp->dec_nbitsmask = nbitsmask; + sp->dec_oldcodep = oldcodep; + sp->dec_free_entp = free_entp; + sp->dec_maxcodep = maxcodep; + + if (occ > 0) { + TIFFError(tif->tif_name, + "LZWDecodeCompat: Not enough data at scanline %d (short %d bytes)", + tif->tif_row, occ); + return (0); + } + return (1); +} +#endif /* LZW_COMPAT */ + + + +static void +LZWCleanup(TIFF* tif) +{ + if (tif->tif_data) { + if (tif->tif_mode == O_RDONLY) { + if (DecoderState(tif)->dec_codetab) + _TIFFfree(tif, DecoderState(tif)->dec_codetab); + } + _TIFFfree(tif, tif->tif_data); + tif->tif_data = NULL; + } +} + +static int +LZWSetupEncode(TIFF* tif) +{ + TIFFError(tif->tif_name, + "LZW compression is not available to due to Unisys patent enforcement"); + return (0); +} + +int +TIFFInitLZW(TIFF* tif, int scheme) +{ + assert(scheme == COMPRESSION_LZW); + /* + * Allocate state block so tag methods have storage to record values. + */ + if (tif->tif_mode == O_RDONLY) + { + tif->tif_data=(tidata_t) _TIFFmalloc(tif, sizeof (LZWDecodeState)); + if (tif->tif_data == NULL) + goto bad; + DecoderState(tif)->dec_codetab = NULL; + DecoderState(tif)->dec_decode = NULL; + } + + /* + * Install codec methods. + */ + tif->tif_setupencode = LZWSetupEncode; + tif->tif_setupdecode = LZWSetupDecode; + tif->tif_predecode = LZWPreDecode; + tif->tif_decoderow = LZWDecode; + tif->tif_decodestrip = LZWDecode; + tif->tif_decodetile = LZWDecode; + tif->tif_cleanup = LZWCleanup; + + /* + * Setup predictor setup. + */ + if( tif->tif_mode == O_RDONLY ) + (void) TIFFPredictorInit(tif); + + return (1); + +bad: + TIFFError("TIFFInitLZW", "No space for LZW state block"); + return (0); +} + +/* + * Copyright (c) 1985, 1986 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * James A. Woods, derived from original work by Spencer Thomas + * and Joseph Orost. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ +#endif /* LZW_SUPPORT */ diff --git a/src/libs/pdflib/libs/tiff/tif_next.c b/src/libs/pdflib/libs/tiff/tif_next.c new file mode 100644 index 0000000000..3e211e9659 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_next.c @@ -0,0 +1,142 @@ +/* PDFlib GmbH cvsid: $Id: tif_next.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tiffiop.h" +#ifdef NEXT_SUPPORT +/* + * TIFF Library. + * + * NeXT 2-bit Grey Scale Compression Algorithm Support + */ + +#define SETPIXEL(op, v) { \ + switch (npixels++ & 3) { \ + case 0: op[0] = (v) << 6; break; \ + case 1: op[0] |= (v) << 4; break; \ + case 2: op[0] |= (v) << 2; break; \ + case 3: *op++ |= (v); break; \ + } \ +} + +#define LITERALROW 0x00 +#define LITERALSPAN 0x40 +#define WHITE ((1<<2)-1) + +static int +NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +{ + register tif_char *bp, *op; + register tsize_t cc; + register int n; + tidata_t row; + tsize_t scanline; + + (void) s; + /* + * Each scanline is assumed to start off as all + * white (we assume a PhotometricInterpretation + * of ``min-is-black''). + */ + for (op = buf, cc = occ; cc-- > 0;) + *op++ = 0xff; + + bp = (tif_char *)tif->tif_rawcp; + cc = tif->tif_rawcc; + scanline = tif->tif_scanlinesize; + for (row = buf; (long)occ > 0; occ -= scanline, row += scanline) { + n = *bp++, cc--; + switch (n) { + case LITERALROW: + /* + * The entire scanline is given as literal values. + */ + if (cc < scanline) + goto bad; + _TIFFmemcpy(row, bp, scanline); + bp += scanline; + cc -= scanline; + break; + case LITERALSPAN: { + int off; + /* + * The scanline has a literal span + * that begins at some offset. + */ + off = (bp[0] * 256) + bp[1]; + n = (bp[2] * 256) + bp[3]; + if (cc < 4+n) + goto bad; + _TIFFmemcpy(row+off, bp+4, n); + bp += 4+n; + cc -= 4+n; + break; + } + default: { + register int npixels = 0, grey; + tif_long imagewidth = tif->tif_dir.td_imagewidth; + + /* + * The scanline is composed of a sequence + * of constant color ``runs''. We shift + * into ``run mode'' and interpret bytes + * as codes of the form + * until we've filled the scanline. + */ + op = row; + for (;;) { + grey = (n>>6) & 0x3; + n &= 0x3f; + while (n-- > 0) + SETPIXEL(op, grey); + if (npixels >= (int) imagewidth) + break; + if (cc == 0) + goto bad; + n = *bp++, cc--; + } + break; + } + } + } + tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcc = cc; + return (1); +bad: + TIFFError(tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", + (long) tif->tif_row); + return (0); +} + +int +TIFFInitNeXT(TIFF* tif, int scheme) +{ + (void) scheme; + tif->tif_decoderow = NeXTDecode; + tif->tif_decodestrip = NeXTDecode; + tif->tif_decodetile = NeXTDecode; + return (1); +} +#endif /* NEXT_SUPPORT */ diff --git a/src/libs/pdflib/libs/tiff/tif_open.c b/src/libs/pdflib/libs/tiff/tif_open.c new file mode 100644 index 0000000000..bc37b09f3b --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_open.c @@ -0,0 +1,535 @@ +/* PDFlib GmbH cvsid: $Id: tif_open.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + */ +#include "tiffiop.h" + +static const long typemask[13] = { + 0L, /* TIFF_NOTYPE */ + 0x000000ffL, /* TIFF_BYTE */ + 0xffffffffL, /* TIFF_ASCII */ + 0x0000ffffL, /* TIFF_SHORT */ + 0xffffffffL, /* TIFF_LONG */ + 0xffffffffL, /* TIFF_RATIONAL */ + 0x000000ffL, /* TIFF_SBYTE */ + 0x000000ffL, /* TIFF_UNDEFINED */ + 0x0000ffffL, /* TIFF_SSHORT */ + 0xffffffffL, /* TIFF_SLONG */ + 0xffffffffL, /* TIFF_SRATIONAL */ + 0xffffffffL, /* TIFF_FLOAT */ + 0xffffffffL, /* TIFF_DOUBLE */ +}; +static const int bigTypeshift[13] = { + 0, /* TIFF_NOTYPE */ + 24, /* TIFF_BYTE */ + 0, /* TIFF_ASCII */ + 16, /* TIFF_SHORT */ + 0, /* TIFF_LONG */ + 0, /* TIFF_RATIONAL */ + 24, /* TIFF_SBYTE */ + 24, /* TIFF_UNDEFINED */ + 16, /* TIFF_SSHORT */ + 0, /* TIFF_SLONG */ + 0, /* TIFF_SRATIONAL */ + 0, /* TIFF_FLOAT */ + 0, /* TIFF_DOUBLE */ +}; +static const int litTypeshift[13] = { + 0, /* TIFF_NOTYPE */ + 0, /* TIFF_BYTE */ + 0, /* TIFF_ASCII */ + 0, /* TIFF_SHORT */ + 0, /* TIFF_LONG */ + 0, /* TIFF_RATIONAL */ + 0, /* TIFF_SBYTE */ + 0, /* TIFF_UNDEFINED */ + 0, /* TIFF_SSHORT */ + 0, /* TIFF_SLONG */ + 0, /* TIFF_SRATIONAL */ + 0, /* TIFF_FLOAT */ + 0, /* TIFF_DOUBLE */ +}; + +/* + * Initialize the shift & mask tables, and the + * byte swapping state according to the file + * contents and the machine architecture. + */ +static void +TIFFInitOrder(TIFF* tif, int magic, int bigendian) +{ + tif->tif_typemask = typemask; + if (magic == TIFF_BIGENDIAN) { + tif->tif_typeshift = bigTypeshift; + if (!bigendian) + tif->tif_flags |= TIFF_SWAB; + } else { + tif->tif_typeshift = litTypeshift; + if (bigendian) + tif->tif_flags |= TIFF_SWAB; + } +} + +int +_TIFFgetMode(const char* mode, const char* module) +{ + int m = -1; + + switch (mode[0]) { + case 'r': + m = O_RDONLY; + if (mode[1] == '+') + m = O_RDWR; + break; + case 'w': + case 'a': + m = O_RDWR|O_CREAT; + if (mode[0] == 'w') + m |= O_TRUNC; + break; + default: + TIFFError(module, "\"%s\": Bad mode", mode); + break; + } + return (m); +} + +TIFF* +TIFFClientOpen( + const char* name, const char* mode, + void* clientdata, + TIFFReadWriteProc readproc, + TIFFReadWriteProc writeproc, + TIFFSeekProc seekproc, + TIFFCloseProc closeproc, + TIFFSizeProc sizeproc, + TIFFMapFileProc mapproc, + TIFFUnmapFileProc unmapproc, + void* pdflib_opaque, + TIFFmallocHandler malloc_h, + TIFFreallocHandler realloc_h, + TIFFfreeHandler free_h, + TIFFErrorHandler error_h, + TIFFErrorHandler warn_h +) +{ + static const char module[] = "TIFFClientOpen"; + TIFF pdftiff; + TIFF *tif = &pdftiff; + int m, bigendian; + const char* cp; + + /* PDFlib: we read only */ +/* + m = _TIFFgetMode(mode, module); + if (m == -1) + goto bad2; +*/ + m = O_RDONLY; + /* PDFlib: preset tiff structure so that the first malloc works */ + tif->pdflib_opaque = pdflib_opaque; + tif->pdflib_malloc = malloc_h; + tif->pdflib_realloc = realloc_h; + tif->pdflib_free = free_h; + tif->pdflib_error = error_h; + tif->pdflib_warn = warn_h; + + tif = (TIFF *)_TIFFmalloc(tif, sizeof (TIFF) + strlen(name) + 1); + if (tif == NULL) { + TIFFError(module, "%s: Out of memory (TIFF structure)", name); + goto bad2; + } + _TIFFmemset(tif, 0, sizeof (*tif)); + + /* PDFlib: add own mallochandling */ + tif->pdflib_opaque = pdflib_opaque; + tif->pdflib_malloc = malloc_h; + tif->pdflib_realloc = realloc_h; + tif->pdflib_free = free_h; + tif->pdflib_error = error_h; + tif->pdflib_warn = warn_h; + + tif->tif_name = (char *)tif + sizeof (TIFF); + strcpy(tif->tif_name, name); + tif->tif_mode = m &~ (O_CREAT|O_TRUNC); + tif->tif_curdir = (tdir_t) -1; /* non-existent directory */ + tif->tif_curoff = 0; + tif->tif_curstrip = (tstrip_t) -1; /* invalid strip */ + tif->tif_row = (uint32) -1; /* read/write pre-increment */ + tif->tif_clientdata = clientdata; + tif->tif_readproc = readproc; + tif->tif_writeproc = writeproc; + tif->tif_seekproc = seekproc; + tif->tif_closeproc = closeproc; + tif->tif_sizeproc = sizeproc; + tif->tif_mapproc = mapproc; + tif->tif_unmapproc = unmapproc; + _TIFFSetDefaultCompressionState(tif); /* setup default state */ + /* + * Default is to return data MSB2LSB and enable the + * use of memory-mapped files and strip chopping when + * a file is opened read-only. + */ + tif->tif_flags = FILLORDER_MSB2LSB; +#ifdef HAVE_MMAP + if (m == O_RDONLY ) + tif->tif_flags |= TIFF_MAPPED; +#endif + +#ifdef STRIPCHOP_DEFAULT + if (m == O_RDONLY || m == O_RDWR) + tif->tif_flags |= STRIPCHOP_DEFAULT; +#endif + + { union { int32 i; char c[4]; } u; u.i = 1; bigendian = u.c[0] == 0; } + /* + * Process library-specific flags in the open mode string. + * The following flags may be used to control intrinsic library + * behaviour that may or may not be desirable (usually for + * compatibility with some application that claims to support + * TIFF but only supports some braindead idea of what the + * vendor thinks TIFF is): + * + * 'l' use little-endian byte order for creating a file + * 'b' use big-endian byte order for creating a file + * 'L' read/write information using LSB2MSB bit order + * 'B' read/write information using MSB2LSB bit order + * 'H' read/write information using host bit order + * 'M' enable use of memory-mapped files when supported + * 'm' disable use of memory-mapped files + * 'C' enable strip chopping support when reading + * 'c' disable strip chopping support + * + * The use of the 'l' and 'b' flags is strongly discouraged. + * These flags are provided solely because numerous vendors, + * typically on the PC, do not correctly support TIFF; they + * only support the Intel little-endian byte order. This + * support is not configured by default because it supports + * the violation of the TIFF spec that says that readers *MUST* + * support both byte orders. It is strongly recommended that + * you not use this feature except to deal with busted apps + * that write invalid TIFF. And even in those cases you should + * bang on the vendors to fix their software. + * + * The 'L', 'B', and 'H' flags are intended for applications + * that can optimize operations on data by using a particular + * bit order. By default the library returns data in MSB2LSB + * bit order for compatibiltiy with older versions of this + * library. Returning data in the bit order of the native cpu + * makes the most sense but also requires applications to check + * the value of the FillOrder tag; something they probabyl do + * not do right now. + * + * The 'M' and 'm' flags are provided because some virtual memory + * systems exhibit poor behaviour when large images are mapped. + * These options permit clients to control the use of memory-mapped + * files on a per-file basis. + * + * The 'C' and 'c' flags are provided because the library support + * for chopping up large strips into multiple smaller strips is not + * application-transparent and as such can cause problems. The 'c' + * option permits applications that only want to look at the tags, + * for example, to get the unadulterated TIFF tag information. + */ + for (cp = mode; *cp; cp++) + switch (*cp) { + case 'b': + if ((m&O_CREAT) && !bigendian) + tif->tif_flags |= TIFF_SWAB; + break; + case 'l': + if ((m&O_CREAT) && bigendian) + tif->tif_flags |= TIFF_SWAB; + break; + case 'B': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + FILLORDER_MSB2LSB; + break; + case 'L': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + FILLORDER_LSB2MSB; + break; +#ifdef PDF_UNUSED /* PDFlib GmbH */ + case 'H': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + HOST_FILLORDER; + break; +#endif +#ifdef HAVE_MMAP + case 'M': + if (m == O_RDONLY) + tif->tif_flags |= TIFF_MAPPED; + break; + case 'm': + if (m == O_RDONLY) + tif->tif_flags &= ~TIFF_MAPPED; + break; +#endif + case 'C': + if (m == O_RDONLY) + tif->tif_flags |= TIFF_STRIPCHOP; + break; + case 'c': + if (m == O_RDONLY) + tif->tif_flags &= ~TIFF_STRIPCHOP; + break; + } + /* + * Read in TIFF header. + */ + if (!ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { +#ifdef PDF_USED + if (tif->tif_mode == O_RDONLY) { +#endif + TIFFError(name, "Cannot read TIFF header"); + goto bad; +#ifdef PDF_USED + } + /* + * Setup header and write. + */ + tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB + ? (bigendian ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN) + : (bigendian ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN); + tif->tif_header.tiff_version = TIFF_VERSION; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&tif->tif_header.tiff_version); + tif->tif_header.tiff_diroff = 0; /* filled in later */ + + /* + * This seek shouldn't be necessary, but I have had some + * crazy problems with a failed fseek() on Solaris leaving + * the current file pointer out of whack when an fwrite() + * is done. + */ + TIFFSeekFile( tif, 0, SEEK_SET ); + + if (!WriteOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { + TIFFError(name, "Error writing TIFF header"); + goto bad; + } + /* + * Setup the byte order handling. + */ + TIFFInitOrder(tif, tif->tif_header.tiff_magic, bigendian); + /* + * Setup default directory. + */ + if (!TIFFDefaultDirectory(tif)) + goto bad; + tif->tif_diroff = 0; + return (tif); +#endif + } + /* + * Setup the byte order handling. + */ + if (tif->tif_header.tiff_magic != TIFF_BIGENDIAN && + tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN) { + TIFFError(name, "Not a TIFF file, bad magic number %d (0x%x)", + tif->tif_header.tiff_magic, + tif->tif_header.tiff_magic); + goto bad; + } + TIFFInitOrder(tif, tif->tif_header.tiff_magic, bigendian); + /* + * Swap header if required. + */ + if (tif->tif_flags & TIFF_SWAB) { + TIFFSwabShort(&tif->tif_header.tiff_version); + TIFFSwabLong(&tif->tif_header.tiff_diroff); + } + /* + * Now check version (if needed, it's been byte-swapped). + * Note that this isn't actually a version number, it's a + * magic number that doesn't change (stupid). + */ + if (tif->tif_header.tiff_version != TIFF_VERSION) { + TIFFError(name, + "Not a TIFF file, bad version number %d (0x%x)", + tif->tif_header.tiff_version, + tif->tif_header.tiff_version); + goto bad; + } + tif->tif_flags |= TIFF_MYBUFFER; + tif->tif_rawcp = tif->tif_rawdata = 0; + tif->tif_rawdatasize = 0; + /* + * Setup initial directory. + */ + switch (mode[0]) { + case 'r': + tif->tif_nextdiroff = tif->tif_header.tiff_diroff; +#ifdef HAVE_MMAP + /* + * Try to use a memory-mapped file if the client + * has not explicitly suppressed usage with the + * 'm' flag in the open mode (see above). + */ + if ((tif->tif_flags & TIFF_MAPPED) && + !TIFFMapFileContents(tif, (tdata_t*) &tif->tif_base, &tif->tif_size)) + tif->tif_flags &= ~TIFF_MAPPED; +#endif + if (TIFFReadDirectory(tif)) { + if( m != O_RDONLY + && tif->tif_dir.td_compression != COMPRESSION_NONE ) + { + TIFFError( name, + "Can't open a compressed TIFF file" + " with compression for update." ); + goto bad; + } + tif->tif_rawcc = -1; + tif->tif_flags |= TIFF_BUFFERSETUP; + return (tif); + } + break; + case 'a': + /* + * New directories are automatically append + * to the end of the directory chain when they + * are written out (see TIFFWriteDirectory). + */ + if (!TIFFDefaultDirectory(tif)) + goto bad; + return (tif); + } +bad: + tif->tif_mode = O_RDONLY; /* XXX avoid flush */ + TIFFClose(tif); + return ((TIFF*)0); +bad2: + (void) (*closeproc)(clientdata); + return ((TIFF*)0); +} + +/* + * Query functions to access private data. + */ + +/* + * Return open file's name. + */ +const char * +TIFFFileName(TIFF* tif) +{ + return (tif->tif_name); +} + +#ifdef PDF_USED +/* + * Return open file's I/O descriptor. + */ +int +TIFFFileno(TIFF* tif) +{ + return (tif->tif_fd); +} +#endif + +/* + * Return read/write mode. + */ +int +TIFFGetMode(TIFF* tif) +{ + return (tif->tif_mode); +} + +/* + * Return nonzero if file is organized in + * tiles; zero if organized as strips. + */ +int +TIFFIsTiled(TIFF* tif) +{ + return (isTiled(tif)); +} + +/* + * Return current row being read/written. + */ +uint32 +TIFFCurrentRow(TIFF* tif) +{ + return (tif->tif_row); +} + +/* + * Return index of the current directory. + */ +tdir_t +TIFFCurrentDirectory(TIFF* tif) +{ + return (tif->tif_curdir); +} + +/* + * Return current strip. + */ +tstrip_t +TIFFCurrentStrip(TIFF* tif) +{ + return (tif->tif_curstrip); +} + +/* + * Return current tile. + */ +ttile_t +TIFFCurrentTile(TIFF* tif) +{ + return (tif->tif_curtile); +} + +/* + * Return nonzero if the file has byte-swapped data. + */ +int +TIFFIsByteSwapped(TIFF* tif) +{ + return ((tif->tif_flags & TIFF_SWAB) != 0); +} + +/* + * Return nonzero if the data is returned up-sampled. + */ +int +TIFFIsUpSampled(TIFF* tif) +{ + return (isUpSampled(tif)); +} + +/* + * Return nonzero if the data is returned in MSB-to-LSB bit order. + */ +int +TIFFIsMSB2LSB(TIFF* tif) +{ + return (isFillOrder(tif, FILLORDER_MSB2LSB)); +} diff --git a/src/libs/pdflib/libs/tiff/tif_packbits.c b/src/libs/pdflib/libs/tiff/tif_packbits.c new file mode 100644 index 0000000000..384e4bc7e9 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_packbits.c @@ -0,0 +1,299 @@ +/* PDFlib GmbH cvsid: $Id: tif_packbits.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tiffiop.h" +#ifdef PACKBITS_SUPPORT +/* + * TIFF Library. + * + * PackBits Compression Algorithm Support + */ +#include +#include + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +PackBitsPreEncode(TIFF* tif, tsample_t s) +{ + (void) s; + /* + * Calculate the scanline/tile-width size in bytes. + */ + if (isTiled(tif)) + tif->tif_data = (tidata_t) TIFFTileRowSize(tif); + else + tif->tif_data = (tidata_t) TIFFScanlineSize(tif); + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * NB: tidata is the type representing *(tidata_t); + * if tidata_t is made signed then this type must + * be adjusted accordingly. + */ +typedef unsigned char tidata; + +/* + * Encode a run of pixels. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +{ + tif_char* bp = (tif_char*) buf; + tidata_t op, ep, lastliteral; + long n, slop; + int b; + enum { BASE, LITERAL, RUN, LITERAL_RUN } state; + + (void) s; + op = tif->tif_rawcp; + ep = tif->tif_rawdata + tif->tif_rawdatasize; + state = BASE; + lastliteral = 0; + while (cc > 0) { + /* + * Find the longest string of identical bytes. + */ + b = *bp++, cc--, n = 1; + for (; cc > 0 && b == *bp; cc--, bp++) + n++; + again: + if (op + 2 >= ep) { /* insure space for new data */ + /* + * Be careful about writing the last + * literal. Must write up to that point + * and then copy the remainder to the + * front of the buffer. + */ + if (state == LITERAL || state == LITERAL_RUN) { + slop = op - lastliteral; + tif->tif_rawcc += lastliteral - tif->tif_rawcp; + if (!TIFFFlushData1(tif)) + return (-1); + op = tif->tif_rawcp; + while (slop-- > 0) + *op++ = *lastliteral++; + lastliteral = tif->tif_rawcp; + } else { + tif->tif_rawcc += op - tif->tif_rawcp; + if (!TIFFFlushData1(tif)) + return (-1); + op = tif->tif_rawcp; + } + } + switch (state) { + case BASE: /* initial state, set run/literal */ + if (n > 1) { + state = RUN; + if (n > 128) { + *op++ = (tidata) -127; + *op++ = b; + n -= 128; + goto again; + } + *op++ = (tidataval_t)(-(n-1)); + *op++ = b; + } else { + lastliteral = op; + *op++ = 0; + *op++ = b; + state = LITERAL; + } + break; + case LITERAL: /* last object was literal string */ + if (n > 1) { + state = LITERAL_RUN; + if (n > 128) { + *op++ = (tidata) -127; + *op++ = b; + n -= 128; + goto again; + } + *op++ = (tidataval_t)(-(n-1)); /* encode run */ + *op++ = b; + } else { /* extend literal */ + if (++(*lastliteral) == 127) + state = BASE; + *op++ = b; + } + break; + case RUN: /* last object was run */ + if (n > 1) { + if (n > 128) { + *op++ = (tidata) -127; + *op++ = b; + n -= 128; + goto again; + } + *op++ = (tidataval_t)(-(n-1)); + *op++ = b; + } else { + lastliteral = op; + *op++ = 0; + *op++ = b; + state = LITERAL; + } + break; + case LITERAL_RUN: /* literal followed by a run */ + /* + * Check to see if previous run should + * be converted to a literal, in which + * case we convert literal-run-literal + * to a single literal. + */ + if (n == 1 && op[-2] == (tidata) -1 && + *lastliteral < 126) { + state = (((*lastliteral) += 2) == 127 ? + BASE : LITERAL); + op[-2] = op[-1]; /* replicate */ + } else + state = RUN; + goto again; + } + } + tif->tif_rawcc += op - tif->tif_rawcp; + tif->tif_rawcp = op; + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Encode a rectangular chunk of pixels. We break it up + * into row-sized pieces to insure that encoded runs do + * not span rows. Otherwise, there can be problems with + * the decoder if data is read, for example, by scanlines + * when it was encoded by strips. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + tsize_t rowsize = (tsize_t) tif->tif_data; + + assert(rowsize > 0); + +#ifdef YCBCR_SUPPORT + /* + * YCBCR data isn't really separable into rows, so we + * might as well encode the whole tile/strip as one chunk. + */ + if( tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR ) + rowsize = (tsize_t) tif->tif_data; +#endif + + while ((long)cc > 0) { + int chunk = rowsize; + + if( cc < chunk ) + chunk = cc; + + if (PackBitsEncode(tif, bp, chunk, s) < 0) + return (-1); + bp += chunk; + cc -= chunk; + } + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static int +PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +{ + char *bp; + tsize_t cc; + long n; + int b; + + (void) s; + bp = (char*) tif->tif_rawcp; + cc = tif->tif_rawcc; + while (cc > 0 && (long)occ > 0) { + n = (long) *bp++, cc--; + /* + * Watch out for compilers that + * don't sign extend chars... + */ + if (n >= 128) + n -= 256; + if (n < 0) { /* replicate next byte -n+1 times */ + if (n == -128) /* nop */ + continue; + n = -n + 1; + if( occ < n ) + { + TIFFWarning(tif->tif_name, + "PackBitsDecode: discarding %d bytes " + "to avoid buffer overrun", + n - occ); + n = occ; + } + occ -= n; + b = *bp++, cc--; + while (n-- > 0) + *op++ = b; + } else { /* copy next n+1 bytes literally */ + if (occ < n + 1) + { + TIFFWarning(tif->tif_name, + "PackBitsDecode: discarding %d bytes " + "to avoid buffer overrun", + n - occ + 1); + n = occ - 1; + } + _TIFFmemcpy(op, bp, ++n); + op += n; occ -= n; + bp += n; cc -= n; + } + } + tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcc = cc; + if (occ > 0) { + TIFFError(tif->tif_name, + "PackBitsDecode: Not enough data for scanline %ld", + (long) tif->tif_row); + return (0); + } + return (1); +} + +int +TIFFInitPackBits(TIFF* tif, int scheme) +{ + (void) scheme; + tif->tif_decoderow = PackBitsDecode; + tif->tif_decodestrip = PackBitsDecode; + tif->tif_decodetile = PackBitsDecode; +#ifdef PDFLIB_TIFFWRITE_SUPPORT + tif->tif_preencode = PackBitsPreEncode; + tif->tif_encoderow = PackBitsEncode; + tif->tif_encodestrip = PackBitsEncodeChunk; + tif->tif_encodetile = PackBitsEncodeChunk; +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + return (1); +} +#endif /* PACKBITS_SUPPORT */ diff --git a/src/libs/pdflib/libs/tiff/tif_predict.c b/src/libs/pdflib/libs/tiff/tif_predict.c new file mode 100644 index 0000000000..95a7e49a0b --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_predict.c @@ -0,0 +1,465 @@ +/* PDFlib GmbH cvsid: $Id: tif_predict.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Predictor Tag Support (used by multiple codecs). + */ +#include "tiffiop.h" +#include "tif_predict.h" + +#include + +#define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) + +static void horAcc8(TIFF*, tidata_t, tsize_t); +static void horAcc16(TIFF*, tidata_t, tsize_t); +static void swabHorAcc16(TIFF*, tidata_t, tsize_t); +static void horDiff8(TIFF*, tidata_t, tsize_t); +static void horDiff16(TIFF*, tidata_t, tsize_t); +static int PredictorDecodeRow(TIFF*, tidata_t, tsize_t, tsample_t); +static int PredictorDecodeTile(TIFF*, tidata_t, tsize_t, tsample_t); +static int PredictorEncodeRow(TIFF*, tidata_t, tsize_t, tsample_t); +static int PredictorEncodeTile(TIFF*, tidata_t, tsize_t, tsample_t); + +static int +PredictorSetup(TIFF* tif) +{ + TIFFPredictorState* sp = PredictorState(tif); + TIFFDirectory* td = &tif->tif_dir; + + if (sp->predictor == 1) /* no differencing */ + return (1); + if (sp->predictor != 2) { + TIFFError(tif->tif_name, "\"Predictor\" value %d not supported", + sp->predictor); + return (0); + } + if (td->td_bitspersample != 8 && td->td_bitspersample != 16) { + TIFFError(tif->tif_name, + "Horizontal differencing \"Predictor\" not supported with %d-bit samples", + td->td_bitspersample); + return (0); + } + sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? + td->td_samplesperpixel : 1); + /* + * Calculate the scanline/tile-width size in bytes. + */ + if (isTiled(tif)) + sp->rowsize = TIFFTileRowSize(tif); + else + sp->rowsize = TIFFScanlineSize(tif); + return (1); +} + +static int +PredictorSetupDecode(TIFF* tif) +{ + TIFFPredictorState* sp = PredictorState(tif); + TIFFDirectory* td = &tif->tif_dir; + + if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif)) + return (0); + if (sp->predictor == 2) { + switch (td->td_bitspersample) { + case 8: sp->pfunc = horAcc8; break; + case 16: sp->pfunc = horAcc16; break; + } + /* + * Override default decoding method with + * one that does the predictor stuff. + */ + sp->coderow = tif->tif_decoderow; + tif->tif_decoderow = PredictorDecodeRow; + sp->codestrip = tif->tif_decodestrip; + tif->tif_decodestrip = PredictorDecodeTile; + sp->codetile = tif->tif_decodetile; + tif->tif_decodetile = PredictorDecodeTile; + /* + * If the data is horizontally differenced + * 16-bit data that requires byte-swapping, + * then it must be byte swapped before the + * accumulation step. We do this with a + * special-purpose routine and override the + * normal post decoding logic that the library + * setup when the directory was read. + */ + if (tif->tif_flags&TIFF_SWAB) { + if (sp->pfunc == horAcc16) { + sp->pfunc = swabHorAcc16; + tif->tif_postdecode = _TIFFNoPostDecode; + } /* else handle 32-bit case... */ + } + } + return (1); +} + +static int +PredictorSetupEncode(TIFF* tif) +{ + TIFFPredictorState* sp = PredictorState(tif); + TIFFDirectory* td = &tif->tif_dir; + + if (!(*sp->setupencode)(tif) || !PredictorSetup(tif)) + return (0); + if (sp->predictor == 2) { + switch (td->td_bitspersample) { + case 8: sp->pfunc = horDiff8; break; + case 16: sp->pfunc = horDiff16; break; + } + /* + * Override default encoding method with + * one that does the predictor stuff. + */ + sp->coderow = tif->tif_encoderow; + tif->tif_encoderow = PredictorEncodeRow; + sp->codestrip = tif->tif_encodestrip; + tif->tif_encodestrip = PredictorEncodeTile; + sp->codetile = tif->tif_encodetile; + tif->tif_encodetile = PredictorEncodeTile; + } + return (1); +} + +#define REPEAT4(n, op) \ + switch (n) { \ + default: { int i; for (i = n-4; i > 0; i--) { op; } } \ + case 4: op; \ + case 3: op; \ + case 2: op; \ + case 1: op; \ + case 0: ; \ + } + +static void +horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc) +{ + TIFFPredictorState* sp = PredictorState(tif); + tsize_t stride = sp->stride; + + char* cp = (char*) cp0; + if (cc > stride) { + cc -= stride; + /* + * Pipeline the most common cases. + */ + if (stride == 3) { + tif_int cr = cp[0]; + tif_int cg = cp[1]; + tif_int cb = cp[2]; + do { + cc -= 3, cp += 3; + cp[0] = (cr += cp[0]); + cp[1] = (cg += cp[1]); + cp[2] = (cb += cp[2]); + } while ((int32) cc > 0); + } else if (stride == 4) { + tif_int cr = cp[0]; + tif_int cg = cp[1]; + tif_int cb = cp[2]; + tif_int ca = cp[3]; + do { + cc -= 4, cp += 4; + cp[0] = (cr += cp[0]); + cp[1] = (cg += cp[1]); + cp[2] = (cb += cp[2]); + cp[3] = (ca += cp[3]); + } while ((int32) cc > 0); + } else { + do { + REPEAT4(stride, cp[stride] += *cp; cp++) + cc -= stride; + } while ((int32) cc > 0); + } + } +} + +static void +swabHorAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) +{ + TIFFPredictorState* sp = PredictorState(tif); + tsize_t stride = sp->stride; + uint16* wp = (uint16*) cp0; + tsize_t wc = cc / 2; + + if (wc > stride) { + TIFFSwabArrayOfShort(wp, wc); + wc -= stride; + do { + REPEAT4(stride, wp[stride] += wp[0]; wp++) + wc -= stride; + } while ((int32) wc > 0); + } +} + +static void +horAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) +{ + tsize_t stride = PredictorState(tif)->stride; + uint16* wp = (uint16*) cp0; + tsize_t wc = cc / 2; + + if (wc > stride) { + wc -= stride; + do { + REPEAT4(stride, wp[stride] += wp[0]; wp++) + wc -= stride; + } while ((int32) wc > 0); + } +} + +/* + * Decode a scanline and apply the predictor routine. + */ +static int +PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +{ + TIFFPredictorState *sp = PredictorState(tif); + + assert(sp != NULL); + assert(sp->coderow != NULL); + assert(sp->pfunc != NULL); + if ((*sp->coderow)(tif, op0, occ0, s)) { + (*sp->pfunc)(tif, op0, occ0); + return (1); + } else + return (0); +} + +/* + * Decode a tile/strip and apply the predictor routine. + * Note that horizontal differencing must be done on a + * row-by-row basis. The width of a "row" has already + * been calculated at pre-decode time according to the + * strip/tile dimensions. + */ +static int +PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +{ + TIFFPredictorState *sp = PredictorState(tif); + + assert(sp != NULL); + assert(sp->codetile != NULL); + if ((*sp->codetile)(tif, op0, occ0, s)) { + tsize_t rowsize = sp->rowsize; + assert(rowsize > 0); + assert(sp->pfunc != NULL); + while ((long)occ0 > 0) { + (*sp->pfunc)(tif, op0, (tsize_t) rowsize); + occ0 -= rowsize; + op0 += rowsize; + } + return (1); + } else + return (0); +} + +static void +horDiff8(TIFF* tif, tidata_t cp0, tsize_t cc) +{ + TIFFPredictorState* sp = PredictorState(tif); + tsize_t stride = sp->stride; + char* cp = (char*) cp0; + + if (cc > stride) { + cc -= stride; + /* + * Pipeline the most common cases. + */ + if (stride == 3) { + int r1, g1, b1; + int r2 = cp[0]; + int g2 = cp[1]; + int b2 = cp[2]; + do { + r1 = cp[3]; cp[3] = r1-r2; r2 = r1; + g1 = cp[4]; cp[4] = g1-g2; g2 = g1; + b1 = cp[5]; cp[5] = b1-b2; b2 = b1; + cp += 3; + } while ((int32)(cc -= 3) > 0); + } else if (stride == 4) { + int r1, g1, b1, a1; + int r2 = cp[0]; + int g2 = cp[1]; + int b2 = cp[2]; + int a2 = cp[3]; + do { + r1 = cp[4]; cp[4] = r1-r2; r2 = r1; + g1 = cp[5]; cp[5] = g1-g2; g2 = g1; + b1 = cp[6]; cp[6] = b1-b2; b2 = b1; + a1 = cp[7]; cp[7] = a1-a2; a2 = a1; + cp += 4; + } while ((int32)(cc -= 4) > 0); + } else { + cp += cc - 1; + do { + REPEAT4(stride, cp[stride] -= cp[0]; cp--) + } while ((int32)(cc -= stride) > 0); + } + } +} + +static void +horDiff16(TIFF* tif, tidata_t cp0, tsize_t cc) +{ + TIFFPredictorState* sp = PredictorState(tif); + tsize_t stride = sp->stride; + int16 *wp = (int16*) cp0; + tsize_t wc = cc/2; + + if (wc > stride) { + wc -= stride; + wp += wc - 1; + do { + REPEAT4(stride, wp[stride] -= wp[0]; wp--) + wc -= stride; + } while ((int32) wc > 0); + } +} + +static int +PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + TIFFPredictorState *sp = PredictorState(tif); + + assert(sp != NULL); + assert(sp->pfunc != NULL); + assert(sp->coderow != NULL); +/* XXX horizontal differencing alters user's data XXX */ + (*sp->pfunc)(tif, bp, cc); + return ((*sp->coderow)(tif, bp, cc, s)); +} + +static int +PredictorEncodeTile(TIFF* tif, tidata_t bp0, tsize_t cc0, tsample_t s) +{ + TIFFPredictorState *sp = PredictorState(tif); + tsize_t cc = cc0, rowsize; + tif_char* bp = bp0; + + assert(sp != NULL); + assert(sp->pfunc != NULL); + assert(sp->codetile != NULL); + rowsize = sp->rowsize; + assert(rowsize > 0); + while ((long)cc > 0) { + (*sp->pfunc)(tif, bp, (tsize_t) rowsize); + cc -= rowsize; + bp += rowsize; + } + return ((*sp->codetile)(tif, bp0, cc0, s)); +} + +#define FIELD_PREDICTOR (FIELD_CODEC+0) /* XXX */ + +static const TIFFFieldInfo predictFieldInfo[] = { + { TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, FIELD_PREDICTOR, + FALSE, FALSE, "Predictor" }, +}; +#define N(a) (sizeof (a) / sizeof (a[0])) + +static int +PredictorVSetField(TIFF* tif, ttag_t tag, va_list ap) +{ + TIFFPredictorState *sp = PredictorState(tif); + + switch (tag) { + case TIFFTAG_PREDICTOR: + sp->predictor = (uint16) va_arg(ap, int); + TIFFSetFieldBit(tif, FIELD_PREDICTOR); + break; + default: + return (*sp->vsetparent)(tif, tag, ap); + } + tif->tif_flags |= TIFF_DIRTYDIRECT; + return (1); +} + +static int +PredictorVGetField(TIFF* tif, ttag_t tag, va_list ap) +{ + TIFFPredictorState *sp = PredictorState(tif); + + switch (tag) { + case TIFFTAG_PREDICTOR: + *va_arg(ap, uint16*) = sp->predictor; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return (1); +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static void +PredictorPrintDir(TIFF* tif, FILE* fd, long flags) +{ + TIFFPredictorState* sp = PredictorState(tif); + + (void) flags; + if (TIFFFieldSet(tif,FIELD_PREDICTOR)) { + fprintf(fd, " Predictor: "); + switch (sp->predictor) { + case 1: fprintf(fd, "none "); break; + case 2: fprintf(fd, "horizontal differencing "); break; + } + fprintf(fd, "%u (0x%x)\n", sp->predictor, sp->predictor); + } + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +int +TIFFPredictorInit(TIFF* tif) +{ + TIFFPredictorState* sp = PredictorState(tif); + + /* + * Merge codec-specific tag information and + * override parent get/set field methods. + */ + _TIFFMergeFieldInfo(tif, predictFieldInfo, N(predictFieldInfo)); + sp->vgetparent = tif->tif_vgetfield; + tif->tif_vgetfield = PredictorVGetField;/* hook for predictor tag */ + sp->vsetparent = tif->tif_vsetfield; + tif->tif_vsetfield = PredictorVSetField;/* hook for predictor tag */ + sp->printdir = tif->tif_printdir; +#ifdef PDFLIB_TIFFWRITE_SUPPORT + tif->tif_printdir = PredictorPrintDir; /* hook for predictor tag */ +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + + sp->setupdecode = tif->tif_setupdecode; + tif->tif_setupdecode = PredictorSetupDecode; + sp->setupencode = tif->tif_setupencode; + tif->tif_setupencode = PredictorSetupEncode; + + sp->predictor = 1; /* default value */ + sp->pfunc = NULL; /* no predictor routine */ + return (1); +} diff --git a/src/libs/pdflib/libs/tiff/tif_predict.h b/src/libs/pdflib/libs/tiff/tif_predict.h new file mode 100644 index 0000000000..74ec960276 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_predict.h @@ -0,0 +1,61 @@ +/* PDFlib GmbH cvsid: $Id: tif_predict.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1995-1997 Sam Leffler + * Copyright (c) 1995-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFFPREDICT_ +#define _TIFFPREDICT_ +/* + * ``Library-private'' Support for the Predictor Tag + */ + +/* + * Codecs that want to support the Predictor tag must place + * this structure first in their private state block so that + * the predictor code can cast tif_data to find its state. + */ +typedef struct { + int predictor; /* predictor tag value */ + int stride; /* sample stride over data */ + tsize_t rowsize; /* tile/strip row size */ + + TIFFPostMethod pfunc; /* horizontal differencer/accumulator */ + TIFFCodeMethod coderow; /* parent codec encode/decode row */ + TIFFCodeMethod codestrip; /* parent codec encode/decode strip */ + TIFFCodeMethod codetile; /* parent codec encode/decode tile */ + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ + TIFFPrintMethod printdir; /* super-class method */ + TIFFBoolMethod setupdecode; /* super-class method */ + TIFFBoolMethod setupencode; /* super-class method */ +} TIFFPredictorState; + +#if defined(__cplusplus) +extern "C" { +#endif +extern int TIFFPredictorInit(TIFF*); +#if defined(__cplusplus) +} +#endif +#endif /* _TIFFPREDICT_ */ diff --git a/src/libs/pdflib/libs/tiff/tif_read.c b/src/libs/pdflib/libs/tiff/tif_read.c new file mode 100644 index 0000000000..428906453d --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_read.c @@ -0,0 +1,636 @@ +/* PDFlib GmbH cvsid: $Id: tif_read.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * Scanline-oriented Read Support + */ +#include "tiffiop.h" +#include +#include + +static int TIFFFillStrip(TIFF*, tstrip_t); +static int TIFFFillTile(TIFF*, ttile_t); +static int TIFFStartStrip(TIFF*, tstrip_t); +static int TIFFStartTile(TIFF*, ttile_t); +static int TIFFCheckRead(TIFF*, int); + +#define NOSTRIP ((tstrip_t) -1) /* undefined state */ +#define NOTILE ((ttile_t) -1) /* undefined state */ + +/* + * Seek to a random row+sample in a file. + */ +static int +TIFFSeek(TIFF* tif, uint32 row, tsample_t sample) +{ + register TIFFDirectory *td = &tif->tif_dir; + tstrip_t strip; + + if (row >= td->td_imagelength) { /* out of range */ + TIFFError(tif->tif_name, "%lu: Row out of range, max %lu", + (tif_long) row, (tif_long) td->td_imagelength); + return (0); + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + if (sample >= td->td_samplesperpixel) { + TIFFError(tif->tif_name, + "%lu: Sample out of range, max %lu", + (tif_long)sample,(tif_long)td->td_samplesperpixel); + return (0); + } + strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; + } else + strip = row / td->td_rowsperstrip; + if (strip != tif->tif_curstrip) { /* different strip, refill */ + if (!TIFFFillStrip(tif, strip)) + return (0); + } else if (row < tif->tif_row) { + /* + * Moving backwards within the same strip: backup + * to the start and then decode forward (below). + * + * NB: If you're planning on lots of random access within a + * strip, it's better to just read and decode the entire + * strip, and then access the decoded data in a random fashion. + */ + if (!TIFFStartStrip(tif, strip)) + return (0); + } + if (row != tif->tif_row) { + /* + * Seek forward to the desired row. + */ + if (!(*tif->tif_seek)(tif, row - tif->tif_row)) + return (0); + tif->tif_row = row; + } + return (1); +} + +int +TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) +{ + int e; + + if (!TIFFCheckRead(tif, 0)) + return (-1); + if( (e = TIFFSeek(tif, row, sample)) != 0) { + /* + * Decompress desired row into user buffer. + */ + e = (*tif->tif_decoderow) + (tif, (tidata_t) buf, tif->tif_scanlinesize, sample); + tif->tif_row++; + if (e) + (*tif->tif_postdecode)(tif, (tidata_t) buf, + tif->tif_scanlinesize); + } + return (e > 0 ? 1 : -1); +} + +/* + * Read a strip of data and decompress the specified + * amount into the user-supplied buffer. + */ +tsize_t +TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) +{ + TIFFDirectory *td = &tif->tif_dir; + uint32 nrows; + tsize_t stripsize; + tstrip_t sep_strip, strips_per_sep; + + if (!TIFFCheckRead(tif, 0)) + return (-1); + if (strip >= td->td_nstrips) { + TIFFError(tif->tif_name, "%ld: Strip out of range, max %ld", + (long) strip, (long) td->td_nstrips); + return (-1); + } + /* + * Calculate the strip size according to the number of + * rows in the strip (check for truncated last strip on any + * of the separations). + */ + if( td->td_rowsperstrip >= td->td_imagelength ) + strips_per_sep = 1; + else + strips_per_sep = (td->td_imagelength+td->td_rowsperstrip-1) + / td->td_rowsperstrip; + + sep_strip = strip % strips_per_sep; + + if (sep_strip != strips_per_sep-1 || + (nrows = td->td_imagelength % td->td_rowsperstrip) == 0) + nrows = td->td_rowsperstrip; + + stripsize = TIFFVStripSize(tif, nrows); + if (size == (tsize_t) -1) + size = stripsize; + else if (size > stripsize) + size = stripsize; + if (TIFFFillStrip(tif, strip) && (*tif->tif_decodestrip)(tif, + (tidata_t) buf, size, (tsample_t)(strip / td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (tidata_t) buf, size); + return (size); + } else + return ((tsize_t) -1); +} + +static tsize_t +TIFFReadRawStrip1(TIFF* tif, + tstrip_t strip, tdata_t buf, tsize_t size, const char* module) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (!isMapped(tif)) { + tsize_t cc; + + if (!SeekOK(tif, td->td_stripoffset[strip])) { + TIFFError(module, + "%s: Seek error at scanline %lu, strip %lu", + tif->tif_name, + (tif_long) tif->tif_row, (tif_long) strip); + return (-1); + } + cc = TIFFReadFile(tif, buf, size); + if (cc != size) { + TIFFError(module, + "%s: Read error at scanline %lu; got %lu bytes, expected %lu", + tif->tif_name, + (tif_long) tif->tif_row, + (tif_long) cc, + (tif_long) size); + return (-1); + } + } else { + if (td->td_stripoffset[strip] + size > tif->tif_size) { + TIFFError(module, + "%s: Read error at scanline %lu, strip %lu; got %lu bytes, expected %lu", + tif->tif_name, + (tif_long) tif->tif_row, + (tif_long) strip, + (tif_long)tif->tif_size-td->td_stripoffset[strip], + (tif_long) size); + return (-1); + } + _TIFFmemcpy(buf, tif->tif_base+td->td_stripoffset[strip], size); + } + return (size); +} + +/* + * Read a strip of data from the file. + */ +tsize_t +TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) +{ + static const char module[] = "TIFFReadRawStrip"; + TIFFDirectory *td = &tif->tif_dir; + tsize_t bytecount; + + if (!TIFFCheckRead(tif, 0)) + return ((tsize_t) -1); + if (strip >= td->td_nstrips) { + TIFFError(tif->tif_name, "%lu: Strip out of range, max %lu", + (tif_long) strip, (tif_long) td->td_nstrips); + return ((tsize_t) -1); + } + bytecount = td->td_stripbytecount[strip]; + if (bytecount <= 0) { + TIFFError(tif->tif_name, + "%lu: Invalid strip byte count, strip %lu", + (tif_long) bytecount, (tif_long) strip); + return ((tsize_t) -1); + } + if (size != (tsize_t)-1 && size < bytecount) + bytecount = size; + return (TIFFReadRawStrip1(tif, strip, buf, bytecount, module)); +} + +/* + * Read the specified strip and setup for decoding. + * The data buffer is expanded, as necessary, to + * hold the strip's data. + */ +static int +TIFFFillStrip(TIFF* tif, tstrip_t strip) +{ + static const char module[] = "TIFFFillStrip"; + TIFFDirectory *td = &tif->tif_dir; + tsize_t bytecount; + + bytecount = td->td_stripbytecount[strip]; + if (bytecount <= 0) { + TIFFError(tif->tif_name, + "%lu: Invalid strip byte count, strip %lu", + (tif_long) bytecount, (tif_long) strip); + return (0); + } + if (isMapped(tif) && + (isFillOrder(tif, td->td_fillorder) + || (tif->tif_flags & TIFF_NOBITREV))) { + /* + * The image is mapped into memory and we either don't + * need to flip bits or the compression routine is going + * to handle this operation itself. In this case, avoid + * copying the raw data and instead just reference the + * data from the memory mapped file image. This assumes + * that the decompression routines do not modify the + * contents of the raw data buffer (if they try to, + * the application will get a fault since the file is + * mapped read-only). + */ + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) + _TIFFfree(tif, tif->tif_rawdata); + tif->tif_flags &= ~TIFF_MYBUFFER; + if ( td->td_stripoffset[strip] + bytecount > tif->tif_size) { + /* + * This error message might seem strange, but it's + * what would happen if a read were done instead. + */ + TIFFError(module, + "%s: Read error on strip %lu; got %lu bytes, expected %lu", + tif->tif_name, + (tif_long) strip, + (tif_long)tif->tif_size-td->td_stripoffset[strip], + (tif_long) bytecount); + tif->tif_curstrip = NOSTRIP; + return (0); + } + tif->tif_rawdatasize = bytecount; + tif->tif_rawdata = tif->tif_base + td->td_stripoffset[strip]; + } else { + /* + * Expand raw data buffer, if needed, to + * hold data strip coming from file + * (perhaps should set upper bound on + * the size of a buffer we'll use?). + */ + if (bytecount > tif->tif_rawdatasize) { + tif->tif_curstrip = NOSTRIP; + if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { + TIFFError(module, + "%s: Data buffer too small to hold strip %lu", + tif->tif_name, (tif_long) strip); + return (0); + } + if (!TIFFReadBufferSetup(tif, 0, + TIFFroundup(bytecount, 1024))) + return (0); + } + if (TIFFReadRawStrip1(tif, strip, (tif_char *)tif->tif_rawdata, + bytecount, module) != bytecount) + return (0); + if (!isFillOrder(tif, td->td_fillorder) && + (tif->tif_flags & TIFF_NOBITREV) == 0) + TIFFReverseBits(tif->tif_rawdata, bytecount); + } + return (TIFFStartStrip(tif, strip)); +} + +/* + * Tile-oriented Read Support + * Contributed by Nancy Cam (Silicon Graphics). + */ + +/* + * Read and decompress a tile of data. The + * tile is selected by the (x,y,z,s) coordinates. + */ +tsize_t +TIFFReadTile(TIFF* tif, + tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) +{ + if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) + return (-1); + return (TIFFReadEncodedTile(tif, + TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); +} + +/* + * Read a tile of data and decompress the specified + * amount into the user-supplied buffer. + */ +tsize_t +TIFFReadEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) +{ + TIFFDirectory *td = &tif->tif_dir; + tsize_t tilesize = tif->tif_tilesize; + + if (!TIFFCheckRead(tif, 1)) + return (-1); + if (tile >= td->td_nstrips) { + TIFFError(tif->tif_name, "%ld: Tile out of range, max %ld", + (long) tile, (tif_long) td->td_nstrips); + return (-1); + } + if (size == (tsize_t) -1) + size = tilesize; + else if (size > tilesize) + size = tilesize; + if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, + (tidata_t) buf, size, (tsample_t)(tile/td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (tidata_t) buf, size); + return (size); + } else + return (-1); +} + +static tsize_t +TIFFReadRawTile1(TIFF* tif, + ttile_t tile, tdata_t buf, tsize_t size, const char* module) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (!isMapped(tif)) { + tsize_t cc; + + if (!SeekOK(tif, td->td_stripoffset[tile])) { + TIFFError(module, + "%s: Seek error at row %ld, col %ld, tile %ld", + tif->tif_name, + (long) tif->tif_row, + (long) tif->tif_col, + (long) tile); + return ((tsize_t) -1); + } + cc = TIFFReadFile(tif, buf, size); + if (cc != size) { + TIFFError(module, + "%s: Read error at row %ld, col %ld; got %lu bytes, expected %lu", + tif->tif_name, + (long) tif->tif_row, + (long) tif->tif_col, + (tif_long) cc, + (tif_long) size); + return ((tsize_t) -1); + } + } else { + if (td->td_stripoffset[tile] + size > tif->tif_size) { + TIFFError(module, + "%s: Read error at row %ld, col %ld, tile %ld; got %lu bytes, expected %lu", + tif->tif_name, + (long) tif->tif_row, + (long) tif->tif_col, + (long) tile, + (tif_long) tif->tif_size - td->td_stripoffset[tile], + (tif_long) size); + return ((tsize_t) -1); + } + _TIFFmemcpy(buf, tif->tif_base+td->td_stripoffset[tile], size); + } + return (size); +} + +/* + * Read a tile of data from the file. + */ +tsize_t +TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) +{ + static const char module[] = "TIFFReadRawTile"; + TIFFDirectory *td = &tif->tif_dir; + tsize_t bytecount; + + if (!TIFFCheckRead(tif, 1)) + return ((tsize_t) -1); + if (tile >= td->td_nstrips) { + TIFFError(tif->tif_name, "%lu: Tile out of range, max %lu", + (tif_long) tile, (tif_long) td->td_nstrips); + return ((tsize_t) -1); + } + bytecount = td->td_stripbytecount[tile]; + if (size != (tsize_t) -1 && size < bytecount) + bytecount = size; + return (TIFFReadRawTile1(tif, tile, buf, bytecount, module)); +} + +/* + * Read the specified tile and setup for decoding. + * The data buffer is expanded, as necessary, to + * hold the tile's data. + */ +static int +TIFFFillTile(TIFF* tif, ttile_t tile) +{ + static const char module[] = "TIFFFillTile"; + TIFFDirectory *td = &tif->tif_dir; + tsize_t bytecount; + + bytecount = td->td_stripbytecount[tile]; + if (bytecount <= 0) { + TIFFError(tif->tif_name, + "%lu: Invalid tile byte count, tile %lu", + (tif_long) bytecount, (tif_long) tile); + return (0); + } + if (isMapped(tif) && + (isFillOrder(tif, td->td_fillorder) || + (tif->tif_flags & TIFF_NOBITREV))) { + /* + * The image is mapped into memory and we either don't + * need to flip bits or the compression routine is going + * to handle this operation itself. In this case, avoid + * copying the raw data and instead just reference the + * data from the memory mapped file image. This assumes + * that the decompression routines do not modify the + * contents of the raw data buffer (if they try to, + * the application will get a fault since the file is + * mapped read-only). + */ + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) + _TIFFfree(tif, tif->tif_rawdata); + tif->tif_flags &= ~TIFF_MYBUFFER; + if ( td->td_stripoffset[tile] + bytecount > tif->tif_size) { + tif->tif_curtile = NOTILE; + return (0); + } + tif->tif_rawdatasize = bytecount; + tif->tif_rawdata = tif->tif_base + td->td_stripoffset[tile]; + } else { + /* + * Expand raw data buffer, if needed, to + * hold data tile coming from file + * (perhaps should set upper bound on + * the size of a buffer we'll use?). + */ + if (bytecount > tif->tif_rawdatasize) { + tif->tif_curtile = NOTILE; + if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { + TIFFError(module, + "%s: Data buffer too small to hold tile %ld", + tif->tif_name, (long) tile); + return (0); + } + if (!TIFFReadBufferSetup(tif, 0, + TIFFroundup(bytecount, 1024))) + return (0); + } + if (TIFFReadRawTile1(tif, tile, (tif_char *)tif->tif_rawdata, + bytecount, module) != bytecount) + return (0); + if (!isFillOrder(tif, td->td_fillorder) && + (tif->tif_flags & TIFF_NOBITREV) == 0) + TIFFReverseBits(tif->tif_rawdata, bytecount); + } + return (TIFFStartTile(tif, tile)); +} + +/* + * Setup the raw data buffer in preparation for + * reading a strip of raw data. If the buffer + * is specified as zero, then a buffer of appropriate + * size is allocated by the library. Otherwise, + * the client must guarantee that the buffer is + * large enough to hold any individual strip of + * raw data. + */ +int +TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) +{ + static const char module[] = "TIFFReadBufferSetup"; + + if (tif->tif_rawdata) { + if (tif->tif_flags & TIFF_MYBUFFER) + _TIFFfree(tif, tif->tif_rawdata); + tif->tif_rawdata = NULL; + } + if (bp) { + tif->tif_rawdatasize = size; + tif->tif_rawdata = (tidata_t) bp; + tif->tif_flags &= ~TIFF_MYBUFFER; + } else { + tif->tif_rawdatasize = TIFFroundup(size, 1024); + tif->tif_rawdata = + (tidata_t) _TIFFmalloc(tif, tif->tif_rawdatasize); + tif->tif_flags |= TIFF_MYBUFFER; + } + if (tif->tif_rawdata == NULL) { + TIFFError(module, + "%s: No space for data buffer at scanline %ld", + tif->tif_name, (long) tif->tif_row); + tif->tif_rawdatasize = 0; + return (0); + } + return (1); +} + +/* + * Set state to appear as if a + * strip has just been read in. + */ +static int +TIFFStartStrip(TIFF* tif, tstrip_t strip) +{ + TIFFDirectory *td = &tif->tif_dir; + + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupdecode)(tif)) + return (0); + tif->tif_flags |= TIFF_CODERSETUP; + } + tif->tif_curstrip = strip; + tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; + tif->tif_rawcp = tif->tif_rawdata; + tif->tif_rawcc = td->td_stripbytecount[strip]; + return ((*tif->tif_predecode)(tif, + (tsample_t)(strip / td->td_stripsperimage))); +} + +/* + * Set state to appear as if a + * tile has just been read in. + */ +static int +TIFFStartTile(TIFF* tif, ttile_t tile) +{ + TIFFDirectory *td = &tif->tif_dir; + + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupdecode)(tif)) + return (0); + tif->tif_flags |= TIFF_CODERSETUP; + } + tif->tif_curtile = tile; + tif->tif_row = + (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) * + td->td_tilelength; + tif->tif_col = + (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) * + td->td_tilewidth; + tif->tif_rawcp = tif->tif_rawdata; + tif->tif_rawcc = td->td_stripbytecount[tile]; + return ((*tif->tif_predecode)(tif, + (tsample_t)(tile/td->td_stripsperimage))); +} + +static int +TIFFCheckRead(TIFF* tif, int tiles) +{ + if (tif->tif_mode == O_WRONLY) { + TIFFError(tif->tif_name, "File not open for reading"); + return (0); + } + if (tiles ^ isTiled(tif)) { + TIFFError(tif->tif_name, tiles ? + "Can not read tiles from a stripped image" : + "Can not read scanlines from a tiled image"); + return (0); + } + return (1); +} + +void +_TIFFNoPostDecode(TIFF* tif, tidata_t buf, tsize_t cc) +{ + (void) tif; (void) buf; (void) cc; +} + +void +_TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc) +{ + (void) tif; + assert((cc & 1) == 0); + TIFFSwabArrayOfShort((uint16*) buf, cc/2); +} + +void +_TIFFSwab32BitData(TIFF* tif, tidata_t buf, tsize_t cc) +{ + (void) tif; + assert((cc & 3) == 0); + TIFFSwabArrayOfLong((uint32*) buf, cc/4); +} + +void +_TIFFSwab64BitData(TIFF* tif, tidata_t buf, tsize_t cc) +{ + (void) tif; + assert((cc & 7) == 0); + TIFFSwabArrayOfDouble((double*) buf, cc/8); +} diff --git a/src/libs/pdflib/libs/tiff/tif_strip.c b/src/libs/pdflib/libs/tiff/tif_strip.c new file mode 100644 index 0000000000..109095afdf --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_strip.c @@ -0,0 +1,192 @@ +/* PDFlib GmbH cvsid: $Id: tif_strip.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1991-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Strip-organized Image Support Routines. + */ +#include "tiffiop.h" + +/* + * Compute which strip a (row,sample) value is in. + */ +tstrip_t +TIFFComputeStrip(TIFF* tif, uint32 row, tsample_t sample) +{ + TIFFDirectory *td = &tif->tif_dir; + tstrip_t strip; + + strip = row / td->td_rowsperstrip; + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + if (sample >= td->td_samplesperpixel) { + TIFFError(tif->tif_name, + "%u: Sample out of range, max %u", + sample, td->td_samplesperpixel); + return ((tstrip_t) 0); + } + strip += sample*td->td_stripsperimage; + } + return (strip); +} + +/* + * Compute how many strips are in an image. + */ +tstrip_t +TIFFNumberOfStrips(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + tstrip_t nstrips; + + nstrips = (td->td_rowsperstrip == (uint32) -1 ? + (td->td_imagelength != 0 ? 1 : 0) : + TIFFhowmany(td->td_imagelength, td->td_rowsperstrip)); + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + nstrips *= td->td_samplesperpixel; + return (nstrips); +} + +/* + * Compute the # bytes in a variable height, row-aligned strip. + */ +tsize_t +TIFFVStripSize(TIFF* tif, uint32 nrows) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (nrows == (uint32) -1) + nrows = td->td_imagelength; +#ifdef YCBCR_SUPPORT + if (td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_photometric == PHOTOMETRIC_YCBCR && + !isUpSampled(tif)) { + /* + * Packed YCbCr data contain one Cb+Cr for every + * HorizontalSampling*VerticalSampling Y values. + * Must also roundup width and height when calculating + * since images that are not a multiple of the + * horizontal/vertical subsampling area include + * YCbCr data for the extended image. + */ + tsize_t w = + TIFFroundup(td->td_imagewidth, td->td_ycbcrsubsampling[0]); + tsize_t scanline = TIFFhowmany(w*td->td_bitspersample, 8); + tsize_t samplingarea = + td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; + nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); + /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ + return ((tsize_t) + (nrows*scanline + 2*(nrows*scanline / samplingarea))); + } else +#endif + return ((tsize_t)(nrows * TIFFScanlineSize(tif))); +} + +/* + * Compute the # bytes in a (row-aligned) strip. + * + * Note that if RowsPerStrip is larger than the + * recorded ImageLength, then the strip size is + * truncated to reflect the actual space required + * to hold the strip. + */ +tsize_t +TIFFStripSize(TIFF* tif) +{ + TIFFDirectory* td = &tif->tif_dir; + uint32 rps = td->td_rowsperstrip; + if (rps > td->td_imagelength) + rps = td->td_imagelength; + return (TIFFVStripSize(tif, rps)); +} + +/* + * Compute a default strip size based on the image + * characteristics and a requested value. If the + * request is <1 then we choose a strip size according + * to certain heuristics. + */ +uint32 +TIFFDefaultStripSize(TIFF* tif, uint32 request) +{ + return (*tif->tif_defstripsize)(tif, request); +} + +uint32 +_TIFFDefaultStripSize(TIFF* tif, uint32 s) +{ + if ((int32) s < 1) { + /* + * If RowsPerStrip is unspecified, try to break the + * image up into strips that are approximately 8Kbytes. + */ + tsize_t scanline = TIFFScanlineSize(tif); + s = (uint32)(8*1024) / (scanline == 0 ? 1 : scanline); + if (s == 0) /* very wide images */ + s = 1; + } + return (s); +} + +/* + * Return the number of bytes to read/write in a call to + * one of the scanline-oriented i/o routines. Note that + * this number may be 1/samples-per-pixel if data is + * stored as separate planes. + */ +tsize_t +TIFFScanlineSize(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + tsize_t scanline; + + scanline = td->td_bitspersample * td->td_imagewidth; + if (td->td_planarconfig == PLANARCONFIG_CONTIG) + scanline *= td->td_samplesperpixel; + return ((tsize_t) TIFFhowmany(scanline, 8)); +} + +/* + * Return the number of bytes required to store a complete + * decoded and packed raster scanline (as opposed to the + * I/O size returned by TIFFScanlineSize which may be less + * if data is store as separate planes). + */ +tsize_t +TIFFRasterScanlineSize(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + tsize_t scanline; + + scanline = td->td_bitspersample * td->td_imagewidth; + if (td->td_planarconfig == PLANARCONFIG_CONTIG) { + scanline *= td->td_samplesperpixel; + return ((tsize_t) TIFFhowmany(scanline, 8)); + } else + return ((tsize_t) + TIFFhowmany(scanline, 8)*td->td_samplesperpixel); +} diff --git a/src/libs/pdflib/libs/tiff/tif_swab.c b/src/libs/pdflib/libs/tiff/tif_swab.c new file mode 100644 index 0000000000..35649b9c00 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_swab.c @@ -0,0 +1,205 @@ +/* PDFlib GmbH cvsid: $Id: tif_swab.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library Bit & Byte Swapping Support. + * + * XXX We assume short = 16-bits and long = 32-bits XXX + */ +#include "tiffiop.h" + +void +TIFFSwabShort(uint16* wp) +{ + register tif_char* cp = (tif_char*) wp; + int t; + + t = cp[1]; cp[1] = cp[0]; cp[0] = t; +} + +void +TIFFSwabLong(uint32* lp) +{ + register tif_char* cp = (tif_char*) lp; + int t; + + t = cp[3]; cp[3] = cp[0]; cp[0] = t; + t = cp[2]; cp[2] = cp[1]; cp[1] = t; +} + +void +TIFFSwabArrayOfShort(uint16* wp, register tif_long n) +{ + register tif_char* cp; + register int t; + + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (tif_char*) wp; + t = cp[1]; cp[1] = cp[0]; cp[0] = t; + wp++; + } +} + +void +TIFFSwabArrayOfLong(register uint32* lp, register tif_long n) +{ + register unsigned char *cp; + register int t; + + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char *)lp; + t = cp[3]; cp[3] = cp[0]; cp[0] = t; + t = cp[2]; cp[2] = cp[1]; cp[1] = t; + lp++; + } +} + +void +TIFFSwabDouble(double *dp) +{ + register uint32* lp = (uint32*) dp; + uint32 t; + + TIFFSwabArrayOfLong(lp, 2); + t = lp[0]; lp[0] = lp[1]; lp[1] = t; +} + +void +TIFFSwabArrayOfDouble(double* dp, register tif_long n) +{ + register uint32* lp = (uint32*) dp; + register uint32 t; + + TIFFSwabArrayOfLong(lp, n + n); + while (n-- > 0) { + t = lp[0]; lp[0] = lp[1]; lp[1] = t; + lp += 2; + } +} + +/* + * Bit reversal tables. TIFFBitRevTable[] gives + * the bit reversed value of . Used in various + * places in the library when the FillOrder requires + * bit reversal of byte values (e.g. CCITT Fax 3 + * encoding/decoding). TIFFNoBitRevTable is provided + * for algorithms that want an equivalent table that + * do not reverse bit values. + */ +static const unsigned char TIFFBitRevTable[256] = { + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; +static const unsigned char TIFFNoBitRevTable[256] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, +}; + +const unsigned char* +TIFFGetBitRevTable(int reversed) +{ + return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable); +} + +void +TIFFReverseBits(register tif_char* cp, register tif_long n) +{ + for (; n > 8; n -= 8) { + cp[0] = TIFFBitRevTable[cp[0]]; + cp[1] = TIFFBitRevTable[cp[1]]; + cp[2] = TIFFBitRevTable[cp[2]]; + cp[3] = TIFFBitRevTable[cp[3]]; + cp[4] = TIFFBitRevTable[cp[4]]; + cp[5] = TIFFBitRevTable[cp[5]]; + cp[6] = TIFFBitRevTable[cp[6]]; + cp[7] = TIFFBitRevTable[cp[7]]; + cp += 8; + } + while (n-- > 0) + *cp = TIFFBitRevTable[*cp], cp++; +} diff --git a/src/libs/pdflib/libs/tiff/tif_thunder.c b/src/libs/pdflib/libs/tiff/tif_thunder.c new file mode 100644 index 0000000000..64e29f8e27 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_thunder.c @@ -0,0 +1,154 @@ +/* PDFlib GmbH cvsid: $Id: tif_thunder.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tiffiop.h" +#ifdef THUNDER_SUPPORT +/* + * TIFF Library. + * + * ThunderScan 4-bit Compression Algorithm Support + */ + +/* + * ThunderScan uses an encoding scheme designed for + * 4-bit pixel values. Data is encoded in bytes, with + * each byte split into a 2-bit code word and a 6-bit + * data value. The encoding gives raw data, runs of + * pixels, or pixel values encoded as a delta from the + * previous pixel value. For the latter, either 2-bit + * or 3-bit delta values are used, with the deltas packed + * into a single byte. + */ +#define THUNDER_DATA 0x3f /* mask for 6-bit data */ +#define THUNDER_CODE 0xc0 /* mask for 2-bit code word */ +/* code values */ +#define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */ +#define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */ +#define DELTA2_SKIP 2 /* skip code for 2-bit deltas */ +#define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */ +#define DELTA3_SKIP 4 /* skip code for 3-bit deltas */ +#define THUNDER_RAW 0xc0 /* raw data encoded */ + +static const int twobitdeltas[4] = { 0, 1, 0, -1 }; +static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; + +#define SETPIXEL(op, v) { \ + lastpixel = (v) & 0xf; \ + if (npixels++ & 1) \ + *op++ |= lastpixel; \ + else \ + op[0] = lastpixel << 4; \ +} + +static int +ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) +{ + register tif_char *bp; + register tsize_t cc; + tif_int lastpixel; + tsize_t npixels; + + bp = (tif_char *)tif->tif_rawcp; + cc = tif->tif_rawcc; + lastpixel = 0; + npixels = 0; + while (cc > 0 && npixels < maxpixels) { + int n, delta; + + n = *bp++, cc--; + switch (n & THUNDER_CODE) { + case THUNDER_RUN: /* pixel run */ + /* + * Replicate the last pixel n times, + * where n is the lower-order 6 bits. + */ + if (npixels & 1) { + op[0] |= lastpixel; + lastpixel = *op++; npixels++; n--; + } else + lastpixel |= lastpixel << 4; + npixels += n; + for (; n > 0; n -= 2) + *op++ = lastpixel; + if (n == -1) + *--op &= 0xf0; + lastpixel &= 0xf; + break; + case THUNDER_2BITDELTAS: /* 2-bit deltas */ + if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP) + SETPIXEL(op, lastpixel + twobitdeltas[delta]); + if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP) + SETPIXEL(op, lastpixel + twobitdeltas[delta]); + if ((delta = (n & 3)) != DELTA2_SKIP) + SETPIXEL(op, lastpixel + twobitdeltas[delta]); + break; + case THUNDER_3BITDELTAS: /* 3-bit deltas */ + if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP) + SETPIXEL(op, lastpixel + threebitdeltas[delta]); + if ((delta = (n & 7)) != DELTA3_SKIP) + SETPIXEL(op, lastpixel + threebitdeltas[delta]); + break; + case THUNDER_RAW: /* raw data */ + SETPIXEL(op, n); + break; + } + } + tif->tif_rawcp = (tidata_t) bp; + tif->tif_rawcc = cc; + if (npixels != maxpixels) { + TIFFError(tif->tif_name, + "ThunderDecode: %s data at scanline %ld (%lu != %lu)", + npixels < maxpixels ? "Not enough" : "Too much", + (long) tif->tif_row, (long) npixels, (long) maxpixels); + return (0); + } + return (1); +} + +static int +ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +{ + tidata_t row = buf; + + (void) s; + while ((long)occ > 0) { + if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) + return (0); + occ -= tif->tif_scanlinesize; + row += tif->tif_scanlinesize; + } + return (1); +} + +int +TIFFInitThunderScan(TIFF* tif, int scheme) +{ + (void) scheme; + tif->tif_decoderow = ThunderDecodeRow; + tif->tif_decodestrip = ThunderDecodeRow; + return (1); +} +#endif /* THUNDER_SUPPORT */ diff --git a/src/libs/pdflib/libs/tiff/tif_tile.c b/src/libs/pdflib/libs/tiff/tif_tile.c new file mode 100644 index 0000000000..59f57391b0 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_tile.c @@ -0,0 +1,219 @@ +/* PDFlib GmbH cvsid: $Id: tif_tile.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1991-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + * + * Tiled Image Support Routines. + */ +#include "tiffiop.h" + +/* + * Compute which tile an (x,y,z,s) value is in. + */ +ttile_t +TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) +{ + TIFFDirectory *td = &tif->tif_dir; + uint32 dx = td->td_tilewidth; + uint32 dy = td->td_tilelength; + uint32 dz = td->td_tiledepth; + ttile_t tile = 1; + + if (td->td_imagedepth == 1) + z = 0; + if (dx == (uint32) -1) + dx = td->td_imagewidth; + if (dy == (uint32) -1) + dy = td->td_imagelength; + if (dz == (uint32) -1) + dz = td->td_imagedepth; + if (dx != 0 && dy != 0 && dz != 0) { + uint32 xpt = TIFFhowmany(td->td_imagewidth, dx); + uint32 ypt = TIFFhowmany(td->td_imagelength, dy); + uint32 zpt = TIFFhowmany(td->td_imagedepth, dz); + + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + tile = (xpt*ypt*zpt)*s + + (xpt*ypt)*(z/dz) + + xpt*(y/dy) + + x/dx; + else + tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx + s; + } + return (tile); +} + +/* + * Check an (x,y,z,s) coordinate + * against the image bounds. + */ +int +TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) +{ + TIFFDirectory *td = &tif->tif_dir; + + if (x >= td->td_imagewidth) { + TIFFError(tif->tif_name, "Col %ld out of range, max %lu", + (long) x, (tif_long) td->td_imagewidth); + return (0); + } + if (y >= td->td_imagelength) { + TIFFError(tif->tif_name, "Row %ld out of range, max %lu", + (long) y, (tif_long) td->td_imagelength); + return (0); + } + if (z >= td->td_imagedepth) { + TIFFError(tif->tif_name, "Depth %ld out of range, max %lu", + (long) z, (tif_long) td->td_imagedepth); + return (0); + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE && + s >= td->td_samplesperpixel) { + TIFFError(tif->tif_name, "Sample %d out of range, max %u", + (int) s, td->td_samplesperpixel); + return (0); + } + return (1); +} + +/* + * Compute how many tiles are in an image. + */ +ttile_t +TIFFNumberOfTiles(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + uint32 dx = td->td_tilewidth; + uint32 dy = td->td_tilelength; + uint32 dz = td->td_tiledepth; + ttile_t ntiles; + + if (dx == (uint32) -1) + dx = td->td_imagewidth; + if (dy == (uint32) -1) + dy = td->td_imagelength; + if (dz == (uint32) -1) + dz = td->td_imagedepth; + ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : + (TIFFhowmany(td->td_imagewidth, dx) * + TIFFhowmany(td->td_imagelength, dy) * + TIFFhowmany(td->td_imagedepth, dz)); + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + ntiles *= td->td_samplesperpixel; + return (ntiles); +} + +/* + * Compute the # bytes in each row of a tile. + */ +tsize_t +TIFFTileRowSize(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + tsize_t rowsize; + + if (td->td_tilelength == 0 || td->td_tilewidth == 0) + return ((tsize_t) 0); + rowsize = td->td_bitspersample * td->td_tilewidth; + if (td->td_planarconfig == PLANARCONFIG_CONTIG) + rowsize *= td->td_samplesperpixel; + return ((tsize_t) TIFFhowmany(rowsize, 8)); +} + +/* + * Compute the # bytes in a variable length, row-aligned tile. + */ +tsize_t +TIFFVTileSize(TIFF* tif, uint32 nrows) +{ + TIFFDirectory *td = &tif->tif_dir; + tsize_t tilesize; + + if (td->td_tilelength == 0 || td->td_tilewidth == 0 || + td->td_tiledepth == 0) + return ((tsize_t) 0); +#ifdef YCBCR_SUPPORT + if (td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_photometric == PHOTOMETRIC_YCBCR && + !isUpSampled(tif)) { + /* + * Packed YCbCr data contain one Cb+Cr for every + * HorizontalSampling*VerticalSampling Y values. + * Must also roundup width and height when calculating + * since images that are not a multiple of the + * horizontal/vertical subsampling area include + * YCbCr data for the extended image. + */ + tsize_t w = + TIFFroundup(td->td_tilewidth, td->td_ycbcrsubsampling[0]); + tsize_t rowsize = TIFFhowmany(w*td->td_bitspersample, 8); + tsize_t samplingarea = + td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; + nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); + /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ + tilesize = nrows*rowsize + 2*(nrows*rowsize / samplingarea); + } else +#endif + tilesize = nrows * TIFFTileRowSize(tif); + return ((tsize_t)(tilesize * td->td_tiledepth)); +} + +/* + * Compute the # bytes in a row-aligned tile. + */ +tsize_t +TIFFTileSize(TIFF* tif) +{ + return (TIFFVTileSize(tif, tif->tif_dir.td_tilelength)); +} + +/* + * Compute a default tile size based on the image + * characteristics and a requested value. If a + * request is <1 then we choose a size according + * to certain heuristics. + */ +void +TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) +{ + (*tif->tif_deftilesize)(tif, tw, th); +} + +void +_TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) +{ + (void) tif; + if (*(int32*) tw < 1) + *tw = 256; + if (*(int32*) th < 1) + *th = 256; + /* roundup to a multiple of 16 per the spec */ + if (*tw & 0xf) + *tw = TIFFroundup(*tw, 16); + if (*th & 0xf) + *th = TIFFroundup(*th, 16); +} diff --git a/src/libs/pdflib/libs/tiff/tif_unix.c b/src/libs/pdflib/libs/tiff/tif_unix.c new file mode 100644 index 0000000000..ad6251480e --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_unix.c @@ -0,0 +1,223 @@ +/* PDFlib GmbH cvsid: $Id: tif_unix.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library UNIX-specific Routines. + */ +#include "tiffiop.h" +#include "pc_config.h" +#include + +static tsize_t +_tiffReadProc(void* fd, tdata_t buf, tsize_t size) +{ + return ((tsize_t) fread(buf, 1, (size_t) size, (FILE *)fd)); +} + +static tsize_t +_tiffWriteProc(void* fd, tdata_t buf, tsize_t size) +{ + return ((tsize_t) fwrite(buf, 1, (size_t) size, (FILE *)fd)); +} + +static toff_t +_tiffSeekProc(void* fd, toff_t off, int whence) +{ + return ((toff_t) fseek((FILE *)fd, (long) off, whence)); +} + +static int +_tiffCloseProc(void* fd) +{ + return (fclose((FILE *)fd)); +} + +static toff_t +_tiffSizeProc(void* fd) +{ +#if defined(MVS) && defined(I370) +#define PDF_FTELL_BUSIZE 32000 + + char buf[PDF_FTELL_BUSIZE]; + size_t filelen = 0; + + fseek((FILE *)fd, 0, SEEK_SET); + + while (!feof((FILE *)fd)) + filelen += fread((void *) buf, 1, PDF_FTELL_BUSIZE, (FILE *)fd); + + return filelen; +#else + fseek((FILE *)fd, 0, SEEK_END); + return (toff_t) ftell((FILE *)fd); +#endif +} + +#ifdef HAVE_MMAP +#include + +static int +_tiffMapProc(void* fd, tdata_t* pbase, toff_t* psize) +{ + toff_t size = _tiffSizeProc((FILE *)fd); + if (size != (toff_t) -1) { + *pbase = (tdata_t) + mmap(0, size, PROT_READ, MAP_SHARED, (FILE *) fd, 0); + if (*pbase != (tdata_t) -1) { + *psize = size; + return (1); + } + } + return (0); +} + +static void +_tiffUnmapProc(void* fd, tdata_t base, toff_t size) +{ + (void) fd; + (void) munmap(base, (off_t) size); +} +#else /* !HAVE_MMAP */ +static int +_tiffMapProc(void* fd, tdata_t* pbase, toff_t* psize) +{ + (void) fd; (void) pbase; (void) psize; + return (0); +} + +static void +_tiffUnmapProc(void* fd, tdata_t base, toff_t size) +{ + (void) fd; (void) base; (void) size; +} +#endif /* !HAVE_MMAP */ + +/* + * Open a TIFF file descriptor for read/writing. + */ +TIFF* +TIFFFdOpen(void* fd, const char* name, const char* mode, void* pdflib_opaque, + TIFFmallocHandler malloc_h, TIFFreallocHandler realloc_h, + TIFFfreeHandler free_h, TIFFErrorHandler error_h, + TIFFErrorHandler warn_h) +{ + TIFF* tif; + + tif = TIFFClientOpen(name, mode, fd, + _tiffReadProc, _tiffWriteProc, + _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, + _tiffMapProc, _tiffUnmapProc, pdflib_opaque, + malloc_h, realloc_h, free_h, error_h, warn_h); + if (tif) + tif->tif_fd = (FILE *)fd; + return (tif); +} + +/* + * Open a TIFF file for read/writing. + */ +TIFF* +TIFFOpen(const char* name, const char* mode, void* pdflib_opaque, + TIFFmallocHandler malloc_h, TIFFreallocHandler realloc_h, + TIFFfreeHandler free_h, TIFFErrorHandler error_h, + TIFFErrorHandler warn_h) +{ + static const char module[] = "TIFFOpen"; + FILE *fd; + + if ((fd = fopen(name, READBMODE)) == NULL) { + TIFFError(module, "%s: Cannot open", name); + return ((TIFF *)0); + } + return (TIFFFdOpen(fd, name, mode, pdflib_opaque, + malloc_h, realloc_h, free_h, error_h, warn_h)); +} + +void* +_TIFFmalloc(TIFF* tif, tsize_t s) +{ + if (tif->pdflib_malloc != NULL) + return (tif->pdflib_malloc(tif, (size_t) s)); + else + return (malloc((size_t) s)); +} + +void +_TIFFfree(TIFF* tif, tdata_t p) +{ + if (tif->pdflib_free != NULL) + tif->pdflib_free(tif, p); + else + free(p); +} + +void* +_TIFFrealloc(TIFF* tif, tdata_t p, tsize_t s) +{ + if (tif->pdflib_realloc != NULL) + return (tif->pdflib_realloc(tif, p, (size_t) s)); + else + return (realloc(p, (size_t) s)); +} + +void +_TIFFmemset(tdata_t p, int v, tsize_t c) +{ + memset(p, v, (size_t) c); +} + +void +_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) +{ + memcpy(d, s, (size_t) c); +} + +int +_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) +{ + return (memcmp(p1, p2, (size_t) c)); +} + +static void +unixWarningHandler(const char* module, const char* fmt, va_list ap) +{ + if (module != NULL) + fprintf(stderr, "%s: ", module); + fprintf(stderr, "Warning, "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ".\n"); +} +TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler; + +static void +unixErrorHandler(const char* module, const char* fmt, va_list ap) +{ + if (module != NULL) + fprintf(stderr, "%s: ", module); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ".\n"); +} +TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler; diff --git a/src/libs/pdflib/libs/tiff/tif_version.c b/src/libs/pdflib/libs/tiff/tif_version.c new file mode 100644 index 0000000000..169e7bff78 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_version.c @@ -0,0 +1,33 @@ +/* PDFlib GmbH cvsid: $Id: tif_version.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ +/* + * Copyright (c) 1992-1997 Sam Leffler + * Copyright (c) 1992-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +#include "tiffiop.h" + +static const char TIFFVersion[] = TIFFLIB_VERSION_STR; + +const char* +TIFFGetVersion(void) +{ + return (TIFFVersion); +} diff --git a/src/libs/pdflib/libs/tiff/tif_warning.c b/src/libs/pdflib/libs/tiff/tif_warning.c new file mode 100644 index 0000000000..0fe2a82d6d --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_warning.c @@ -0,0 +1,49 @@ +/* PDFlib GmbH cvsid: $Id: tif_warning.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library. + */ +#include "tiffiop.h" + +TIFFErrorHandler +TIFFSetWarningHandler(TIFFErrorHandler handler) +{ + TIFFErrorHandler prev = _TIFFwarningHandler; + _TIFFwarningHandler = handler; + return (prev); +} + +void +TIFFWarning(const char* module, const char* fmt, ...) +{ + if (_TIFFwarningHandler) { + va_list ap; + va_start(ap, fmt); + (*_TIFFwarningHandler)(module, fmt, ap); + va_end(ap); + } +} diff --git a/src/libs/pdflib/libs/tiff/tif_zip.c b/src/libs/pdflib/libs/tiff/tif_zip.c new file mode 100644 index 0000000000..943816e03b --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tif_zip.c @@ -0,0 +1,380 @@ +/* PDFlib GmbH cvsid: $Id: tif_zip.c,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1995-1997 Sam Leffler + * Copyright (c) 1995-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "tiffiop.h" +#ifdef ZIP_SUPPORT +/* + * TIFF Library. + * + * ZIP (aka Deflate) Compression Support + * + * This file is simply an interface to the zlib library written by + * Jean-loup Gailly and Mark Adler. You must use version 1.0 or later + * of the library: this code assumes the 1.0 API and also depends on + * the ability to write the zlib header multiple times (one per strip) + * which was not possible with versions prior to 0.95. Note also that + * older versions of this codec avoided this bug by supressing the header + * entirely. This means that files written with the old library cannot + * be read; they should be converted to a different compression scheme + * and then reconverted. + * + * The data format used by the zlib library is described in the files + * zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available in the + * directory ftp://ftp.uu.net/pub/archiving/zip/doc. The library was + * last found at ftp://ftp.uu.net/pub/archiving/zip/zlib/zlib-0.99.tar.gz. + */ +#include "tif_predict.h" +#include "zlib.h" + +#include +#include + +/* + * Sigh, ZLIB_VERSION is defined as a string so there's no + * way to do a proper check here. Instead we guess based + * on the presence of #defines that were added between the + * 0.95 and 1.0 distributions. + */ +#if !defined(Z_NO_COMPRESSION) || !defined(Z_DEFLATED) +#error "Antiquated ZLIB software; you must use version 1.0 or later" +#endif + +/* + * State block for each open TIFF + * file using ZIP compression/decompression. + */ +typedef struct { + TIFFPredictorState predict; + z_stream stream; + int zipquality; /* compression level */ + int state; /* state flags */ +#define ZSTATE_INIT 0x1 /* zlib setup successfully */ + + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ +} ZIPState; + +#define ZState(tif) ((ZIPState*) (tif)->tif_data) +#define DecoderState(tif) ZState(tif) +#define EncoderState(tif) ZState(tif) + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int ZIPEncode(TIFF*, tidata_t, tsize_t, tsample_t); +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ +static int ZIPDecode(TIFF*, tidata_t, tsize_t, tsample_t); + +static int +ZIPSetupDecode(TIFF* tif) +{ + ZIPState* sp = DecoderState(tif); + static const char module[] = "ZIPSetupDecode"; + + assert(sp != NULL); + if (inflateInit(&sp->stream) != Z_OK) { + TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg); + return (0); + } else { + sp->state |= ZSTATE_INIT; + return (1); + } +} + +/* + * Setup state for decoding a strip. + */ +static int +ZIPPreDecode(TIFF* tif, tsample_t s) +{ + ZIPState* sp = DecoderState(tif); + + (void) s; + assert(sp != NULL); + sp->stream.next_in = tif->tif_rawdata; + sp->stream.avail_in = tif->tif_rawcc; + return (inflateReset(&sp->stream) == Z_OK); +} + +static int +ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +{ + ZIPState* sp = DecoderState(tif); + static const char module[] = "ZIPDecode"; + + (void) s; + assert(sp != NULL); + sp->stream.next_out = op; + sp->stream.avail_out = occ; + do { + int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); + if (state == Z_STREAM_END) + break; + if (state == Z_DATA_ERROR) { + TIFFError(module, + "%s: Decoding error at scanline %d, %s", + tif->tif_name, tif->tif_row, sp->stream.msg); + if (inflateSync(&sp->stream) != Z_OK) + return (0); + continue; + } + if (state != Z_OK) { + TIFFError(module, "%s: zlib error: %s", + tif->tif_name, sp->stream.msg); + return (0); + } + } while (sp->stream.avail_out > 0); + if (sp->stream.avail_out != 0) { + TIFFError(module, + "%s: Not enough data at scanline %d (short %d bytes)", + tif->tif_name, tif->tif_row, sp->stream.avail_out); + return (0); + } + return (1); +} + +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +ZIPSetupEncode(TIFF* tif) +{ + ZIPState* sp = EncoderState(tif); + static const char module[] = "ZIPSetupEncode"; + + assert(sp != NULL); + if (deflateInit(&sp->stream, sp->zipquality) != Z_OK) { + TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg); + return (0); + } else { + sp->state |= ZSTATE_INIT; + return (1); + } +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Reset encoding state at the start of a strip. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +ZIPPreEncode(TIFF* tif, tsample_t s) +{ + ZIPState *sp = EncoderState(tif); + + (void) s; + assert(sp != NULL); + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = tif->tif_rawdatasize; + return (deflateReset(&sp->stream) == Z_OK); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Encode a chunk of pixels. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +{ + ZIPState *sp = EncoderState(tif); + static const char module[] = "ZIPEncode"; + + (void) s; + sp->stream.next_in = bp; + sp->stream.avail_in = cc; + do { + if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { + TIFFError(module, "%s: Encoder error: %s", + tif->tif_name, sp->stream.msg); + return (0); + } + if (sp->stream.avail_out == 0) { + tif->tif_rawcc = tif->tif_rawdatasize; + TIFFFlushData1(tif); + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = tif->tif_rawdatasize; + } + } while (sp->stream.avail_in > 0); + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +/* + * Finish off an encoded strip by flushing the last + * string and tacking on an End Of Information code. + */ +#ifdef PDFLIB_TIFFWRITE_SUPPORT +static int +ZIPPostEncode(TIFF* tif) +{ + ZIPState *sp = EncoderState(tif); + static const char module[] = "ZIPPostEncode"; + int state; + + sp->stream.avail_in = 0; + do { + state = deflate(&sp->stream, Z_FINISH); + switch (state) { + case Z_STREAM_END: + case Z_OK: + if (sp->stream.avail_out != tif->tif_rawdatasize) { + tif->tif_rawcc = + tif->tif_rawdatasize - sp->stream.avail_out; + TIFFFlushData1(tif); + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = tif->tif_rawdatasize; + } + break; + default: + TIFFError(module, "%s: zlib error: %s", + tif->tif_name, sp->stream.msg); + return (0); + } + } while (state != Z_STREAM_END); + return (1); +} +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + +static void +ZIPCleanup(TIFF* tif) +{ + ZIPState* sp = ZState(tif); + if (sp) { + if (sp->state&ZSTATE_INIT) { + /* NB: avoid problems in the library */ + if (tif->tif_mode == O_RDONLY) + inflateEnd(&sp->stream); + else + deflateEnd(&sp->stream); + } + _TIFFfree(tif, sp); + tif->tif_data = NULL; + } +} + +static int +ZIPVSetField(TIFF* tif, ttag_t tag, va_list ap) +{ + ZIPState* sp = ZState(tif); + static const char module[] = "ZIPVSetField"; + + switch (tag) { + case TIFFTAG_ZIPQUALITY: + sp->zipquality = va_arg(ap, int); + if (tif->tif_mode != O_RDONLY && (sp->state&ZSTATE_INIT)) { + if (deflateParams(&sp->stream, + sp->zipquality, Z_DEFAULT_STRATEGY) != Z_OK) { + TIFFError(module, "%s: zlib error: %s", + tif->tif_name, sp->stream.msg); + return (0); + } + } + return (1); + default: + return (*sp->vsetparent)(tif, tag, ap); + } + /*NOTREACHED*/ +} + +static int +ZIPVGetField(TIFF* tif, ttag_t tag, va_list ap) +{ + ZIPState* sp = ZState(tif); + + switch (tag) { + case TIFFTAG_ZIPQUALITY: + *va_arg(ap, int*) = sp->zipquality; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return (1); +} + +static const TIFFFieldInfo zipFieldInfo[] = { + { TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, FIELD_PSEUDO, + TRUE, FALSE, "" }, +}; +#define N(a) (sizeof (a) / sizeof (a[0])) + +int +TIFFInitZIP(TIFF* tif, int scheme) +{ + ZIPState* sp; + + assert( (scheme == COMPRESSION_DEFLATE) + || (scheme == COMPRESSION_ADOBE_DEFLATE)); + + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (tidata_t) _TIFFmalloc(tif, sizeof (ZIPState)); + if (tif->tif_data == NULL) + goto bad; + sp = ZState(tif); + sp->stream.zalloc = NULL; + sp->stream.zfree = NULL; + sp->stream.opaque = NULL; + sp->stream.data_type = Z_BINARY; + + /* + * Merge codec-specific tag information and + * override parent get/set field methods. + */ + _TIFFMergeFieldInfo(tif, zipFieldInfo, N(zipFieldInfo)); + sp->vgetparent = tif->tif_vgetfield; + tif->tif_vgetfield = ZIPVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_vsetfield; + tif->tif_vsetfield = ZIPVSetField; /* hook for codec tags */ + + /* Default values for codec-specific fields */ + sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */ + sp->state = 0; + + /* + * Install codec methods. + */ + tif->tif_setupdecode = ZIPSetupDecode; + tif->tif_predecode = ZIPPreDecode; + tif->tif_decoderow = ZIPDecode; + tif->tif_decodestrip = ZIPDecode; + tif->tif_decodetile = ZIPDecode; +#ifdef PDFLIB_TIFFWRITE_SUPPORT + tif->tif_setupencode = ZIPSetupEncode; + tif->tif_preencode = ZIPPreEncode; + tif->tif_postencode = ZIPPostEncode; + tif->tif_encoderow = ZIPEncode; + tif->tif_encodestrip = ZIPEncode; + tif->tif_encodetile = ZIPEncode; +#endif /* PDFLIB_TIFFWRITE_SUPPORT */ + tif->tif_cleanup = ZIPCleanup; + /* + * Setup predictor setup. + */ + (void) TIFFPredictorInit(tif); + return (1); +bad: + TIFFError("TIFFInitZIP", "No space for ZIP state block"); + return (0); +} +#endif /* ZIP_SUPORT */ diff --git a/src/libs/pdflib/libs/tiff/tiff.dsp b/src/libs/pdflib/libs/tiff/tiff.dsp new file mode 100644 index 0000000000..9447507b4e --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tiff.dsp @@ -0,0 +1,267 @@ +# Microsoft Developer Studio Project File - Name="tiff" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=tiff - Win32 Debug DLL +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "tiff.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "tiff.mak" CFG="tiff - Win32 Debug DLL" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "tiff - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "tiff - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE "tiff - Win32 Release mtDLL" (based on "Win32 (x86) Static Library") +!MESSAGE "tiff - Win32 Release DLL" (based on "Win32 (x86) Static Library") +!MESSAGE "tiff - Win32 Debug DLL" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "tiff - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdcore" /I "../flate" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"tiff.lib" + +!ELSEIF "$(CFG)" == "tiff - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /I "../flate" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"libtiff.lib" + +!ELSEIF "$(CFG)" == "tiff - Win32 Release mtDLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_mtDLL" +# PROP BASE Intermediate_Dir "Release_mtDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_mtDLL" +# PROP Intermediate_Dir "Release_mtDLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdflib" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "../pdcore" /I "../flate" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"libtiff.lib" +# ADD LIB32 /nologo /out:"libtiff.lib" + +!ELSEIF "$(CFG)" == "tiff - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release_DLL" +# PROP BASE Intermediate_Dir "Release_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release_DLL" +# PROP Intermediate_Dir "Release_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /O2 /I "../pdcore" /I "../flate" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD CPP /nologo /MT /W3 /O2 /I "../pdcore" /I "../flate" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"tiff.lib" +# ADD LIB32 /nologo /out:"tiff.lib" + +!ELSEIF "$(CFG)" == "tiff - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug_DLL" +# PROP BASE Intermediate_Dir "Debug_DLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug_DLL" +# PROP Intermediate_Dir "Debug_DLL" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /I "../flate" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../pdcore" /I "../flate" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "_MT" /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo /out:"libtiff.lib" +# ADD LIB32 /nologo /out:"libtiff.lib" + +!ENDIF + +# Begin Target + +# Name "tiff - Win32 Release" +# Name "tiff - Win32 Debug" +# Name "tiff - Win32 Release mtDLL" +# Name "tiff - Win32 Release DLL" +# Name "tiff - Win32 Debug DLL" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\tif_auxx.c +# End Source File +# Begin Source File + +SOURCE=.\tif_close.c +# End Source File +# Begin Source File + +SOURCE=.\tif_codec.c +# End Source File +# Begin Source File + +SOURCE=.\tif_compress.c +# End Source File +# Begin Source File + +SOURCE=.\tif_dir.c +# End Source File +# Begin Source File + +SOURCE=.\tif_dirinfo.c +# End Source File +# Begin Source File + +SOURCE=.\tif_dirread.c +# End Source File +# Begin Source File + +SOURCE=.\tif_dumpmode.c +# End Source File +# Begin Source File + +SOURCE=.\tif_error.c +# End Source File +# Begin Source File + +SOURCE=.\tif_fax3.c +# End Source File +# Begin Source File + +SOURCE=.\tif_fax3sm.c +# End Source File +# Begin Source File + +SOURCE=.\tif_getimage.c +# End Source File +# Begin Source File + +SOURCE=.\tif_luv.c +# End Source File +# Begin Source File + +SOURCE=.\tif_lzw.c +# End Source File +# Begin Source File + +SOURCE=.\tif_next.c +# End Source File +# Begin Source File + +SOURCE=.\tif_open.c +# End Source File +# Begin Source File + +SOURCE=.\tif_packbits.c +# End Source File +# Begin Source File + +SOURCE=.\tif_predict.c +# End Source File +# Begin Source File + +SOURCE=.\tif_read.c +# End Source File +# Begin Source File + +SOURCE=.\tif_strip.c +# End Source File +# Begin Source File + +SOURCE=.\tif_swab.c +# End Source File +# Begin Source File + +SOURCE=.\tif_tile.c +# End Source File +# Begin Source File + +SOURCE=.\tif_unix.c +# End Source File +# Begin Source File + +SOURCE=.\tif_version.c +# End Source File +# Begin Source File + +SOURCE=.\tif_warning.c +# End Source File +# Begin Source File + +SOURCE=.\tif_zip.c +# End Source File +# End Group +# End Target +# End Project diff --git a/src/libs/pdflib/libs/tiff/tiff.h b/src/libs/pdflib/libs/tiff/tiff.h new file mode 100644 index 0000000000..d28a54182f --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tiff.h @@ -0,0 +1,458 @@ +/* PDFlib GmbH cvsid: $Id: tiff.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFF_ +#define _TIFF_ +/* + * Tag Image File Format (TIFF) + * + * Based on Rev 6.0 from: + * Developer's Desk + * Aldus Corporation + * 411 First Ave. South + * Suite 200 + * Seattle, WA 98104 + * 206-622-5500 + */ +#define TIFF_VERSION 42 + +#define TIFF_BIGENDIAN 0x4d4d +#define TIFF_LITTLEENDIAN 0x4949 + +#ifndef _TIFF_DATA_TYPEDEFS_ +#define _TIFF_DATA_TYPEDEFS_ +/* + * Intrinsic data types required by the file format: + * + * 8-bit quantities int8/uint8 + * 16-bit quantities int16/uint16 + * 32-bit quantities int32/uint32 + * strings unsigned char* + */ +#ifdef AIX + #include + typedef u_int8 uint8; + typedef u_int16 uint16; + typedef u_int32 uint32; +#else + #ifdef __STDC__ + typedef signed char int8; /* NB: non-ANSI compilers may not grok */ + #else + typedef char int8; + #endif + typedef unsigned char uint8; + typedef short int16; + typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ + #if defined(__alpha) || (defined(_MIPS_SZLONG) && _MIPS_SZLONG == 64) || \ + defined(__sparcv9) || defined(__LP64__) || defined(__arch64__) + typedef int int32; + typedef unsigned int uint32; /* sizeof (uint32) must == 4 */ + #else + typedef long int32; + typedef unsigned long uint32; /* sizeof (uint32) must == 4 */ + #endif +#endif +#endif /* _TIFF_DATA_TYPEDEFS_ */ + +/* For TIFFReassignTagToIgnore */ +enum TIFFIgnoreSense /* IGNORE tag table */ +{ + TIS_STORE, + TIS_EXTRACT, + TIS_EMPTY +}; + +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ + uint16 tiff_version; /* TIFF version number */ + uint32 tiff_diroff; /* byte offset to first directory */ +} TIFFHeader; + +/* + * TIFF Image File Directories are comprised of + * a table of field descriptors of the form shown + * below. The table is sorted in ascending order + * by tag. The values associated with each entry + * are disjoint and may appear anywhere in the file + * (so long as they are placed on a word boundary). + * + * If the value is 4 bytes or less, then it is placed + * in the offset field to save space. If the value + * is less than 4 bytes, it is left-justified in the + * offset field. + */ +typedef struct { + uint16 tdir_tag; /* see below */ + uint16 tdir_type; /* data type; see below */ + uint32 tdir_count; /* number of items; length in spec */ + uint32 tdir_offset; /* byte offset to field data */ +} TIFFDirEntry; + +/* + * NB: In the comments below, + * - items marked with a + are obsoleted by revision 5.0, + * - items marked with a ! are introduced in revision 6.0. + * - items marked with a % are introduced post revision 6.0. + * - items marked with a $ are obsoleted by revision 6.0. + */ + +/* + * Tag data type information. + * + * Note: RATIONALs are the ratio of two 32-bit integer values. + */ +typedef enum { + TIFF_NOTYPE = 0, /* placeholder */ + TIFF_BYTE = 1, /* 8-bit unsigned integer */ + TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ + TIFF_SHORT = 3, /* 16-bit unsigned integer */ + TIFF_LONG = 4, /* 32-bit unsigned integer */ + TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ + TIFF_SBYTE = 6, /* !8-bit signed integer */ + TIFF_UNDEFINED = 7, /* !8-bit untyped data */ + TIFF_SSHORT = 8, /* !16-bit signed integer */ + TIFF_SLONG = 9, /* !32-bit signed integer */ + TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ + TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ + TIFF_DOUBLE = 12 /* !64-bit IEEE floating point */ +} TIFFDataType; + +/* + * TIFF Tag Definitions. + */ +#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ +#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ +#define FILETYPE_PAGE 0x2 /* one page of many */ +#define FILETYPE_MASK 0x4 /* transparency mask */ +#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ +#define OFILETYPE_IMAGE 1 /* full resolution image data */ +#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ +#define OFILETYPE_PAGE 3 /* one page of many */ +#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ +#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ +#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ +#define TIFFTAG_COMPRESSION 259 /* data compression technique */ +#define COMPRESSION_NONE 1 /* dump mode */ +#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ +#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ +#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ +#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ +#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ +#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ +#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ +#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ +#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ +#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ +#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ +#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ +/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ +#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ +#define COMPRESSION_JBIG 34661 /* ISO JBIG */ +#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ +#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ +#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ +#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ +#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ +#define PHOTOMETRIC_RGB 2 /* RGB color model */ +#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ +#define PHOTOMETRIC_MASK 4 /* $holdout mask */ +#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ +#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ +#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ +#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ +#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ +#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ +#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ +#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ +#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ +#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ +#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ +#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ +#define TIFFTAG_FILLORDER 266 /* data order within a byte */ +#define FILLORDER_MSB2LSB 1 /* most significant -> least */ +#define FILLORDER_LSB2MSB 2 /* least significant -> most */ +#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ +#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ +#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ +#define TIFFTAG_MODEL 272 /* scanner model name/number */ +#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ +#define TIFFTAG_ORIENTATION 274 /* +image orientation */ +#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ +#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ +#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ +#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ +#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ +#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ +#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ +#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ +#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ +#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ +#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ +#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ +#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ +#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ +#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ +#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ +#define PLANARCONFIG_CONTIG 1 /* single image plane */ +#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ +#define TIFFTAG_PAGENAME 285 /* page name image is from */ +#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ +#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ +#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ +#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ +#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ +#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ +#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ +#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ +#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ +#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ +#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ +#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ +#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ +#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ +#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ +#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ +#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ +#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ +#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ +#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ +#define RESUNIT_NONE 1 /* no meaningful units */ +#define RESUNIT_INCH 2 /* english */ +#define RESUNIT_CENTIMETER 3 /* metric */ +#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ +#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ +#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ +#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ +#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ +#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ +#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ +#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ +#define TIFFTAG_SOFTWARE 305 /* name & release */ +#define TIFFTAG_DATETIME 306 /* creation date and time */ +#define TIFFTAG_ARTIST 315 /* creator of image */ +#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ +#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ +#define TIFFTAG_WHITEPOINT 318 /* image white point */ +#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ +#define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ +#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ +#define TIFFTAG_TILEWIDTH 322 /* !rows/data tile */ +#define TIFFTAG_TILELENGTH 323 /* !cols/data tile */ +#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ +#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ +#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ +#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ +#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ +#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ +#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ +#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ +#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ +#define TIFFTAG_INKSET 332 /* !inks in separated image */ +#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black */ +#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ +#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ +#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ +#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ +#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ +#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ +#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ +#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ +#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ +#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ +#define SAMPLEFORMAT_INT 2 /* !signed integer data */ +#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ +#define SAMPLEFORMAT_VOID 4 /* !untyped data */ +#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ +#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ +#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ +#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ +#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ +/* + * Tags 512-521 are obsoleted by Technical Note #2 + * which specifies a revised JPEG-in-TIFF scheme. + */ +#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ +#define JPEGPROC_BASELINE 1 /* !baseline sequential */ +#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ +#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ +#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ +#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ +#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ +#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ +#define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ +#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ +#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ +#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ +#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ +#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ +#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ +#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ +#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ +/* tags 32952-32956 are private tags registered to Island Graphics */ +#define TIFFTAG_REFPTS 32953 /* image reference points */ +#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ +#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ +#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ +/* tags 32995-32999 are private tags registered to SGI */ +#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ +#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ +#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ +#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ +/* tags 33300-33309 are private tags registered to Pixar */ +/* + * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH + * are set when an image has been cropped out of a larger image. + * They reflect the size of the original uncropped image. + * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used + * to determine the position of the smaller image in the larger one. + */ +#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ +#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ + /* Tags 33302-33306 are used to identify special image modes and data + * used by Pixar's texture formats. + */ +#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ +#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ +#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ +#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 +#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 +/* tag 33405 is a private tag registered to Eastman Kodak */ +#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ +/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ +#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ +/* IPTC TAG from RichTIFF specifications */ +#define TIFFTAG_RICHTIFFIPTC 33723 +/* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ +#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ +/* tag 34929 is a private tag registered to FedEx */ +#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ +/* tag 65535 is an undefined tag used by Eastman Kodak */ +#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ + +/* + * The following are ``pseudo tags'' that can be + * used to control codec-specific functionality. + * These tags are not written to file. Note that + * these values start at 0xffff+1 so that they'll + * never collide with Aldus-assigned tags. + * + * If you want your private pseudo tags ``registered'' + * (i.e. added to this file), send mail to sam@sgi.com + * with the appropriate C definitions to add. + */ +#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ +#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ +#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ +#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ +#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ +#define FAXMODE_WORDALIGN 0x0008 /* word align row */ +#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ +#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ +/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ +#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ +#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ +#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ +#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ +#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ +#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ +/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ +#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ +#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ +#define PIXARLOGDATAFMT_8BIT 0 /* regular tif_char samples */ +#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order tif_chars */ +#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ +#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ +#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ +#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ +/* 65550-65556 are allocated to Oceana Matrix */ +#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ +#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ +#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ +#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ +#define DCSIMAGERFILTER_IR 0 /* infrared filter */ +#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ +#define DCSIMAGERFILTER_CFA 2 /* color filter array */ +#define DCSIMAGERFILTER_OTHER 3 /* other filter */ +#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ +#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ +#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ +#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ +#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ +#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ +#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ +#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ +/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ +#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ +#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ +/* 65559 is allocated to Oceana Matrix */ +#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ +#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ +#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ +#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ +#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ +#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ +#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ +#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ +#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ +#endif /* _TIFF_ */ diff --git a/src/libs/pdflib/libs/tiff/tiffconf.h b/src/libs/pdflib/libs/tiff/tiffconf.h new file mode 100644 index 0000000000..725ece5306 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tiffconf.h @@ -0,0 +1,148 @@ +/* PDFlib GmbH cvsid: $Id: tiffconf.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ +/* + * Library Configuration Definitions. + * + * This file defines the default configuration for the library. + * If the target system does not have make or a way to specify + * #defines on the command line, this file can be edited to + * configure the library. Otherwise, one can override portability + * and configuration-related definitions from a Makefile or command + * line by defining FEATURE_SUPPORT and COMPRESSION_SUPPORT (see below). + */ + +/* + * General portability-related defines: + * + * HAVE_IEEEFP define as 0 or 1 according to the floating point + * format suported by the machine + * BSDTYPES define this if your system does NOT define the + * usual 4BSD typedefs tif_int et. al. + * HAVE_MMAP enable support for memory mapping read-only files; + * this is typically deduced by the configure script + * HOST_FILLORDER native cpu bit order: one of FILLORDER_MSB2LSB + * or FILLODER_LSB2MSB; this is typically set by the + * configure script + * HOST_BIGENDIAN native cpu byte order: 1 if big-endian (Motorola) + * or 0 if little-endian (Intel); this may be used + * in codecs to optimize code + * USE_64BIT_API set to 1 if tif_unix.c should use lseek64(), + * fstat64() and stat64 allowing 2-4GB files. + */ +#ifndef HAVE_IEEEFP +#define HAVE_IEEEFP 1 +#endif +/* not uesd: PDFlib GmbH: +#ifndef HOST_FILLORDER +#define HOST_FILLORDER FILLORDER_MSB2LSB +#endif +#ifndef HOST_BIGENDIAN +#define HOST_BIGENDIAN 1 +#endif +*/ + +#ifndef USE_64BIT_API +# define USE_64BIT_API 0 +#endif + +#ifndef FEATURE_SUPPORT +/* + * Feature support definitions: + * + * COLORIMETRY_SUPPORT enable support for 6.0 colorimetry tags + * YCBCR_SUPPORT enable support for 6.0 YCbCr tags + * CMYK_SUPPORT enable support for 6.0 CMYK tags + * ICC_SUPPORT enable support for ICC profile tag + * PHOTOSHOP_SUPPORT enable support for PHOTOSHOP resource tag + * IPTC_SUPPORT enable support for RichTIFF IPTC tag + */ +#define COLORIMETRY_SUPPORT +#define YCBCR_SUPPORT +#define CMYK_SUPPORT +#define ICC_SUPPORT +#define PHOTOSHOP_SUPPORT +#define IPTC_SUPPORT +#endif /* FEATURE_SUPPORT */ + +#ifndef COMPRESSION_SUPPORT +/* + * Compression support defines: + * + * CCITT_SUPPORT enable support for CCITT Group 3 & 4 algorithms + * PACKBITS_SUPPORT enable support for Macintosh PackBits algorithm + * LZW_SUPPORT enable support for LZW algorithm + * THUNDER_SUPPORT enable support for ThunderScan 4-bit RLE algorithm + * NEXT_SUPPORT enable support for NeXT 2-bit RLE algorithm + * OJPEG_SUPPORT enable support for 6.0-style JPEG DCT algorithms + * (requires IJG software) + * JPEG_SUPPORT enable support for post-6.0-style JPEG DCT algorithms + * (requires freely available IJG software, see tif_jpeg.c) + * ZIP_SUPPORT enable support for Deflate algorithm + * (requires freely available zlib software, see tif_zip.c) + * PIXARLOG_SUPPORT enable support for Pixar log-format algorithm + * LOGLUV_SUPPORT enable support for LogLuv high dynamic range encoding + */ +#define CCITT_SUPPORT +#define PACKBITS_SUPPORT +#define LZW_SUPPORT /* PDFlib GmbH, required for predictor tag */ +#undef THUNDER_SUPPORT /* PDFlib GmbH */ +#undef OJPEG_SUPPORT /* PDFlib GmbH */ +#undef JPEG_SUPPORT /* PDFlib GmbH */ +#define ZIP_SUPPORT /* PDFlib GmbH */ +#define NEXT_SUPPORT +#define LOGLUV_SUPPORT +#endif /* COMPRESSION_SUPPORT */ + +/* + * If JPEG compression is enabled then we must also include + * support for the colorimetry and YCbCr-related tags. + */ +#ifdef JPEG_SUPPORT +#ifndef YCBCR_SUPPORT +#define YCBCR_SUPPORT +#endif +#ifndef COLORIMETRY_SUPPORT +#define COLORIMETRY_SUPPORT +#endif +#endif /* JPEG_SUPPORT */ + +/* + * ``Orthogonal Features'' + * + * STRIPCHOP_DEFAULT default handling of strip chopping support (whether + * or not to convert single-strip uncompressed images + * to mutiple strips of ~8Kb--to reduce memory use) + * SUBIFD_SUPPORT enable support for SubIFD tag (thumbnails and such) + */ +#ifndef STRIPCHOP_DEFAULT +#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* default is to enable */ +#endif +#ifndef SUBIFD_SUPPORT +#define SUBIFD_SUPPORT 1 /* enable SubIFD tag (330) support */ +#endif +#endif /* _TIFFCONF_ */ diff --git a/src/libs/pdflib/libs/tiff/tiffio.h b/src/libs/pdflib/libs/tiff/tiffio.h new file mode 100644 index 0000000000..29954d98a6 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tiffio.h @@ -0,0 +1,351 @@ +/* PDFlib GmbH cvsid: $Id: tiffio.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFFIO_ +#define _TIFFIO_ +/* + * PDFlib Gmbh, special memory management + * therefore all calls to _TIFFmalloc ... are changed to get a TIFF pointer + * which contains a PDF pointer + */ +#define TIFF_PDFLIB_MEM_SUPPORTED + +/* + * TIFF I/O Library Definitions. + */ +#include "tiff.h" +#include "tiffvers.h" +#include "port.h" + +/* + * TIFF is defined as an incomplete type to hide the + * library's internal data structures from clients. + */ +typedef struct tiff TIFF; + +/* + * The following typedefs define the intrinsic size of + * data types used in the *exported* interfaces. These + * definitions depend on the proper definition of types + * in tiff.h. Note also that the varargs interface used + * to pass tag types and values uses the types defined in + * tiff.h directly. + * + * NB: ttag_t is unsigned int and not unsigned short because + * ANSI C requires that the type before the ellipsis be a + * promoted type (i.e. one of int, unsigned int, pointer, + * or double) and because we defined pseudo-tags that are + * outside the range of legal Aldus-assigned tags. + * NB: tsize_t is int32 and not uint32 because some functions + * return -1. + * NB: toff_t is not off_t for many reasons; TIFFs max out at + * 32-bit file offsets being the most important, and to ensure + * that it is unsigned, rather than signed. + */ +typedef uint32 ttag_t; /* directory tag */ +typedef uint16 tdir_t; /* directory index */ +typedef uint16 tsample_t; /* sample number */ +typedef uint32 tstrip_t; /* strip number */ +typedef uint32 ttile_t; /* tile number */ +typedef int32 tsize_t; /* i/o size in bytes */ +typedef void* tdata_t; /* image data ref */ +typedef uint32 toff_t; /* file offset */ + +#ifndef NULL +#define NULL 0 +#endif + +/* + * Flags to pass to TIFFPrintDirectory to control + * printing of data structures that are potentially + * very large. Bit-or these flags to enable printing + * multiple items. + */ +#define TIFFPRINT_NONE 0x0 /* no extra info */ +#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ +#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ +#define TIFFPRINT_COLORMAP 0x4 /* colormap */ +#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ +#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ +#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ + +/* + * RGBA-style image support. + */ +typedef unsigned char TIFFRGBValue; /* 8-bit samples */ +typedef struct _TIFFRGBAImage TIFFRGBAImage; +/* + * The image reading and conversion routines invoke + * ``put routines'' to copy/image/whatever tiles of + * raw image data. A default set of routines are + * provided to convert/copy raw image data to 8-bit + * packed ABGR format rasters. Applications can supply + * alternate routines that unpack the data into a + * different format or, for example, unpack the data + * and draw the unpacked raster on the display. + */ +typedef void (*tileContigRoutine) + (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, + unsigned char*); +typedef void (*tileSeparateRoutine) + (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, + unsigned char*, unsigned char*, unsigned char*, unsigned char*); +/* + * RGBA-reader state. + */ +typedef struct { /* YCbCr->RGB support */ + TIFFRGBValue* clamptab; /* range clamping table */ + int* Cr_r_tab; + int* Cb_b_tab; + int32* Cr_g_tab; + int32* Cb_g_tab; + float coeffs[3]; /* cached for repeated use */ +} TIFFYCbCrToRGB; + +struct _TIFFRGBAImage { + TIFF* tif; /* image handle */ + int stoponerr; /* stop on read error */ + int isContig; /* data is packed/separate */ + int alpha; /* type of alpha data present */ + uint32 width; /* image width */ + uint32 height; /* image height */ + uint16 bitspersample; /* image bits/sample */ + uint16 samplesperpixel; /* image samples/pixel */ + uint16 orientation; /* image orientation */ + uint16 photometric; /* image photometric interp */ + uint16* redcmap; /* colormap pallete */ + uint16* greencmap; + uint16* bluecmap; + /* get image data routine */ + int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); + union { + void (*any)(TIFFRGBAImage*); + tileContigRoutine contig; + tileSeparateRoutine separate; + } put; /* put decoded strip/tile */ + TIFFRGBValue* Map; /* sample mapping array */ + uint32** BWmap; /* black&white map */ + uint32** PALmap; /* palette image map */ + TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ + + int row_offset; + int col_offset; +}; + +/* + * Macros for extracting components from the + * packed ABGR form returned by TIFFReadRGBAImage. + */ +#define TIFFGetR(abgr) ((abgr) & 0xff) +#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) +#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) +#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) + +/* + * A CODEC is a software package that implements decoding, + * encoding, or decoding+encoding of a compression algorithm. + * The library provides a collection of builtin codecs. + * More codecs may be registered through calls to the library + * and/or the builtin implementations may be overridden. + */ +typedef int (*TIFFInitMethod)(TIFF*, int); +typedef struct { + char* name; + uint16 scheme; + TIFFInitMethod init; +} TIFFCodec; + +#include +#include + +/* share internal LogLuv conversion routines? */ +#ifndef LOGLUV_PUBLIC +#define LOGLUV_PUBLIC 1 +#endif + +#if defined(__cplusplus) +extern "C" { +#endif +typedef tdata_t (*TIFFmallocHandler)(TIFF*, tsize_t); +typedef tdata_t (*TIFFreallocHandler)(TIFF*, tdata_t, tsize_t); +typedef void (*TIFFfreeHandler)(TIFF*, tdata_t); +typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); +typedef tsize_t (*TIFFReadWriteProc)(void*, tdata_t, tsize_t); +typedef toff_t (*TIFFSeekProc)(void*, toff_t, int); +typedef int (*TIFFCloseProc)(void*); +typedef toff_t (*TIFFSizeProc)(void*); +typedef int (*TIFFMapFileProc)(void*, tdata_t*, toff_t*); +typedef void (*TIFFUnmapFileProc)(void*, tdata_t, toff_t); +typedef void (*TIFFExtendProc)(TIFF*); + +extern const char* TIFFGetVersion(void); + +extern const TIFFCodec* TIFFFindCODEC(uint16); +extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); +extern void TIFFUnRegisterCODEC(TIFFCodec*); + +extern tdata_t _TIFFmalloc(TIFF*, tsize_t); +extern tdata_t _TIFFrealloc(TIFF*, tdata_t, tsize_t); +extern void _TIFFmemset(tdata_t, int, tsize_t); +extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t); +extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t); +extern void _TIFFfree(TIFF*, tdata_t); + +extern void TIFFClose(TIFF*); +extern int TIFFFlush(TIFF*); +extern int TIFFFlushData(TIFF*); +extern int TIFFGetField(TIFF*, ttag_t, ...); +extern int TIFFVGetField(TIFF*, ttag_t, va_list); +extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); +extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); +extern int TIFFReadDirectory(TIFF*); +extern tsize_t TIFFScanlineSize(TIFF*); +extern tsize_t TIFFRasterScanlineSize(TIFF*); +extern tsize_t TIFFStripSize(TIFF*); +extern tsize_t TIFFVStripSize(TIFF*, uint32); +extern tsize_t TIFFTileRowSize(TIFF*); +extern tsize_t TIFFTileSize(TIFF*); +extern tsize_t TIFFVTileSize(TIFF*, uint32); +extern uint32 TIFFDefaultStripSize(TIFF*, uint32); +extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); +extern int TIFFFileno(TIFF*); +extern int TIFFGetMode(TIFF*); +extern int TIFFIsTiled(TIFF*); +extern int TIFFIsByteSwapped(TIFF*); +extern int TIFFIsUpSampled(TIFF*); +extern int TIFFIsMSB2LSB(TIFF*); +extern uint32 TIFFCurrentRow(TIFF*); +extern tdir_t TIFFCurrentDirectory(TIFF*); +extern tdir_t TIFFNumberOfDirectories(TIFF*); +extern uint32 TIFFCurrentDirOffset(TIFF*); +extern tstrip_t TIFFCurrentStrip(TIFF*); +extern ttile_t TIFFCurrentTile(TIFF*); +extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); +extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); +extern int TIFFWriteCheck(TIFF*, int, const char *); +extern int TIFFCreateDirectory(TIFF*); +extern int TIFFLastDirectory(TIFF*); +extern int TIFFSetDirectory(TIFF*, tdir_t); +extern int TIFFSetSubDirectory(TIFF*, uint32); +extern int TIFFUnlinkDirectory(TIFF*, tdir_t); +extern int TIFFSetField(TIFF*, ttag_t, ...); +extern int TIFFVSetField(TIFF*, ttag_t, va_list); +extern int TIFFWriteDirectory(TIFF *); +extern int TIFFRewriteDirectory(TIFF *); +extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int); + +#if defined(c_plusplus) || defined(__cplusplus) +extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); +extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); +extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); +extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); +#else +extern void TIFFPrintDirectory(TIFF*, FILE*, long); +extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); +extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); +extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); +#endif + +extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * ); +extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); +extern int TIFFRGBAImageOK(TIFF*, char [1024]); +extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); +extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); +extern void TIFFRGBAImageEnd(TIFF*, TIFFRGBAImage*); +extern TIFF* TIFFOpen(const char*, const char*, void*, + TIFFmallocHandler, TIFFreallocHandler, TIFFfreeHandler, + TIFFErrorHandler, TIFFErrorHandler); +extern TIFF* TIFFFdOpen(void*, const char*, const char*, void*, + TIFFmallocHandler, TIFFreallocHandler, TIFFfreeHandler, + TIFFErrorHandler, TIFFErrorHandler); +extern TIFF* TIFFClientOpen(const char*, const char*, void*, + TIFFReadWriteProc, TIFFReadWriteProc, + TIFFSeekProc, TIFFCloseProc, + TIFFSizeProc, + TIFFMapFileProc, TIFFUnmapFileProc, void*, + TIFFmallocHandler, TIFFreallocHandler, TIFFfreeHandler, + TIFFErrorHandler, TIFFErrorHandler); +extern const char* TIFFFileName(TIFF*); +extern void TIFFError(const char*, const char*, ...); +extern void TIFFWarning(const char*, const char*, ...); +extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); +extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); +extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); +extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); +extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); +extern ttile_t TIFFNumberOfTiles(TIFF*); +extern tsize_t TIFFReadTile(TIFF*, + tdata_t, uint32, uint32, uint32, tsample_t); +extern tsize_t TIFFWriteTile(TIFF*, + tdata_t, uint32, uint32, uint32, tsample_t); +extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); +extern tstrip_t TIFFNumberOfStrips(TIFF*); +extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); +extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); +extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); +extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); +extern void TIFFSetWriteOffset(TIFF*, toff_t); +extern void TIFFSwabShort(uint16*); +extern void TIFFSwabLong(uint32*); +extern void TIFFSwabDouble(double*); +extern void TIFFSwabArrayOfShort(uint16*, unsigned long); +extern void TIFFSwabArrayOfLong(uint32*, unsigned long); +extern void TIFFSwabArrayOfDouble(double*, unsigned long); +extern void TIFFReverseBits(unsigned char *, unsigned long); +extern const unsigned char* TIFFGetBitRevTable(int); + +#ifdef LOGLUV_PUBLIC +#define U_NEU 0.210526316 +#define V_NEU 0.473684211 +#define UVSCALE 410. +extern double LogL16toY(int); +extern double LogL10toY(int); +extern void XYZtoRGB24(float*, uint8*); +extern int uv_decode(double*, double*, int); +extern void LogLuv24toXYZ(uint32, float*); +extern void LogLuv32toXYZ(uint32, float*); +#if defined(c_plusplus) || defined(__cplusplus) +extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); +extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); +extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); +extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); +extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); +#else +extern int LogL16fromY(double, int); +extern int LogL10fromY(double, int); +extern int uv_encode(double, double, int); +extern uint32 LogLuv24fromXYZ(float*, int); +extern uint32 LogLuv32fromXYZ(float*, int); +#endif +#endif /* LOGLUV_PUBLIC */ +#if defined(__cplusplus) +} +#endif +#endif /* _TIFFIO_ */ diff --git a/src/libs/pdflib/libs/tiff/tiffiop.h b/src/libs/pdflib/libs/tiff/tiffiop.h new file mode 100644 index 0000000000..339552d47f --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tiffiop.h @@ -0,0 +1,279 @@ +/* PDFlib GmbH cvsid: $Id: tiffiop.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef _TIFFIOP_ +#define _TIFFIOP_ +/* + * ``Library-private'' definitions. + */ + +#include "port.h" /* PDFlib GmbH */ +#include "tiffconf.h" + +#include "tiffio.h" +#include "tif_dir.h" + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +/* + * Typedefs for ``method pointers'' used internally. + */ +typedef unsigned char tidataval_t; /* internal image data value type */ +typedef tidataval_t* tidata_t; /* reference to internal image data */ + +typedef void (*TIFFVoidMethod)(TIFF*); +typedef int (*TIFFBoolMethod)(TIFF*); +typedef int (*TIFFPreMethod)(TIFF*, tsample_t); +typedef int (*TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t); +typedef int (*TIFFSeekMethod)(TIFF*, uint32); +typedef void (*TIFFPostMethod)(TIFF*, tidata_t, tsize_t); +typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); +typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); +typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); +typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); +typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); + +struct tiff { + char* tif_name; /* name of open file */ + FILE* tif_fd; /* open file descriptor */ + int tif_mode; /* open mode (O_*) */ + uint32 tif_flags; +#define TIFF_FILLORDER 0x0003 /* natural bit fill order for machine */ +#define TIFF_DIRTYHEADER 0x0004 /* header must be written on close */ +#define TIFF_DIRTYDIRECT 0x0008 /* current directory must be written */ +#define TIFF_BUFFERSETUP 0x0010 /* data buffers setup */ +#define TIFF_CODERSETUP 0x0020 /* encoder/decoder setup done */ +#define TIFF_BEENWRITING 0x0040 /* written 1+ scanlines to file */ +#define TIFF_SWAB 0x0080 /* byte swap file information */ +#define TIFF_NOBITREV 0x0100 /* inhibit bit reversal logic */ +#define TIFF_MYBUFFER 0x0200 /* my raw data buffer; free on close */ +#define TIFF_ISTILED 0x0400 /* file is tile, not strip- based */ +#define TIFF_MAPPED 0x0800 /* file is mapped into memory */ +#define TIFF_POSTENCODE 0x1000 /* need call to postencode routine */ +#define TIFF_INSUBIFD 0x2000 /* currently writing a subifd */ +#define TIFF_UPSAMPLED 0x4000 /* library is doing data up-sampling */ +#define TIFF_STRIPCHOP 0x8000 /* enable strip chopping support */ + toff_t tif_diroff; /* file offset of current directory */ + toff_t tif_nextdiroff; /* file offset of following directory */ + TIFFDirectory tif_dir; /* internal rep of current directory */ + TIFFHeader tif_header; /* file's header block */ + tidata_t tif_clientdir; /* client TIFF directory */ + const int* tif_typeshift; /* data type shift counts */ + const long* tif_typemask; /* data type masks */ + uint32 tif_row; /* current scanline */ + tdir_t tif_curdir; /* current directory (index) */ + tstrip_t tif_curstrip; /* current strip for read/write */ + toff_t tif_curoff; /* current offset for read/write */ + toff_t tif_dataoff; /* current offset for writing dir */ +#if SUBIFD_SUPPORT + uint16 tif_nsubifd; /* remaining subifds to write */ + toff_t tif_subifdoff; /* offset for patching SubIFD link */ +#endif +/* tiling support */ + uint32 tif_col; /* current column (offset by row too) */ + ttile_t tif_curtile; /* current tile for read/write */ + tsize_t tif_tilesize; /* # of bytes in a tile */ +/* compression scheme hooks */ + TIFFBoolMethod tif_setupdecode;/* called once before predecode */ + TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ + TIFFBoolMethod tif_setupencode;/* called once before preencode */ + TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ + TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ + TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ + TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ + TIFFCodeMethod tif_decodestrip;/* strip decoding routine */ + TIFFCodeMethod tif_encodestrip;/* strip encoding routine */ + TIFFCodeMethod tif_decodetile; /* tile decoding routine */ + TIFFCodeMethod tif_encodetile; /* tile encoding routine */ + TIFFVoidMethod tif_close; /* cleanup-on-close routine */ + TIFFSeekMethod tif_seek; /* position within a strip routine */ + TIFFVoidMethod tif_cleanup; /* cleanup state routine */ + TIFFStripMethod tif_defstripsize;/* calculate/constrain strip size */ + TIFFTileMethod tif_deftilesize;/* calculate/constrain tile size */ + tidata_t tif_data; /* compression scheme private data */ +/* input/output buffering */ + tsize_t tif_scanlinesize;/* # of bytes in a scanline */ + tsize_t tif_scanlineskew;/* scanline skew for reading strips */ + tidata_t tif_rawdata; /* raw data buffer */ + tsize_t tif_rawdatasize;/* # of bytes in raw data buffer */ + tidata_t tif_rawcp; /* current spot in raw buffer */ + tsize_t tif_rawcc; /* bytes unread from raw buffer */ +/* memory-mapped file support */ + tidata_t tif_base; /* base of mapped file */ + toff_t tif_size; /* size of mapped file region (bytes) */ + TIFFMapFileProc tif_mapproc; /* map file method */ + TIFFUnmapFileProc tif_unmapproc;/* unmap file method */ +/* input/output callback methods */ + void* tif_clientdata; /* callback parameter */ + TIFFReadWriteProc tif_readproc; /* read method */ + TIFFReadWriteProc tif_writeproc;/* write method */ + TIFFSeekProc tif_seekproc; /* lseek method */ + TIFFCloseProc tif_closeproc; /* close method */ + TIFFSizeProc tif_sizeproc; /* filesize method */ +/* post-decoding support */ + TIFFPostMethod tif_postdecode; /* post decoding routine */ +/* tag support */ + TIFFFieldInfo** tif_fieldinfo; /* sorted table of registered tags */ + int tif_nfields; /* # entries in registered tag table */ + TIFFVSetMethod tif_vsetfield; /* tag set routine */ + TIFFVGetMethod tif_vgetfield; /* tag get routine */ + TIFFPrintMethod tif_printdir; /* directory print routine */ + void* pdflib_opaque; /* for PDFlib memory handling */ + TIFFmallocHandler pdflib_malloc; /* for PDFlib memory handling */ + TIFFreallocHandler pdflib_realloc; /* for PDFlib memory handling */ + TIFFfreeHandler pdflib_free; /* for PDFlib memory handling */ + TIFFErrorHandler pdflib_error; /* for PDFlib */ + TIFFErrorHandler pdflib_warn; /* for PDFlib */ +}; + +#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ + +#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) +#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) +#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) +#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) +#define TIFFReadFile(tif, buf, size) \ + ((*(tif)->tif_readproc)((tif)->tif_clientdata,buf,size)) +#define TIFFWriteFile(tif, buf, size) \ + ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size)) +#define TIFFSeekFile(tif, off, whence) \ + ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)) +#define TIFFCloseFile(tif) \ + ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) +#define TIFFGetFileSize(tif) \ + ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) +#define TIFFMapFileContents(tif, paddr, psize) \ + ((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize)) +#define TIFFUnmapFileContents(tif, addr, size) \ + ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size)) + +/* + * Default Read/Seek/Write definitions. + */ +#ifndef ReadOK +#define ReadOK(tif, buf, size) \ + (TIFFReadFile(tif, (tdata_t) buf, (tsize_t)(size)) == (tsize_t)(size)) +#endif +#ifndef SeekOK +#define SeekOK(tif, off) \ + (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) != (toff_t) -1) +#endif +#ifndef WriteOK +#define WriteOK(tif, buf, size) \ + (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) +#endif + +/* NB: the uint32 casts are to silence certain ANSI-C compilers */ +#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) +#define TIFFroundup(x, y) (TIFFhowmany(x,y)*((uint32)(y))) + +#if defined(__cplusplus) +extern "C" { +#endif +extern int PDFlibEncodeError(TIFF*, tidata_t, tsize_t, tsample_t); +extern int _TIFFgetMode(const char*, const char*); +extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t); +extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t); +extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t); +extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t); +extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t); +extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t); +extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t); +extern int _TIFFNoPreCode (TIFF*, tsample_t); +extern int _TIFFNoSeek(TIFF*, uint32); +extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t); +extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t); +extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t); +extern int TIFFFlushData1(TIFF*); +extern void TIFFFreeDirectory(TIFF*); +extern int TIFFDefaultDirectory(TIFF*); +extern int TIFFSetCompressionScheme(TIFF*, int); +extern int TIFFSetDefaultCompressionState(TIFF*); +extern void _TIFFSetDefaultCompressionState(TIFF*); +extern uint32 _TIFFDefaultStripSize(TIFF*, uint32); +extern void _TIFFDefaultTileSize(TIFF*, uint32*, uint32*); + +extern void _TIFFsetByteArray(TIFF*, void**, void*, long); +extern void _TIFFsetString(TIFF*, char**, char*); +extern void _TIFFsetShortArray(TIFF*, uint16**, uint16*, long); +extern void _TIFFsetLongArray(TIFF*, uint32**, uint32*, long); +extern void _TIFFsetFloatArray(TIFF*, float**, float*, long); +extern void _TIFFsetDoubleArray(TIFF*, double**, double*, long); + +extern void _TIFFprintAscii(FILE*, const char*); +extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); + +GLOBALDATA(TIFFErrorHandler,_TIFFwarningHandler); +GLOBALDATA(TIFFErrorHandler,_TIFFerrorHandler); + +extern int TIFFInitDumpMode(TIFF*, int); +#ifdef PACKBITS_SUPPORT +extern int TIFFInitPackBits(TIFF*, int); +#endif +#ifdef CCITT_SUPPORT +extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); +extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); +#endif +#ifdef THUNDER_SUPPORT +extern int TIFFInitThunderScan(TIFF*, int); +#endif +#ifdef NEXT_SUPPORT +extern int TIFFInitNeXT(TIFF*, int); +#endif +#ifdef LZW_SUPPORT +extern int TIFFInitLZW(TIFF*, int); +#endif +#ifdef OJPEG_SUPPORT +extern int TIFFInitOJPEG(TIFF*, int); +#endif +#ifdef JPEG_SUPPORT +extern int TIFFInitJPEG(TIFF*, int); +#endif +#ifdef JBIG_SUPPORT +extern int TIFFInitJBIG(TIFF*, int); +#endif +#ifdef ZIP_SUPPORT +extern int TIFFInitZIP(TIFF*, int); +#endif +#ifdef PIXARLOG_SUPPORT +extern int TIFFInitPixarLog(TIFF*, int); +#endif +#ifdef LOGLUV_SUPPORT +extern int TIFFInitSGILog(TIFF*, int); +#endif +#ifdef VMS +extern const TIFFCodec _TIFFBuiltinCODECS[]; +#else +extern TIFFCodec _TIFFBuiltinCODECS[]; +#endif + +#if defined(__cplusplus) +} +#endif +#endif /* _TIFFIOP_ */ diff --git a/src/libs/pdflib/libs/tiff/tiffvers.h b/src/libs/pdflib/libs/tiff/tiffvers.h new file mode 100644 index 0000000000..f380309cc6 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/tiffvers.h @@ -0,0 +1,13 @@ +/* PDFlib GmbH cvsid: $Id: tiffvers.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.5.7\n\ +Copyright (c) 1988-1996 Sam Leffler\n\ +Copyright (c) 1991-1996 Silicon Graphics, Inc." +/* + * This define can be used in code that requires + * compilation-related definitions specific to a + * version or versions of the library. Runtime + * version checking should be done based on the + * string returned by TIFFGetVersion. + */ +#define TIFFLIB_VERSION 20011123 diff --git a/src/libs/pdflib/libs/tiff/uvcode.h b/src/libs/pdflib/libs/tiff/uvcode.h new file mode 100644 index 0000000000..29223a2914 --- /dev/null +++ b/src/libs/pdflib/libs/tiff/uvcode.h @@ -0,0 +1,175 @@ +/* PDFlib GmbH cvsid: $Id: uvcode.h,v 1.1 2004/10/06 17:46:51 laplace Exp $ */ + +/* Version 1.0 generated April 7, 1997 by Greg Ward Larson, SGI */ +#define UV_SQSIZ (float)0.003500 +#define UV_NDIVS 16289 +#define UV_VSTART (float)0.016940 +#define UV_NVS 163 +static struct { + float ustart; + short nus, ncum; +} uv_row[UV_NVS] = { + {(float)0.247663, 4, 0}, + {(float)0.243779, 6, 4}, + {(float)0.241684, 7, 10}, + {(float)0.237874, 9, 17}, + {(float)0.235906, 10, 26}, + {(float)0.232153, 12, 36}, + {(float)0.228352, 14, 48}, + {(float)0.226259, 15, 62}, + {(float)0.222371, 17, 77}, + {(float)0.220410, 18, 94}, + {(float)0.214710, 21, 112}, + {(float)0.212714, 22, 133}, + {(float)0.210721, 23, 155}, + {(float)0.204976, 26, 178}, + {(float)0.202986, 27, 204}, + {(float)0.199245, 29, 231}, + {(float)0.195525, 31, 260}, + {(float)0.193560, 32, 291}, + {(float)0.189878, 34, 323}, + {(float)0.186216, 36, 357}, + {(float)0.186216, 36, 393}, + {(float)0.182592, 38, 429}, + {(float)0.179003, 40, 467}, + {(float)0.175466, 42, 507}, + {(float)0.172001, 44, 549}, + {(float)0.172001, 44, 593}, + {(float)0.168612, 46, 637}, + {(float)0.168612, 46, 683}, + {(float)0.163575, 49, 729}, + {(float)0.158642, 52, 778}, + {(float)0.158642, 52, 830}, + {(float)0.158642, 52, 882}, + {(float)0.153815, 55, 934}, + {(float)0.153815, 55, 989}, + {(float)0.149097, 58, 1044}, + {(float)0.149097, 58, 1102}, + {(float)0.142746, 62, 1160}, + {(float)0.142746, 62, 1222}, + {(float)0.142746, 62, 1284}, + {(float)0.138270, 65, 1346}, + {(float)0.138270, 65, 1411}, + {(float)0.138270, 65, 1476}, + {(float)0.132166, 69, 1541}, + {(float)0.132166, 69, 1610}, + {(float)0.126204, 73, 1679}, + {(float)0.126204, 73, 1752}, + {(float)0.126204, 73, 1825}, + {(float)0.120381, 77, 1898}, + {(float)0.120381, 77, 1975}, + {(float)0.120381, 77, 2052}, + {(float)0.120381, 77, 2129}, + {(float)0.112962, 82, 2206}, + {(float)0.112962, 82, 2288}, + {(float)0.112962, 82, 2370}, + {(float)0.107450, 86, 2452}, + {(float)0.107450, 86, 2538}, + {(float)0.107450, 86, 2624}, + {(float)0.107450, 86, 2710}, + {(float)0.100343, 91, 2796}, + {(float)0.100343, 91, 2887}, + {(float)0.100343, 91, 2978}, + {(float)0.095126, 95, 3069}, + {(float)0.095126, 95, 3164}, + {(float)0.095126, 95, 3259}, + {(float)0.095126, 95, 3354}, + {(float)0.088276, 100, 3449}, + {(float)0.088276, 100, 3549}, + {(float)0.088276, 100, 3649}, + {(float)0.088276, 100, 3749}, + {(float)0.081523, 105, 3849}, + {(float)0.081523, 105, 3954}, + {(float)0.081523, 105, 4059}, + {(float)0.081523, 105, 4164}, + {(float)0.074861, 110, 4269}, + {(float)0.074861, 110, 4379}, + {(float)0.074861, 110, 4489}, + {(float)0.074861, 110, 4599}, + {(float)0.068290, 115, 4709}, + {(float)0.068290, 115, 4824}, + {(float)0.068290, 115, 4939}, + {(float)0.068290, 115, 5054}, + {(float)0.063573, 119, 5169}, + {(float)0.063573, 119, 5288}, + {(float)0.063573, 119, 5407}, + {(float)0.063573, 119, 5526}, + {(float)0.057219, 124, 5645}, + {(float)0.057219, 124, 5769}, + {(float)0.057219, 124, 5893}, + {(float)0.057219, 124, 6017}, + {(float)0.050985, 129, 6141}, + {(float)0.050985, 129, 6270}, + {(float)0.050985, 129, 6399}, + {(float)0.050985, 129, 6528}, + {(float)0.050985, 129, 6657}, + {(float)0.044859, 134, 6786}, + {(float)0.044859, 134, 6920}, + {(float)0.044859, 134, 7054}, + {(float)0.044859, 134, 7188}, + {(float)0.040571, 138, 7322}, + {(float)0.040571, 138, 7460}, + {(float)0.040571, 138, 7598}, + {(float)0.040571, 138, 7736}, + {(float)0.036339, 142, 7874}, + {(float)0.036339, 142, 8016}, + {(float)0.036339, 142, 8158}, + {(float)0.036339, 142, 8300}, + {(float)0.032139, 146, 8442}, + {(float)0.032139, 146, 8588}, + {(float)0.032139, 146, 8734}, + {(float)0.032139, 146, 8880}, + {(float)0.027947, 150, 9026}, + {(float)0.027947, 150, 9176}, + {(float)0.027947, 150, 9326}, + {(float)0.023739, 154, 9476}, + {(float)0.023739, 154, 9630}, + {(float)0.023739, 154, 9784}, + {(float)0.023739, 154, 9938}, + {(float)0.019504, 158, 10092}, + {(float)0.019504, 158, 10250}, + {(float)0.019504, 158, 10408}, + {(float)0.016976, 161, 10566}, + {(float)0.016976, 161, 10727}, + {(float)0.016976, 161, 10888}, + {(float)0.016976, 161, 11049}, + {(float)0.012639, 165, 11210}, + {(float)0.012639, 165, 11375}, + {(float)0.012639, 165, 11540}, + {(float)0.009991, 168, 11705}, + {(float)0.009991, 168, 11873}, + {(float)0.009991, 168, 12041}, + {(float)0.009016, 170, 12209}, + {(float)0.009016, 170, 12379}, + {(float)0.009016, 170, 12549}, + {(float)0.006217, 173, 12719}, + {(float)0.006217, 173, 12892}, + {(float)0.005097, 175, 13065}, + {(float)0.005097, 175, 13240}, + {(float)0.005097, 175, 13415}, + {(float)0.003909, 177, 13590}, + {(float)0.003909, 177, 13767}, + {(float)0.002340, 177, 13944}, + {(float)0.002389, 170, 14121}, + {(float)0.001068, 164, 14291}, + {(float)0.001653, 157, 14455}, + {(float)0.000717, 150, 14612}, + {(float)0.001614, 143, 14762}, + {(float)0.000270, 136, 14905}, + {(float)0.000484, 129, 15041}, + {(float)0.001103, 123, 15170}, + {(float)0.001242, 115, 15293}, + {(float)0.001188, 109, 15408}, + {(float)0.001011, 103, 15517}, + {(float)0.000709, 97, 15620}, + {(float)0.000301, 89, 15717}, + {(float)0.002416, 82, 15806}, + {(float)0.003251, 76, 15888}, + {(float)0.003246, 69, 15964}, + {(float)0.004141, 62, 16033}, + {(float)0.005963, 55, 16095}, + {(float)0.008839, 47, 16150}, + {(float)0.010490, 40, 16197}, + {(float)0.016994, 31, 16237}, + {(float)0.023659, 21, 16268}, +}; diff --git a/src/libs/pdflib/progs/Makefile b/src/libs/pdflib/progs/Makefile new file mode 100644 index 0000000000..f33dc23b8c --- /dev/null +++ b/src/libs/pdflib/progs/Makefile @@ -0,0 +1,9 @@ +# Main libs Makefile +# $Id: Makefile,v 1.1 2004/10/06 17:46:52 laplace Exp $ + +include ../config/mkcommon.inc + +MAKEOPT = -i +SUB_DIRS = $(PROGTARGETS) + +include ../config/mksubdirs.inc diff --git a/src/libs/pdflib/progs/pdflib/Makefile b/src/libs/pdflib/progs/pdflib/Makefile new file mode 100644 index 0000000000..e4d51fe84b --- /dev/null +++ b/src/libs/pdflib/progs/pdflib/Makefile @@ -0,0 +1,37 @@ +# Makefile for PDFlib clients +# $Id: Makefile,v 1.1 2004/10/06 17:46:52 laplace Exp $ + +top_builddir = ../.. + +include $(top_builddir)/config/mkcommon.inc + +DEPLIBS = $(PDFLIBLINK) +LIBS = $(DEPLIBS) $(EXTERNALLIBS) +INCLUDES = $(PDFLIBINC) +CFLAGS = $(DEFS) $(DEFINES) $(INCLUDES) +FLAGS = $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) +EXTRA_SOURCES = getopt.c + +# ------------------------------ + +SRC = \ + $(srcdir)/pdfimpose.c \ + $(srcdir)/pdfimage.c \ + $(srcdir)/text2pdf.c + +PROGS = \ + pdfimpose$(EXE) \ + pdfimage$(EXE) \ + text2pdf$(EXE) + +include $(top_builddir)/config/mkprogs.inc + +pdfimpose$(EXE): pdfimpose.c $(DEPLIBS) $(EXTRA_SOURCES) + $(PROGS_BUILD) + +pdfimage$(EXE): pdfimage.c $(DEPLIBS) $(EXTRA_SOURCES) + $(PROGS_BUILD) + +text2pdf$(EXE): text2pdf.c $(DEPLIBS) $(EXTRA_SOURCES) + $(PROGS_BUILD) + diff --git a/src/libs/pdflib/progs/pdflib/getopt.c b/src/libs/pdflib/progs/pdflib/getopt.c new file mode 100644 index 0000000000..13d99c9a84 --- /dev/null +++ b/src/libs/pdflib/progs/pdflib/getopt.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getopt.c 4.13 (Berkeley) 2/23/91"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +/* + * get option letter from argument vector + */ +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt; /* character checked for validity */ +char *optarg; /* argument associated with option */ + +#define BADCH (int)'?' +#define EMSG "" + +int +getopt(int nargc, char *const* nargv, const char *ostr) +{ + static char *place = EMSG; /* option letter processing */ + register char *oli; /* option letter list index */ + char *p; + + if (!*place) { /* update scanning pointer */ + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return(EOF); + } + if (place[1] && *++place == '-') { /* found "--" */ + ++optind; + place = EMSG; + return(EOF); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means EOF. + */ + if (optopt == (int)'-') + return(EOF); + if (!*place) + ++optind; + if (opterr) { + if (!(p = strrchr(*nargv, '/'))) + p = *nargv; + else + ++p; + (void)fprintf(stderr, "%s: illegal option -- %c\n", + p, optopt); + } + return(BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (!(p = strrchr(*nargv, '/'))) + p = *nargv; + else + ++p; + if (opterr) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + p, optopt); + return(BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return(optopt); /* dump back option letter */ +} diff --git a/src/libs/pdflib/progs/pdflib/pdfimage.c b/src/libs/pdflib/progs/pdflib/pdfimage.c new file mode 100644 index 0000000000..2cf9b3a987 --- /dev/null +++ b/src/libs/pdflib/progs/pdflib/pdfimage.c @@ -0,0 +1,165 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdfimage.c,v 1.1 2004/10/06 17:46:52 laplace Exp $ + * + * Convert BMP/PNG/TIFF/GIF/JPEG images to PDF + * + */ + +#include +#include +#include +#include + +#if defined(__CYGWIN32__) +#include +#elif defined(WIN32) +int getopt(int argc, char * const argv[], const char *optstring); +extern char *optarg; +extern int optind; +#elif !defined(WIN32) && !defined(MAC) +#include +#endif + +#ifdef WIN32 +#include +#endif + +#ifdef NeXT +#include /* for getopt(), optind, optarg */ +#endif + +#ifdef __CYGWIN32__ +#include /* for getopt(), optind, optarg */ +#endif + +#include "pdflib.h" + +#if defined WIN32 || defined __DJGPP__ || \ + defined __OS2__ || defined __IBMC__ || defined __IBMCPP__ || \ + defined __POWERPC__ || defined __CFM68K__ || defined __MC68K__ + +#define READMODE "rb" + +#else + +#define READMODE "r" + +#endif /* Mac, Windows, and OS/2 platforms */ + +static void +usage(void) +{ + fprintf(stderr, "pdfimage: convert images to PDF.\n"); + fprintf(stderr, "(C) PDFlib GmbH and Thomas Merz 1997-2004\n"); + fprintf(stderr, "usage: pdfimage [options] imagefile(s)\n"); + fprintf(stderr, "Available options:\n"); + fprintf(stderr, "-o output file (required)\n"); + fprintf(stderr, "-p bookmark page numbering starting from num\n"); + fprintf(stderr, "-r force resolution overriding image settings\n"); + + exit(1); +} + +int +main(int argc, char *argv[]) +{ + char *pdffilename = NULL; + FILE *imagefile; + PDF *p; + int image; + int opt; + int resolution = 0; + int page_numbering = 0; + int current_page = 1; + char optlist[128]; + + while ((opt = getopt(argc, argv, "r:o:p:w")) != -1) + switch (opt) { + case 'o': + pdffilename = optarg; + break; + + case 'p': + page_numbering = 1; + if (optarg) { + current_page = atoi(optarg); + } + break; + + case 'r': + if (!optarg || (resolution = atoi(optarg)) <= 0) { + fprintf(stderr, "Error: non-positive resolution.\n"); + usage(); + } + + case '?': + default: + usage(); + } + + if (optind == argc) { + fprintf(stderr, "Error: no image files given.\n"); + usage(); + } + + if (pdffilename == NULL) { + fprintf(stderr, "Error: no output file given.\n"); + usage(); + } + + p = PDF_new(); + + if (PDF_open_file(p, pdffilename) == -1) { + fprintf(stderr, "Error: cannot open output file %s.\n", pdffilename); + exit(1); + } + + PDF_set_info(p, "Creator", "pdfimage"); + + while (optind++ < argc) { + fprintf(stderr, "Processing image file '%s'...\n", argv[optind-1]); + + image = PDF_load_image(p, "auto", argv[optind-1], 0, ""); + + if (image == -1) { + fprintf(stderr, "Error: %s (skipped).\n", PDF_get_errmsg(p)); + continue; + } + + /* dummy page size, will be adjusted later */ + PDF_begin_page(p, 20, 20); + + /* define outline with filename or page number */ + if (page_numbering) { + char buf[32]; + sprintf(buf, "Page %d", current_page++); + PDF_add_bookmark(p, buf, 0, 0); + } else { + PDF_add_bookmark(p, argv[optind-1], 0, 0); + } + + if (resolution != 0) + sprintf(optlist, "dpi %d", resolution); + else + sprintf(optlist, "adjustpage"); + + PDF_fit_image(p, image, 0.0, 0.0, optlist); + + PDF_end_page(p); + } + + PDF_close(p); + PDF_delete(p); + exit(0); +} diff --git a/src/libs/pdflib/progs/pdflib/pdfimpose.c b/src/libs/pdflib/progs/pdflib/pdfimpose.c new file mode 100644 index 0000000000..16e6b7baab --- /dev/null +++ b/src/libs/pdflib/progs/pdflib/pdfimpose.c @@ -0,0 +1,329 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: pdfimpose.c,v 1.1 2004/10/06 17:46:52 laplace Exp $ + * + * Impose multiple PDF documents on a single sheet, + * or concatenate multiple PDFs (if no -g option is supplied) + * (requires the PDF import library PDI) + * + */ + +#include +#include +#include + +#if defined(__CYGWIN32__) +#include +#elif defined(WIN32) +int getopt(int argc, char * const argv[], const char *optstring); +extern char *optarg; +extern int optind; +#elif !defined(WIN32) && !defined(MAC) +#include +#endif + +#include "pdflib.h" + +/* Array of known page sizes including name, width, and height */ + +typedef struct { const char *name; float width; float height; } PageSize_s; + +PageSize_s PageSizes[] = { + {"a0", 2380.0f, 3368.0f}, + {"a1", 1684.0f, 2380.0f}, + {"a2", 1190.0f, 1684.0f}, + {"a3", 842.0f, 1190.0f}, + {"a4", 595.0f, 842.0f}, + {"a5", 421.0f, 595.0f}, + {"a6", 297.0f, 421.0f}, + {"b5", 501.0f, 709.0f}, + {"letter", 612.0f, 792.0f}, + {"legal", 612.0f, 1008.0f}, + {"ledger", 1224.0f, 792.0f}, + {"p11x17", 792.0f, 1224.0f} +}; + +#define PAGESIZELISTLEN (sizeof(PageSizes)/sizeof(PageSizes[0])) + +static void +usage(void) +{ + fprintf(stderr, + "\npdfimpose: impose multiple PDF documents on a single sheet.\n"); + fprintf(stderr, "(C) PDFlib GmbH and Thomas Merz 2001-2004\n"); + fprintf(stderr, "usage: pdfimpose [options] pdffiles(s)\n\n"); + fprintf(stderr, "Available options:\n"); + fprintf(stderr, "-b print boxes around imposed pages\n"); + fprintf(stderr, + "-g wxh number of columns and rows per sheet (default: 1x1)\n"); + fprintf(stderr, "-l landscape mode\n"); + fprintf(stderr, "-n start each document on a new page\n"); + fprintf(stderr, "-o output file\n"); + fprintf(stderr, "-p page format (a0-a6, letter, legal, etc.)\n"); + fprintf(stderr, "-q quiet mode: do not emit info messages\n"); + fprintf(stderr, "-v PDF output version: 1.3, 1.4, or 1.5\n"); + + exit(1); +} + +int +main(int argc, char *argv[]) +{ + char *pdffilename = NULL; + char *pdfversion = NULL; + PDF *p; + int opt; + int doc, page; + int pageno, docpages; + char *filename; + int quiet = 0, landscape = 0, boxes = 0, newpage = 0; + int cols = 1, rows = 1; + int c = 0, r = 0; + float sheetwidth = 595.0f, sheetheight = 842.0f; + float width, height, scale = 1.0f; + float rowheight = 0.0f, colwidth = 0.0f; + + while ((opt = getopt(argc, argv, "bg:lnp:o:qv:")) != -1) + switch (opt) { + case 'b': + boxes = 1; + break; + + case 'g': + if (sscanf(optarg, "%dx%d", &rows, &cols) != 2) { + fprintf(stderr, "Error: Couldn't parse -g option.\n"); + usage(); + } + if (rows <= 0 || cols <= 0) { + fprintf(stderr, "Bad row or column number.\n"); + usage(); + } + break; + + case 'l': + landscape = 1; + break; + + case 'n': + newpage = 1; + break; + + case 'p': + for(c = 0; c < PAGESIZELISTLEN; c++) + if (!strcmp((const char *) optarg, PageSizes[c].name)) { + sheetheight = PageSizes[c].height; + sheetwidth = PageSizes[c].width; + break; + } + if (c == PAGESIZELISTLEN) { /* page size name not found */ + fprintf(stderr, "Error: Unknown page size '%s'.\n", optarg); + usage(); + } + break; + + case 'o': + pdffilename = optarg; + break; + + case 'v': + pdfversion = optarg; + if (strcmp(pdfversion, "1.3") && strcmp(pdfversion, "1.4") && + strcmp(pdfversion, "1.5")) { + fprintf(stderr, "Error: bad PDF version number '%s'.\n", + optarg); + usage(); + } + + break; + + case 'q': + quiet = 1; + break; + + case '?': + default: + usage(); + } + + if (optind == argc) { + fprintf(stderr, "Error: no PDF files given.\n"); + usage(); + } + + if (pdffilename == NULL) { + fprintf(stderr, "Error: no PDF output file given.\n"); + usage(); + } + + p = PDF_new(); + + if (pdfversion) + PDF_set_parameter(p, "compatibility", pdfversion); + + if (PDF_open_file(p, pdffilename) == -1) { + fprintf(stderr, "Error: %s.\n", PDF_get_errmsg(p)); + exit(1); + } + + PDF_set_info(p, "Creator", "pdfimpose by PDFlib GmbH"); + + PDF_set_parameter(p, "openaction", "fitpage"); + + if (!quiet) + PDF_set_parameter(p, "pdiwarning", "true"); /* report PDI problems */ + + /* multi-page imposition: calculate scaling factor and cell dimensions */ + if (rows != 1 || cols != 1) { + if (landscape) { + height = sheetheight; + sheetheight = sheetwidth; + sheetwidth = height; + } + + if (rows > cols) + scale = 1.0f / rows; + else + scale = 1.0f / cols; + + rowheight = sheetheight * scale; + colwidth = sheetwidth * scale; + } + + /* process all PDF documents */ + while (optind++ < argc) { + filename = argv[optind-1]; + + if (!quiet) + fprintf(stderr, "Imposing '%s'...\n", filename); + + if ((doc = PDF_open_pdi(p, filename, "", 0)) == -1) { + if (quiet) + fprintf(stderr, "Error: %s.\n", PDF_get_errmsg(p)); + continue; + } + + /* query number of pages in the document */ + docpages = (int) PDF_get_pdi_value(p, "/Root/Pages/Count", doc, -1, 0); + + /* single cell only: concatenate, using original page dimensions */ + if (rows == 1 && cols == 1) { + /* open all pages and add to the output file */ + for (pageno = 1; pageno <= docpages ; pageno++) { + + page = PDF_open_pdi_page(p, doc, pageno, ""); + + if (page == -1) { + /* we'll get an exception in verbose mode anyway */ + if (quiet) + fprintf(stderr, + "Couldn't open page %d of PDF file '%s' (%s)\n", + pageno, filename, PDF_get_errmsg(p)); + break; + } + + sheetwidth = PDF_get_pdi_value(p, "width", doc, page, 0); + sheetheight = PDF_get_pdi_value(p, "height", doc, page, 0); + + PDF_begin_page(p, sheetwidth, sheetheight); + + /* define bookmark with filename */ + if (pageno == 1) + PDF_add_bookmark(p, argv[optind-1], 0, 0); + + PDF_place_pdi_page(p, page, 0.0f, 0.0f, 1.0f, 1.0f); + PDF_close_pdi_page(p, page); + PDF_end_page(p); + } + + } else { /* impose multiple pages */ + + if (newpage) + r = c = 0; + + /* open all pages and add to the output file */ + for (pageno = 1; pageno <= docpages ; pageno++) { + + page = PDF_open_pdi_page(p, doc, pageno, ""); + + if (page == -1) { + /* we'll get an exception in verbose mode anyway */ + if (quiet) + fprintf(stderr, + "Couldn't open page %d of PDF file '%s' (%s)\n", + pageno, filename, PDF_get_errmsg(p)); + break; + } + + /* start a new page */ + if (r == 0 && c == 0) + PDF_begin_page(p, sheetwidth, sheetheight); + + /* define bookmark with filename */ + if (pageno == 1) + PDF_add_bookmark(p, argv[optind-1], 0, 0); + + width = PDF_get_pdi_value(p, "width", doc, page, 0); + height = PDF_get_pdi_value(p, "height", doc, page, 0); + + /* + * The save/restore pair is required to get the clipping right, + * and helps PostScript printing manage its memory efficiently. + */ + PDF_save(p); + PDF_rect(p, c * colwidth, sheetheight - (r + 1) * rowheight, + colwidth, rowheight); + PDF_clip(p); + + PDF_setcolor(p, "stroke", "gray", 0.0f, 0.0f, 0.0f, 0.0f); + + /* TODO: adjust scaling factor if page doesn't fit into cell */ + PDF_place_pdi_page(p, page, + c * colwidth, sheetheight - (r + 1) * rowheight, + scale, scale); + + PDF_close_pdi_page(p, page); + + /* only half of the linewidth will be drawn due to clip() */ + if (boxes) { + PDF_setlinewidth(p, 1.0f * scale); + PDF_rect(p, c * colwidth, + sheetheight - (r + 1) * rowheight, + colwidth, rowheight); + PDF_stroke(p); + } + + PDF_restore(p); + + c++; + if (c == cols) { + c = 0; + r++; + } + if (r == rows) { + r = 0; + PDF_end_page(p); + } + } + } + + PDF_close_pdi(p, doc); + } + + /* finish last page if multi-page imposition */ + if ((rows != 1 || cols != 1) && (r != 0 || c != 0)) + PDF_end_page(p); + + PDF_close(p); + PDF_delete(p); + exit(0); +} diff --git a/src/libs/pdflib/progs/pdflib/text2pdf.c b/src/libs/pdflib/progs/pdflib/text2pdf.c new file mode 100644 index 0000000000..e29013a38a --- /dev/null +++ b/src/libs/pdflib/progs/pdflib/text2pdf.c @@ -0,0 +1,233 @@ +/*---------------------------------------------------------------------------* + | PDFlib - A library for generating PDF on the fly | + +---------------------------------------------------------------------------+ + | Copyright (c) 1997-2004 Thomas Merz and PDFlib GmbH. All rights reserved. | + +---------------------------------------------------------------------------+ + | | + | This software is subject to the PDFlib license. It is NOT in the | + | public domain. Extended versions and commercial licenses are | + | available, please check http://www.pdflib.com. | + | | + *---------------------------------------------------------------------------*/ + +/* $Id: text2pdf.c,v 1.1 2004/10/06 17:46:52 laplace Exp $ + * + * Convert text files to PDF + * + */ + +#include +#include +#include + +#if defined(__CYGWIN32__) +#include +#elif defined(WIN32) +int getopt(int argc, char * const argv[], const char *optstring); +extern char *optarg; +extern int optind; +#elif !defined(WIN32) && !defined(MAC) +#include +#endif + + +#ifdef WIN32 +#include +#endif + +#ifdef NeXT +#include /* for getopt(), optind, optarg */ +#endif + +#ifdef __CYGWIN32__ +#include /* for getopt(), optind, optarg */ +#endif + +#if defined WIN32 || defined __DJGPP__ || \ + defined __OS2__ || defined __IBMC__ || defined __IBMCPP__ || \ + defined __POWERPC__ || defined __CFM68K__ || defined __MC68K__ || \ + defined AS400 || defined __ILEC400__ + +#define READMODE "rb" + +#else + +#define READMODE "r" + +#endif /* Mac, Windows, and OS/2 platforms */ + +/* figure out whether or not we're running on an EBCDIC-based machine */ +#define ASCII_A 0x41 +#define PLATFORM_A 'A' +#define EBCDIC_BRACKET 0x4A +#define PLATFORM_BRACKET '[' + +#if (ASCII_A != PLATFORM_A && EBCDIC_BRACKET == PLATFORM_BRACKET) +#define PDFLIB_EBCDIC +#endif + +#include "pdflib.h" + +static void +usage(void) +{ + fprintf(stderr, "text2pdf - convert text files to PDF.\n"); + fprintf(stderr, "(C) PDFlib GmbH and Thomas Merz 1997-2004\n"); + fprintf(stderr, "usage: text2pdf [options] [textfile]\n"); + fprintf(stderr, "Available options:\n"); + fprintf(stderr, + "-e encoding font encoding to use. Common encoding names:\n"); + fprintf(stderr, + " winansi, macroman, ebcdic, or user-defined\n"); + fprintf(stderr, " host = default encoding of this platform\n"); + fprintf(stderr, "-f fontname name of font to use\n"); + fprintf(stderr, "-h height page height in points\n"); + fprintf(stderr, "-m margin margin size in points\n"); + fprintf(stderr, "-o filename PDF output file name\n"); + fprintf(stderr, "-s size font size\n"); + fprintf(stderr, "-w width page width in points\n"); + + exit(1); +} + +#define BUFLEN 512 + +int +main(int argc, char *argv[]) +{ + char buf[BUFLEN], *s; + char *pdffilename = NULL; + FILE *textfile = stdin; + PDF *p; + int opt; + int font; + char *fontname, *encoding; + float fontsize; + float x, y, width = a4_width, height = a4_height, margin = 20; + char ff, nl; + + fontname = "Courier"; + fontsize = 12.0; + encoding = "host"; + nl = '\n'; + ff = '\f'; + + while ((opt = getopt(argc, argv, "e:f:h:m:o:s:w:")) != -1) + switch (opt) { + case 'e': + encoding = optarg; + break; + + case 'f': + fontname = optarg; + break; + + case 'h': + height = atoi(optarg); + if (height < 0) { + fprintf(stderr, "Error: bad page height %f!\n", height); + usage(); + } + break; + + case 'm': + margin = atoi(optarg); + if (margin < 0) { + fprintf(stderr, "Error: bad margin %f!\n", margin); + usage(); + } + break; + + case 'o': + pdffilename = optarg; + break; + + case 's': + fontsize = atoi(optarg); + if (fontsize < 0) { + fprintf(stderr, "Error: bad font size %f!\n", fontsize); + usage(); + } + break; + + case 'w': + width = atoi(optarg); + if (width < 0) { + fprintf(stderr, "Error: bad page width %f!\n", width); + usage(); + } + break; + + case '?': + default: + usage(); + } + + if (!strcmp(encoding, "ebcdic")) { + /* form feed is 0x0C in both ASCII and EBCDIC */ + nl = 0x15; + } + + if (pdffilename == NULL) + usage(); + + if (optind < argc) { + if ((textfile = fopen(argv[optind], READMODE)) == NULL) { + fprintf(stderr, "Error: cannot open input file %s.\n",argv[optind]); + exit(2); + } + } else + textfile = stdin; + + p = PDF_new(); + if (p == NULL) { + fprintf(stderr, "Error: cannot open output file %s.\n", pdffilename); + exit(1); + } + + PDF_open_file(p, pdffilename); + + PDF_set_info(p, "Title", "Converted text"); + PDF_set_info(p, "Creator", "text2pdf"); + + x = margin; + y = height - margin; + + while ((s = fgets(buf, BUFLEN, textfile)) != NULL) { + if (s[0] == ff) { + if (y == height - margin) + PDF_begin_page(p, width, height); + PDF_end_page(p); + y = height - margin; + continue; + } + + if (s[0] != '\0' && s[strlen(s) - 1] == nl) + s[strlen(s) - 1] = '\0'; /* remove newline character */ + + if (y < margin) { /* page break necessary? */ + y = height - margin; + PDF_end_page(p); + } + + if (y == height - margin) { + PDF_begin_page(p, width, height); + font = PDF_findfont(p, fontname, encoding, 0); + PDF_setfont(p, font, fontsize); + PDF_set_text_pos(p, x, y); + y -= fontsize; + } + + PDF_continue_text(p, s); + y -= fontsize; + + } + + if (y != height - margin) + PDF_end_page(p); + + PDF_close(p); + PDF_delete(p); + + exit(0); +}