summaryrefslogtreecommitdiffstats
path: root/10.patch
blob: b8ade4b62794457ffc7474ecc4438ee322cf7edd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From c788be10e9bd9979b9f8ae0d649b26f6b1cce140 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Thu, 24 Sep 2020 11:01:28 +0200
Subject: [PATCH] display library version in MINFO

---
 ip2location.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/ip2location.c b/ip2location.c
index 7996b57..848bb36 100644
--- a/ip2location.c
+++ b/ip2location.c
@@ -119,9 +119,26 @@ PHP_MSHUTDOWN_FUNCTION(ip2location)
  *  */
 PHP_MINFO_FUNCTION(ip2location)
 {
+	char buf[32];
+	unsigned long ver;
+
 	php_info_print_table_start();
 	php_info_print_table_header(2, "ip2location support", "enabled");
-	php_info_print_table_row(2, "version", PHP_IP2LOCATION_VERSION);
+	php_info_print_table_row(2, "extension version", PHP_IP2LOCATION_VERSION);
+#if API_VERSION_NUMERIC >= 80100
+	ver = IP2Location_api_version_number();
+#else
+	ver = IP2Location_api_version_num();
+#endif
+	snprintf(buf, sizeof(buf), "%d.%d.%d", API_VERSION_MAJOR, API_VERSION_MINOR, API_VERSION_RELEASE);
+	if (API_VERSION_NUMERIC == ver) {
+		php_info_print_table_row(2, "library version", buf);
+	} else {
+		/* display both headers/runtime versions when differ */
+		php_info_print_table_row(2, "library headers version", buf);
+		snprintf(buf, sizeof(buf), "%lu.%lu.%lu", ver / 10000, (ver / 100) % 100, ver % 100);
+		php_info_print_table_row(2, "library runtime version", buf);
+	}
 	php_info_print_table_end();
 }
 /* }}} */