#include "php.h"
#include "php_assert.h"
+#include "php_ini.h"
typedef struct {
int active;
- int exit;
+ int bail;
int warning;
char *callback;
} php_assert_globals;
#define ASSERT_ACTIVE 1
#define ASSERT_CALLBACK 2
-#define ASSERT_EXIT 3
+#define ASSERT_BAIL 3
#define ASSERT_WARNING 4
-#ifdef ZTS
-static void php_assert_init_globals(php_assert_globals *assert_globals)
-{
- ASSERT(active) = 0;
- ASSERT(exit) = 0;
- ASSERT(callback) = 0;
- ASSERT(warning) = 1;
-}
-#endif
+PHP_INI_BEGIN()
+ STD_PHP_INI_BOOLEAN("assert.active", "0", PHP_INI_ALL, OnUpdateInt, active, php_assert_globals, assert_globals)
+ STD_PHP_INI_BOOLEAN("assert.bail", "0", PHP_INI_ALL, OnUpdateInt, bail, php_assert_globals, assert_globals)
+ STD_PHP_INI_BOOLEAN("assert.warning", "1", PHP_INI_ALL, OnUpdateInt, warning, php_assert_globals, assert_globals)
+ PHP_INI_ENTRY("assert.callback", NULL, PHP_INI_ALL, NULL)
+PHP_INI_END()
PHP_MINIT_FUNCTION(assert)
{
#ifdef ZTS
assert_globals_id = ts_allocate_id(sizeof(php_assert_globals), (ts_allocate_ctor) php_assert_init_globals, NULL);
-#else
- ASSERT(active) = 0;
- ASSERT(exit) = 0;
- ASSERT(callback) = 0;
- ASSERT(warning) = 1;
#endif
+ REGISTER_INI_ENTRIES();
+
REGISTER_LONG_CONSTANT("ASSERT_ACTIVE", ASSERT_ACTIVE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ASSERT_CALLBACK", ASSERT_CALLBACK, CONST_CS|CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("ASSERT_EXIT", ASSERT_EXIT, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ASSERT_BAIL", ASSERT_BAIL, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ASSERT_WARNING", ASSERT_WARNING, CONST_CS|CONST_PERSISTENT);
return SUCCESS;
PHP_MSHUTDOWN_FUNCTION(assert)
{
- if (ASSERT(callback)) {
- efree(ASSERT(callback));
- ASSERT(callback) = NULL;
- }
-
return SUCCESS;
}
PHP_RINIT_FUNCTION(assert)
{
+ ASSERTLS_FETCH();
+
+ ASSERT(callback) = estrdup(INI_STR("assert.callback"));
+
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(assert)
{
ASSERTLS_FETCH();
-
- if (ASSERT(callback)) {
- efree(ASSERT(callback));
- ASSERT(callback) = NULL;
- }
+
+ if (ASSERT(callback)) efree(ASSERT(callback));
return SUCCESS;
}
PHP_MINFO_FUNCTION(assert)
{
+ ASSERTLS_FETCH();
+
+ DISPLAY_INI_ENTRIES();
}
/* }}} */
}
}
- if (ASSERT(exit)) {
+ if (ASSERT(bail)) {
zend_bailout();
}
}
RETURN_LONG(oldint);
break;
- case ASSERT_EXIT:
- oldint = ASSERT(exit);
+ case ASSERT_BAIL:
+ oldint = ASSERT(bail);
if (ac == 2) {
convert_to_long_ex(value);
- ASSERT(exit) = (*value)->value.lval;
+ ASSERT(bail) = (*value)->value.lval;
}
RETURN_LONG(oldint);
break;
mssql.min_error_severity = 10 ; minimum error severity to display
mssql.min_message_severity = 10 ; minimum message severity to display
mssql.compatability_mode = Off ; compatability mode with old versions of PHP 3.0.
+
+[Assertion]
+assert.active = Off ; assert(expr); does nothing by default
+assert.warning = On ; assert() will issue a PHP warning for each failed assertion.
+assert.bail = Off ; assert() will not bail out by default.
+assert.callback = 0 ; assert() will not call any user-defined PHP-Code by default.
+