void refill() { assert(buffer_used == 0); zval retval; ZVAL_NULL(&retval); zval *args[1]; MAKE_STD_ZVAL(args[0]); ZVAL_LONG(args[0], buffer_size); TSRMLS_FETCH(); zval funcname; ZVAL_STRING(&funcname, "read", 0); call_user_function(EG(function_table), &t, &funcname, &retval, 1, args TSRMLS_CC); zval_ptr_dtor(args); if (EG(exception)) { zval_dtor(&retval); zval* ex = EG(exception); EG(exception) = NULL; throw PHPExceptionWrapper(ex); } buffer_used = Z_STRLEN(retval); memcpy(buffer, Z_STRVAL(retval), buffer_used); zval_dtor(&retval); buffer_ptr = buffer; }
void refill() { assert(buffer_used == 0); zval retval; zval args[1]; zval funcname; ZVAL_NULL(&retval); ZVAL_LONG(&args[0], buffer_size); ZVAL_STRING(&funcname, "read"); call_user_function(EG(function_table), &(this->t), &funcname, &retval, 1, args); zval_dtor(&args[0]); zval_dtor(&funcname); if (EG(exception)) { zval_dtor(&retval); zend_object *ex = EG(exception); EG(exception) = nullptr; throw PHPExceptionWrapper(ex); } buffer_used = Z_STRLEN(retval); memcpy(buffer, Z_STRVAL(retval), buffer_used); zval_dtor(&retval); buffer_ptr = buffer; }
static void throw_tprotocolexception(const char* what, long errorcode) { zval zwhat, zerrorcode; ZVAL_STRING(&zwhat, what); ZVAL_LONG(&zerrorcode, errorcode); zval ex; createObject("\\Thrift\\Exception\\TProtocolException", &ex, 2, &zwhat, &zerrorcode); zval_dtor(&zwhat); zval_dtor(&zerrorcode); throw PHPExceptionWrapper(&ex); }
void throw_tprotocolexception(char* what, long errorcode) { TSRMLS_FETCH(); zval *zwhat, *zerrorcode; MAKE_STD_ZVAL(zwhat); MAKE_STD_ZVAL(zerrorcode); ZVAL_STRING(zwhat, what, 1); ZVAL_LONG(zerrorcode, errorcode); zval* ex; MAKE_STD_ZVAL(ex); createObject("TProtocolException", ex, 2, zwhat, zerrorcode); zval_ptr_dtor(&zwhat); zval_ptr_dtor(&zerrorcode); throw PHPExceptionWrapper(ex); }
void directWrite(const char* data, size_t len) { zval args[1], ret, writefn; ZVAL_STRING(&writefn, "write"); ZVAL_STRINGL(&args[0], data, len); ZVAL_NULL(&ret); call_user_function(EG(function_table), &(this->t), &writefn, &ret, 1, args); zval_dtor(&writefn); zval_dtor(&ret); zval_dtor(&args[0]); if (EG(exception)) { zend_object *ex = EG(exception); EG(exception) = nullptr; throw PHPExceptionWrapper(ex); } }
void directWrite(const char* data, size_t len) { zval writefn; ZVAL_STRING(&writefn, "write", 0); char* newbuf = (char*)emalloc(len + 1); memcpy(newbuf, data, len); newbuf[len] = '\0'; zval *args[1]; MAKE_STD_ZVAL(args[0]); ZVAL_STRINGL(args[0], newbuf, len, 0); TSRMLS_FETCH(); zval ret; ZVAL_NULL(&ret); call_user_function(EG(function_table), &t, &writefn, &ret, 1, args TSRMLS_CC); zval_ptr_dtor(args); zval_dtor(&ret); if (EG(exception)) { zval* ex = EG(exception); EG(exception) = NULL; throw PHPExceptionWrapper(ex); } }