From ae63b95211f32f169af37dc03956f9d23fd6794d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 10 Aug 2005 15:58:25 +0000 Subject: Augment existing CAIRO_VERSION_MAJOR/MINOR/MICRO and CAIRO_VERSION_STRING with CAIRO_VERSION_ENCODE and CAIRO_VERSION. Add functions for run-time access: cairo_version cairo_version_string --- ChangeLog | 11 +++++++++++ src/cairo.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/cairo.h | 16 ++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/ChangeLog b/ChangeLog index d99c2c799..e1db1745f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-08-10 Carl Worth + + * src/cairo.h: + * src/cairo.c: (cairo_version), (cairo_version_string): + Augment existing CAIRO_VERSION_MAJOR/MINOR/MICRO and + CAIRO_VERSION_STRING with CAIRO_VERSION_ENCODE and CAIRO_VERSION. + Add functions for run-time access: + + cairo_version + cairo_version_string + 2005-08-10 Carl Worth From Travis Spencer : diff --git a/src/cairo.c b/src/cairo.c index 4c4b03ebe..bed064f56 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -110,6 +110,48 @@ _cairo_set_error (cairo_t *cr, cairo_status_t status) _cairo_error (status); } +/** + * cairo_version: + * + * Returns the version of the cairo library encoded in a single + * integer as per CAIRO_VERSION_ENCODE. The encoding ensures that + * later versions compare greater than earlier versions. + * + * A run-time comparison to check that cairo's version is greater than + * or equal to version X.Y.Z could be performed as follows: + * + * + * if (cairo_version() >= CAIRO_VERSION_ENCODE(X,Y,Z)) {...} + * + * + * See also cairo_version_string() as well as the compile-time + * equivalents %CAIRO_VERSION and %CAIRO_VERSION_STRING. + * + * Return value: the encoded version. + **/ +int +cairo_version (void) +{ + return CAIRO_VERSION; +} + +/** + * cairo_version_string: + * + * Returns the version of the cairo library as a human-readable string + * of the form "X.Y.Z". + * + * See also cairo_version() as well as the compile-time equivalents + * %CAIRO_VERSION_STRING and %CAIRO_VERSION. + * + * Return value: a string containing the version. + **/ +const char* +cairo_version_string (void) +{ + return CAIRO_VERSION_STRING; +} + /** * cairo_create: * @target: target surface for the context diff --git a/src/cairo.h b/src/cairo.h index 1d871c812..06a6d6a08 100644 --- a/src/cairo.h +++ b/src/cairo.h @@ -42,6 +42,22 @@ CAIRO_BEGIN_DECLS +#define CAIRO_VERSION_ENCODE(major, minor, micro) ( \ + ((major) * 10000) \ + + ((minor) * 100) \ + + ((micro) * 1)) + +#define CAIRO_VERSION CAIRO_VERSION_ENCODE( \ + CAIRO_VERSION_MAJOR, \ + CAIRO_VERSION_MINOR, \ + CAIRO_VERSION_MICRO) + +int +cairo_version (void); + +const char* +cairo_version_string (void); + /** * cairo_bool_t: * -- cgit v1.2.3