zval * cpMD5(zval *arr) {//pass in array , out md5 zval smart_str ser_data = {0}; cp_serialize(&ser_data, arr); zval fun_name, **args[1], *retval, *str; CP_ZVAL_STRING(&fun_name, "md5", 0); CP_MAKE_STD_ZVAL(str); #if PHP_MAJOR_VERSION < 7 CP_ZVAL_STRINGL(str, ser_data.c, ser_data.len, 1); #else zend_string *str_data = ser_data.s; CP_ZVAL_STRINGL(str, str_data->val, str_data->len, 1); #endif args[0] = &str; if (cp_call_user_function_ex(CG(function_table), NULL, &fun_name, &retval, 1, args, 0, NULL TSRMLS_CC) != SUCCESS) { cp_zval_ptr_dtor(&str); smart_str_free(&ser_data); return NULL; } cp_zval_ptr_dtor(&str); smart_str_free(&ser_data); return retval; }
void cpSettitle(char *title_name) { // assert(MAX_TITLE_LENGTH > strlen(title) + 5); int len = 0; char name[MAX_TITLE_LENGTH + 5] = {0}; strcat(name, "pool_"); if (strlen(title_name) >= MAX_TITLE_LENGTH) { len = MAX_TITLE_LENGTH; } else { len = strlen(title_name); } memcpy(name + 5, title_name, len); zval *zname; CP_MAKE_STD_ZVAL(zname); CP_ZVAL_STRING(zname, name, 0); #if PHP_MAJOR_VERSION >= 7 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 4) zval *retval; zval **args[1]; args[0] = &zname; zval *function; CP_MAKE_STD_ZVAL(function); CP_ZVAL_STRING(function, "cli_set_process_title", 1); if (cp_call_user_function_ex(EG(function_table), NULL, function, &retval, 1, args, 0, NULL TSRMLS_CC) == FAILURE) { return; } cp_zval_ptr_dtor(&function); if (retval) { cp_zval_ptr_dtor(&retval); } #else bzero(sapi_module.executable_location, 127); memcpy(sapi_module.executable_location, Z_STRVAL_P(zname), Z_STRLEN_P(zname)); #endif }
PHP_METHOD(pdo_connect_pool_PDOStatement, next) { zval *pos, *next; CP_MAKE_STD_ZVAL(next); zend_class_entry *ce; ce = Z_OBJCE_P(getThis()); pos = cp_zend_read_property(ce, getThis(), "pos", sizeof("pos") -1, 0 TSRMLS_DC); ZVAL_LONG(next, ++Z_LVAL_P(pos)); zend_update_property(ce, getThis(), "pos", sizeof("pos") -1, next TSRMLS_CC); }
PHP_METHOD(pdo_connect_pool_PDOStatement, current) { zval *pos, *rs, *row; zend_class_entry *ce; ce = Z_OBJCE_P(getThis()); pos = cp_zend_read_property(ce, getThis(), "pos", sizeof("pos") -1, 0 TSRMLS_DC); rs = cp_zend_read_property(ce, getThis(), "rs", sizeof("rs") -1, 0 TSRMLS_DC); CP_MAKE_STD_ZVAL(row); cp_zend_hash_index_find(Z_ARRVAL_P(rs), Z_LVAL_P(pos), (void**) &row); RETVAL_ZVAL(row, 1, 1); }
PHP_METHOD(pdo_connect_pool_PDOStatement, valid) { zval *pos, *rs, *row = NULL; zend_class_entry *ce; ce = Z_OBJCE_P(getThis()); pos = cp_zend_read_property(ce, getThis(), "pos", sizeof("pos") -1, 0 TSRMLS_DC); rs = cp_zend_read_property(ce, getThis(), "rs", sizeof("rs") -1, 0 TSRMLS_DC); CP_MAKE_STD_ZVAL(row); if (cp_zend_hash_index_find(Z_ARRVAL_P(rs), Z_LVAL_P(pos), (void**) &row) == SUCCESS) { RETURN_BOOL(1); } else { RETURN_BOOL(0); } }
PHP_METHOD(pdo_connect_pool_PDOStatement, rewind) { zval *object = getThis(); zval *method_ptr, method, *ret_value = NULL, *pos; method_ptr = &method; zend_class_entry *ce; ce = Z_OBJCE_P(object); CP_MAKE_STD_ZVAL(pos); ZVAL_LONG(pos, 0); CP_ZVAL_STRING(method_ptr, "fetchAll", 0); //cp_internal_call_user_function(object, method_ptr, &ret_value, NULL); if (cp_call_user_function_ex(EG(function_table), &object, method_ptr, &ret_value, 0, NULL, 0, NULL TSRMLS_CC) == FAILURE) { return ; } zend_update_property(ce, object, "pos", sizeof("pos") -1, pos TSRMLS_CC); zend_update_property(ce, object, "rs", sizeof("rs") - 1, ret_value TSRMLS_CC); }
void cpSettitle(char *title_name) { // assert(MAX_TITLE_LENGTH > strlen(title) + 5); char title[MAX_TITLE_LENGTH + 5] = {0}; strcat(title, "pool_"); strcat(title, title_name); #if PHP_MAJOR_VERSION > 5 && PHP_MINOR_VERSION > 4 ||PHP_MAJOR_VERSION==7 zval *name_ptr, name; name_ptr = &name; CP_ZVAL_STRING(name_ptr, title, 1); cp_zval_add_ref(&name_ptr); zval *retval; zval **args[1]; args[0] = &name_ptr; zval *function; CP_MAKE_STD_ZVAL(function); CP_ZVAL_STRING(function, "cli_set_process_title", 1); if (cp_call_user_function_ex(EG(function_table), NULL, function, &retval, 1, args, 0, NULL TSRMLS_CC) == FAILURE) { return; } cp_zval_ptr_dtor(&function); if (retval) { cp_zval_ptr_dtor(&retval); } #else bzero(sapi_module.executable_location, MAX_TITLE_LENGTH); memcpy(sapi_module.executable_location, title, strlen(title)); #endif }