| 123 |
ZEND_FUNCTION(xnp_get_index_id_by_item_id ); |
ZEND_FUNCTION(xnp_get_index_id_by_item_id ); |
| 124 |
ZEND_FUNCTION(xnp_get_own_public_item_id ); |
ZEND_FUNCTION(xnp_get_own_public_item_id ); |
| 125 |
|
|
| 126 |
|
ZEND_FUNCTION(xnp_zip_create ); |
| 127 |
|
|
| 128 |
}; |
}; |
| 129 |
/* compiled function list so Zend knows what's in this module */ |
/* compiled function list so Zend knows what's in this module */ |
| 130 |
zend_function_entry xnpalmod_functions[] = |
zend_function_entry xnpalmod_functions[] = |
| 218 |
ZEND_FE(xnp_get_index_id_by_item_id ,NULL) |
ZEND_FE(xnp_get_index_id_by_item_id ,NULL) |
| 219 |
ZEND_FE(xnp_get_own_public_item_id ,NULL) |
ZEND_FE(xnp_get_own_public_item_id ,NULL) |
| 220 |
|
|
| 221 |
|
ZEND_FE(xnp_zip_create ,NULL) |
| 222 |
|
|
| 223 |
{NULL, NULL, NULL} |
{NULL, NULL, NULL} |
| 224 |
}; |
}; |
| 225 |
|
|
| 3347 |
|
|
| 3348 |
RETURN_LONG( result ); |
RETURN_LONG( result ); |
| 3349 |
} |
} |
| 3350 |
|
|
| 3351 |
|
ZEND_FUNCTION(xnp_zip_create) |
| 3352 |
|
{ |
| 3353 |
|
zval* zzipfile; |
| 3354 |
|
zval* zfiles; |
| 3355 |
|
result_t result = RES_ERROR; |
| 3356 |
|
|
| 3357 |
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "za", |
| 3358 |
|
&zzipfile, &zfiles) == FAILURE) { |
| 3359 |
|
return; |
| 3360 |
|
} |
| 3361 |
|
char* zipfile = getZvalString( &zzipfile ); |
| 3362 |
|
char** files = 0; |
| 3363 |
|
int len; |
| 3364 |
|
|
| 3365 |
|
if ( Z_TYPE_P(zfiles) != IS_ARRAY ){ |
| 3366 |
|
result = RES_ERROR; |
| 3367 |
|
} |
| 3368 |
|
else { |
| 3369 |
|
len = zend_hash_num_elements(Z_ARRVAL_P(zfiles)); |
| 3370 |
|
if(len > 0) { |
| 3371 |
|
zval **tmp; |
| 3372 |
|
HashPosition pos; |
| 3373 |
|
int i = 0; |
| 3374 |
|
files = new char*[ len ]; |
| 3375 |
|
|
| 3376 |
|
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(zfiles), &pos); |
| 3377 |
|
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(zfiles), (void **) &tmp, &pos) == SUCCESS ) { |
| 3378 |
|
SEPARATE_ZVAL(tmp); // zend.arguments.write-safety.html 参照 |
| 3379 |
|
convert_to_string_ex(tmp); |
| 3380 |
|
|
| 3381 |
|
if ( i < len ) |
| 3382 |
|
files[i++] = Z_STRVAL_PP(tmp); |
| 3383 |
|
zend_hash_move_forward_ex(Z_ARRVAL_P(zfiles), &pos); |
| 3384 |
|
} |
| 3385 |
|
//len = i; |
| 3386 |
|
} |
| 3387 |
|
} |
| 3388 |
|
if( files != 0 ){ |
| 3389 |
|
result = zipCreate( zipfile, files, len ); |
| 3390 |
|
}else{ |
| 3391 |
|
result = RES_ERROR; |
| 3392 |
|
} |
| 3393 |
|
|
| 3394 |
|
RETURN_LONG( result ); |
| 3395 |
|
} |
| 3396 |
|
|