diff options
author | Calvin Morrison <calvin@pobox.com> | 2023-04-05 14:13:39 -0400 |
---|---|---|
committer | Calvin Morrison <calvin@pobox.com> | 2023-04-05 14:13:39 -0400 |
commit | 835e373b3eeaabcd0621ed6798ab500f37982fae (patch) | |
tree | dfa16b0e2e1b4956b38f693220eac4e607802133 /xpdf-qt/xpdf.cc |
Diffstat (limited to 'xpdf-qt/xpdf.cc')
-rw-r--r-- | xpdf-qt/xpdf.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/xpdf-qt/xpdf.cc b/xpdf-qt/xpdf.cc new file mode 100644 index 0000000..63e52d8 --- /dev/null +++ b/xpdf-qt/xpdf.cc @@ -0,0 +1,59 @@ +//======================================================================== +// +// xpdf.cc +// +// Copyright 1996-2105 Glyph & Cog, LLC +// +//======================================================================== + +#include <aconf.h> + +#include "gmem.h" +#include "Object.h" +#include "XpdfApp.h" + +int main(int argc, char *argv[]) { + int exitCode; + + { + // this is inside a block so that the XpdfApp object gets freed + XpdfApp app(argc, argv); + if (app.getNumViewers() > 0) { + exitCode = app.exec(); + } else { + exitCode = 1; + } + } + + Object::memCheck(stderr); + gMemReport(stderr); + + return exitCode; +} + +#ifdef _WIN32 +int CALLBACK WinMain(HINSTANCE hIstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nCmdShow) { + wchar_t **args; + int argc, i, n, ret; + + if (!(args = CommandLineToArgvW(GetCommandLineW(), &argc)) || + argc < 0) { + return -1; + } + char **argv = (char **)gmallocn(argc + 1, sizeof(char *)); + for (i = 0; i < argc; ++i) { + n = WideCharToMultiByte(CP_UTF8, 0, args[i], -1, NULL, 0, NULL, NULL); + argv[i] = (char *)gmalloc(n); + WideCharToMultiByte(CP_UTF8, 0, args[i], -1, argv[i], n, NULL, NULL); + } + argv[argc] = NULL; + LocalFree(args); + ret = main(argc, argv); + for (i = 0; i < argc; ++i) { + gfree(argv[i]); + } + gfree(argv); + return ret; +} +#endif |