From fb3845a438cad9ef09eb1b0b86388ce99a726502 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 22 Sep 2011 11:16:34 +0200 Subject: curl tool: reviewed code moved to tool_*.[ch] files my_setopt and my_setopt_str no longer ignores curl_easy_setopt result. Fixed some OOM handling issues. --- src/tool_libinfo.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/tool_libinfo.c (limited to 'src/tool_libinfo.c') diff --git a/src/tool_libinfo.c b/src/tool_libinfo.c new file mode 100644 index 000000000..1469c8807 --- /dev/null +++ b/src/tool_libinfo.c @@ -0,0 +1,102 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include "setup.h" + +#include + +#include "rawstr.h" + +#define ENABLE_CURLX_PRINTF +/* use our own printf() functions */ +#include "curlx.h" + +#include "tool_libinfo.h" + +#include "memdebug.h" /* keep this as LAST include */ + +/* global variable definitions, for libcurl run-time info */ + +curl_version_info_data *curlinfo = NULL; +long built_in_protos = 0; + +/* + * libcurl_info_init: retrieves run-time information about libcurl, + * setting a global pointer 'curlinfo' to libcurl's run-time info + * struct, and a global bit pattern 'built_in_protos' composed of + * CURLPROTO_* bits indicating which protocols are actually built + * into library being used. + */ + +CURLcode get_libcurl_info(void) +{ + static struct proto_name_pattern { + const char *proto_name; + long proto_pattern; + } const possibly_built_in[] = { + { "dict", CURLPROTO_DICT }, + { "file", CURLPROTO_FILE }, + { "ftp", CURLPROTO_FTP }, + { "ftps", CURLPROTO_FTPS }, + { "gopher", CURLPROTO_GOPHER }, + { "http", CURLPROTO_HTTP }, + { "https", CURLPROTO_HTTPS }, + { "imap", CURLPROTO_IMAP }, + { "imaps", CURLPROTO_IMAPS }, + { "ldap", CURLPROTO_LDAP }, + { "ldaps", CURLPROTO_LDAPS }, + { "pop3", CURLPROTO_POP3 }, + { "pop3s", CURLPROTO_POP3S }, + { "rtmp", CURLPROTO_RTMP }, + { "rtsp", CURLPROTO_RTSP }, + { "scp", CURLPROTO_SCP }, + { "sftp", CURLPROTO_SFTP }, + { "smtp", CURLPROTO_SMTP }, + { "smtps", CURLPROTO_SMTPS }, + { "telnet", CURLPROTO_TELNET }, + { "tftp", CURLPROTO_TFTP }, + { NULL, 0 } + }; + + struct proto_name_pattern const *p; + const char *const *proto; + + /* Pointer to libcurl's run-time version information */ + curlinfo = curl_version_info(CURLVERSION_NOW); + if(!curlinfo) + return CURLE_FAILED_INIT; + + /* Build CURLPROTO_* bit pattern with libcurl's built-in protocols */ + built_in_protos = 0; + if(curlinfo->protocols) { + for(proto = curlinfo->protocols; *proto; proto++) { + for(p = possibly_built_in; p->proto_name; p++) { + if(curlx_raw_equal(*proto, p->proto_name)) { + built_in_protos |= p->proto_pattern; + break; + } + } + } + } + + return CURLE_OK; +} + -- cgit v1.2.1 From 919c97fa65a5c00f7044e849eeb0095408413505 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 6 Apr 2012 23:35:15 +0200 Subject: curl tool: use configuration files from lib directory Configuration files such as curl_config.h and all config-*.h no longer exist nor are generated/copied into 'src' directory, now these only exist in 'lib' directory from where curl tool sources uses them. Additionally old src/setup.h has been refactored into src/tool_setup.h which now pulls lib/setup.h The possibility of a makefile needing an include path adjustment exists. --- src/tool_libinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/tool_libinfo.c') diff --git a/src/tool_libinfo.c b/src/tool_libinfo.c index 1469c8807..ba2f44325 100644 --- a/src/tool_libinfo.c +++ b/src/tool_libinfo.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2012, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -19,7 +19,7 @@ * KIND, either express or implied. * ***************************************************************************/ -#include "setup.h" +#include "tool_setup.h" #include -- cgit v1.2.1 From 01b0f1061da2bd7a8703f4c8aa846a9088d7ab3e Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 8 Apr 2012 13:50:18 +0200 Subject: curl tool: make curl.h first header included in tool_setup.h --- src/tool_libinfo.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/tool_libinfo.c') diff --git a/src/tool_libinfo.c b/src/tool_libinfo.c index ba2f44325..81b6680c8 100644 --- a/src/tool_libinfo.c +++ b/src/tool_libinfo.c @@ -21,8 +21,6 @@ ***************************************************************************/ #include "tool_setup.h" -#include - #include "rawstr.h" #define ENABLE_CURLX_PRINTF -- cgit v1.2.1