diff --git a/ChangeLog b/ChangeLog index c944b5cd..d35dcae0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,11 @@ * 2.1.rc1: release -2009-10-19 Jay Berkenbilt +2009-10-24 Jay Berkenbilt + + * Provide interfaces for getting qpdf's own version number + +2009-10-19 Jay Berkenbilt * include/qpdf/QPDF.hh (QPDF): getWarnings now returns a list of QPDFExc rather than a list of strings. This way, warnings may be diff --git a/include/qpdf/qpdf-c.h b/include/qpdf/qpdf-c.h index 4b000a24..698d24a7 100644 --- a/include/qpdf/qpdf-c.h +++ b/include/qpdf/qpdf-c.h @@ -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. */ diff --git a/libqpdf/qpdf-c.cc b/libqpdf/qpdf-c.cc index ffb8ad6f..384e0983 100644 --- a/libqpdf/qpdf-c.cc +++ b/libqpdf/qpdf-c.cc @@ -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"); diff --git a/qpdf/qpdf-ctest.c b/qpdf/qpdf-ctest.c index ef839c31..30e7af2f 100644 --- a/qpdf/qpdf-ctest.c +++ b/qpdf/qpdf-ctest.c @@ -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); diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov index 4d4c537a..54f22f1a 100644 --- a/qpdf/qpdf.testcov +++ b/qpdf/qpdf.testcov @@ -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 diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index 6a2fa5de..05e6c7ed 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -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) {