本文整理汇总了C++中php_error函数的典型用法代码示例。如果您正苦于以下问题:C++ php_error函数的具体用法?C++ php_error怎么用?C++ php_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了php_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MultiByteToWideChar
PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage)
{
OLECHAR *unicode_str;
//request needed buffersize
uint reqSize = MultiByteToWideChar(codepage, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, C_str, -1, NULL, 0);
if(reqSize)
{
unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * reqSize);
//convert string
MultiByteToWideChar(codepage, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, C_str, -1, unicode_str, reqSize);
}
else
{
unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR));
*unicode_str = 0;
switch(GetLastError())
{
case ERROR_NO_UNICODE_TRANSLATION:
php_error(E_WARNING,"No unicode translation available for the specified string");
break;
default:
php_error(E_WARNING,"Error in php_char_to_OLECHAR()");
}
}
return unicode_str;
}
示例2: YRMCDS_METHOD
YRMCDS_METHOD(Client, decr2) {
char* key;
size_t key_len;
long value;
long initial;
long expire = 0;
zend_bool quiet = 0;
if( zend_parse_parameters(ZEND_NUM_ARGS(), "s!ll|lb",
&key, &key_len, &value, &initial,
&expire, &quiet) == FAILURE ) {
php_error(E_ERROR, "Invalid argument");
RETURN_FALSE;
}
if( key_len == 0 ) {
php_error(E_ERROR, "Invalid key");
RETURN_FALSE;
}
if( value < 0 ) {
php_error(E_ERROR, "Invalid value");
RETURN_FALSE;
}
if( initial < 0 ) {
php_error(E_ERROR, "Invalid initial value");
RETURN_FALSE;
}
YRMCDS_CLIENT_EXPLODE(getThis());
uint32_t serial;
CHECK_YRMCDS( yrmcds_decr2(&obj->conn->res, key, key_len, value, initial,
expire, quiet, &serial) );
RETURN_LONG((long)serial);
}
示例3: set_appointment_recurrence_pattern
void set_appointment_recurrence_pattern(struct AppointmentRecurrencePattern *arp, zval *to_set)
{
HashTable *ht = to_set->value.ht;
zval **to_set_rp;
if (zend_hash_find(ht, "RecurrencePattern", strlen("RecurrencePattern")+1, (void**) &to_set_rp) != SUCCESS) {
php_error(E_ERROR, "Cannot find RecurrencePattern member");
}
set_recurrence_pattern(&(arp->RecurrencePattern), *to_set_rp);
arp->ReaderVersion2 = 0x00003006;
arp->WriterVersion2 = 0x00003009;
long lval;
if (hash_find_long(ht, "StartTimeOffset", &lval) == SUCCESS) {
arp->StartTimeOffset = lval;
} else {
php_error(E_ERROR, "Missing StartTimeOffset field");
}
if (hash_find_long(ht, "EndTimeOffset", &lval) == SUCCESS) {
arp->EndTimeOffset = lval;
} else {
php_error(E_ERROR, "Missing EndTimeOffset field");
}
// XXX Exceptions not managed by now
arp->ExceptionCount = 0;
arp->ExceptionInfo = NULL;
arp->ReservedBlock1Size = 0;
arp->ReservedBlock1 = NULL;
arp->ExtendedException = NULL;
arp->ReservedBlock2Size = 0;
arp->ReservedBlock2 = NULL;
}
示例4: php_couchbase_res_ok
int php_couchbase_res_ok(int ec TSRMLS_DC)
{
switch (ec) {
case PHP_COUCHBASE_RES_OK:
return 1;
case PHP_COUCHBASE_RES_ERETURN:
return 0;
case PHP_COUCHBASE_RES_ENOTCONN:
php_error(E_WARNING, "There is no active connection to couchbase");
return 0;
case PHP_COUCHBASE_RES_EBUSY:
php_error(E_WARNING, "There are some results that should be "
"fetched before doing any sync operations");
return 0;
default:
fprintf(stderr, "Unexpected code %d. abort\n", ec);
abort();
/* not reached */
return -1;
}
}
示例5: clamav_load_database
static int clamav_load_database()
{
int ret = 0; /* return value */
int reload = 0;
/* libclamav initialization */
if (CLAMAV_G(cl_initcalled) == 0){
if((ret = cl_init(CL_INIT_DEFAULT)) != CL_SUCCESS) {
php_error(E_WARNING, "cl_init: failed : error code %i (%s)\n", ret, cl_strerror(ret));
return FAILURE;
} else {
CLAMAV_G(cl_initcalled) = 1;
}
}
/* database reload */
if (CLAMAV_G(dbstat.dir) != NULL && cl_statchkdir(&CLAMAV_G(dbstat)) == 1) {
reload = 1;
cl_statfree(&CLAMAV_G(dbstat));
}
/* load engine */
if (!(CLAMAV_G(dbengine) = cl_engine_new())){
php_error(E_WARNING, "Can’t create new engine\n");
return FAILURE;
}
if (CLAMAV_G(dbpath) == NULL) CLAMAV_G(dbpath) = (char *) cl_retdbdir();
/* database loading */
if ((ret = cl_load(CLAMAV_G(dbpath), CLAMAV_G(dbengine), &CLAMAV_G(sig_num), CL_DB_STDOPT)) != CL_SUCCESS) {
php_error(E_WARNING, "cl_load: failed : error code %i (%s)\n", ret, cl_strerror(ret));
return FAILURE;
}
/* compile signature database */
if ((ret = cl_engine_compile(CLAMAV_G(dbengine))) != CL_SUCCESS) {
php_error(E_WARNING, "cl_engine_compile : error code %i (%s\n", ret, cl_strerror(ret));
return FAILURE;
}
/* allocate cl_stat */
if (!reload) memset(&CLAMAV_G(dbstat), 0, sizeof(struct cl_stat));
/* database stats */
if ((ret = cl_statinidir(CLAMAV_G(dbpath), &CLAMAV_G(dbstat))) != CL_SUCCESS) {
php_error(E_WARNING, "cl_statinidir : error code %i (%s\n", ret, cl_strerror(ret));
return FAILURE;
}
/* set engine parameters */
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_MAX_FILES, CLAMAV_G(maxfiles));
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_MAX_FILESIZE, CLAMAV_G(maxfilesize));
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_MAX_SCANSIZE, CLAMAV_G(maxscansize));
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_MAX_RECURSION, CLAMAV_G(maxreclevel));
cl_engine_set_num(CLAMAV_G(dbengine), CL_ENGINE_KEEPTMP, CLAMAV_G(keeptmp));
cl_engine_set_str(CLAMAV_G(dbengine), CL_ENGINE_TMPDIR, CLAMAV_G(tmpdir));
return ret;
}
示例6: PHP_METHOD
/**
* override __call()
* it require two parameters, func_name and args
**/
PHP_METHOD(McpackHessianClient, __call) {
zend_class_entry *ce;
zval *p_this, *args, *params, *result, *method, *tmp;
char *func_name, *ret_str = NULL;
int func_name_len = 0;
size_t return_len = 0, max_len = 1024 * 1024 * 1024;
p_this = getThis();
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, p_this,
"Osz", &ce, mcphessian_ce_ptr, &func_name, &func_name_len, &args) == FAILURE) {
php_error(E_WARNING, "parse parameters error.");
RETURN_NULL();
}
// init params
MAKE_STD_ZVAL(params);
array_init(params);
add_assoc_string(params, "jsonrpc", "2.0", 0);
add_assoc_string(params, "method", func_name, 0);
add_assoc_zval(params, "params", args);
add_assoc_string(params, "id", "123456", 0);
zval *pack = array2mcpack(params);
// post data
zval *z_url = zend_read_property(mcphessian_ce_ptr, p_this, ZEND_STRL("url"), 1 TSRMLS_CC);
convert_to_string(z_url);
char *url = Z_STRVAL_P(z_url);
php_stream_context *context = php_stream_context_alloc();
MAKE_STD_ZVAL(method);
ZVAL_STRING(method, "POST", 0);
php_stream_context_set_option(context, "http", "method", method);
php_stream_context_set_option(context, "http", "content", pack);
// read data from stream
php_stream *stream = php_stream_open_wrapper_ex(url, "rb", REPORT_ERRORS, NULL, context);
if (stream) {
ret_str = php_stream_get_line(stream, NULL, max_len, &return_len);
} else {
php_error(E_WARNING, "failed to open stream %s.", url);
RETURN_NULL();
}
MAKE_STD_ZVAL(tmp);
ZVAL_STRINGL(tmp, ret_str, return_len, 0);
result = mcpack2array(tmp);
php_stream_close(stream);
efree(ret_str);
// get result from array
zval **ret_val;
if (zend_hash_exists(Z_ARRVAL_P(result), "result", 7)) {
zend_hash_find(Z_ARRVAL_P(result), "result", 7, (void **)&ret_val);
RETURN_ZVAL(*ret_val, 1, 0);
} else {
php_error(E_WARNING, "return value illegal.");
RETURN_NULL();
}
}
示例7: pip_mapping_to_hash
/* {{{ pip_mapping_to_hash(PyObject *map)
Convert a Python mapping to a PHP hash */
zval *
pip_mapping_to_hash(PyObject *map)
{
zval *hash, *val;
PyObject *keys, *key, *item;
char *key_name;
int i, key_len;
if (!PyMapping_Check(map)) {
return NULL;
}
/* Initialize our PHP array */
MAKE_STD_ZVAL(hash);
if (array_init(hash) != SUCCESS) {
return NULL;
}
/* Retrieve the list of keys for this mapping */
keys = PyMapping_Keys(map);
if (keys == NULL) {
return hash;
}
/* Iterate over the list of keys */
for (i = 0; i < PySequence_Size(keys); i++) {
key = PySequence_GetItem(keys, i);
if (key) {
/* Get the string representation of the key */
if (pip_str(key, &key_name, &key_len) != -1) {
/* Extract the item for this key */
item = PyMapping_GetItemString(map, key_name);
if (item) {
val = pip_pyobject_to_zval(item);
/* Add the new item to the associative array */
if (zend_hash_update(HASH_OF(hash), key_name, key_len,
(void *)&val, sizeof(zval *),
NULL) == FAILURE) {
php_error(E_ERROR, "Python: Array conversion error");
}
Py_DECREF(item);
} else {
php_error(E_ERROR, "Python: Could not get item for key");
}
} else {
php_error(E_ERROR, "Python: Mapping key conversion error");
}
Py_DECREF(key);
}
}
Py_DECREF(keys);
return hash;
}
示例8: PHP_METHOD
/* Object constructor */
static PHP_METHOD(midgard_query_builder, __construct)
{
MidgardConnection *mgd = mgd_handle(TSRMLS_C);
CHECK_MGD(mgd);
char *classname;
long classname_length;
zval *zval_object = getThis();
GObject *gobject;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &classname, &classname_length) == FAILURE) {
return;
}
zend_class_entry *ce = zend_fetch_class(classname, classname_length, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
if (ce == NULL) {
php_error(E_WARNING, "Didn't find %s class", classname);
php_midgard_error_exception_force_throw(mgd, MGD_ERR_INVALID_OBJECT TSRMLS_CC);
return;
}
zend_class_entry *base_ce = php_midgard_get_baseclass_ptr(ce);
const gchar *g_base_class_name = php_class_name_to_g_class_name(base_ce->name);
GType classtype = g_type_from_name(g_base_class_name);
if (!g_type_is_a(classtype, MIDGARD_TYPE_DBOBJECT)) {
php_error(E_WARNING, "Expected %s derived class", g_type_name(MIDGARD_TYPE_DBOBJECT));
php_midgard_error_exception_force_throw(mgd, MGD_ERR_INVALID_OBJECT TSRMLS_CC);
return;
}
gobject = __php_gobject_ptr(zval_object);
if (!gobject) {
MidgardQueryBuilder *builder = midgard_query_builder_new(mgd, g_base_class_name);
if (!builder) {
php_midgard_error_exception_throw(mgd TSRMLS_CC);
return;
}
MGD_PHP_SET_GOBJECT(zval_object, builder);
} else {
// we already have gobject injected
}
php_midgard_gobject *php_gobject = __php_objstore_object(zval_object);
/* Set user defined class. We might need it when execute is invoked */
php_gobject->user_ce = ce;
php_gobject->user_class_name = (char *)ce->name;
}
示例9: PHP_METHOD
/* Object constructor */
PHP_METHOD(midgard_connection, __construct)
{
MidgardConnection *mgd = NULL;
if (MGDG(midgard_memory_debug)) {
php_printf("[%p] midgard_connection::__construct()\n", getThis());
}
if (zend_parse_parameters_none() == FAILURE)
return;
if (MGDG(midgard_http)) {
/* trying to reuse saved connection */
mgd = php_midgard_handle_lookup(&MGDG(midgard_global_holder), MGDG(all_configs) TSRMLS_CC);
if (mgd == NULL) {
/* @todo throw exception, instead */
php_error(E_ERROR, "Midgard handle-lookup failed (could not connect to database)");
return;
}
} else {
mgd = midgard_connection_new();
if (mgd == NULL) {
/* @todo throw exception, instead */
php_error(E_ERROR, "Failed to create underlying GObject instance");
return;
}
}
if (global_loghandler) {
if (MGDG(midgard_memory_debug)) {
php_printf("---> g_log_remove_handler(..., %d)\n", global_loghandler);
}
g_log_remove_handler(G_LOG_DOMAIN, global_loghandler);
}
// midgard_connection_set_loglevel(mgd, "warning", NULL);
global_loghandler = midgard_connection_get_loghandler(mgd);
if (MGDG(midgard_memory_debug)) {
php_printf("---> global_loghandler = %d\n", global_loghandler);
}
/* storing midgard_connection in object's store-structure */
MGD_PHP_SET_GOBJECT(getThis(), mgd);
// explicitly enable replication (to stay compatible with mjölnir)
midgard_connection_enable_replication(mgd, TRUE);
if (MGDG(midgard_memory_debug)) {
php_printf("[%p] <= midgard_connection::__construct()\n", getThis());
}
}
示例10: CloseTray
static int CloseTray(int fd)
#endif
{
int status;
#ifdef PHP_WIN32
DWORD bytesReturned;
BOOL result;
LPVOID lpMsgBuf;
bytesReturned = 0;
result = DeviceIoControl(
fd,
IOCTL_STORAGE_LOAD_MEDIA,
NULL,
0,
NULL,
0,
&bytesReturned,
NULL);
if (!result) {
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
_tprintf(TEXT("%d, %s"), dw, lpMsgBuf);
php_error(E_ERROR, "%d, %s", dw, lpMsgBuf);
LocalFree(lpMsgBuf);
}
return result ? 1 : 0;
#else
#ifdef CDROMCLOSETRAY
status = ioctl(fd, CDROMCLOSETRAY);
if (status != 0) {
php_error(E_WARNING, "CD-ROM tray close command failed: %s\n", strerror(errno));
return 0;
} else {
return 1;
}
#else
php_error(E_WARNING, "CD-ROM tray close command not supported by this kernel\n");
return 0;
#endif /* CDROMCLOSETRAY */
#endif /* PHP_WIN32 */
}
示例11: my_copy_zval
/* {{{ my_copy_zval */
zval* my_copy_zval(zval* dst, const zval* src, int persistent TSRMLS_DC)
{
zval **tmp;
assert(dst != NULL);
assert(src != NULL);
memcpy(dst, src, sizeof(zval));
/* deep copies are refcount(1), but moved up for recursive
* arrays, which end up being add_ref'd during its copy. */
Z_SET_REFCOUNT_P(dst, 1);
Z_UNSET_ISREF_P(dst);
switch (src->type & IS_CONSTANT_TYPE_MASK) {
case IS_RESOURCE:
php_error(E_ERROR, "Cannot copy resource");
break;
case IS_BOOL:
case IS_LONG:
case IS_DOUBLE:
case IS_NULL:
break;
case IS_CONSTANT:
case IS_STRING:
if (src->value.str.val) {
dst->value.str.val = pestrndup(src->value.str.val, src->value.str.len, persistent);
}
break;
#if ZEND_EXTENSION_API_NO < PHP_5_5_X_API_NO
case IS_CONSTANT_ARRAY:
#endif
case IS_ARRAY:
dst->value.ht = my_copy_hashtable(NULL, src->value.ht, (ht_copy_fun_t) my_copy_zval_ptr, (void*) &tmp, sizeof(zval *), persistent TSRMLS_CC);
break;
// XXX: we don't serialize object.
case IS_OBJECT:
php_error(E_ERROR, "Cannot copy Object.");
break;
#ifdef ZEND_ENGINE_2_4
case IS_CALLABLE:
php_error(E_ERROR, "Cannot copy Callable.");
// XXX: we don't serialize callbable object.
break;
#endif
default:
assert(0);
}
return dst;
}
示例12: die
// die
// Terminate the PHP request with an error message
// We use this function rather than php_error directly because we use the FormatMessage syntax in most other
// places within the extension (e.g., LOG), whereas php_error uses the printf format syntax. There were
// places where we were using the FormatMessage syntax inadvertently with DIE which left messages without
// proper information. Rather than convert those messages and try and remember the difference between LOG and
// DIE, it is simpler to make the format syntax common between them.
void die( const char* msg, ... )
{
va_list format_args;
va_start( format_args, msg );
DWORD rc = FormatMessage( FORMAT_MESSAGE_FROM_STRING, msg, 0, 0, last_err_msg, sizeof( last_err_msg ), &format_args );
va_end( format_args );
if( rc == 0 ) {
php_error( E_ERROR, reinterpret_cast<const char*>( INTERNAL_FORMAT_ERROR ));
}
php_error( E_ERROR, last_err_msg );
}
示例13: xslt_call_function
/* {{{ call_xslt_function()
Call an XSLT handler */
extern void xslt_call_function(char *name,
struct xslt_function *fptr,
int argc,
zval **argv,
zval **retval)
{
int error; /* Error container */
int idx; /* Idx, when looping through and free'ing the arguments */
ELS_FETCH(); /* For TS mode, fetch the executor globals */
/* Allocate and initialize return value from the function */
MAKE_STD_ZVAL(*retval);
/* Call the function */
error = call_user_function(EG(function_table),
XSLT_OBJ(fptr),
XSLT_FUNC(fptr),
*retval, argc, argv);
if (error == FAILURE) {
php_error(E_WARNING, "Cannot call the %s handler: %s",
name, Z_STRVAL_P(XSLT_FUNC(fptr)));
}
/* Cleanup arguments */
for (idx = 0; idx < argc; idx++) {
/* Decrease refcount and free if refcount is <= 0 */
zval_ptr_dtor(&argv[idx]);
}
}
示例14: _php_curl_write_header
static size_t _php_curl_write_header(char *data, size_t size, size_t nmemb, void *ctx)
{
php_curl *ch = (php_curl *) ctx;
zval *func = ch->handlers->write_header;
zval *argv[2];
zval *retval;
int error;
int length;
ELS_FETCH();
MAKE_STD_ZVAL(argv[0]);
MAKE_STD_ZVAL(argv[1]);
MAKE_STD_ZVAL(retval);
ZVAL_RESOURCE(argv[0], ch->id);
zend_list_addref(ch->id);
ZVAL_STRINGL(argv[0], data, size * nmemb, 1);
error = call_user_function(EG(function_table),
NULL,
func,
retval, 2, argv);
if (error == FAILURE) {
php_error(E_WARNING, "Couldn't call the CURLOPT_HEADERFUNCTION");
return -1;
}
length = Z_LVAL_P(retval);
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&retval);
return length;
}
示例15: __register_class_closure
static void __register_class_closure(const gchar *class_name, const gchar *signal, php_mgd_closure *closure)
{
if (__classes_hash == NULL)
return;
gchar *sname = g_strdup(signal);
g_strdelimit (sname, G_STR_DELIMITERS ":^", '_'); /* FIXME, it should be fast, so no conversion here */
guint signal_id = g_signal_lookup(sname, g_type_from_name(class_name));
if (signal_id == 0) {
php_error(E_WARNING, "'%s' is not registered as event for '%s'", sname, class_name);
g_free(sname);
return;
}
GHashTable *closures_hash =
g_hash_table_lookup(__classes_hash, class_name);
if (!closures_hash) {
closures_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, __php_midgard_closure_free);
}
g_hash_table_insert(closures_hash, (gpointer) sname, closure);
g_hash_table_insert(__classes_hash, (gpointer) g_strdup(class_name), closures_hash);
}