本文整理汇总了C++中php_error函数的典型用法代码示例。如果您正苦于以下问题:C++ php_error函数的具体用法?C++ php_error怎么用?C++ php_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了php_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:31,代码来源:conversion.c
示例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);
}
开发者ID:cybozu,项目名称:php-yrmcds,代码行数:33,代码来源:yrmcds.c
示例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;
}
开发者ID:ThHirsch,项目名称:openchange,代码行数:35,代码来源:mapi_appointment.c
示例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;
}
}
开发者ID:mnunberg,项目名称:php-ext-couchbase,代码行数:26,代码来源:resmgr.c
示例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;
}
开发者ID:argos66,项目名称:php-clamav,代码行数:60,代码来源:clamav.c
示例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();
}
}
开发者ID:Raaaay,项目名称:mcphessian,代码行数:61,代码来源:mcphessian.c
示例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;
}
开发者ID:demos,项目名称:Motif,代码行数:57,代码来源:pip_convert.c
示例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;
}
开发者ID:William-Wai,项目名称:midgard-php5,代码行数:54,代码来源:query_builder.c
示例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());
}
}
开发者ID:indeyets,项目名称:midgard-php5,代码行数:53,代码来源:php_midgard_connection.c
示例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 */
}
开发者ID:oasynnoum,项目名称:php-eject,代码行数:52,代码来源:eject.c
示例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;
}
开发者ID:26597925,项目名称:Pux,代码行数:52,代码来源:pux_functions.c
示例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 );
}
开发者ID:Jan-E,项目名称:msphpsql,代码行数:22,代码来源:core_util.cpp
示例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]);
}
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:31,代码来源:xslt.c
示例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;
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:35,代码来源:curl.c
示例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);
}
开发者ID:William-Wai,项目名称:midgard-php5,代码行数:26,代码来源:php_midgard_gobject_closures.c
示例16: apd_summary_output_enter_function
void
apd_summary_output_enter_function(int index, int filenum, int linenum)
{
apd_function_entry_t *function_entry;
apd_fcall_t *fcall;
TSRMLS_FETCH();
if (index == 1) {
return;
}
function_entry = apd_array_get(&APD_GLOBALS(summary).functions, index);
if (function_entry == NULL) {
php_error(E_WARNING, "Couldn't find function entry by index %d", index);
return;
}
fcall = find_fcall(&function_entry->coverage, filenum, linenum);
if (!fcall) {
fcall = ecalloc(1, sizeof(apd_fcall_t));
fcall->line = linenum;
fcall->file = filenum;
fcall->entry = function_entry;
append_fcall(&function_entry->coverage, fcall);
}
fcall->calls++;
zend_llist_add_element(&APD_GLOBALS(summary).call_list, &fcall);
}
开发者ID:ZeWaren,项目名称:pecl-apd,代码行数:30,代码来源:apd_summary.c
示例17: Z_INTL_RESOURCEBUNDLE_P
/* {{{ resourcebundle_get_iterator */
zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *object, int byref )
{
ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P(object );
ResourceBundle_iterator *iterator = emalloc( sizeof( ResourceBundle_iterator ) );
if (byref) {
php_error( E_ERROR, "ResourceBundle does not support writable iterators" );
}
zend_iterator_init(&iterator->intern);
ZVAL_COPY(&iterator->intern.data, object);
iterator->intern.funcs = &resourcebundle_iterator_funcs;
iterator->subject = rb;
/* The iterated rb can only be either URES_TABLE or URES_ARRAY
* All other types are returned as php primitives!
*/
iterator->is_table = (ures_getType( rb->me ) == URES_TABLE);
iterator->length = ures_getSize( rb->me );
ZVAL_UNDEF(&iterator->current);
iterator->currentkey = NULL;
iterator->i = 0;
return (zend_object_iterator *) iterator;
}
开发者ID:AmesianX,项目名称:php-src,代码行数:28,代码来源:resourcebundle_iterator.c
示例18: pip_sequence_to_hash
/* {{{ pip_sequence_to_hash(PyObject *seq)
* Convert a Python sequence to a PHP hash */
zval *
pip_sequence_to_hash(PyObject *seq)
{
zval *hash, *val;
PyObject *item;
int i = 0;
/* Make sure this object implements the sequence protocol */
if (!PySequence_Check(seq)) {
return NULL;
}
/* Initialize our PHP array */
MAKE_STD_ZVAL(hash);
if (array_init(hash) != SUCCESS) {
return NULL;
}
/* Iterate over the items in the sequence */
while (item = PySequence_GetItem(seq, i++)) {
val = pip_pyobject_to_zval(item);
if (zend_hash_next_index_insert(HASH_OF(hash), (void *)&val,
sizeof(zval *), NULL) == FAILURE) {
php_error(E_ERROR, "Python: Array conversion error");
}
Py_DECREF(item);
}
return hash;
}
开发者ID:demos,项目名称:Motif,代码行数:33,代码来源:pip_convert.c
示例19: WideCharToMultiByte
PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int persistent, int codepage)
{
char *C_str;
uint length = 0;
//request needed buffersize
uint reqSize = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, NULL, 0, NULL, NULL);
if(reqSize)
{
C_str = (char *) pemalloc(sizeof(char) * reqSize, persistent);
//convert string
length = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, unicode_str, -1, C_str, reqSize, NULL, NULL) - 1;
}
else
{
C_str = (char *) pemalloc(sizeof(char), persistent);
*C_str = 0;
php_error(E_WARNING,"Error in php_OLECHAR_to_char()");
}
if(out_length)
*out_length = length;
return C_str;
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:28,代码来源:conversion.c
示例20: PHP_METHOD
static PHP_METHOD(midgard_object_class, has_metadata)
{
MidgardConnection *mgd = mgd_handle(TSRMLS_C);
CHECK_MGD(mgd);
zval *zvalue;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zvalue) == FAILURE) {
return;
}
const char *php_classname = NULL;
if (Z_TYPE_P(zvalue) == IS_STRING) {
php_classname = Z_STRVAL_P(zvalue);
} else if (Z_TYPE_P(zvalue) == IS_OBJECT) {
php_classname = Z_OBJCE_P(zvalue)->name;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "argument should be object or string");
return;
}
const gchar *g_classname = php_class_name_to_g_class_name(php_classname);
MidgardObjectClass *klass = MIDGARD_OBJECT_GET_CLASS_BY_NAME(g_classname);
if (!klass) {
php_error(E_WARNING, "MidgardObjectClass not found");
return;
}
RETURN_BOOL(midgard_reflector_object_has_metadata_class(g_classname));
}
开发者ID:William-Wai,项目名称:midgard-php5,代码行数:32,代码来源:php_midgard_object_class.c
注:本文中的php_error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论