Re: cvs: php-src /ext/curl interface.c
| From: | Marcus Boerger | Date: | Tue, 11 Nov 2008 10:51:21 +0000 |
| Subject: | Re: cvs: php-src /ext/curl interface.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-54186@lists.php.net to get a copy of this message | ||
Hello Pierre-Alain,
Monday, November 10, 2008, 11:58:44 PM, you wrote:
> pajoye Mon Nov 10 22:58:44 2008 UTC
> Modified files:
> /php-src/ext/curl interface.c
> Log:
> - make the curl phpinfo more verbose
>
>
> http://cvs.php.net/viewvc.cgi/php-src/ext/curl/interface.c?r1=1.128&r2=1.129&diff_format=u
> Index: php-src/ext/curl/interface.c
> diff -u php-src/ext/curl/interface.c:1.128 php-src/ext/curl/interface.c:1.129
> --- php-src/ext/curl/interface.c:1.128 Sun Nov 2 21:10:07 2008
> +++ php-src/ext/curl/interface.c Mon Nov 10 22:58:44 2008
> @@ -16,7 +16,7 @@
>
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: interface.c,v 1.128 2008/11/02 21:10:07 felipe Exp $ */
> +/* $Id: interface.c,v 1.129 2008/11/10 22:58:44 pajoye Exp $ */
>
> #define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
>
> @@ -336,9 +336,94 @@
> */
> PHP_MINFO_FUNCTION(curl)
> {
> + curl_version_info_data *d;
> + char **p;
> + char str[1024];
> + size_t n = 0;
> +
> +
> + d = curl_version_info(CURLVERSION_NOW);
> php_info_print_table_start();
> php_info_print_table_row(2, "cURL support", "enabled");
> - php_info_print_table_row(2, "cURL Information", curl_version());
> + php_info_print_table_row(2, "cURL Information", d->version);
> + sprintf(str, "%d", d->age);
> + php_info_print_table_row(2, "Age", str);
> +
> +
> + if (d->features & CURL_VERSION_IPV6) {
> + n = sprintf(str, "%s", "IPv6-enabled, ");
> + }
> + if (d->features & CURL_VERSION_KERBEROS4) {
> + n += sprintf(str + n, "%s", "kerberos auth is supported,
> ");
> + }
> + if (d->features & CURL_VERSION_SSL) {
> + n += sprintf(str + n, "%s", "SSL options are present,
> ");
> + }
> + if (d->features & CURL_VERSION_LIBZ) {
> + n += sprintf(str + n, "%s", "libz features are present,
> ");
> + }
> + if (d->features & CURL_VERSION_NTLM) {
> + n += sprintf(str + n, "%s", "NTLM auth is supported,
> ");
> + }
> + if (d->features & CURL_VERSION_GSSNEGOTIATE) {
> + n += sprintf(str + n, "%s", "Negotiate auth support,
> ");
> + }
> + if (d->features & CURL_VERSION_DEBUG) {
> + n += sprintf(str + n, "%s", "built with debug
> capabilities, ");
> + }
> + if (d->features & CURL_VERSION_ASYNCHDNS) {
> + n += sprintf(str + n, "%s", "asynchronous dns resolves,
> ");
> + }
> + if (d->features & CURL_VERSION_SPNEGO) {
> + n += sprintf(str + n, "%s", "SPNEGO auth, ");
> + }
> + if (d->features & CURL_VERSION_LARGEFILE) {
> + n += sprintf(str + n, "%s", "supports files bigger than
> 2GB, ");
> + }
> + if (d->features & CURL_VERSION_IDN) {
> + n += sprintf(str + n, "%s", "International Domain Names
> support, ");
> + }
> + if (d->features & CURL_VERSION_SSPI) {
> + n += sprintf(str + n, "%s", "SSPI is supported, ");
> + }
> + if (d->features & CURL_VERSION_CONV) {
> + n += sprintf(str + n, "%s", "character conversions are
> supported, ");
> + }
This is extremely bad code. We have tons of better APIs to do what you
want. And besides wouldn't it be better to list all those entries with
enabled/disabled as table rows anyway?
(spprintf, snprintf, strcat, smart-strings,...)
(the problem is that adding something will mostlikely result in crashes as
ppl will add the necessary three lines and be happy because something else
is disabled for them. Then someone having all enabled gets crashes because
they forgot to increase the size of the string.
> +
> + if (n > 3) {
> + str[n - 2] = '\0';
> + }
> + php_info_print_table_row(2, "Features", str);
> + n = 0;
> + p = (char **) d->protocols;
> + while (*p != NULL) {
> + n += sprintf(str + n, "%s%s", *p, *(p + 1) != NULL ? ",
> " : "");
> + p++;
> + }
> + php_info_print_table_row(2, "Protocols", str);
> +
> + php_info_print_table_row(2, "Host", d->host);
> +
> + if (d->ssl_version) {
> + php_info_print_table_row(2, "SSL Version", d->ssl_version);
> + }
> +
> + if (d->libz_version) {
> + php_info_print_table_row(2, "ZLib Version", d->libz_version);
> + }
> +
> + if (d->libz_version) {
> + php_info_print_table_row(2, "libIDN Version", d->libidn);
> + }
> +
> + if (d->iconv_ver_num) {
> + php_info_print_table_row(2, "IconV Version", d->iconv_ver_num);
> + }
> +
> + if (d->libssh_version) {
> + php_info_print_table_row(2, "libSSH Version", d->libssh_version);
> + }
> +
> php_info_print_table_end();
> }
> /* }}} */
Best regards,
Marcus