Compare commits

..

54 Commits

Author SHA1 Message Date
Daniel Stenberg
f6163b375f 7.4.1 commit 2000-10-16 13:52:05 +00:00
Daniel Stenberg
b2d73c50d3 pre5 and pre6 fixes 2000-10-12 09:14:57 +00:00
Daniel Stenberg
834b7de33c Added lib/libcurl.def for win32 DLL creations 2000-10-12 09:13:55 +00:00
Daniel Stenberg
debdd93e1b just removed some example lines in the top comment 2000-10-12 09:13:22 +00:00
Daniel Stenberg
4e8ddedc8f Jrn added glob_cleanup() 2000-10-12 09:12:24 +00:00
Daniel Stenberg
751d503f54 sprintf() => snprintf() 2000-10-12 08:22:16 +00:00
Daniel Stenberg
b2e47dfde4 updated to better reflect reality 2000-10-11 10:59:36 +00:00
Daniel Stenberg
0af8201cc2 make curl capable of using the mozilla SSL engine 2000-10-11 10:59:16 +00:00
Daniel Stenberg
7717212912 free the URL string if that was allocated 2000-10-11 10:58:37 +00:00
Daniel Stenberg
ccb2b5d22c free the FTP struct already in the _done() function 2000-10-11 10:57:52 +00:00
Daniel Stenberg
85174ed358 memory leak adjusts 2000-10-11 10:29:25 +00:00
Daniel Stenberg
111d1d09d3 removed the header that confuses PHP 2000-10-09 22:29:35 +00:00
Daniel Stenberg
4f5a4c9bd5 added the bool typedef, moved here from curl/curl.h 2000-10-09 21:36:38 +00:00
Daniel Stenberg
8c62e337b0 bool typedef fix 2000-10-09 21:35:40 +00:00
Daniel Stenberg
51bcdb472b use this to analyze the memory debug logs MALLOCDEBUG will generate 2000-10-09 11:31:55 +00:00
Daniel Stenberg
5ee185f420 just too many to mention 2000-10-09 11:25:40 +00:00
Daniel Stenberg
fb739ac130 Added commented MALLOCDEBUG stuff for memory debugging 2000-10-09 11:24:49 +00:00
Daniel Stenberg
cdd91bed46 I commented the -DMALLOCDEBUG flag to make it easier to add 2000-10-09 11:24:18 +00:00
Daniel Stenberg
9defb83930 added memory debugging support 2000-10-09 11:13:17 +00:00
Daniel Stenberg
0f8facb49b added memory debugging include file 2000-10-09 11:12:34 +00:00
Daniel Stenberg
d49d05bce6 added for memory leak debugging etc 2000-10-09 11:11:43 +00:00
Daniel Stenberg
1e2e6a4e33 GetHost() did not properly assign the third argument pointer! 2000-10-08 12:50:51 +00:00
Daniel Stenberg
5b39a48e22 corrected the --longoption parser 2000-10-06 12:45:05 +00:00
Daniel Stenberg
2918836cef removed include "writeout.h" 2000-10-06 11:06:20 +00:00
Daniel Stenberg
b900318d8d Jrg's updated makefile 2000-10-06 11:03:43 +00:00
Daniel Stenberg
c58dc8f82f the --interface code doesn't work on win32 and is #ifndef WIN32 now 2000-10-06 11:03:20 +00:00
Daniel Stenberg
0ddacf929a added for the win32 version 2000-10-06 11:02:48 +00:00
Daniel Stenberg
a513e97464 moved the src/config.h stuff to the bottom, as automake were adding include
stuff to ../src in the lib directory's Makefile.in otherwise!
2000-10-06 10:40:43 +00:00
Daniel Stenberg
03a56b3e56 HTTP resume fix, now the range pointer may be allocated 2000-10-06 06:28:39 +00:00
Daniel Stenberg
18f67852be filled in more information on the options 2000-10-04 13:09:15 +00:00
Daniel Stenberg
693aab0e95 size_request and size_header added to the -w description 2000-10-04 13:08:54 +00:00
Daniel Stenberg
ccd0f07c41 -w supports size_header and size_request 2000-10-04 13:08:17 +00:00
Daniel Stenberg
5865860ad6 counts header and request size 2000-10-04 13:07:43 +00:00
Daniel Stenberg
bf56377865 Added Jason S. Priebe as contributor 2000-10-03 22:07:09 +00:00
Daniel Stenberg
e012d32e66 documented writeinfo as removed in 7.4 2000-10-03 22:06:26 +00:00
Daniel Stenberg
763797ab3c introduced in libcurl 7.4 2000-10-03 22:05:27 +00:00
Daniel Stenberg
2cdd150723 removed writeinfo stuff 2000-10-03 22:04:04 +00:00
Daniel Stenberg
d46b006f22 add_buffer_send() free()d the buffer *before* it was used! :-O 2000-10-03 16:53:41 +00:00
Daniel Stenberg
033263e696 added the new upload_bufsize to the connectdata struct 2000-10-03 11:05:09 +00:00
Daniel Stenberg
eee5c71aff inits the upload_bufsize at connect time 2000-10-03 11:03:55 +00:00
Daniel Stenberg
f1b8566ea2 new upload-buffer size design that starts with a smallish buffer and increases
its size in case of need
2000-10-03 11:02:52 +00:00
Daniel Stenberg
d3f9b2a490 introduced the new add_buffer() concept that makes the HTTP request to get
sent in only one shot
2000-10-03 11:01:32 +00:00
Daniel Stenberg
398d21696f Added curl_easy_getinfo.3 2000-10-02 06:49:51 +00:00
Daniel Stenberg
99fbcac6b9 added a small suggestion on how to get the curl man page in text format
without nroff
2000-10-02 06:40:14 +00:00
Daniel Stenberg
c23e387928 Uses the new "client-side" writeout function 2000-10-02 06:36:34 +00:00
Daniel Stenberg
ef77d484f0 removed writeout.[ch] and added getinfo.c 2000-10-02 06:32:31 +00:00
Daniel Stenberg
df7b9e7af6 Added writeout.c 2000-10-02 06:32:05 +00:00
Daniel Stenberg
f612f194be writeout.[ch] added in src/ 2000-10-02 06:31:10 +00:00
Daniel Stenberg
dfec172157 moved out from the library and put here, uses the new curl_easy_getinfo() 2000-10-02 06:30:40 +00:00
Daniel Stenberg
888182c16d adjusted for curl_easy_getinfo 2000-10-02 06:29:39 +00:00
Daniel Stenberg
d5ad450db6 getinfo.c replaces the former writeout.c 2000-10-02 06:28:55 +00:00
Daniel Stenberg
b0274a553b Added curl_easy_getinfo() 2000-10-02 06:27:43 +00:00
Daniel Stenberg
e372a440c0 #include <malloc.h> was removed, it causes warnings on openbsd 2000-09-29 06:34:50 +00:00
Daniel Stenberg
91bda5650c include base64.h instead of base64_krb.h 2000-09-28 10:36:31 +00:00
47 changed files with 1402 additions and 292 deletions

129
CHANGES
View File

@@ -6,6 +6,135 @@
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
Daniel (28 September 2000)

3
FILES
View File

@@ -49,6 +49,8 @@ src/setup.h
src/urlglob.c
src/urlglob.h
src/version.h
src/writeout.c
src/writeout.h
src/*.in
src/*.am
src/mkhelp.pl
@@ -60,6 +62,7 @@ lib/*in
lib/*am
lib/Makefile.vc6
lib/*m32
lib/libcurl.def
include/README
include/Makefile.in
include/Makefile.am

View File

@@ -2,7 +2,7 @@ dnl $Id$
dnl Process this file with autoconf to produce a configure script.
AC_INIT(lib/urldata.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
dnl

View File

@@ -34,8 +34,7 @@ Windows vs Unix
(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
through stdout...
(4) we set stdout to binary under windows
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
@@ -84,10 +83,6 @@ Library
called). The speedcheck functions in lib/speedcheck.c are also used to verify
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
resources.
@@ -158,3 +153,9 @@ Client
control after the curl_easy_perform() it cleans up the library, checks status
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.

View File

@@ -7,6 +7,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = \
curl.1 \
curl_easy_cleanup.3 \
curl_easy_getinfo.3 \
curl_easy_init.3 \
curl_easy_perform.3 \
curl_easy_setopt.3 \

View File

@@ -17,3 +17,8 @@ README.win32
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
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

View File

@@ -13,6 +13,14 @@ For the future
product! (Yes, you may add things not mentioned here, these are just a
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
possible to write using that interface. Document the low-level interface

View File

@@ -410,11 +410,17 @@ The total amount of bytes that were downloaded.
.B size_upload
The total amount of bytes that were uploaded.
.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
The average download speed that curl measured for the complete download.
.TP
.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
.IP "-x/--proxy <proxyhost[:port]>"
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>
- Martin Hedenfalk <mhe@stacken.kth.se>
- Richard Prescott
- Jason S. Priebe <priebe@wral-tv.com>
.SH WWW
http://curl.haxx.se

81
docs/curl_easy_getinfo.3 Normal file
View 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!

View File

@@ -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)
.TP
.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
report information after a successful request. This string may contain
variables that will be substituted by their contents when output. Described

View File

@@ -412,10 +412,6 @@ typedef enum {
#ifdef __BEOS__
#include <support/SupportDefs.h>
#else
#ifndef __cplusplus /* (rabe) */
typedef char bool;
#endif /* (rabe) */
#endif
@@ -438,14 +434,14 @@ int curl_formparse(char *string,
MUST be free()ed after usage is complete. */
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);
/* This is the version number */
#define LIBCURL_VERSION "7.3"
#define LIBCURL_VERSION_NUM 0x070300
#define LIBCURL_VERSION "7.4.1"
#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 {
char *data;
struct curl_slist *next;
@@ -642,6 +638,45 @@ CURLcode curl_disconnect(CURLconnect *connect);
*/
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
}
#endif

View File

@@ -48,6 +48,21 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
CURLcode curl_easy_perform(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
}
#endif

View File

@@ -7,7 +7,7 @@ AUTOMAKE_OPTIONS = foreign
lib_LTLIBRARIES = libcurl.la
# Some flags needed when trying to cause warnings ;-)
# CFLAGS = -g -Wall #-pedantic
# CFLAGS = -DMALLOCDEBUG -g # -Wall #-pedantic
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 \
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
getinfo.c highlevel.c strequal.c strequal.h easy.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.
$(srcdir)/getdate.c: getdate.y

View File

@@ -82,11 +82,11 @@ AUTOMAKE_OPTIONS = foreign
lib_LTLIBRARIES = libcurl.la
# Some flags needed when trying to cause warnings ;-)
# CFLAGS = -g -Wall #-pedantic
# CFLAGS = -DMALLOCDEBUG -g # -Wall #-pedantic
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
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 \
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 \
getenv.lo escape.lo mprintf.lo telnet.lo getpass.lo netrc.lo \
writeout.lo highlevel.lo strequal.lo easy.lo security.lo krb4.lo
getenv.lo escape.lo mprintf.lo telnet.lo getpass.lo netrc.lo getinfo.lo \
highlevel.lo strequal.lo easy.lo security.lo krb4.lo memdebug.lo
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)

View File

@@ -1,6 +1,6 @@
#############################################################
## 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
##
## Comments to: Troy Engel <tengel@sonic.net> or
@@ -9,48 +9,59 @@
CC = gcc
AR = ar
RANLIB = ranlib
OPENSSL_PATH = ../../openssl-0.9.5a
STRIP = strip -g
OPENSSL_PATH = ../../openssl-0.9.6
########################################################
## Nothing more to do below this line!
INCLUDES = -I. -I.. -I../include
INCLUDES = -I. -I.. -I../include -I../src
CFLAGS = -g -O2 -DMINGW32
ifdef SSL
INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl"
CFLAGS += -DUSE_SSLEAY
DLL_LIBS = -leay32 -lssl32 -lRSAglue
endif
COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
libcurl_a_LIBRARIES = libcurl.a
libcurl_a_SOURCES = base64.c getenv.c if2ip.h progress.h \
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 \
urldata.h formdata.c hostip.h netrc.h stdcheaders.h formdata.h \
if2ip.c progress.c sendf.c sendf.h speedcheck.c speedcheck.h \
ftp.c ftp.h getpass.h version.c timeval.c timeval.h cookie.c \
cookie.h escape.c escape.h getdate.c getdate.h dict.h dict.c http.c \
http.h telnet.c telnet.h file.c file.h ldap.c ldap.h writeout.c writeout.h \
highlevel.c strequal.c strequal.h easy.c
libcurl_a_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
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 \
sendf.o speedcheck.o ftp.o version.o timeval.o \
cookie.o escape.o getdate.o dict.o http.o telnet.o file.o ldap.o writeout.o \
highlevel.o strequal.o easy.o
libcurl_a_OBJECTS = file.o timeval.o base64.o hostip.o progress.o \
formdata.o cookie.o http.o sendf.o ftp.o url.o dict.o if2ip.o \
speedcheck.o getdate.o download.o ldap.o ssluse.o version.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)
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
$(AR) cru libcurl.a $(libcurl_a_OBJECTS)
$(RANLIB) libcurl.a
$(STRIP) $@
# remove the last line above to keep debug info
libcurl.dll libcurldll.a: libcurl.a libcurl.def dllinit.o
-@erase $@
dllwrap --dllname $@ --output-lib libcurldll.a --export-all --def libcurl.def $(libcurl_a_LIBRARIES) dllinit.o -L$(OPENSSL_PATH)/out $(DLL_LIBS) -lwsock32
$(STRIP) $@
# remove the last line above to keep debug info
.c.o:
$(COMPILE) -c $<

View File

@@ -38,6 +38,11 @@
#include <string.h>
#include "base64.h"
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static int pos(char c)

View File

@@ -65,6 +65,11 @@ Example set of cookies:
#include "getdate.h"
#include "strequal.h"
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
/****************************************************************************
*
* cookie_add()
@@ -496,6 +501,7 @@ void cookie_cleanup(struct CookieInfo *c)
free(co);
co = next;
}
free(c); /* free the base struct as well */
}
}

82
lib/dllinit.c Normal file
View 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;
}

View File

@@ -162,3 +162,13 @@ void curl_easy_cleanup(CURL *curl)
curl_close(curl);
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);
}

View File

@@ -48,6 +48,11 @@
#include <stdlib.h>
#include <string.h>
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
char *curl_escape(char *string)
{
int alloc=strlen(string)+1;

View File

@@ -63,6 +63,11 @@
#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
in binary data is very close to zero, 64^32 makes
6277101735386680763835789423207666416102355444464034512896
@@ -458,12 +463,20 @@ struct FormData *getFormData(struct HttpPost *post,
"\r\nContent-Type: %s",
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 &&
!strnequal("text/", file->contenttype, 5)) {
/* this is not a text content, mention our binary encoding */
size += AddFormData(&form, "\r\nContent-Transfer-Encoding: binary", 0);
}
#endif
size += AddFormData(&form, "\r\n\r\n", 0);

View File

@@ -89,6 +89,10 @@
#ifdef KRB4
#include "security.h"
#endif
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
/* returns last node in linked 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)
free(ftp->dir);
/* TBD: the ftp struct is still allocated here */
free(ftp);
data->proto.ftp=NULL; /* it is gone */
return CURLE_OK;
}
@@ -1178,7 +1183,7 @@ CURLcode _ftp(struct connectdata *conn)
else {
/* Set type to binary (unless specified ASCII) */
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);
if(nread < 0)

View File

@@ -45,6 +45,10 @@
#include <windows.h>
#endif
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
char *GetEnv(char *variable)
{
#ifdef WIN32

124
lib/getinfo.c Normal file
View 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;
}

View File

@@ -107,11 +107,19 @@
#include "getpass.h"
#include "progress.h"
#include "getdate.h"
#include "writeout.h"
#define _MPRINTF_REPLACE /* use our functions only */
#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
_Transfer(struct connectdata *c_conn)
{
@@ -345,6 +353,7 @@ _Transfer(struct connectdata *c_conn)
return CURLE_WRITE_ERROR;
}
}
data->header_size += p - data->headerbuff;
break; /* exit header line loop */
}
@@ -421,6 +430,7 @@ _Transfer(struct connectdata *c_conn)
return CURLE_WRITE_ERROR;
}
}
data->header_size += hbuflen;
/* reset hbufp pointer && hbuflen */
hbufp = data->headerbuff;
@@ -522,7 +532,7 @@ _Transfer(struct connectdata *c_conn)
if(data->crlf)
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
unsigned size_t */
@@ -570,6 +580,15 @@ _Transfer(struct connectdata *c_conn)
if (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)) {
failf (data, "Operation timed out with %d out of %d bytes received",
bytecount, conn->size);
@@ -703,6 +722,7 @@ CURLcode curl_transfer(CURL *curl)
/* TBD: set the URL with curl_setopt() */
data->url = data->newurl;
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
following isn't what anyone would want! */
@@ -724,10 +744,12 @@ CURLcode curl_transfer(CURL *curl)
if(data->newurl)
free(data->newurl);
#if 0
if((CURLE_OK == res) && data->writeinfo) {
/* Time to output some info to stdout */
WriteOut(data);
}
#endif
return res;
}

View File

@@ -41,7 +41,6 @@
#include "setup.h"
#include <string.h>
#include <malloc.h>
#include <errno.h>
#define _REENTRANT
@@ -73,6 +72,11 @@
#include "inet_ntoa_r.h"
#endif
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
/* --- resolve name or IP-number --- */
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);
if(!buf)
return NULL; /* major failure */
*bufp = buf;
if ( (in=inet_addr(hostname)) != INADDR_NONE ) {
struct in_addr *addrentry;

View File

@@ -117,6 +117,11 @@
#define _MPRINTF_REPLACE /* use our functions only */
#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
* header (prefix).
@@ -249,7 +254,8 @@ CURLcode http_done(struct connectdata *conn)
*bytecount = http->readbytecount + http->writebytecount;
}
/* TBD: the HTTP struct remains allocated here */
free(http);
data->proto.http=NULL; /* it is gone */
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";
do {
send_buffer *req_buffer;
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:
(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> */
);
/* initialize a dynamic send-buffer */
req_buffer = add_buffer_init();
/* add the main request stuff */
add_bufferf(req_buffer,
"%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:
(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) {
int count=0;
@@ -376,19 +388,16 @@ CURLcode http(struct connectdata *conn)
while(co) {
if(co->value && strlen(co->value)) {
if(0 == count) {
sendf(data->firstsocket, data,
"Cookie:");
add_bufferf(req_buffer, "Cookie:");
}
sendf(data->firstsocket, data,
"%s%s=%s", count?"; ":"", co->name,
co->value);
add_bufferf(req_buffer,
"%s%s=%s", count?"; ":"", co->name, co->value);
count++;
}
co = co->next; /* next cookie please */
}
if(count) {
sendf(data->firstsocket, data,
"\r\n");
add_buffer(req_buffer, "\r\n", 2);
}
cookie_freelist(co); /* free the cookie list */
co=NULL;
@@ -419,16 +428,16 @@ CURLcode http(struct connectdata *conn)
switch(data->timecondition) {
case TIMECOND_IFMODSINCE:
default:
sendf(data->firstsocket, data,
"If-Modified-Since: %s\r\n", buf);
add_bufferf(req_buffer,
"If-Modified-Since: %s\r\n", buf);
break;
case TIMECOND_IFUNMODSINCE:
sendf(data->firstsocket, data,
"If-Unmodified-Since: %s\r\n", buf);
add_bufferf(req_buffer,
"If-Unmodified-Since: %s\r\n", buf);
break;
case TIMECOND_LASTMOD:
sendf(data->firstsocket, data,
"Last-Modified: %s\r\n", buf);
add_bufferf(req_buffer,
"Last-Modified: %s\r\n", buf);
break;
}
}
@@ -445,9 +454,7 @@ CURLcode http(struct connectdata *conn)
if(*ptr) {
/* only send this if the contents was non-blank */
sendf(data->firstsocket, data,
"%s\015\012",
headers->data);
add_bufferf(req_buffer, "%s\r\n", headers->data);
}
}
headers = headers->next;
@@ -468,12 +475,14 @@ CURLcode http(struct connectdata *conn)
generated form data */
data->in = (FILE *)&http->form;
sendf(data->firstsocket, data,
"Content-Length: %d\r\n",
http->postsize-2);
add_bufferf(req_buffer,
"Content-Length: %d\r\n", http->postsize-2);
/* set upload size to the progress meter */
pgrsSetUploadSize(data, http->postsize);
data->request_size =
add_buffer_send(data->firstsocket, conn, req_buffer);
result = Transfer(conn, data->firstsocket, -1, TRUE,
&http->readbytecount,
data->firstsocket,
@@ -487,16 +496,21 @@ CURLcode http(struct connectdata *conn)
/* Let's PUT the data to the server! */
if(data->infilesize>0) {
sendf(data->firstsocket, data,
"Content-Length: %d\r\n\r\n", /* file size */
data->infilesize );
add_bufferf(req_buffer,
"Content-Length: %d\r\n\r\n", /* file size */
data->infilesize );
}
else
sendf(data->firstsocket, data,
"\015\012");
add_bufferf(req_buffer, "\015\012");
/* set the upload size to the progress meter */
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,
&http->readbytecount,
data->firstsocket,
@@ -512,28 +526,35 @@ CURLcode http(struct connectdata *conn)
if(!checkheaders(data, "Content-Length:"))
/* we allow replacing this header, although it isn't very wise to
actually set your own */
sendf(data->firstsocket, data,
"Content-Length: %d\r\n",
(data->postfieldsize?data->postfieldsize:
strlen(data->postfields)) );
add_bufferf(req_buffer,
"Content-Length: %d\r\n",
(data->postfieldsize?data->postfieldsize:
strlen(data->postfields)) );
if(!checkheaders(data, "Content-Type:"))
sendf(data->firstsocket, data,
"Content-Type: application/x-www-form-urlencoded\r\n");
add_bufferf(req_buffer,
"Content-Type: application/x-www-form-urlencoded\r\n");
/* and here comes the actual data */
if(data->postfieldsize) {
ssend(data->firstsocket, conn, "\r\n", 2);
ssend(data->firstsocket, conn, data->postfields, data->postfieldsize);
ssend(data->firstsocket, conn, "\r\n", 2);
add_buffer(req_buffer, "\r\n", 2);
add_buffer(req_buffer, data->postfields,
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
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: */
result = Transfer(conn, data->firstsocket, -1, TRUE, bytecount,

View File

@@ -40,13 +40,18 @@
#ifdef KRB4
#include "security.h"
#include "base64_krb.h"
#include "base64.h"
#include <stdlib.h>
#include <netdb.h>
#include <syslog.h>
#include <string.h>
#include <krb.h>
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
#ifdef FTP_SERVER
#define LOCAL_ADDR ctrl_addr
#define REMOTE_ADDR his_addr

37
lib/libcurl.def Normal file
View 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
View 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
View 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

View File

@@ -98,6 +98,10 @@ static const char rcsid[] = "@(#)$Id$";
#include <ctype.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 MAX_PARAMETERS 128 /* lame static limit */

View File

@@ -38,15 +38,19 @@
#include "setup.h"
#include <curl/mprintf.h>
#ifdef KRB4
#include <curl/mprintf.h>
#include "security.h"
#include <stdlib.h>
#include <string.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))

View File

@@ -53,13 +53,19 @@
#include <curl/curl.h>
#include "urldata.h"
#include "sendf.h"
#define _MPRINTF_REPLACE /* use the internal *printf() functions */
#include <curl/mprintf.h>
#ifdef KRB4
#include "security.h"
#include <string.h>
#endif
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
/* infof() is for info message along the way */
@@ -82,14 +88,14 @@ void failf(struct UrlData *data, char *fmt, ...)
va_list ap;
va_start(ap, fmt);
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 */
vfprintf(data->err, fmt, ap);
va_end(ap);
}
/* 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;
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
*/
int ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
size_t ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
{
size_t bytes_written;
char *s;
@@ -154,9 +160,6 @@ size_t ssend(int fd, struct connectdata *conn, void *mem, size_t len)
size_t bytes_written;
struct UrlData *data=conn->data; /* conn knows data, not vice versa */
if(data->bits.verbose)
fprintf(data->err, "> [binary output]\n");
#ifdef USE_SSLEAY
if (data->use_ssl) {
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;
}
/*
* 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;
}

View File

@@ -46,4 +46,18 @@ size_t ssend(int fd, struct connectdata *, void *fmt, size_t len);
void infof(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

View File

@@ -57,6 +57,10 @@
#endif
#endif
#ifndef __cplusplus /* (rabe) */
typedef char bool;
#endif /* (rabe) */
#include <stdio.h>
#ifndef OS
#ifdef WIN32

View File

@@ -109,7 +109,6 @@
#include "progress.h"
#include "cookie.h"
#include "strequal.h"
#include "writeout.h"
/* And now for the protocols */
#include "ftp.h"
@@ -127,6 +126,10 @@
#ifdef KRB4
#include "security.h"
#endif
/* The last #include file should be: */
#ifdef MALLOCDEBUG
#include "memdebug.h"
#endif
/* -- -- */
@@ -184,6 +187,11 @@ void static urlfree(struct UrlData *data, bool totally)
data->bits.httpproxy=FALSE;
}
if(data->bits.rangestringalloc) {
free(data->range);
data->range=NULL;
}
if(data->ptr_proxyuserpwd) {
free(data->ptr_proxyuserpwd);
data->ptr_proxyuserpwd=NULL;
@@ -227,6 +235,10 @@ void static urlfree(struct UrlData *data, bool totally)
if(data->free_referer)
free(data->referer);
if(data->bits.urlstringalloc)
/* the URL is allocated, free it! */
free(data->url);
cookie_cleanup(data->cookies);
free(data);
@@ -483,9 +495,11 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
case CURLOPT_WRITEFUNCTION:
data->fwrite = va_arg(param, curl_write_callback);
break;
#if 0
case CURLOPT_WRITEINFO:
data->writeinfo = va_arg(param, char *);
break;
#endif
case CURLOPT_READFUNCTION:
data->fread = va_arg(param, curl_read_callback);
break;
@@ -692,6 +706,9 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
conn->data = data; /* remember our daddy */
conn->state = CONN_INIT;
conn->upload_bufsize = UPLOAD_BUFSIZE; /* the smallest upload buffer size
we use */
buf = data->buffer; /* this is our buffer */
#if 0
@@ -900,8 +917,9 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
if(data->resume_from) {
if(!data->bits.set_range) {
/* if it already was in use, we just skip this */
sprintf(resumerange, "%d-", data->resume_from);
data->range=resumerange; /* tell ourselves to fetch this range */
snprintf(resumerange, sizeof(resumerange), "%d-", data->resume_from);
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 */
}
}
@@ -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_port = htons(data->port);
/* sck 8/31/2000 add support for specifing device to bind socket to */
/* #ifdef LINUX */
/* I am using this, but it may not work everywhere, only tested on RedHat 6.2 */
#ifndef WIN32
/* We don't generally like checking for OS-versions, we should make this
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
#ifndef INADDR_NONE
@@ -1326,6 +1349,7 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
} /* end of device selection support */
#endif /* end of HAVE_INET_NTOA */
#endif /* end of not WIN32 */
if (connect(data->firstsocket,
(struct sockaddr *) &(conn->serv_addr),
@@ -1391,7 +1415,8 @@ CURLcode curl_connect(CURL *curl, CURLconnect **in_connect)
if(data->bits.proxy_user_passwd) {
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),
&authorization) >= 0) {
data->ptr_proxyuserpwd =

View File

@@ -99,6 +99,11 @@
/* Download buffer size, keep it fairly big for speed reasons */
#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
of need. */
#define HEADERSIZE 256
@@ -175,6 +180,9 @@ struct connectdata {
long bytecount;
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
be protocol dependent */
CURLcode (*curl_do)(struct connectdata *connect);
@@ -203,7 +211,6 @@ struct connectdata {
the same we read from. -1 disables */
long *writebytecountp; /* return number of bytes written or NULL */
#ifdef KRB4
enum protection_level command_prot;
@@ -297,7 +304,6 @@ struct Configbits {
bool mute;
bool no_body;
bool proxy_user_passwd;
bool proxystringalloc; /* the http proxy string is malloc()'ed */
bool set_port;
bool set_range;
bool upload;
@@ -306,6 +312,10 @@ struct Configbits {
bool verbose;
bool this_is_a_follow; /* this is a followed Location: request */
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 */
@@ -349,6 +359,10 @@ struct UrlData {
proxy string features a ":[port]" that one will override
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 ************/
union {
@@ -455,8 +469,11 @@ struct UrlData {
char *headerbuff; /* allocated buffer to store headers in */
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
completion */
#endif
struct Progress progress;

98
memanalyze.pl Executable file
View 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";
}
}

View File

@@ -3,14 +3,17 @@
#
# Some flags needed when trying to cause warnings ;-)
# CFLAGS = -Wall -pedantic
# CFLAGS = -g -DMALLOCDEBUG # -Wall -pedantic
#CPPFLAGS = -DGLOBURL -DCURL_SEPARATORS
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_DEPENDENCIES = $(top_srcdir)/lib/libcurl.la
BUILT_SOURCES = hugehelp.c

View File

@@ -1,15 +1,15 @@
#############################################################
## 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
## Joern Hartroth <hartroth@acm.org>
CC = gcc
STRIP = strip -s
OPENSSL_PATH = ../../openssl-0.9.5a
OPENSSL_PATH = ../../openssl-0.9.6
# We may need these someday
# PERL = perl
@@ -25,10 +25,16 @@ COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
curl_PROGRAMS = curl.exe
curl_OBJECTS = main.o hugehelp.o urlglob.o
curl_SOURCES = main.c hugehelp.c urlglob.c
curl_DEPENDENCIES = ../lib/libcurl.a
curl_LDADD = -L../lib -lcurl -lwsock32
curl_OBJECTS = main.o hugehelp.o urlglob.o writeout.o
curl_SOURCES = main.c hugehelp.c urlglob.c writeout.c
ifdef DYN
curl_DEPENDENCIES = ../lib/libcurldll.a ../lib/libcurl.dll
curl_LDADD = -L../lib -lcurldll
else
curl_DEPENDENCIES = ../lib/libcurl.a
curl_LDADD = -L../lib -lcurl
endif
curl_LDADD += -lwsock32
ifdef SSL
curl_LDADD += -L$(OPENSSL_PATH)/out -leay32 -lssl32 -lRSAglue
endif
@@ -37,12 +43,12 @@ PROGRAMS = $(curl_PROGRAMS)
SOURCES = $(curl_SOURCES)
OBJECTS = $(curl_OBJECTS)
all: curl
all: curl.exe
curl: $(curl_OBJECTS) $(curl_DEPENDENCIES)
-@erase curl.exe
curl.exe: $(curl_OBJECTS) $(curl_DEPENDENCIES)
-@erase $@
$(LINK) $(curl_OBJECTS) $(curl_LDADD)
$(STRIP) $(curl_PROGRAMS)
$(STRIP) $@
# We don't have nroff normally under win32
# hugehelp.c: ../README.curl ../curl.1 mkhelp.pl

View File

@@ -496,11 +496,17 @@ puts (
" size_upload The total amount of bytes that were\n"
" uploaded.\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"
" measured for the complete download.\n"
"\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"
" -x/--proxy <proxyhost[:port]>\n"
" Use specified proxy. If the port number is not speci<63>\n"
@@ -575,7 +581,6 @@ puts (
"\n"
" FTP_PROXY [protocol://]<host>[:port]\n"
" Sets proxy server to use for FTP.\n"
"\n"
" GOPHER_PROXY [protocol://]<host>[:port]\n"
" Sets proxy server to use for GOPHER.\n"
"\n"
@@ -627,12 +632,12 @@ puts (
"\n"
" 12 FTP weird USER reply. Curl couldn't parse the reply\n"
" sent to the USER request.\n"
"\n"
" 13 FTP weird PASV reply, Curl couldn't parse the reply\n"
" sent to the PASV request.\n"
"\n"
" 14 FTP weird 227 formay. Curl couldn't parse the 227-line\n"
" the server sent.\n"
"\n"
" 15 FTP can't get host. Couldn't resolve the host IP we got\n"
" in the 227-line.\n"
"\n"
@@ -685,6 +690,7 @@ puts (
"\n"
" 34 HTTP post error. Internal post-request generation\n"
" error.\n"
"\n"
" 35 SSL connect error. The SSL handshaking failed.\n"
"\n"
" 36 FTP bad download resume. Couldn't continue an earlier\n"
@@ -743,13 +749,13 @@ puts (
" - Felix von Leitner <felix@convergence.de>\n"
" - Dan Zitter <dzitter@zitter.net>\n"
" - Jongki Suwandi <Jongki.Suwandi@eng.sun.com>\n"
);
puts(
" - Chris Maltby <chris@aurema.com>\n"
" - Ron Zapp <rzapper@yahoo.com>\n"
" - Paul Marquis <pmarquis@iname.com>\n"
" - Ellis Pritchard <ellis@citria.com>\n"
" - Damien Adant <dams@usa.net>\n"
);
puts(
" - Chris <cbayliss@csc.come>\n"
" - Marco G. Salvagno <mgs@whiz.cjb.net>\n"
" - Paul Marquis <pmarquis@iname.com>\n"
@@ -764,6 +770,7 @@ puts (
" - Stephen Kick <skick@epicrealm.com>\n"
" - Martin Hedenfalk <mhe@stacken.kth.se>\n"
" - Richard Prescott\n"
" - Jason S. Priebe <priebe@wral-tv.com>\n"
"\n"
"WWW\n"
" http://curl.haxx.se\n"
@@ -1057,14 +1064,14 @@ puts (
" being available or contain certain data.\n"
"\n"
" curl -e www.coolsite.com http://www.showme.com/\n"
);
puts(
"\n"
"USER AGENT\n"
"\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"
" line. It is especially useful to fool or trick stupid servers or CGI\n"
);
puts(
" scripts that only accept certain browsers.\n"
"\n"
" Example:\n"
@@ -1318,14 +1325,14 @@ puts (
"\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"
);
puts(
" SSL-version curl should use. Use -3 or -2 to specify that exact SSL version\n"
" to use:\n"
"\n"
" curl -2 https://secure.site.com/\n"
"\n"
" Otherwise, curl will first attempt to use v3 and then v2.\n"
);
puts(
"\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"

View File

@@ -48,6 +48,8 @@
#include <curl/curl.h>
#include <curl/types.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 "urlglob.h"
@@ -80,6 +82,16 @@
#include <fcntl.h>
#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 {
HTTPREQ_UNSPEC,
HTTPREQ_GET,
@@ -504,23 +516,26 @@ static int getparameter(char *flag, /* f or -long-flag */
if('-' == flag[0]) {
/* try a long name */
int fnam=strlen(&flag[1]);
int numhits=0;
for(j=0; j< sizeof(aliases)/sizeof(aliases[0]); j++) {
if(strnequal(aliases[j].lname, &flag[1], fnam)) {
longopt = TRUE;
numhits++;
if(strequal(aliases[j].lname, &flag[1])) {
parse = aliases[j].letter;
hit = j;
numhits = 1; /* a single unique hit */
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;
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) {
helpf("unknown option -%s.\n", flag);
return CURLE_FAILED_INIT;
@@ -1137,6 +1152,7 @@ void progressbarinit(struct ProgressData *bar)
int main(int argc, char *argv[])
{
char errorbuffer[CURL_ERROR_SIZE];
char useragent[128]; /* buah, we don't want a larger default user agent */
struct ProgressData progressbar;
struct OutStruct outs;
@@ -1161,11 +1177,13 @@ int main(int argc, char *argv[])
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));
/* set non-zero default values: */
config.useragent= maprintf(CURL_NAME "/" CURL_VERSION " (" OS ") "
"%s", curl_version());
config.showerror=TRUE;
config.conf=CONF_DEFAULT;
#if 0
@@ -1241,6 +1259,12 @@ int main(int argc, char *argv[])
helpf("no URL specified!\n");
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
fprintf(stderr, "URL: %s PROXY: %s\n", url, config.proxy?config.proxy:"none");
#endif
@@ -1512,7 +1536,6 @@ int main(int argc, char *argv[])
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, config.condtime);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, config.customrequest);
curl_easy_setopt(curl, CURLOPT_STDERR, config.errors);
curl_easy_setopt(curl, CURLOPT_WRITEINFO, config.writeout);
/* three new ones in libcurl 7.3: */
curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, config.proxytunnel);
@@ -1530,6 +1553,10 @@ int main(int argc, char *argv[])
res = curl_easy_perform(curl);
if(config.writeout) {
ourWriteOut(curl, config.writeout);
}
/* always cleanup */
curl_easy_cleanup(curl);
@@ -1571,6 +1598,9 @@ int main(int argc, char *argv[])
printf("--%s--\n", MIMEseparator);
#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.postquote); /* */
curl_slist_free_all(config.headers); /* */

View File

@@ -45,6 +45,10 @@
#include <curl/curl.h>
#include "urlglob.h"
#ifdef MALLOCDEBUG
#include "../lib/memdebug.h"
#endif
char glob_buffer[URL_MAX_LENGTH];
URLGlob *glob_expand;
@@ -218,6 +222,24 @@ int glob_url(URLGlob** glob, char* url, int *urlnum)
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)
{
static int beenhere = 0;

View File

@@ -1,3 +1,3 @@
#define CURL_NAME "curl"
#define CURL_VERSION "7.3"
#define CURL_VERSION "7.4.1"
#define CURL_ID CURL_NAME " " CURL_VERSION " (" OS ") "

View File

@@ -38,12 +38,14 @@
* ------------------------------------------------------------
****************************************************************************/
#include "setup.h"
#include <stdio.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"
typedef enum {
@@ -57,6 +59,8 @@ typedef enum {
VAR_SPEED_DOWNLOAD,
VAR_SPEED_UPLOAD,
VAR_HTTP_CODE,
VAR_HEADER_SIZE,
VAR_REQUEST_SIZE,
VAR_EFFECTIVE_URL,
VAR_NUM_OF_VARS /* must be the last */
} replaceid;
@@ -74,6 +78,8 @@ static struct variable replacements[]={
{"time_namelookup", VAR_NAMELOOKUP_TIME},
{"time_connect", VAR_CONNECT_TIME},
{"time_pretransfer", VAR_PRETRANSFER_TIME},
{"size_header", VAR_HEADER_SIZE},
{"size_request", VAR_REQUEST_SIZE},
{"size_download", VAR_SIZE_DOWNLOAD},
{"size_upload", VAR_SIZE_UPLOAD},
{"speed_download", VAR_SPEED_DOWNLOAD},
@@ -81,10 +87,14 @@ static struct variable replacements[]={
{NULL}
};
void WriteOut(struct UrlData *data)
void ourWriteOut(CURL *curl, char *writeinfo)
{
FILE *stream = stdout;
char *ptr=data->writeinfo;
char *ptr=writeinfo;
char *stringp;
long longinfo;
double doubleinfo;
while(*ptr) {
if('%' == *ptr) {
if('%' == ptr[1]) {
@@ -105,37 +115,65 @@ void WriteOut(struct UrlData *data)
if(strequal(ptr, replacements[i].name)) {
switch(replacements[i].id) {
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;
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;
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;
case VAR_NAMELOOKUP_TIME:
fprintf(stream, "%.3f", tvdiff(data->progress.t_nslookup,
data->progress.start));
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME,
&doubleinfo))
fprintf(stream, "%.3f", doubleinfo);
break;
case VAR_CONNECT_TIME:
fprintf(stream, "%.3f", tvdiff(data->progress.t_connect,
data->progress.start));
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &doubleinfo))
fprintf(stream, "%.3f", doubleinfo);
break;
case VAR_PRETRANSFER_TIME:
fprintf(stream, "%.3f", tvdiff(data->progress.t_pretransfer,
data->progress.start));
if(CURLE_OK ==
curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &doubleinfo))
fprintf(stream, "%.3f", doubleinfo);
break;
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;
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;
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;
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;

View File

@@ -40,8 +40,6 @@
* ------------------------------------------------------------
****************************************************************************/
#include "urldata.h"
void WriteOut(struct UrlData *data);
void ourWriteOut(CURL *curl, char *out);
#endif