mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2026-04-09 13:32:31 +02:00
Compare commits
9 Commits
d03e5ee5d9
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a81732f3b | ||
|
|
96840e97c5 | ||
|
|
d6e4570c2e | ||
|
|
73e3805aea | ||
|
|
d4c3e5ac13 | ||
|
|
7d43cabbe0 | ||
|
|
baa9fca941 | ||
|
|
d9444880c5 | ||
|
|
15f197d030 |
@@ -9,6 +9,7 @@ v1.7.0 - YYYY-MM-DD
|
||||
- Added support for basic compound stream filters for ASCII85Decode support
|
||||
(Issue #11)
|
||||
- Added support for LZWDecode filters (Issue #11)
|
||||
- Added support for Unicode filenames on Windows (Issue #18)
|
||||
- Added support for writing object streams (Issue #101)
|
||||
- Added support for GIF files (Issue #145)
|
||||
- Added support for WebP files (Issue #144)
|
||||
@@ -17,7 +18,7 @@ v1.7.0 - YYYY-MM-DD
|
||||
- Fixed a buffer overflow in the (still not enabled) AES-256 code.
|
||||
|
||||
|
||||
v1.6.2 - YYYY-MM-DD
|
||||
v1.6.2 - 2026-02-15
|
||||
-------------------
|
||||
|
||||
- Increased the maximum length of a single string to 128k (Issue #146)
|
||||
@@ -28,6 +29,7 @@ v1.6.2 - YYYY-MM-DD
|
||||
- Fixed xref reconstruction for objects lacking a `Type` value.
|
||||
- Fixed `pdfioPageOpenStream` for indirect `Contents` arrays.
|
||||
- Fixed an error propagation bug when reading too-long values (Issue #146)
|
||||
- Fixed a bug when converting Unicode characters above plane 0 (issue #159)
|
||||
- Fixed a Clang warning.
|
||||
|
||||
|
||||
|
||||
@@ -235,6 +235,7 @@ pdfio1.def: $(LIBOBJS) Makefile
|
||||
echo "LIBRARY pdfio1" >$@
|
||||
echo "VERSION $(PDFIO_VERSION_MAJOR).$(PDFIO_VERSION_MINOR)" >>$@
|
||||
echo "EXPORTS" >>$@
|
||||
echo "_pdfio_win32_open" >>$@
|
||||
nm $(LIBOBJS) 2>/dev/null | grep "T _" | awk '{print $$3}' | \
|
||||
grep -v '^_ttf' | sed -e '1,$$s/^_//' | sort >>$@
|
||||
|
||||
|
||||
@@ -1885,7 +1885,7 @@ pdfioFileCreateFontObjFromFile(
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0)
|
||||
if ((fd = open(filename, O_RDONLY | O_BINARY, 0)) < 0)
|
||||
{
|
||||
_pdfioFileError(pdf, "Unable to open font file '%s': %s", filename, strerror(errno));
|
||||
return (NULL);
|
||||
@@ -2021,7 +2021,7 @@ pdfioFileCreateICCObjFromFile(
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0)
|
||||
if ((fd = open(filename, O_RDONLY | O_BINARY, 0)) < 0)
|
||||
{
|
||||
_pdfioFileError(pdf, "Unable to open ICC profile '%s': %s", filename, strerror(errno));
|
||||
return (NULL);
|
||||
@@ -2180,7 +2180,7 @@ pdfioFileCreateImageObjFromFile(
|
||||
return (NULL);
|
||||
|
||||
// Try opening the file...
|
||||
if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0)
|
||||
if ((fd = open(filename, O_RDONLY | O_BINARY, 0)) < 0)
|
||||
{
|
||||
_pdfioFileError(pdf, "Unable to open image file '%s': %s", filename, strerror(errno));
|
||||
return (NULL);
|
||||
|
||||
84
pdfio-file.c
84
pdfio-file.c
@@ -1166,7 +1166,7 @@ pdfioFileOpen(
|
||||
pdf->permissions = PDFIO_PERMISSION_ALL;
|
||||
|
||||
// Open the file...
|
||||
if ((pdf->fd = open(filename, O_RDONLY | O_BINARY)) < 0)
|
||||
if ((pdf->fd = open(filename, O_RDONLY | O_BINARY, 0)) < 0)
|
||||
{
|
||||
_pdfioFileError(pdf, "Unable to open file - %s", strerror(errno));
|
||||
free(pdf->filename);
|
||||
@@ -1414,8 +1414,88 @@ pdfioFileSetTitle(pdfio_file_t *pdf, // I - PDF file
|
||||
}
|
||||
|
||||
|
||||
#if _WIN32
|
||||
//
|
||||
// '_pdfioObjAdd()' - Add an object to a file.
|
||||
// '_pdfio_win32_open()' - Open or create a file.
|
||||
//
|
||||
// This function handles mapping of UTF-8 filenames to UTF-16 on Windows.
|
||||
//
|
||||
|
||||
int // O - File descriptor or -1 on error
|
||||
_pdfio_win32_open(const char *filename, // I - UTF-8 filename
|
||||
int oflag, // I - Open flags
|
||||
int mode) // I - File permissions
|
||||
{
|
||||
wchar_t utf16name[1024], // UTF-16 filename
|
||||
*utf16ptr; // Pointer into UTF-16 filename
|
||||
int unich; // Unicode character
|
||||
|
||||
|
||||
// Convert the UTF-8 string to UTF-16...
|
||||
utf16ptr = utf16name;
|
||||
while (*filename && utf16ptr < (utf16name + sizeof(utf16name) / sizeof(utf16name[0]) - 2))
|
||||
{
|
||||
if ((unich = *filename++) & 0x80)
|
||||
{
|
||||
if ((unich & 0xe0) == 0xc0 && (*filename & 0xc0) == 0x80)
|
||||
{
|
||||
// 2-byte UTF-8
|
||||
unich = ((unich & 0x1f) << 6) | (*filename & 0x3f);
|
||||
filename ++;
|
||||
}
|
||||
else if ((unich & 0xf0) == 0xe0 && (*filename & 0xc0) == 0x80 && (filename[1] & 0xc0) == 0x80)
|
||||
{
|
||||
// 3-byte UTF-8
|
||||
unich = ((unich & 0x0f) << 12) | ((*filename & 0x3f) << 6) | (filename[1] & 0x3f);
|
||||
filename += 2;
|
||||
}
|
||||
else if ((unich & 0xf8) == 0xf0 && (*filename & 0xc0) == 0x80 && (filename[1] & 0xc0) == 0x80 && (filename[2] & 0xc0) == 0x80)
|
||||
{
|
||||
// 4-byte UTF-8
|
||||
unich = ((unich & 0x07) << 18) | ((*filename & 0x3f) << 12) | ((filename[1] & 0x3f) << 6) | (filename[2] & 0x3f);
|
||||
filename += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid UTF-8 char...
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the unicode character...
|
||||
if (unich > 0xffff)
|
||||
{
|
||||
// Two-word sequence...
|
||||
*utf16ptr++ = 0xd800 | ((unich >> 10) & 0x03ff);
|
||||
*utf16ptr++ = 0xdc00 | (unich & 0x03ff);
|
||||
}
|
||||
else
|
||||
{
|
||||
// One-word...
|
||||
*utf16ptr++ = unich;
|
||||
}
|
||||
}
|
||||
|
||||
*utf16ptr = '\0';
|
||||
|
||||
if (*filename)
|
||||
{
|
||||
// Filename too long...
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Pass on to _wopen...
|
||||
return (_wopen(utf16name, oflag, mode));
|
||||
}
|
||||
}
|
||||
#endif // WIN32
|
||||
|
||||
|
||||
//
|
||||
// 'add_obj()' - Add an object to a file.
|
||||
//
|
||||
|
||||
static pdfio_obj_t * // O - Object
|
||||
|
||||
@@ -126,10 +126,10 @@ pdfioPageGetBoolean(pdfio_obj_t *page, // I - Page object
|
||||
// Dictionary value
|
||||
|
||||
|
||||
if (v && v->type == PDFIO_VALTYPE_ARRAY)
|
||||
if (v && v->type == PDFIO_VALTYPE_BOOLEAN)
|
||||
return (v->value.boolean);
|
||||
else
|
||||
return (NULL);
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
# define fileno _fileno
|
||||
# define lseek(f,o,w) (off_t)_lseek((f),(long)(o),(w))
|
||||
# define mkdir(d,p) _mkdir(d)
|
||||
# define open _open
|
||||
# define open _pdfio_win32_open
|
||||
# define read(f,b,s) _read((f),(b),(unsigned)(s))
|
||||
# define rmdir _rmdir
|
||||
# define snprintf _snprintf
|
||||
@@ -412,6 +412,7 @@ extern size_t _pdfio_strlcpy(char *dst, const char *src, size_t dstsize) _PDFIO
|
||||
extern double _pdfio_strtod(pdfio_file_t *pdf, const char *s) _PDFIO_INTERNAL;
|
||||
extern void _pdfio_utf16cpy(char *dst, const unsigned char *src, size_t srclen, size_t dstsize) _PDFIO_INTERNAL;
|
||||
extern ssize_t _pdfio_vsnprintf(pdfio_file_t *pdf, char *buffer, size_t bufsize, const char *format, va_list ap) _PDFIO_INTERNAL;
|
||||
extern int _pdfio_win32_open(const char *filename, int oflag, int mode) _PDFIO_INTERNAL;
|
||||
|
||||
extern bool _pdfioArrayDecrypt(pdfio_file_t *pdf, pdfio_obj_t *obj, pdfio_array_t *a, size_t depth) _PDFIO_INTERNAL;
|
||||
extern void _pdfioArrayDebug(pdfio_array_t *a, FILE *fp) _PDFIO_INTERNAL;
|
||||
|
||||
@@ -229,7 +229,7 @@ _pdfio_utf16cpy(
|
||||
else
|
||||
{
|
||||
// 4-byte UTF-8
|
||||
*dstptr++ = (char)(0xe0 | (ch >> 18));
|
||||
*dstptr++ = (char)(0xf0 | (ch >> 18));
|
||||
*dstptr++ = (char)(0x80 | ((ch >> 12) & 0x3f));
|
||||
*dstptr++ = (char)(0x80 | ((ch >> 6) & 0x3f));
|
||||
*dstptr++ = (char)(0x80 | (ch & 0x3f));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
LIBRARY pdfio1
|
||||
VERSION 1.7
|
||||
EXPORTS
|
||||
_pdfio_win32_open
|
||||
_pdfio_strlcpy
|
||||
_pdfio_strtod
|
||||
_pdfio_utf16cpy
|
||||
@@ -64,6 +65,7 @@ _pdfioStreamOpen
|
||||
_pdfioStringAllocBuffer
|
||||
_pdfioStringFreeBuffer
|
||||
_pdfioStringIsAllocated
|
||||
_pdfioStringPrintf
|
||||
_pdfioTokenClear
|
||||
_pdfioTokenFlush
|
||||
_pdfioTokenGet
|
||||
|
||||
Reference in New Issue
Block a user