[libsoup] Add API to get version information



commit 33cf3c6f2530732e85a93d42c153db53844feebb
Author: Martin Robinson <mrobinson igalia com>
Date:   Thu Sep 20 17:02:40 2012 -0700

    Add API to get version information
    
    Expose API to get information about the soup version. This is useful
    because it allows applications to use API without actually depending on
    it completely.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684514

 .gitignore                              |    1 +
 configure.ac                            |   14 +++-
 docs/reference/libsoup-2.4-docs.sgml    |    1 +
 docs/reference/libsoup-2.4-sections.txt |   15 +++
 libsoup/Makefile.am                     |    4 +
 libsoup/soup-version.c                  |  146 +++++++++++++++++++++++++++++++
 libsoup/soup-version.h.in               |   41 +++++++++
 7 files changed, 221 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index c387360..203bd2f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,6 +48,7 @@ libsoup/Soup-2.4.typelib
 libsoup/SoupGNOME-2.4.gir
 libsoup/SoupGNOME-2.4.typelib
 libsoup/tld_data.inc
+libsoup/soup-version.h
 libtool
 ltmain.sh
 m4/gtk-doc.m4
diff --git a/configure.ac b/configure.ac
index a6b2b70..438df9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,8 +2,12 @@ dnl *******************************************
 dnl *** Initialize automake and set version ***
 dnl *******************************************
 
+m4_define([soup_major_version], [2])
+m4_define([soup_minor_version], [41])
+m4_define([soup_micro_version], [0])
+
 AC_PREREQ(2.63)
-AC_INIT([libsoup],[2.41.0],[http://bugzilla.gnome.org/enter_bug.cgi?product=libsoup])
+AC_INIT([libsoup],[soup_major_version.soup_minor_version.soup_micro_version],[http://bugzilla.gnome.org/enter_bug.cgi?product=libsoup])
 AC_CONFIG_SRCDIR([libsoup-2.4.pc.in])
 AC_CONFIG_MACRO_DIR([m4])
 
@@ -12,6 +16,13 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
 
 AC_PROG_MAKE_SET
 
+SOUP_MAJOR_VERSION=soup_major_version
+SOUP_MINOR_VERSION=soup_minor_version
+SOUP_MICRO_VERSION=soup_micro_version
+AC_SUBST(SOUP_MAJOR_VERSION)
+AC_SUBST(SOUP_MINOR_VERSION)
+AC_SUBST(SOUP_MICRO_VERSION)
+
 SOUP_API_VERSION=2.4
 AC_SUBST(SOUP_API_VERSION)
 
@@ -365,6 +376,7 @@ AC_CONFIG_FILES([
 	tests/httpd.conf
 	docs/Makefile
 	docs/reference/Makefile
+	libsoup/soup-version.h
 	])
 AC_OUTPUT
 
diff --git a/docs/reference/libsoup-2.4-docs.sgml b/docs/reference/libsoup-2.4-docs.sgml
index 76aa87e..ae74c01 100644
--- a/docs/reference/libsoup-2.4-docs.sgml
+++ b/docs/reference/libsoup-2.4-docs.sgml
@@ -33,6 +33,7 @@
     <xi:include href="xml/soup-status.xml"/>
     <xi:include href="xml/soup-tld.xml"/>
     <xi:include href="xml/soup-uri.xml"/>
+    <xi:include href="xml/soup-version.xml"/>
   </chapter>
 
   <chapter>
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index 961e416..4c1c60b 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -1202,3 +1202,18 @@ SoupTLDError
 <SUBSECTION Private>
 soup_tld_error_quark
 </SECTION>
+
+<SECTION>
+<FILE>soup-version</FILE>
+<TITLE>Version Information</TITLE>
+soup_get_major_version
+soup_get_minor_version
+soup_get_micro_version
+soup_check_version
+
+<SUBSECTION>
+SOUP_MAJOR_VERSION
+SOUP_MINOR_VERSION
+SOUP_MICRO_VERSION
+SOUP_CHECK_VERSION
+</SECTION>
diff --git a/libsoup/Makefile.am b/libsoup/Makefile.am
index cc99e75..c5f0e40 100644
--- a/libsoup/Makefile.am
+++ b/libsoup/Makefile.am
@@ -72,6 +72,9 @@ libsoupinclude_HEADERS =	\
 	$(soup_headers)		\
 	soup-enum-types.h
 
+nodist_libsoupinclude_HEADERS =	\
+	soup-version.h
+
 lib_LTLIBRARIES = libsoup-2.4.la
 
 libsoup_2_4_la_LDFLAGS =	\
@@ -171,6 +174,7 @@ libsoup_2_4_la_SOURCES =		\
 	soup-tld-private.h		\
 	soup-uri.c			\
 	soup-value-utils.c		\
+	soup-version.c		\
 	soup-xmlrpc.c
 
 # TLD rules
diff --git a/libsoup/soup-version.c b/libsoup/soup-version.c
new file mode 100644
index 0000000..e2ed0bf
--- /dev/null
+++ b/libsoup/soup-version.c
@@ -0,0 +1,146 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * soup-version.c: Version information
+ *
+ * Copyright (C) 2012 Igalia S.L.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "soup-version.h"
+
+/**
+ * SECTION:soup-version
+ * @short_description: Variables and functions to check the libsoup version
+ **/
+
+/**
+ * SOUP_MAJOR_VERSION:
+ *
+ * Like soup_get_major_version(), but from the headers used at
+ * application compile time, rather than from the library linked
+ * against at application run time.
+ *
+ * Since: 2.42
+ */
+
+/**
+ * SOUP_MINOR_VERSION:
+ *
+ * Like soup_get_minor_version(), but from the headers used at
+ * application compile time, rather than from the library linked
+ * against at application run time.
+ *
+ * Since: 2.42
+ */
+
+/**
+ * SOUP_MICRO_VERSION:
+ *
+ * Like soup_get_micro_version(), but from the headers used at
+ * application compile time, rather than from the library linked
+ * against at application run time.
+ *
+ * Since: 2.42
+ */
+
+/**
+ * SOUP_CHECK_VERSION:
+ * @major: major version (e.g. 2 for version 2.42.0)
+ * @minor: minor version (e.g. 42 for version 2.42.0)
+ * @micro: micro version (e.g. 0 for version 2.42.0)
+ *
+ * Returns: %TRUE if the version of the libsoup header files
+ * is the same as or newer than the passed-in version.
+ *
+ * Since: 2.42
+ */
+
+/**
+ * soup_get_major_version:
+ *
+ * Returns the major version number of the libsoup library.
+ * (e.g. in libsoup version 2.42.0 this is 2.)
+ *
+ * This function is in the library, so it represents the libsoup library
+ * your code is running against. Contrast with the #SOUP_MAJOR_VERSION
+ * macro, which represents the major version of the libsoup headers you
+ * have included when compiling your code.
+ *
+ * Returns: the major version number of the libsoup library
+ *
+ * Since: 2.42
+ */
+guint
+soup_get_major_version (void)
+{
+    return SOUP_MAJOR_VERSION;
+}
+
+/**
+ * soup_get_minor_version:
+ *
+ * Returns the minor version number of the libsoup library.
+ * (e.g. in libsoup version 2.42.0 this is 42.)
+ *
+ * This function is in the library, so it represents the libsoup library
+ * your code is running against. Contrast with the #SOUP_MINOR_VERSION
+ * macro, which represents the minor version of the libsoup headers you
+ * have included when compiling your code.
+ *
+ * Returns: the minor version number of the libsoup library
+ *
+ * Since: 2.42
+ */
+guint
+soup_get_minor_version (void)
+{
+    return SOUP_MINOR_VERSION;
+}
+
+/**
+ * soup_get_micro_version:
+ *
+ * Returns the micro version number of the libsoup library.
+ * (e.g. in libsoup version 2.42.0 this is 0.)
+ *
+ * This function is in the library, so it represents the libsoup library
+ * your code is running against. Contrast with the #SOUP_MICRO_VERSION
+ * macro, which represents the micro version of the libsoup headers you
+ * have included when compiling your code.
+ *
+ * Returns: the micro version number of the libsoup library
+ *
+ * Since: 2.42
+ */
+guint
+soup_get_micro_version (void)
+{
+    return SOUP_MICRO_VERSION;
+}
+
+/**
+ * soup_check_version:
+ * @major: the major version to check
+ * @minor: the minor version to check
+ * @micro: the micro version to check
+ *
+ * Like SOUP_CHECK_VERSION, but the check for soup_check_version is
+ * at runtime instead of compile time. This is useful for compiling
+ * against older versions of libsoup, but using features from newer
+ * versions.
+ *
+ * Returns: %TRUE if the version of the libsoup currently loaded
+ * is the same as or newer than the passed-in version.
+ *
+ * Since: 2.42
+ */
+gboolean
+soup_check_version (guint major,
+                    guint minor,
+                    guint micro)
+{
+    return SOUP_CHECK_VERSION (major, minor, micro);
+}
diff --git a/libsoup/soup-version.h.in b/libsoup/soup-version.h.in
new file mode 100644
index 0000000..6332d58
--- /dev/null
+++ b/libsoup/soup-version.h.in
@@ -0,0 +1,41 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * soup-version.h: Version information
+ *
+ * Copyright (C) 2012 Igalia S.L.
+ */
+
+#ifndef SOUP_VERSION_H
+#define SOUP_VERSION_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define SOUP_MAJOR_VERSION (@SOUP_MAJOR_VERSION@)
+#define SOUP_MINOR_VERSION (@SOUP_MINOR_VERSION@)
+#define SOUP_MICRO_VERSION (@SOUP_MICRO_VERSION@)
+
+#define SOUP_CHECK_VERSION(major, minor, micro) \
+    (SOUP_MAJOR_VERSION > (major) || \
+    (SOUP_MAJOR_VERSION == (major) && SOUP_MINOR_VERSION > (minor)) || \
+    (SOUP_MAJOR_VERSION == (major) && SOUP_MINOR_VERSION == (minor) && \
+     SOUP_MICRO_VERSION >= (micro)))
+
+guint
+soup_get_major_version (void);
+
+guint
+soup_get_minor_version (void);
+
+guint
+soup_get_micro_version (void);
+
+gboolean
+soup_check_version     (guint major,
+                        guint minor,
+                        guint micro);
+
+G_END_DECLS
+
+#endif /* SOUP_VERSION_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]