static void n1ix_list_callback(lcb_t instance, int cbtype, const lcb_RESPN1XMGMT *resp) { opcookie_n1ix_list_res *result = ecalloc(1, sizeof(opcookie_n1ix_list_res)); int i; TSRMLS_FETCH(); result->header.err = resp->rc; if (result->header.err == LCB_QUERY_ERROR) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to list indexes. %d: %.*s", (int)resp->inner->htresp->htstatus, (int)resp->inner->nrow, (char *)resp->inner->row); } result->nspecs = resp->nspecs; result->specs = ecalloc(result->nspecs, sizeof(zapval)); for (i = 0; i < result->nspecs; ++i) { const lcb_N1XSPEC *spec = resp->specs[i]; zapval value, rawjson, json; zapval_alloc_stringl(rawjson, spec->rawjson, spec->nrawjson); zapval_alloc(json); php_json_decode(zapval_zvalptr(json), zapval_strval_p(&rawjson), zapval_strlen_p(&rawjson), 1, PHP_JSON_PARSER_DEFAULT_DEPTH TSRMLS_CC); zapval_alloc_null(value); pcbc_make_n1ix_spec(zapval_zvalptr(value), json TSRMLS_CC); result->specs[i] = value; } opcookie_push((opcookie*)resp->cookie, &result->header); }
void make_exception(zapval *ex, zend_class_entry *exception_ce, const char *message, long code TSRMLS_DC) { zapval_alloc(*ex); object_init_ex(zapval_zvalptr_p(ex), cb_exception_ce); if (message) { zend_update_property_string( cb_exception_ce, zapval_zvalptr_p(ex), "message", sizeof("message")-1, message TSRMLS_CC); } if (code) { zend_update_property_long( cb_exception_ce, zapval_zvalptr_p(ex), "code", sizeof("code")-1, code TSRMLS_CC); } }