summaryrefslogtreecommitdiffstats
path: root/15.patch
blob: ca21ec971af0151090e7eea6d75b6de7906bc7e0 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
From 8a24f22087beca64a579fb4685f7ead92ccb535f Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 30 Oct 2020 10:05:59 +0100
Subject: [PATCH] add ip2location_bin_version from library version 8.3.0

---
 ip2location.c     | 30 ++++++++++++++++++++++++++++--
 php_ip2location.h |  3 +++
 tests/file.phpt   |  2 ++
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/ip2location.c b/ip2location.c
index 198410a..e849e52 100644
--- a/ip2location.c
+++ b/ip2location.c
@@ -76,6 +76,9 @@ static zend_function_entry ip2location_functions_entry[] = {
 	PHP_FE(ip2location_get_all, ip2location_ip_address)
 	PHP_FE(ip2location_close, ip2location_void)
 	PHP_FE(ip2location_delete_shm, ip2location_void)
+#if API_VERSION_NUMERIC >= 80300
+	PHP_FE(ip2location_bin_version, ip2location_void)
+#endif
 #ifdef PHP_FE_END
 	PHP_FE_END
 #else
@@ -805,7 +808,7 @@ PHP_FUNCTION(ip2location_get_all)
  * Returns the record information */
 PHP_FUNCTION(ip2location_close)
 {
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") != SUCCESS) { 
+	if (zend_parse_parameters_none() != SUCCESS) {
 		return;
 	}
 	if (IP2LOCATION_G(ip2location_ptr)) {
@@ -819,7 +822,7 @@ PHP_FUNCTION(ip2location_close)
  * Returns nothing */
 PHP_FUNCTION(ip2location_delete_shm)
 {
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") != SUCCESS) {
+	if (zend_parse_parameters_none() != SUCCESS) {
 		return;
 	}
 #if API_VERSION_NUMERIC >= 80100
@@ -830,6 +833,29 @@ PHP_FUNCTION(ip2location_delete_shm)
 }
 /* }}} */
 
+#if API_VERSION_NUMERIC >= 80300
+/* {{{ ip2location_open_mem()
+ * Returns the version */
+PHP_FUNCTION(ip2location_bin_version)
+{
+	char *version;
+
+	if (zend_parse_parameters_none() != SUCCESS) {
+		return;
+	}
+
+	PHP_IP2LOCATION_DB_CHECK;
+	version  = IP2Location_bin_version(IP2LOCATION_G(ip2location_ptr));
+
+#if PHP_MAJOR_VERSION >= 7
+	RETVAL_STRING(version);
+#else
+	RETVAL_STRING(version, 1);
+#endif
+}
+/* }}} */
+#endif
+
 /*
  * Local variables:
  * tab-width: 4
diff --git a/php_ip2location.h b/php_ip2location.h
index f055009..37ec987 100644
--- a/php_ip2location.h
+++ b/php_ip2location.h
@@ -64,6 +64,9 @@ PHP_FUNCTION(ip2location_get_usagetype);
 PHP_FUNCTION(ip2location_get_all);
 PHP_FUNCTION(ip2location_close);
 PHP_FUNCTION(ip2location_delete_shm);
+#if API_VERSION_NUMERIC >= 80300
+PHP_FUNCTION(ip2location_bin_version);
+#endif
 
 ZEND_BEGIN_MODULE_GLOBALS(ip2location)
         IP2Location *ip2location_ptr;
diff --git a/tests/file.phpt b/tests/file.phpt
index 6b6bc4c..6c9a4f5 100644
--- a/tests/file.phpt
+++ b/tests/file.phpt
@@ -11,6 +11,7 @@ var_dump(ip2location_open(__DIR__ . '/IP-COUNTRY-SAMPLE.BIN'));
 var_dump(ip2location_open_mem(IP2LOCATION_FILE_IO));
 var_dump(ip2location_get_country_short('25.5.10.2'));
 var_dump(ip2location_get_country_long('25.5.10.2'));
+var_dump(ip2location_bin_version());
 var_dump(ip2location_close());
 ?>
 Done
@@ -19,5 +20,6 @@ bool(true)
 bool(true)
 string(2) "UK"
 string(14) "UNITED KINGDOM"
+string(9) "2013-4-11"
 NULL
 Done