mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
cb769c62e5
This comment expands all tabs using an 8-character tab-width. You should ignore this commit when using git blame or use git blame -w. In the early days, I used to use tabs where possible for indentation, since emacs did this automatically. In recent years, I have switched to only using spaces, which means qpdf source code has been a mixture of spaces and tabs. I have avoided cleaning this up because of not wanting gratuitous whitespaces change to cloud the output of git blame, but I changed my mind after discussing with users who view qpdf source code in editors/IDEs that have other tab widths by default and in light of the fact that I am planning to start applying automatic code formatting soon.
60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
#include <qpdf/qpdfjob-c.h>
|
|
|
|
#include <qpdf/QPDFJob.hh>
|
|
#include <qpdf/QUtil.hh>
|
|
#include <qpdf/QPDFUsage.hh>
|
|
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
|
|
int qpdfjob_run_from_argv(char const* const argv[])
|
|
{
|
|
auto whoami_p = QUtil::make_unique_cstr(argv[0]);
|
|
auto whoami = QUtil::getWhoami(whoami_p.get());
|
|
QUtil::setLineBuf(stdout);
|
|
|
|
QPDFJob j;
|
|
try
|
|
{
|
|
j.initializeFromArgv(argv);
|
|
j.run();
|
|
}
|
|
catch (std::exception& e)
|
|
{
|
|
std::cerr << whoami << ": " << e.what() << std::endl;
|
|
return QPDFJob::EXIT_ERROR;
|
|
}
|
|
return j.getExitCode();
|
|
}
|
|
|
|
#ifndef QPDF_NO_WCHAR_T
|
|
int qpdfjob_run_from_wide_argv(wchar_t const* const argv[])
|
|
{
|
|
int argc = 0;
|
|
for (auto k = argv; *k; ++k)
|
|
{
|
|
++argc;
|
|
}
|
|
return QUtil::call_main_from_wmain(
|
|
argc, argv, [](int, char const* const new_argv[]) {
|
|
return qpdfjob_run_from_argv(new_argv);
|
|
});
|
|
}
|
|
#endif // QPDF_NO_WCHAR_T
|
|
|
|
int qpdfjob_run_from_json(char const* json)
|
|
{
|
|
QPDFJob j;
|
|
try
|
|
{
|
|
j.initializeFromJson(json);
|
|
j.run();
|
|
}
|
|
catch (std::exception& e)
|
|
{
|
|
std::cerr << "qpdfjob json: " << e.what() << std::endl;
|
|
return QPDFJob::EXIT_ERROR;
|
|
}
|
|
return j.getExitCode();
|
|
}
|