static int spl_autoload(zend_string *class_name, zend_string *lc_name, const char *ext, int ext_len) /* {{{ */ { char *class_file; int class_file_len; zval dummy; zend_file_handle file_handle; zend_op_array *new_op_array; zval result; int ret; class_file_len = (int)spprintf(&class_file, 0, "%s%.*s", ZSTR_VAL(lc_name), ext_len, ext); #if DEFAULT_SLASH != '\\' { char *ptr = class_file; char *end = ptr + class_file_len; while ((ptr = memchr(ptr, '\\', (end - ptr))) != NULL) { *ptr = DEFAULT_SLASH; } } #endif ret = php_stream_open_for_zend_ex(class_file, &file_handle, USE_PATH|STREAM_OPEN_FOR_INCLUDE); if (ret == SUCCESS) { zend_string *opened_path; if (!file_handle.opened_path) { file_handle.opened_path = zend_string_init(class_file, class_file_len, 0); } opened_path = zend_string_copy(file_handle.opened_path); ZVAL_NULL(&dummy); if (zend_hash_add(&EG(included_files), opened_path, &dummy)) { new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE); zend_destroy_file_handle(&file_handle); } else { new_op_array = NULL; zend_file_handle_dtor(&file_handle); } zend_string_release(opened_path); if (new_op_array) { ZVAL_UNDEF(&result); zend_execute(new_op_array, &result); destroy_op_array(new_op_array); efree(new_op_array); if (!EG(exception)) { zval_ptr_dtor(&result); } efree(class_file); return zend_hash_exists(EG(class_table), lc_name); } } efree(class_file); return 0; } /* }}} */
} /* }}} */ static int spl_autoload(const char *class_name, const char * lc_name, int class_name_len, const char * file_extension TSRMLS_DC) /* {{{ */ { char *class_file; int class_file_len; int dummy = 1; zend_file_handle file_handle; zend_op_array *new_op_array; zval *result = NULL; int ret; class_file_len = spprintf(&class_file, 0, "%s%s", lc_name, file_extension); ret = php_stream_open_for_zend_ex(class_file, &file_handle, ENFORCE_SAFE_MODE|USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC); if (ret == SUCCESS) { if (!file_handle.opened_path) { file_handle.opened_path = estrndup(class_file, class_file_len); } if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC); } else { new_op_array = NULL; zend_file_handle_dtor(&file_handle TSRMLS_CC); } if (new_op_array) { EG(return_value_ptr_ptr) = &result; EG(active_op_array) = new_op_array;