lib558.c problem

2009-04-08 Thread Gisle Vanem

This test program makes calls to `Curl_mk_dnscache' and
`Curl_hash_destroy'. Since there internals are not exported from libcurl.dll,
what should be done about it? Force everybody on Windows to link statically?
No option for me.

--gv


Re: libcurl stuck with half-open connection

2009-04-17 Thread Gisle Vanem

Joe Eggleston j...@arbor.net wrote:

I have a C program using the multi-interface to libcurl with libevent.  
I found it stuck with a half-open connection. By half-open I mean the  
connection was established, then the server box died, so there was no  
FIN, etc.


Then the connection is probably in CLOSE_WAIT. This is normal and nothing
libcurl should care about AFAICS. Why do yuo really care what netstat is saying?
If you're on Windows, you could use e.g. ActivePorts from SysInternals and kill
the connection.

--gv


SCTP anyone?

2009-06-01 Thread Gisle Vanem

I there any plans or ideas to incorporate support for SCTP into
libcurl? AFAICS there are several SCTP implementations for Linux 
and also for Win32 [1]. I took a look at this API [2] and noticed first it 
didn't resemble Berkley sockets at all. That makes it a bit hard to code 
into libcurl I think.


So is there any use for SCTP in libcurl? And what about an url-scheme for it?
http-sctp://  or something...

[1] http://www.sctp.de/sctp-download.html
[2] http://tdrwww.exp-math.uni-essen.de/inhalt/forschung/sctp_fb/sctp_api.html

Ideas welcome.

--gv


Re: libcurl-7.19.3-win32-ssl-msvc - release lib file is larger thandebug?

2010-11-23 Thread Gisle Vanem

Jerry W. Rice jerrywr...@fabnexus.com wrote:


I've downloaded the 'libcurl-7.19.3-win32-ssl-msvc' zip file, and installed
it on my Windows development system.  I intend to link the 'libCurl' static
release library file (lib/Release/curllib_static.lib) with my Windows
application.  I've noticed that the pre-built Release library file is 1857
Kb in length.  On the other hand, the pre-built static Debug library file is
1733 Kb in length.  This seems unusual. 


No so strange. All lib-files contains the (relative) path of the objects it was
built from. I.e 'release\version.obj' vs 'debug\version.obj'. There are 65 
objects
in each lib. The word 'release' is 2 letters longer than 'debug'. Hence the 
release
lib is rightly 130 bytes larger. There could be other reasons, but why care?

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Linking curllib to other library

2011-03-15 Thread Gisle Vanem

Krzysztof Fediuk krzysiek.fed...@gmail.com wrote:

mlib project is supposed to be a common part of all apps and because of 
that i've set this project as a static library. I've added all necessary 
paths and libcurl_static.lib file to be linked. This project compiles fine.


A -DCURL_STATICLIB in your CFLAGS then?

In the second project i've added mlib as a reference and when building 
this project i get unresolved external symbol linker error on every curl 
function.


I'm not so experienced  in C++, but i thought that after making mlib 
file everything should be included there, so I can only depend on this 
particular file?


You cannot unless mlib uses libcurl dynamically. If mlib is a static lib, then 
the final linking stage must also include libcurl_static.lib (normally added after 
mlib.lib). Also read http://curl.haxx.se/docs/faq.html. Section 5.7.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Potentially wiped disk with Makefile.b32

2011-03-22 Thread Gisle Vanem

I have a big problem with the use of rmdir /s in the Makefile.b32 files.
The 'make clean' could really create mayhem for a inexperienced user or
from a small error/typo in these makefiles. Here is a warning in this regard 
(from the 4nt shell docs):

 /S (Subdirectories) (4NT, TC) This option is included only for compatibility
 with Windows NT 4.0's CMD.EXE, and should be used with EXTREME CAUTION!
 It deletes all files (including hidden and system files) in the named directory 
 and all of its subdirectories, then removes all subdirectories. It can potentially 
 erase all files on a drive with a single command.


This can happen if $(OBJDIR) becomes '\' for some reason.

To fix it, we should 'make clean' in 3 steps (delete the .obj, .int and the dir 
itself).
Are you reading this Yang? I could do this myself, but you seems to know Borland's 
make much better.


Also there is a problem if you have e.g. 'rmdir.exe' on path (like i have with
CygWin's /usr/bin/rmdir.exe). AFAICS Borland's make doesn't have 'del', 'rmdir' 
etc. internally (like wmake have). So if you have 'rmdir.exe on path, 'make clean' 
doesn't work as intended. I think it would be better to let the shell perform the 'del',

'rmdir' etc.

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Potentially wiped disk with Makefile.b32

2011-03-22 Thread Gisle Vanem

Gisle Vanem gva...@broadpark.no wrote:


Also there is a problem if you have e.g. 'rmdir.exe' on path (like i have with
CygWin's /usr/bin/rmdir.exe). AFAICS Borland's make doesn't have 'del', 'rmdir' 
etc. internally (like wmake have). So if you have 'rmdir.exe on path, 'make clean' 
doesn't work as intended. I think it would be better to let the shell perform the 'del',

'rmdir' etc.


I gather we could just do: 
 RMDIR  = $(COMSPEC) /c mkdir /q 2NUL


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


[Patch] transfer.c

2011-03-29 Thread Gisle Vanem

A small typo in transfer.c:

--- Git-latest/lib/transfer.cTue Mar 29 11:04:17 2011
+++ lib/transfer.c  Tue Mar 29 12:06:04 2011
@@ -125,7 +125,7 @@
#ifdef CURL_DOES_CONVERSIONS
  bool sending_http_headers = FALSE;

-  if((conn-protocol(CURLPROTO_HTTP|CURLPROTO_RTSP)) 
+  if((conn-handler-protocol  (CURLPROTO_HTTP|CURLPROTO_RTSP)) 
 (data-state.proto.http-sending == HTTPSEND_REQUEST)) {
/* We're sending the HTTP request headers, not the data.
   Remember that so we don't re-translate them into garbage. */

--gv



---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


[Patch] src/Makefile.b32

2011-04-07 Thread Gisle Vanem

I'm not sure this patch should go the curl-users or curl-lib ML, but
I choose the latter. This patch does several things:

* Rename the object object directory from 'objs' to 'BCC_obj' to be in
 sync with my previous patch for lib/Makefile.b32.

* Turn off these warnings to keep the build totally silent (with CBuilder-6
 that is).
  -w-inl8026 Functions X are not expanded inline.
  -w-pia   8060 Possibly incorrect assignment
  -w-pin  8061 Initialization is only partially bracketed
 (same added in src/Makefile.b32)

* $(MKDIR) and $(RMDIR) have been replaced with the shell-commands 'md'
 and 'rd'. When having MingW/Msys programs 'mkdir.exe' and 'rmdir.exe' in 
 $PATH, this confuses Borland's make and the result (the cleaning etc.) would

 not be as expected.

* Removed the preprocessing step; no need for PP_CMD and the .int files.
 curl.exe builds fine w/o and the makefile gets simpler.

* Added a target for creating a compressed hugehelp.c if WITH_ZLIB is 
 defined. It assumes groff, gzip and perl is available if such an advanced 
 users requests it. Okay? BTW. My groff and Perl needs unix-slashes ('/').

 Other perls should handle both forms ('/' and '\').

-

--- Git-latest\src\Makefile.b32 Thu Jan 20 12:22:45 2011
+++ src\Makefile.b32 Thu Apr 07 13:58:57 2011
@@ -34,18 +34,18 @@
PROGNAME = curl.exe

# Setup environment
-PP_CMD   = cpp32 -q -P-
CC_CMD   = bcc32 -q -c
LD   = bcc32
RM   = del 2NUL
-MKDIR= mkdir
-RMDIR= rmdir /s /q 2NUL
+MKDIR= md
+RMDIR= rd /q 2nul
+COPY = $(COMSPEC) /c copy /y

-CC_FLAGS = -5 -O2 -tWM -w -w-aus -w-ccc -w-dup -w-prc -w-pro -w-rch -w-sig 
-w-spa -Dinline=__inline
+CC_FLAGS = -5 -O2 -tWM -w -w-aus -w-ccc -w-dup -w-prc -w-pro -w-rch -w-sig 
-w-spa -w-inl -w-pia -w-pin -Dinline=__inline
LDFLAGS  = -q -lq -lap

SRCDIRS  = .;..\lib
-OBJDIR   = .\objs
+OBJDIR   = .\BCC_objs
INCDIRS  = -I.;..\include;..\lib
LINKLIB  = $(BCCDIR)\lib\cw32mt.lib
DEFINES  = -DNDEBUG -DWIN32
@@ -84,13 +84,14 @@
OBJECTS  = $(CSOURCES:.c=.obj)

.c.obj:
- @-$(RM) $(@R).int
- $(PP_CMD) $(CC_FLAGS) $(INCDIRS) $(DEFINES) -o$(@R).int $()
- $(CC_CMD) $(CC_FLAGS) -o$(@) $(@R).int
+ $(CC_CMD) $(CC_FLAGS) $(INCDIRS) $(DEFINES) -o$@ $

-all: $(OBJDIR) $(PROGNAME)
+all: $(OBJDIR) hugehelp $(PROGNAME)

clean:
+ cd $(OBJDIR)
+ @-$(RM) $(OBJECTS)
+ cd ..
 @-$(RMDIR) $(OBJDIR)
 @-$(RM) $(PROGNAME)
 @-$(RM) curl.tds
@@ -98,6 +99,16 @@
$(OBJDIR):
 @-$(RMDIR) $(OBJDIR)
 @-$(MKDIR) $(OBJDIR)
+
+!ifdef WITH_ZLIB
+hugehelp: ..\docs\MANUAL ..\docs\curl.1 mkhelp.pl
+groff -Tascii -man -P -c ../docs/curl.1  hugehelp.tmp
+perl -w mkhelp.pl -c ../docs/MANUAL  hugehelp.tmp  hugehelp.c
+ @-$(RM) hugehelp.tmp
+!else
+hugehelp:
+ $(COPY) hugehelp.c.cvs hugehelp.c
+!endif

$(PROGNAME): $(OBJECTS) $(LIBCURL_LIB) $(LINKLIB)
 @-$(RM) $(PROGNAME)


-

Also attached.

--gv

--- Git-latest\src\Makefile.b32 Thu Jan 20 12:22:45 2011
+++ src\Makefile.b32Thu Apr 07 13:58:57 2011
@@ -34,18 +34,18 @@
PROGNAME = curl.exe

# Setup environment
-PP_CMD   = cpp32 -q -P-
CC_CMD   = bcc32 -q -c
LD   = bcc32
RM   = del 2NUL
-MKDIR= mkdir
-RMDIR= rmdir /s /q 2NUL
+MKDIR= md
+RMDIR= rd /q 2nul
+COPY = $(COMSPEC) /c copy /y

-CC_FLAGS = -5 -O2 -tWM -w -w-aus -w-ccc -w-dup -w-prc -w-pro -w-rch -w-sig 
-w-spa -Dinline=__inline
+CC_FLAGS = -5 -O2 -tWM -w -w-aus -w-ccc -w-dup -w-prc -w-pro -w-rch -w-sig 
-w-spa -w-inl -w-pia -w-pin -Dinline=__inline
LDFLAGS  = -q -lq -lap

SRCDIRS  = .;..\lib
-OBJDIR   = .\objs
+OBJDIR   = .\BCC_objs
INCDIRS  = -I.;..\include;..\lib
LINKLIB  = $(BCCDIR)\lib\cw32mt.lib
DEFINES  = -DNDEBUG -DWIN32
@@ -84,13 +84,14 @@
OBJECTS  = $(CSOURCES:.c=.obj)

.c.obj:
-   @-$(RM) $(@R).int
-   $(PP_CMD) $(CC_FLAGS) $(INCDIRS) $(DEFINES) -o$(@R).int $()
-   $(CC_CMD) $(CC_FLAGS) -o$(@) $(@R).int
+   $(CC_CMD) $(CC_FLAGS) $(INCDIRS) $(DEFINES) -o$@ $

-all:   $(OBJDIR) $(PROGNAME)
+all:   $(OBJDIR) hugehelp $(PROGNAME)

clean:
+   cd $(OBJDIR)
+   @-$(RM) $(OBJECTS)
+   cd ..
@-$(RMDIR) $(OBJDIR)
@-$(RM) $(PROGNAME)
@-$(RM) curl.tds
@@ -98,6 +99,16 @@
$(OBJDIR):
@-$(RMDIR) $(OBJDIR)
@-$(MKDIR) $(OBJDIR)
+
+!ifdef WITH_ZLIB
+hugehelp: ..\docs\MANUAL ..\docs\curl.1 mkhelp.pl
+groff -Tascii -man -P -c ../docs/curl.1  hugehelp.tmp
+perl -w mkhelp.pl -c ../docs/MANUAL  hugehelp.tmp  hugehelp.c
+   @-$(RM) hugehelp.tmp
+!else
+hugehelp:
+   $(COPY) hugehelp.c.cvs hugehelp.c
+!endif

$(PROGNAME): $(OBJECTS) $(LIBCURL_LIB) $(LINKLIB)
@-$(RM) $(PROGNAME)
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Address change

2011-04-13 Thread Gisle Vanem

Please change my email address in some makefile.dj files:

diff -u3 -Hb Git-latest/lib/makefile.dj ./lib/makefile.dj
--- Git-latest/lib/makefile.dj  Wed Dec 08 17:27:28 2010
+++ ./lib/makefile.dj   Wed Apr 13 23:06:53 2011
@@ -1,6 +1,6 @@
#
#  Adapted for djgpp2 / Watt-32 / DOS by
-#  Gisle Vanem g...@bgnett.no
+#  Gisle Vanem gva...@broadpark.no
#

DEPEND_PREREQ = curl_config.h

diff -u3 -Hb -r Git-latest/src/makefile.dj ./src/Makefile.dj
--- Git-latest/src/makefile.dj  Wed Dec 08 17:27:29 2010
+++ ./src/Makefile.dj   Wed Apr 13 23:06:19 2011
@@ -1,10 +1,10 @@
#
#
#  Adapted for djgpp2 / Watt-32 / DOS by
-#  Gisle Vanem g...@bgnett.no
+#  Gisle Vanem gva...@broadpark.no
#

-DEPEND_PREREQ = curl_config.h hugehelp.c
+DEPEND_PREREQ = curl_config.h # hugehelp.c

top_srcdir = ..
TOPDIR = ..

-

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: CURL_DOES_CONVERSIONS reworked

2011-04-20 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:

So, is there anyone around who needs the conversion and can do some test 
builds and make sure things still work as they should?


I can't say I need it, but I compile regularly with CURL_DOES_CONVERSIONS.
So here are my patches that makes this possible. Attached. Sorry for the
Win/DOS-paths. I'm not sure what the proper Git command(s) would be to
create the correct diff.

non-ascii.c didn't compile at all because of some missing headers and a 
stray 's'. I patched transfer.c to add prototype for 'Curl_convert_to_network()'.


--gv


diff -u3 -Hb Git-latest\lib\non-ascii.c lib\non-ascii.c
--- Git-latest\lib\non-ascii.c  Wed Apr 20 11:44:07 2011
+++ lib\non-ascii.c Wed Apr 20 12:20:28 2011
@@ -21,6 +21,12 @@
 ***/

#include setup.h
+#include non-ascii.h
+#include formdata.h
+#include sendf.h
+#include urldata.h
+
+#include curl/curl.h

#ifdef CURL_DOES_CONVERSIONS

@@ -37,10 +43,10 @@
#endif /* HAVE_ICONV */

/*
- * Curl_convertclone() returns a malloced copy of the source string (if
+ * Curl_convert_clone() returns a malloced copy of the source string (if
 * returning CURLE_OK), with the data converted to network format.
 */
-CURLcode Curl_convertclone(struct SessionHandle *data,
+CURLcode Curl_convert_clone(struct SessionHandle *data,
   const char *indata,
   size_t insize,
   char **outbuf)
@@ -54,7 +60,7 @@

  memcpy(convbuf, indata, insize);
  result = Curl_convert_to_network(data, convbuf, insize);
-  if(result) {s
+  if(result) {
free(convbuf);
return result;
  }
diff -u3 -Hb Git-latest\lib\non-ascii.h lib\non-ascii.h
--- Git-latest\lib\non-ascii.h  Wed Apr 20 11:44:07 2011
+++ lib\non-ascii.h Wed Apr 20 12:21:05 2011
@@ -26,7 +26,7 @@
#include urldata.h

/*
- * Curl_convertclone() returns a malloced copy of the source string (if
+ * Curl_convert_clone() returns a malloced copy of the source string (if
 * returning CURLE_OK), with the data converted to network format.
 *
 * If no conversion was needed *outbuf may be NULL.

diff -u3 -Hb Git-latest\lib\transfer.c lib\transfer.c
--- Git-latest\lib\transfer.c   Wed Apr 20 11:44:07 2011
+++ lib\transfer.c  Wed Apr 20 12:04:41 2011
@@ -103,6 +103,7 @@
#include multiif.h
#include rtsp.h
#include connect.h
+#include non-ascii.h

#define _MPRINTF_REPLACE /* use our functions only */
#include curl/mprintf.h
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: Curl lib with IPV6 support for Windows

2011-07-11 Thread Gisle Vanem

Sumit Popli sumit.po...@gmail.com wrote:


I have tried all the versions of Curl libraries listed on the web site for
windows. None of them have support for IP V6 .
Any help will be greatly appreciated.


No, you have to build the lib youself after adding this to your
CFLAGS:
 -DENABLE_IPV6 


Not too hard. See config-win32.h and setup.h.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Added BSD-style lwIP TCP/IP stack support

2011-08-05 Thread Gisle Vanem

Yang Tse yangs...@gmail.com wrote:


I've made this happen, and have been able to compile curl and libcurl
with lwIP 1.4.0 sockets on Win32.


Great. Does it actually work too? I've been looking at lwIP and built it so far
as to the netif stuff. Do you have a working netif driver for Win32? If not, I 
assume this could be done using WinPcap or libpcap.


--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Added BSD-style lwIP TCP/IP stack support

2011-08-06 Thread Gisle Vanem

Yang Tse yangs...@gmail.com wrote:


I have no clue. Around here I only have VC6 and msvc makefile/projects
provided with lwIP 1.4.0 only support newer msvc compilers. :-(


I found the LwIP netif files in an extra distro; installed under 
'src/contrib/ports/win32'. I managed to build it and link to curl okay, 
but it crashes inside 'lwip!sys_arch_protect'. No idea why I'm investigating
further. 


PS. I made a lwIP build-system (GNU make) for MSVC (any 'cl' version) and MingW.
Maybe you could test with that? It's here:
 http://home.broadpark.no/~gvanem/misc/lwip-windows.zip

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Problem using static libraries libcurl with OpenSSL, minGW, Eclipse

2011-08-12 Thread Gisle Vanem

Oleksiy patriot_of...@ukr.net wrote:


  It is compiled with this:
  g++ -DCURL_STATICLIB -O0 -g3 -Wall -c -fmessage-length=0 -osrc\main.o
  ..\src\main.cpp

  g++ -L..\lib -oYTUploader.exe src\main.o -lcurl -lcurldll -lws2_32
  -lwldap32 -leay32 -lssleay32 -lz


Here you link with both libcurl.a and libcurldll.a. I don't think you want the 
latter.



  I run DependencyWalker, and it says that it's missing ieshims.dll,
  libeay32.dll and ssleay32.dll. But WHY? Why it want OpenSSL dll, I'm
  using static linking! 


Because curl.dll (i.e. via libcurldll.a) wants them.


About ieshims.dll I also can't get why it needs it! Help,


No idea why. What does depends say about it? How depends on this DLL?
It should be part of IE installed in %ProgramFiles%\Internet Explorer.
But I don't have it and have no problems with curl or OpenSSL w/o it.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Compiling libcurl staticly within DLL-module with mingw32

2011-08-20 Thread Gisle Vanem

Alexander Tumin itakingite...@gmail.com wrote:


As you can see in Makefile; module.c is compiled twice:
* once linked staticly with libstatic_curl.a and
* once linked dynamicly with libcurl-4.dll

There is no problems with dynamic build - it just works perfectly as expected.

The problem is that when it is linked staticly: all module's symbols
becomes completely inaccessible with
GetProcAddress() function from windows.h - it just returns NULL for anything.


A static DLL is a self-contradiction. At least when you build it like this:

module_static.dll: module.c
$(CC) -L . -shared module.c -o module_static.dll -DCURL_STATICLIB 
libstatic_curl.a -lws2_32

module_static.dll will have nothing to export because of 'CURL_STATICLIB'. I.e.
'CURL_EXTERN' in curl/curl.h is not '__declspec(dllimport)' as is required 
when
using libcurl dynamically.

Verify this with 'pedump module_static.dll' and 'depends'.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: RE: RE: RE: Linker errors when statically compiled linkinglibcurl+openssl to my project

2011-08-25 Thread Gisle Vanem

Steve Holme steve_ho...@hotmail.com wrote:


I use Visual Studio (and have solution and project files for .NET 2003
(v7.1), 2005 (v8.0), 2008 (v9.0) and 2010 (v10.0)) and have them configured
to build against OpenSSL (as a DLL rather than statically) and to include


Visual Studio uses a 2 pass linker. gnu-ld does not. The OP may have to 
reorder the libs in the link-command. -lws2_32 (missing htonl@4 etc.)

should come after all other libs referring to those functions.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Lots of errors when try ro use self built OpenSSL and lincUrl with it

2011-08-30 Thread Gisle Vanem

Oleksiy patriot_of...@ukr.net wrote:


  ..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0x6):
  undefined reference to `_chkstk'
  ..\lib/libeay32.lib(tmp32/asn_mime.obj):(.text[_SMIME_text]+0xb):
  undefined reference to `__security_cookie'


Because the libeay32.lib was built using MS Visual-C and you're using
MingW. This will not work. You have to get OpenSSL libs targeting
MingW or preferably build them yourself.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


lwIP not using getaddrinfo()

2011-09-22 Thread Gisle Vanem

Playing with lwIP, I see libcurl (Win32/MSVC) doesn't use getaddrinfo().
Although lwIP has it. This stack-trace shows it:

...
lwip.dll!sys_arch_sem_wait+0xbb
lwip.dll!netconn_gethostbyname+0xb6
lwip.dll!lwip_gethostbyname_r+0x87
curl.exe!Curl_ipv4_resolve_r+0x78
curl.exe!Curl_resolver_getaddrinfo+0x6b
curl.exe!Curl_resolv+0xf0
curl.exe!Curl_resolv_timeout+0x2c
curl.exe!resolve_server+0x12d
curl.exe!create_conn+0x4ea
curl.exe!Curl_connect+0x1d
curl.exe!connect_host+0x27
curl.exe!Curl_do_perform+0x42
curl.exe!Curl_perform+0x17
curl.exe!curl_easy_perform+0xa0
curl.exe!operate+0x244e
curl.exe!main+0x42
...

But I cannot make sense of the messy #ifdef-ing to select the correct
resolver. We have been told for like 10 years that gethostbyname() has 
been deprecated. At least on Windows. So someone help me fix this.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: lwIP not using getaddrinfo()

2011-09-22 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:


On Thu, 22 Sep 2011, Gisle Vanem wrote:

But I cannot make sense of the messy #ifdef-ing to select the correct 
resolver. We have been told for like 10 years that gethostbyname() has been 
deprecated. At least on Windows. So someone help me fix this.


It currently depends on ENABLE_IPV6, which in lib/setup.h (line 495) will 
define CURLRES_IPV6 then.


Does lwIP support IPv6? Otherwise I guess you can leave ENABLE_IPV6 undefined 
and just explicity define CURLRES_IPV6 and undefine CURLRES_IPV4,


It does. Trying that, I see lwIP uses getaddrinfo(), then calls gethostbyname() 
internally and then hangs forever waiting for some event:


...
kernel32.dll!WaitForSingleObjectEx+0xa8 
kernel32.dll!WaitForSingleObject+0x12  
lwip.dll!sys_arch_sem_wait+0xbb

lwip.dll!netconn_gethostbyname+0xb6
lwip.dll!lwip_gethostbyname+0x11
libcurl.dll!Curl_getaddrinfo+0x43
libcurl.dll!Curl_resolv+0xd1
libcurl.dll!Curl_resolv_timeout+0x44
libcurl.dll!resolve_server+0x12d
libcurl.dll!create_conn+0x4ea
libcurl.dll!Curl_connect+0x1d
libcurl.dll!Curl_do_perform+0x5a
libcurl.dll!Curl_perform+0x17
libcurl.dll!curl_easy_perform+0xa0
curl.exe!operate+0x2468
...

Must check further.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: lwIP not using getaddrinfo()

2011-09-23 Thread Gisle Vanem

Gisle Vanem gva...@broadpark.no wrote:

It does. Trying that, I see lwIP uses getaddrinfo(), then calls gethostbyname() 
internally and then hangs forever waiting for some event:


...
kernel32.dll!WaitForSingleObjectEx+0xa8 


I see why. lwip_init() is called from easy.c. But the main input processing 
loop (polling the ifaces, checking timers, taking care of retransmissions etc.)
is supposed to be called from an interrupt context. That's the idea on embedded 
systems where that is safe to do.  This main-loop is missing in libcurl.


On Windows (no interrupt context) one needs to call lwIP's tcpip_init(). This 
should
create a threaded main-loop that gets everything going. Ref.
lwip-root/src/contrib/ports/win32/test.c

Yang are you there? What's your idea on this, since you added the lwIP stuff?
What's the motivation for calling lwip_init() only? AFAICS, this doesn't call 
the
required WinPcap init stuff. How can we best make libcurl+lwIP support
embedded and Win32 targets?

--gv



---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


[Patch] url.c

2011-10-04 Thread Gisle Vanem

url.c doesn't compile w/o #define USE_SLL. Here goes:

--- Git-latest/lib/url.c Tue Oct 04 16:23:23 2011
+++ lib/url.c   Tue Oct 04 18:17:20 2011
@@ -2084,10 +2084,12 @@
  if(data-share-cookies == data-cookies)
data-cookies = NULL;

+#ifdef USE_SSL
  if(data-share-sslsession == data-state.session) {
data-state.session = NULL;
data-set.ssl.numsessions = 0;
  }
+#endif

  data-share-dirty--;

@@ -2120,10 +2122,13 @@
data-cookies = data-share-cookies;
  }
#endif   /* CURL_DISABLE_HTTP */
+
+#ifdef USE_SSL
  if(data-share-sslsession) {
data-set.ssl.numsessions = data-share-nsslsession;
data-state.session = data-share-sslsession;
  }
+#endif
  Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);

}



BTW, In share.h, shouldn't the member 'nsslsessions' be inside a 
#ifdef USE_SSL?


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Curl + Visual Studio 2010 - Application fails to initialize

2012-02-13 Thread Gisle Vanem

eli net...@gmail.com wrote:


There are two PCs i work on, both have the same versions of Windows
and the same versions of Visual Studio. The first is desktop PC and
the second is laptop.


It would be nice to know which Windows that is?


  Loaded '..\Debug\curllib.dll', Binary was not built with debug information.
  LDR: LdrpWalkImportDescriptor() failed to probe
..\Debug\curllib.dll for its manifest, ntstatus 0xc0150002


Google led me here:
 
http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/eb6a6e10-9996-42c5-a8d4-6c71c375a7bd/

One of the answers there, had this link:
 
http://www.microsoft.com/downloads/details.aspx?familyid=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5displaylang=en

which sounds like the problem you're experiencing.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: static link libcurl with VS2010 causes crash

2012-02-21 Thread Gisle Vanem

JonathonS thejunk...@gmail.com wrote:


stack below of the crash.

msvcr100d.dll!_free()  + 0x10 bytes 
xx.dll!destroy_async_data(Curl_async * async=0x003f2aa0)  Line 326 + 0xe bytes C


What excactly is it trying to free? Who allocated the data? You must
make sure that the allocator and the code that does the free() uses the 
same C-runtime. Same rule applies to passing 'FILE*' pointers between 
such boundaries.



I made sure to build everything using the same runtimes (/MD runtimes
as DLL). 


Did you make sure to build OpenSSL with '/MD' too?
You could try to run under WinDbg and trace your program (command
'wt' if I remember correctly).


I am all out of ideas on what could be wrong with my build
of libcurl.  I am statically linking both openssl and libcurl which I
built myself.  


Statically or dynamically linking should make no difference regarding
the rules of passing pointers between boundaries.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: libcurl+openssl on windows

2012-02-28 Thread Gisle Vanem

Alex Loukissas a...@maginatics.com wrote:


I have an app that links statically against libcurl, which itself (libcurl)
is built with openssl support. My app is cross-compiled on Linux with
mingw-64 and run on Win7-64. The problem I'm facing is the following:

Unless I use the CURLOPT_CAINFO option and hard-code a certificate path,
the program throws an error: error setting certificate verify locations:
CAfile: /etc/ssl/certs/ca-certificates.crt. My question is: can libcurl
use Windows' certificates somehow, and if so, how? From an old thread (
http://curl.haxx.se/mail/archive-2000-05/0060.html), it seems that the
answer may be no, although my suspicion is that openSSL supports this.


Maybe this will help:
 http://curl.haxx.se/mail/lib-2008-03/0293.html

Basically, something like -DCURL_CA_BUNDLE='curl_getenv(CURL_CA_BUNDLE)'
in your CFLAGS if I didn't misunderstand the problem. Or experiment with something 
like:

 curl_getenv (%APPDATA%\\ca-cert.crt)   - will become expanded at run-time.

Also, check this section in acinclude.m4:

dnl CURL_CHECK_CA_BUNDLE
dnl -
dnl Check if a default ca-bundle should be used
dnl
...

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Cross-compiling libcurl for an embedded platform using lwip

2012-02-28 Thread Gisle Vanem

Dan Fandrich d...@coneharvesters.com wrote:


curl very much expects a BSD-style socket library. The best bet is to
write a shim library that calls the LWIP socket functions using the
standard names so that configure can find them. 


lwIP already has this shim built-in.
Ref. src/include/lwip/sockets.h:

#if LWIP_COMPAT_SOCKETS
#define accept(a,b,c) lwip_accept(a,b,c)
#define bind(a,b,c)   lwip_bind(a,b,c)
#define shutdown(a,b) lwip_shutdown(a,b)
#define closesocket(s)lwip_close(s)
...

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Cross-compiling libcurl for an embedded platform using lwip

2012-02-28 Thread Gisle Vanem

Dan Fandrich d...@coneharvesters.com wrote:


Do the shim include files mirror the POSIX socket include files? If so,
then adding something like CPPFLAGS=-Isrc/include/lwip/ to the configure
like ought to make configure  curl pick them up. If not, it's trickier.


I'm not sure about non-Windows; only that setup.h has this section:

#ifdef USE_LWIPSOCK
#  include lwip/init.h
#  include lwip/sockets.h
#  include lwip/netdb.h
#endif

So AFAICS, all targets should be able to use that section.

Better ask Yang Tse about it. He added the lwIP patches and I tried 
(privately) approx 1 year ago to build a Win-version of libcurl+lwIP, but 
failed to get it working. But I do use lwIP for othe stuff.


--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Using libcurl on top of lwip on POSIX embedded platform (take 2)

2012-03-19 Thread Gisle Vanem

Guenter li...@gknw.net wrote:

If its not possible to check if initialisation is required or not then 
its probably worth to talk to the lwip team and suggest an enhancement 
to lwip_init() so that it does simply nothing if the stack is already 
initialized.


I can only speak for Windows. We can probably assume that lwIP on Win can 
never replace the real tcp/ip stack (Winsock). So the init of lwIP+libcurl is per 
process. There is AFAICS no global settings at the bottom of lwIP. And the win32 
port (src/contrib/ports/Win32/*.c) doesn't use registry or a config-file. It could 
though. Such things are deliberately left to the implementors of a specific OS-port 
of lwIP. 

And the core function lwip_init() does not initialise stuff like netif, mask  address. 
But only things that are common to most tcp/ip-stacks; like loopback address etc. 
See core/init.c.


Since lwip+libcurl needs to be configured per process the mask/address etc. should 
be called from libcurl. Where else? Similar to how the lwip application samples does this.
I have looked into this some time ago. Can you Guenter take a look at the attached 
lwip-thread.c and see what you think? curl_lwip_init() should be called from win32_init() 
in easy.c. I'm not happy with this either since the stuff therein are hardcoded ATM.


--gv

/***
*  _   _   _
*  Project ___| | | |  _ \| |
* / __| | | | |_) | |
*| (__| |_| |  _ | |___
* \___|\___/|_| \_\_|
*
* Copyright (C) 1998 - 2012, Daniel Stenberg, dan...@haxx.se, 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 curl_threads.h

#if defined(USE_LWIPSOCK)
#include conio.h
#include lwip/netif.h
#include lwip/dhcp.h
#include lwip/sys.h
#include lwip/tcpip.h
#include pcapif.h  /* in lwIP-root/src/contrib/ports/win32/ */

static struct netif  netif;
static unsigned char debug_flags;
static ip_addr_t ipaddr, netmask, gw; /* (manually) host IP configuration */
static sys_sem_t init_sem;
static BOOL  quit = FALSE;

static DWORD CURL_STDCALL main_thread(void *arg);

void curl_lwip_init (void)
{
 struct packet_adapter *pa;

 IP4_ADDR(gw, 10,0,0,1);
 IP4_ADDR(netmask, 255,255,255,0);
 IP4_ADDR(ipaddr, 10,0,0,3);

 lwip_init();
 sys_sem_new(init_sem, 0);
 netif_init();

#if 0
 if (!netif.state)
abort();
#endif

 sys_thread_new(main_thread, (lwip_thread_fn)main_thread, init_sem,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}

static void tcpip_init_done (void *arg)
{
 sys_sem_t *sem = (sys_sem_t*)arg;
 struct netif *iface = netif_add(netif, ipaddr, netmask, gw, NULL, 
pcapif_init, tcpip_input);

 netif_set_default(iface);
 netif_set_up(netif);

 sys_sem_signal(sem);
}

static DWORD CURL_STDCALL main_thread (void *arg)
{
 struct in_addr inaddr;
 char ip_str[16] = {0}, nm_str[16] = {0}, gw_str[16] = {0};
 sys_sem_t *sem = (sys_sem_t*) arg;

 tcpip_init(tcpip_init_done, sem);
 sys_sem_wait(sem);

 inaddr.s_addr = ipaddr.addr;
 strncpy(ip_str,inet_ntoa(inaddr),sizeof(ip_str));
 inaddr.s_addr = netmask.addr;
 strncpy(nm_str,inet_ntoa(inaddr),sizeof(nm_str));
 inaddr.s_addr = gw.addr;
 strncpy(gw_str,inet_ntoa(inaddr),sizeof(gw_str));

 printf(TCP/IP initialized. Using IP %s, netmask %s, gateway %s\n,
ip_str, nm_str, gw_str);

 while (!_kbhit())
 {
   netif_poll(netif);
   Sleep (10);
 }
 sys_sem_free(sem);
}
#endif

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: ftpget.c example error

2012-03-28 Thread Gisle Vanem

Avi Manor ama...@airspan.com wrote:

Please don't post in html. It's messy to format a sensible reply in html.


While testing this example I have noticed that every call to my_fwrite comes 
with size = 1.
This is the reason why the error is unnoticeable. However, it is not guaranteed to 
get every call with size = 1.


Why not? AFAICS, 'data-set.fwrite_func()' is always called with 'size=1'.
Ref. sendf.c line 456. Can you figure out where your callback is called
from? And on what OS and libcurl version do you see this behavior?

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: pycurl/libcurl/libfaketime crash in clock_gettime

2012-04-04 Thread Gisle Vanem

Dima Tisnek dim...@gmail.com wrote:


Granted this is hardly an outright bug in pycurl, however I would
rather like to track it down.


Agreed, I think the bug must be in libfaketime. Ask them.


stack head:
#0  0x in ?? ()
#1  0x77bd9a3d in clock_gettime ()
  from /dima/libfaketime/src/libfaketime.so.1
#2  0x74702a13 in ?? () from /usr/lib/libcurl.so.4
#3  0x74703ca3 in ?? () from /usr/lib/libcurl.so.4
#4  0x747246d7 in ?? () from /usr/lib/libcurl.so.4
#5  0x74724f82 in ?? () from /usr/lib/libcurl.so.4
#6  0x7495b4f2 in ?? () from /usr/lib/python2.7/site-packages/pycurl.so


I don't think you can blame anything of this on libcurl. AFAICS, libfaketime
intercepts user (i.e. libcurl) calls of time(), clock_gettime() etc to itself via some 
trampoline or dynlibs hacks. I don't use Linux, but I'm sure libcurl cannot be 
involved here. libcurl just trusts clock_gettime() to behave well.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: SSL/TLS support using Windows SSPI Schannel API

2012-04-09 Thread Gisle Vanem

Marc Hörsken i...@marc-hoersken.de wrote:


Yes, that is basically the whole purpose of this. Schannel is a
replacement for other SSL/TLS implementations, like OpenSSL.
I am currently building it using the previously mentioned Makefile.vc in
winbuild/ and can successfully do HTTPS without OpenSSL.


Can you please tell me what besides '-DUSE_WINDOWS_SSPI' and
'-DUSE_SCHANNEL' is required? This is my cmdline now:

cl.exe -nologo -O2 -W3 -GF -Gy -Zi -Ot -DWIN32 -D_WIN32
-DHAVE_LONGLONG -DHAVE_LL -DHAVE_SPNEGO=1
-D_WIN32_WINNT=0x0501 -DWINVER=0x0501 -DWIN32_LEAN_AND_MEAN
-MD -D_RELEASE -DENABLE_IPV6 -DDEBUG_ADDRINFO
-DUSE_WINDOWS_SSPI -DUSE_SCHANNEL -DDEBUG_LDAP
-DHAVE_LDAP_SSL -DHAVE_LIBZ=1 -DHAVE_ZLIB_H=1
-DBUILDING_LIBCURL -I. -I../include -I../lib -I../../../../zlib-1.2.5
-FoMSVC_obj\\wildcard.obj -c wildcard.c


Example version output of my customized curl version:

D:\Dev\curl\builds\libcurl-release-dll-ssl-schannel-ipv6-sspi\bincurl -V
curl 7.25.1-DEV (i386-pc-win32) libcurl/7.25.1-DEV Schannel/1.0.0.0


I give up; no way I'm getting Schannel/.. from my version.c. I'll wait until
you've added your work to the normal git-repo. I'm confused..

--gv 


---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: SSL/TLS support using Windows SSPI Schannel API

2012-04-14 Thread Gisle Vanem

Marc Hoersken i...@marc-hoersken.de wrote:


functionality of SSL/TLS encryption behind the API. This is the whole
purpose of the general SSPI API and provider approach. It might be
hard to get some information out of it.


I think I see. I've played a little at enumerating and getting the
version of the security packages. Used '-QuerySecurityPackageInfo'.
But they all seemed to be '1' !

My motive was to get a better version info from secur32.dll. Maybe we
should retrieve the file-version of secur32.dll / security.dll itself? Like:

filever -v f:\windows\system32\secur32.dll
--a-- W32i   DLL ENU   5.1.2600.5834 shp 56,832 06-25-2009 secur32.dll
   Language0x0409 (Engelsk (USA))
   CharSet 0x04b0 Unicode
   OleSelfRegister Disabled
   CompanyName Microsoft Corporation
   FileDescription Security Support Provider Interface
   InternalNamesecurity.dll
   OriginalFilenam security.dll
   ProductName Microsoft« Windows« Operating System
   ProductVersion  5.1.2600.5834 !!

Can be obtained using GetFileVersion().

--gv 


---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: Using libcurl with zlib

2012-05-10 Thread Gisle Vanem

east2006 east2006 east2...@gmail.com wrote:


1libcurl.lib(content_encoding.obj) : error LNK2019: unresolved external
symbol _zlibVersion@0 referenced in function _Curl_unencode_gzip_write
1.\Standalone-D\MelodoContent.exe : fatal error LNK1120: 5 unresolved
externals


I'm staticly compiling libcurl with zlib (1.2.3) by including zlib.lib and
adding preprocessors:

HAVE_ZLIB_H
HAVE_ZLIB
HAVE_LIBZ


Somehow you seems to have built libcurl with '-DZLIB_WINAPI' while 
zlib.lib was built without this. How have you built libcurl? Alternatively
build zlib with '-DZLIB_WINAPI'. 

Either way, the linker in your case expects __stdcall imports. I.e. 
the '@x' suffixes.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Using libcurl with zlib

2012-05-10 Thread Gisle Vanem

east2006 east2006 east2...@gmail.com wrote:


Thank you, that solved it

When compiling libcurl with zlib (MSVC), I get this error:

libcurl.res : fatal error LNK1241: resource file zlib1d.lib(zlib1.res)
already specified


Well, zlib1.res must have been included twice. Why, I don't know.
Where and how was zlib1d.lib built? Did you build it using
zlib's old\visualc6\zlib.dsp? I don't think that's up-to-date. 
Anyway, use 'link -verbose' to figure it out.



Unless I turn on 'Link Time Code Generation'.


I have no idea what that is.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


host.name vs. host.dispname

2012-06-06 Thread Gisle Vanem

When running curl --trace-ascii -, I see lots of such lines:

 == Info: Re-using existing connection! (#0) with host (nil)
 == Info: Connected to (nil) (194.103.154.240) port 443 (#0)

I mean, the (nil) looks ugly. So to give a nicer trace, when 'host.name' is
known, why not use that instead when 'host.dispname' is NULL?

What is the purpose of setting 'host.dispname' to NULL anyway? An 
oversight? AFAICS there are 3 places that needs patching. In url.c at 
Curl_verboseconnect() and the parts that says:

 infof(data, Re-using existing connection!  ...
 infof(data, Connection #%ld to host %s left intact\n,

More places? Here is my suggestion:

--- ..\Git-latest\lib\url.c Tue Apr 24 09:42:46 2012
+++ url.c   Wed Jun 06 18:46:13 2012
@@ -3328,7 +3328,8 @@
{
  if(conn-data-set.verbose)
infof(conn-data, Connected to %s (%s) port %ld (#%ld)\n,
-  conn-bits.proxy ? conn-proxy.dispname : conn-host.dispname,
+  conn-bits.proxy? conn-proxy.dispname :
+  conn-host.dispname ? conn-host.dispname : conn-host.name,
  conn-ip_addr_str, conn-port, conn-connectindex);
}
#endif
@@ -5137,7 +5138,8 @@
*in_connect = conn;
infof(data, Re-using existing connection! (#%ld) with host %s\n,
  conn-connectindex,
-  conn-proxy.name?conn-proxy.dispname:conn-host.dispname);
+  conn-proxy.name ? conn-proxy.dispname :
+  conn-host.dispname ? conn-host.dispname : conn-host.name);
  }
  else {
/*
@@ -5421,7 +5423,8 @@

infof(data, Connection #%ld to host %s left intact\n,
  conn-connectindex,
-  conn-bits.httpproxy?conn-proxy.dispname:conn-host.dispname);
+  conn-bits.httpproxy ? conn-proxy.dispname :
+  conn-host.dispname  ? conn-host.dispname : conn-host.name);
  }

  *connp = NULL; /* to make the caller of this function better detect that

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: host.name vs. host.dispname

2012-06-06 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote.

I mean, the (nil) looks ugly. So to give a nicer trace, when 'host.name' 
is known, why not use that instead when 'host.dispname' is NULL?


I don't get to see this. How do you get it like this? What name resolver is 
this libcurl built to use?


The standard AFAICS. I used '-DENABLE_IPV6' and no C-ares; so CURLRES_IPV6 
and CURLRES_SYNCH becomes defined (ref. setup.h). I tried with C-ares too. But 
with the same (nil) in the trace. I fail to see that this is a resolver fault.



What is the purpose of setting 'host.dispname' to NULL anyway? An oversight?


I can only spot one place dispname gets assigned, and that is in the beginning 
of lib/url.c:fix_hostname() ...


Unless we use a proxy (I don't) or it's a fresh connection (not reusing).
So couldn't 'host.dispname' become undefined when reusing the connection
(following or what not)?

Right. Unless we can make dispname not be NULL at one single place first 
instead. Do you think that would be possible?


We could maybe hack ConnectionExists() instead. I don't understand the
details of it.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Windows SSPI Schannel implementation ready

2012-06-12 Thread Gisle Vanem

Marc Hoersken i...@marc-hoersken.de wrote:


I like this idea. That way Curl_schannel_version would still return
something useful while avoiding the dependency on version.lib.


Do you also mean that '-DWIN_USE_SSPI' also needs to
drop the version.lib requirement? I mean, 'WIN_USE_SSPI'
without 'USE_SCHANNEL'. 

I'm in favour of loading version.dll dynamically if we 
absolutely need version info.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


CyaSSL problem in ldap.c

2012-06-13 Thread Gisle Vanem

From gcc/MingW:


In file included from ../../CyaSSL-2.2.0/cyassl/openssl/ssl.h:31:0,
from urldata.h:115,
from ldap.c:68:
../../CyaSSL-2.2.0/cyassl/ssl.h:422:5: error: expected identifier before '(' 
token

Reason being that OCSP_REQUEST+OCSP_RESPONSE are enum values
in CyaSSL and defines in wincrypt.h included via winldap.h in ldap.c.
A fix is to #undef-ine them before ldap.c hits them again via urldata.h:

diff --git a/lib/urldata.h b/lib/urldata.h
index 20e339b..590d79a 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -112,6 +112,12 @@
#endif

#ifdef USE_CYASSL
+/*
+ * These are enum values in cyassl/ssl.h and defines in wincrypt.h
+ * included elsewhere (ldap.c).
+ */
+#undef OCSP_REQUEST
+#undef OCSP_RESPONSE
#include cyassl/openssl/ssl.h
#endif


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: host.name vs. host.dispname

2012-07-09 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:

Okay, but can you give me an exact command line you use to get it? I've not 
yet managed to repeat this problem and I would like to, so that I can perhaps 
make a test case for it.


Sorry for the delay. I forgot about this. But this example shows the 
(nil) part in the trace:
 curl -vL -o NUL https://www.skandiabanken.se 


...
 * Couldn't find host www.skandiabanken.se in the _netrc file; using defaults
 * Re-using existing connection! (#0) with host (nil)
 * Connected to (nil) (194.114.243.37) port 443 (#0)
  GET /hem HTTP/1.1
  User-Agent: curl/7.27.0-DEV

My libcurl options. curl.exe -V
curl 7.27.0-DEV (i386-pc-win32) libcurl/7.27.0-DEV SSL-Windows-native 
zlib/1.2.5 libidn/1.18 iconv/1.9 libssh2/1.4.3_DEV
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 
pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS TrackMemory GSS-Negotiate IDN IPv6 Largefile NTLM SPNEGO 
SSL SSPI libz CharConv

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: What is the best way to debug this?

2012-07-15 Thread Gisle Vanem

Igor Korot ikoro...@gmail.com wrote:


Here is my code:

[code]
struct curl_slist *post = NULL;
   char *data;
   sprintf( data, ---%x,
static_castunsigned int( time( NULL ) ) );
post = curl_slist_append( post, Content-Type: multipart/form-data );
post = curl_slist_append( post, Expect: 100-continue );
post = curl_slist_append( post, Connection: keep-alive );
curl_easy_setopt( handle, CURLOPT_READFUNCTION, CWindowPanel::put_data );
curl_easy_setopt( handle, CURLOPT_READDATA, data );


You call sprintf() with a data pointer initialised where? 'data' points to
a random location. Strange it doesn't crash. think you should do
 char data[100];
 snprintf (data, sizeof(data), ...);

And be careful using C++ functions as callbacks.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Unable to build libcurl on mingw with curl-7.26.0 - Daniel

2012-07-19 Thread Gisle Vanem

Guenter li...@gknw.net wrote:

Another option we could do in our GIT would be to at least add *.c and 
*.h to .gitattributes to so that they are also always forced to be 
checked out in LF format; AFAIK all compilers can deal with this.


Haven't followed the thread so closely. The core problem is with the
GNU bash, right? If so, another option would be to use a proper 'sh' 
program that understands CRLF endings. Like the 'sh' shipped with 
Git.


I have 3 versions of 'sh' here. Only the Cygwin have problems with '\r\n'
files. And that 'sh' is *newer* than the ones (i686-pc-msys, v. 3.1.17)
that has no problems with this. A pathetic problem really.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Unable to build libcurl on mingw with curl-7.26.0 - Daniel

2012-07-19 Thread Gisle Vanem

Guenter li...@gknw.net wrote:

Hello Gunter


What do you mean with problems with '\r\n' ?


Errors from 'sh' like:
 line 12: $'\r': command not found


Did you actually run an autobuild from GIT with MSYS?


No. I'm not keen on using Msys more than absolutely neccesary.


Currently I dont believe that its a problem with the shell itself but
with something else like awk


It's maybe caused by your awk depending on cygwin1.dll? But then
again, I stick to build-tools I know best; I.e. GNU make from my 4NT
shell. And with minimum of auto*/shell hacks involved. Attashed is
the 4nt-script I use to pull things from Git. Then I go through the
curl.diff manually.

--gv


get-latest.btm
Description: Binary data
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: Conflicting lines 273 and 317 in /lib/urldata.h

2012-07-28 Thread Gisle Vanem

Jan Ehrhardt php...@ehrhardt.nl wrote:


The first error is the double declaration of 'connecting_state' in lines
273 and 317 of urldata.h. The next ones have to do with X509_NAME.

../../win32build/include/openssl\x509v3.h(192) : error C2059: syntax
error : '('

line 192 of x509v3.h (OpelSSL 1.0.1c) is:
X509_NAME *directoryName;


Not user about this one. Use cl -E and inspect the output to see why.
But, this ...


C:\php-sdk\curl-src\winbuildcl.exe /O2 /DNDEBUG /MD /DCURL_STATICLIB
/I. /I../include /nologo /W3 /EHsc /DWIN32 /FD /c /DBUILDING_LIBCURL
/I../../win32build/include /DUSE_WIN32_IDN /DWANT_IDN_PROTOTYPES
/DUSE_SSLEAY /I../../win32build/include/openssl /DHAVE_ZLIB_H
/DHAVE_ZLIB /DHAVE_LIBZ /DHAVE_LIBSSH2 /DHAVE_LIBSSH2_H /DLIBSSH2_WIN32
/DLIBSSH2_LIBRARY /DUSE_LIBSSH2 /I../../win32build/include/libssh2
/DUSE_IPV6  /DUSE_WINDOWS_SSPI /DUSE_SCHANNEL


You cannot have -DUSE_SSLEAY and -DUSE_SCHANNEL at the same time.
(connecting_state thus gets defined twice in the same struct). setup.h should 
have done an #error in this case.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: ld.exe: cannot find -lcurl

2012-07-31 Thread Gisle Vanem

Chris Ch charc...@gmail.com wrote:


I am trying to compile a simple program which uses libcurl with Mingw using
Msys. Here is my command and the output given:

Chris@Chris-HP ~
$ gcc -L/usr/local/lib/libcurl.a -o live live.c -DCURL_STATICLIB
-I/usr/local/include -lcurl
c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe:
cannot find -lcurl


The '-L' option (ld search-path) is supposed to contain a directory
(not a file). IMHO it's better to explicitly tell the linker what lib to use;

gcc -o live live.c -DCURL_STATICLIB -I/usr/local/include /usr/local/lib/libcurl.a 


Since (on Windows at least), if you use '-lcurl', GNU ld will use 
'libcurl.dll.a' if both
libcurl.dll.a and libcurl.a are present in the same directory. Very annoying.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: ld.exe: cannot find -lcurl

2012-07-31 Thread Gisle Vanem

Chris Ch charc...@gmail.com wrote:


Chris@Chris-HP ~
$ gcc -o live live.c -DCURL_STATICLIB -I/usr/local/include
/usr/local/lib/libcu



From your prompt, I thought you were not on Win32. How come

you have /usr/local/lib on MingW? Sure you don't use MSys?
In any case use:

 gcc -o live live.c -DCURL_STATICLIB -I/usr/local/include \
/usr/local/lib/libcurl.a -lws2_32

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Issues building with ZLIB and c-ares, Mingw on Win8 x64

2012-12-13 Thread Gisle Vanem

Jesse Nicholson ascensionsyst...@gmail.com wrote:


Anyway so I downloaded latest release c-ares, zlib and curl... compiled
c-ares successfully (although I can only get it to spit out a static lib),


That's the problem.


zlib compiled without issue, then on to curl. Curl will compile the static
lib without issue, but as soon as it goes to link together libcurl.dll, I
get a ton of undefined references to c-ares functions. (note that the
linker doesn't complain about not finding -lcares) Example:


Then I guess you *don't* have both of these files:

dir g:\MingW32\src\inet\DNS\c-ares\*.a

3.10.2012  16:21 424.734  libcares.a
3.10.2012  16:21  58.172  libcares.dll.a

Per the gcc heuristics when given a command like -lcares it
will pick libcares.dll.a first, then libcares.a (if the first
imp-lib isn't found). That's my I prefer to use absolute lib names.

In this case Makefile.m32 should IMHO have stated:
 DLL_LIBS += $(LIBCARES_PATH)/libcares.dll.a  (absolute form)
and not:
 DLL_LIBS += -L$(LIBCARES_PATH) -lcares (obfuscated form)


That's why `_imp__ares_version` is missing (since ld sees a static
lib). Check it by modifying the link command to produce a .map-file:

$(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) 
$(libcurl_dll_DEPENDENCIES)
@$(call DEL, $@)
$(CC) -v -Wl,--print-map,--sort-common,--cref $(LDFLAGS) -shared -o $@ \
  -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) \
  $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)  $(@:.dll=.map)

If you have only libcares.a you will see something like:
 LOAD g:\MingW32\src\inet\DNS\C-ares/libcares.a

If you have both libcares.a and libcares.dll.a you will see something like:
 LOAD g:\MingW32\src\inet\DNS\C-ares/libcares.dll.a

BTW. Why is $(libcurl_dll_DEPENDENCIES) == libcares.a here?

If you reall want to use libcares.a (static lib), add '-DCARES_STATICLIB' to
your CFLAGS. But it would be best to figure out why libcares.dll.a isn't
produced.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [bagder/curl] 13606b: build: make use of 93 lib/*.c renamed files

2013-01-03 Thread Gisle Vanem

GitHub nore...@github.com i.e. Yang Tse wrote:


93 *.c source files renamed to use our standard naming scheme.

..

   A lib/curl_amigaos.c
   A lib/curl_asyn_ares.c
   A lib/curl_asyn_thread.c
   A lib/curl_axtls.c
   A lib/curl_base64.c
   A lib/curl_bundles.c


Okay, but now we can say goodbye to 8+3 unique names on
FAT systems. A DOS-box under Windows should be okay due 
to the SFN-tilde (~) hackery.


Not that I really care, but killing support for Metaware + Pharlap
DOS-extender is a pity. Metaware High-C/C++ still rocks. One of the 
1st true C++ compilers that didn't go via C-code. The C-compiler

also has some cool and unique features.

I'll try to check if libcurl HighC/Pharlap still builds under a Win-XP DOS-box.

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [bagder/curl] 13606b: build: make use of 93 lib/*.c renamed files

2013-01-03 Thread Gisle Vanem

Yang Tse yangs...@gmail.com wrote:


2) When debugging libcurl or apps that use it with debuggers that are
capable of showing the name of the source file it is much easier to
know if one is stepping in libcurl's code or elsewhere.


I think that's a good argument for renaming. 


From your message http://curl.haxx.se/mail/lib-2013-01/0012.html I'm
unable to fully understand if Metaware+Pharlap-DOS-extender was
capable of working before this commit, or if support for it was
already broken.


High-C + Pharlap-DOSX + Watt-32 tcp/ip used to work fine (approx. 5 
years since I checked). But this combo was broken 3 years ago. Is there's 
some interest in making it work again? I'm looking into it.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [bagder/curl] 13606b: build: make use of 93 lib/*.c renamed files

2013-01-05 Thread Gisle Vanem

Steve Holme steve_ho...@hotmail.com wrote:


I'm still more in favour of going back to the old names and reverting the
change.


Me too.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


#include setup.h in libtest

2013-01-10 Thread Gisle Vanem

Yang, I think you forgot about patching tests/libtest.

Some files under tests\libtest, includes setup.h. (e.g. in chkhostname.c).
Shouldn't that be '#include curl_setup.h'? 


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


[Patch] packages/DOS/common.dj

2013-01-10 Thread Gisle Vanem

gcc on DOS hasn't really supported COFF-debug (-gcoff) on djgpp
for a long time. Eli Zaretskii wrote in:
 
http://newsgroups.derkeiler.com/Archive/Comp/comp.os.msdos.djgpp/2012-01/msg00070.html

Sounds like the COFF debug info generation has bit-rotted in GCC.
Nothing new here, no other platform uses COFF AFAIK.

So lets drop it too:

--- packages\DOS\common.dj.old  2013-01-07 02:56:35.65625 +0100
+++ packages\DOS\common.dj  2013-01-10 15:53:34.335625000 +0100
@@ -92,7 +92,7 @@
CC   = gcc
YACC = bison -y

-CFLAGS = -g -gcoff -O2 -I. -I$(TOPDIR)/include -I$(TOPDIR)/lib \
+CFLAGS = -g -O2 -I. -I$(TOPDIR)/include -I$(TOPDIR)/lib \
 -I$(WATT32_ROOT)/inc -Wall -DHAVE_CONFIG_H

ifeq ($(USE_SSL),1)

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: USE_ARES in config-win32.h

2013-01-11 Thread Gisle Vanem

Yang Tse yangs...@gmail.com wrote:


config-platform.h in this case (config-win32.h) should be defining
USE_ARES and verifying that USE_THREADS_WIN32 is not defined when
WITH_ARES or ENABLE_ARES is defined.


It's been a long time since I was involved in the
asyn*.c / resolver stuff. Many other have contributed to asyn-thread.c
etc. since I was involved. So my memory is rustly regarding this.

WITH_ARES? AFAICS only Netware uses this. Can we rename this to 
USE_ARES? And I cannot find ENABLE_ARES anywhere.



config-win32.h should verify that USE_ARES and USE_THREADS_WIN32 are
none defined when WITH_SYNC_DNS or ENABLE_SYNC_DNS is defined.


Where are WITH_SYNC_DNS or ENABLE_SYNC_DNS defined and tested? 
Not here. Are you perhaps confused too? As I am regarding mixing WITH_x,

ENABLE_x and USE_x. We should be consistent and use only one form
(maybe except for ENABLE_IPV6 use USE_x). I'm just scratching the surface
on this build/configuration problem


Notice that changing this in config-win32.h affects all makefiles
which can be used to build a win32/64 target. Your proposed change
would equally affect same number of makefiles.


Not sure I understood this. Some Windows targets is generating 
config-win32.h?


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


ares_getsock() return value

2013-01-11 Thread Gisle Vanem

I'm not sure it matters, but the comment in asyn-ares.c is
wrong:

/*
...
* Returns: CURLE_OK always!
*/
int Curl_resolver_getsock(struct connectdata *conn,
 curl_socket_t *socks,
 int numsocks)

{
..
 int max = ares_getsock((ares_channel)conn-data-state.resolver,
(ares_socket_t *)socks, numsocks);

...
 return max;
}

Here 'max' is a bitmap of readable (or writable) sockets AFAICS.
And multi_getsock() seems to handle this correctly. Except maybe for
16-bit systems, DOS. The bitmap is an 'unsigned int' in multi.c !?

BTW. C-ares handles max 16 sockets here, but multi.c handles
only 2 * MAX_SOCKSPEREASYHANDLE==10. A little too conservative?

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: ares_getsock() return value

2013-01-13 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:

It's funny that we haven't noticed bigger problems with this from users. It 
might be that it is a fairly unusual limit to actual hit in real life.


Have you tried to just bump it? Anyone else?


No I haven't. Just caught this while reading and figuring out 
the c-ares interface in libcurl.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [W32] Testsuite does not build in 7.28.1 anymore

2013-01-22 Thread Gisle Vanem

LRN lrn1...@gmail.com wrote:


compiled object files that go into libcurl. So the header tells
it to link to dllimport mprintf functions, while the object files
provide only normal mprintf functions for internal use.


Right, unless you put a -DCURL_STATICLIB in your CFLAGS.
And link with a static libcurl.a Thus functions in include\curl\mprintf.h 
become undecorated with no dll* attribs. E.g.:


 CURL_EXTERN /* == __declspec(dllimport)  when using libcurl */
 int curl_msnprintf(char *buffer, size_t maxlength,
 # define snprintf curl_msnprintf

boils down to:
 snprintf  ==  curl_msnprintf


you should try a build with --disable-shared


Been there, done that.


From the checklog you sent, I cannot see the '-DCURL_STATICLIB' 

was used. ./tests/libtest/Makefile.am has a:

 if USE_CPPFLAG_CURL_STATICLIB
 AM_CPPFLAGS += -DCURL_STATICLIB
 endif

But how this gets into the Makefile is beyond me. I try to avoid 
autotools at all cost. 


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Patch to get Windows proxy settings

2013-01-28 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:


1 - you don't follow our code style, run lib/checksrc.pl and you'll find many
errors (tabs, spaces, line lengths)


And there's no need to typecast ret-vals from malloc(). libcurl
is written in C, not C++.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Moving some files?

2013-01-28 Thread Gisle Vanem

Just some ideas I have to reduce the number of files in
curl's root-dir:

1) Could  ./Android.mk be moved to ./packages/Android like
 we do for other platforms? 


2) Not sure about ./MacOSX-Framework. I do not know OSX-building.
 But a ./packages/OSX seems logical.

3) ./curl-style.el + ./sample.emacs: Maybe there should be a 'contrib' subdir 
 at root.  Hence ./perl/contrib could become ./contrib/perl. And curl-style.el 
+ sample.emacs be moved to ./contrib/Emacs.


4) Moving 'Makefile.msvc.names' to winbuild? 


auto* files should be left alone off-course.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: curl 7.28.1/MakefileBuild.vc bug?

2013-01-28 Thread Gisle Vanem

Pierre Joye pierre@gmail.com wrote:


However, I do not think we should allow non thread safe crt usage with
curl. Not a big matter as recent versions of the VC does not support
it anymore.

2003 (7.1) was the last version to support it:


What you mean by recent versions? My version is:

 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86

The free version that comes with VCExpress 2010 and Win SDK v7.1a. Plenty 
good still. More recent versions costs lot of money, don't they? (and VCExpress 
2012 doesn't run on Win-XP).


But I agree that /MT should be avoided (MS recomends that because of
side-by-side runtimes and Windows Update). /MD[d] should be default.

Besides the Watcom toolkit has a cl.exe that emulates most (all?) the cmd-line 
switches for MSVC's cl. I haven't tested it, but it could be possible to use 
Makefile.vc with free Watcom tools:


wmake -ms -f Makefile.vc   (nmake compatibility mode)

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Slow Upload Performance on High-Bandwidth connections on windows

2013-02-01 Thread Gisle Vanem

Christian Hägele haeg...@teamviewer.com wrote:

The reason for that is the Curl_sndbufset-function in connect.c. On  windows the socket-sendbuffer is set to a value of 
CURL_MAX_WRITE_SIZE +  32 (16416 bytes). There is a also a strange comment why this is done.
When the SO_SNDBUF is not explicitly set the socket-sendbuffer is  increased automatically by the OS (starting with windows 
Vista/Server  2008).


Did you also see the comment in include/curl/curl.h?  'CURL_MAX_WRITE_SIZE'
can be set a compile-time. I suggest you do that to not make transfer slower
for people using an older Windows (Win-XP).

The problem described in http://support.microsoft.com/kb/823764
doesn't seems to apply to Win-Vista. So do you mean Curl_sendbufset()
should not be set for Vista/2008 R2? If so, there should be an adaption to
the running Windows version. Try it; ref. curl_sspi.c.

--gv 


---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [bagder/curl] 0e66d5: vc: remove explicit MSVC6 IDE project file and doc...

2013-02-07 Thread Gisle Vanem

Yang Tse yangs...@gmail.com wrote:


The possibility of building by other means is no reason to drop this.
Sometimes the best way of debugging something is using the IDE, even
when it is possible to build using makefiles.


Also. MSVC6 IDE can generate makefiles from project files.
Not sure if later MSVC IDEs can do that.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [PATCH] More features changes

2013-02-07 Thread Gisle Vanem

Nick Zitzmann n...@chronosnet.com wrote:


@@ -173,6 +175,12 @@ FOOTNOTES
  *4 = requires FBopenssl
  *5 = requires a krb4 library, such as the MIT one or similar.
  *6 = requires c-ares
-  *7 = requires OpenSSL or NSS, as GnuTLS only supports SSLv3 and TLSv1
+  *7 = requires OpenSSL, NSS, qssl, schannel, or Secure Transport; GnuTLS, for
+   example, only supports SSLv3 and TLSv1


What about PolarSSL? It seems to only support SSLv3 and TLSv1 (from 
the comment in polarssl.c). So it should be in the same group as GnuTLS?


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


tests/libtest/chkhostname.c

2013-02-08 Thread Gisle Vanem

This is AFAICS the only test program in this directory that doesn't
call curl_global_init(). This function is needed for Curl_gethostname()
to work on Windows at least.

Besides it does a case-sensitive string compare of 'argv[1]' and return
buffer from Curl_gethostname(). Aren't hostnames always compared
with curl_str[n]equal() other places (case-insensitive)?

The LD_PRELOAD failed message seems too *nix centric too.

My suggested patch is attached. Patching Makefile.inc should be easy, 
but not my cup of tea.


--gv


chkhostname.diff
Description: Binary data
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Mem leak in curl_ntlm_msg.c

2013-02-08 Thread Gisle Vanem

Running tests\libtest\libntlmconnect.exe reveals a 1 byte (!) leak in
./lib/curl_ntlm_msgs.c:

perl ..\memanalyze.pl c:memdebug.curl
Leak detected: memory still allocated: 1 bytes
At 9771e8, there's 1 bytes.
allocated by curl_ntlm_msgs.c:399

Snippet from curl_ntlm_msgs.c:
   /* setup ntlm identity's domain and length */
   dup_domain.tchar_ptr = malloc(sizeof(TCHAR) * (domlen + 1));

(my domlen == 0).

'dup_domain.tbyte_ptr' looks to be freed in Curl_ntlm_sspi_cleanup()
via 'ntlm-identity.Domain'. But I see no freeing of 'dup_domain.tchar_ptr'.

Patch:

--- Git-latest\lib\curl_ntlm_msgs.c  Mon Jan 28 16:48:37 2013
+++ curl_ntlm_msgs.cFri Feb 08 13:52:21 2013
@@ -405,6 +405,7 @@
*(dup_domain.tchar_ptr + domlen) = TEXT('\0');
ntlm-identity.Domain = dup_domain.tbyte_ptr;
ntlm-identity.DomainLength = curlx_uztoul(domlen);
+free(dup_domain.tchar_ptr);
dup_domain.tchar_ptr = NULL;

Curl_unicodefree(useranddomain.tchar_ptr);

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Mem leak in curl_ntlm_msg.c

2013-02-11 Thread Gisle Vanem

Christian Hägele haeg...@teamviewer.com wrote:


I didn't have the opportunity to test the code, but as


Really?  You should build libcurl with '-DCURLDEBUG', do a
set CURL_MEMDEBUG=mem_trace_file, run
tests\libtest\libntlmconnect.exe and check leaks with
perl tests\memanalyze.pl mem_trace_file.

dup_domain.tbyte_ptr and dup_domain.tchar_ptr is the same pointer (it's  defined as union xcharp_u not as struct) your explanation 
seems wrong.
If you free dup_domain.tchar_ptr as you proposed in your patch you also  deleting the memory you just assigned to the 
ntlm-identity.Domain pointer.

Did I miss something here? Did you test your code with a domainlen larger  than 
0?


No. But I don't think the leaks dissapears if 'domlen  0'.

I saw the definition of 'xcharp_u' and '#ifdef's in curl_multibyte.h just now
(the macros for UNICODE vs. ASCII). If you mean my added 'free()' results
in double-freeing, that's not so evident from your NTLM source (which is not
so easy to follow).

The trace from CURL_MEMDEBUG evidently show a mem-leak in the NTLM sources.
Please take a look at it.

--gv 


---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


[Patch] lib/config-dos.h

2013-02-14 Thread Gisle Vanem

1) HAVE_TERMIOS_H and HAVE_STRLCAT are for djgpp only.

2) The HAVE_CLOSESOCKET_CAMEL hack is not suited for 
 MSDOS/Watt-32. To close a socket, close_s() should be used. 
 Not obfuscated as CloseSocket(). Change reflected in curl_setup_once.h 
 also. Camel as in Apache Camel?


3) Need to force High-C to use strerror_s_() and not strerror().

Also I have a beef with the 'NEED_MALLOC_H' used in some places.
What's the distinction between having some header and needing a header?
We absolutely need string.h and other str*() functions everywhere, so why 
aren't there a NEED_STRING_H/NEED_STRINGS_H also? IMHO, it should 
be renamed to HAVE_MALLOC_H. 


Patches for 1) - 3) attached.

--gv

--- Git-latest\lib\config-dos.h Thu Feb 14 16:46:14 2013
+++ lib\config-dos.hThu Feb 14 18:24:56 2013
@@ -79,7 +79,6 @@
#define HAVE_SYS_SOCKET_H  1
#define HAVE_SYS_STAT_H1
#define HAVE_SYS_TYPES_H   1
-#define HAVE_TERMIOS_H 1
#define HAVE_TIME_H1
#define HAVE_UNISTD_H  1

@@ -149,7 +148,7 @@

#if defined(__HIGHC__) || \
(defined(__GNUC__)  (__GNUC__  4))
-#define ssize_tint
+  #define ssize_t  int
#endif

#define CURL_CA_BUNDLE  getenv(CURL_CA_BUNDLE)
@@ -162,6 +161,7 @@
  #define HAVE_SIGACTION  1
  #define HAVE_SIGSETJMP  1
  #define HAVE_SYS_TIME_H 1
+  #define HAVE_TERMIOS_H  1
  #define HAVE_VARIADIC_MACROS_GCC 1

  /* Because djgpp = 2.03 doesn't have snprintf() etc. */
@@ -174,11 +174,7 @@

#elif defined(__HIGHC__)
  #define HAVE_SYS_TIME_H 1
-#endif
-
-#ifdef MSDOS  /* Watt-32 */
-  #define HAVE_CLOSESOCKET_CAMEL  1
-  #define CloseSocket(s)  close_s((s))
+  #define strerror(e) strerror_s_(e)
#endif

#undef word
--- Git-latest\lib\curl_setup_once.hThu Feb 07 12:33:48 2013
+++ lib\curl_setup_once.h   Thu Feb 14 18:17:27 2013
@@ -255,6 +255,8 @@

#if defined(HAVE_CLOSESOCKET)
#  define sclose(x)  closesocket((x))
+#elif defined(MSDOS) || defined(USE_WATT32)
+#  define sclose(x)   close_s((x))
#elif defined(HAVE_CLOSESOCKET_CAMEL)
#  define sclose(x)  CloseSocket((x))
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: [Patch] lib/config-dos.h

2013-02-15 Thread Gisle Vanem

Yang Tse yangs...@gmail.com wrote:


Pushed your changes, although #2 done differently.


I saw that. Okay by me.


If you are trying to figure out for some specific system what should
be defined, use the following heuristic. Don't define HAVE_MALLOC_H
nor NEED_MALLOC_H and see if everything compiles and works nicely.
OTOH If you get errors about implicit declarations of malloc() free()
etc, and you have malloc.h define NEED_MALLOC_H and try again.


Okay. So it looks like a test for NEED_MEMORY_H is missing from the
CMake system. 


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: limits of independent curl connections

2013-02-25 Thread Gisle Vanem

Tom K. li...@citizenkeen.com wrote:


https://github.com/tomisarobot/curl_race

This example creates a CURL handle and then sends data in a loop.  I
start 200 of these applications up and eventually the system will
become unresponsive to the point of having to press the power button.


When running curl_race.exe in a long sequence here, I don't see any problem.
But in run_many.bat you start so many processes in parallel that you hit 
this problem. Buffer/stack overflow, starved Winsock buffers, runtime 
DLL limits etc. What happens if you experiment with other 'start' options? 
E.g. 'start /BELOWNORMAL'? I agree with Daniel that this problem is outside 
the scope of libcurl.


I'm not sure the MS C++ is as good as other C++ compilers. You seems to
be using VC++8 which is quite old. So you should try a recent GNU C++ 
(and maybe Watcom C++) to rule out libcurl from the equation.


PS. In the project-file I saw you did use '-D_SCL_SECURE_NO_WARNINGS'.
 Why? 


--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: limits of independent curl connections

2013-02-26 Thread Gisle Vanem

Tom K. li...@citizenkeen.com wrote:


How would a different compiler rule out libcurl?


I'm just suggesting that GNU C++ is a better compiler than MSVC++.


PS. In the project-file I saw you did use '-D_SCL_SECURE_NO_WARNINGS'.
 Why?


This is fairly common practice with MSVC, whether good or bad.  It
disables warnings about safe versions of the printf family of
functions.  It will also warn if you disable checked iterators, which
is common on windows because of performance.


Okay, I know what '_CRT_SECURE_NO_WARNINGS' is. But I haven't
grasped the point of '_SCL_SECURE_NO_WARNINGS' before.

--gv


---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


[Patch] lib/polarssl.c

2013-03-08 Thread Gisle Vanem

A typo in lib/polarssl.c? lib/polarsslthreadlock.h doesn't
exists here. Patch:

--- Git-latest\lib\polarssl.c  Sat Feb 23 20:58:58 2013
+++ lib\polarssl.c   Tue Feb 26 09:05:09 2013
@@ -66,7 +66,7 @@
#include connect.h /* for the connect timeout */
#include select.h
#include rawstr.h
-#include polarsslthreadlock.h
+#include polarssl_threadlock.h

#define _MPRINTF_REPLACE /* use our functions only */
#include curl/mprintf.h

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [PATCH] Addition of trailer headers in HTTP requests generated by libcurl

2013-03-15 Thread Gisle Vanem

Chrysovaladis Datsios cdats...@gmail.com wrote:


In the patch:

...

(line 155 in patch):

+  trailer_headers_buf = malloc(headers_buf_size);
+  if(trailer_headers_buf == NULL)
+return CURLE_BAD_FUNCTION_ARGUMENT;


W/o looking at your code in details, why isn't this returning
'CURLE_OUT_OF_MEMORY'? 


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Unable to send/receive messages using curl (version 7.28.1)

2013-03-22 Thread Gisle Vanem

subrahmanya sum.sa...@gmail.com wrote:


When I run my application I get the value -1 for nread. This was not
considered as error till 7.18.0 release. From release 7.18.0 onwards this
value is treated as error because of the condition if((size_t)nread 
buffersize). And hence my application breaks.


Do you have a read callback set with 'CURLOPT_READFUNCTION'? If so,
it could be returning a wrong value. Show it to us.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: libuv example

2013-03-27 Thread Gisle Vanem

Clemens Gruber clemens.gru...@pqgruber.com wrote:


I am sure many of you are aware that libev and libevent only support
select()/poll() on Windows, but not the nice and much faster IO
Completion Ports API.


libevent as used in the Tor-project and others has used IOCP for 
some time now. Since ver 2.0? Ref: 
 http://sourceforge.net/projects/levent/

 http://sourceforge.net/scm/?type=gitgroup_id=50884source=navbar

Would be nice to see how libuv compares to libevent.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Name lookup/DNS resolution mechanism of libcurl

2013-04-01 Thread Gisle Vanem

Michael-O 1983-01...@gmx.net wrote:


Jackpot!

No proxies but I found several addresses in 192.168.56.*
This is the VirtualBox (version 4.1.24 installed) Host-Only Network 
adapter. I have disabled it, and boom curl resolves immediately. A bug 
in VirtualBox I would guess. Some similar issue is still open [1].


I see similar issues with AsyncDNS if I have a dead or really slow 
nameserver in the list of DNS-server libcurl is trying. Building without
USE_ARES gives much better resolve times in this case. AFAICS since 
the WindDNS (the code enabled by USE_THREADS_WIN32) is smarter 
than C-ares is. ipconfig /all will give you a hint of  what DNS-servers 
C-ares will try.


BTW. Gunter, your testspeed.bat file writes the test-file to disk
 and then deletes it right after. IMHO when testing just network speed,
 (and rule out a slow disk) you could write to the NUL-device and possibly
 eliminate some timing errors:
   curl -s -A %UAGENT% -w %OUTFMT% -o NUL %BASEURL%/%DLFILE%

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [bagder/curl] efa548: ftp.pm: Made Perl testsuite able to kill Windows p...

2013-04-06 Thread Gisle Vanem

 Commit: efa5488448771f9cf6554b137d388ea5f3dc90c6
 
https://github.com/bagder/curl/commit/efa5488448771f9cf6554b137d388ea5f3dc90c6
 Author: Marc Hoersken i...@marc-hoersken.de
 Date:   2013-04-06 (Sat, 06 Apr 2013)

..

 ftp.pm: Made Perl testsuite able to kill Windows processes


This patch uses a tool from Windows-XP Professional:
 system(taskkill $filter nul 21);

I run Windows-XP Home and have no such tool. AFAICS,
one cannot get this from MS w/o having a pro version.
Isn't there a better alternative (like pskill)?

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Make DNS requests follow the CURLOPT_INTERFACE if c-ares is in use

2013-04-07 Thread Gisle Vanem

Vandry van...@tzone.org wrote:

If c-ares is in use, this is actually easy to implement because c-ares 
already has a hook for it. I propose a small change that would make DNS 
requests also follow the CURLOPT_INTERFACE binding if c-ares is in use. 
If c-ares is not in use or if the c-ares version is too old to support 
this, the behaviour would be the same as it is now. I could have made it 
fail with CURLE_NOT_BUILT_IN but I don't think that's a good idea.


And also for Windows since 'ares_set_local_dev()' boils down to
'setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE)' which Winsock
doesn't support. There should be another neater way to at least
send DNS-requests to a specific interface on Windows. 


--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Name lookup/DNS resolution mechanism of libcurl

2013-04-09 Thread Gisle Vanem

Guenter li...@gknw.net wrote:

On 09.04.2013 20:01, Michael-O wrote:
 Günter,


were you able to look at the Makefiles of c-ares and curl?


yes, today commited two patches - one for curl and one for c-ares ...


Thanks for fixing this. I wrote about this in this thread:
 http://curl.haxx.se/mail/lib-2013-01/0131.html

earlier this year. Your patch below looks good here.
Except:

+#if !defined(USE_ARES)  !defined(USE_THREADS_WIN32)
# define USE_THREADS_WIN32 1
+#elif defined(USE_THREADS_WIN32)  USE_THREADS_WIN32 == 0
+#  undef USE_THREADS_WIN32
#endif

How can USE_THREADS_WIN32 both be defined and set to 0?
The  USE_THREADS_WIN32 == 0 part is superfluous AFAICS.

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Name lookup/DNS resolution mechanism of libcurl

2013-04-10 Thread Gisle Vanem

Guenter li...@gknw.net wrote:


How can USE_THREADS_WIN32 both be defined and set to 0?
The  USE_THREADS_WIN32 == 0 part is superfluous AFAICS.

well, simply by -DUSE_THREADS_WIN32=0 ...


I think you know I already knew that. Just that it's highly suspicious 
that it was needed. I forgot the reason behind this and possibly in some 
time, nobody will understand the historic reason.


honestly I'm not happy with that hack, and if someone has something 
better in mind please speak up!


Me neither. That's why I reacted on this tree-state logic. 


--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: progressfunction called too much

2013-06-04 Thread Gisle Vanem

Linos i...@linos.es wrote:


  https://sourceforge.net/p/curl/bugs/1238/



You are welcome, thank you for create the bug report.


I also see this. Here is the stack of the main thread:

ntkrnlpa.exe!KiUnexpectedInterrupt+0x121
ntkrnlpa.exe!ZwYieldExecution+0x1c90
hal.dll!HalClearSoftwareInterrupt+0x342
python27.dll!PyEval_EvalFrameEx+0xd9f
python27.dll!PyEval_EvalCodeEx+0x6b5
python27.dll!PyEval_EvalCodeEx+0x695
python27.dll!PyFunction_SetClosure+0x86a
python27.dll!PyObject_Call+0x4c
python27.dll!PyEval_CallObjectWithKeywords+0x89
pycurl.pyd+0x284c
libcurl.dll!Curl_pgrsUpdate+0x2e4!!! this is causing python to suck 25% CPU 
libcurl.dll!multi_runsingle+0xc6d

libcurl.dll!curl_multi_perform+0x7c
libcurl.dll!curl_easy_perform+0xd1
pycurl.pyd+0x2279
python27.dll!PyEval_GetGlobals+0x68b



I would expect a Python-script to run longer because of the limit on 
recv-rate. But not that it should longer because the CPU gets overloaded

by Curl_pgrsUpdate().

BTW. I used the attached script to play with. In some cases with a rate_limit 
 of approx. 1000 bytes/sec, I also got a

   pycurl.error: (56, 'Recv failure: Connection was reset')

 Presumably because the server lost patience with such a slow client...

Win-XP SP3, pycurl + libcurl using MSVC v16.

--gv
#! /usr/bin/env python

import sys, pycurl

num_progress_callbacks = 0
dl_last = 0

def curl_progress (dl_total, dl_now, ul_total, ul_now):
  global num_progress_callbacks, dl_last

  if dl_now  0.0 and dl_now  dl_last:
 # print ('curl_progress. dl_now %15.0f bytes' % dl_now)
 dl_last = dl_now
  num_progress_callbacks += 1
  return 0

def dev_null (buf):
  pass

def test (url, rate_limit = 0):
  if rate_limit  0:
print ('rate_limit %d bytes/sec' % rate_limit)
  else:
print ('No speed limit')

  curl = pycurl.Curl()
  curl.setopt (curl.URL, url)
  curl.setopt (curl.MAX_RECV_SPEED_LARGE, rate_limit)

  curl.setopt (curl.WRITEFUNCTION, dev_null)
  curl.setopt (curl.NOPROGRESS, 0)
  curl.setopt (curl.PROGRESSFUNCTION, curl_progress)
  curl.setopt (curl.FOLLOWLOCATION, 1)

  curl.perform()
  curl.close()

rate_limit = 0
if len(sys.argv)  1:
  rate_limit = int(sys.argv[1])

test ('http://www.vg.no', rate_limit)
print ('num_progress_callbacks %d' % num_progress_callbacks)
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: progressfunction called too much

2013-06-14 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:

Just for the record: I just pushed a fix for this (commit 0feeab7802dd2a) and 
I've closed that issue!


Good. It's much better now. No longer a CPU-hog. Here
is the call-stack now with the same Python script:

ntkrnlpa.exe!KiUnexpectedInterrupt+0x121
ntkrnlpa.exe!ZwYieldExecution+0x1d3a
ntkrnlpa.exe!ZwYieldExecution+0x261c
ntkrnlpa.exe!ProbeForRead+0x605
ntkrnlpa.exe!KeReleaseInStackQueuedSpinLockFromDpcLevel+0xb80
ntdll.dll!KiFastSystemCall+0x3
ntdll.dll!KiFastSystemCallRet
ntdll.dll!NtDelayExecution+0xc
kernel32.dll!SleepEx+0x61
kernel32.dll!Sleep+0xf
libcurld.dll!Curl_wait_ms+0x20
libcurld.dll!curl_easy_perform+0x12a
pycurl.pyd+0x2279
python27.dll!PyEval_GetGlobals+0x68b

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: x64 libcurl

2013-07-09 Thread Gisle Vanem

Jamey Kirby kirby.ja...@gmail.com wrote:


I am trying to build libcurl for x64, I finally got it almost working. I
can build x86 with no problems. Fails when it tried to compile amigaos for
x64. How do I tell it to only build vc-x64?

Here is my build line:

nmake /f Makefile.vc10 MACHINE=x64 cfg=release


Looks okay.


Works when I select x86, but amigaos fails and build fails when I select x64


Not only amigaos.obj fails. All your objects fails to link. That one fails only
because it's the first in the list given to link.exe. 


Did you prepare your environment for building 64-bit code. I.e. call
vcvars32.bat 64bit to setup the PATH to point to the x64 version 
of cl.exe?


--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: x64 libcurl

2013-07-09 Thread Gisle Vanem

Jamey Kirby kirby.ja...@gmail.com wrote:


Gonna have a try. Again, thanks for your help and tolerating my
frustrations. Having been dinking with this for a month, it is getting
frustrating.



I'm not sure you're using the correct cl.exe. In a cmd-shell, what does cl 
/?
print? Here with my normal x86 cl.exe, I get:
 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86

But with the x64 version, I get from cl /?:
 Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64

You'll have to ensure you're using the correct cl.exe.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Compiling Curl with TLS support using MSVC 2008

2013-07-13 Thread Gisle Vanem

sumit gambhir sumitgambh...@gmail.com wrote:


Please provide steps to compile Curl with TLS and HTTPS support using MSVC
2008.


What HTTPS library you want to use? The SSL that comes with
Windows would probably be best for your. It could be built in this ugly
way:
 cd lib
 nmake -f Makefile.vc6 WINDOWS_SSPI=1 CFG=release-winssl-zlib

This creates libcurl.lib that you link to in you app. Or use to build curl.exe
itself:
 cd ..\src
 copy tool_hugehelp.c.cvs tool_hugehelp.c
 nmake -f Makefile.vc6 WINDOWS_SSPI=1 CFG=release-winssl-zlib

PS. you need zlib.h + zlib.lib installed and set %ZLIB_PATH to point to it. 
E.g.

 ZLIB_PATH=g:\MingW32\src\zlib-1.2.7

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


[Patch] transfer.c

2013-08-20 Thread Gisle Vanem
A change in 'struct SessionHandle' broke the 
'CURL_DOES_CONVERSIONS' code in transfer.c:


--- Git-latest/lib/transfer.c2013-08-20 06:52:36 +
+++ lib/transfer.c  2013-08-20 07:05:06 +
@@ -101,8 +101,10 @@
#ifdef CURL_DOES_CONVERSIONS
  bool sending_http_headers = FALSE;

-  if((conn-handler-protocol(CURLPROTO_HTTP|CURLPROTO_RTSP)) 
- (data-state.proto.http-sending == HTTPSEND_REQUEST)) {
+  if(conn-handler-protocol(CURLPROTO_HTTP|CURLPROTO_RTSP)) {
+const struct HTTP *http = data-req.protop;
+
+if (http-sending == HTTPSEND_REQUEST)
/* We're sending the HTTP request headers, not the data.
   Remember that so we don't re-translate them into garbage. */
sending_http_headers = TRUE;

-

BTW. 
 Building with 'CURL_DOES_CONVERSIONS' gives me extra newlines 
 in CURLOPT_VERBOSE output. I cannot see why.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Linker errors in pre-compiled static library for windows

2013-08-22 Thread Gisle Vanem

Garrick Mason gtm.ma...@gmail.com wrote:

lib\libcurl.a(url.o):(.text.unlikely+0x1a4): undefined reference to 
`stringprep_check_version'

lib\libcurl.a(sendf.o):(.text+0x147): undefined reference to `recv@16'


Try adding 'libidn.a' and '-lws2_32' to the link command.
libidn.a should be in the .zip Gunter has provided.
You may have to add some more libs depending on what
features is built into that static libcurl.a.

To see what the linker is looking for or is pulling in, tell
g++ to make a .map file. Add something like this to the 
link command:

 mingw32-g++.exe {...} -Wl,--print-map,--sort-common  my_app.map

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


snprintf in http2.c

2013-09-06 Thread Gisle Vanem

I built NgHTTP2 some days ago using MSVC 2010. I was amazed
of how easy it was. Not very Unix/Posix centric at all. But using the
first little merge of nghttp2 into libcurl, I stumbeled on the missing
'snprintf' in MSVCRT. Isn't this how we do it for other libcurl files?
I.e. use 'curl_msnprintf' and not 'snprintf' directly:

--- Git-latest/lib/http2.c   2013-09-05 13:47:19 +
+++ lib/http2.c 2013-09-06 09:52:57 +
@@ -22,6 +22,9 @@

#include curl_setup.h

+#define _MPRINTF_REPLACE
+#include curl/mprintf.h
+
#ifdef USE_NGHTTP2
#include nghttp2/nghttp2.h
#include http2.h


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: best practices: c-ares vs threaded resolver

2013-09-17 Thread Gisle Vanem

m brandenberg mcb...@panix.com wrote:


So these and other issues make me want to use the system resolver
library.  When it fails, there's a general system/network
configuration issue that doesn't become a support issue for us.


I tend to agree. The systems resolver seems alway to work best
for me. At least when I use a VPN. Then (without messing with my routing-
table, C-ares is using the default interface which doesn't work). I whish
there could be a config-file similar to '/etc/resolv.conf' for C-ares/Win.

Besides the new C-ares functions for specifying DNS addr/iface that's
recently been added to curl does nothing on Windows; '--dns-interface'
boils down to 'setsockopt (..SO_BINDTODEVICE)' and '--dns-ipvX-addr'
boils down to a 'bind(..ipvX-addr)' which AFAICS is useful only for those 
running a DNS-server locally. I doesn't do any good on my Winsock. The

'--dns-ipvX-addr' option should IMHO be used to specify what DNS-server
to connect to.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


HTTP 2.0 selects forever

2013-09-25 Thread Gisle Vanem

I'm having some success with HTTP 2.0 using the NgHTTP2 test server
http://106.186.112.116/ .   I don't suppose there are other HTTP 2.0 servers
I can test with?

The problem is some extra garbage in the start and end of output. Using this
command
 curl --http2.0 http://106.186.112.116/

Gives this in the beginning (before the !DOCTYPE):

┴☺♦   ☺ÇB☺0E   text/htmlF↔Wed, 25 Sep 2013 12:14:27 
GMTG→179b1-19b0-4e657336a7280I↔Sat, 14 Sep 2013
12:35:06 GMTJ▬Apache/2.2.22 (Ubuntu)L☼Accept-EncodingM↑1.1 varnish, 1.1 
nghttpx@x-varnish
215791734♫╝ ☺

And at the end:

 Created using a href=http://sphinx.pocoo.org/;Sphinx/a 1.1.3.
   /div
 /body
/html   ☺   ☺

Some junk at the end too.

Another thing, using a Winsock-tracer lib I can see libcurl is still waiting on
more data on recv-socket:

* g:\mingw32\src\inet\curl\lib\select.c(466) (Curl_poll+584):
   select (n=1525, rd, wr, ex, {tv=1.00s}) -- No error.
 fd_input  - rd: 1524
  wr:
  ex:
 fd_output - rd:
  wr:
  ex:

-

I can see the Switching Protocols and Upgrade: HTTP/2.0 in the response.
But no Content-Length:. How is libcurl supposed to know when to stop 
receiving?

I'm using MSVC on Win-XP SP3.

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: HTTP 2.0 selects forever

2013-09-26 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:

I have a few local commits that make it slightly better but recently I've hit 
a little obstacle in nghttp2's API that I've been communicating with Tatsuhiro 
about how to solve[1]. I hope to be able to get something done on that soon so 
that I can get a first HTTP2 download transfer done properly.


Thanks for the clarification. But I'm a bit confused about the
relationship between HTTP2.0 and SPDY. Does NgHTTp2 require
libspdylay for libcurl do be usable with e.g. big players like YouTube and
Google? 


--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: HTTP 2.0 selects forever

2013-09-27 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:


On Thu, 26 Sep 2013, Tatsuhiro Tsujikawa wrote:

But SPDY will disappear when HTTP/2.0 is standardized, so there may be less 
incentive to invest the time to support SPDY now, but YMMV.


Exactly. SPDY was pioneered by Google and it is now being offered on many 
servers out there. But Google is also completely involved in the IETF effort 
for HTTP2 so I don't think we have any reasons do doubt that SPDY will be 
replaced with HTTP2 as soon as the spec has matured enough. HTTP2 will 
probably also have more supporters and implementors from the fraction that 
never liked SPDY...


Thank you Tatsuhiro  Daniel for the clarification.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


errno on lwIP

2013-10-09 Thread Gisle Vanem

lib/curl_setup_once.h assumes lwIP on Windows uses 'SetLastError()'
to set network errors. It doesn't; it uses 'errno'. Hence this little
patch:

--- g:/MingW32/src/inet/curl/Git-latest/lib/curl_setup_once.h   2013-02-23 
19:58:58 +
+++ g:/MingW32/src/inet/curl/lib/curl_setup_once.h  2013-08-23 20:10:25 
+
@@ -440,7 +440,7 @@
 * (or equivalent) on this platform to hide platform details to code using it.
 */

-#ifdef WIN32
+#if defined(WIN32)  !defined(USE_LWIPSOCK)
#define ERRNO ((int)GetLastError())
#define SET_ERRNO(x)  (SetLastError((DWORD)(x)))
#else

--gv


---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


[Patch] docs/examples/httpput.c

2013-10-22 Thread Gisle Vanem

Patch docs/examples/httpput.c for MSVC since it's missing unistd.h:

--- Git-latest/docs/examples/httpput.c 2013-01-28 15:48:38 +
+++ docs/examples/httpput.c2013-10-09 11:54:26 +
@@ -22,7 +22,9 @@
#include stdio.h
#include fcntl.h
#include sys/stat.h
-#include unistd.h
+#ifndef _MSC_VER
+#  include unistd.h
+#endif

#include curl/curl.h



But I'm not sure unistd.h is needed at all.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Question about some platform updates to Windows

2013-10-24 Thread Gisle Vanem

Myria myriac...@cox.net wrote:

I noticed that Windows does not define HAVE_GMTIME_R or HAVE_LOCALTIME_R. 
It is true that Visual Studio's C runtime library doesn't have gmtime_r, but 
it has a somewhat-equivalent API, gmtime_s.  gmtime_s's prototype is 
different, reversing the order of the two parameters and returning an errno 
error code instead of the tm* parameter.  (gmtime_s took its reentrancy more 
seriously than gmtime_r, and doesn't modify the thread-local variable 
errno.)  The same applies to localtime_r existing in Visual Studio as 
localtime_s.


Without opening a can of worms [*] by using this new _gmtime64_s() function, 
we could make a thread-safe Curl_gmtime() in libcurl too? It shouldn't be that 
hard; a call to gmtime64() protected inside a critical-section and with a push/pop 
of errno.


localtime_r() isn't used anywhere AFAICS. So what's this HAVE_LOCALTIME_R
all about?

By worms, I mean using a MSVCRT.DLL function in e.g. Vista that isn't 
available
 in Win-XP. So a libcurl.dll would not work everwhere.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [Patch] docs/examples/httpput.c

2013-10-24 Thread Gisle Vanem

Dan Fandrich d...@coneharvesters.com wrote:


But I'm not sure unistd.h is needed at all.


It's needed for close(2). But the only reason that's needed is because fstat
is used instead of stat(2); if you fix that, then you could remove that
include altogether.


Okay. I've tested the following with MSVC and MingW. htttput.c now
simply uses stat():

--- Git-latest/docs/examples/httpput.c 2013-01-28 15:48:38 +
+++ docs/examples/httpput.c2013-10-24 13:18:09 +
@@ -22,8 +22,6 @@
#include stdio.h
#include fcntl.h
#include sys/stat.h
-#include unistd.h
-
#include curl/curl.h

/*
@@ -59,7 +57,6 @@
  CURL *curl;
  CURLcode res;
  FILE * hd_src ;
-  int hd ;
  struct stat file_info;

  char *file;
@@ -72,9 +69,7 @@
  url = argv[2];

  /* get the file size of the local file */
-  hd = open(file, O_RDONLY) ;
-  fstat(hd, file_info);
-  close(hd) ;
+  stat(file, file_info);

  /* get a FILE * of the same file, could also be made with
 fdopen() from the previous descriptor, but hey this is just

---

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Program using libcurl

2013-10-25 Thread Gisle Vanem

Something to add to http://curl.haxx.se/libcurl/using/apps.html

PeerBlock [1] lets you control who your computer talks to on the Internet.  
By selecting appropriate lists of known bad computers, you can block 
communication with advertising or spyware oriented servers...


The PeerBlock program is using libcurl to update it's program and black-list. 
Shown here:

 
https://code.google.com/p/peerblock/source/browse/trunk/src/peerblock/updatelists.cpp

[1] http://www.peerblock.com/

--gv

---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [Bulk] I want to delete file from sftp bu libcurl, but...

2013-12-11 Thread Gisle Vanem

?? 506017...@qq.com wrote:


headerlist = curl_slist_append(headerlist, rm abc.c);
result = curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);


Maybe the command should be dele abc.c under this SFTP-server.

--gv 


---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Re: [Bulk] RE: Win32 use of GetVersionEx()

2014-01-17 Thread Gisle Vanem

Steve Holme steve_ho...@hotmail.com wrote:


Whilst this has fixed the native VC12 builds [1] I seem to have broken the 
mingw [2] auto builds :(

I'm guessing that these builds don't pull in the same header files as native 
build do, so does anyone know what I need to include?


For those functions to work, -D_WIN32_WINNT must be = _WIN32_WINNT_WIN2K.

--gv 


---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Wrong NgHTTP2 user-data

2014-01-29 Thread Gisle Vanem

Something is wrong in 'userp' for the HTTP2 recv_callback().
The session is created using bogus user-data; 'conn' and not
'conn'.

I noticed this since the socket-value in Curl_read_plain() was set to a
impossible high value. A patch:

--- orig/http2.c  2014-01-29 15:19:25 +
+++ http2.c 2014-01-29 16:38:07 +
@@ -111,12 +111,12 @@
{
  struct connectdata *conn = (struct connectdata *)userp;
  ssize_t nread;
-  CURLcode rc = Curl_read_plain(conn-sock[0], (char *)buf, length, nread);
+  CURLcode rc = Curl_read_plain(conn-sock[FIRSTSOCKET], (char *)buf, length, 
nread);
  (void)h2;
  (void)flags;

  if(rc) {
-failf(conn-data, Failed recving HTTP2 data);
+failf(conn-data, Failed receiving HTTP2 data);
return NGHTTP2_ERR_CALLBACK_FAILURE;
  }
  if(!nread)
@@ -169,7 +171,7 @@
  if(!conn-proto.httpc.h2) {
/* The nghttp2 session is not yet setup, do it */
int rc = nghttp2_session_client_new(conn-proto.httpc.h2,
-callbacks, conn);
+callbacks, conn);
if(rc) {
  failf(conn-data, Couldn't initialize nghttp2!);
  return CURLE_OUT_OF_MEMORY; /* most likely at least */

---

Things work bettter now:
  Upgrade: HTTP-draft-09/2.0
 * Received 101
 * We have switched to HTTP2
 * Failed receiving HTTP2 data

The last error seems to be due to a EWOULDBLOCK in the callback.
Should we maybe return NGHTTP2_ERR_WOULDBLOCK in this case?

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: Wrong NgHTTP2 user-data

2014-01-29 Thread Gisle Vanem

Something is wrong in 'userp' for the HTTP2 recv_callback().


Another patch for http2.c; the number of elements in the 
'nghttp2_session_callbacks' structure is now reduced by 2 in 
version 0.3.0 (I'm not sure when the change happened, but

checking for ver 0.3.0 work for me).

The excess initialisers gets passed by gcc, but not MSVC. It says:
 http2.c(149) : error C2078: too many initializers. 


So a patch like this would be in order:

--- orig/http2.c   2014-01-29 15:19:25 +
+++ http2.c 2014-01-29 16:54:23 +
@@ -140,9 +143,11 @@
  NULL,
  NULL,
  NULL,
-  NULL,
-  NULL,
  NULL
+#if (NGHTTP2_VERSION_NUM  0x000300)
+ ,NULL
+ ,NULL
+#endif
};

/*
---

--gv



---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [Bulk] Re: Wrong NgHTTP2 user-data

2014-01-29 Thread Gisle Vanem

Fabian Frank fabian.frank...@gmail.com wrote:

Do we already want to introduce ifdefs for backwards compatibility at this point? HTTP2 and nghttp2 are moving 
so fast and nothing is finalized yet, so it might make the code easier to maintain in the long run if we 
just mandate an exact (or the latest) nghttp2 version until things are more stabilized. What do you think?


Whatever you think is best. Or simply initialise the struct manually
and do a memset() for the remainder.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: [Bulk] Re: Why syntax error in release version of code in visual c++

2014-02-06 Thread Gisle Vanem

ansh kumar anshgrav...@gmail.com wrote:


Okay I've removed \0 from the buffer size.
1) I want to know why I'm getting following error if I use
CURLOPT_INFILESIZE_LARGE option instead of CURLOPT_INFILESIZE :


MAIL FROM:x...@gmail.com SIZE=141949047089924518


Did you cast the CURLOPT_INFILESIZE_LARGE argument (the file_size)
to 64-bit? And are you sure curl_off_t is 64-bit on your platform?

You can do:
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (unsigned long long)file_size);

to make sure the arg on the stack is correct.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


  1   2   3   >