|
|
|
@@ -7,11 +7,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
INTERNALS
|
|
|
|
INTERNALS
|
|
|
|
|
|
|
|
|
|
|
|
The project is kind of split in two. The library and the client. The client
|
|
|
|
The project is split in two. The library and the client. The client part uses
|
|
|
|
part uses the library, but the library is meant to be designed to allow other
|
|
|
|
the library, but the library is designed to allow other applications to use
|
|
|
|
applications to use it.
|
|
|
|
it.
|
|
|
|
|
|
|
|
|
|
|
|
Thus, the largest amount of code and complexity is in the library part.
|
|
|
|
The largest amount of code and complexity is in the library part.
|
|
|
|
|
|
|
|
|
|
|
|
CVS
|
|
|
|
CVS
|
|
|
|
===
|
|
|
|
===
|
|
|
|
@@ -35,13 +35,13 @@ Windows vs Unix
|
|
|
|
the same at all places except for the header file that defines them. The
|
|
|
|
the same at all places except for the header file that defines them. The
|
|
|
|
macros in use are sclose(), sread() and swrite().
|
|
|
|
macros in use are sclose(), sread() and swrite().
|
|
|
|
|
|
|
|
|
|
|
|
2. Windows requires a couple of init calls for the socket stuff
|
|
|
|
2. Windows requires a couple of init calls for the socket stuff.
|
|
|
|
|
|
|
|
|
|
|
|
Those must be made by the application that uses libcurl, in curl that means
|
|
|
|
Those must be made by the application that uses libcurl, in curl that means
|
|
|
|
src/main.c has some code #ifdef'ed to do just that.
|
|
|
|
src/main.c has some code #ifdef'ed to do just that.
|
|
|
|
|
|
|
|
|
|
|
|
3. The file descriptors for network communication and file operations are
|
|
|
|
3. The file descriptors for network communication and file operations are
|
|
|
|
not easily interchangable as in unix
|
|
|
|
not easily interchangable as in unix.
|
|
|
|
|
|
|
|
|
|
|
|
We avoid this by not trying any funny tricks on file descriptors.
|
|
|
|
We avoid this by not trying any funny tricks on file descriptors.
|
|
|
|
|
|
|
|
|
|
|
|
@@ -51,10 +51,10 @@ Windows vs Unix
|
|
|
|
|
|
|
|
|
|
|
|
We set stdout to binary under windows
|
|
|
|
We set stdout to binary under windows
|
|
|
|
|
|
|
|
|
|
|
|
Inside the source code, I do make an effort to avoid '#ifdef WIN32'. All
|
|
|
|
Inside the source code, We make an effort to avoid '#ifdef [Your OS]'. All
|
|
|
|
conditionals that deal with features *should* instead be in the format
|
|
|
|
conditionals that deal with features *should* instead be in the format
|
|
|
|
'#ifdef HAVE_THAT_WEIRD_FUNCTION'. Since Windows can't run configure scripts,
|
|
|
|
'#ifdef HAVE_THAT_WEIRD_FUNCTION'. Since Windows can't run configure scripts,
|
|
|
|
I maintain two config-win32.h files (one in / and one in src/) that are
|
|
|
|
we maintain two config-win32.h files (one in / and one in src/) that are
|
|
|
|
supposed to look exactly as a config.h file would have looked like on a
|
|
|
|
supposed to look exactly as a config.h file would have looked like on a
|
|
|
|
Windows machine!
|
|
|
|
Windows machine!
|
|
|
|
|
|
|
|
|
|
|
|
@@ -64,12 +64,6 @@ Windows vs Unix
|
|
|
|
Library
|
|
|
|
Library
|
|
|
|
=======
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
|
|
As described elsewhere, libcurl is meant to get two different "layers" of
|
|
|
|
|
|
|
|
interfaces. At the present point only the high-level, the "easy", interface
|
|
|
|
|
|
|
|
has been fully implemented and documented. We assume the easy-interface in
|
|
|
|
|
|
|
|
this description, the low-level interface will be documented when fully
|
|
|
|
|
|
|
|
implemented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
There are plenty of entry points to the library, namely each publicly defined
|
|
|
|
There are plenty of entry points to the library, namely each publicly defined
|
|
|
|
function that libcurl offers to applications. All of those functions are
|
|
|
|
function that libcurl offers to applications. All of those functions are
|
|
|
|
rather small and easy-to-follow. All the ones prefixed with 'curl_easy' are
|
|
|
|
rather small and easy-to-follow. All the ones prefixed with 'curl_easy' are
|
|
|
|
@@ -115,6 +109,22 @@ Library
|
|
|
|
When completed, the curl_easy_cleanup() should be called to free up used
|
|
|
|
When completed, the curl_easy_cleanup() should be called to free up used
|
|
|
|
resources.
|
|
|
|
resources.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A quick roundup on internal function sequences (many of these call
|
|
|
|
|
|
|
|
protocol-specific function-pointers):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
curl_connect - connects to a remote site and does initial connect fluff
|
|
|
|
|
|
|
|
This also checks for an existing connection to the requested site and uses
|
|
|
|
|
|
|
|
that one if it is possible.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
curl_do - starts a transfer
|
|
|
|
|
|
|
|
curl_transfer() - transfers data
|
|
|
|
|
|
|
|
curl_done - ends a transfer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
curl_disconnect - disconnects from a remote site. This is called when the
|
|
|
|
|
|
|
|
disconnect is really requested, which doesn't necessarily have to be
|
|
|
|
|
|
|
|
exactly after curl_done in case we want to keep the connection open for
|
|
|
|
|
|
|
|
a while.
|
|
|
|
|
|
|
|
|
|
|
|
HTTP(S)
|
|
|
|
HTTP(S)
|
|
|
|
|
|
|
|
|
|
|
|
HTTP offers a lot and is the protocol in curl that uses the most lines of
|
|
|
|
HTTP offers a lot and is the protocol in curl that uses the most lines of
|
|
|
|
@@ -130,6 +140,14 @@ Library
|
|
|
|
the source by the use of curl_read() for reading and curl_write() for writing
|
|
|
|
the source by the use of curl_read() for reading and curl_write() for writing
|
|
|
|
data to the remote server.
|
|
|
|
data to the remote server.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
http_chunks.c contains functions that understands HTTP 1.1 chunked transfer
|
|
|
|
|
|
|
|
encoding.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
An interesting detail with the HTTP(S) request, is the add_buffer() series of
|
|
|
|
|
|
|
|
functions we use. They append data to one single buffer, and when the
|
|
|
|
|
|
|
|
building is done the entire request is sent off in one single write. This is
|
|
|
|
|
|
|
|
done this way to overcome problems with flawed firewalls and lame servers.
|
|
|
|
|
|
|
|
|
|
|
|
FTP
|
|
|
|
FTP
|
|
|
|
|
|
|
|
|
|
|
|
The Curl_if2ip() function can be used for getting the IP number of a
|
|
|
|
The Curl_if2ip() function can be used for getting the IP number of a
|
|
|
|
@@ -265,12 +283,12 @@ Memory Debugging
|
|
|
|
deal with resources that might give us problems if we "leak" them. The
|
|
|
|
deal with resources that might give us problems if we "leak" them. The
|
|
|
|
functions in the memdebug system do nothing fancy, they do their normal
|
|
|
|
functions in the memdebug system do nothing fancy, they do their normal
|
|
|
|
function and then log information about what they just did. The logged data
|
|
|
|
function and then log information about what they just did. The logged data
|
|
|
|
is then analyzed after a complete session,
|
|
|
|
can then be analyzed after a complete session,
|
|
|
|
|
|
|
|
|
|
|
|
memanalyze.pl is a perl script present only in CVS (not part of the release
|
|
|
|
memanalyze.pl is a perl script present only present in CVS (not part of the
|
|
|
|
archives) that analyzes a log file generated by the memdebug system. It
|
|
|
|
release archives) that analyzes a log file generated by the memdebug
|
|
|
|
detects if resources are allocated but never freed and other kinds of errors
|
|
|
|
system. It detects if resources are allocated but never freed and other kinds
|
|
|
|
related to resource management.
|
|
|
|
of errors related to resource management.
|
|
|
|
|
|
|
|
|
|
|
|
Use -DMALLOCDEBUG when compiling to enable memory debugging.
|
|
|
|
Use -DMALLOCDEBUG when compiling to enable memory debugging.
|
|
|
|
|
|
|
|
|
|
|
|
|