diff options
author | Carl Worth <cworth@cworth.org> | 2005-08-10 15:58:25 +0000 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2005-08-10 15:58:25 +0000 |
commit | ae63b95211f32f169af37dc03956f9d23fd6794d (patch) | |
tree | 0d3ac4b90b70052f565ee97839f3996522119eab | |
parent | bdd8cbddeedec584fc859c5c092ce67c3a1830eb (diff) |
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
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | src/cairo.c | 42 | ||||
-rw-r--r-- | src/cairo.h | 16 |
3 files changed, 69 insertions, 0 deletions
@@ -1,5 +1,16 @@ 2005-08-10 Carl Worth <cworth@cworth.org> + * 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 <cworth@cworth.org> + From Travis Spencer <tspencer@cs.pdx.edu>: * src/cairo-xcb-surface.c: diff --git a/src/cairo.c b/src/cairo.c index 4c4b03ebe..bed064f56 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -111,6 +111,48 @@ _cairo_set_error (cairo_t *cr, cairo_status_t 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: + * + * <informalexample><programlisting> + * if (cairo_version() >= CAIRO_VERSION_ENCODE(X,Y,Z)) {...} + * </programlisting></informalexample> + * + * 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: * |