Browse code

Curl fixes for Win32

git-svn: trunk@1793

Nigel Horne authored on 2005/12/28 22:51:36
Showing 2 changed files
... ...
@@ -1,3 +1,10 @@
1
+Wed Dec 28 13:49:46 GMT 2005 (njh)
2
+----------------------------------
3
+  * libclamav/mbox.c:	Added patches by Gianluigi Tiesi <sherpya*netfarm.it>
4
+  				Improve CURL support on Windows
5
+				Improve CURL error message for systems without
6
+					CURL_ERRORBUFFER
7
+
1 8
 Thu Dec 15 20:51:27 CET 2005 (tk)
2 9
 ---------------------------------
3 10
   * libclamav/sis.c: use mmap() when available
... ...
@@ -15,7 +15,7 @@
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.263 2005/12/09 17:19:10 nigelhorne Exp $";
18
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.264 2005/12/28 13:46:57 nigelhorne Exp $";
19 19
 
20 20
 #if HAVE_CONFIG_H
21 21
 #include "clamav-config.h"
... ...
@@ -3689,6 +3689,9 @@ checkURLs(message *m, const char *dir)
3689 3689
 	html_tag_arg_free(&hrefs);
3690 3690
 }
3691 3691
 
3692
+/*
3693
+ * Includes some Win32 patches by Gianluigi Tiesi <sherpya@netfarm.it>
3694
+ */
3692 3695
 #ifdef	WITH_CURL
3693 3696
 static void *
3694 3697
 #ifdef	CL_THREAD_SAFE
... ...
@@ -3711,13 +3714,15 @@ getURL(struct arg *arg)
3711 3711
 	char fout[NAME_MAX + 1];
3712 3712
 #ifdef	CURLOPT_ERRORBUFFER
3713 3713
 	char errorbuffer[CURL_ERROR_SIZE];
3714
+#else
3715
+	CURLcode res = CURLE_OK;
3714 3716
 #endif
3715 3717
 
3716 3718
 #ifdef	CL_THREAD_SAFE
3717 3719
 	pthread_mutex_lock(&init_mutex);
3718 3720
 #endif
3719 3721
 	if(!initialised) {
3720
-		if(curl_global_init(CURL_GLOBAL_NOTHING) != 0) {
3722
+		if(curl_global_init(CURL_GLOBAL_ALL) != 0) {
3721 3723
 #ifdef	CL_THREAD_SAFE
3722 3724
 			pthread_mutex_unlock(&init_mutex);
3723 3725
 #endif
... ...
@@ -3741,7 +3746,7 @@ getURL(struct arg *arg)
3741 3741
 
3742 3742
 	snprintf(fout, NAME_MAX, "%s/%s", dir, filename);
3743 3743
 
3744
-	fp = fopen(fout, "w");
3744
+	fp = fopen(fout, "wb");
3745 3745
 
3746 3746
 	if(fp == NULL) {
3747 3747
 		cli_errmsg("Can't open '%s' for writing", fout);
... ...
@@ -3808,11 +3813,12 @@ getURL(struct arg *arg)
3808 3808
 	 * memory leak * here in getaddrinfo(), see
3809 3809
 	 *	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=139559
3810 3810
 	 */
3811
-	if(curl_easy_perform(curl) != CURLE_OK) {
3811
+	if((res = curl_easy_perform(curl)) != CURLE_OK) {
3812 3812
 #ifdef	CURLOPT_ERRORBUFFER
3813 3813
 		cli_warnmsg("URL %s failed to download: %s\n", url, errorbuffer);
3814 3814
 #else
3815
-		cli_warnmsg("URL %s failed to download\n", url);
3815
+		cli_warnmsg("URL %s failed to download: %s\n", url,
3816
+			curl_easy_strerror(res));
3816 3817
 #endif
3817 3818
 	}
3818 3819