本文整理汇总了C++中zend_parse_parameters函数的典型用法代码示例。如果您正苦于以下问题:C++ zend_parse_parameters函数的具体用法?C++ zend_parse_parameters怎么用?C++ zend_parse_parameters使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zend_parse_parameters函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHP_METHOD
/**
* Manually bind params to a SQL statement. This method requires an active connection to a database system
*
*<code>
* $sql = $connection->bindParams('SELECT * FROM robots WHERE name = ?0', array('Bender'));
* echo $sql; // SELECT * FROM robots WHERE name = 'Bender'
*</code>
*
* @param string $sqlStatement
* @param array $params
* @return string
*/
PHP_METHOD(Phalcon_Db_Adapter_Pdo, bindParams){
zval *sql_statement, *params, *sql = NULL, *pdo, *bind_value = NULL;
zval *index = NULL, *value = NULL, *place_key = NULL, *replaced_sql = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &sql_statement, ¶ms) == FAILURE) {
RETURN_MM_NULL();
}
if (Z_TYPE_P(params) == IS_ARRAY) {
if (phalcon_fast_count_ev(params TSRMLS_CC)) {
PHALCON_CPY_WRT(sql, sql_statement);
PHALCON_OBS_VAR(pdo);
phalcon_read_property(&pdo, this_ptr, SL("_pdo"), PH_NOISY_CC);
if (!phalcon_is_iterable(params, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_FOREACH_KEY(index, ah0, hp0);
PHALCON_GET_FOREACH_VALUE(bind_value);
if (phalcon_is_numeric(bind_value)) {
PHALCON_CPY_WRT(value, bind_value);
} else {
if (Z_TYPE_P(bind_value) == IS_OBJECT) {
PHALCON_INIT_NVAR(value);
PHALCON_CALL_FUNC_PARAMS_1(value, "strval", bind_value);
} else {
PHALCON_INIT_NVAR(value);
PHALCON_CALL_METHOD_PARAMS_1(value, pdo, "quote", bind_value);
}
}
/**
* Handle long parameters as numeric placeholders: ?0, ?1
*/
if (Z_TYPE_P(index) == IS_LONG) {
PHALCON_INIT_NVAR(place_key);
PHALCON_CONCAT_SV(place_key, "?", index);
PHALCON_INIT_NVAR(replaced_sql);
phalcon_fast_str_replace(replaced_sql, place_key, value, sql TSRMLS_CC);
PHALCON_CPY_WRT(sql, replaced_sql);
zend_hash_move_forward_ex(ah0, &hp0);
continue;
}
/**
* Handle long parameters as string placeholders: :name:, :other:
*/
if (Z_TYPE_P(index) == IS_STRING) {
PHALCON_INIT_NVAR(place_key);
PHALCON_CONCAT_SVS(place_key, ":", index, ":");
PHALCON_INIT_NVAR(replaced_sql);
phalcon_fast_str_replace(replaced_sql, place_key, value, sql TSRMLS_CC);
PHALCON_CPY_WRT(sql, replaced_sql);
zend_hash_move_forward_ex(ah0, &hp0);
continue;
}
/**
* Unrecognized parameter type
*/
PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Invalid bind parameter");
return;
zend_hash_move_forward_ex(ah0, &hp0);
}
RETURN_CCTOR(sql);
}
}
RETURN_CCTOR(sql_statement);
}
示例2: PHP_METHOD
PHP_METHOD(MongoDB, command) {
zval limit, *temp, *cmd, *cursor, *ns, *options = 0;
mongo_db *db;
mongo_link *link;
char *cmd_ns;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &cmd, &options) == FAILURE) {
return;
}
if (IS_SCALAR_P(cmd)) {
zend_error(E_WARNING, "MongoDB::command() expects parameter 1 to be an array or object");
return;
}
PHP_MONGO_GET_DB(getThis());
// create db.$cmd
MAKE_STD_ZVAL(ns);
cmd_ns = get_cmd_ns(Z_STRVAL_P(db->name), Z_STRLEN_P(db->name));
ZVAL_STRING(ns, cmd_ns, 0);
// create cursor
MAKE_STD_ZVAL(cursor);
object_init_ex(cursor, mongo_ce_Cursor);
MAKE_STD_ZVAL(temp);
ZVAL_NULL(temp);
MONGO_METHOD3(MongoCursor, __construct, temp, cursor, db->link, ns, cmd);
zval_ptr_dtor(&ns);
zval_ptr_dtor(&temp);
MAKE_STD_ZVAL(temp);
ZVAL_NULL(temp);
// limit
Z_TYPE(limit) = IS_LONG;
Z_LVAL(limit) = -1;
MONGO_METHOD1(MongoCursor, limit, temp, cursor, &limit);
zval_ptr_dtor(&temp);
if (options) {
zval **timeout;
if (zend_hash_find(HASH_P(options), "timeout", strlen("timeout")+1, (void**)&timeout) == SUCCESS) {
MAKE_STD_ZVAL(temp);
ZVAL_NULL(temp);
MONGO_METHOD1(MongoCursor, timeout, temp, cursor, *timeout);
zval_ptr_dtor(&temp);
}
}
// make sure commands aren't be sent to slaves
PHP_MONGO_GET_LINK(db->link);
if (link->rs) {
zval slave_okay;
Z_TYPE(slave_okay) = IS_BOOL;
Z_LVAL(slave_okay) = 0;
MAKE_STD_ZVAL(temp);
ZVAL_NULL(temp);
MONGO_METHOD1(MongoCursor, slaveOkay, temp, cursor, &slave_okay);
zval_ptr_dtor(&temp);
}
// query
MONGO_METHOD(MongoCursor, getNext, return_value, cursor);
clear_exception(return_value TSRMLS_CC);
zend_objects_store_del_ref(cursor TSRMLS_CC);
zval_ptr_dtor(&cursor);
}
示例3: get_icu_disp_value_src_php
/* {{{
* common code shared by display_xyz functions to get the value from ICU
}}} */
static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
{
const char* loc_name = NULL;
int loc_name_len = 0;
const char* disp_loc_name = NULL;
int disp_loc_name_len = 0;
int free_loc_name = 0;
UChar* disp_name = NULL;
int32_t disp_name_len = 0;
char* mod_loc_name = NULL;
int32_t buflen = 512;
UErrorCode status = U_ZERO_ERROR;
char* utf8value = NULL;
int utf8value_len = 0;
char* msg = NULL;
int grOffset = 0;
intl_error_reset( NULL TSRMLS_CC );
if(zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s|s",
&loc_name, &loc_name_len ,
&disp_loc_name ,&disp_loc_name_len ) == FAILURE)
{
spprintf(&msg , 0, "locale_get_display_%s : unable to parse input params", tag_name );
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, msg , 1 TSRMLS_CC );
efree(msg);
RETURN_FALSE;
}
if(loc_name_len > ULOC_FULLNAME_CAPACITY) {
/* See bug 67397: overlong locale names cause trouble in uloc_getDisplayName */
spprintf(&msg , 0, "locale_get_display_%s : name too long", tag_name );
intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, msg , 1 TSRMLS_CC );
efree(msg);
RETURN_FALSE;
}
if(loc_name_len == 0) {
loc_name = intl_locale_get_default(TSRMLS_C);
}
if( strcmp(tag_name, DISP_NAME) != 0 ){
/* Handle grandfathered languages */
grOffset = findOffset( LOC_GRANDFATHERED , loc_name );
if( grOffset >= 0 ){
if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
mod_loc_name = getPreferredTag( loc_name );
} else {
/* Since Grandfathered, no value, do nothing, retutn NULL */
RETURN_FALSE;
}
}
} /* end of if != LOC_CANONICAL_TAG */
if( mod_loc_name==NULL ){
mod_loc_name = estrdup( loc_name );
}
/* Check if disp_loc_name passed , if not use default locale */
if( !disp_loc_name){
disp_loc_name = estrdup(intl_locale_get_default(TSRMLS_C));
free_loc_name = 1;
}
/* Get the disp_value for the given locale */
do{
disp_name = erealloc( disp_name , buflen * sizeof(UChar) );
disp_name_len = buflen;
if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
buflen = uloc_getDisplayLanguage ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status);
} else if( strcmp(tag_name , LOC_SCRIPT_TAG)==0 ){
buflen = uloc_getDisplayScript ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status);
} else if( strcmp(tag_name , LOC_REGION_TAG)==0 ){
buflen = uloc_getDisplayCountry ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status);
} else if( strcmp(tag_name , LOC_VARIANT_TAG)==0 ){
buflen = uloc_getDisplayVariant ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status);
} else if( strcmp(tag_name , DISP_NAME)==0 ){
buflen = uloc_getDisplayName ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status);
}
/* U_STRING_NOT_TERMINATED_WARNING is admissible here; don't look for it */
if( U_FAILURE( status ) )
{
if( status == U_BUFFER_OVERFLOW_ERROR )
{
status = U_ZERO_ERROR;
continue;
}
spprintf(&msg, 0, "locale_get_display_%s : unable to get locale %s", tag_name , tag_name );
//.........这里部分代码省略.........
示例4: PHP_METHOD
/**
* Gets the column name in PostgreSQL
*
* @param Phalcon\Db\Column $column
*/
PHP_METHOD(Phalcon_Db_Dialect_Postgresql, getColumnDefinition){
zval *column = NULL, *size = NULL, *column_type = NULL, *column_sql = NULL;
zval *scale = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &column) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (Z_TYPE_P(column) != IS_OBJECT) {
PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Column definition must be an instance of Phalcon\\Db\\Column");
return;
}
PHALCON_INIT_VAR(size);
PHALCON_CALL_METHOD(size, column, "getsize", PH_NO_CHECK);
PHALCON_INIT_VAR(column_type);
PHALCON_CALL_METHOD(column_type, column, "gettype", PH_NO_CHECK);
if (phalcon_compare_strict_long(column_type, 0 TSRMLS_CC)) {
PHALCON_INIT_VAR(column_sql);
ZVAL_STRING(column_sql, "INT", 1);
goto ph_end_0;
}
if (phalcon_compare_strict_long(column_type, 1 TSRMLS_CC)) {
PHALCON_INIT_VAR(column_sql);
ZVAL_STRING(column_sql, "DATE", 1);
goto ph_end_0;
}
if (phalcon_compare_strict_long(column_type, 2 TSRMLS_CC)) {
PHALCON_INIT_VAR(column_sql);
PHALCON_CONCAT_SVS(column_sql, "CHARACTER VARYING(", size, ")");
goto ph_end_0;
}
if (phalcon_compare_strict_long(column_type, 3 TSRMLS_CC)) {
PHALCON_INIT_VAR(scale);
PHALCON_CALL_METHOD(scale, column, "getscale", PH_NO_CHECK);
PHALCON_INIT_VAR(column_sql);
PHALCON_CONCAT_SVSVS(column_sql, "NUMERIC(", size, ",", scale, ")");
goto ph_end_0;
}
if (phalcon_compare_strict_long(column_type, 4 TSRMLS_CC)) {
PHALCON_INIT_VAR(column_sql);
ZVAL_STRING(column_sql, "TIMESTAMP", 1);
goto ph_end_0;
}
if (phalcon_compare_strict_long(column_type, 5 TSRMLS_CC)) {
PHALCON_INIT_VAR(column_sql);
PHALCON_CONCAT_SVS(column_sql, "CHARACTER(", size, ")");
goto ph_end_0;
}
if (phalcon_compare_strict_long(column_type, 6 TSRMLS_CC)) {
PHALCON_INIT_VAR(column_sql);
ZVAL_STRING(column_sql, "TEXT", 1);
goto ph_end_0;
}
if (phalcon_compare_strict_long(column_type, 7 TSRMLS_CC)) {
PHALCON_INIT_VAR(column_sql);
ZVAL_STRING(column_sql, "FLOAT", 1);
goto ph_end_0;
}
PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "Unrecognized PostgreSQL data type");
return;
ph_end_0:
RETURN_CTOR(column_sql);
}
示例5: _php_intlrbbi_constructor_body
static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
{
zval *object = getThis();
char *rules;
int rules_len;
zend_bool compiled = 0;
UErrorCode status = U_ZERO_ERROR;
intl_error_reset(NULL TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b",
&rules, &rules_len, &compiled) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"rbbi_create_instance: bad arguments", 0 TSRMLS_CC);
RETURN_NULL();
}
// instantiation of ICU object
RuleBasedBreakIterator *rbbi;
if (!compiled) {
UnicodeString rulesStr;
UParseError parseError = UParseError();
if (intl_stringFromChar(rulesStr, rules, rules_len, &status)
== FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"rbbi_create_instance: rules were not a valid UTF-8 string",
0 TSRMLS_CC);
RETURN_NULL();
}
rbbi = new RuleBasedBreakIterator(rulesStr, parseError, status);
intl_error_set_code(NULL, status TSRMLS_CC);
if (U_FAILURE(status)) {
char *msg;
smart_str parse_error_str;
parse_error_str = intl_parse_error_to_string(&parseError);
spprintf(&msg, 0, "rbbi_create_instance: unable to create "
"RuleBasedBreakIterator from rules (%s)", parse_error_str.c);
smart_str_free(&parse_error_str);
intl_error_set_custom_msg(NULL, msg, 1 TSRMLS_CC);
efree(msg);
delete rbbi;
RETURN_NULL();
}
} else { // compiled
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
rbbi = new RuleBasedBreakIterator((uint8_t*)rules, rules_len, status);
if (U_FAILURE(status)) {
intl_error_set(NULL, status, "rbbi_create_instance: unable to "
"create instance from compiled rules", 0 TSRMLS_CC);
delete rbbi;
RETURN_NULL();
}
#else
intl_error_set(NULL, U_UNSUPPORTED_ERROR, "rbbi_create_instance: "
"compiled rules require ICU >= 4.8", 0 TSRMLS_CC);
RETURN_NULL();
#endif
}
breakiterator_object_create(return_value, rbbi TSRMLS_CC);
}
示例6: PHP_FUNCTION
/* {{{ proto int pspell_config_create(string language [, string spelling [, string jargon [, string encoding]]])
Create a new config to be used later to create a manager */
static PHP_FUNCTION(pspell_config_create)
{
char *language, *spelling = NULL, *jargon = NULL, *encoding = NULL;
size_t language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0;
zval *ind;
PspellConfig *config;
#ifdef PHP_WIN32
TCHAR aspell_dir[200];
TCHAR data_dir[220];
TCHAR dict_dir[220];
HKEY hkey;
DWORD dwType,dwLen;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|sss", &language, &language_len, &spelling, &spelling_len,
&jargon, &jargon_len, &encoding, &encoding_len) == FAILURE) {
return;
}
config = new_pspell_config();
#ifdef PHP_WIN32
/* If aspell was installed using installer, we should have a key
* pointing to the location of the dictionaries
*/
if (0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
LONG result;
dwLen = sizeof(aspell_dir) - 1;
result = RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir, &dwLen);
RegCloseKey(hkey);
if (result == ERROR_SUCCESS) {
strlcpy(data_dir, aspell_dir, sizeof(data_dir));
strlcat(data_dir, "\\data", sizeof(data_dir));
strlcpy(dict_dir, aspell_dir, sizeof(dict_dir));
strlcat(dict_dir, "\\dict", sizeof(dict_dir));
pspell_config_replace(config, "data-dir", data_dir);
pspell_config_replace(config, "dict-dir", dict_dir);
}
}
#endif
pspell_config_replace(config, "language-tag", language);
if (spelling_len) {
pspell_config_replace(config, "spelling", spelling);
}
if (jargon_len) {
pspell_config_replace(config, "jargon", jargon);
}
if (encoding_len) {
pspell_config_replace(config, "encoding", encoding);
}
/* By default I do not want to write anything anywhere because it'll try to write to $HOME
which is not what we want */
pspell_config_replace(config, "save-repl", "false");
ind = zend_list_insert(config, le_pspell_config);
RETURN_LONG(Z_RES_HANDLE_P(ind));
}
示例7: PHP_METHOD
PHP_METHOD(Edge_Loader, autoload)
{
char *class_name;
char *dir = NULL;
int cnlen;
int drlen;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &class_name, &cnlen, &dir, &drlen) == FAILURE)
{
printf("autoload get class name error\n");
return;
}
char *_home_path = NULL;
char *file;
char *delim = "_";
if(dir == NULL)
{
char *lib_path = "LIB_PATH";
int lib_path_len = strlen(lib_path);
zval c;
if (zend_get_constant_ex(lib_path, lib_path_len, &c, NULL, ZEND_FETCH_CLASS_SILENT TSRMLS_CC)) {
_home_path = estrdup(Z_STRVAL(c));
zval_dtor(&c);
} else {
_home_path = estrdup("IfLib/");
}
}else
{
_home_path = estrdup(dir);
}
if(!strncmp(class_name, "If", 2) || !strncmp(class_name, "IF", 2))
{
strtok(class_name, delim);
file = strtok(NULL, delim);
}else
{
class_name[0] = toupper(class_name[0]);
file = class_name;
}
char *include_file_path;
/*
include_file_path = emalloc(sizeof(char *) * strlen(EDGE_G(root_path)) +
sizeof(char *) * strlen(_home_path) +
sizeof(char *) * strlen(file) +
sizeof(char *) * strlen(".php"));
*/
/*
strcpy(include_file_path, EDGE_G(root_path));
strcat(include_file_path, _home_path);
strcat(include_file_path, file);
strcat(include_file_path, ".php");
*/
spprintf(&include_file_path, 0, "%s%s%s%s", EDGE_G(root_path), _home_path, file, ".php");
zval *func_name;
MAKE_STD_ZVAL(func_name);
ZVAL_STRING(func_name, "file_exists", 1);
zval **call_args[1];
zval *str;
MAKE_STD_ZVAL(str);
ZVAL_STRING(str, include_file_path, 1);
call_args[0] = &str;
zval *ret, *fret;
MAKE_STD_ZVAL(ret);
if(call_user_function_ex(CG(function_table), NULL, func_name, &fret, 1, call_args, 0, NULL TSRMLS_CC) == FAILURE)
{
ZVAL_FALSE(ret);
RETURN_ZVAL(ret, 1, 1);
}
if(!Z_BVAL_P(fret))
{
efree(_home_path);
efree(include_file_path);
zval_ptr_dtor(&func_name);
zval_ptr_dtor(&fret);
zval_ptr_dtor(*call_args);
ZVAL_FALSE(ret);
RETURN_ZVAL(ret, 1, 1);
}
if(!edge_file_include(include_file_path))
{
efree(_home_path);
efree(include_file_path);
ZVAL_FALSE(ret);
}else{
efree(_home_path);
efree(include_file_path);
ZVAL_TRUE(ret);
}
zval_ptr_dtor(&func_name);
zval_ptr_dtor(*call_args);
zval_ptr_dtor(&fret);
RETURN_ZVAL(ret, 1, 1);
}
示例8: PHP_METHOD
/**
* Applies the internal format to the message
*
* @param string $message
* @param int $type
* @param int $time
* @return string
*/
PHP_METHOD(Phalcon_Logger_Adapter_File, _applyFormat){
zval *message = NULL, *type = NULL, *time = NULL, *format = NULL;
zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL;
zval *t0 = NULL, *t1 = NULL;
zval *c0 = NULL, *c1 = NULL, *c2 = NULL;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &message, &type, &time) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
if (!time) {
PHALCON_INIT_VAR(time);
ZVAL_LONG(time, 0);
} else {
PHALCON_SEPARATE_PARAM(time);
}
if (!zend_is_true(time)) {
PHALCON_ALLOC_ZVAL_MM(r0);
PHALCON_CALL_FUNC(r0, "time", 0x018);
PHALCON_CPY_WRT(time, r0);
}
PHALCON_ALLOC_ZVAL_MM(t0);
phalcon_read_property(&t0, this_ptr, "_format", sizeof("_format")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_CPY_WRT(format, t0);
PHALCON_ALLOC_ZVAL_MM(r1);
PHALCON_INIT_VAR(c0);
ZVAL_STRING(c0, "%date%", 1);
PHALCON_ALLOC_ZVAL_MM(r2);
PHALCON_ALLOC_ZVAL_MM(t1);
phalcon_read_property(&t1, this_ptr, "_dateFormat", sizeof("_dateFormat")-1, PHALCON_NOISY TSRMLS_CC);
PHALCON_CALL_FUNC_PARAMS_2(r2, "date", t1, time, 0x04E);
PHALCON_CALL_FUNC_PARAMS_3(r1, "str_replace", c0, r2, format, 0x003);
PHALCON_CPY_WRT(format, r1);
PHALCON_ALLOC_ZVAL_MM(r3);
PHALCON_INIT_VAR(c1);
ZVAL_STRING(c1, "%type%", 1);
PHALCON_ALLOC_ZVAL_MM(r4);
PHALCON_CALL_METHOD_PARAMS_1(r4, this_ptr, "gettypestring", type, PHALCON_NO_CHECK);
PHALCON_CALL_FUNC_PARAMS_3(r3, "str_replace", c1, r4, format, 0x003);
PHALCON_CPY_WRT(format, r3);
PHALCON_ALLOC_ZVAL_MM(r5);
PHALCON_INIT_VAR(c2);
ZVAL_STRING(c2, "%message%", 1);
PHALCON_CALL_FUNC_PARAMS_3(r5, "str_replace", c2, message, format, 0x003);
PHALCON_CPY_WRT(format, r5);
PHALCON_RETURN_CHECK_CTOR(format);
}
示例9: ZEND_FUNCTION
/* {{{ proto array accelerator_get_status([bool fetch_scripts])
Obtain statistics information regarding code acceleration */
static ZEND_FUNCTION(opcache_get_status)
{
long reqs;
zval *memory_usage,*statistics,*scripts;
zend_bool fetch_scripts = 1;
/* keep the compiler happy */
(void)ht; (void)return_value_ptr; (void)this_ptr; (void)return_value_used;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &fetch_scripts) == FAILURE) {
return;
}
if (!validate_api_restriction(TSRMLS_C)) {
RETURN_FALSE;
}
if (!accel_startup_ok) {
RETURN_FALSE;
}
array_init(return_value);
/* Trivia */
add_assoc_bool(return_value, "opcache_enabled", ZCG(enabled) && (ZCG(counted) || ZCSG(accelerator_enabled)));
add_assoc_bool(return_value, "cache_full", ZSMMG(memory_exhausted));
add_assoc_bool(return_value, "restart_pending", ZCSG(restart_pending));
add_assoc_bool(return_value, "restart_in_progress", ZCSG(restart_in_progress));
/* Memory usage statistics */
MAKE_STD_ZVAL(memory_usage);
array_init(memory_usage);
add_assoc_long(memory_usage, "used_memory", ZCG(accel_directives).memory_consumption-zend_shared_alloc_get_free_memory()-ZSMMG(wasted_shared_memory));
add_assoc_long(memory_usage, "free_memory", zend_shared_alloc_get_free_memory());
add_assoc_long(memory_usage, "wasted_memory", ZSMMG(wasted_shared_memory));
add_assoc_double(memory_usage, "current_wasted_percentage", (((double) ZSMMG(wasted_shared_memory))/ZCG(accel_directives).memory_consumption)*100.0);
add_assoc_zval(return_value, "memory_usage", memory_usage);
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
if (ZCSG(interned_strings_start) && ZCSG(interned_strings_end) && ZCSG(interned_strings_top)) {
zval *interned_strings_usage;
MAKE_STD_ZVAL(interned_strings_usage);
array_init(interned_strings_usage);
add_assoc_long(interned_strings_usage, "buffer_size", ZCSG(interned_strings_end) - ZCSG(interned_strings_start));
add_assoc_long(interned_strings_usage, "used_memory", ZCSG(interned_strings_top) - ZCSG(interned_strings_start));
add_assoc_long(interned_strings_usage, "free_memory", ZCSG(interned_strings_end) - ZCSG(interned_strings_top));
add_assoc_long(interned_strings_usage, "number_of_strings", ZCSG(interned_strings).nNumOfElements);
add_assoc_zval(return_value, "interned_strings_usage", interned_strings_usage);
}
#endif
/* Accelerator statistics */
MAKE_STD_ZVAL(statistics);
array_init(statistics);
add_assoc_long(statistics, "num_cached_scripts", ZCSG(hash).num_direct_entries);
add_assoc_long(statistics, "num_cached_keys", ZCSG(hash).num_entries);
add_assoc_long(statistics, "max_cached_keys", ZCSG(hash).max_num_entries);
add_assoc_long(statistics, "hits", ZCSG(hits));
add_assoc_long(statistics, "start_time", ZCSG(start_time));
add_assoc_long(statistics, "last_restart_time", ZCSG(last_restart_time));
add_assoc_long(statistics, "oom_restarts", ZCSG(oom_restarts));
add_assoc_long(statistics, "hash_restarts", ZCSG(hash_restarts));
add_assoc_long(statistics, "manual_restarts", ZCSG(manual_restarts));
add_assoc_long(statistics, "misses", ZSMMG(memory_exhausted)?ZCSG(misses):ZCSG(misses)-ZCSG(blacklist_misses));
add_assoc_long(statistics, "blacklist_misses", ZCSG(blacklist_misses));
reqs = ZCSG(hits)+ZCSG(misses);
add_assoc_double(statistics, "blacklist_miss_ratio", reqs?(((double) ZCSG(blacklist_misses))/reqs)*100.0:0);
add_assoc_double(statistics, "opcache_hit_rate", reqs?(((double) ZCSG(hits))/reqs)*100.0:0);
add_assoc_zval(return_value, "opcache_statistics", statistics);
if (fetch_scripts) {
/* accelerated scripts */
scripts = accelerator_get_scripts(TSRMLS_C);
if (scripts) {
add_assoc_zval(return_value, "scripts", scripts);
}
}
}
示例10: PHP_METHOD
/**
* Outputs a message formatting it with HTML
*
* @param string $type
* @param string $message
*/
PHP_METHOD(Phalcon_Flash, outputMessage){
zval *type = NULL, *message = NULL, *automatic_html = NULL, *classes = NULL;
zval *type_classes = NULL, *joined_classes = NULL, *css_classes = NULL;
zval *eol = NULL, *implicit_flush = NULL, *content = NULL, *msg = NULL, *html_message = NULL;
zval *c0 = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
int eval_int;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &type, &message) == FAILURE) {
PHALCON_MM_RESTORE();
RETURN_NULL();
}
PHALCON_INIT_VAR(automatic_html);
phalcon_read_property(&automatic_html, this_ptr, SL("_automaticHtml"), PH_NOISY_CC);
if (PHALCON_IS_TRUE(automatic_html)) {
PHALCON_INIT_VAR(classes);
phalcon_read_property(&classes, this_ptr, SL("_cssClasses"), PH_NOISY_CC);
eval_int = phalcon_array_isset(classes, type);
if (eval_int) {
PHALCON_INIT_VAR(type_classes);
phalcon_array_fetch(&type_classes, classes, type, PH_NOISY_CC);
if (Z_TYPE_P(type_classes) == IS_ARRAY) {
PHALCON_INIT_VAR(c0);
ZVAL_STRING(c0, " ", 1);
PHALCON_INIT_VAR(joined_classes);
phalcon_fast_join(joined_classes, c0, type_classes TSRMLS_CC);
PHALCON_INIT_VAR(css_classes);
PHALCON_CONCAT_SVS(css_classes, " class=\"", joined_classes, "\"");
} else {
PHALCON_INIT_VAR(css_classes);
PHALCON_CONCAT_SVS(css_classes, " class=\"", type_classes, "\"");
}
} else {
PHALCON_INIT_VAR(css_classes);
ZVAL_STRING(css_classes, "", 1);
}
PHALCON_INIT_VAR(eol);
zend_get_constant(SL("PHP_EOL"), eol TSRMLS_CC);
}
PHALCON_INIT_VAR(implicit_flush);
phalcon_read_property(&implicit_flush, this_ptr, SL("_implicitFlush"), PH_NOISY_CC);
if (Z_TYPE_P(message) == IS_ARRAY) {
if (PHALCON_IS_FALSE(implicit_flush)) {
PHALCON_INIT_VAR(content);
ZVAL_STRING(content, "", 1);
}
if (!phalcon_valid_foreach(message TSRMLS_CC)) {
return;
}
ah0 = Z_ARRVAL_P(message);
zend_hash_internal_pointer_reset_ex(ah0, &hp0);
fes_3b3c_0:
if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
goto fee_3b3c_0;
}
PHALCON_INIT_VAR(msg);
ZVAL_ZVAL(msg, *hd, 1, 0);
if (PHALCON_IS_TRUE(automatic_html)) {
PHALCON_INIT_VAR(html_message);
PHALCON_CONCAT_SVSVSV(html_message, "<div", css_classes, ">", msg, "</div>", eol);
} else {
PHALCON_CPY_WRT(html_message, msg);
}
if (PHALCON_IS_TRUE(implicit_flush)) {
zend_print_zval(html_message, 1);
} else {
phalcon_concat_self(&content, html_message TSRMLS_CC);
}
zend_hash_move_forward_ex(ah0, &hp0);
goto fes_3b3c_0;
fee_3b3c_0:
if (PHALCON_IS_FALSE(implicit_flush)) {
RETURN_CTOR(content);
}
} else {
if (PHALCON_IS_TRUE(automatic_html)) {
PHALCON_INIT_VAR(html_message);
PHALCON_CONCAT_SVSVSV(html_message, "<div", css_classes, ">", message, "</div>", eol);
} else {
PHALCON_CPY_WRT(html_message, message);
}
//.........这里部分代码省略.........
示例11: ZEND_METHOD
/* {{{ proto mixed Closure::call(object to [, mixed parameter] [, mixed ...] )
Call closure, binding to a given object with its class as the scope */
ZEND_METHOD(Closure, call)
{
zval *zclosure, *newthis, closure_result;
zend_closure *closure;
zend_fcall_info fci;
zend_fcall_info_cache fci_cache;
zval *my_params;
int my_param_count = 0;
zend_function my_function;
zend_object *newobj;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o*", &newthis, &my_params, &my_param_count) == FAILURE) {
return;
}
zclosure = getThis();
closure = (zend_closure *) Z_OBJ_P(zclosure);
newobj = Z_OBJ_P(newthis);
if (!zend_valid_closure_binding(closure, newthis, Z_OBJCE_P(newthis))) {
return;
}
/* This should never happen as closures will always be callable */
if (zend_fcall_info_init(zclosure, 0, &fci, &fci_cache, NULL, NULL) != SUCCESS) {
ZEND_ASSERT(0);
}
fci.retval = &closure_result;
fci.params = my_params;
fci.param_count = my_param_count;
fci.object = fci_cache.object = newobj;
fci_cache.initialized = 1;
fci_cache.called_scope = Z_OBJCE_P(newthis);
if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_GENERATOR) {
zval new_closure;
zend_create_closure(&new_closure, fci_cache.function_handler, Z_OBJCE_P(newthis), closure->called_scope, newthis);
closure = (zend_closure *) Z_OBJ(new_closure);
fci_cache.function_handler = &closure->func;
} else {
memcpy(&my_function, fci_cache.function_handler, fci_cache.function_handler->type == ZEND_USER_FUNCTION ? sizeof(zend_op_array) : sizeof(zend_internal_function));
/* use scope of passed object */
my_function.common.scope = Z_OBJCE_P(newthis);
fci_cache.function_handler = &my_function;
/* Runtime cache relies on bound scope to be immutable, hence we need a separate rt cache in case scope changed */
if (ZEND_USER_CODE(my_function.type) && closure->func.common.scope != Z_OBJCE_P(newthis)) {
my_function.op_array.run_time_cache = emalloc(my_function.op_array.cache_size);
memset(my_function.op_array.run_time_cache, 0, my_function.op_array.cache_size);
}
}
if (zend_call_function(&fci, &fci_cache) == SUCCESS && Z_TYPE(closure_result) != IS_UNDEF) {
if (Z_ISREF(closure_result)) {
zend_unwrap_reference(&closure_result);
}
ZVAL_COPY_VALUE(return_value, &closure_result);
}
if (fci_cache.function_handler->common.fn_flags & ZEND_ACC_GENERATOR) {
/* copied upon generator creation */
--GC_REFCOUNT(&closure->std);
} else if (ZEND_USER_CODE(my_function.type) && closure->func.common.scope != Z_OBJCE_P(newthis)) {
efree(my_function.op_array.run_time_cache);
}
}
示例12: _php_image_output_ctx
/* {{{ _php_image_output_ctx */
static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)())
{
zval *imgind;
char *file = NULL;
int file_len = 0;
long quality, basefilter;
gdImagePtr im;
FILE *fp = NULL;
int argc = ZEND_NUM_ARGS();
int q = -1, i;
int f = -1;
gdIOCtx *ctx;
/* The third (quality) parameter for Wbmp stands for the threshold when called from image2wbmp().
* The third (quality) parameter for Wbmp and Xbm stands for the foreground color index when called
* from imagey<type>().
*/
if (image_type == PHP_GDIMG_TYPE_XBM) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs!|ll", &imgind, &file, &file_len, &quality, &basefilter) == FAILURE) {
return;
}
} else {
/* PHP_GDIMG_TYPE_GIF
* PHP_GDIMG_TYPE_PNG
* PHP_GDIMG_TYPE_JPG
* PHP_GDIMG_TYPE_WBM */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|s!ll", &imgind, &file, &file_len, &quality, &basefilter) == FAILURE) {
return;
}
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &imgind, -1, "Image", phpi_get_le_gd());
if (argc > 1) {
if (argc >= 3) {
q = quality; /* or colorindex for foreground of BW images (defaults to black) */
if (argc == 4) {
f = basefilter;
}
}
}
if (argc > 1 && file_len) {
PHP_GD_CHECK_OPEN_BASEDIR(file, "Invalid filename");
fp = VCWD_FOPEN(file, "wb");
if (!fp) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for writing: %s", file, strerror(errno));
RETURN_FALSE;
}
ctx = gdNewFileCtx(fp);
} else {
ctx = emalloc(sizeof(gdIOCtx));
ctx->putC = _php_image_output_putc;
ctx->putBuf = _php_image_output_putbuf;
ctx->gd_free = _php_image_output_ctxfree;
}
switch(image_type) {
case PHP_GDIMG_CONVERT_WBM:
if(q<0||q>255) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid threshold value '%d'. It must be between 0 and 255", q);
}
case PHP_GDIMG_TYPE_JPG:
(*func_p)(im, ctx, q);
break;
case PHP_GDIMG_TYPE_PNG:
(*func_p)(im, ctx, q, f);
break;
case PHP_GDIMG_TYPE_XBM:
case PHP_GDIMG_TYPE_WBM:
if (argc < 3) {
for(i=0; i < gdImageColorsTotal(im); i++) {
if(!gdImageRed(im, i) && !gdImageGreen(im, i) && !gdImageBlue(im, i)) break;
}
q = i;
}
if (image_type == PHP_GDIMG_TYPE_XBM) {
(*func_p)(im, file, q, ctx);
} else {
(*func_p)(im, q, ctx);
}
break;
default:
(*func_p)(im, ctx);
break;
}
ctx->gd_free(ctx);
if(fp) {
fflush(fp);
fclose(fp);
}
RETURN_TRUE;
}
示例13: php_hash_do_hash
static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_bool raw_output_default) /* {{{ */
{
zend_string *digest;
char *algo, *data;
size_t algo_len, data_len;
zend_bool raw_output = raw_output_default;
const php_hash_ops *ops;
void *context;
php_stream *stream = NULL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|b", &algo, &algo_len, &data, &data_len, &raw_output) == FAILURE) {
return;
}
ops = php_hash_fetch_ops(algo, algo_len);
if (!ops) {
php_error_docref(NULL, E_WARNING, "Unknown hashing algorithm: %s", algo);
RETURN_FALSE;
}
if (isfilename) {
if (CHECK_NULL_PATH(data, data_len)) {
RETURN_FALSE;
}
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
if (!stream) {
/* Stream will report errors opening file */
RETURN_FALSE;
}
}
context = emalloc(ops->context_size);
ops->hash_init(context);
if (isfilename) {
char buf[1024];
size_t n;
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
ops->hash_update(context, (unsigned char *) buf, n);
}
php_stream_close(stream);
} else {
ops->hash_update(context, (unsigned char *) data, data_len);
}
digest = zend_string_alloc(ops->digest_size, 0);
ops->hash_final((unsigned char *) digest->val, context);
efree(context);
if (raw_output) {
digest->val[ops->digest_size] = 0;
RETURN_NEW_STR(digest);
} else {
zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0);
php_hash_bin2hex(hex_digest->val, (unsigned char *) digest->val, ops->digest_size);
hex_digest->val[2 * ops->digest_size] = 0;
zend_string_release(digest);
RETURN_NEW_STR(hex_digest);
}
}
示例14: PHP_METHOD
/**
* Returns an array of Phalcon\Db\Column objects describing a table
*
* <code>
* print_r($connection->describeColumns("posts")); ?>
* </code>
*
* @param string $table
* @param string $schema
* @return Phalcon\Db\Column[]
*/
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, describeColumns){
zval *table, *schema = NULL, *columns, *dialect, *size_pattern;
zval *sql, *fetch_assoc, *describe, *old_column = NULL;
zval *field = NULL, *definition = NULL, *column_type = NULL, *pos = NULL, *attribute = NULL;
zval *matches = NULL, *match_one = NULL, *column_name = NULL, *column = NULL;
HashTable *ah0;
HashPosition hp0;
zval **hd;
PHALCON_MM_GROW();
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|z", &table, &schema) == FAILURE) {
RETURN_MM_NULL();
}
if (!schema) {
PHALCON_INIT_VAR(schema);
}
PHALCON_INIT_VAR(columns);
array_init(columns);
PHALCON_OBS_VAR(dialect);
phalcon_read_property(&dialect, this_ptr, SL("_dialect"), PH_NOISY_CC);
PHALCON_INIT_VAR(size_pattern);
ZVAL_STRING(size_pattern, "#\\(([0-9]+)(,[0-9]+)*\\)#", 1);
PHALCON_INIT_VAR(sql);
PHALCON_CALL_METHOD_PARAMS_2(sql, dialect, "describecolumns", table, schema);
PHALCON_INIT_VAR(fetch_assoc);
phalcon_get_class_constant(fetch_assoc, phalcon_db_ce, SS("FETCH_ASSOC") TSRMLS_CC);
PHALCON_INIT_VAR(describe);
PHALCON_CALL_METHOD_PARAMS_2(describe, this_ptr, "fetchall", sql, fetch_assoc);
PHALCON_INIT_VAR(old_column);
if (!phalcon_is_iterable(describe, &ah0, &hp0, 0, 0 TSRMLS_CC)) {
return;
}
while (zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) == SUCCESS) {
PHALCON_GET_FOREACH_VALUE(field);
PHALCON_INIT_NVAR(definition);
array_init_size(definition, 1);
add_assoc_long_ex(definition, SS("bindType"), 2);
PHALCON_OBS_NVAR(column_type);
phalcon_array_fetch_string(&column_type, field, SL("type"), PH_NOISY_CC);
PHALCON_INIT_NVAR(pos);
phalcon_fast_stripos_str(pos, column_type, SL("int") TSRMLS_CC);
if (PHALCON_IS_NOT_FALSE(pos)) {
phalcon_array_update_string_long(&definition, SL("type"), 0, PH_SEPARATE TSRMLS_CC);
phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC);
phalcon_array_update_string_long(&definition, SL("bindType"), 1, PH_SEPARATE TSRMLS_CC);
PHALCON_OBS_NVAR(attribute);
phalcon_array_fetch_string(&attribute, field, SL("pk"), PH_NOISY_CC);
if (zend_is_true(attribute)) {
phalcon_array_update_string_bool(&definition, SL("autoIncrement"), 1, PH_SEPARATE TSRMLS_CC);
}
} else {
if (phalcon_memnstr_str(column_type, SL("varchar") TSRMLS_CC)) {
phalcon_array_update_string_long(&definition, SL("type"), 2, PH_SEPARATE TSRMLS_CC);
} else {
if (phalcon_memnstr_str(column_type, SL("date") TSRMLS_CC)) {
phalcon_array_update_string_long(&definition, SL("type"), 1, PH_SEPARATE TSRMLS_CC);
} else {
if (phalcon_memnstr_str(column_type, SL("decimal") TSRMLS_CC)) {
phalcon_array_update_string_long(&definition, SL("type"), 3, PH_SEPARATE TSRMLS_CC);
phalcon_array_update_string_bool(&definition, SL("isNumeric"), 1, PH_SEPARATE TSRMLS_CC);
phalcon_array_update_string_long(&definition, SL("bindType"), 32, PH_SEPARATE TSRMLS_CC);
} else {
if (phalcon_memnstr_str(column_type, SL("char") TSRMLS_CC)) {
phalcon_array_update_string_long(&definition, SL("type"), 5, PH_SEPARATE TSRMLS_CC);
} else {
if (phalcon_memnstr_str(column_type, SL("datetime") TSRMLS_CC)) {
phalcon_array_update_string_long(&definition, SL("type"), 4, PH_SEPARATE TSRMLS_CC);
} else {
if (phalcon_memnstr_str(column_type, SL("text") TSRMLS_CC)) {
phalcon_array_update_string_long(&definition, SL("type"), 6, PH_SEPARATE TSRMLS_CC);
} else {
if (phalcon_memnstr_str(column_type, SL("float") TSRMLS_CC)) {
//.........这里部分代码省略.........
示例15: SPL_METHOD
/* {{{ proto void SplDoublyLinkedList::offsetUnset(mixed index)
Unsets the value at the specified $index. */
SPL_METHOD(SplDoublyLinkedList, offsetUnset)
{
zval *zindex;
zend_long index;
spl_dllist_object *intern;
spl_ptr_llist_element *element;
spl_ptr_llist *llist;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zindex) == FAILURE) {
return;
}
intern = Z_SPLDLLIST_P(ZEND_THIS);
index = spl_offset_convert_to_long(zindex);
llist = intern->llist;
if (index < 0 || index >= intern->llist->count) {
zend_throw_exception(spl_ce_OutOfRangeException, "Offset out of range", 0);
return;
}
element = spl_ptr_llist_offset(intern->llist, index, intern->flags & SPL_DLLIST_IT_LIFO);
if (element != NULL) {
/* connect the neightbors */
if (element->prev) {
element->prev->next = element->next;
}
if (element->next) {
element->next->prev = element->prev;
}
/* take care of head/tail */
if (element == llist->head) {
llist->head = element->next;
}
if (element == llist->tail) {
llist->tail = element->prev;
}
/* finally, delete the element */
llist->count--;
if(llist->dtor) {
llist->dtor(element);
}
if (intern->traverse_pointer == element) {
SPL_LLIST_DELREF(element);
intern->traverse_pointer = NULL;
}
zval_ptr_dtor(&element->data);
ZVAL_UNDEF(&element->data);
SPL_LLIST_DELREF(element);
} else {
zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0);
return;
}
} /* }}} */