Compare commits
54 Commits
curl-7_3
...
curl-7_4_1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f6163b375f | ||
![]() |
b2d73c50d3 | ||
![]() |
834b7de33c | ||
![]() |
debdd93e1b | ||
![]() |
4e8ddedc8f | ||
![]() |
751d503f54 | ||
![]() |
b2e47dfde4 | ||
![]() |
0af8201cc2 | ||
![]() |
7717212912 | ||
![]() |
ccb2b5d22c | ||
![]() |
85174ed358 | ||
![]() |
111d1d09d3 | ||
![]() |
4f5a4c9bd5 | ||
![]() |
8c62e337b0 | ||
![]() |
51bcdb472b | ||
![]() |
5ee185f420 | ||
![]() |
fb739ac130 | ||
![]() |
cdd91bed46 | ||
![]() |
9defb83930 | ||
![]() |
0f8facb49b | ||
![]() |
d49d05bce6 | ||
![]() |
1e2e6a4e33 | ||
![]() |
5b39a48e22 | ||
![]() |
2918836cef | ||
![]() |
b900318d8d | ||
![]() |
c58dc8f82f | ||
![]() |
0ddacf929a | ||
![]() |
a513e97464 | ||
![]() |
03a56b3e56 | ||
![]() |
18f67852be | ||
![]() |
693aab0e95 | ||
![]() |
ccd0f07c41 | ||
![]() |
5865860ad6 | ||
![]() |
bf56377865 | ||
![]() |
e012d32e66 | ||
![]() |
763797ab3c | ||
![]() |
2cdd150723 | ||
![]() |
d46b006f22 | ||
![]() |
033263e696 | ||
![]() |
eee5c71aff | ||
![]() |
f1b8566ea2 | ||
![]() |
d3f9b2a490 | ||
![]() |
398d21696f | ||
![]() |
99fbcac6b9 | ||
![]() |
c23e387928 | ||
![]() |
ef77d484f0 | ||
![]() |
df7b9e7af6 | ||
![]() |
f612f194be | ||
![]() |
dfec172157 | ||
![]() |
888182c16d | ||
![]() |
d5ad450db6 | ||
![]() |
b0274a553b | ||
![]() |
e372a440c0 | ||
![]() |
91bda5650c |
129
CHANGES
129
CHANGES
@@ -6,6 +6,135 @@
|
|||||||
|
|
||||||
History of Changes
|
History of Changes
|
||||||
|
|
||||||
|
Version 7.4.1
|
||||||
|
Daniel (16 October 2000)
|
||||||
|
- I forgot to remove some of the malloc debug defines from the makefiles in
|
||||||
|
the release archive (of course).
|
||||||
|
|
||||||
|
Version 7.4
|
||||||
|
|
||||||
|
Daniel (16 October 2000)
|
||||||
|
- The buffer overflow mentioned below was posted to bugtraq on Friday 13th.
|
||||||
|
|
||||||
|
Daniel (12 October 2000)
|
||||||
|
- Colin Robert Phipps elegantly corrected a buffer overflow. It could be used
|
||||||
|
by an evil ftp server to crash curl. I took the opportunity of replacing a
|
||||||
|
few other sprintf()s into snprintf()s as well.
|
||||||
|
|
||||||
|
Daniel (11 October 2000)
|
||||||
|
- Found some more memory leaks. This new simple memory debugger has turned out
|
||||||
|
really useful!
|
||||||
|
|
||||||
|
Version 7.4 pre6
|
||||||
|
|
||||||
|
Daniel (9 October 2000)
|
||||||
|
- Florian Koenig pointed out that the bool typedef in the curl/curl.h include
|
||||||
|
file was breaking PHP 4.0.3 compiling. The bool typedef is not used in the
|
||||||
|
public interface and was wrongly inserted in that header file.
|
||||||
|
|
||||||
|
- J<>rg Hartroth corrected a minor memory leak in the src/urlglob.c stuff. It
|
||||||
|
didn't harm anyone since the memory is free()ed on exit anyway.
|
||||||
|
|
||||||
|
- Corrected the src/main.c. We use the _MPRINTF_REPLACE #define to use our
|
||||||
|
libcurl-printf() functions. This gives us snprintf() et al on all
|
||||||
|
platforms. I converted the allocated useragent string to one that uses a
|
||||||
|
local buffer.
|
||||||
|
|
||||||
|
- I've set an #if 0 section around the Content-Transfer-Encoding header
|
||||||
|
generated in lib/formdata.c. This will hopefully make curl do more
|
||||||
|
PHP-friendly multi-part posts.
|
||||||
|
|
||||||
|
Version 7.4 pre5
|
||||||
|
|
||||||
|
Daniel (9 October 2000)
|
||||||
|
- Nico Baggus found out that curl's ability to force a ASCII download when
|
||||||
|
using FTP was no longer working! I corrected this. This problem was probably
|
||||||
|
introduced when I redesigned libcurl for version 7.
|
||||||
|
|
||||||
|
- Georg Horn provided a source example that proved a memory leak in libcurl.
|
||||||
|
I added simple memory debugging facilities and now we can make libcurl log
|
||||||
|
all memory fiddling functions. An additional perl script is used to analyze
|
||||||
|
the output logfile and to match malloc()s with free()s etc. The memory leak
|
||||||
|
Georg found turned out to be the main cookie struct that cookie_cleanup()
|
||||||
|
didn't free! The perl script is named memanalyze.pl and it is available in
|
||||||
|
the CVS respository, not in the release archive.
|
||||||
|
|
||||||
|
Daniel (8 October 2000)
|
||||||
|
- Georg Horn found a GetHost() problem. It turned out it never assigned the
|
||||||
|
pointer in the third argument properly! This could make a crash, or at best
|
||||||
|
a memory leak!
|
||||||
|
|
||||||
|
Version 7.4 pre4
|
||||||
|
|
||||||
|
Daniel (6 October 2000)
|
||||||
|
- Is the -F post following the RFC 1867 spec? We had this dicussion on the
|
||||||
|
mailing list since it appears curl can't post -F form posts to a PHP
|
||||||
|
receiver... I've been in touch with the PHP developers about this.
|
||||||
|
|
||||||
|
- Domenico Andreoli found out that the long option '--proxy' wasn't working
|
||||||
|
anymore! The option parser got confused when I added the --proxytunnel for
|
||||||
|
7.3. This was indeed a very old flaw that hasn't turned up until now...
|
||||||
|
|
||||||
|
- J<>rn Hartroth provided patches, updated makefiles and two new files for DLL
|
||||||
|
stuff on win32. He also pointed out that lib source files were compiled with
|
||||||
|
-I../src which isn't only wrong but plain stupid!
|
||||||
|
|
||||||
|
- Troels Walsted Hansen fixed a problem with HTTP resume. Curl previously used
|
||||||
|
a local variable badly, that could lead to crashes.
|
||||||
|
|
||||||
|
Version 7.4 pre3
|
||||||
|
|
||||||
|
Daniel (4 October 2000)
|
||||||
|
- More docs written. The curl_easy_getinfo.3 man page is now pretty accurate,
|
||||||
|
as is the -w section in curl.1. I added two options to enable the user to
|
||||||
|
get information about the received headers' size and the size of the HTTP
|
||||||
|
request. T. Bharath requested them.
|
||||||
|
|
||||||
|
Daniel (3 October 2000)
|
||||||
|
- Corrected a sever free() before use in the new add_buffer_send()! ;-)
|
||||||
|
|
||||||
|
Version 7.4 pre2
|
||||||
|
|
||||||
|
Daniel (3 October 2000)
|
||||||
|
- Jason S. Priebe sent me patches that changed the way curl issues HTTP
|
||||||
|
requests. The entire request is now issued in one single shot. It didn't do
|
||||||
|
this previously, and it has turned out that since the common browsers do it
|
||||||
|
this way, some sites have turned out to work with browsers but not with
|
||||||
|
curl! Although this is not a client-side problem, we want to be able to
|
||||||
|
fully emulate browsers, and thus we have now adjusted the networking layer
|
||||||
|
to slightly more appear as a browser. I adjusted Jason's patch, the faults
|
||||||
|
are probably mine.
|
||||||
|
|
||||||
|
Daniel (2 October 2000)
|
||||||
|
- Anyone who ever uploaded data with curl on a slow link has noticed that the
|
||||||
|
progess meter is updated very infrequently. That is due to the large buffer
|
||||||
|
size curl is using. It reads 50Kb and sends it, updates the progress meter
|
||||||
|
and loops. 50Kb is very much on a slow link, although it is pretty neat to
|
||||||
|
use on a fast one.
|
||||||
|
|
||||||
|
I've now made an adjustment that makes curl use a 2Kb buffer for uploads to
|
||||||
|
start with. If curl's average upload speed is faster than buffer size bytes
|
||||||
|
per second, curl will increase the used buffer size up to max 50Kb. It
|
||||||
|
should make the progress meter work better.
|
||||||
|
|
||||||
|
Version 7.4 pre1
|
||||||
|
|
||||||
|
Daniel (29 September 2000)
|
||||||
|
- Ripped out the -w stuff from the library and put in the curl tool. It gets
|
||||||
|
all the relevant info from the library using the new curl_easy_getinfo()
|
||||||
|
function.
|
||||||
|
|
||||||
|
- brad at openbsd.org mailed me a patch that corrected my kerberos mistake and
|
||||||
|
removed a compiler warning from hostip.c that OpenBSD people get.
|
||||||
|
|
||||||
|
Daniel (28 September 2000)
|
||||||
|
- Of course (I should probably get punished somehow) I didn't properly correct
|
||||||
|
the #include lines for the base64 stuff in the kerberos sources in the just
|
||||||
|
released 7.3 package. They still include the *_krb.h files! Now, the error
|
||||||
|
is sooo very easy to spot and fix so I won't bother with a quick bug fix
|
||||||
|
release. I'll post a patch whenever one is needed instead. It'll be
|
||||||
|
available in the CVS in a few minutes anyway.
|
||||||
|
|
||||||
Version 7.3
|
Version 7.3
|
||||||
|
|
||||||
Daniel (28 September 2000)
|
Daniel (28 September 2000)
|
||||||
|
3
FILES
3
FILES
@@ -49,6 +49,8 @@ src/setup.h
|
|||||||
src/urlglob.c
|
src/urlglob.c
|
||||||
src/urlglob.h
|
src/urlglob.h
|
||||||
src/version.h
|
src/version.h
|
||||||
|
src/writeout.c
|
||||||
|
src/writeout.h
|
||||||
src/*.in
|
src/*.in
|
||||||
src/*.am
|
src/*.am
|
||||||
src/mkhelp.pl
|
src/mkhelp.pl
|
||||||
@@ -60,6 +62,7 @@ lib/*in
|
|||||||
lib/*am
|
lib/*am
|
||||||
lib/Makefile.vc6
|
lib/Makefile.vc6
|
||||||
lib/*m32
|
lib/*m32
|
||||||
|
lib/libcurl.def
|
||||||
include/README
|
include/README
|
||||||
include/Makefile.in
|
include/Makefile.in
|
||||||
include/Makefile.am
|
include/Makefile.am
|
||||||
|
@@ -2,7 +2,7 @@ dnl $Id$
|
|||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
AC_INIT(lib/urldata.h)
|
AC_INIT(lib/urldata.h)
|
||||||
AM_CONFIG_HEADER(config.h src/config.h)
|
AM_CONFIG_HEADER(config.h src/config.h)
|
||||||
AM_INIT_AUTOMAKE(curl,"7.3")
|
AM_INIT_AUTOMAKE(curl,"7.4.1")
|
||||||
AM_PROG_LIBTOOL
|
AM_PROG_LIBTOOL
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
|
@@ -34,8 +34,7 @@ Windows vs Unix
|
|||||||
|
|
||||||
(3) is simply avoided by not trying any funny tricks on file descriptors.
|
(3) is simply avoided by not trying any funny tricks on file descriptors.
|
||||||
|
|
||||||
(4) is left alone, giving windows users problems when they pipe binary data
|
(4) we set stdout to binary under windows
|
||||||
through stdout...
|
|
||||||
|
|
||||||
Inside the source code, I do make an effort to avoid '#ifdef WIN32'. All
|
Inside the source code, I do make an effort to avoid '#ifdef WIN32'. All
|
||||||
conditionals that deal with features *should* instead be in the format
|
conditionals that deal with features *should* instead be in the format
|
||||||
@@ -84,10 +83,6 @@ Library
|
|||||||
called). The speedcheck functions in lib/speedcheck.c are also used to verify
|
called). The speedcheck functions in lib/speedcheck.c are also used to verify
|
||||||
that the transfer is as fast as required.
|
that the transfer is as fast as required.
|
||||||
|
|
||||||
When the operation is done, the writeout() function in lib/writeout.c may be
|
|
||||||
called to report about the operation as specified previously in the arguments
|
|
||||||
to curl_easy_setopt().
|
|
||||||
|
|
||||||
When completed curl_easy_cleanup() should be called to free up used
|
When completed curl_easy_cleanup() should be called to free up used
|
||||||
resources.
|
resources.
|
||||||
|
|
||||||
@@ -158,3 +153,9 @@ Client
|
|||||||
control after the curl_easy_perform() it cleans up the library, checks status
|
control after the curl_easy_perform() it cleans up the library, checks status
|
||||||
and exits.
|
and exits.
|
||||||
|
|
||||||
|
When the operation is done, the ourWriteOut() function in src/writeout.c may
|
||||||
|
be called to report about the operation. That function is using the
|
||||||
|
curl_easy_getinfo() function to extract useful information from the curl
|
||||||
|
session.
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
|
|||||||
man_MANS = \
|
man_MANS = \
|
||||||
curl.1 \
|
curl.1 \
|
||||||
curl_easy_cleanup.3 \
|
curl_easy_cleanup.3 \
|
||||||
|
curl_easy_getinfo.3 \
|
||||||
curl_easy_init.3 \
|
curl_easy_init.3 \
|
||||||
curl_easy_perform.3 \
|
curl_easy_perform.3 \
|
||||||
curl_easy_setopt.3 \
|
curl_easy_setopt.3 \
|
||||||
|
@@ -17,3 +17,8 @@ README.win32
|
|||||||
freely available nroff binary for win32 (*pointers appriciated*), convert
|
freely available nroff binary for win32 (*pointers appriciated*), convert
|
||||||
the files into plain-text on your neighbor's unix machine or run over to the
|
the files into plain-text on your neighbor's unix machine or run over to the
|
||||||
curl web site and view them as plain HTML.
|
curl web site and view them as plain HTML.
|
||||||
|
|
||||||
|
The main curl.1 man page is "built-in". Use a command line similar to this
|
||||||
|
in order to extract a separate text file:
|
||||||
|
|
||||||
|
curl -M >manual.txt
|
||||||
|
@@ -13,6 +13,14 @@ For the future
|
|||||||
product! (Yes, you may add things not mentioned here, these are just a
|
product! (Yes, you may add things not mentioned here, these are just a
|
||||||
few teasers...)
|
few teasers...)
|
||||||
|
|
||||||
|
* Improve the command line option parser to accept '-m300' as well as the '-m
|
||||||
|
300' convention. It should be able to work if '-m300' is considered to be
|
||||||
|
space separated to the next option.
|
||||||
|
|
||||||
|
* Make the SSL layer option capable of using the Mozilla Security Services as
|
||||||
|
an alternative to OpenSSL:
|
||||||
|
http://www.mozilla.org/projects/security/pki/nss/
|
||||||
|
|
||||||
* Make sure the low-level interface works. highlevel.c should basically be
|
* Make sure the low-level interface works. highlevel.c should basically be
|
||||||
possible to write using that interface. Document the low-level interface
|
possible to write using that interface. Document the low-level interface
|
||||||
|
|
||||||
|
@@ -410,11 +410,17 @@ The total amount of bytes that were downloaded.
|
|||||||
.B size_upload
|
.B size_upload
|
||||||
The total amount of bytes that were uploaded.
|
The total amount of bytes that were uploaded.
|
||||||
.TP
|
.TP
|
||||||
|
.B size_header
|
||||||
|
The total amount of bytes of the downloaded headers.
|
||||||
|
.TP
|
||||||
|
.B size_request
|
||||||
|
The total amount of bytes that were sent in the HTTP request.
|
||||||
|
.TP
|
||||||
.B speed_download
|
.B speed_download
|
||||||
The average download speed that curl measured for the complete download.
|
The average download speed that curl measured for the complete download.
|
||||||
.TP
|
.TP
|
||||||
.B speed_upload
|
.B speed_upload
|
||||||
The average upload speed that curl measured for the complete download.
|
The average upload speed that curl measured for the complete upload.
|
||||||
.RE
|
.RE
|
||||||
.IP "-x/--proxy <proxyhost[:port]>"
|
.IP "-x/--proxy <proxyhost[:port]>"
|
||||||
Use specified proxy. If the port number is not specified, it is assumed at
|
Use specified proxy. If the port number is not specified, it is assumed at
|
||||||
@@ -636,6 +642,7 @@ If you do find any (or have other suggestions), mail Daniel Stenberg
|
|||||||
- Stephen Kick <skick@epicrealm.com>
|
- Stephen Kick <skick@epicrealm.com>
|
||||||
- Martin Hedenfalk <mhe@stacken.kth.se>
|
- Martin Hedenfalk <mhe@stacken.kth.se>
|
||||||
- Richard Prescott
|
- Richard Prescott
|
||||||
|
- Jason S. Priebe <priebe@wral-tv.com>
|
||||||
|
|
||||||
.SH WWW
|
.SH WWW
|
||||||
http://curl.haxx.se
|
http://curl.haxx.se
|
||||||
|
81
docs/curl_easy_getinfo.3
Normal file
81
docs/curl_easy_getinfo.3
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
.\" You can view this file with:
|
||||||
|
.\" nroff -man [file]
|
||||||
|
.\" Written by daniel@haxx.se
|
||||||
|
.\"
|
||||||
|
.TH curl_easy_init 3 "2 October 2000" "Curl 7.4" "libcurl Manual"
|
||||||
|
.SH NAME
|
||||||
|
curl_easy_getinfo - Extract information from a curl session (added in 7.4)
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B #include <curl/easy.h>
|
||||||
|
.sp
|
||||||
|
.BI "CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... );"
|
||||||
|
.ad
|
||||||
|
.SH DESCRIPTION
|
||||||
|
Request internal information from the curl session with this function. The
|
||||||
|
third argument
|
||||||
|
.B MUST
|
||||||
|
be a pointer to a long, a pointer to a char * or a pointer to a double (as
|
||||||
|
this documentation describes further down). The data pointed-to will be
|
||||||
|
filled in accordingly and can be relied upon only if the function returns
|
||||||
|
CURLE_OK. This function is intended to get used *AFTER* a performed transfer,
|
||||||
|
all results from this function are undefined until the transfer is completed.
|
||||||
|
.SH AVAILABLE INFORMATION
|
||||||
|
These are informations that can be extracted:
|
||||||
|
.TP 0.8i
|
||||||
|
.B CURLINFO_EFFECTIVE_URL
|
||||||
|
Pass a pointer to a 'char *' to receive the last used effective URL.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_HTTP_CODE
|
||||||
|
Pass a pointer to a long to receive the last received HTTP code.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_TOTAL_TIME
|
||||||
|
Pass a pointer to a double to receive the total transaction time in seconds
|
||||||
|
for the previous transfer.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_NAMELOOKUP_TIME
|
||||||
|
Pass a pointer to a double to receive the time, in seconds, it took from the
|
||||||
|
start until the name resolving was completed.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_CONNECT_TIME
|
||||||
|
Pass a pointer to a double to receive the time, in seconds, it took from the
|
||||||
|
start until the connect to the remote host (or proxy) was completed.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_PRETRANSFER_TIME
|
||||||
|
Pass a pointer to a double to receive the time, in seconds, it took from the
|
||||||
|
start until the file transfer is just about to begin. This includes all
|
||||||
|
pre-transfer commands and negotiations that are specific to the particular
|
||||||
|
protocol(s) involved.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_SIZE_UPLOAD
|
||||||
|
Pass a pointer to a double to receive the total amount of bytes that were
|
||||||
|
uploaded.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_SIZE_DOWNLOAD
|
||||||
|
Pass a pointer to a double to receive the total amount of bytes that were
|
||||||
|
downloaded.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_SPEED_DOWNLOAD
|
||||||
|
Pass a pointer to a double to receive the average download speed that curl
|
||||||
|
measured for the complete download.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_SPEED_UPLOAD
|
||||||
|
Pass a pointer to a double to receive the average upload speed that curl
|
||||||
|
measured for the complete upload.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_HEADER_SIZE
|
||||||
|
Pass a pointer to a long to receive the total size of all the headers
|
||||||
|
received.
|
||||||
|
.TP
|
||||||
|
.B CURLINFO_REQUEST_SIZE
|
||||||
|
Pass a pointer to a long to receive the total size of the issued
|
||||||
|
requests. This is so far only for HTTP requests. Note that this may be more
|
||||||
|
than one request if FOLLOWLOCATION is true.
|
||||||
|
.PP
|
||||||
|
|
||||||
|
.SH RETURN VALUE
|
||||||
|
If the operation was successful, CURLE_OK is returned. Otherwise an
|
||||||
|
appropriate error code will be returned.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
.BR curl_easy_setopt "(3)"
|
||||||
|
.SH BUGS
|
||||||
|
Surely there are some, you tell me!
|
@@ -330,6 +330,7 @@ will be used. Set the string to NULL to disable kerberos4. The kerberos
|
|||||||
support only works for FTP. (Added in libcurl 7.3)
|
support only works for FTP. (Added in libcurl 7.3)
|
||||||
.TP
|
.TP
|
||||||
.B CURLOPT_WRITEINFO
|
.B CURLOPT_WRITEINFO
|
||||||
|
(NOT PRESENT IN 7.4 or later!)
|
||||||
Pass a pointer to a zero terminated string as parameter. It will be used to
|
Pass a pointer to a zero terminated string as parameter. It will be used to
|
||||||
report information after a successful request. This string may contain
|
report information after a successful request. This string may contain
|
||||||
variables that will be substituted by their contents when output. Described
|
variables that will be substituted by their contents when output. Described
|
||||||
|
@@ -412,10 +412,6 @@ typedef enum {
|
|||||||
|
|
||||||
#ifdef __BEOS__
|
#ifdef __BEOS__
|
||||||
#include <support/SupportDefs.h>
|
#include <support/SupportDefs.h>
|
||||||
#else
|
|
||||||
#ifndef __cplusplus /* (rabe) */
|
|
||||||
typedef char bool;
|
|
||||||
#endif /* (rabe) */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -438,14 +434,14 @@ int curl_formparse(char *string,
|
|||||||
MUST be free()ed after usage is complete. */
|
MUST be free()ed after usage is complete. */
|
||||||
char *curl_getenv(char *variable);
|
char *curl_getenv(char *variable);
|
||||||
|
|
||||||
/* returns ascii string of the libcurl version */
|
/* Returns a static ascii string of the libcurl version. */
|
||||||
char *curl_version(void);
|
char *curl_version(void);
|
||||||
|
|
||||||
/* This is the version number */
|
/* This is the version number */
|
||||||
#define LIBCURL_VERSION "7.3"
|
#define LIBCURL_VERSION "7.4.1"
|
||||||
#define LIBCURL_VERSION_NUM 0x070300
|
#define LIBCURL_VERSION_NUM 0x070401
|
||||||
|
|
||||||
/* linked-list structure for the CURLOPT_QUOTE option */
|
/* linked-list structure for the CURLOPT_QUOTE option (and other) */
|
||||||
struct curl_slist {
|
struct curl_slist {
|
||||||
char *data;
|
char *data;
|
||||||
struct curl_slist *next;
|
struct curl_slist *next;
|
||||||
@@ -642,6 +638,45 @@ CURLcode curl_disconnect(CURLconnect *connect);
|
|||||||
*/
|
*/
|
||||||
time_t curl_getdate(const char *p, const time_t *now);
|
time_t curl_getdate(const char *p, const time_t *now);
|
||||||
|
|
||||||
|
|
||||||
|
#define CURLINFO_STRING 0x100000
|
||||||
|
#define CURLINFO_LONG 0x200000
|
||||||
|
#define CURLINFO_DOUBLE 0x300000
|
||||||
|
#define CURLINFO_MASK 0x0fffff
|
||||||
|
#define CURLINFO_TYPEMASK 0xf00000
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CURLINFO_NONE, /* first, never use this */
|
||||||
|
CURLINFO_EFFECTIVE_URL = CURLINFO_STRING + 1,
|
||||||
|
CURLINFO_HTTP_CODE = CURLINFO_LONG + 2,
|
||||||
|
CURLINFO_TOTAL_TIME = CURLINFO_DOUBLE + 3,
|
||||||
|
CURLINFO_NAMELOOKUP_TIME = CURLINFO_DOUBLE + 4,
|
||||||
|
CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5,
|
||||||
|
CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,
|
||||||
|
CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7,
|
||||||
|
CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8,
|
||||||
|
CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9,
|
||||||
|
CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10,
|
||||||
|
CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11,
|
||||||
|
CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12,
|
||||||
|
|
||||||
|
CURLINFO_LASTONE = 13,
|
||||||
|
} CURLINFO;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_getinfo()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Request internal information from the curl session with this function.
|
||||||
|
* The third argument MUST be a pointer to a long or a pointer to a char *.
|
||||||
|
* The data pointed to will be filled in accordingly and can be relied upon
|
||||||
|
* only if the function returns CURLE_OK.
|
||||||
|
* This function is intended to get used *AFTER* a performed transfer, all
|
||||||
|
* results are undefined before the transfer is completed.
|
||||||
|
*/
|
||||||
|
CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -48,6 +48,21 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
|
|||||||
CURLcode curl_easy_perform(CURL *curl);
|
CURLcode curl_easy_perform(CURL *curl);
|
||||||
void curl_easy_cleanup(CURL *curl);
|
void curl_easy_cleanup(CURL *curl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NAME curl_easy_getinfo()
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
*
|
||||||
|
* Request internal information from the curl session with this function. The
|
||||||
|
* third argument MUST be a pointer to a long, a pointer to a char * or a
|
||||||
|
* pointer to a double (as the documentation describes elsewhere). The data
|
||||||
|
* pointed to will be filled in accordingly and can be relied upon only if the
|
||||||
|
* function returns CURLE_OK. This function is intended to get used *AFTER* a
|
||||||
|
* performed transfer, all results from this function are undefined until the
|
||||||
|
* transfer is completed.
|
||||||
|
*/
|
||||||
|
CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -7,7 +7,7 @@ AUTOMAKE_OPTIONS = foreign
|
|||||||
lib_LTLIBRARIES = libcurl.la
|
lib_LTLIBRARIES = libcurl.la
|
||||||
|
|
||||||
# Some flags needed when trying to cause warnings ;-)
|
# Some flags needed when trying to cause warnings ;-)
|
||||||
# CFLAGS = -g -Wall #-pedantic
|
# CFLAGS = -DMALLOCDEBUG -g # -Wall #-pedantic
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/include
|
INCLUDES = -I$(top_srcdir)/include
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ download.c getdate.h ldap.c ssluse.c version.c \
|
|||||||
download.h getenv.c ldap.h ssluse.h \
|
download.h getenv.c ldap.h ssluse.h \
|
||||||
escape.c getenv.h mprintf.c telnet.c \
|
escape.c getenv.h mprintf.c telnet.c \
|
||||||
escape.h getpass.c netrc.c telnet.h \
|
escape.h getpass.c netrc.c telnet.h \
|
||||||
writeout.c writeout.h highlevel.c strequal.c strequal.h easy.c \
|
getinfo.c highlevel.c strequal.c strequal.h easy.c \
|
||||||
security.h security.c krb4.c
|
security.h security.c krb4.c memdebug.c memdebug.h
|
||||||
|
|
||||||
# Say $(srcdir), so GNU make does not report an ambiguity with the .y.c rule.
|
# Say $(srcdir), so GNU make does not report an ambiguity with the .y.c rule.
|
||||||
$(srcdir)/getdate.c: getdate.y
|
$(srcdir)/getdate.c: getdate.y
|
||||||
|
@@ -82,11 +82,11 @@ AUTOMAKE_OPTIONS = foreign
|
|||||||
lib_LTLIBRARIES = libcurl.la
|
lib_LTLIBRARIES = libcurl.la
|
||||||
|
|
||||||
# Some flags needed when trying to cause warnings ;-)
|
# Some flags needed when trying to cause warnings ;-)
|
||||||
# CFLAGS = -g -Wall #-pedantic
|
# CFLAGS = -DMALLOCDEBUG -g # -Wall #-pedantic
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/include
|
INCLUDES = -I$(top_srcdir)/include
|
||||||
|
|
||||||
libcurl_la_SOURCES = arpa_telnet.h file.c getpass.h netrc.h timeval.c base64.c file.h hostip.c progress.c timeval.h base64.h formdata.c hostip.h progress.h cookie.c formdata.h http.c sendf.c cookie.h ftp.c http.h sendf.h url.c dict.c ftp.h if2ip.c speedcheck.c url.h dict.h getdate.c if2ip.h speedcheck.h urldata.h download.c getdate.h ldap.c ssluse.c version.c download.h getenv.c ldap.h ssluse.h escape.c getenv.h mprintf.c telnet.c escape.h getpass.c netrc.c telnet.h writeout.c writeout.h highlevel.c strequal.c strequal.h easy.c security.h security.c krb4.c
|
libcurl_la_SOURCES = arpa_telnet.h file.c getpass.h netrc.h timeval.c base64.c file.h hostip.c progress.c timeval.h base64.h formdata.c hostip.h progress.h cookie.c formdata.h http.c sendf.c cookie.h ftp.c http.h sendf.h url.c dict.c ftp.h if2ip.c speedcheck.c url.h dict.h getdate.c if2ip.h speedcheck.h urldata.h download.c getdate.h ldap.c ssluse.c version.c download.h getenv.c ldap.h ssluse.h escape.c getenv.h mprintf.c telnet.c escape.h getpass.c netrc.c telnet.h getinfo.c highlevel.c strequal.c strequal.h easy.c security.h security.c krb4.c memdebug.c memdebug.h
|
||||||
|
|
||||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||||
CONFIG_HEADER = ../config.h ../src/config.h
|
CONFIG_HEADER = ../config.h ../src/config.h
|
||||||
@@ -103,8 +103,8 @@ libcurl_la_LIBADD =
|
|||||||
libcurl_la_OBJECTS = file.lo timeval.lo base64.lo hostip.lo progress.lo \
|
libcurl_la_OBJECTS = file.lo timeval.lo base64.lo hostip.lo progress.lo \
|
||||||
formdata.lo cookie.lo http.lo sendf.lo ftp.lo url.lo dict.lo if2ip.lo \
|
formdata.lo cookie.lo http.lo sendf.lo ftp.lo url.lo dict.lo if2ip.lo \
|
||||||
speedcheck.lo getdate.lo download.lo ldap.lo ssluse.lo version.lo \
|
speedcheck.lo getdate.lo download.lo ldap.lo ssluse.lo version.lo \
|
||||||
getenv.lo escape.lo mprintf.lo telnet.lo getpass.lo netrc.lo \
|
getenv.lo escape.lo mprintf.lo telnet.lo getpass.lo netrc.lo getinfo.lo \
|
||||||
writeout.lo highlevel.lo strequal.lo easy.lo security.lo krb4.lo
|
highlevel.lo strequal.lo easy.lo security.lo krb4.lo memdebug.lo
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
151
lib/Makefile.m32
151
lib/Makefile.m32
@@ -1,70 +1,81 @@
|
|||||||
#############################################################
|
#############################################################
|
||||||
## Makefile for building libcurl.a with MingW32 (GCC-2.95) and
|
## Makefile for building libcurl.a with MingW32 (GCC-2.95) and
|
||||||
## optionally OpenSSL (0.9.4)
|
## optionally OpenSSL (0.9.6)
|
||||||
## Use: make -f Makefile.m32
|
## Use: make -f Makefile.m32
|
||||||
##
|
##
|
||||||
## Comments to: Troy Engel <tengel@sonic.net> or
|
## Comments to: Troy Engel <tengel@sonic.net> or
|
||||||
## Joern Hartroth <hartroth@acm.org>
|
## Joern Hartroth <hartroth@acm.org>
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
AR = ar
|
AR = ar
|
||||||
RANLIB = ranlib
|
RANLIB = ranlib
|
||||||
OPENSSL_PATH = ../../openssl-0.9.5a
|
STRIP = strip -g
|
||||||
|
OPENSSL_PATH = ../../openssl-0.9.6
|
||||||
########################################################
|
|
||||||
## Nothing more to do below this line!
|
########################################################
|
||||||
|
## Nothing more to do below this line!
|
||||||
INCLUDES = -I. -I.. -I../include
|
|
||||||
CFLAGS = -g -O2 -DMINGW32
|
INCLUDES = -I. -I.. -I../include -I../src
|
||||||
ifdef SSL
|
CFLAGS = -g -O2 -DMINGW32
|
||||||
INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl"
|
ifdef SSL
|
||||||
CFLAGS += -DUSE_SSLEAY
|
INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl"
|
||||||
endif
|
CFLAGS += -DUSE_SSLEAY
|
||||||
COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
|
DLL_LIBS = -leay32 -lssl32 -lRSAglue
|
||||||
|
endif
|
||||||
libcurl_a_LIBRARIES = libcurl.a
|
COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
|
||||||
|
|
||||||
libcurl_a_SOURCES = base64.c getenv.c if2ip.h progress.h \
|
libcurl_a_LIBRARIES = libcurl.a
|
||||||
base64.h getenv.h mprintf.c setup.h url.c download.c getpass.c \
|
|
||||||
mprintf.h ssluse.c url.h download.h hostip.c netrc.c ssluse.h \
|
libcurl_a_SOURCES = arpa_telnet.h file.c getpass.h netrc.h timeval.c base64.c \
|
||||||
urldata.h formdata.c hostip.h netrc.h stdcheaders.h formdata.h \
|
file.h hostip.c progress.c timeval.h base64.h formdata.c hostip.h progress.h \
|
||||||
if2ip.c progress.c sendf.c sendf.h speedcheck.c speedcheck.h \
|
cookie.c formdata.h http.c sendf.c cookie.h ftp.c http.h sendf.h url.c dict.c \
|
||||||
ftp.c ftp.h getpass.h version.c timeval.c timeval.h cookie.c \
|
ftp.h if2ip.c speedcheck.c url.h dict.h getdate.c if2ip.h speedcheck.h \
|
||||||
cookie.h escape.c escape.h getdate.c getdate.h dict.h dict.c http.c \
|
urldata.h download.c getdate.h ldap.c ssluse.c version.c download.h getenv.c \
|
||||||
http.h telnet.c telnet.h file.c file.h ldap.c ldap.h writeout.c writeout.h \
|
ldap.h ssluse.h escape.c getenv.h mprintf.c telnet.c escape.h getpass.c netrc.c \
|
||||||
highlevel.c strequal.c strequal.h easy.c
|
telnet.h getinfo.c highlevel.c strequal.c strequal.h easy.c security.h \
|
||||||
|
security.c krb4.c
|
||||||
libcurl_a_OBJECTS = base64.o getenv.o mprintf.o url.o download.o \
|
|
||||||
getpass.o ssluse.o hostip.o netrc.o formdata.o if2ip.o progress.o \
|
libcurl_a_OBJECTS = file.o timeval.o base64.o hostip.o progress.o \
|
||||||
sendf.o speedcheck.o ftp.o version.o timeval.o \
|
formdata.o cookie.o http.o sendf.o ftp.o url.o dict.o if2ip.o \
|
||||||
cookie.o escape.o getdate.o dict.o http.o telnet.o file.o ldap.o writeout.o \
|
speedcheck.o getdate.o download.o ldap.o ssluse.o version.o \
|
||||||
highlevel.o strequal.o easy.o
|
getenv.o escape.o mprintf.o telnet.o getpass.o netrc.o getinfo.o \
|
||||||
|
highlevel.o strequal.o easy.o security.o krb4.o
|
||||||
LIBRARIES = $(libcurl_a_LIBRARIES)
|
|
||||||
SOURCES = $(libcurl_a_SOURCES)
|
LIBRARIES = $(libcurl_a_LIBRARIES)
|
||||||
OBJECTS = $(libcurl_a_OBJECTS)
|
SOURCES = $(libcurl_a_SOURCES)
|
||||||
|
OBJECTS = $(libcurl_a_OBJECTS)
|
||||||
|
|
||||||
all: libcurl.a
|
|
||||||
|
all: libcurl.a libcurl.dll libcurldll.a
|
||||||
libcurl.a: $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
|
|
||||||
-@erase libcurl.a
|
libcurl.a: $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
|
||||||
$(AR) cru libcurl.a $(libcurl_a_OBJECTS)
|
-@erase libcurl.a
|
||||||
$(RANLIB) libcurl.a
|
$(AR) cru libcurl.a $(libcurl_a_OBJECTS)
|
||||||
|
$(RANLIB) libcurl.a
|
||||||
.c.o:
|
$(STRIP) $@
|
||||||
$(COMPILE) -c $<
|
|
||||||
|
# remove the last line above to keep debug info
|
||||||
.s.o:
|
|
||||||
$(COMPILE) -c $<
|
libcurl.dll libcurldll.a: libcurl.a libcurl.def dllinit.o
|
||||||
|
-@erase $@
|
||||||
.S.o:
|
dllwrap --dllname $@ --output-lib libcurldll.a --export-all --def libcurl.def $(libcurl_a_LIBRARIES) dllinit.o -L$(OPENSSL_PATH)/out $(DLL_LIBS) -lwsock32
|
||||||
$(COMPILE) -c $<
|
$(STRIP) $@
|
||||||
|
|
||||||
clean:
|
# remove the last line above to keep debug info
|
||||||
-@erase $(libcurl_a_OBJECTS)
|
|
||||||
|
.c.o:
|
||||||
distrib: clean
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
-@erase $(libcurl_a_LIBRARIES)
|
.s.o:
|
||||||
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
|
.S.o:
|
||||||
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-@erase $(libcurl_a_OBJECTS)
|
||||||
|
|
||||||
|
distrib: clean
|
||||||
|
|
||||||
|
-@erase $(libcurl_a_LIBRARIES)
|
||||||
|
|
||||||
|
@@ -38,6 +38,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
static int pos(char c)
|
static int pos(char c)
|
||||||
|
@@ -65,6 +65,11 @@ Example set of cookies:
|
|||||||
#include "getdate.h"
|
#include "getdate.h"
|
||||||
#include "strequal.h"
|
#include "strequal.h"
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* cookie_add()
|
* cookie_add()
|
||||||
@@ -496,6 +501,7 @@ void cookie_cleanup(struct CookieInfo *c)
|
|||||||
free(co);
|
free(co);
|
||||||
co = next;
|
co = next;
|
||||||
}
|
}
|
||||||
|
free(c); /* free the base struct as well */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
82
lib/dllinit.c
Normal file
82
lib/dllinit.c
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/* dllinit.c -- Portable DLL initialization.
|
||||||
|
Copyright (C) 1998, 1999 Free Software Foundation, Inc.
|
||||||
|
Contributed by Mumit Khan (khan@xraylith.wisc.edu).
|
||||||
|
|
||||||
|
I've used DllMain as the DLL "main" since that's the most common
|
||||||
|
usage. MSVC and Mingw32 both default to DllMain as the standard
|
||||||
|
callback from the linker entry point. Cygwin, as of b20.1, also
|
||||||
|
uses DllMain as the default callback from the entry point.
|
||||||
|
|
||||||
|
The real entry point is typically always defined by the runtime
|
||||||
|
library, and usually never overridden by (casual) user. What you can
|
||||||
|
override however is the callback routine that the entry point calls,
|
||||||
|
and this file provides such a callback function, DllMain.
|
||||||
|
|
||||||
|
Mingw32: The default entry point for mingw32 is DllMainCRTStartup
|
||||||
|
which is defined in libmingw32.a This in turn calls DllMain which is
|
||||||
|
defined here. If not defined, there is a stub in libmingw32.a which
|
||||||
|
does nothing.
|
||||||
|
|
||||||
|
Cygwin: The default entry point for Cygwin b20.1 or newer is
|
||||||
|
__cygwin_dll_entry which is defined in libcygwin.a. This in turn
|
||||||
|
calls the routine DllMain. If not defined, there is a stub in
|
||||||
|
libcygwin.a which does nothing.
|
||||||
|
|
||||||
|
MSVC: MSVC runtime calls DllMain, just like Mingw32.
|
||||||
|
|
||||||
|
Summary: If you need to do anything special in DllMain, just add it
|
||||||
|
here. Otherwise, the default setup should be just fine for 99%+ of
|
||||||
|
the time. I strongly suggest that you *not* change the entry point,
|
||||||
|
but rather change DllMain as appropriate.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
|
#undef WIN32_LEAN_AND_MEAN
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason,
|
||||||
|
LPVOID reserved /* Not used. */ );
|
||||||
|
|
||||||
|
/*
|
||||||
|
*----------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* DllMain --
|
||||||
|
*
|
||||||
|
* This routine is called by the Mingw32, Cygwin32 or VC++ C run
|
||||||
|
* time library init code, or the Borland DllEntryPoint routine. It
|
||||||
|
* is responsible for initializing various dynamically loaded
|
||||||
|
* libraries.
|
||||||
|
*
|
||||||
|
* Results:
|
||||||
|
* TRUE on sucess, FALSE on failure.
|
||||||
|
*
|
||||||
|
* Side effects:
|
||||||
|
*
|
||||||
|
*----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
BOOL APIENTRY
|
||||||
|
DllMain (
|
||||||
|
HINSTANCE hInst /* Library instance handle. */ ,
|
||||||
|
DWORD reason /* Reason this function is being called. */ ,
|
||||||
|
LPVOID reserved /* Not used. */ )
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (reason)
|
||||||
|
{
|
||||||
|
case DLL_PROCESS_ATTACH:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DLL_PROCESS_DETACH:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DLL_THREAD_ATTACH:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DLL_THREAD_DETACH:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
10
lib/easy.c
10
lib/easy.c
@@ -162,3 +162,13 @@ void curl_easy_cleanup(CURL *curl)
|
|||||||
curl_close(curl);
|
curl_close(curl);
|
||||||
curl_free();
|
curl_free();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...)
|
||||||
|
{
|
||||||
|
va_list arg;
|
||||||
|
void *paramp;
|
||||||
|
va_start(arg, info);
|
||||||
|
paramp = va_arg(arg, void *);
|
||||||
|
|
||||||
|
return curl_getinfo(curl, info, paramp);
|
||||||
|
}
|
||||||
|
@@ -48,6 +48,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
char *curl_escape(char *string)
|
char *curl_escape(char *string)
|
||||||
{
|
{
|
||||||
int alloc=strlen(string)+1;
|
int alloc=strlen(string)+1;
|
||||||
|
@@ -63,6 +63,11 @@
|
|||||||
|
|
||||||
#include "strequal.h"
|
#include "strequal.h"
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Length of the random boundary string. The risk of this being used
|
/* Length of the random boundary string. The risk of this being used
|
||||||
in binary data is very close to zero, 64^32 makes
|
in binary data is very close to zero, 64^32 makes
|
||||||
6277101735386680763835789423207666416102355444464034512896
|
6277101735386680763835789423207666416102355444464034512896
|
||||||
@@ -458,12 +463,20 @@ struct FormData *getFormData(struct HttpPost *post,
|
|||||||
"\r\nContent-Type: %s",
|
"\r\nContent-Type: %s",
|
||||||
file->contenttype);
|
file->contenttype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* The header Content-Transfer-Encoding: seems to confuse some receivers
|
||||||
|
* (like the built-in PHP engine). While I can't see any reason why it
|
||||||
|
* should, I can just as well skip this to the benefit of the users who
|
||||||
|
* are using such confused receivers.
|
||||||
|
*/
|
||||||
|
|
||||||
if(file->contenttype &&
|
if(file->contenttype &&
|
||||||
!strnequal("text/", file->contenttype, 5)) {
|
!strnequal("text/", file->contenttype, 5)) {
|
||||||
/* this is not a text content, mention our binary encoding */
|
/* this is not a text content, mention our binary encoding */
|
||||||
size += AddFormData(&form, "\r\nContent-Transfer-Encoding: binary", 0);
|
size += AddFormData(&form, "\r\nContent-Transfer-Encoding: binary", 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
size += AddFormData(&form, "\r\n\r\n", 0);
|
size += AddFormData(&form, "\r\n\r\n", 0);
|
||||||
|
|
||||||
|
@@ -89,6 +89,10 @@
|
|||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#endif
|
#endif
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* returns last node in linked list */
|
/* returns last node in linked list */
|
||||||
static struct curl_slist *slist_get_last(struct curl_slist *list)
|
static struct curl_slist *slist_get_last(struct curl_slist *list)
|
||||||
@@ -584,7 +588,8 @@ CURLcode ftp_done(struct connectdata *conn)
|
|||||||
if(ftp->dir)
|
if(ftp->dir)
|
||||||
free(ftp->dir);
|
free(ftp->dir);
|
||||||
|
|
||||||
/* TBD: the ftp struct is still allocated here */
|
free(ftp);
|
||||||
|
data->proto.ftp=NULL; /* it is gone */
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@@ -1178,7 +1183,7 @@ CURLcode _ftp(struct connectdata *conn)
|
|||||||
else {
|
else {
|
||||||
/* Set type to binary (unless specified ASCII) */
|
/* Set type to binary (unless specified ASCII) */
|
||||||
ftpsendf(data->firstsocket, conn, "TYPE %s",
|
ftpsendf(data->firstsocket, conn, "TYPE %s",
|
||||||
(data->bits.ftp_list_only)?"A":"I");
|
(data->bits.ftp_ascii)?"A":"I");
|
||||||
|
|
||||||
nread = GetLastResponse(data->firstsocket, buf, conn);
|
nread = GetLastResponse(data->firstsocket, buf, conn);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
|
@@ -45,6 +45,10 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
char *GetEnv(char *variable)
|
char *GetEnv(char *variable)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
124
lib/getinfo.c
Normal file
124
lib/getinfo.c
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License
|
||||||
|
* Version 1.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS"
|
||||||
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing rights and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is Curl.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Daniel Stenberg.
|
||||||
|
*
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 1999.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
* Main author:
|
||||||
|
* - Daniel Stenberg <daniel@haxx.se>
|
||||||
|
*
|
||||||
|
* http://curl.haxx.se
|
||||||
|
*
|
||||||
|
* $Source$
|
||||||
|
* $Revision$
|
||||||
|
* $Date$
|
||||||
|
* $Author$
|
||||||
|
* $State$
|
||||||
|
* $Locker$
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "setup.h"
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
#include "urldata.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
CURLcode curl_getinfo(CURL *curl, CURLINFO info, ...)
|
||||||
|
{
|
||||||
|
va_list arg;
|
||||||
|
long *param_longp;
|
||||||
|
double *param_doublep;
|
||||||
|
char **param_charp;
|
||||||
|
struct UrlData *data = (struct UrlData *)curl;
|
||||||
|
va_start(arg, info);
|
||||||
|
|
||||||
|
switch(info&CURLINFO_TYPEMASK) {
|
||||||
|
default:
|
||||||
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
case CURLINFO_STRING:
|
||||||
|
param_charp = va_arg(arg, char **);
|
||||||
|
if(NULL == param_charp)
|
||||||
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
break;
|
||||||
|
case CURLINFO_LONG:
|
||||||
|
param_longp = va_arg(arg, long *);
|
||||||
|
if(NULL == param_longp)
|
||||||
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
break;
|
||||||
|
case CURLINFO_DOUBLE:
|
||||||
|
param_doublep = va_arg(arg, double *);
|
||||||
|
if(NULL == param_doublep)
|
||||||
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(info) {
|
||||||
|
case CURLINFO_EFFECTIVE_URL:
|
||||||
|
*param_charp = data->url?data->url:"";
|
||||||
|
break;
|
||||||
|
case CURLINFO_HTTP_CODE:
|
||||||
|
*param_longp = data->progress.httpcode;
|
||||||
|
break;
|
||||||
|
case CURLINFO_HEADER_SIZE:
|
||||||
|
*param_longp = data->header_size;
|
||||||
|
break;
|
||||||
|
case CURLINFO_REQUEST_SIZE:
|
||||||
|
*param_longp = data->request_size;
|
||||||
|
break;
|
||||||
|
case CURLINFO_TOTAL_TIME:
|
||||||
|
*param_doublep = data->progress.timespent;
|
||||||
|
break;
|
||||||
|
case CURLINFO_NAMELOOKUP_TIME:
|
||||||
|
*param_doublep = tvdiff(data->progress.t_nslookup,
|
||||||
|
data->progress.start);
|
||||||
|
break;
|
||||||
|
case CURLINFO_CONNECT_TIME:
|
||||||
|
*param_doublep = tvdiff(data->progress.t_connect,
|
||||||
|
data->progress.start);
|
||||||
|
break;
|
||||||
|
case CURLINFO_PRETRANSFER_TIME:
|
||||||
|
*param_doublep = tvdiff(data->progress.t_pretransfer,
|
||||||
|
data->progress.start);
|
||||||
|
break;
|
||||||
|
case CURLINFO_SIZE_UPLOAD:
|
||||||
|
*param_doublep = data->progress.uploaded;
|
||||||
|
break;
|
||||||
|
case CURLINFO_SIZE_DOWNLOAD:
|
||||||
|
*param_doublep = data->progress.downloaded;
|
||||||
|
break;
|
||||||
|
case CURLINFO_SPEED_DOWNLOAD:
|
||||||
|
*param_doublep = data->progress.dlspeed;
|
||||||
|
break;
|
||||||
|
case CURLINFO_SPEED_UPLOAD:
|
||||||
|
*param_doublep = data->progress.ulspeed;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
}
|
||||||
|
return CURLE_OK;
|
||||||
|
}
|
@@ -107,11 +107,19 @@
|
|||||||
#include "getpass.h"
|
#include "getpass.h"
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
#include "getdate.h"
|
#include "getdate.h"
|
||||||
#include "writeout.h"
|
|
||||||
|
|
||||||
#define _MPRINTF_REPLACE /* use our functions only */
|
#define _MPRINTF_REPLACE /* use our functions only */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef min
|
||||||
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
CURLcode
|
CURLcode
|
||||||
_Transfer(struct connectdata *c_conn)
|
_Transfer(struct connectdata *c_conn)
|
||||||
{
|
{
|
||||||
@@ -345,6 +353,7 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
return CURLE_WRITE_ERROR;
|
return CURLE_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
data->header_size += p - data->headerbuff;
|
||||||
break; /* exit header line loop */
|
break; /* exit header line loop */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,6 +430,7 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
return CURLE_WRITE_ERROR;
|
return CURLE_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
data->header_size += hbuflen;
|
||||||
|
|
||||||
/* reset hbufp pointer && hbuflen */
|
/* reset hbufp pointer && hbuflen */
|
||||||
hbufp = data->headerbuff;
|
hbufp = data->headerbuff;
|
||||||
@@ -522,7 +532,7 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
if(data->crlf)
|
if(data->crlf)
|
||||||
buf = data->buffer; /* put it back on the buffer */
|
buf = data->buffer; /* put it back on the buffer */
|
||||||
|
|
||||||
nread = data->fread(buf, 1, BUFSIZE, data->in);
|
nread = data->fread(buf, 1, conn->upload_bufsize, data->in);
|
||||||
|
|
||||||
/* the signed int typecase of nread of for systems that has
|
/* the signed int typecase of nread of for systems that has
|
||||||
unsigned size_t */
|
unsigned size_t */
|
||||||
@@ -570,6 +580,15 @@ _Transfer(struct connectdata *c_conn)
|
|||||||
if (urg)
|
if (urg)
|
||||||
return urg;
|
return urg;
|
||||||
|
|
||||||
|
if(data->progress.ulspeed > conn->upload_bufsize) {
|
||||||
|
/* If we're transfering more data per second than fits in our buffer,
|
||||||
|
we increase the buffer size to adjust to the current
|
||||||
|
speed. However, we must not set it larger than BUFSIZE. We don't
|
||||||
|
adjust it downwards again since we don't see any point in that!
|
||||||
|
*/
|
||||||
|
conn->upload_bufsize=(long)min(data->progress.ulspeed, BUFSIZE);
|
||||||
|
}
|
||||||
|
|
||||||
if (data->timeout && (tvdiff (now, start) > data->timeout)) {
|
if (data->timeout && (tvdiff (now, start) > data->timeout)) {
|
||||||
failf (data, "Operation timed out with %d out of %d bytes received",
|
failf (data, "Operation timed out with %d out of %d bytes received",
|
||||||
bytecount, conn->size);
|
bytecount, conn->size);
|
||||||
@@ -703,6 +722,7 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
/* TBD: set the URL with curl_setopt() */
|
/* TBD: set the URL with curl_setopt() */
|
||||||
data->url = data->newurl;
|
data->url = data->newurl;
|
||||||
data->newurl = NULL; /* don't show! */
|
data->newurl = NULL; /* don't show! */
|
||||||
|
data->bits.urlstringalloc = TRUE; /* the URL is allocated */
|
||||||
|
|
||||||
/* Disable both types of POSTs, since doing a second POST when
|
/* Disable both types of POSTs, since doing a second POST when
|
||||||
following isn't what anyone would want! */
|
following isn't what anyone would want! */
|
||||||
@@ -724,10 +744,12 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
if(data->newurl)
|
if(data->newurl)
|
||||||
free(data->newurl);
|
free(data->newurl);
|
||||||
|
|
||||||
|
#if 0
|
||||||
if((CURLE_OK == res) && data->writeinfo) {
|
if((CURLE_OK == res) && data->writeinfo) {
|
||||||
/* Time to output some info to stdout */
|
/* Time to output some info to stdout */
|
||||||
WriteOut(data);
|
WriteOut(data);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,6 @@
|
|||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#define _REENTRANT
|
#define _REENTRANT
|
||||||
@@ -73,6 +72,11 @@
|
|||||||
#include "inet_ntoa_r.h"
|
#include "inet_ntoa_r.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* --- resolve name or IP-number --- */
|
/* --- resolve name or IP-number --- */
|
||||||
|
|
||||||
char *MakeIP(unsigned long num,char *addr, int addr_len)
|
char *MakeIP(unsigned long num,char *addr, int addr_len)
|
||||||
@@ -118,6 +122,7 @@ struct hostent *GetHost(struct UrlData *data,
|
|||||||
char *buf = (char *)malloc(CURL_NAMELOOKUP_SIZE);
|
char *buf = (char *)malloc(CURL_NAMELOOKUP_SIZE);
|
||||||
if(!buf)
|
if(!buf)
|
||||||
return NULL; /* major failure */
|
return NULL; /* major failure */
|
||||||
|
*bufp = buf;
|
||||||
|
|
||||||
if ( (in=inet_addr(hostname)) != INADDR_NONE ) {
|
if ( (in=inet_addr(hostname)) != INADDR_NONE ) {
|
||||||
struct in_addr *addrentry;
|
struct in_addr *addrentry;
|
||||||
|
153
lib/http.c
153
lib/http.c
@@ -117,6 +117,11 @@
|
|||||||
#define _MPRINTF_REPLACE /* use our functions only */
|
#define _MPRINTF_REPLACE /* use our functions only */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function checks the linked list of custom HTTP headers for a particular
|
* This function checks the linked list of custom HTTP headers for a particular
|
||||||
* header (prefix).
|
* header (prefix).
|
||||||
@@ -249,7 +254,8 @@ CURLcode http_done(struct connectdata *conn)
|
|||||||
*bytecount = http->readbytecount + http->writebytecount;
|
*bytecount = http->readbytecount + http->writebytecount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TBD: the HTTP struct remains allocated here */
|
free(http);
|
||||||
|
data->proto.http=NULL; /* it is gone */
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
@@ -340,35 +346,41 @@ CURLcode http(struct connectdata *conn)
|
|||||||
http->p_accept = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r\n";
|
http->p_accept = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r\n";
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
send_buffer *req_buffer;
|
||||||
struct curl_slist *headers=data->headers;
|
struct curl_slist *headers=data->headers;
|
||||||
sendf(data->firstsocket, data,
|
|
||||||
"%s " /* GET/HEAD/POST/PUT */
|
|
||||||
"%s HTTP/1.0\r\n" /* path */
|
|
||||||
"%s" /* proxyuserpwd */
|
|
||||||
"%s" /* userpwd */
|
|
||||||
"%s" /* range */
|
|
||||||
"%s" /* user agent */
|
|
||||||
"%s" /* cookie */
|
|
||||||
"%s" /* host */
|
|
||||||
"%s" /* pragma */
|
|
||||||
"%s" /* accept */
|
|
||||||
"%s", /* referer */
|
|
||||||
|
|
||||||
data->customrequest?data->customrequest:
|
/* initialize a dynamic send-buffer */
|
||||||
(data->bits.no_body?"HEAD":
|
req_buffer = add_buffer_init();
|
||||||
(data->bits.http_post || data->bits.http_formpost)?"POST":
|
|
||||||
(data->bits.http_put)?"PUT":"GET"),
|
/* add the main request stuff */
|
||||||
ppath,
|
add_bufferf(req_buffer,
|
||||||
(data->bits.proxy_user_passwd && data->ptr_proxyuserpwd)?data->ptr_proxyuserpwd:"",
|
"%s " /* GET/HEAD/POST/PUT */
|
||||||
(data->bits.user_passwd && data->ptr_userpwd)?data->ptr_userpwd:"",
|
"%s HTTP/1.0\r\n" /* path */
|
||||||
(data->bits.set_range && data->ptr_rangeline)?data->ptr_rangeline:"",
|
"%s" /* proxyuserpwd */
|
||||||
(data->useragent && *data->useragent && data->ptr_uagent)?data->ptr_uagent:"",
|
"%s" /* userpwd */
|
||||||
(data->ptr_cookie?data->ptr_cookie:""), /* Cookie: <data> */
|
"%s" /* range */
|
||||||
(data->ptr_host?data->ptr_host:""), /* Host: host */
|
"%s" /* user agent */
|
||||||
http->p_pragma?http->p_pragma:"",
|
"%s" /* cookie */
|
||||||
http->p_accept?http->p_accept:"",
|
"%s" /* host */
|
||||||
(data->bits.http_set_referer && data->ptr_ref)?data->ptr_ref:"" /* Referer: <data> <CRLF> */
|
"%s" /* pragma */
|
||||||
);
|
"%s" /* accept */
|
||||||
|
"%s", /* referer */
|
||||||
|
|
||||||
|
data->customrequest?data->customrequest:
|
||||||
|
(data->bits.no_body?"HEAD":
|
||||||
|
(data->bits.http_post || data->bits.http_formpost)?"POST":
|
||||||
|
(data->bits.http_put)?"PUT":"GET"),
|
||||||
|
ppath,
|
||||||
|
(data->bits.proxy_user_passwd && data->ptr_proxyuserpwd)?data->ptr_proxyuserpwd:"",
|
||||||
|
(data->bits.user_passwd && data->ptr_userpwd)?data->ptr_userpwd:"",
|
||||||
|
(data->bits.set_range && data->ptr_rangeline)?data->ptr_rangeline:"",
|
||||||
|
(data->useragent && *data->useragent && data->ptr_uagent)?data->ptr_uagent:"",
|
||||||
|
(data->ptr_cookie?data->ptr_cookie:""), /* Cookie: <data> */
|
||||||
|
(data->ptr_host?data->ptr_host:""), /* Host: host */
|
||||||
|
http->p_pragma?http->p_pragma:"",
|
||||||
|
http->p_accept?http->p_accept:"",
|
||||||
|
(data->bits.http_set_referer && data->ptr_ref)?data->ptr_ref:"" /* Referer: <data> <CRLF> */
|
||||||
|
);
|
||||||
|
|
||||||
if(co) {
|
if(co) {
|
||||||
int count=0;
|
int count=0;
|
||||||
@@ -376,19 +388,16 @@ CURLcode http(struct connectdata *conn)
|
|||||||
while(co) {
|
while(co) {
|
||||||
if(co->value && strlen(co->value)) {
|
if(co->value && strlen(co->value)) {
|
||||||
if(0 == count) {
|
if(0 == count) {
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer, "Cookie:");
|
||||||
"Cookie:");
|
|
||||||
}
|
}
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer,
|
||||||
"%s%s=%s", count?"; ":"", co->name,
|
"%s%s=%s", count?"; ":"", co->name, co->value);
|
||||||
co->value);
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
co = co->next; /* next cookie please */
|
co = co->next; /* next cookie please */
|
||||||
}
|
}
|
||||||
if(count) {
|
if(count) {
|
||||||
sendf(data->firstsocket, data,
|
add_buffer(req_buffer, "\r\n", 2);
|
||||||
"\r\n");
|
|
||||||
}
|
}
|
||||||
cookie_freelist(co); /* free the cookie list */
|
cookie_freelist(co); /* free the cookie list */
|
||||||
co=NULL;
|
co=NULL;
|
||||||
@@ -419,16 +428,16 @@ CURLcode http(struct connectdata *conn)
|
|||||||
switch(data->timecondition) {
|
switch(data->timecondition) {
|
||||||
case TIMECOND_IFMODSINCE:
|
case TIMECOND_IFMODSINCE:
|
||||||
default:
|
default:
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer,
|
||||||
"If-Modified-Since: %s\r\n", buf);
|
"If-Modified-Since: %s\r\n", buf);
|
||||||
break;
|
break;
|
||||||
case TIMECOND_IFUNMODSINCE:
|
case TIMECOND_IFUNMODSINCE:
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer,
|
||||||
"If-Unmodified-Since: %s\r\n", buf);
|
"If-Unmodified-Since: %s\r\n", buf);
|
||||||
break;
|
break;
|
||||||
case TIMECOND_LASTMOD:
|
case TIMECOND_LASTMOD:
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer,
|
||||||
"Last-Modified: %s\r\n", buf);
|
"Last-Modified: %s\r\n", buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -445,9 +454,7 @@ CURLcode http(struct connectdata *conn)
|
|||||||
if(*ptr) {
|
if(*ptr) {
|
||||||
/* only send this if the contents was non-blank */
|
/* only send this if the contents was non-blank */
|
||||||
|
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer, "%s\r\n", headers->data);
|
||||||
"%s\015\012",
|
|
||||||
headers->data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headers = headers->next;
|
headers = headers->next;
|
||||||
@@ -468,12 +475,14 @@ CURLcode http(struct connectdata *conn)
|
|||||||
generated form data */
|
generated form data */
|
||||||
data->in = (FILE *)&http->form;
|
data->in = (FILE *)&http->form;
|
||||||
|
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer,
|
||||||
"Content-Length: %d\r\n",
|
"Content-Length: %d\r\n", http->postsize-2);
|
||||||
http->postsize-2);
|
|
||||||
|
|
||||||
|
/* set upload size to the progress meter */
|
||||||
pgrsSetUploadSize(data, http->postsize);
|
pgrsSetUploadSize(data, http->postsize);
|
||||||
|
|
||||||
|
data->request_size =
|
||||||
|
add_buffer_send(data->firstsocket, conn, req_buffer);
|
||||||
result = Transfer(conn, data->firstsocket, -1, TRUE,
|
result = Transfer(conn, data->firstsocket, -1, TRUE,
|
||||||
&http->readbytecount,
|
&http->readbytecount,
|
||||||
data->firstsocket,
|
data->firstsocket,
|
||||||
@@ -487,16 +496,21 @@ CURLcode http(struct connectdata *conn)
|
|||||||
/* Let's PUT the data to the server! */
|
/* Let's PUT the data to the server! */
|
||||||
|
|
||||||
if(data->infilesize>0) {
|
if(data->infilesize>0) {
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer,
|
||||||
"Content-Length: %d\r\n\r\n", /* file size */
|
"Content-Length: %d\r\n\r\n", /* file size */
|
||||||
data->infilesize );
|
data->infilesize );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer, "\015\012");
|
||||||
"\015\012");
|
|
||||||
|
|
||||||
|
/* set the upload size to the progress meter */
|
||||||
pgrsSetUploadSize(data, data->infilesize);
|
pgrsSetUploadSize(data, data->infilesize);
|
||||||
|
|
||||||
|
/* this sends the buffer and frees all the buffer resources */
|
||||||
|
data->request_size =
|
||||||
|
add_buffer_send(data->firstsocket, conn, req_buffer);
|
||||||
|
|
||||||
|
/* prepare for transfer */
|
||||||
result = Transfer(conn, data->firstsocket, -1, TRUE,
|
result = Transfer(conn, data->firstsocket, -1, TRUE,
|
||||||
&http->readbytecount,
|
&http->readbytecount,
|
||||||
data->firstsocket,
|
data->firstsocket,
|
||||||
@@ -512,28 +526,35 @@ CURLcode http(struct connectdata *conn)
|
|||||||
if(!checkheaders(data, "Content-Length:"))
|
if(!checkheaders(data, "Content-Length:"))
|
||||||
/* we allow replacing this header, although it isn't very wise to
|
/* we allow replacing this header, although it isn't very wise to
|
||||||
actually set your own */
|
actually set your own */
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer,
|
||||||
"Content-Length: %d\r\n",
|
"Content-Length: %d\r\n",
|
||||||
(data->postfieldsize?data->postfieldsize:
|
(data->postfieldsize?data->postfieldsize:
|
||||||
strlen(data->postfields)) );
|
strlen(data->postfields)) );
|
||||||
|
|
||||||
if(!checkheaders(data, "Content-Type:"))
|
if(!checkheaders(data, "Content-Type:"))
|
||||||
sendf(data->firstsocket, data,
|
add_bufferf(req_buffer,
|
||||||
"Content-Type: application/x-www-form-urlencoded\r\n");
|
"Content-Type: application/x-www-form-urlencoded\r\n");
|
||||||
|
|
||||||
/* and here comes the actual data */
|
/* and here comes the actual data */
|
||||||
if(data->postfieldsize) {
|
if(data->postfieldsize) {
|
||||||
ssend(data->firstsocket, conn, "\r\n", 2);
|
add_buffer(req_buffer, "\r\n", 2);
|
||||||
ssend(data->firstsocket, conn, data->postfields, data->postfieldsize);
|
add_buffer(req_buffer, data->postfields,
|
||||||
ssend(data->firstsocket, conn, "\r\n", 2);
|
data->postfieldsize);
|
||||||
|
add_buffer(req_buffer, "\r\n", 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
add_bufferf(req_buffer,
|
||||||
|
"\r\n"
|
||||||
|
"%s\r\n",
|
||||||
|
data->postfields );
|
||||||
}
|
}
|
||||||
sendf(data->firstsocket, data,
|
|
||||||
"\r\n"
|
|
||||||
"%s\r\n",
|
|
||||||
data->postfields );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sendf(data->firstsocket, data, "\r\n");
|
add_buffer(req_buffer, "\r\n", 2);
|
||||||
|
|
||||||
|
/* issue the request */
|
||||||
|
data->request_size =
|
||||||
|
add_buffer_send(data->firstsocket, conn, req_buffer);
|
||||||
|
|
||||||
/* HTTP GET/HEAD download: */
|
/* HTTP GET/HEAD download: */
|
||||||
result = Transfer(conn, data->firstsocket, -1, TRUE, bytecount,
|
result = Transfer(conn, data->firstsocket, -1, TRUE, bytecount,
|
||||||
|
@@ -40,13 +40,18 @@
|
|||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
|
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include "base64_krb.h"
|
#include "base64.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <krb.h>
|
#include <krb.h>
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FTP_SERVER
|
#ifdef FTP_SERVER
|
||||||
#define LOCAL_ADDR ctrl_addr
|
#define LOCAL_ADDR ctrl_addr
|
||||||
#define REMOTE_ADDR his_addr
|
#define REMOTE_ADDR his_addr
|
||||||
|
37
lib/libcurl.def
Normal file
37
lib/libcurl.def
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
;
|
||||||
|
; Definition file for the DLL version of the LIBCURL library from curl
|
||||||
|
;
|
||||||
|
|
||||||
|
LIBRARY LIBCURL
|
||||||
|
|
||||||
|
DESCRIPTION 'curl libcurl - http://curl.haxx.se'
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
curl_close @ 1 ;
|
||||||
|
curl_connect @ 2 ;
|
||||||
|
curl_disconnect @ 3 ;
|
||||||
|
curl_do @ 4 ;
|
||||||
|
curl_done @ 5 ;
|
||||||
|
curl_easy_cleanup @ 6 ;
|
||||||
|
curl_easy_getinfo @ 7 ;
|
||||||
|
curl_easy_init @ 8 ;
|
||||||
|
curl_easy_perform @ 9 ;
|
||||||
|
curl_easy_setopt @ 10 ;
|
||||||
|
curl_escape @ 11 ;
|
||||||
|
curl_formparse @ 12 ;
|
||||||
|
curl_free @ 13 ;
|
||||||
|
curl_getdate @ 14 ;
|
||||||
|
curl_getenv @ 15 ;
|
||||||
|
curl_init @ 16 ;
|
||||||
|
curl_open @ 17 ;
|
||||||
|
curl_read @ 18 ;
|
||||||
|
curl_setopt @ 19 ;
|
||||||
|
curl_slist_append @ 20 ;
|
||||||
|
curl_slist_free_all @ 21 ;
|
||||||
|
curl_transfer @ 22 ;
|
||||||
|
curl_unescape @ 23 ;
|
||||||
|
curl_version @ 24 ;
|
||||||
|
curl_write @ 25 ;
|
||||||
|
maprintf @ 26 ;
|
||||||
|
strequal @ 27 ;
|
||||||
|
strnequal @ 28 ;
|
98
lib/memdebug.c
Normal file
98
lib/memdebug.c
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
/*****************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License
|
||||||
|
* Version 1.0 (the "License"); you may not use this file except in
|
||||||
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS"
|
||||||
|
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing rights and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is Curl.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is Daniel Stenberg.
|
||||||
|
*
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 1999.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
* Main author:
|
||||||
|
* - Daniel Stenberg <daniel@haxx.se>
|
||||||
|
*
|
||||||
|
* http://curl.haxx.se
|
||||||
|
*
|
||||||
|
* $Source$
|
||||||
|
* $Revision$
|
||||||
|
* $Date$
|
||||||
|
* $Author$
|
||||||
|
* $State$
|
||||||
|
* $Locker$
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------------
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "setup.h"
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include "urldata.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note that these debug functions are very simple and they are meant to
|
||||||
|
* remain so. For advanced analysis, record a log file and write perl scripts
|
||||||
|
* to analyze them!
|
||||||
|
*
|
||||||
|
* Don't use these with multithreaded test programs!
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE *logfile=stderr;
|
||||||
|
|
||||||
|
/* this sets the log file name */
|
||||||
|
void curl_memdebug(char *logname)
|
||||||
|
{
|
||||||
|
logfile = fopen(logname, "w");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *curl_domalloc(size_t size, int line, char *source)
|
||||||
|
{
|
||||||
|
void *mem=(malloc)(size);
|
||||||
|
fprintf(logfile, "MEM %s:%d malloc(%d) = %p\n",
|
||||||
|
source, line, size, mem);
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *curl_dostrdup(char *str, int line, char *source)
|
||||||
|
{
|
||||||
|
char *mem=(strdup)(str);
|
||||||
|
size_t len=strlen(str)+1;
|
||||||
|
fprintf(logfile, "MEM %s:%d strdup(%p) (%d) = %p\n",
|
||||||
|
source, line, str, len, mem);
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *curl_dorealloc(void *ptr, size_t size, int line, char *source)
|
||||||
|
{
|
||||||
|
void *mem=(realloc)(ptr, size);
|
||||||
|
fprintf(logfile, "MEM %s:%d realloc(%p, %d) = %p\n",
|
||||||
|
source, line, ptr, size, mem);
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void curl_dofree(void *ptr, int line, char *source)
|
||||||
|
{
|
||||||
|
(free)(ptr);
|
||||||
|
fprintf(logfile, "MEM %s:%d free(%p)\n",
|
||||||
|
source, line, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* MALLOCDEBUG */
|
13
lib/memdebug.h
Normal file
13
lib/memdebug.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
void *curl_domalloc(size_t size, int line, char *source);
|
||||||
|
void *curl_dorealloc(void *ptr, size_t size, int line, char *source);
|
||||||
|
void curl_dofree(void *ptr, int line, char *source);
|
||||||
|
char *curl_dostrdup(char *str, int line, char *source);
|
||||||
|
void curl_memdebug(char *logname);
|
||||||
|
|
||||||
|
/* Set this symbol on the command-line, recompile all lib-sources */
|
||||||
|
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
|
||||||
|
#define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
|
||||||
|
#define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
|
||||||
|
#define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
|
||||||
|
#endif
|
@@ -98,6 +98,10 @@ static const char rcsid[] = "@(#)$Id$";
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BUFFSIZE 256 /* buffer for long-to-str and float-to-str calcs */
|
#define BUFFSIZE 256 /* buffer for long-to-str and float-to-str calcs */
|
||||||
#define MAX_PARAMETERS 128 /* lame static limit */
|
#define MAX_PARAMETERS 128 /* lame static limit */
|
||||||
|
@@ -38,15 +38,19 @@
|
|||||||
|
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
|
||||||
#include <curl/mprintf.h>
|
|
||||||
|
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
|
|
||||||
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include "base64_krb.h"
|
#include "base64.h"
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
|
100
lib/sendf.c
100
lib/sendf.c
@@ -53,13 +53,19 @@
|
|||||||
|
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "urldata.h"
|
#include "urldata.h"
|
||||||
|
#include "sendf.h"
|
||||||
|
|
||||||
|
#define _MPRINTF_REPLACE /* use the internal *printf() functions */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* infof() is for info message along the way */
|
/* infof() is for info message along the way */
|
||||||
|
|
||||||
@@ -82,14 +88,14 @@ void failf(struct UrlData *data, char *fmt, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if(data->errorbuffer)
|
if(data->errorbuffer)
|
||||||
vsprintf(data->errorbuffer, fmt, ap);
|
vsnprintf(data->errorbuffer, CURL_ERROR_SIZE, fmt, ap);
|
||||||
else /* no errorbuffer receives this, write to data->err instead */
|
else /* no errorbuffer receives this, write to data->err instead */
|
||||||
vfprintf(data->err, fmt, ap);
|
vfprintf(data->err, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sendf() sends the formated data to the server */
|
/* sendf() sends the formated data to the server */
|
||||||
int sendf(int fd, struct UrlData *data, char *fmt, ...)
|
size_t sendf(int fd, struct UrlData *data, char *fmt, ...)
|
||||||
{
|
{
|
||||||
size_t bytes_written;
|
size_t bytes_written;
|
||||||
char *s;
|
char *s;
|
||||||
@@ -118,7 +124,7 @@ int sendf(int fd, struct UrlData *data, char *fmt, ...)
|
|||||||
/*
|
/*
|
||||||
* ftpsendf() sends the formated string as a ftp command to a ftp server
|
* ftpsendf() sends the formated string as a ftp command to a ftp server
|
||||||
*/
|
*/
|
||||||
int ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
|
size_t ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
|
||||||
{
|
{
|
||||||
size_t bytes_written;
|
size_t bytes_written;
|
||||||
char *s;
|
char *s;
|
||||||
@@ -154,9 +160,6 @@ size_t ssend(int fd, struct connectdata *conn, void *mem, size_t len)
|
|||||||
size_t bytes_written;
|
size_t bytes_written;
|
||||||
struct UrlData *data=conn->data; /* conn knows data, not vice versa */
|
struct UrlData *data=conn->data; /* conn knows data, not vice versa */
|
||||||
|
|
||||||
if(data->bits.verbose)
|
|
||||||
fprintf(data->err, "> [binary output]\n");
|
|
||||||
|
|
||||||
#ifdef USE_SSLEAY
|
#ifdef USE_SSLEAY
|
||||||
if (data->use_ssl) {
|
if (data->use_ssl) {
|
||||||
bytes_written = SSL_write(data->ssl, mem, len);
|
bytes_written = SSL_write(data->ssl, mem, len);
|
||||||
@@ -177,6 +180,91 @@ size_t ssend(int fd, struct connectdata *conn, void *mem, size_t len)
|
|||||||
return bytes_written;
|
return bytes_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* add_buffer_init() returns a fine buffer struct
|
||||||
|
*/
|
||||||
|
send_buffer *add_buffer_init(void)
|
||||||
|
{
|
||||||
|
send_buffer *blonk;
|
||||||
|
blonk=(send_buffer *)malloc(sizeof(send_buffer));
|
||||||
|
if(blonk) {
|
||||||
|
memset(blonk, 0, sizeof(send_buffer));
|
||||||
|
return blonk;
|
||||||
|
}
|
||||||
|
return NULL; /* failed, go home */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* add_buffer_send() sends a buffer and frees all associated memory.
|
||||||
|
*/
|
||||||
|
size_t add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in)
|
||||||
|
{
|
||||||
|
size_t amount;
|
||||||
|
if(conn->data->bits.verbose) {
|
||||||
|
fputs("> ", conn->data->err);
|
||||||
|
/* this data _may_ contain binary stuff */
|
||||||
|
fwrite(in->buffer, in->size_used, 1, conn->data->err);
|
||||||
|
}
|
||||||
|
|
||||||
|
amount = ssend(sockfd, conn, in->buffer, in->size_used);
|
||||||
|
|
||||||
|
if(in->buffer)
|
||||||
|
free(in->buffer);
|
||||||
|
free(in);
|
||||||
|
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* add_bufferf() builds a buffer from the formatted input
|
||||||
|
*/
|
||||||
|
CURLcode add_bufferf(send_buffer *in, char *fmt, ...)
|
||||||
|
{
|
||||||
|
CURLcode result = CURLE_OUT_OF_MEMORY;
|
||||||
|
char *s;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
s = mvaprintf(fmt, ap); /* this allocs a new string to append */
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if(s) {
|
||||||
|
result = add_buffer(in, s, strlen(s));
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* add_buffer() appends a memory chunk to the existing one
|
||||||
|
*/
|
||||||
|
CURLcode add_buffer(send_buffer *in, void *inptr, size_t size)
|
||||||
|
{
|
||||||
|
char *new_rb;
|
||||||
|
int new_size;
|
||||||
|
|
||||||
|
if(size > 0) {
|
||||||
|
if(!in->buffer ||
|
||||||
|
((in->size_used + size) > (in->size_max - 1))) {
|
||||||
|
new_size = (in->size_used+size)*2;
|
||||||
|
if(in->buffer)
|
||||||
|
/* we have a buffer, enlarge the existing one */
|
||||||
|
new_rb = (char *)realloc(in->buffer, new_size);
|
||||||
|
else
|
||||||
|
/* create a new buffer */
|
||||||
|
new_rb = (char *)malloc(new_size);
|
||||||
|
|
||||||
|
if(!new_rb)
|
||||||
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
in->buffer = new_rb;
|
||||||
|
in->size_max = new_size;
|
||||||
|
}
|
||||||
|
memcpy(&in->buffer[in->size_used], inptr, size);
|
||||||
|
|
||||||
|
in->size_used += size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CURLE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
14
lib/sendf.h
14
lib/sendf.h
@@ -46,4 +46,18 @@ size_t ssend(int fd, struct connectdata *, void *fmt, size_t len);
|
|||||||
void infof(struct UrlData *, char *fmt, ...);
|
void infof(struct UrlData *, char *fmt, ...);
|
||||||
void failf(struct UrlData *, char *fmt, ...);
|
void failf(struct UrlData *, char *fmt, ...);
|
||||||
|
|
||||||
|
struct send_buffer {
|
||||||
|
char *buffer;
|
||||||
|
long size_max;
|
||||||
|
long size_used;
|
||||||
|
};
|
||||||
|
typedef struct send_buffer send_buffer;
|
||||||
|
|
||||||
|
|
||||||
|
send_buffer *add_buffer_init(void);
|
||||||
|
CURLcode add_buffer(send_buffer *in, void *inptr, size_t size);
|
||||||
|
CURLcode add_bufferf(send_buffer *in, char *fmt, ...);
|
||||||
|
size_t add_buffer_send(int sockfd, struct connectdata *conn, send_buffer *in);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -57,6 +57,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __cplusplus /* (rabe) */
|
||||||
|
typedef char bool;
|
||||||
|
#endif /* (rabe) */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifndef OS
|
#ifndef OS
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
39
lib/url.c
39
lib/url.c
@@ -109,7 +109,6 @@
|
|||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
#include "cookie.h"
|
#include "cookie.h"
|
||||||
#include "strequal.h"
|
#include "strequal.h"
|
||||||
#include "writeout.h"
|
|
||||||
|
|
||||||
/* And now for the protocols */
|
/* And now for the protocols */
|
||||||
#include "ftp.h"
|
#include "ftp.h"
|
||||||
@@ -127,6 +126,10 @@
|
|||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
#include "security.h"
|
#include "security.h"
|
||||||
#endif
|
#endif
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* -- -- */
|
/* -- -- */
|
||||||
|
|
||||||
@@ -183,6 +186,11 @@ void static urlfree(struct UrlData *data, bool totally)
|
|||||||
switch off that knowledge again... */
|
switch off that knowledge again... */
|
||||||
data->bits.httpproxy=FALSE;
|
data->bits.httpproxy=FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(data->bits.rangestringalloc) {
|
||||||
|
free(data->range);
|
||||||
|
data->range=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(data->ptr_proxyuserpwd) {
|
if(data->ptr_proxyuserpwd) {
|
||||||
free(data->ptr_proxyuserpwd);
|
free(data->ptr_proxyuserpwd);
|
||||||
@@ -227,6 +235,10 @@ void static urlfree(struct UrlData *data, bool totally)
|
|||||||
if(data->free_referer)
|
if(data->free_referer)
|
||||||
free(data->referer);
|
free(data->referer);
|
||||||
|
|
||||||
|
if(data->bits.urlstringalloc)
|
||||||
|
/* the URL is allocated, free it! */
|
||||||
|
free(data->url);
|
||||||
|
|
||||||
cookie_cleanup(data->cookies);
|
cookie_cleanup(data->cookies);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
@@ -483,9 +495,11 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
|
|||||||
case CURLOPT_WRITEFUNCTION:
|
case CURLOPT_WRITEFUNCTION:
|
||||||
data->fwrite = va_arg(param, curl_write_callback);
|
data->fwrite = va_arg(param, curl_write_callback);
|
||||||
break;
|
break;
|
||||||
|
#if 0
|
||||||
case CURLOPT_WRITEINFO:
|
case CURLOPT_WRITEINFO:
|
||||||
data->writeinfo = va_arg(param, char *);
|
data->writeinfo = va_arg(param, char *);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case CURLOPT_READFUNCTION:
|
case CURLOPT_READFUNCTION:
|
||||||
data->fread = va_arg(param, curl_read_callback);
|
data->fread = va_arg(param, curl_read_callback);
|
||||||
break;
|
break;
|
||||||
@@ -692,6 +706,9 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
|
|||||||
conn->data = data; /* remember our daddy */
|
conn->data = data; /* remember our daddy */
|
||||||
conn->state = CONN_INIT;
|
conn->state = CONN_INIT;
|
||||||
|
|
||||||
|
conn->upload_bufsize = UPLOAD_BUFSIZE; /* the smallest upload buffer size
|
||||||
|
we use */
|
||||||
|
|
||||||
buf = data->buffer; /* this is our buffer */
|
buf = data->buffer; /* this is our buffer */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -900,8 +917,9 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
|
|||||||
if(data->resume_from) {
|
if(data->resume_from) {
|
||||||
if(!data->bits.set_range) {
|
if(!data->bits.set_range) {
|
||||||
/* if it already was in use, we just skip this */
|
/* if it already was in use, we just skip this */
|
||||||
sprintf(resumerange, "%d-", data->resume_from);
|
snprintf(resumerange, sizeof(resumerange), "%d-", data->resume_from);
|
||||||
data->range=resumerange; /* tell ourselves to fetch this range */
|
data->range=strdup(resumerange); /* tell ourselves to fetch this range */
|
||||||
|
data->bits.rangestringalloc = TRUE; /* mark as allocated */
|
||||||
data->bits.set_range = 1; /* switch on range usage */
|
data->bits.set_range = 1; /* switch on range usage */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1195,9 +1213,14 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
|
|||||||
conn->serv_addr.sin_family = conn->hp->h_addrtype;
|
conn->serv_addr.sin_family = conn->hp->h_addrtype;
|
||||||
conn->serv_addr.sin_port = htons(data->port);
|
conn->serv_addr.sin_port = htons(data->port);
|
||||||
|
|
||||||
/* sck 8/31/2000 add support for specifing device to bind socket to */
|
#ifndef WIN32
|
||||||
/* #ifdef LINUX */
|
/* We don't generally like checking for OS-versions, we should make this
|
||||||
/* I am using this, but it may not work everywhere, only tested on RedHat 6.2 */
|
HAVE_XXXX based, although at the moment I don't have a decent test for
|
||||||
|
this! */
|
||||||
|
|
||||||
|
/* sck 8/31/2000 add support for specifing device to bind socket to */
|
||||||
|
/* I am using this, but it may not work everywhere, only tested on
|
||||||
|
RedHat 6.2 */
|
||||||
#ifdef HAVE_INET_NTOA
|
#ifdef HAVE_INET_NTOA
|
||||||
|
|
||||||
#ifndef INADDR_NONE
|
#ifndef INADDR_NONE
|
||||||
@@ -1326,6 +1349,7 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
|
|||||||
|
|
||||||
} /* end of device selection support */
|
} /* end of device selection support */
|
||||||
#endif /* end of HAVE_INET_NTOA */
|
#endif /* end of HAVE_INET_NTOA */
|
||||||
|
#endif /* end of not WIN32 */
|
||||||
|
|
||||||
if (connect(data->firstsocket,
|
if (connect(data->firstsocket,
|
||||||
(struct sockaddr *) &(conn->serv_addr),
|
(struct sockaddr *) &(conn->serv_addr),
|
||||||
@@ -1391,7 +1415,8 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
|
|||||||
|
|
||||||
if(data->bits.proxy_user_passwd) {
|
if(data->bits.proxy_user_passwd) {
|
||||||
char *authorization;
|
char *authorization;
|
||||||
sprintf(data->buffer, "%s:%s", data->proxyuser, data->proxypasswd);
|
snprintf(data->buffer, BUFSIZE, "%s:%s",
|
||||||
|
data->proxyuser, data->proxypasswd);
|
||||||
if(base64_encode(data->buffer, strlen(data->buffer),
|
if(base64_encode(data->buffer, strlen(data->buffer),
|
||||||
&authorization) >= 0) {
|
&authorization) >= 0) {
|
||||||
data->ptr_proxyuserpwd =
|
data->ptr_proxyuserpwd =
|
||||||
|
@@ -99,6 +99,11 @@
|
|||||||
/* Download buffer size, keep it fairly big for speed reasons */
|
/* Download buffer size, keep it fairly big for speed reasons */
|
||||||
#define BUFSIZE (1024*50)
|
#define BUFSIZE (1024*50)
|
||||||
|
|
||||||
|
/* Upload buffer size, keep it smallish to get faster progress meter
|
||||||
|
updates. This should probably become dynamic and adjust to the upload
|
||||||
|
speed. */
|
||||||
|
#define UPLOAD_BUFSIZE (1024*2)
|
||||||
|
|
||||||
/* Initial size of the buffer to store headers in, it'll be enlarged in case
|
/* Initial size of the buffer to store headers in, it'll be enlarged in case
|
||||||
of need. */
|
of need. */
|
||||||
#define HEADERSIZE 256
|
#define HEADERSIZE 256
|
||||||
@@ -175,6 +180,9 @@ struct connectdata {
|
|||||||
long bytecount;
|
long bytecount;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
|
|
||||||
|
long upload_bufsize; /* adjust as you see fit, never bigger than BUFSIZE
|
||||||
|
never smaller than UPLOAD_BUFSIZE */
|
||||||
|
|
||||||
/* These two functions MUST be set by the curl_connect() function to be
|
/* These two functions MUST be set by the curl_connect() function to be
|
||||||
be protocol dependent */
|
be protocol dependent */
|
||||||
CURLcode (*curl_do)(struct connectdata *connect);
|
CURLcode (*curl_do)(struct connectdata *connect);
|
||||||
@@ -203,7 +211,6 @@ struct connectdata {
|
|||||||
the same we read from. -1 disables */
|
the same we read from. -1 disables */
|
||||||
long *writebytecountp; /* return number of bytes written or NULL */
|
long *writebytecountp; /* return number of bytes written or NULL */
|
||||||
|
|
||||||
|
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
|
|
||||||
enum protection_level command_prot;
|
enum protection_level command_prot;
|
||||||
@@ -297,7 +304,6 @@ struct Configbits {
|
|||||||
bool mute;
|
bool mute;
|
||||||
bool no_body;
|
bool no_body;
|
||||||
bool proxy_user_passwd;
|
bool proxy_user_passwd;
|
||||||
bool proxystringalloc; /* the http proxy string is malloc()'ed */
|
|
||||||
bool set_port;
|
bool set_port;
|
||||||
bool set_range;
|
bool set_range;
|
||||||
bool upload;
|
bool upload;
|
||||||
@@ -306,6 +312,10 @@ struct Configbits {
|
|||||||
bool verbose;
|
bool verbose;
|
||||||
bool this_is_a_follow; /* this is a followed Location: request */
|
bool this_is_a_follow; /* this is a followed Location: request */
|
||||||
bool krb4; /* kerberos4 connection requested */
|
bool krb4; /* kerberos4 connection requested */
|
||||||
|
|
||||||
|
bool proxystringalloc; /* the http proxy string is malloc()'ed */
|
||||||
|
bool rangestringalloc; /* the range string is malloc()'ed */
|
||||||
|
bool urlstringalloc; /* the URL string is malloc()'ed */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* What type of interface that intiated this struct */
|
/* What type of interface that intiated this struct */
|
||||||
@@ -349,6 +359,10 @@ struct UrlData {
|
|||||||
proxy string features a ":[port]" that one will override
|
proxy string features a ":[port]" that one will override
|
||||||
this. */
|
this. */
|
||||||
|
|
||||||
|
|
||||||
|
long header_size; /* size of read header(s) in bytes */
|
||||||
|
long request_size; /* the amount of bytes sent in the request(s) */
|
||||||
|
|
||||||
/*************** Request - specific items ************/
|
/*************** Request - specific items ************/
|
||||||
|
|
||||||
union {
|
union {
|
||||||
@@ -455,8 +469,11 @@ struct UrlData {
|
|||||||
char *headerbuff; /* allocated buffer to store headers in */
|
char *headerbuff; /* allocated buffer to store headers in */
|
||||||
int headersize; /* size of the allocation */
|
int headersize; /* size of the allocation */
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* this was removed in libcurl 7.4 */
|
||||||
char *writeinfo; /* if non-NULL describes what to output on a successful
|
char *writeinfo; /* if non-NULL describes what to output on a successful
|
||||||
completion */
|
completion */
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Progress progress;
|
struct Progress progress;
|
||||||
|
|
||||||
|
98
memanalyze.pl
Executable file
98
memanalyze.pl
Executable file
@@ -0,0 +1,98 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# Example input:
|
||||||
|
#
|
||||||
|
# MEM mprintf.c:1094 malloc(32) = e5718
|
||||||
|
# MEM mprintf.c:1103 realloc(e5718, 64) = e6118
|
||||||
|
# MEM sendf.c:232 free(f6520)
|
||||||
|
|
||||||
|
do {
|
||||||
|
if($ARGV[0] eq "-v") {
|
||||||
|
$verbose=1;
|
||||||
|
}
|
||||||
|
} while (shift @ARGV);
|
||||||
|
|
||||||
|
while(<STDIN>) {
|
||||||
|
chomp $_;
|
||||||
|
$line = $_;
|
||||||
|
if($verbose) {
|
||||||
|
print "IN: $line\n";
|
||||||
|
}
|
||||||
|
if($line =~ /^MEM ([^:]*):(\d*) (.*)/) {
|
||||||
|
# generic match for the filename+linenumber
|
||||||
|
$source = $1;
|
||||||
|
$linenum = $2;
|
||||||
|
$function = $3;
|
||||||
|
|
||||||
|
if($function =~ /free\(([0-9a-f]*)/) {
|
||||||
|
$addr = $1;
|
||||||
|
if($sizeataddr{$addr} <= 0) {
|
||||||
|
print "FREE ERROR: No memory allocated: $line\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$totalmem -= $sizeataddr{$addr};
|
||||||
|
$sizeataddr{$addr}=0;
|
||||||
|
$getmem{$addr}=""; # forget after a good free()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($function =~ /malloc\((\d*)\) = ([0-9a-f]*)/) {
|
||||||
|
$size = $1;
|
||||||
|
$addr = $2;
|
||||||
|
$sizeataddr{$addr}=$size;
|
||||||
|
$totalmem += $size;
|
||||||
|
|
||||||
|
$getmem{$addr}="$source:$linenum";
|
||||||
|
}
|
||||||
|
elsif($function =~ /realloc\(([0-9a-f]*), (\d*)\) = ([0-9a-f]*)/) {
|
||||||
|
$oldaddr = $1;
|
||||||
|
$newsize = $2;
|
||||||
|
$newaddr = $3;
|
||||||
|
|
||||||
|
$totalmem -= $sizeataddr{$oldaddr};
|
||||||
|
$sizeataddr{$oldaddr}=0;
|
||||||
|
|
||||||
|
$totalmem += $newsize;
|
||||||
|
$sizeataddr{$newaddr}=$newsize;
|
||||||
|
|
||||||
|
$getmem{$oldaddr}="";
|
||||||
|
$getmem{$newaddr}="$source:$linenum";
|
||||||
|
}
|
||||||
|
elsif($function =~ /strdup\(([0-9a-f]*)\) \((\d*)\) = ([0-9a-f]*)/) {
|
||||||
|
# strdup(a5b50) (8) = df7c0
|
||||||
|
|
||||||
|
$dup = $1;
|
||||||
|
$size = $2;
|
||||||
|
$addr = $3;
|
||||||
|
$getmem{$addr}="$source:$linenum";
|
||||||
|
$sizeataddr{$addr}=$size;
|
||||||
|
|
||||||
|
$totalmem += $size;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "Not recognized input line: $function\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "Not recognized prefix line: $line\n";
|
||||||
|
}
|
||||||
|
if($verbose) {
|
||||||
|
print "TOTAL: $totalmem\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(0 == $totalmem) {
|
||||||
|
print "No leak found\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Leak detected: memory still allocated: $totalmem bytes\n";
|
||||||
|
|
||||||
|
for(keys %sizeataddr) {
|
||||||
|
$addr = $_;
|
||||||
|
$size = $sizeataddr{$addr};
|
||||||
|
if($size) {
|
||||||
|
print "At $addr, there's $size bytes.\n";
|
||||||
|
print " allocated by ".$getmem{$addr}."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -3,14 +3,17 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Some flags needed when trying to cause warnings ;-)
|
# Some flags needed when trying to cause warnings ;-)
|
||||||
# CFLAGS = -Wall -pedantic
|
# CFLAGS = -g -DMALLOCDEBUG # -Wall -pedantic
|
||||||
#CPPFLAGS = -DGLOBURL -DCURL_SEPARATORS
|
#CPPFLAGS = -DGLOBURL -DCURL_SEPARATORS
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/include
|
INCLUDES = -I$(top_srcdir)/include
|
||||||
|
|
||||||
bin_PROGRAMS = curl
|
bin_PROGRAMS = curl #memtest
|
||||||
|
|
||||||
curl_SOURCES = main.c hugehelp.c urlglob.c
|
#memtest_SOURCES = memtest.c
|
||||||
|
#memtest_LDADD = $(top_srcdir)/lib/libcurl.la
|
||||||
|
|
||||||
|
curl_SOURCES = main.c hugehelp.c urlglob.c writeout.c
|
||||||
curl_LDADD = $(top_srcdir)/lib/libcurl.la
|
curl_LDADD = $(top_srcdir)/lib/libcurl.la
|
||||||
curl_DEPENDENCIES = $(top_srcdir)/lib/libcurl.la
|
curl_DEPENDENCIES = $(top_srcdir)/lib/libcurl.la
|
||||||
BUILT_SOURCES = hugehelp.c
|
BUILT_SOURCES = hugehelp.c
|
||||||
|
136
src/Makefile.m32
136
src/Makefile.m32
@@ -1,65 +1,71 @@
|
|||||||
#############################################################
|
#############################################################
|
||||||
## Makefile for building curl.exe with MingW32 (GCC-2.95) and
|
## Makefile for building curl.exe with MingW32 (GCC-2.95) and
|
||||||
## optionally OpenSSL (0.9.4)
|
## optionally OpenSSL (0.9.6)
|
||||||
##
|
##
|
||||||
## Use: make -f Makefile.m32 [SSL=1]
|
## Use: make -f Makefile.m32 [SSL=1] [DYN=1]
|
||||||
##
|
##
|
||||||
## Comments to: Troy Engel <tengel@sonic.net> or
|
## Comments to: Troy Engel <tengel@sonic.net> or
|
||||||
## Joern Hartroth <hartroth@acm.org>
|
## Joern Hartroth <hartroth@acm.org>
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
STRIP = strip -s
|
STRIP = strip -s
|
||||||
OPENSSL_PATH = ../../openssl-0.9.5a
|
OPENSSL_PATH = ../../openssl-0.9.6
|
||||||
|
|
||||||
# We may need these someday
|
# We may need these someday
|
||||||
# PERL = perl
|
# PERL = perl
|
||||||
# NROFF = nroff
|
# NROFF = nroff
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
## Nothing more to do below this line!
|
## Nothing more to do below this line!
|
||||||
|
|
||||||
INCLUDES = -I. -I.. -I../include
|
INCLUDES = -I. -I.. -I../include
|
||||||
CFLAGS = -g -O2 -DMINGW32
|
CFLAGS = -g -O2 -DMINGW32
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
|
COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
|
||||||
LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
curl_PROGRAMS = curl.exe
|
curl_PROGRAMS = curl.exe
|
||||||
curl_OBJECTS = main.o hugehelp.o urlglob.o
|
curl_OBJECTS = main.o hugehelp.o urlglob.o writeout.o
|
||||||
curl_SOURCES = main.c hugehelp.c urlglob.c
|
curl_SOURCES = main.c hugehelp.c urlglob.c writeout.c
|
||||||
curl_DEPENDENCIES = ../lib/libcurl.a
|
ifdef DYN
|
||||||
curl_LDADD = -L../lib -lcurl -lwsock32
|
curl_DEPENDENCIES = ../lib/libcurldll.a ../lib/libcurl.dll
|
||||||
ifdef SSL
|
curl_LDADD = -L../lib -lcurldll
|
||||||
curl_LDADD += -L$(OPENSSL_PATH)/out -leay32 -lssl32 -lRSAglue
|
else
|
||||||
endif
|
curl_DEPENDENCIES = ../lib/libcurl.a
|
||||||
|
curl_LDADD = -L../lib -lcurl
|
||||||
PROGRAMS = $(curl_PROGRAMS)
|
endif
|
||||||
SOURCES = $(curl_SOURCES)
|
curl_LDADD += -lwsock32
|
||||||
OBJECTS = $(curl_OBJECTS)
|
ifdef SSL
|
||||||
|
curl_LDADD += -L$(OPENSSL_PATH)/out -leay32 -lssl32 -lRSAglue
|
||||||
all: curl
|
endif
|
||||||
|
|
||||||
curl: $(curl_OBJECTS) $(curl_DEPENDENCIES)
|
PROGRAMS = $(curl_PROGRAMS)
|
||||||
-@erase curl.exe
|
SOURCES = $(curl_SOURCES)
|
||||||
$(LINK) $(curl_OBJECTS) $(curl_LDADD)
|
OBJECTS = $(curl_OBJECTS)
|
||||||
$(STRIP) $(curl_PROGRAMS)
|
|
||||||
|
all: curl.exe
|
||||||
# We don't have nroff normally under win32
|
|
||||||
# hugehelp.c: ../README.curl ../curl.1 mkhelp.pl
|
curl.exe: $(curl_OBJECTS) $(curl_DEPENDENCIES)
|
||||||
# -@erase hugehelp.c
|
-@erase $@
|
||||||
# $(NROFF) -man ../curl.1 | $(PERL) mkhelp.pl ../README.curl > hugehelp.c
|
$(LINK) $(curl_OBJECTS) $(curl_LDADD)
|
||||||
|
$(STRIP) $@
|
||||||
.c.o:
|
|
||||||
$(COMPILE) -c $<
|
# We don't have nroff normally under win32
|
||||||
|
# hugehelp.c: ../README.curl ../curl.1 mkhelp.pl
|
||||||
.s.o:
|
# -@erase hugehelp.c
|
||||||
$(COMPILE) -c $<
|
# $(NROFF) -man ../curl.1 | $(PERL) mkhelp.pl ../README.curl > hugehelp.c
|
||||||
|
|
||||||
.S.o:
|
.c.o:
|
||||||
$(COMPILE) -c $<
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
clean:
|
.s.o:
|
||||||
-@erase $(curl_OBJECTS)
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
distrib: clean
|
.S.o:
|
||||||
-@erase $(curl_PROGRAMS)
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-@erase $(curl_OBJECTS)
|
||||||
|
|
||||||
|
distrib: clean
|
||||||
|
-@erase $(curl_PROGRAMS)
|
||||||
|
@@ -496,11 +496,17 @@ puts (
|
|||||||
" size_upload The total amount of bytes that were\n"
|
" size_upload The total amount of bytes that were\n"
|
||||||
" uploaded.\n"
|
" uploaded.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" size_header The total amount of bytes of the down<77>\n"
|
||||||
|
" loaded headers.\n"
|
||||||
|
"\n"
|
||||||
|
" size_request The total amount of bytes that were sent\n"
|
||||||
|
" in the HTTP request.\n"
|
||||||
|
"\n"
|
||||||
" speed_download The average download speed that curl\n"
|
" speed_download The average download speed that curl\n"
|
||||||
" measured for the complete download.\n"
|
" measured for the complete download.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" speed_upload The average upload speed that curl mea<65>\n"
|
" speed_upload The average upload speed that curl mea<65>\n"
|
||||||
" sured for the complete download.\n"
|
" sured for the complete upload.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -x/--proxy <proxyhost[:port]>\n"
|
" -x/--proxy <proxyhost[:port]>\n"
|
||||||
" Use specified proxy. If the port number is not speci<63>\n"
|
" Use specified proxy. If the port number is not speci<63>\n"
|
||||||
@@ -575,7 +581,6 @@ puts (
|
|||||||
"\n"
|
"\n"
|
||||||
" FTP_PROXY [protocol://]<host>[:port]\n"
|
" FTP_PROXY [protocol://]<host>[:port]\n"
|
||||||
" Sets proxy server to use for FTP.\n"
|
" Sets proxy server to use for FTP.\n"
|
||||||
"\n"
|
|
||||||
" GOPHER_PROXY [protocol://]<host>[:port]\n"
|
" GOPHER_PROXY [protocol://]<host>[:port]\n"
|
||||||
" Sets proxy server to use for GOPHER.\n"
|
" Sets proxy server to use for GOPHER.\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -627,12 +632,12 @@ puts (
|
|||||||
"\n"
|
"\n"
|
||||||
" 12 FTP weird USER reply. Curl couldn't parse the reply\n"
|
" 12 FTP weird USER reply. Curl couldn't parse the reply\n"
|
||||||
" sent to the USER request.\n"
|
" sent to the USER request.\n"
|
||||||
"\n"
|
|
||||||
" 13 FTP weird PASV reply, Curl couldn't parse the reply\n"
|
" 13 FTP weird PASV reply, Curl couldn't parse the reply\n"
|
||||||
" sent to the PASV request.\n"
|
" sent to the PASV request.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" 14 FTP weird 227 formay. Curl couldn't parse the 227-line\n"
|
" 14 FTP weird 227 formay. Curl couldn't parse the 227-line\n"
|
||||||
" the server sent.\n"
|
" the server sent.\n"
|
||||||
|
"\n"
|
||||||
" 15 FTP can't get host. Couldn't resolve the host IP we got\n"
|
" 15 FTP can't get host. Couldn't resolve the host IP we got\n"
|
||||||
" in the 227-line.\n"
|
" in the 227-line.\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -685,6 +690,7 @@ puts (
|
|||||||
"\n"
|
"\n"
|
||||||
" 34 HTTP post error. Internal post-request generation\n"
|
" 34 HTTP post error. Internal post-request generation\n"
|
||||||
" error.\n"
|
" error.\n"
|
||||||
|
"\n"
|
||||||
" 35 SSL connect error. The SSL handshaking failed.\n"
|
" 35 SSL connect error. The SSL handshaking failed.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" 36 FTP bad download resume. Couldn't continue an earlier\n"
|
" 36 FTP bad download resume. Couldn't continue an earlier\n"
|
||||||
@@ -743,13 +749,13 @@ puts (
|
|||||||
" - Felix von Leitner <felix@convergence.de>\n"
|
" - Felix von Leitner <felix@convergence.de>\n"
|
||||||
" - Dan Zitter <dzitter@zitter.net>\n"
|
" - Dan Zitter <dzitter@zitter.net>\n"
|
||||||
" - Jongki Suwandi <Jongki.Suwandi@eng.sun.com>\n"
|
" - Jongki Suwandi <Jongki.Suwandi@eng.sun.com>\n"
|
||||||
|
);
|
||||||
|
puts(
|
||||||
" - Chris Maltby <chris@aurema.com>\n"
|
" - Chris Maltby <chris@aurema.com>\n"
|
||||||
" - Ron Zapp <rzapper@yahoo.com>\n"
|
" - Ron Zapp <rzapper@yahoo.com>\n"
|
||||||
" - Paul Marquis <pmarquis@iname.com>\n"
|
" - Paul Marquis <pmarquis@iname.com>\n"
|
||||||
" - Ellis Pritchard <ellis@citria.com>\n"
|
" - Ellis Pritchard <ellis@citria.com>\n"
|
||||||
" - Damien Adant <dams@usa.net>\n"
|
" - Damien Adant <dams@usa.net>\n"
|
||||||
);
|
|
||||||
puts(
|
|
||||||
" - Chris <cbayliss@csc.come>\n"
|
" - Chris <cbayliss@csc.come>\n"
|
||||||
" - Marco G. Salvagno <mgs@whiz.cjb.net>\n"
|
" - Marco G. Salvagno <mgs@whiz.cjb.net>\n"
|
||||||
" - Paul Marquis <pmarquis@iname.com>\n"
|
" - Paul Marquis <pmarquis@iname.com>\n"
|
||||||
@@ -764,6 +770,7 @@ puts (
|
|||||||
" - Stephen Kick <skick@epicrealm.com>\n"
|
" - Stephen Kick <skick@epicrealm.com>\n"
|
||||||
" - Martin Hedenfalk <mhe@stacken.kth.se>\n"
|
" - Martin Hedenfalk <mhe@stacken.kth.se>\n"
|
||||||
" - Richard Prescott\n"
|
" - Richard Prescott\n"
|
||||||
|
" - Jason S. Priebe <priebe@wral-tv.com>\n"
|
||||||
"\n"
|
"\n"
|
||||||
"WWW\n"
|
"WWW\n"
|
||||||
" http://curl.haxx.se\n"
|
" http://curl.haxx.se\n"
|
||||||
@@ -1057,14 +1064,14 @@ puts (
|
|||||||
" being available or contain certain data.\n"
|
" being available or contain certain data.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" curl -e www.coolsite.com http://www.showme.com/\n"
|
" curl -e www.coolsite.com http://www.showme.com/\n"
|
||||||
|
);
|
||||||
|
puts(
|
||||||
"\n"
|
"\n"
|
||||||
"USER AGENT\n"
|
"USER AGENT\n"
|
||||||
"\n"
|
"\n"
|
||||||
" A HTTP request has the option to include information about the browser\n"
|
" A HTTP request has the option to include information about the browser\n"
|
||||||
" that generated the request. Curl allows it to be specified on the command\n"
|
" that generated the request. Curl allows it to be specified on the command\n"
|
||||||
" line. It is especially useful to fool or trick stupid servers or CGI\n"
|
" line. It is especially useful to fool or trick stupid servers or CGI\n"
|
||||||
);
|
|
||||||
puts(
|
|
||||||
" scripts that only accept certain browsers.\n"
|
" scripts that only accept certain browsers.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Example:\n"
|
" Example:\n"
|
||||||
@@ -1318,14 +1325,14 @@ puts (
|
|||||||
"\n"
|
"\n"
|
||||||
" Many older SSL-servers have problems with SSLv3 or TLS, that newer versions\n"
|
" Many older SSL-servers have problems with SSLv3 or TLS, that newer versions\n"
|
||||||
" of OpenSSL etc is using, therefore it is sometimes useful to specify what\n"
|
" of OpenSSL etc is using, therefore it is sometimes useful to specify what\n"
|
||||||
|
);
|
||||||
|
puts(
|
||||||
" SSL-version curl should use. Use -3 or -2 to specify that exact SSL version\n"
|
" SSL-version curl should use. Use -3 or -2 to specify that exact SSL version\n"
|
||||||
" to use:\n"
|
" to use:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" curl -2 https://secure.site.com/\n"
|
" curl -2 https://secure.site.com/\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Otherwise, curl will first attempt to use v3 and then v2.\n"
|
" Otherwise, curl will first attempt to use v3 and then v2.\n"
|
||||||
);
|
|
||||||
puts(
|
|
||||||
"\n"
|
"\n"
|
||||||
" To use OpenSSL to convert your favourite browser's certificate into a PEM\n"
|
" To use OpenSSL to convert your favourite browser's certificate into a PEM\n"
|
||||||
" formatted one that curl can use, do something like this (assuming netscape,\n"
|
" formatted one that curl can use, do something like this (assuming netscape,\n"
|
||||||
|
48
src/main.c
48
src/main.c
@@ -48,6 +48,8 @@
|
|||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <curl/types.h> /* new for v7 */
|
#include <curl/types.h> /* new for v7 */
|
||||||
#include <curl/easy.h> /* new for v7 */
|
#include <curl/easy.h> /* new for v7 */
|
||||||
|
|
||||||
|
#define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */
|
||||||
#include <curl/mprintf.h>
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
#include "urlglob.h"
|
#include "urlglob.h"
|
||||||
@@ -80,6 +82,16 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* The last #include file should be: */
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
/* this is low-level hard-hacking memory leak tracking shit */
|
||||||
|
#include "../lib/memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __cplusplus /* (rabe) */
|
||||||
|
typedef char bool;
|
||||||
|
#endif /* (rabe) */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HTTPREQ_UNSPEC,
|
HTTPREQ_UNSPEC,
|
||||||
HTTPREQ_GET,
|
HTTPREQ_GET,
|
||||||
@@ -504,23 +516,26 @@ static int getparameter(char *flag, /* f or -long-flag */
|
|||||||
if('-' == flag[0]) {
|
if('-' == flag[0]) {
|
||||||
/* try a long name */
|
/* try a long name */
|
||||||
int fnam=strlen(&flag[1]);
|
int fnam=strlen(&flag[1]);
|
||||||
|
int numhits=0;
|
||||||
for(j=0; j< sizeof(aliases)/sizeof(aliases[0]); j++) {
|
for(j=0; j< sizeof(aliases)/sizeof(aliases[0]); j++) {
|
||||||
if(strnequal(aliases[j].lname, &flag[1], fnam)) {
|
if(strnequal(aliases[j].lname, &flag[1], fnam)) {
|
||||||
longopt = TRUE;
|
longopt = TRUE;
|
||||||
|
numhits++;
|
||||||
if(strequal(aliases[j].lname, &flag[1])) {
|
if(strequal(aliases[j].lname, &flag[1])) {
|
||||||
parse = aliases[j].letter;
|
parse = aliases[j].letter;
|
||||||
hit = j;
|
hit = j;
|
||||||
|
numhits = 1; /* a single unique hit */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(parse) {
|
|
||||||
/* this is the second match, we can't continue! */
|
|
||||||
helpf("option --%s is ambiguous\n", &flag[1]);
|
|
||||||
return CURLE_FAILED_INIT;
|
|
||||||
}
|
|
||||||
parse = aliases[j].letter;
|
parse = aliases[j].letter;
|
||||||
hit = j;
|
hit = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(numhits>1) {
|
||||||
|
/* this is at least the second match! */
|
||||||
|
helpf("option --%s is ambiguous\n", &flag[1]);
|
||||||
|
return CURLE_FAILED_INIT;
|
||||||
|
}
|
||||||
if(hit < 0) {
|
if(hit < 0) {
|
||||||
helpf("unknown option -%s.\n", flag);
|
helpf("unknown option -%s.\n", flag);
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
@@ -1137,6 +1152,7 @@ void progressbarinit(struct ProgressData *bar)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char errorbuffer[CURL_ERROR_SIZE];
|
char errorbuffer[CURL_ERROR_SIZE];
|
||||||
|
char useragent[128]; /* buah, we don't want a larger default user agent */
|
||||||
struct ProgressData progressbar;
|
struct ProgressData progressbar;
|
||||||
|
|
||||||
struct OutStruct outs;
|
struct OutStruct outs;
|
||||||
@@ -1161,11 +1177,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
outs.stream = stdout;
|
outs.stream = stdout;
|
||||||
|
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
/* this sends all memory debug messages to a logfile named memdump */
|
||||||
|
curl_memdebug("memdump");
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(&config, 0, sizeof(struct Configurable));
|
memset(&config, 0, sizeof(struct Configurable));
|
||||||
|
|
||||||
/* set non-zero default values: */
|
|
||||||
config.useragent= maprintf(CURL_NAME "/" CURL_VERSION " (" OS ") "
|
|
||||||
"%s", curl_version());
|
|
||||||
config.showerror=TRUE;
|
config.showerror=TRUE;
|
||||||
config.conf=CONF_DEFAULT;
|
config.conf=CONF_DEFAULT;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1241,6 +1259,12 @@ int main(int argc, char *argv[])
|
|||||||
helpf("no URL specified!\n");
|
helpf("no URL specified!\n");
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
|
if(NULL == config.useragent) {
|
||||||
|
/* set non-zero default values: */
|
||||||
|
snprintf(useragent, sizeof(useragent),
|
||||||
|
CURL_NAME "/" CURL_VERSION " (" OS ") " "%s", curl_version());
|
||||||
|
config.useragent= useragent;
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "URL: %s PROXY: %s\n", url, config.proxy?config.proxy:"none");
|
fprintf(stderr, "URL: %s PROXY: %s\n", url, config.proxy?config.proxy:"none");
|
||||||
#endif
|
#endif
|
||||||
@@ -1512,7 +1536,6 @@ int main(int argc, char *argv[])
|
|||||||
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, config.condtime);
|
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, config.condtime);
|
||||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, config.customrequest);
|
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, config.customrequest);
|
||||||
curl_easy_setopt(curl, CURLOPT_STDERR, config.errors);
|
curl_easy_setopt(curl, CURLOPT_STDERR, config.errors);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEINFO, config.writeout);
|
|
||||||
|
|
||||||
/* three new ones in libcurl 7.3: */
|
/* three new ones in libcurl 7.3: */
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config.proxytunnel);
|
curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config.proxytunnel);
|
||||||
@@ -1530,6 +1553,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
if(config.writeout) {
|
||||||
|
ourWriteOut(curl, config.writeout);
|
||||||
|
}
|
||||||
|
|
||||||
/* always cleanup */
|
/* always cleanup */
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
@@ -1571,6 +1598,9 @@ int main(int argc, char *argv[])
|
|||||||
printf("--%s--\n", MIMEseparator);
|
printf("--%s--\n", MIMEseparator);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* cleanup memory used for URL globbing patterns */
|
||||||
|
glob_cleanup(urls);
|
||||||
|
|
||||||
curl_slist_free_all(config.quote); /* the checks for config.quote == NULL */
|
curl_slist_free_all(config.quote); /* the checks for config.quote == NULL */
|
||||||
curl_slist_free_all(config.postquote); /* */
|
curl_slist_free_all(config.postquote); /* */
|
||||||
curl_slist_free_all(config.headers); /* */
|
curl_slist_free_all(config.headers); /* */
|
||||||
|
@@ -45,6 +45,10 @@
|
|||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "urlglob.h"
|
#include "urlglob.h"
|
||||||
|
|
||||||
|
#ifdef MALLOCDEBUG
|
||||||
|
#include "../lib/memdebug.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
char glob_buffer[URL_MAX_LENGTH];
|
char glob_buffer[URL_MAX_LENGTH];
|
||||||
URLGlob *glob_expand;
|
URLGlob *glob_expand;
|
||||||
|
|
||||||
@@ -218,6 +222,24 @@ int glob_url(URLGlob** glob, char* url, int *urlnum)
|
|||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void glob_cleanup(URLGlob* glob) {
|
||||||
|
int i, elem;
|
||||||
|
|
||||||
|
for (i = glob->size - 1; i >= 0; --i) {
|
||||||
|
if (!(i & 1)) { /* even indexes contain literals */
|
||||||
|
free(glob->literal[i/2]);
|
||||||
|
} else { /* odd indexes contain sets or ranges */
|
||||||
|
if (glob->pattern[i/2].type == UPTSet) {
|
||||||
|
for (elem = glob->pattern[i/2].content.Set.size - 1; elem >= 0; --elem) {
|
||||||
|
free(glob->pattern[i/2].content.Set.elements[elem]);
|
||||||
|
}
|
||||||
|
free(glob->pattern[i/2].content.Set.elements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(glob);
|
||||||
|
}
|
||||||
|
|
||||||
char *next_url(URLGlob *glob)
|
char *next_url(URLGlob *glob)
|
||||||
{
|
{
|
||||||
static int beenhere = 0;
|
static int beenhere = 0;
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
#define CURL_NAME "curl"
|
#define CURL_NAME "curl"
|
||||||
#define CURL_VERSION "7.3"
|
#define CURL_VERSION "7.4.1"
|
||||||
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "
|
||||||
|
@@ -38,12 +38,14 @@
|
|||||||
* ------------------------------------------------------------
|
* ------------------------------------------------------------
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "setup.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "strequal.h"
|
#include <curl/curl.h>
|
||||||
|
#include <curl/types.h>
|
||||||
|
#include <curl/easy.h>
|
||||||
|
#include <curl/mprintf.h>
|
||||||
|
|
||||||
#include "writeout.h"
|
#include "writeout.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -57,6 +59,8 @@ typedef enum {
|
|||||||
VAR_SPEED_DOWNLOAD,
|
VAR_SPEED_DOWNLOAD,
|
||||||
VAR_SPEED_UPLOAD,
|
VAR_SPEED_UPLOAD,
|
||||||
VAR_HTTP_CODE,
|
VAR_HTTP_CODE,
|
||||||
|
VAR_HEADER_SIZE,
|
||||||
|
VAR_REQUEST_SIZE,
|
||||||
VAR_EFFECTIVE_URL,
|
VAR_EFFECTIVE_URL,
|
||||||
VAR_NUM_OF_VARS /* must be the last */
|
VAR_NUM_OF_VARS /* must be the last */
|
||||||
} replaceid;
|
} replaceid;
|
||||||
@@ -74,6 +78,8 @@ static struct variable replacements[]={
|
|||||||
{"time_namelookup", VAR_NAMELOOKUP_TIME},
|
{"time_namelookup", VAR_NAMELOOKUP_TIME},
|
||||||
{"time_connect", VAR_CONNECT_TIME},
|
{"time_connect", VAR_CONNECT_TIME},
|
||||||
{"time_pretransfer", VAR_PRETRANSFER_TIME},
|
{"time_pretransfer", VAR_PRETRANSFER_TIME},
|
||||||
|
{"size_header", VAR_HEADER_SIZE},
|
||||||
|
{"size_request", VAR_REQUEST_SIZE},
|
||||||
{"size_download", VAR_SIZE_DOWNLOAD},
|
{"size_download", VAR_SIZE_DOWNLOAD},
|
||||||
{"size_upload", VAR_SIZE_UPLOAD},
|
{"size_upload", VAR_SIZE_UPLOAD},
|
||||||
{"speed_download", VAR_SPEED_DOWNLOAD},
|
{"speed_download", VAR_SPEED_DOWNLOAD},
|
||||||
@@ -81,10 +87,14 @@ static struct variable replacements[]={
|
|||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
void WriteOut(struct UrlData *data)
|
void ourWriteOut(CURL *curl, char *writeinfo)
|
||||||
{
|
{
|
||||||
FILE *stream = stdout;
|
FILE *stream = stdout;
|
||||||
char *ptr=data->writeinfo;
|
char *ptr=writeinfo;
|
||||||
|
char *stringp;
|
||||||
|
long longinfo;
|
||||||
|
double doubleinfo;
|
||||||
|
|
||||||
while(*ptr) {
|
while(*ptr) {
|
||||||
if('%' == *ptr) {
|
if('%' == *ptr) {
|
||||||
if('%' == ptr[1]) {
|
if('%' == ptr[1]) {
|
||||||
@@ -105,37 +115,65 @@ void WriteOut(struct UrlData *data)
|
|||||||
if(strequal(ptr, replacements[i].name)) {
|
if(strequal(ptr, replacements[i].name)) {
|
||||||
switch(replacements[i].id) {
|
switch(replacements[i].id) {
|
||||||
case VAR_EFFECTIVE_URL:
|
case VAR_EFFECTIVE_URL:
|
||||||
fprintf(stream, "%s", data->url?data->url:"");
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &stringp))
|
||||||
|
fputs(stringp, stream);
|
||||||
break;
|
break;
|
||||||
case VAR_HTTP_CODE:
|
case VAR_HTTP_CODE:
|
||||||
fprintf(stream, "%03d", data->progress.httpcode);
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_HTTP_CODE, &longinfo))
|
||||||
|
fprintf(stream, "%03d", longinfo);
|
||||||
|
break;
|
||||||
|
case VAR_HEADER_SIZE:
|
||||||
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_HEADER_SIZE, &longinfo))
|
||||||
|
fprintf(stream, "%d", longinfo);
|
||||||
|
break;
|
||||||
|
case VAR_REQUEST_SIZE:
|
||||||
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_REQUEST_SIZE, &longinfo))
|
||||||
|
fprintf(stream, "%d", longinfo);
|
||||||
break;
|
break;
|
||||||
case VAR_TOTAL_TIME:
|
case VAR_TOTAL_TIME:
|
||||||
fprintf(stream, "%.3f", data->progress.timespent);
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &doubleinfo))
|
||||||
|
fprintf(stream, "%.3f", doubleinfo);
|
||||||
break;
|
break;
|
||||||
case VAR_NAMELOOKUP_TIME:
|
case VAR_NAMELOOKUP_TIME:
|
||||||
fprintf(stream, "%.3f", tvdiff(data->progress.t_nslookup,
|
if(CURLE_OK ==
|
||||||
data->progress.start));
|
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME,
|
||||||
|
&doubleinfo))
|
||||||
|
fprintf(stream, "%.3f", doubleinfo);
|
||||||
break;
|
break;
|
||||||
case VAR_CONNECT_TIME:
|
case VAR_CONNECT_TIME:
|
||||||
fprintf(stream, "%.3f", tvdiff(data->progress.t_connect,
|
if(CURLE_OK ==
|
||||||
data->progress.start));
|
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &doubleinfo))
|
||||||
|
fprintf(stream, "%.3f", doubleinfo);
|
||||||
break;
|
break;
|
||||||
case VAR_PRETRANSFER_TIME:
|
case VAR_PRETRANSFER_TIME:
|
||||||
fprintf(stream, "%.3f", tvdiff(data->progress.t_pretransfer,
|
if(CURLE_OK ==
|
||||||
data->progress.start));
|
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &doubleinfo))
|
||||||
|
fprintf(stream, "%.3f", doubleinfo);
|
||||||
break;
|
break;
|
||||||
case VAR_SIZE_UPLOAD:
|
case VAR_SIZE_UPLOAD:
|
||||||
fprintf(stream, "%.0f", data->progress.uploaded);
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_SIZE_UPLOAD, &doubleinfo))
|
||||||
|
fprintf(stream, "%.3f", doubleinfo);
|
||||||
break;
|
break;
|
||||||
case VAR_SIZE_DOWNLOAD:
|
case VAR_SIZE_DOWNLOAD:
|
||||||
fprintf(stream, "%.0f", data->progress.downloaded);
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD, &doubleinfo))
|
||||||
|
fprintf(stream, "%.3f", doubleinfo);
|
||||||
break;
|
break;
|
||||||
case VAR_SPEED_DOWNLOAD:
|
case VAR_SPEED_DOWNLOAD:
|
||||||
fprintf(stream, "%.2f", data->progress.dlspeed);
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD, &doubleinfo))
|
||||||
|
fprintf(stream, "%.3f", doubleinfo);
|
||||||
break;
|
break;
|
||||||
case VAR_SPEED_UPLOAD:
|
case VAR_SPEED_UPLOAD:
|
||||||
fprintf(stream, "%.2f", data->progress.ulspeed);
|
if(CURLE_OK ==
|
||||||
|
curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD, &doubleinfo))
|
||||||
|
fprintf(stream, "%.3f", doubleinfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
@@ -40,8 +40,6 @@
|
|||||||
* ------------------------------------------------------------
|
* ------------------------------------------------------------
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "urldata.h"
|
void ourWriteOut(CURL *curl, char *out);
|
||||||
|
|
||||||
void WriteOut(struct UrlData *data);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user