diff --git a/.gitignore b/.gitignore index 6d7e84a..9d029fe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ *.log *.o *.so.1 +/.vs +/packages /testpdfio /testpdfio-out.pdf - +/x64 diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..56146d7 --- /dev/null +++ b/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/pdfio-content.c b/pdfio-content.c index 436eebf..ea9d6f7 100644 --- a/pdfio-content.c +++ b/pdfio-content.c @@ -11,10 +11,13 @@ // Include necessary headers... // -#include "pdfio-content.h" #include "pdfio-private.h" +#include "pdfio-content.h" #include "ttf.h" #include +#ifndef M_PI +# define M_PI 3.14159265358979323846264338327950288 +#endif // M_PI // diff --git a/pdfio-private.h b/pdfio-private.h index f2022e0..929b4c8 100644 --- a/pdfio-private.h +++ b/pdfio-private.h @@ -14,10 +14,20 @@ // Include necessary headers... // +# ifdef _WIN32 +/* + * Disable bogus VS warnings/errors... + */ + +# define _CRT_SECURE_NO_WARNINGS +# endif // _WIN32 + # include "pdfio.h" # include +# include # include # include +# include # ifdef _WIN32 # include # include @@ -59,7 +69,6 @@ # define O_TRUNC _O_TRUNC # define O_BINARY _O_BINARY # else // !_WIN32 -# include # include # define O_BINARY 0 # endif // _WIN32 diff --git a/pdfio-stream.c b/pdfio-stream.c index 0b8de57..165ecf4 100644 --- a/pdfio-stream.c +++ b/pdfio-stream.c @@ -706,7 +706,7 @@ pdfioStreamWrite( pbpixel = st->pbpixel; bufptr = (const unsigned char *)buffer; - bufsecond = buffer + pbpixel; + bufsecond = bufptr + pbpixel; while (bytes > 0) { @@ -736,7 +736,7 @@ pdfioStreamWrite( for (remaining = pbline; remaining > 0; remaining --, bufptr ++, sptr ++) { if (bufptr >= bufsecond) - *sptr = *bufptr - bufptr[-pbpixel]; + *sptr = *bufptr - bufptr[-(int)pbpixel]; else *sptr = *bufptr; } @@ -755,7 +755,7 @@ pdfioStreamWrite( for (remaining = pbline; remaining > 0; remaining --, bufptr ++, sptr ++, pptr ++) { if (bufptr >= bufsecond) - *sptr = *bufptr - (bufptr[-pbpixel] + *pptr) / 2; + *sptr = *bufptr - (bufptr[-(int)pbpixel] + *pptr) / 2; else *sptr = *bufptr - *pptr / 2; } @@ -767,7 +767,7 @@ pdfioStreamWrite( for (remaining = pbline; remaining > 0; remaining --, bufptr ++, sptr ++, pptr ++) { if (bufptr >= bufsecond) - *sptr = *bufptr - stream_paeth(bufptr[-pbpixel], *pptr, pptr[-pbpixel]); + *sptr = *bufptr - stream_paeth(bufptr[-(int)pbpixel], *pptr, pptr[-(int)pbpixel]); else *sptr = *bufptr - stream_paeth(0, *pptr, 0); } @@ -939,7 +939,7 @@ stream_read(pdfio_stream_t *st, // I - Stream for (; bufptr < bufsecond; remaining --, sptr ++) *bufptr++ = *sptr; for (; remaining > 0; remaining --, sptr ++, bufptr ++) - *bufptr = *sptr + bufptr[-pbpixel]; + *bufptr = *sptr + bufptr[-(int)pbpixel]; break; case 2 : // Up for (; remaining > 0; remaining --, sptr ++, pptr ++) @@ -949,13 +949,13 @@ stream_read(pdfio_stream_t *st, // I - Stream for (; bufptr < bufsecond; remaining --, sptr ++, pptr ++) *bufptr++ = *sptr + *pptr / 2; for (; remaining > 0; remaining --, sptr ++, pptr ++, bufptr ++) - *bufptr = *sptr + (bufptr[-pbpixel] + *pptr) / 2; + *bufptr = *sptr + (bufptr[-(int)pbpixel] + *pptr) / 2; break; case 4 : // Paeth for (; bufptr < bufsecond; remaining --, sptr ++, pptr ++) *bufptr++ = *sptr + stream_paeth(0, *pptr, 0); for (; remaining > 0; remaining --, sptr ++, pptr ++, bufptr ++) - *bufptr = *sptr + stream_paeth(bufptr[-pbpixel], *pptr, pptr[-pbpixel]); + *bufptr = *sptr + stream_paeth(bufptr[-(int)pbpixel], *pptr, pptr[-(int)pbpixel]); break; default : diff --git a/pdfio-value.c b/pdfio-value.c index 0183804..b97acd1 100644 --- a/pdfio-value.c +++ b/pdfio-value.c @@ -408,7 +408,11 @@ _pdfioValueWrite(pdfio_file_t *pdf, // I - PDF file { struct tm date; // Date values - gmtime_r(&v->value.date, &date); +#ifdef _WIN32 + gmtime_s(&date, &v->value.date); +#else + gmtime_r(&v->value.date, &date); +#endif // _WIN32 return (_pdfioFilePrintf(pdf, "(D:%04d%02d%02d%02d%02d%02dZ)", date.tm_year + 1900, date.tm_mon + 1, date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec)); } diff --git a/pdfio.h b/pdfio.h index b98cc26..d441110 100644 --- a/pdfio.h +++ b/pdfio.h @@ -47,6 +47,10 @@ extern "C" { // Types and constants... // +# ifdef _WIN32 +typedef __int64 ssize_t; // POSIX type not present on Windows... +# endif // _WIN32 + typedef struct _pdfio_array_s pdfio_array_t; // Array of PDF values typedef struct _pdfio_dict_s pdfio_dict_t; diff --git a/pdfio.sln b/pdfio.sln new file mode 100644 index 0000000..78fc260 --- /dev/null +++ b/pdfio.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30413.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pdfio", "pdfio.vcxproj", "{98F2DE9E-2978-4387-AF71-82532BEDB29E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {98F2DE9E-2978-4387-AF71-82532BEDB29E}.Debug|x64.ActiveCfg = Debug|x64 + {98F2DE9E-2978-4387-AF71-82532BEDB29E}.Debug|x64.Build.0 = Debug|x64 + {98F2DE9E-2978-4387-AF71-82532BEDB29E}.Debug|x86.ActiveCfg = Debug|Win32 + {98F2DE9E-2978-4387-AF71-82532BEDB29E}.Debug|x86.Build.0 = Debug|Win32 + {98F2DE9E-2978-4387-AF71-82532BEDB29E}.Release|x64.ActiveCfg = Release|x64 + {98F2DE9E-2978-4387-AF71-82532BEDB29E}.Release|x64.Build.0 = Release|x64 + {98F2DE9E-2978-4387-AF71-82532BEDB29E}.Release|x86.ActiveCfg = Release|Win32 + {98F2DE9E-2978-4387-AF71-82532BEDB29E}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1C37E030-5C42-41DE-B3F6-C137DF5CFA91} + EndGlobalSection +EndGlobal diff --git a/pdfio.vcxproj b/pdfio.vcxproj new file mode 100644 index 0000000..92e93be --- /dev/null +++ b/pdfio.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {98f2de9e-2978-4387-af71-82532bedb29e} + pdfio + 10.0 + pdfio1 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/pdfio.vcxproj.filters b/pdfio.vcxproj.filters new file mode 100644 index 0000000..71e3849 --- /dev/null +++ b/pdfio.vcxproj.filters @@ -0,0 +1,72 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + + \ No newline at end of file diff --git a/pdfio.vcxproj.user b/pdfio.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/pdfio.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ttf.c b/ttf.c index e0bc1fb..3f21154 100644 --- a/ttf.c +++ b/ttf.c @@ -13,12 +13,17 @@ // Include necessary headers... // +#ifdef _WIN32 +# define _CRT_SECURE_NO_WARNINGS +#endif // _WIN32 + #include "ttf.h" #include #include #include #include #include +#include #ifdef _WIN32 # include @@ -61,9 +66,10 @@ # define O_CREAT _O_CREAT # define O_TRUNC _O_TRUNC +typedef __int64 ssize_t; // POSIX type not present on Windows... + #else # include -# include # define O_BINARY 0 #endif // _WIN32 @@ -877,7 +883,7 @@ copy_name(ttf_t *font, // I - Font int chars, // Length of string to copy in characters bpc; // Bytes per character - if ((name->offset + name->length) > font->names.storage_size) + if ((unsigned)(name->offset + name->length) > font->names.storage_size) { TTF_DEBUG("copy_name: offset(%d)+length(%d) > storage_size(%d)\n", name->offset, name->length, font->names.storage_size); continue;