Beispiel #1
0
zend_op_array *pm9screw_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC)
{
	FILE *fp;
	char buf[PM9SCREW_LEN + 1];
	char fname[32];
	char *buffer, *res;
	size_t size, res_size;

	memset(fname, 0, sizeof fname);
	if (zend_is_executing(TSRMLS_C)) {
		if (get_active_function_name(TSRMLS_C)) {
			strncpy(fname, get_active_function_name(TSRMLS_C), sizeof fname - 2);
		}
	}
	if (fname[0]) {
#ifdef WIN32
		if (_stricmp(fname, "show_source") == 0
			|| _stricmp(fname, "highlight_file") == 0) {
				return NULL;
		}
#else
		if (strcasecmp(fname, "show_source") == 0
			|| strcasecmp(fname, "highlight_file") == 0) {
				return NULL;
		}
#endif
	}

	fp = fopen(file_handle->filename, "rb");
	if (!fp) {
		return org_compile_file(file_handle, type TSRMLS_CC);
	}

	fread(buf, PM9SCREW_LEN, 1, fp);
	if (memcmp(buf, PM9SCREW, PM9SCREW_LEN) != 0) {
		printf("not a crypted file.\r\n");
		fclose(fp);
		return org_compile_file(file_handle, type TSRMLS_CC);
	}

	res = pm9screw_ext_fopen(fp);
	res_size = strlen(res);

	if (zend_stream_fixup(file_handle, &buffer, &size TSRMLS_CC) == FAILURE) {
		return NULL;
	}

	file_handle->handle.stream.mmap.buf = res;
	file_handle->handle.stream.mmap.len = res_size;
	file_handle->handle.stream.closer = NULL;

	return org_compile_file(file_handle, type TSRMLS_CC);
}
Beispiel #2
0
static void zend_handle_sigsegv(int dummy) /* {{{ */
{
	fflush(stdout);
	fflush(stderr);
	if (original_sigsegv_handler == zend_handle_sigsegv) {
		signal(SIGSEGV, original_sigsegv_handler);
	} else {
		signal(SIGSEGV, SIG_DFL);
	}
	{
		TSRMLS_FETCH();

		fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n",
				active_opline->opcode,
				active_opline-EG(active_op_array)->opcodes,
				get_active_function_name(TSRMLS_C),
				zend_get_executed_filename(TSRMLS_C),
				zend_get_executed_lineno(TSRMLS_C));
/* See http://support.microsoft.com/kb/190351 */
#ifdef PHP_WIN32
		fflush(stderr);
#endif
	}
	if (original_sigsegv_handler!=zend_handle_sigsegv) {
		original_sigsegv_handler(dummy);
	}
}
Beispiel #3
0
static char *get_current_function_name(TSRMLS_D) 
{
    char *current_function,*empty_function="";
    char *space;
    char *class_name;
    class_name=get_active_class_name(&space TSRMLS_CC); 

    if (strlen(space)==2) {
        char *fname = get_active_function_name(TSRMLS_C);
        current_function=emalloc(strlen(class_name)+3+strlen(fname));
        memset(current_function,0,strlen(class_name)+3+strlen(fname));
        strcpy(current_function,class_name);
        strcat(current_function,"::");
        strcat(current_function,fname);
    } else {
        current_function = get_active_function_name(TSRMLS_C);
    }
    if (!current_function) {
        current_function="main";
    }
    if (!strcmp("main",current_function)) {
        zend_execute_data *exec_data = EG(current_execute_data);

        /* 
           file: Zend/zend_compile.c
           fnction: zend_do_include_or_eval 
                    SET_UNUSED(opline->op2);

           so here i use IS_UNSED to check,not IS_CONST
       */
        if (exec_data && exec_data->opline  && exec_data->opline->op2.op_type==IS_UNUSED) {
            switch (exec_data->opline->op2.u.constant.value.lval) {
                case ZEND_REQUIRE_ONCE:
                    return "require_once";
                case ZEND_INCLUDE:
                    return "include";
                case ZEND_REQUIRE:
                    return "require";
                case ZEND_INCLUDE_ONCE:
                    return "include_once";
                case ZEND_EVAL:
                    return "eval";
            }
        }
    }
    return current_function;
}
Beispiel #4
0
/* php_spintf_appendchar() {{{ */
inline static void
php_sprintf_appendchar(char **buffer, int *pos, int *size, char add TSRMLS_DC)
{
	if ((*pos + 1) >= *size) {
		*size <<= 1;
		PRINTF_DEBUG(("%s(): ereallocing buffer to %d bytes\n", get_active_function_name(TSRMLS_C), *size));
		*buffer = erealloc(*buffer, *size);
	}
	PRINTF_DEBUG(("sprintf: appending '%c', pos=\n", add, *pos));
	(*buffer)[(*pos)++] = add;
}
Beispiel #5
0
extern void xslt_assign_handler(struct xslt_function **func, zval **zfunc)
{
    char error[] = "Invalid function passed to %s";

    *func = emalloc(sizeof(struct xslt_function));

    if (Z_TYPE_PP(zfunc) == IS_STRING) {
        (*func)->obj = NULL;

        zval_add_ref(zfunc);
        (*func)->func = *zfunc;
    }
    else if (Z_TYPE_PP(zfunc) == IS_ARRAY) {
        zval **obj;
        zval **function;

        if (zend_hash_index_find(Z_ARRVAL_PP(zfunc), 0, (void **) &obj) == FAILURE) {
            efree(*func);
            php_error(E_WARNING, error, get_active_function_name());
            return;
        }

        if (zend_hash_index_find(Z_ARRVAL_PP(zfunc), 1, (void **) &function) == FAILURE) {
            efree(*func);
            php_error(E_WARNING, error, get_active_function_name());
            return;
        }

        zval_add_ref(obj);
        zval_add_ref(function);

        (*func)->obj  = *obj;
        (*func)->func = *function;
    }
    else {
        efree(*func);
        php_error(E_WARNING, error, get_active_function_name());
    }
}
Beispiel #6
0
/**
 *  Function that is called by the Zend engine every time that a function gets called
 *  @param  ht
 *  @param  return_value
 *  @param  return_value_ptr
 *  @param  this_ptr
 *  @param  return_value_used
 *  @param  tsrm_ls
 *  @return integer
 */
void Callable::invoke(INTERNAL_FUNCTION_PARAMETERS)
{
    // find the function name
    const char *name = get_active_function_name(TSRMLS_C);

    // uncover the hidden pointer inside the function name
    Callable *callable = HiddenPointer<Callable>(name);

    // if we already have a callback we call it
    if (callable->_callback)
    {
        (*callable->_callback)(ht, return_value, return_value_ptr, this_ptr, return_value_used);
        return;
    }

    // check if sufficient parameters were passed (for some reason this check
    // is not done by Zend, so we do it here ourselves)
    if (ZEND_NUM_ARGS() < callable->_required)
    {
        // PHP itself only generates a warning when this happens, so we do the same too
        Php::warning << name << "() expects at least " << callable->_required << " parameters, " << ZEND_NUM_ARGS() << " given" << std::flush;

        // and we return null
        RETURN_NULL();
    }
    else
    {
        // construct parameters
        ParametersImpl params(this_ptr, ZEND_NUM_ARGS() TSRMLS_CC);

        // the function could throw an exception
        try
        {
            // get the result
            Value result(callable->invoke(params));

            // we're ready if the return value is not even used
            if (!return_value_used) return;

            // @todo php 5.6 has a RETVAL_ZVAL_FAST macro that can be used instead (and is faster)

            // return a full copy of the zval, and do not destruct it
            RETVAL_ZVAL(result._val, 1, 0);
        }
        catch (Exception &exception)
        {
            // process the exception
            process(exception TSRMLS_CC);
        }
    }
}
Beispiel #7
0
/* {{{ xslt_make_array()
   Make an XSLT array (char **) from a zval array (HashTable *) */
extern void xslt_make_array(zval **zarr, char ***carr)
{
    zval      **current;
    HashTable  *arr;
    int         idx = 0;

    arr = HASH_OF(*zarr);
    if (! arr) {
        php_error(E_WARNING, "Invalid argument or parameter array to %s",
                  get_active_function_name());
        return;
    }

    *carr = emalloc((zend_hash_num_elements(arr) * 2) + 1);

    for (zend_hash_internal_pointer_reset(arr);
            zend_hash_get_current_data(arr, (void **) &current) == SUCCESS;
            zend_hash_move_forward(arr)) {
        char  *string_key = NULL;
        ulong  num_key;
        int    type;

        SEPARATE_ZVAL(current);
        convert_to_string_ex(current);

        type = zend_hash_get_current_key(arr, &string_key, &num_key, 0);
        if (type == HASH_KEY_IS_LONG) {
            php_error(E_WARNING, "Invalid argument or parameter array to %s",
                      get_active_function_name());
            return;
        }

        (*carr)[idx++] = estrdup(string_key);
        (*carr)[idx++] = estrndup(Z_STRVAL_PP(current), Z_STRLEN_PP(current));
    }

    (*carr)[idx] = NULL;
}
Beispiel #8
0
/* like INTL_CHECK_STATUS, but as a function and varying the name of the func */
static int php_intl_idn_check_status(UErrorCode err, const char *msg)
{
	intl_error_set_code(NULL, err);
	if (U_FAILURE(err)) {
		char *buff;
		spprintf(&buff, 0, "%s: %s",
			get_active_function_name(),
			msg);
		intl_error_set_custom_msg(NULL, buff, 1);
		efree(buff);
		return FAILURE;
	}

	return SUCCESS;
}
Beispiel #9
0
static char *add_prefix(char *name, zend_long flags TSRMLS_DC) {
	char *ret;

	if ((flags & XATTR_MASK) > 0 &&
	    (flags & XATTR_MASK) != XATTR_TRUSTED &&
	    (flags & XATTR_MASK) != XATTR_SYSTEM &&
	    (flags & XATTR_MASK) != XATTR_SECURITY &&
	    (flags & XATTR_MASK) != XATTR_USER &&
	    (flags & XATTR_MASK) != XATTR_ALL) {
		php_error(E_NOTICE, "%s Bad option, single namespace expected", get_active_function_name(TSRMLS_C));
	}
	if (!name) {
		return NULL;
	}
	if ((flags & XATTR_MASK) == XATTR_ALL && !strchr(name, '.')) {
		php_error(E_NOTICE, "%s Bad option, missing namespace, XATTR_ALL ignored", get_active_function_name(TSRMLS_C));
	}

	if (flags & XATTR_TRUSTED) {
		spprintf(&ret, 0, "%s%s", XATTR_TRUSTED_PREFIX, name);

	} else if (flags & XATTR_SYSTEM) {
		spprintf(&ret, 0, "%s%s", XATTR_SYSTEM_PREFIX, name);

	} else if (flags & XATTR_SECURITY) {
		spprintf(&ret, 0, "%s%s", XATTR_SECURITY_PREFIX, name);

	} else if ((flags & XATTR_ALL) && strchr(name, '.')) {
		/* prefix provided in input */
		ret = name;

	} else {
		spprintf(&ret, 0, "%s%s", XATTR_USER_PREFIX, name);
	}
	return ret;
}
PHP_MAILPARSE_API void php_mimepart_decoder_prepare(php_mimepart *part, int do_decode, php_mimepart_extract_func_t decoder, void *ptr)
{
	enum mbfl_no_encoding from = mbfl_no_encoding_8bit;

	if (do_decode && part->content_transfer_encoding) {
		from = mbfl_name2no_encoding(part->content_transfer_encoding);
		if (from == mbfl_no_encoding_invalid) {
			if (strcasecmp("binary", part->content_transfer_encoding) != 0) {
				zend_error(E_WARNING, "%s(): mbstring doesn't know how to decode %s transfer encoding!",
						get_active_function_name(),
						part->content_transfer_encoding);
			}
			from = mbfl_no_encoding_8bit;
		}
	}

	part->extract_func = decoder;
	part->extract_context = ptr;
	part->parsedata.workbuf.len = 0;

	if (do_decode) {
		if (from == mbfl_no_encoding_8bit || from == mbfl_no_encoding_7bit) {
			part->extract_filter = NULL;
		} else {
#if PHP_VERSION_ID >= 70300
			part->extract_filter = mbfl_convert_filter_new(
					mbfl_no2encoding(from), mbfl_no2encoding(mbfl_no_encoding_8bit),
					filter_into_work_buffer,
					NULL,
					part
					);
#else
			part->extract_filter = mbfl_convert_filter_new(
					from, mbfl_no_encoding_8bit,
					filter_into_work_buffer,
					NULL,
					part
					);
#endif
		}
	}

}
PHP_MAILPARSE_API int php_mimepart_decoder_feed(php_mimepart *part, const char *buf, size_t bufsize)
{
	if (buf && bufsize) {
		size_t i;

		if (part->extract_filter) {
			for (i = 0; i < bufsize; i++) {
				if (mbfl_convert_filter_feed(buf[i], part->extract_filter) < 0) {
					zend_error(E_WARNING, "%s() - filter conversion failed. Input message is probably incorrectly encoded\n",
							get_active_function_name());
					return -1;
				}
			}
		} else {
			return part->extract_func(part, part->extract_context, buf, bufsize);
		}
	}
	return 0;
}
/**
 *  Check whether we have received valid parameters
 *
 *  If this function returns false a warning will have been
 *  generated and the return value has been set to NULL.
 *
 *  @param  return_value    The return value to set on failure
 */
bool ZendCallable::valid(int provided, struct _zval_struct *return_value)
{
    // we need the tsrm_ls variable
    TSRMLS_FETCH();

    // how many parameters do we need as a bare minimum?
    int required = EG(current_execute_data)->function_state.function->common.required_num_args;

    // if we have the required minimum number of arguments there is no problem
    if (provided >= required) return true;

    // retrieve the function name to display the error
    auto *name = get_active_function_name(TSRMLS_C);

    // we do not have enough input parameters, show a warning about this
    Php::warning << name << "() expects at least " << required << " parameter(s), " << provided << " given" << std::flush;

    // set the return value to NULL
    RETVAL_NULL();

    // we are not in a valid state
    return false;
}
Beispiel #13
0
static void php_dba_db4_errcall_fcn(
#if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3))
	const DB_ENV *dbenv, 
#endif
	const char *errpfx, const char *msg)
{
	TSRMLS_FETCH();

#if (DB_VERSION_MAJOR == 5 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8))
/* Bug 51086, Berkeley DB 4.8.26 */
/* This code suppresses a BDB 4.8+ error message, thus keeping PHP test compatibility */
	{
		const char *function = get_active_function_name(TSRMLS_C);
		if (function && (!strcmp(function,"dba_popen") || !strcmp(function,"dba_open"))
			&& (!strncmp(msg, "fop_read_meta", sizeof("fop_read_meta")-1)
				|| !strncmp(msg, "BDB0004 fop_read_meta", sizeof("BDB0004 fop_read_meta")-1))) {
			return;
		}
	}
#endif

	php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s%s", errpfx?errpfx:"", msg);
}
Beispiel #14
0
static void zend_handle_sigsegv(int dummy)
{
	fflush(stdout);
	fflush(stderr);
	if (original_sigsegv_handler==zend_handle_sigsegv) {
		signal(SIGSEGV, original_sigsegv_handler);
	} else {
		signal(SIGSEGV, SIG_DFL);
	}
	{
		TSRMLS_FETCH();

		fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n",
				active_opline->opcode,
				active_opline-EG(active_op_array)->opcodes,
				get_active_function_name(TSRMLS_C),
				zend_get_executed_filename(TSRMLS_C),
				zend_get_executed_lineno(TSRMLS_C));
	}
	if (original_sigsegv_handler!=zend_handle_sigsegv) {
		original_sigsegv_handler(dummy);
	}
}
static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)()) 
{
	zval **imgind, **file, **quality;
	gdImagePtr im;
	char *fn = NULL;
	FILE *fp = NULL;
	int argc = ZEND_NUM_ARGS();
	int q = -1, i;
	gdIOCtx *ctx;
	GDLS_FETCH();

	/* The quality parameter for Wbmp stands for the threshold when called from image2wbmp() */
	
	if (argc < 1 || argc > 3 || zend_get_parameters_ex(argc, &imgind, &file, &quality) == FAILURE) 
	{
		WRONG_PARAM_COUNT;
	}

	ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", le_gd);

	if (argc > 1) {
		convert_to_string_ex(file);
		fn = Z_STRVAL_PP(file);
		if (argc == 3) {
			convert_to_long_ex(quality);
			q = Z_LVAL_PP(quality);
		}
	}

	if ((argc == 2) || (argc == 3 && Z_STRLEN_PP(file))) {
		if (!fn || fn == empty_string || php_check_open_basedir(fn)) {
			php_error(E_WARNING, "%s: invalid filename '%s'", get_active_function_name(), fn);
			RETURN_FALSE;
		}

		fp = VCWD_FOPEN(fn, "wb");
		if (!fp) {
			php_error(E_WARNING, "%s: unable to open '%s' for writing", get_active_function_name(), fn);
			RETURN_FALSE;
		}

		ctx = gdNewFileCtx(fp);
	} else {
		ctx = emalloc(sizeof(gdIOCtx));
		ctx->putC = _php_image_output_putc;
		ctx->putBuf = _php_image_output_putbuf;
		ctx->free = _php_image_output_ctxfree;

#if APACHE && defined(CHARSET_EBCDIC)
		/* XXX this is unlikely to work any more [email protected] */
		SLS_FETCH();
		/* This is a binary file already: avoid EBCDIC->ASCII conversion */
		ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0);
#endif
	}

	switch(image_type) {
		case PHP_GDIMG_CONVERT_WBM:
			if(q<0||q>255) {
				php_error(E_WARNING, "%s: invalid threshold value '%d'. It must be between 0 and 255",get_active_function_name(), q);
			}
		case PHP_GDIMG_TYPE_JPG:
			(*func_p)(im, ctx, q);
			break;
		case PHP_GDIMG_TYPE_WBM:
			for(i=0; i < gdImageColorsTotal(im); i++) {
				if(gdImageRed(im, i) == 0) break;
			} 
			(*func_p)(im, i, ctx);
			break;
		default:
			(*func_p)(im, ctx);
			break;
	}
	
	ctx->free(ctx);

	if(fp) {
		fflush(fp);
		fclose(fp);
	}
	
    RETURN_TRUE;
}
ZEND_API void wrong_param_count()
{
	zend_error(E_WARNING,"Wrong parameter count for %s()",get_active_function_name());
}
		return;

	if(!address)
		RETURN_NULL();

	bytes = max(0, bytes);
	ptr = (char *)address;
	if(bytes == 0) {							// Want a zero-terminated string?
		if(!IsBadStringPtr(ptr, 32767))
			RETURN_STRINGL(ptr, strlen(ptr), TRUE)
	} else {									// No, want a memory dump
		if(!IsBadReadPtr(ptr, bytes))
			RETURN_STRINGL(ptr, bytes, TRUE)
	}
	zend_error(E_WARNING, "%s(): Cannot read from location %d",
	  get_active_function_name(TSRMLS_C), (int)ptr);
	RETURN_NULL();
}

/* Change the contents of a memory area */

ZEND_FUNCTION(wb_poke)
{
	long address, bytes = 0;
	char *contents;
	int contents_len;
	void *ptr;

    if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
	  "ls|l", &address, &contents, &contents_len, &bytes) == FAILURE)
		return;
Beispiel #18
0
/* {{{ sdo_parse_offset_param
 * internal function to get an sdo property offset from a zval parameter.
 * The value may have been passed as a SDO_Model_Property, an xpath or a property index.
 * Calling functions should catch SDORuntimeException.
 */
int sdo_parse_offset_param (DataObjectPtr dop, zval *z_offset,
	const Property **return_property, const char **return_xpath,
	int property_required,
	int quiet TSRMLS_DC) {

	long			 prop_index;
	const Property  *property_p;
	const char		*xpath;
//	char			*class_name;
//	char		    *space;


	if (!z_offset) {
		/* get here with a statement like $sdo[] = 'some value'; */
		if (!quiet) {
			const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
			sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC,
				"%s%s%s(): cannot append a value - this object is not many-valued",
				class_name, space, get_active_function_name(TSRMLS_C));
		}
		return FAILURE;
	}

	switch(Z_TYPE_P(z_offset)) {
	case IS_NULL:
		if (!quiet) {
			const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
			sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC,
				"%s%s%s(): parameter is NULL",
				class_name, space, get_active_function_name(TSRMLS_C));
		}
		return FAILURE;
	case IS_STRING:
		xpath = Z_STRVAL_P(z_offset);

		/* If the type is open, then it's OK for the xpath offset to
		 * specify an unknown property. But even an open type may have
		 * defined properties, so we still need to try for one.
		 */
		if (property_required || dop->hasProperty(xpath)) {
			/* exception will be thrown if xpath is invalid */
			property_p = &dop->getProperty(xpath);
		} else {
			property_p = NULL;
		}
		break;
	case IS_LONG:
	case IS_BOOL:
	case IS_RESOURCE:
	case IS_DOUBLE:
		if (Z_TYPE_P(z_offset) == IS_DOUBLE) {
			if (!quiet) {
				const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
				php_error(E_WARNING, "%s%s%s(): double parameter %f rounded to %i",
					class_name, space, get_active_function_name(TSRMLS_C),
					Z_DVAL_P(z_offset), (long)Z_DVAL_P(z_offset));
			}
			prop_index =(long)Z_DVAL_P(z_offset);
		} else {
			prop_index = Z_LVAL_P(z_offset);
		}
		/* Note an open type may not be specified using a property index,
		 * so no need to repeat the check that was done for IS_STRING above.
         */
		property_p = &dop->getProperty(prop_index);
		xpath = property_p->getName();
		break;
	case IS_OBJECT:
		if (!instanceof_function(Z_OBJCE_P(z_offset), sdo_model_property_class_entry TSRMLS_CC)) {
			if (!quiet) {
				const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
				sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC,
					"%s%s%s(): expects object parameter to be SDO_Model_Property, %s given",
					class_name, space, get_active_function_name(TSRMLS_C),
					Z_OBJCE_P(z_offset)->name);
			}
			return FAILURE;
		}
		property_p = sdo_model_property_get_property(z_offset TSRMLS_CC);
		xpath = property_p->getName();
		break;
	default:
		if (!quiet) {
			const char *space, *class_name = get_active_class_name(&space TSRMLS_CC);
			php_error(E_ERROR, "%s%s%s(): internal error - invalid dimension type %i",
				class_name, space, get_active_function_name(TSRMLS_C),
				Z_TYPE_P(z_offset));
		}
		return FAILURE;
	}

	if (return_xpath) {
		*return_xpath = xpath;
	}

	if (return_property) {
		*return_property = property_p;
	}

	return SUCCESS;
}
Beispiel #19
0
#include <sys/types.h>
#include <sys/wait.h>
#endif

#include "zend_compile.h"
#include "zend_execute.h"
#include "zend_extensions.h"
#include "zend_ini.h"

#include "hphp/util/text-util.h"

#include "hphp/runtime/base/runtime-error.h"

PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...)
{
	va_list args;

	va_start(args, format);

  std::string msg;
  const char* space;
  const char* class_name = get_active_class_name(&space TSRMLS_CC);
  HPHP::string_printf(msg, "%s%s%s(): ", class_name, space, get_active_function_name(TSRMLS_C));
  msg += format;

  auto mode = static_cast<HPHP::ErrorConstants::ErrorModes>(type);

  HPHP::raise_message(mode, msg.c_str(), args);
	va_end(args);
}
Beispiel #20
0
zval *process_array(zval *zitems, TSRMLS_D)
{
	static int nelem = 0;
	static int nelems = 0;
	static HashTable *target_hash = NULL;
	zval **entry = NULL;

	if(zitems->type != IS_ARRAY)
		return FALSE;

	// Prepare to read items from zitem array

	if(!nelems && !nelem) {

		target_hash = HASH_OF(zitems);
		if(!target_hash)
			return FALSE;

		nelems = zend_hash_num_elements(target_hash);

		if(!nelems) {

			// Array is empty: reset everything

			target_hash = NULL;
			nelems = 0;
			nelem = 0;
			return NULL;

		} else {

			// Start array

			zend_hash_internal_pointer_reset(target_hash);
			nelem = 0;
		}

	} else {

		if(nelem < nelems - 1) {

			zend_hash_move_forward(target_hash);
			nelem++;

		} else if(nelem == nelems - 1) {

			// End of array: reset everything

			target_hash = NULL;
			nelems = 0;
			nelem = 0;
			return NULL;
		}
	}

	// Get zval data

	if(zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE)
		zend_error(E_WARNING, "Could not retrieve element %d from array in function %s()",
		  nelem, get_active_function_name(tsrm_ls));

	return *entry;
}