2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 02:49:00 +00:00

add C interface for getting software version

git-svn-id: svn+q:///qpdf/trunk@903 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
Jay Berkenbilt 2009-10-24 13:23:20 +00:00
parent 9cc43c6e44
commit a80d9d176d
6 changed files with 28 additions and 2 deletions

View File

@ -2,7 +2,11 @@
* 2.1.rc1: release
2009-10-19 Jay Berkenbilt <jberkenb@argonst.com>
2009-10-24 Jay Berkenbilt <ejb@ql.org>
* Provide interfaces for getting qpdf's own version number
2009-10-19 Jay Berkenbilt <ejb@ql.org>
* include/qpdf/QPDF.hh (QPDF): getWarnings now returns a list of
QPDFExc rather than a list of strings. This way, warnings may be

View File

@ -92,6 +92,10 @@ extern "C" {
# define QPDF_TRUE 1
# define QPDF_FALSE 0
/* Returns the version of the qpdf software */
QPDF_DLL
char const* qpdf_get_qpdf_version();
/* Returns dynamically allocated qpdf_data pointer; must be freed
* by calling qpdf_cleanup.
*/

View File

@ -91,6 +91,12 @@ static QPDF_ERROR_CODE trap_errors(qpdf_data qpdf, void (*fn)(qpdf_data))
return status;
}
char const* qpdf_get_qpdf_version()
{
QTC::TC("qpdf", "qpdf-c called qpdf_get_qpdf_version");
return QPDF::QPDFVersion().c_str();
}
qpdf_data qpdf_init()
{
QTC::TC("qpdf", "qpdf-c called qpdf_init");

View File

@ -292,6 +292,12 @@ int main(int argc, char* argv[])
{
whoami = argv[0];
}
if ((argc == 2) && (strcmp(argv[1], "--version") == 0))
{
printf("qpdf-ctest version %s\n", qpdf_get_qpdf_version());
return 0;
}
if (argc < 5)
{
fprintf(stderr, "usage: %s n infile password outfile\n", whoami);

View File

@ -173,3 +173,4 @@ QPDF_encryption stream crypt filter 0
QPDF ERR object stream with wrong type 0
QPDF object gone after xref reconstruction 0
qpdf-c called qpdf_has_error 0
qpdf-c called qpdf_get_qpdf_version 0

View File

@ -81,12 +81,17 @@ flush_tiff_cache();
show_ntests();
# ----------
$td->notify("--- Miscellaneous Tests ---");
$n_tests += 15;
$n_tests += 16;
$td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"},
{$td->REGEXP => "qpdf version \\S+\n.*", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("C API: qpdf version",
{$td->COMMAND => "qpdf-ctest --version"},
{$td->REGEXP => "qpdf-ctest version \\S+\n",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
foreach (my $i = 1; $i <= 3; ++$i)
{