// Copied from ext/standard/array.c static int php_bencode_key_compare_string(const void *a, const void *b) /* {{{ */ { Bucket *f = (Bucket *) a; Bucket *s = (Bucket *) b; char *s1, *s2; size_t l1, l2; char buf1[MAX_LENGTH_OF_LONG + 1]; char buf2[MAX_LENGTH_OF_LONG + 1]; if (f->key) { s1 = f->key->val; l1 = f->key->len; } else { s1 = zend_print_long_to_buf(buf1 + sizeof(buf1) - 1, f->h); l1 = buf1 + sizeof(buf1) - 1 - s1; } if (s->key) { s2 = s->key->val; l2 = s->key->len; } else { s2 = zend_print_long_to_buf(buf2 + sizeof(buf2) - 1, s->h); l2 = buf2 + sizeof(buf2) - 1 - s1; } return zend_binary_strcmp(s1, l1, s2, l2); }
/* {{{ write_property handler */ static zval *Transliterator_write_property( zval *object, zval *member, zval *value, void **cache_slot ) { zend_class_entry *scope; TRANSLITERATOR_PROPERTY_HANDLER_PROLOG; if (EG(fake_scope)) { scope = EG(fake_scope); } else { scope = zend_get_executed_scope(); } if( ( scope != Transliterator_ce_ptr ) && ( zend_binary_strcmp( "id", sizeof( "id" ) - 1, Z_STRVAL_P( member ), Z_STRLEN_P( member ) ) == 0 ) ) { php_error_docref0( NULL, E_WARNING, "The property \"id\" is read-only" ); } else { value = zend_std_write_property( object, member, value, cache_slot ); } TRANSLITERATOR_PROPERTY_HANDLER_EPILOG; return value; }
/** * Natural compare with string operandus on right */ int phalcon_compare_strict_string(zval *op1, const char *op2, int op2_length){ switch (Z_TYPE_P(op1)) { case IS_STRING: if (!Z_STRLEN_P(op1) && !op2_length) { return 1; } if (Z_STRLEN_P(op1) != op2_length) { return 0; } return !zend_binary_strcmp(Z_STRVAL_P(op1), Z_STRLEN_P(op1), op2, op2_length); case IS_NULL: return !zend_binary_strcmp("", 0, op2, op2_length); case IS_BOOL: if (!Z_BVAL_P(op1)) { return !zend_binary_strcmp("0", strlen("0"), op2, op2_length); } else { return !zend_binary_strcmp("1", strlen("1"), op2, op2_length); } } return 0; }
/** * Used for sorting directories alphabetically */ static int phar_compare_dir_name(const void *a, const void *b) /* {{{ */ { Bucket *f; Bucket *s; int result; f = (Bucket *) a; s = (Bucket *) b; result = zend_binary_strcmp(ZSTR_VAL(f->key), ZSTR_LEN(f->key), ZSTR_VAL(s->key), ZSTR_LEN(s->key)); if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } }
/* {{{ get_property_ptr_ptr handler */ static zval *Transliterator_get_property_ptr_ptr( zval *object, zval *member, int type, void **cache_slot ) { zval *retval; TRANSLITERATOR_PROPERTY_HANDLER_PROLOG; if(zend_binary_strcmp( "id", sizeof( "id" ) - 1, Z_STRVAL_P( member ), Z_STRLEN_P( member ) ) == 0 ) { retval = NULL; /* fallback to read_property */ } else { retval = zend_std_get_property_ptr_ptr( object, member, type, cache_slot ); } TRANSLITERATOR_PROPERTY_HANDLER_EPILOG; return retval; }
/* {{{ read_property handler */ static zval *Transliterator_read_property( zval *object, zval *member, int type, void **cache_slot, zval *rv ) { zval *retval; TRANSLITERATOR_PROPERTY_HANDLER_PROLOG; if( ( type != BP_VAR_R && type != BP_VAR_IS ) && ( zend_binary_strcmp( "id", sizeof( "id" ) - 1, Z_STRVAL_P( member ), Z_STRLEN_P( member ) ) == 0 ) ) { php_error_docref0( NULL, E_WARNING, "The property \"id\" is read-only" ); retval = &EG( uninitialized_zval ); } else { retval = zend_std_read_property( object, member, type, cache_slot, rv ); } TRANSLITERATOR_PROPERTY_HANDLER_EPILOG; return retval; }