summaryrefslogtreecommitdiff
path: root/src/gd_version.c
diff options
context:
space:
mode:
authorChris Reuter <chris@blit.ca>2013-11-04 17:11:33 -0500
committerChris Reuter <chris@blit.ca>2013-11-07 19:44:45 -0500
commit4378b8ded4004249ad13e24873c47b0627a6a1bd (patch)
treee196944185c42e2f8c0f8bad246569bde4622306 /src/gd_version.c
parent38845577002f0af0d538e78e0ff44de82d6e28f2 (diff)
downloadlibgd-4378b8ded4004249ad13e24873c47b0627a6a1bd.tar.gz
gd.h now holds the canonical version number.
Up to now, the version numbers were defined in configure.ac and put into gd.h by generating it from gd.h.in, replacing the values of several C macros. This violates the DRY principle, won't work on a dumb build system, confuses some dev tools and is just a huge headache in general. This change makes gd.h (no longer generated) the home of the version number and provides a script (config/getver.pl) which can extract the requested version components from the header file. configure.ac now gets the version number from gd.h instead of vice versa. In addition, there are now C functions that return the values of the version macros. This is for the benefit of non-C code using the library without access to the header file. It also provides a way to get the version number of the library currently linked rather than the header the program was compiled against. (This could change if the shared library is updated without recompiling the program using it.)
Diffstat (limited to 'src/gd_version.c')
-rw-r--r--src/gd_version.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/gd_version.c b/src/gd_version.c
new file mode 100644
index 0000000..222d428
--- /dev/null
+++ b/src/gd_version.c
@@ -0,0 +1,33 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gd.h"
+
+
+/* These functions return the version information. We use functions
+ * so that changes in the shared library will automatically be
+ * reflected in executables using it without recompiling them. */
+
+BGD_DECLARE(int) gdMajorVersion()
+{
+ return GD_MAJOR_VERSION;
+}
+
+BGD_DECLARE(int) gdMinorVersion()
+{
+ return GD_MINOR_VERSION;
+}
+
+BGD_DECLARE(int) gdReleaseVersion()
+{
+ return GD_RELEASE_VERSION;
+}
+
+BGD_DECLARE(const char *) gdExtraVersion() {
+ return GD_EXTRA_VERSION;
+}
+
+BGD_DECLARE(const char *) gdVersionString() {
+ return GD_VERSION_STRING;
+}