|
Lines 1-6
Link Here
|
| 1 |
--- pHash.cpp.orig 2013-04-23 18:54:02 UTC |
1 |
--- pHash.cpp.orig 2013-04-23 18:54:02 UTC |
| 2 |
+++ pHash.cpp |
2 |
+++ pHash.cpp |
| 3 |
@@ -36,12 +36,14 @@ struct ph_text_hash |
3 |
@@ -36,17 +36,23 @@ struct ph_text_hash |
| 4 |
|
4 |
|
| 5 |
/* {{{ phpinfo logo definitions */ |
5 |
/* {{{ phpinfo logo definitions */ |
| 6 |
|
6 |
|
|
Lines 15-21
Link Here
|
| 15 |
/* }}} */ |
15 |
/* }}} */ |
| 16 |
|
16 |
|
| 17 |
/* {{{ Resource destructors */ |
17 |
/* {{{ Resource destructors */ |
| 18 |
@@ -145,7 +147,9 @@ ZEND_GET_MODULE(pHash) |
18 |
int le_ph_video_hash; |
|
|
19 |
+#if PHP_VERSION_ID >= 70000 |
| 20 |
+extern "C" void ph_video_hash_dtor(zend_resource *rsrc TSRMLS_DC) |
| 21 |
+#else |
| 22 |
extern "C" void ph_video_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) |
| 23 |
+#endif |
| 24 |
{ |
| 25 |
ph_video_hash * resource = (ph_video_hash *)(rsrc->ptr); |
| 26 |
|
| 27 |
@@ -58,7 +64,11 @@ extern "C" void ph_video_hash_dtor(zend_ |
| 28 |
} |
| 29 |
|
| 30 |
int le_ph_image_hash; |
| 31 |
+#if PHP_VERSION_ID >= 70000 |
| 32 |
+extern "C" void ph_image_hash_dtor(zend_resource *rsrc TSRMLS_DC) |
| 33 |
+#else |
| 34 |
extern "C" void ph_image_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) |
| 35 |
+#endif |
| 36 |
{ |
| 37 |
ulong64 * resource = (ulong64 *)(rsrc->ptr); |
| 38 |
|
| 39 |
@@ -67,7 +77,11 @@ extern "C" void ph_image_hash_dtor(zend_ |
| 40 |
} |
| 41 |
|
| 42 |
int le_ph_audio_hash; |
| 43 |
+#if PHP_VERSION_ID >= 70000 |
| 44 |
+extern "C" void ph_audio_hash_dtor(zend_resource *rsrc TSRMLS_DC) |
| 45 |
+#else |
| 46 |
extern "C" void ph_audio_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) |
| 47 |
+#endif |
| 48 |
{ |
| 49 |
ph_audio_hash * resource = (ph_audio_hash *)(rsrc->ptr); |
| 50 |
|
| 51 |
@@ -79,7 +93,11 @@ extern "C" void ph_audio_hash_dtor(zend_ |
| 52 |
} |
| 53 |
|
| 54 |
int le_ph_txt_hash; |
| 55 |
+#if PHP_VERSION_ID >= 70000 |
| 56 |
+extern "C" void ph_txt_hash_dtor(zend_resource *rsrc TSRMLS_DC) |
| 57 |
+#else |
| 58 |
extern "C" void ph_txt_hash_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) |
| 59 |
+#endif |
| 60 |
{ |
| 61 |
ph_text_hash * resource = (ph_text_hash *)(rsrc->ptr); |
| 62 |
|
| 63 |
@@ -145,7 +163,9 @@ ZEND_GET_MODULE(pHash) |
| 19 |
/* {{{ PHP_MINIT_FUNCTION */ |
64 |
/* {{{ PHP_MINIT_FUNCTION */ |
| 20 |
PHP_MINIT_FUNCTION(pHash) |
65 |
PHP_MINIT_FUNCTION(pHash) |
| 21 |
{ |
66 |
{ |
|
Lines 25-31
Link Here
|
| 25 |
le_ph_video_hash = zend_register_list_destructors_ex(ph_video_hash_dtor, |
70 |
le_ph_video_hash = zend_register_list_destructors_ex(ph_video_hash_dtor, |
| 26 |
NULL, "ph_video_hash", module_number); |
71 |
NULL, "ph_video_hash", module_number); |
| 27 |
le_ph_image_hash = zend_register_list_destructors_ex(ph_image_hash_dtor, |
72 |
le_ph_image_hash = zend_register_list_destructors_ex(ph_image_hash_dtor, |
| 28 |
@@ -165,7 +169,9 @@ PHP_MINIT_FUNCTION(pHash) |
73 |
@@ -165,7 +185,9 @@ PHP_MINIT_FUNCTION(pHash) |
| 29 |
/* {{{ PHP_MSHUTDOWN_FUNCTION */ |
74 |
/* {{{ PHP_MSHUTDOWN_FUNCTION */ |
| 30 |
PHP_MSHUTDOWN_FUNCTION(pHash) |
75 |
PHP_MSHUTDOWN_FUNCTION(pHash) |
| 31 |
{ |
76 |
{ |
|
Lines 35-41
Link Here
|
| 35 |
|
80 |
|
| 36 |
/* add your stuff here */ |
81 |
/* add your stuff here */ |
| 37 |
|
82 |
|
| 38 |
@@ -203,7 +209,9 @@ PHP_MINFO_FUNCTION(pHash) |
83 |
@@ -203,7 +225,9 @@ PHP_MINFO_FUNCTION(pHash) |
| 39 |
if (SG(request_info).request_uri) { |
84 |
if (SG(request_info).request_uri) { |
| 40 |
php_printf("%s", (SG(request_info).request_uri)); |
85 |
php_printf("%s", (SG(request_info).request_uri)); |
| 41 |
} |
86 |
} |
|
Lines 45-47
Link Here
|
| 45 |
php_printf("' align='right' alt='image' border='0'>\n"); |
90 |
php_printf("' align='right' alt='image' border='0'>\n"); |
| 46 |
|
91 |
|
| 47 |
php_printf("pHash\n"); |
92 |
php_printf("pHash\n"); |
|
|
93 |
@@ -225,10 +249,12 @@ PHP_MINFO_FUNCTION(pHash) |
| 94 |
PHP_FUNCTION(ph_dct_videohash) |
| 95 |
{ |
| 96 |
ph_video_hash * return_res; |
| 97 |
+#if PHP_VERSION_ID < 70000 |
| 98 |
long return_res_id = -1; |
| 99 |
+#endif |
| 100 |
|
| 101 |
const char * file = NULL; |
| 102 |
- int file_len = 0; |
| 103 |
+ SIZETorINT file_len = 0; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
@@ -249,7 +275,11 @@ PHP_FUNCTION(ph_dct_videohash) |
| 108 |
else |
| 109 |
RETURN_FALSE; |
| 110 |
|
| 111 |
+#if PHP_VERSION_ID >= 70000 |
| 112 |
+ RETURN_RES(zend_register_resource(return_res, le_ph_video_hash)); |
| 113 |
+#else |
| 114 |
return_res_id = ZEND_REGISTER_RESOURCE(return_value, return_res, le_ph_video_hash); |
| 115 |
+#endif |
| 116 |
} |
| 117 |
/* }}} ph_dct_videohash */ |
| 118 |
|
| 119 |
@@ -261,10 +291,12 @@ PHP_FUNCTION(ph_dct_videohash) |
| 120 |
PHP_FUNCTION(ph_dct_imagehash) |
| 121 |
{ |
| 122 |
ulong64 * return_res; |
| 123 |
+#if PHP_VERSION_ID < 70000 |
| 124 |
long return_res_id = -1; |
| 125 |
+#endif |
| 126 |
|
| 127 |
const char * file = NULL; |
| 128 |
- int file_len = 0; |
| 129 |
+ SIZETorINT file_len = 0; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
@@ -282,7 +314,11 @@ PHP_FUNCTION(ph_dct_imagehash) |
| 134 |
else |
| 135 |
return_res = hash; |
| 136 |
|
| 137 |
+#if PHP_VERSION_ID >= 70000 |
| 138 |
+ RETURN_RES(zend_register_resource(return_res, le_ph_image_hash)); |
| 139 |
+#else |
| 140 |
return_res_id = ZEND_REGISTER_RESOURCE(return_value, return_res, le_ph_image_hash); |
| 141 |
+#endif |
| 142 |
} |
| 143 |
/* }}} ph_dct_imagehash */ |
| 144 |
|
| 145 |
@@ -293,10 +329,12 @@ PHP_FUNCTION(ph_dct_imagehash) |
| 146 |
PHP_FUNCTION(ph_texthash) |
| 147 |
{ |
| 148 |
ph_text_hash * return_res; |
| 149 |
+#if PHP_VERSION_ID < 70000 |
| 150 |
long return_res_id = -1; |
| 151 |
+#endif |
| 152 |
|
| 153 |
const char * file = NULL; |
| 154 |
- int file_len = 0; |
| 155 |
+ SIZETorINT file_len = 0; |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
@@ -316,7 +354,11 @@ PHP_FUNCTION(ph_texthash) |
| 160 |
else |
| 161 |
RETURN_FALSE; |
| 162 |
|
| 163 |
+#if PHP_VERSION_ID >= 70000 |
| 164 |
+ RETURN_RES(zend_register_resource(return_res, le_ph_txt_hash)); |
| 165 |
+#else |
| 166 |
return_res_id = ZEND_REGISTER_RESOURCE(return_value, return_res, le_ph_txt_hash); |
| 167 |
+#endif |
| 168 |
} |
| 169 |
/* }}} ph_texthash */ |
| 170 |
|
| 171 |
@@ -327,12 +369,14 @@ PHP_FUNCTION(ph_texthash) |
| 172 |
PHP_FUNCTION(ph_audiohash) |
| 173 |
{ |
| 174 |
ph_audio_hash * return_res; |
| 175 |
+#if PHP_VERSION_ID < 70000 |
| 176 |
long return_res_id = -1; |
| 177 |
+#endif |
| 178 |
|
| 179 |
const char * file = NULL; |
| 180 |
- int file_len = 0; |
| 181 |
- long sample_rate = 5512; |
| 182 |
- long channels = 1; |
| 183 |
+ SIZETorINT file_len = 0; |
| 184 |
+ zppLONG sample_rate = 5512; |
| 185 |
+ zppLONG channels = 1; |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
@@ -362,7 +406,11 @@ PHP_FUNCTION(ph_audiohash) |
| 190 |
else |
| 191 |
RETURN_FALSE; |
| 192 |
|
| 193 |
+#if PHP_VERSION_ID >= 70000 |
| 194 |
+ RETURN_RES(zend_register_resource(return_res, le_ph_audio_hash)); |
| 195 |
+#else |
| 196 |
return_res_id = ZEND_REGISTER_RESOURCE(return_value, return_res, le_ph_audio_hash); |
| 197 |
+#endif |
| 198 |
} |
| 199 |
/* }}} ph_audiohash */ |
| 200 |
|
| 201 |
@@ -386,8 +434,17 @@ PHP_FUNCTION(ph_image_dist) |
| 202 |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &h1_res, &h2_res) == FAILURE) { |
| 203 |
return; |
| 204 |
} |
| 205 |
+#if PHP_VERSION_ID >= 70000 |
| 206 |
+ if ((h1 = (ulong64 *)zend_fetch_resource2(Z_RES_P(h1_res), "ph_image_hash", h1_resid, le_ph_image_hash)) == NULL) { |
| 207 |
+ RETURN_FALSE; |
| 208 |
+ } |
| 209 |
+ if ((h2 = (ulong64 *)zend_fetch_resource2(Z_RES_P(h2_res), "ph_image_hash", h2_resid, le_ph_image_hash)) == NULL) { |
| 210 |
+ RETURN_FALSE; |
| 211 |
+ } |
| 212 |
+#else |
| 213 |
ZEND_FETCH_RESOURCE(h1, ulong64 *, &h1_res, h1_resid, "ph_image_hash", le_ph_image_hash); |
| 214 |
ZEND_FETCH_RESOURCE(h2, ulong64 *, &h2_res, h2_resid, "ph_image_hash", le_ph_image_hash); |
| 215 |
+#endif |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
@@ -415,15 +472,24 @@ PHP_FUNCTION(ph_video_dist) |
| 220 |
int h2_resid = -1; |
| 221 |
ph_video_hash * h2; |
| 222 |
|
| 223 |
- long thresh = 21; |
| 224 |
+ zppLONG thresh = 21; |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l", &h1_res, &h2_res, &thresh) == FAILURE) { |
| 229 |
return; |
| 230 |
} |
| 231 |
+#if PHP_VERSION_ID >= 70000 |
| 232 |
+ if ((h1 = (ph_video_hash *)zend_fetch_resource2(Z_RES_P(h1_res), "ph_video_hash", h1_resid, le_ph_video_hash)) == NULL) { |
| 233 |
+ RETURN_FALSE; |
| 234 |
+ } |
| 235 |
+ if ((h2 = (ph_video_hash *)zend_fetch_resource2(Z_RES_P(h2_res), "ph_video_hash", h2_resid, le_ph_video_hash)) == NULL) { |
| 236 |
+ RETURN_FALSE; |
| 237 |
+ } |
| 238 |
+#else |
| 239 |
ZEND_FETCH_RESOURCE(h1, ph_video_hash *, &h1_res, h1_resid, "ph_video_hash", le_ph_video_hash); |
| 240 |
ZEND_FETCH_RESOURCE(h2, ph_video_hash *, &h2_res, h2_resid, "ph_video_hash", le_ph_video_hash); |
| 241 |
+#endif |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
@@ -452,7 +518,7 @@ PHP_FUNCTION(ph_audio_dist) |
| 246 |
int h2_resid = -1; |
| 247 |
ph_audio_hash * h2; |
| 248 |
|
| 249 |
- long block_size = 256; |
| 250 |
+ zppLONG block_size = 256; |
| 251 |
double thresh = 0.30; |
| 252 |
|
| 253 |
|
| 254 |
@@ -460,8 +526,17 @@ PHP_FUNCTION(ph_audio_dist) |
| 255 |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|ld", &h1_res, &h2_res, &block_size, &thresh) == FAILURE) { |
| 256 |
return; |
| 257 |
} |
| 258 |
+#if PHP_VERSION_ID >= 70000 |
| 259 |
+ if ((h1 = (ph_audio_hash *)zend_fetch_resource2(Z_RES_P(h1_res), "ph_audio_hash", h1_resid, le_ph_audio_hash)) == NULL) { |
| 260 |
+ RETURN_FALSE; |
| 261 |
+ } |
| 262 |
+ if ((h2 = (ph_audio_hash *)zend_fetch_resource2(Z_RES_P(h2_res), "ph_audio_hash", h2_resid, le_ph_audio_hash)) == NULL) { |
| 263 |
+ RETURN_FALSE; |
| 264 |
+ } |
| 265 |
+#else |
| 266 |
ZEND_FETCH_RESOURCE(h1, ph_audio_hash *, &h1_res, h1_resid, "ph_audio_hash", le_ph_audio_hash); |
| 267 |
ZEND_FETCH_RESOURCE(h2, ph_audio_hash *, &h2_res, h2_resid, "ph_audio_hash", le_ph_audio_hash); |
| 268 |
+#endif |
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
@@ -510,8 +585,17 @@ PHP_FUNCTION(ph_compare_text_hashes) |
| 273 |
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &h1_res, &h2_res) == FAILURE) { |
| 274 |
return; |
| 275 |
} |
| 276 |
+#if PHP_VERSION_ID >= 70000 |
| 277 |
+ if ((h1 = (ph_text_hash *)zend_fetch_resource2(Z_RES_P(h1_res), "ph_txt_hash", h1_resid, le_ph_txt_hash)) == NULL) { |
| 278 |
+ RETURN_FALSE; |
| 279 |
+ } |
| 280 |
+ if ((h2 = (ph_text_hash *)zend_fetch_resource2(Z_RES_P(h2_res), "ph_txt_hash", h2_resid, le_ph_txt_hash)) == NULL) { |
| 281 |
+ RETURN_FALSE; |
| 282 |
+ } |
| 283 |
+#else |
| 284 |
ZEND_FETCH_RESOURCE(h1, ph_text_hash *, &h1_res, h1_resid, "ph_txt_hash", le_ph_txt_hash); |
| 285 |
ZEND_FETCH_RESOURCE(h2, ph_text_hash *, &h2_res, h2_resid, "ph_txt_hash", le_ph_txt_hash); |
| 286 |
+#endif |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
@@ -525,6 +609,14 @@ PHP_FUNCTION(ph_compare_text_hashes) |
| 291 |
{ |
| 292 |
for(int i = 0; i < count; ++i) |
| 293 |
{ |
| 294 |
+#if PHP_VERSION_ID >= 70000 |
| 295 |
+ zval array; |
| 296 |
+ array_init(&array); |
| 297 |
+ add_assoc_long(&array, "begin", m[i].first_index); |
| 298 |
+ add_assoc_long(&array, "end", m[i].second_index); |
| 299 |
+ add_assoc_long(&array, "length", m[i].length); |
| 300 |
+ add_next_index_zval(return_value, &array); |
| 301 |
+#else |
| 302 |
zval *array; |
| 303 |
MAKE_STD_ZVAL(array); |
| 304 |
array_init(array); |
| 305 |
@@ -532,6 +624,7 @@ PHP_FUNCTION(ph_compare_text_hashes) |
| 306 |
add_assoc_long(array, "end", m[i].second_index); |
| 307 |
add_assoc_long(array, "length", m[i].length); |
| 308 |
add_next_index_zval(return_value, array); |
| 309 |
+#endif |
| 310 |
} |
| 311 |
free(m); |
| 312 |
} |