Commit b856379370809cca68cb97b737284ade2c44765c

Authored by Jay Berkenbilt
1 parent 92c94e7d

Portability issues: off_t, unlink

New header qpdf/Types.h attempts to make sure size_t and off_t are
defined on any platform and in a way that would work with large file
support.  Additionally, missing header files are included to get
unlink.
examples/pdf-mod-info.cc
@@ -8,6 +8,13 @@ @@ -8,6 +8,13 @@
8 #include <iostream> 8 #include <iostream>
9 #include <string.h> 9 #include <string.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
  11 +#ifdef _WIN32
  12 +#include <Windows.h>
  13 +#include <direct.h>
  14 +#include <io.h>
  15 +#else
  16 +#include <unistd.h>
  17 +#endif
11 18
12 static char const* version = "1.1"; 19 static char const* version = "1.1";
13 static char const* whoami = 0; 20 static char const* whoami = 0;
include/qpdf/QPDF.hh
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 #include <iostream> 15 #include <iostream>
16 16
17 #include <qpdf/DLL.h> 17 #include <qpdf/DLL.h>
  18 +#include <qpdf/Types.h>
18 19
19 #include <qpdf/QPDFXRefEntry.hh> 20 #include <qpdf/QPDFXRefEntry.hh>
20 #include <qpdf/QPDFObjectHandle.hh> 21 #include <qpdf/QPDFObjectHandle.hh>
include/qpdf/QPDFExc.hh
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 10
11 #include <qpdf/DLL.h> 11 #include <qpdf/DLL.h>
12 #include <qpdf/Constants.h> 12 #include <qpdf/Constants.h>
  13 +#include <qpdf/Types.h>
13 #include <stdexcept> 14 #include <stdexcept>
14 15
15 class QPDFExc: public std::runtime_error 16 class QPDFExc: public std::runtime_error
include/qpdf/QPDFObjectHandle.hh
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 #include <map> 14 #include <map>
15 15
16 #include <qpdf/DLL.h> 16 #include <qpdf/DLL.h>
  17 +#include <qpdf/Types.h>
17 18
18 #include <qpdf/PointerHolder.hh> 19 #include <qpdf/PointerHolder.hh>
19 #include <qpdf/Buffer.hh> 20 #include <qpdf/Buffer.hh>
include/qpdf/QPDFXRefEntry.hh
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 #define __QPDFXREFENTRY_HH__ 9 #define __QPDFXREFENTRY_HH__
10 10
11 #include <qpdf/DLL.h> 11 #include <qpdf/DLL.h>
  12 +#include <qpdf/Types.h>
12 13
13 class QPDFXRefEntry 14 class QPDFXRefEntry
14 { 15 {
include/qpdf/Types.h 0 → 100644
  1 +#ifndef __QPDFTYPES_H__
  2 +#define __QPDFTYPES_H__
  3 +
  4 +/* Attempt to provide off_t and size_t on any recent platform. To
  5 + * make cross compilation easier and to be more portable across
  6 + * platforms, QPDF avoids having any public header files use the
  7 + * results of autoconf testing, so we have to handle this ourselves in
  8 + * a static way.
  9 + */
  10 +
  11 +#define _FILE_OFFSET_BITS 64
  12 +#include <sys/types.h>
  13 +#include <stdio.h>
  14 +#include <string.h>
  15 +
  16 +#endif /* __QPDFTYPES_H__ */