예제 #1
0
파일: apc_main.c 프로젝트: nickl-/pecl-apc
/* {{{ apc_lookup_class_hook */
int apc_lookup_class_hook(char *name, int len, ulong hash, zend_class_entry ***ce) {

    apc_class_t *cl;
    apc_context_t ctxt = {0,};
    TSRMLS_FETCH();

    if(zend_is_compiling(TSRMLS_C)) { return FAILURE; }

    if(zend_hash_quick_find(APCG(lazy_class_table), name, len, hash, (void**)&cl) == FAILURE) {
        return FAILURE;
    }

    ctxt.pool = apc_pool_create(APC_UNPOOL, apc_php_malloc, apc_php_free, apc_sma_protect, apc_sma_unprotect TSRMLS_CC);
    ctxt.copy = APC_COPY_OUT_OPCODE;

    if(install_class(*cl, &ctxt, 0 TSRMLS_CC) == FAILURE) {
        apc_warning("apc_lookup_class_hook: could not install %s" TSRMLS_CC, name);
        return FAILURE;
    }

    if(zend_hash_quick_find(EG(class_table), name, len, hash, (void**)ce) == FAILURE) {
        apc_warning("apc_lookup_class_hook: known error trying to fetch class %s" TSRMLS_CC, name);
        return FAILURE;
    }

    return SUCCESS;

}
예제 #2
0
파일: error.c 프로젝트: m6w6/ext-psi
void psi_error_wrapper(struct psi_data *context, struct psi_token *t, int type, const char *msg, ...)
{
	va_list argv;
	const char *fn = NULL;
	unsigned ln = 0;

	if (context) {
		if (context->flags & PSI_SILENT) {
			/* context->last_error may be an argument to print */
			char error[sizeof(context->last_error)];

			va_start(argv, msg);
			vslprintf(error, sizeof(error), msg, argv);
			va_end(argv);

			memcpy(context->last_error, error,
					sizeof(context->last_error));
			return;
		}
	}

	if (t) {
		fn = t->file->val;
		ln = t->line;
	} else if (zend_is_executing()) {
		fn = zend_get_executed_filename();
		ln = zend_get_executed_lineno();
	} else if (zend_is_compiling()) {
		fn = zend_get_compiled_filename()->val;
		ln = zend_get_compiled_lineno();
	} else {
		fn = "PSI module startup";
	}

	va_start(argv, msg);
	psi_verror(type, fn, ln, msg, argv);
	va_end(argv);

	va_start(argv, msg);
	PSI_DEBUG_LOCK(context,
			PSI_DEBUG_PRINTV(context, msg, argv);
			PSI_DEBUG_PRINT(context, "\n");
	);