curl tool was using functions curlx_tvnow and curlx_tvdiff which are not

part of the official libcurl API http://curl.haxx.se/lxr/source/lib/README.curlx
The documented way of using them would be to use timeval.c as a source code file.

The above described method works very well when statically linking libcurl and
apps, curl tool, but has several drawbacks when you build a true shared
libcurl (i.e. Name space clash at linkage stage as functions are defined more
than once. Windows makefiles are not capable of handling this system of
source-level sharing)

So...

Now curlutil.h and curlutil.c define and implement cutil_tvnow and cutil_tvdiff
which replace curlx_tvnow and curlx_tvdiff for the curl tool. Doing this we
avoid the above described problems.
This commit is contained in:
Yang Tse 2007-02-20 12:13:14 +00:00
parent 29bb6f65f1
commit e268e8559e
9 changed files with 194 additions and 38 deletions

View file

@ -37,6 +37,7 @@
#include "writeout.h"
#include "getpass.h"
#include "homedir.h"
#include "curlutil.h"
#ifdef USE_MANUAL
#include "hugehelp.h"
#endif
@ -50,19 +51,6 @@
#include <screen.h>
#endif
#ifdef TIME_WITH_SYS_TIME
/* We can include both fine */
#include <sys/time.h>
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#else
# include <time.h>
#endif
#endif
#include "version.h"
#ifdef HAVE_IO_H /* typical win32 habit */
@ -3028,7 +3016,7 @@ int my_trace(CURL *handle, curl_infotype type,
(void)handle; /* prevent compiler warning */
tv = curlx_tvnow();
tv = cutil_tvnow();
secs = tv.tv_sec;
now = localtime(&secs); /* not multithread safe but we don't care */
if(config->tracetime)
@ -3502,8 +3490,8 @@ operate(struct Configurable *config, int argc, char *argv[])
config->conf=CONF_DEFAULT;
config->use_httpget=FALSE;
config->create_dirs=FALSE;
config->lastrecvtime = curlx_tvnow();
config->lastsendtime = curlx_tvnow();
config->lastrecvtime = cutil_tvnow();
config->lastsendtime = cutil_tvnow();
config->maxredirs = DEFAULT_MAXREDIRS;
if(argc>1 &&
@ -4265,7 +4253,7 @@ operate(struct Configurable *config, int argc, char *argv[])
retry_numretries = config->req_retry;
retrystart = curlx_tvnow();
retrystart = cutil_tvnow();
do {
res = curl_easy_perform(curl);
@ -4276,7 +4264,7 @@ operate(struct Configurable *config, int argc, char *argv[])
time */
if(retry_numretries &&
(!config->retry_maxtime ||
(curlx_tvdiff(curlx_tvnow(), retrystart)<
(cutil_tvdiff(cutil_tvnow(), retrystart)<
config->retry_maxtime*1000)) ) {
enum {
RETRY_NO,