From: Marcus Boerger Date: Tue, 12 Nov 2002 11:49:11 +0000 (+0000) Subject: new function gd_info() returns an associative array of gd support options. # The... X-Git-Tag: php-4.3.0RC1~88 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=597acbc3d33ea13e8d6ffc32a2256d108fb7752f;p=php new function gd_info() returns an associative array of gd support options. # The index names are those from the minfo function. Therefore it is # easy to look into phpinfo() to see which index names are possible. --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 3ec5e9ca96..6768a4d3e2 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -117,6 +117,7 @@ static void _php_image_bw_convert(gdImagePtr im_org, gdIOCtx *out, int threshold /* {{{ gd_functions[] */ function_entry gd_functions[] = { + PHP_FE(gd_info, NULL) PHP_FE(imagearc, NULL) PHP_FE(imageellipse, NULL) PHP_FE(imagechar, NULL) @@ -418,6 +419,82 @@ PHP_MINFO_FUNCTION(gd) } /* }}} */ +/* {{{ proto array gd_info() + */ +PHP_FUNCTION(gd_info) +{ + if (ZEND_NUM_ARGS()!=0) { + ZEND_WRONG_PARAM_COUNT(); + RETURN_FALSE; + } + + if (array_init(return_value) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array"); + RETURN_FALSE; + } +#if HAVE_GD_BUNDLED + add_assoc_string(return_value, "GD Version", "bundled (2.0 compatible)", 1); +#elif HAVE_LIBGD20 + add_assoc_string(return_value, "GD Version", "2.0 or higher", 1); +#elif HAVE_GDIMAGECOLORRESOLVE + add_assoc_string(return_value, "GD Version", "1.6.2 or higher", 1); +#elif HAVE_LIBGD13 + add_assoc_string(return_value, "GD Version", "between 1.3 and 1.6.1", 1); +#else + add_assoc_string(return_value, "GD Version", "1.2", 1); +#endif + +#ifdef ENABLE_GD_TTF + add_assoc_bool(return_value, "FreeType Support", 1); +#if HAVE_LIBFREETYPE + add_assoc_string(return_value, "FreeType Linkage", "with freetype", 1); +#elif HAVE_LIBTTF + add_assoc_string(return_value, "FreeType Linkage", "with TTF library", 1); +#else + add_assoc_string(return_value, "FreeType Linkage", "with unknown library", 1); +#endif +#else + add_assoc_bool(return_value, "FreeType Support", 0); +#endif + +#ifdef HAVE_LIBT1 + add_assoc_bool(return_value, "T1Lib Support", 1); +#else + add_assoc_bool(return_value, "T1Lib Support", 0); +#endif +#ifdef HAVE_GD_GIF_READ + add_assoc_bool(return_value, "GIF Read Support", 1); +#else + add_assoc_bool(return_value, "GIF Read Support", 0); +#endif +#ifdef HAVE_GD_GIF_CREATE + add_assoc_bool(return_value, "GIF Create Support", 1); +#else + add_assoc_bool(return_value, "GIF Create Support", 0); +#endif +#ifdef HAVE_GD_JPG + add_assoc_bool(return_value, "JPG Support", 1); +#else + add_assoc_bool(return_value, "JPG Support", 0); +#endif +#ifdef HAVE_GD_PNG + add_assoc_bool(return_value, "PNG Support", 1); +#else + add_assoc_bool(return_value, "PNG Support", 0); +#endif +#ifdef HAVE_GD_WBMP + add_assoc_bool(return_value, "WBMP Support", 1); +#else + add_assoc_bool(return_value, "WBMP Support", 0); +#endif +#ifdef HAVE_GD_XBM + add_assoc_bool(return_value, "XBM Support", 1); +#else + add_assoc_bool(return_value, "XBM Support", 0); +#endif +} +/* }}} */ + /* Need this for cpdf. See also comment in file.c php3i_get_le_fp() */ PHP_GD_API int phpi_get_le_gd(void) { diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h index 7b7bf341f1..149f9092ba 100644 --- a/ext/gd/php_gd.h +++ b/ext/gd/php_gd.h @@ -59,6 +59,7 @@ PHP_MINFO_FUNCTION(gd); PHP_MINIT_FUNCTION(gd); PHP_MSHUTDOWN_FUNCTION(gd); +PHP_FUNCTION(gd_info); PHP_FUNCTION(imagearc); PHP_FUNCTION(imagechar); PHP_FUNCTION(imagecharup);