Skip to content

Instantly share code, notes, and snippets.

@krakjoe
Created April 4, 2013 15:51
Show Gist options
  • Select an option

  • Save krakjoe/5311608 to your computer and use it in GitHub Desktop.

Select an option

Save krakjoe/5311608 to your computer and use it in GitHub Desktop.
phpconfopts
--- php-virgin/ext/standard/info.c 2013-04-04 16:44:43.017473544 +0100
+++ php-nts/ext/standard/info.c 2013-04-04 16:49:59.395083830 +0100
@@ -1148,6 +1148,37 @@
RETURN_TRUE;
}
+/* {{{ proto array phpconfopts()
+ Returns the array of configuration options in a processable format */
+PHP_FUNCTION(phpconfopts)
+{
+#ifdef CONFIGURE_COMMAND
+ char *configure = estrdup(CONFIGURE_COMMAND);
+ char *position = strtok(configure, " ");
+
+ array_init(return_value);
+
+ while(position &&
+ (position = strtok(NULL, " "))) {
+
+ char *equals = strchr(position, '=');
+ char *key = (position += 3);
+
+ if (equals) {
+ add_assoc_stringl_ex(
+ return_value,
+ key,
+ (strlen(key) - strlen(equals)),
+ ++equals,
+ strlen(equals)-2, 1
+ );
+ } else add_assoc_bool_ex(return_value, key, strlen(key), 1);
+ }
+
+ efree(configure);
+#endif
+} /* }}} */
+
/* }}} */
/* {{{ proto string phpversion([string extension])
--- php-virgin/ext/standard/info.h 2013-01-30 15:04:25.761047081 +0000
+++ php-nts/ext/standard/info.h 2013-04-04 16:10:12.101545519 +0100
@@ -57,6 +57,7 @@
BEGIN_EXTERN_C()
PHP_FUNCTION(phpversion);
PHP_FUNCTION(phpinfo);
+PHP_FUNCTION(phpconfopts);
PHP_FUNCTION(phpcredits);
PHP_FUNCTION(php_sapi_name);
PHP_FUNCTION(php_uname);
--- php-virgin/ext/standard/basic_functions.c 2013-04-04 16:48:12.629537751 +0100
+++ php-nts/ext/standard/basic_functions.c 2013-04-04 16:46:29.400004834 +0100
@@ -1548,6 +1548,9 @@
ZEND_ARG_INFO(0, what)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_phpconfopts, 0, 0, 0)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_phpversion, 0, 0, 0)
ZEND_ARG_INFO(0, extension)
ZEND_END_ARG_INFO()
@@ -2734,6 +2737,7 @@
PHP_FE(image_type_to_extension, arginfo_image_type_to_extension)
PHP_FE(phpinfo, arginfo_phpinfo)
+ PHP_FE(phpconfopts, arginfo_phpconfopts)
PHP_FE(phpversion, arginfo_phpversion)
PHP_FE(phpcredits, arginfo_phpcredits)
PHP_FE(php_sapi_name, arginfo_php_sapi_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment