curl tool: reviewed code moved to tool_*.[ch] files
authorYang Tse <yangsita@gmail.com>
Thu, 6 Oct 2011 15:39:00 +0000 (17:39 +0200)
committerYang Tse <yangsita@gmail.com>
Thu, 6 Oct 2011 15:39:00 +0000 (17:39 +0200)
26 files changed:
maketgz
packages/Symbian/group/curl.mmp
src/.gitignore
src/Makefile.inc
src/Makefile.vc6
src/curl.rc
src/tool_cb_dbg.c
src/tool_getparam.c
src/tool_getpass.c [moved from src/getpass.c with 84% similarity]
src/tool_getpass.h [moved from src/getpass.h with 87% similarity]
src/tool_homedir.c [moved from src/homedir.c with 93% similarity]
src/tool_homedir.h [moved from src/homedir.h with 90% similarity]
src/tool_operate.c
src/tool_operhlp.c
src/tool_paramhlp.c
src/tool_parsecfg.c
src/tool_util.c [moved from src/curlutil.c with 90% similarity]
src/tool_util.h [moved from src/curlutil.h with 69% similarity]
src/tool_version.h [moved from src/version.h with 100% similarity]
src/tool_writeenv.c [moved from src/writeenv.c with 98% similarity]
src/tool_writeenv.h [moved from src/writeenv.h with 84% similarity]
src/tool_writeout.c [moved from src/writeout.c with 96% similarity]
src/tool_writeout.h [moved from src/writeout.h with 90% similarity]
src/tool_xattr.c [moved from src/xattr.c with 85% similarity]
src/tool_xattr.h [moved from src/xattr.h with 91% similarity]
src/vc6curlsrc.dsp

diff --git a/maketgz b/maketgz
index 9cf95a1..9c639f9 100755 (executable)
--- a/maketgz
+++ b/maketgz
@@ -43,7 +43,7 @@ patch=`echo $libversion |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
 numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
 
 HEADER=include/curl/curlver.h
-CHEADER=src/version.h
+CHEADER=src/tool_version.h
 
 # requires a date command that knows -u for UTC time zone
 datestamp=`date -u`
index 22bb5c0..3c47db3 100644 (file)
@@ -8,8 +8,7 @@ UID           0x00000000 0xF0206442
 
 SOURCEPATH  ../../../src
 SOURCE \
-    hugehelp.c writeout.c writeenv.c \
-    getpass.c homedir.c curlutil.c xattr.c \
+    hugehelp.c \
     tool_binmode.c \
     tool_bname.c \
     tool_cb_dbg.c \
@@ -26,8 +25,10 @@ SOURCE \
     tool_easysrc.c \
     tool_formparse.c \
     tool_getparam.c \
+    tool_getpass.c \
     tool_help.c \
     tool_helpers.c \
+    tool_homedir.c \
     tool_libinfo.c \
     tool_main.c \
     tool_mfiles.c \
@@ -40,7 +41,11 @@ SOURCE \
     tool_setopt.c \
     tool_sleep.c \
     tool_urlglob.c \
-    tool_vms.c
+    tool_util.c \
+    tool_vms.c \
+    tool_writeenv.c \
+    tool_writeout.c \
+    tool_xattr.c
 
 SOURCEPATH  ../../../lib
 SOURCE \
index eca86f9..d99cc3f 100644 (file)
@@ -6,5 +6,6 @@ stamp-h2
 Makefile.vc8.dist
 Makefile.vc9.dist
 version.h.dist
+tool_version.h.dist
 Makefile.vc10.dist
 config-win32.h
index d2ee0e6..1660bc4 100644 (file)
@@ -14,8 +14,7 @@ CURLX_ONES = $(top_srcdir)/lib/strtoofft.c \
        $(top_srcdir)/lib/rawstr.c \
        $(top_srcdir)/lib/nonblock.c
 
-CURL_CFILES = hugehelp.c writeout.c writeenv.c \
-       getpass.c homedir.c curlutil.c xattr.c \
+CURL_CFILES = hugehelp.c \
        tool_binmode.c \
        tool_bname.c \
        tool_cb_dbg.c \
@@ -32,8 +31,10 @@ CURL_CFILES = hugehelp.c writeout.c writeenv.c \
        tool_easysrc.c \
        tool_formparse.c \
        tool_getparam.c \
+       tool_getpass.c \
        tool_help.c \
        tool_helpers.c \
+       tool_homedir.c \
        tool_libinfo.c \
        tool_main.c \
        tool_mfiles.c \
@@ -46,11 +47,14 @@ CURL_CFILES = hugehelp.c writeout.c writeenv.c \
        tool_setopt.c \
        tool_sleep.c \
        tool_urlglob.c \
-       tool_vms.c
+       tool_util.c \
+       tool_vms.c \
+       tool_writeenv.c \
+       tool_writeout.c \
+       tool_xattr.c
 
 CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
-       config-riscos.h version.h xattr.h \
-       writeout.h writeenv.h getpass.h homedir.h curlutil.h \
+       config-riscos.h \
        tool_binmode.h \
        tool_bname.h \
        tool_cb_dbg.h \
@@ -67,8 +71,10 @@ CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
        tool_easysrc.h \
        tool_formparse.h \
        tool_getparam.h \
+       tool_getpass.h \
        tool_help.h \
        tool_helpers.h \
+       tool_homedir.h \
        tool_libinfo.h \
        tool_main.h \
        tool_mfiles.h \
@@ -82,7 +88,12 @@ CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
        tool_setopt.h \
        tool_sleep.h \
        tool_urlglob.h \
-       tool_vms.h
+       tool_util.h \
+       tool_version.h \
+       tool_vms.h \
+       tool_writeenv.h \
+       tool_writeout.h \
+       tool_xattr.h
 
 curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)
 
index fe03afe..dbd32f1 100644 (file)
@@ -133,9 +133,6 @@ CFLAGS = $(CFLAGS) /DUSE_WINDOWS_SSPI /I$(WINDOWS_SDK_PATH)\include
 !ENDIF\r
 \r
 RELEASE_OBJS= \\r
-       curlutilr.obj \\r
-       getpassr.obj \\r
-       homedirr.obj \\r
        hugehelpr.obj \\r
        nonblockr.obj \\r
        rawstrr.obj \\r
@@ -156,8 +153,10 @@ RELEASE_OBJS= \
        tool_easysrcr.obj \\r
        tool_formparser.obj \\r
        tool_getparamr.obj \\r
+       tool_getpassr.obj \\r
        tool_helpr.obj \\r
        tool_helpersr.obj \\r
+       tool_homedirr.obj \\r
        tool_libinfor.obj \\r
        tool_mainr.obj \\r
        tool_mfilesr.obj \\r
@@ -170,15 +169,14 @@ RELEASE_OBJS= \
        tool_setoptr.obj \\r
        tool_sleepr.obj \\r
        tool_urlglobr.obj \\r
+       tool_utilr.obj \\r
        tool_vmsr.obj \\r
-       writeoutr.obj \\r
-       xattrr.obj \\r
+       tool_writeenvr.obj \\r
+       tool_writeoutr.obj \\r
+       tool_xattrr.obj \\r
        curlr.res\r
 \r
 DEBUG_OBJS= \\r
-       curlutild.obj \\r
-       getpassd.obj \\r
-       homedird.obj \\r
        hugehelpd.obj \\r
        nonblockd.obj \\r
        rawstrd.obj \\r
@@ -199,8 +197,10 @@ DEBUG_OBJS= \
        tool_easysrcd.obj \\r
        tool_formparsed.obj \\r
        tool_getparamd.obj \\r
+       tool_getpassd.obj \\r
        tool_helpd.obj \\r
        tool_helpersd.obj \\r
+       tool_homedird.obj \\r
        tool_libinfod.obj \\r
        tool_maind.obj \\r
        tool_mfilesd.obj \\r
@@ -213,9 +213,11 @@ DEBUG_OBJS= \
        tool_setoptd.obj \\r
        tool_sleepd.obj \\r
        tool_urlglobd.obj \\r
+       tool_utild.obj \\r
        tool_vmsd.obj \\r
-       writeoutd.obj \\r
-       xattrd.obj \\r
+       tool_writeenvd.obj \\r
+       tool_writeoutd.obj \\r
+       tool_xattrd.obj \\r
        curld.res\r
 \r
 #################################################\r
@@ -340,14 +342,6 @@ debug: $(DEBUG_OBJS)
 ## Release\r
 hugehelpr.obj: hugehelp.c\r
        $(CCR) $(CFLAGS) /Zm200 /Fo"$@" hugehelp.c\r
-writeoutr.obj: writeout.c\r
-       $(CCR) $(CFLAGS) /Fo"$@" writeout.c\r
-getpassr.obj: getpass.c\r
-       $(CCR) $(CFLAGS) /Fo"$@" getpass.c\r
-homedirr.obj: homedir.c\r
-       $(CCR) $(CFLAGS) /Fo"$@" homedir.c\r
-curlutilr.obj: curlutil.c\r
-       $(CCR) $(CFLAGS) /Fo"$@" curlutil.c\r
 nonblockr.obj: ../lib/nonblock.c\r
        $(CCR) $(CFLAGS) /Fo"$@" ../lib/nonblock.c\r
 rawstrr.obj: ../lib/rawstr.c\r
@@ -386,10 +380,14 @@ tool_formparser.obj: tool_formparse.c
        $(CCR) $(CFLAGS) /Fo"$@" tool_formparse.c\r
 tool_getparamr.obj: tool_getparam.c\r
        $(CCR) $(CFLAGS) /Fo"$@" tool_getparam.c\r
+tool_getpassr.obj: tool_getpass.c\r
+       $(CCR) $(CFLAGS) /Fo"$@" tool_getpass.c\r
 tool_helpr.obj: tool_help.c\r
        $(CCR) $(CFLAGS) /Fo"$@" tool_help.c\r
 tool_helpersr.obj: tool_helpers.c\r
        $(CCR) $(CFLAGS) /Fo"$@" tool_helpers.c\r
+tool_homedirr.obj: tool_homedir.c\r
+       $(CCR) $(CFLAGS) /Fo"$@" tool_homedir.c\r
 tool_libinfor.obj: tool_libinfo.c\r
        $(CCR) $(CFLAGS) /Fo"$@" tool_libinfo.c\r
 tool_mainr.obj: tool_main.c\r
@@ -414,24 +412,22 @@ tool_sleepr.obj: tool_sleep.c
        $(CCR) $(CFLAGS) /Fo"$@" tool_sleep.c\r
 tool_urlglobr.obj: tool_urlglob.c\r
        $(CCR) $(CFLAGS) /Fo"$@" tool_urlglob.c\r
+tool_utilr.obj: tool_util.c\r
+       $(CCR) $(CFLAGS) /Fo"$@" tool_util.c\r
 tool_vmsr.obj: tool_vms.c\r
        $(CCR) $(CFLAGS) /Fo"$@" tool_vms.c\r
-xattrr.obj: xattr.c\r
-       $(CCR) $(CFLAGS) /Fo"$@" xattr.c\r
+tool_writeenvr.obj: tool_writeenv.c\r
+       $(CCR) $(CFLAGS) /Fo"$@" tool_writeenv.c\r
+tool_writeoutr.obj: tool_writeout.c\r
+       $(CCR) $(CFLAGS) /Fo"$@" tool_writeout.c\r
+tool_xattrr.obj: tool_xattr.c\r
+       $(CCR) $(CFLAGS) /Fo"$@" tool_xattr.c\r
 curlr.res : curl.rc\r
        $(RCR) $(RESFLAGS) /Fo"$@" curl.rc\r
 \r
 ## Debug\r
 hugehelpd.obj: hugehelp.c\r
        $(CCD) $(CFLAGS) /Zm200 /Fo"$@" hugehelp.c\r
-writeoutd.obj: writeout.c\r
-       $(CCD) $(CFLAGS) /Fo"$@" writeout.c\r
-getpassd.obj: getpass.c\r
-       $(CCD) $(CFLAGS) /Fo"$@" getpass.c\r
-homedird.obj: homedir.c\r
-       $(CCD) $(CFLAGS) /Fo"$@" homedir.c\r
-curlutild.obj: curlutil.c\r
-       $(CCD) $(CFLAGS) /Fo"$@" curlutil.c\r
 nonblockd.obj: ../lib/nonblock.c\r
        $(CCD) $(CFLAGS) /Fo"$@" ../lib/nonblock.c\r
 rawstrd.obj: ../lib/rawstr.c\r
@@ -470,10 +466,14 @@ tool_formparsed.obj: tool_formparse.c
        $(CCD) $(CFLAGS) /Fo"$@" tool_formparse.c\r
 tool_getparamd.obj: tool_getparam.c\r
        $(CCD) $(CFLAGS) /Fo"$@" tool_getparam.c\r
+tool_getpassd.obj: tool_getpass.c\r
+       $(CCD) $(CFLAGS) /Fo"$@" tool_getpass.c\r
 tool_helpd.obj: tool_help.c\r
        $(CCD) $(CFLAGS) /Fo"$@" tool_help.c\r
 tool_helpersd.obj: tool_helpers.c\r
        $(CCD) $(CFLAGS) /Fo"$@" tool_helpers.c\r
+tool_homedird.obj: tool_homedir.c\r
+       $(CCD) $(CFLAGS) /Fo"$@" tool_homedir.c\r
 tool_libinfod.obj: tool_libinfo.c\r
        $(CCD) $(CFLAGS) /Fo"$@" tool_libinfo.c\r
 tool_maind.obj: tool_main.c\r
@@ -498,10 +498,16 @@ tool_sleepd.obj: tool_sleep.c
        $(CCD) $(CFLAGS) /Fo"$@" tool_sleep.c\r
 tool_urlglobd.obj: tool_urlglob.c\r
        $(CCD) $(CFLAGS) /Fo"$@" tool_urlglob.c\r
+tool_utild.obj: tool_util.c\r
+       $(CCD) $(CFLAGS) /Fo"$@" tool_util.c\r
 tool_vmsd.obj: tool_vms.c\r
        $(CCD) $(CFLAGS) /Fo"$@" tool_vms.c\r
-xattrd.obj: xattr.c\r
-       $(CCD) $(CFLAGS) /Fo"$@" xattr.c\r
+tool_writeenvd.obj: tool_writeenv.c\r
+       $(CCD) $(CFLAGS) /Fo"$@" tool_writeenv.c\r
+tool_writeoutd.obj: tool_writeout.c\r
+       $(CCD) $(CFLAGS) /Fo"$@" tool_writeout.c\r
+tool_xattrd.obj: tool_xattr.c\r
+       $(CCD) $(CFLAGS) /Fo"$@" tool_xattr.c\r
 curld.res : curl.rc\r
        $(RCD) $(RESFLAGS) /Fo"$@" curl.rc\r
 \r
index 58e439d..3db59bd 100644 (file)
@@ -20,7 +20,7 @@
  *
  ***************************************************************************/
 #include <winver.h>
-#include "version.h"
+#include "tool_version.h"
 
 LANGUAGE  0x09,0x01
 
index 7b20a0c..7ac9a73 100644 (file)
 /* use our own printf() functions */
 #include "curlx.h"
 
-#include "curlutil.h"
-
 #include "tool_cfgable.h"
 #include "tool_msgs.h"
 #include "tool_cb_dbg.h"
+#include "tool_util.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
@@ -60,7 +59,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
   (void)handle; /* not used */
 
   if(config->tracetime) {
-    tv = cutil_tvnow();
+    tv = tvnow();
     if(!known_offset) {
       epoch_offset = time(NULL) - tv.tv_sec;
       known_offset = 1;
index f18c916..bb36b42 100644 (file)
@@ -33,8 +33,6 @@
 #  include "hugehelp.h"
 #endif
 
-#include "version.h"
-
 #include "tool_binmode.h"
 #include "tool_cfgable.h"
 #include "tool_cb_prg.h"
@@ -46,6 +44,7 @@
 #include "tool_msgs.h"
 #include "tool_paramhlp.h"
 #include "tool_parsecfg.h"
+#include "tool_version.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
similarity index 84%
rename from src/getpass.c
rename to src/tool_getpass.c
index a154d10..b6aa5dd 100644 (file)
 /* this file is only for systems without getpass_r() */
 
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#  include <unistd.h>
 #endif
 
 #ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+#  include <fcntl.h>
 #endif
+
 #ifdef HAVE_TERMIOS_H
-#include <termios.h>
-#else
-#ifdef HAVE_TERMIO_H
-#include <termio.h>
-#endif
+#  include <termios.h>
+#elif defined(HAVE_TERMIO_H)
+#  include <termio.h>
 #endif
 
 #ifdef __VMS
 #  endif
 #endif
 
-#include "getpass.h"
+#define _MPRINTF_REPLACE
+#include <curl/mprintf.h>
+
+#include "tool_getpass.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
@@ -80,15 +82,15 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
 
   $DESCRIPTOR(ttdesc, "TT");
 
-  buffer[0]='\0';
-  sts = sys$assign(&ttdesc, &chan,0,0);
+  buffer[0] = '\0';
+  sts = sys$assign(&ttdesc, &chan, 0, 0);
   if(sts & 1) {
     sts = sys$qiow(0, chan,
                    IO$_READPROMPT | IO$M_NOECHO,
                    &iosb, 0, 0, buffer, buflen, 0, 0,
                    prompt, strlen(prompt));
 
-    if((sts & 1) && (iosb.iosb$w_status&1))
+    if((sts & 1) && (iosb.iosb$w_status & 1))
       buffer[iosb.iosb$w_bcnt] = '\0';
 
     sts = sys$dassgn(chan);
@@ -99,7 +101,7 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
 #endif /* __VMS */
 
 #ifdef __SYMBIAN32__
-#define getch() getchar()
+#  define getch() getchar()
 #endif
 
 #if defined(WIN32) || defined(__SYMBIAN32__)
@@ -109,25 +111,25 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
   size_t i;
   fputs(prompt, stderr);
 
-  for(i=0; i<buflen; i++) {
+  for(i = 0; i < buflen; i++) {
     buffer[i] = (char)getch();
     if(buffer[i] == '\r' || buffer[i] == '\n') {
-      buffer[i] = 0;
+      buffer[i] = '\0';
       break;
     }
     else
       if(buffer[i] == '\b')
         /* remove this letter and if this is not the first key, remove the
            previous one as well */
-        i = i - (i>=1?2:1);
+        i = i - (i >= 1) ? 2 : 1;
   }
 #ifndef __SYMBIAN32__
   /* since echo is disabled, print a newline */
   fputs("\n", stderr);
 #endif
   /* if user didn't hit ENTER, terminate buffer */
-  if(i==buflen)
-    buffer[buflen-1]=0;
+  if(i == buflen)
+    buffer[buflen-1] = '\0';
 
   return buffer; /* we always return success */
 }
@@ -165,7 +167,7 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
       putchar('*');
 
   } while((buffer[i-1] != 13) && (i < buflen));
-  buffer[i-1] = 0;
+  buffer[i-1] = '\0';
   printf("\r\n");
   return buffer;
 }
@@ -176,13 +178,11 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
 #ifndef DONE /* not previously provided */
 
 #ifdef HAVE_TERMIOS_H
-#define struct_term struct termios
-#else
-#ifdef HAVE_TERMIO_H
-#define struct_term  struct termio
+#  define struct_term  struct termios
+#elif defined(HAVE_TERMIO_H)
+#  define struct_term  struct termio
 #else
-#undef struct_term
-#endif
+#  undef  struct_term
 #endif
 
 static bool ttyecho(bool enable, int fd)
@@ -199,18 +199,16 @@ static bool ttyecho(bool enable, int fd)
     noecho = withecho;
     noecho.c_lflag &= ~ECHO;
     tcsetattr(fd, TCSANOW, &noecho);
-#else /* HAVE_TERMIOS_H */
-#ifdef HAVE_TERMIO_H
+#elif defined(HAVE_TERMIO_H)
     ioctl(fd, TCGETA, &withecho);
     noecho = withecho;
     noecho.c_lflag &= ~ECHO;
     ioctl(fd, TCSETA, &noecho);
-#else /* HAVE_TERMIO_H */
-/* neither HAVE_TERMIO_H nor HAVE_TERMIOS_H, we can't disable echo! */
-    (void)fd; /* prevent compiler warning on unused variable */
+#else
+    /* neither HAVE_TERMIO_H nor HAVE_TERMIOS_H, we can't disable echo! */
+    (void)fd;
     return FALSE; /* not disabled */
 #endif
-#endif
     return TRUE; /* disabled */
   }
   else {
@@ -218,14 +216,11 @@ static bool ttyecho(bool enable, int fd)
        now use to reset the terminal status) */
 #ifdef HAVE_TERMIOS_H
     tcsetattr(fd, TCSAFLUSH, &withecho);
-#else /* HAVE_TERMIOS_H */
-#ifdef HAVE_TERMIO_H
+#elif defined(HAVE_TERMIO_H)
     ioctl(fd, TCSETA, &withecho);
 #else
-/* neither HAVE_TERMIO_H nor HAVE_TERMIOS_H */
     return FALSE; /* not enabled */
 #endif
-#endif
     return TRUE; /* enabled */
   }
 }
@@ -236,18 +231,18 @@ char *getpass_r(const char *prompt, /* prompt to display */
 {
   ssize_t nread;
   bool disabled;
-  int fd=open("/dev/tty", O_RDONLY);
+  int fd = open("/dev/tty", O_RDONLY);
   if(-1 == fd)
     fd = 1; /* use stdin if the tty couldn't be used */
 
   disabled = ttyecho(FALSE, fd); /* disable terminal echo */
 
   fputs(prompt, stderr);
-  nread=read(fd, password, buflen);
+  nread = read(fd, password, buflen);
   if(nread > 0)
-    password[--nread]=0; /* zero terminate where enter is stored */
+    password[--nread] = '\0'; /* zero terminate where enter is stored */
   else
-    password[0]=0; /* got nothing */
+    password[0] = '\0'; /* got nothing */
 
   if(disabled) {
     /* if echo actually was disabled, add a newline */
similarity index 87%
rename from src/getpass.h
rename to src/tool_getpass.h
index 7d714fc..506d0fe 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_GETPASS_H
-#define HEADER_CURL_GETPASS_H
+#ifndef HEADER_CURL_TOOL_GETPASS_H
+#define HEADER_CURL_TOOL_GETPASS_H
 /***************************************************************************
  *                                  _   _ ____  _
  *  Project                     ___| | | |  _ \| |
@@ -30,7 +30,7 @@
 /*
  * Returning NULL will abort the continued operation!
  */
-char* getpass_r(const char *prompt, char* buffer, size_t buflen );
+char* getpass_r(const char *prompt, char* buffer, size_t buflen);
 #endif
 
-#endif /* HEADER_CURL_GETPASS_H */
+#endif /* HEADER_CURL_TOOL_GETPASS_H */
similarity index 93%
rename from src/homedir.c
rename to src/tool_homedir.c
index 80ffe07..95d25c7 100644 (file)
 #include "setup.h"
 
 #ifdef HAVE_PWD_H
-#include <pwd.h>
+#  include <pwd.h>
 #endif
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#  include <unistd.h>
 #endif
 #ifdef __VMS
-#include <unixlib.h>
+#  include <unixlib.h>
 #endif
 
-#include "homedir.h"
+#include "tool_homedir.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
-static
-char *GetEnv(const char *variable, char do_expand)
+static char *GetEnv(const char *variable, char do_expand)
 {
   char *env = NULL;
 #ifdef WIN32
@@ -70,7 +69,7 @@ char *GetEnv(const char *variable, char do_expand)
   env = getenv(variable);
 #endif
 #endif
-  return (env && env[0])?strdup(env):NULL;
+  return (env && env[0]) ? strdup(env) : NULL;
 }
 
 /* return the home directory of the current user as an allocated string */
similarity index 90%
rename from src/homedir.h
rename to src/tool_homedir.h
index 252fd0e..109c1f2 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_HOMEDIR_H
-#define HEADER_CURL_HOMEDIR_H
+#ifndef HEADER_CURL_TOOL_HOMEDIR_H
+#define HEADER_CURL_TOOL_HOMEDIR_H
 /***************************************************************************
  *                                  _   _ ____  _
  *  Project                     ___| | | |  _ \| |
@@ -25,4 +25,4 @@
 
 char *homedir(void);
 
-#endif /* HEADER_CURL_HOMEDIR_H */
+#endif /* HEADER_CURL_TOOL_HOMEDIR_H */
index 9a06098..3ee1d10 100644 (file)
 /* use our own printf() functions */
 #include "curlx.h"
 
-#include "curlutil.h"
-#include "homedir.h"
-#include "writeout.h"
-#include "xattr.h"
-
-#ifdef USE_ENVIRONMENT
-#  include "writeenv.h"
-#endif
-
 #include "tool_binmode.h"
 #include "tool_cfgable.h"
 #include "tool_cb_dbg.h"
@@ -70,6 +61,7 @@
 #include "tool_easysrc.h"
 #include "tool_getparam.h"
 #include "tool_helpers.h"
+#include "tool_homedir.h"
 #include "tool_libinfo.h"
 #include "tool_main.h"
 #include "tool_msgs.h"
 #include "tool_setopt.h"
 #include "tool_sleep.h"
 #include "tool_urlglob.h"
+#include "tool_util.h"
+#include "tool_writeenv.h"
+#include "tool_writeout.h"
+#include "tool_xattr.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
@@ -1210,7 +1206,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
 
         retry_numretries = config->req_retry;
         retry_sleep = retry_sleep_default; /* ms */
-        retrystart = cutil_tvnow();
+        retrystart = tvnow();
 
         for(;;) {
           res = curl_easy_perform(curl);
@@ -1227,7 +1223,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
              time */
           if(retry_numretries &&
              (!config->retry_maxtime ||
-              (cutil_tvdiff(cutil_tvnow(), retrystart)<
+              (tvdiff(tvnow(), retrystart) <
                config->retry_maxtime*1000L)) ) {
             enum {
               RETRY_NO,
@@ -1349,10 +1345,9 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
 
         if(config->writeout)
           ourWriteOut(curl, config->writeout);
-#ifdef USE_ENVIRONMENT
+
         if(config->writeenv)
           ourWriteEnv(curl);
-#endif
 
         /*
         ** Code within this loop may jump directly here to label 'show_error'
index d7dbe13..808d2d5 100644 (file)
 /* use our own printf() functions */
 #include "curlx.h"
 
-#include "version.h"
-
 #include "tool_cfgable.h"
 #include "tool_convert.h"
 #include "tool_operhlp.h"
+#include "tool_version.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
index 97681c1..adb12ce 100644 (file)
 /* use our own printf() functions */
 #include "curlx.h"
 
-#include "homedir.h"
-#include "getpass.h"
-
 #include "tool_cfgable.h"
 #include "tool_getparam.h"
+#include "tool_getpass.h"
+#include "tool_homedir.h"
 #include "tool_msgs.h"
 #include "tool_paramhlp.h"
 
index 44d077e..b60d318 100644 (file)
 /* use our own printf() functions */
 #include "curlx.h"
 
-#include "homedir.h"
-
 #include "tool_cfgable.h"
 #include "tool_getparam.h"
 #include "tool_helpers.h"
+#include "tool_homedir.h"
 #include "tool_msgs.h"
 #include "tool_parsecfg.h"
 
similarity index 90%
rename from src/curlutil.c
rename to src/tool_util.c
index a524b65..79c9982 100644 (file)
  ***************************************************************************/
 #include "setup.h"
 
-#include "curlutil.h"
+#include "tool_util.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
 #if defined(WIN32) && !defined(MSDOS)
 
-struct timeval cutil_tvnow(void)
+struct timeval tool_tvnow(void)
 {
   /*
   ** GetTickCount() is available on _all_ Windows versions from W95 up
@@ -43,7 +43,7 @@ struct timeval cutil_tvnow(void)
 
 #elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
 
-struct timeval cutil_tvnow(void)
+struct timeval tool_tvnow(void)
 {
   /*
   ** clock_gettime() is granted to be increased monotonically when the
@@ -77,7 +77,7 @@ struct timeval cutil_tvnow(void)
 
 #elif defined(HAVE_GETTIMEOFDAY)
 
-struct timeval cutil_tvnow(void)
+struct timeval tool_tvnow(void)
 {
   /*
   ** gettimeofday() is not granted to be increased monotonically, due to
@@ -91,7 +91,7 @@ struct timeval cutil_tvnow(void)
 
 #else
 
-struct timeval cutil_tvnow(void)
+struct timeval tool_tvnow(void)
 {
   /*
   ** time() returns the value of time in seconds since the Epoch.
@@ -110,25 +110,25 @@ struct timeval cutil_tvnow(void)
  *
  * Returns: the time difference in number of milliseconds.
  */
-long cutil_tvdiff(struct timeval newer, struct timeval older)
+long tool_tvdiff(struct timeval newer, struct timeval older)
 {
   return (newer.tv_sec-older.tv_sec)*1000+
     (newer.tv_usec-older.tv_usec)/1000;
 }
 
 /*
- * Same as cutil_tvdiff but with full usec resolution.
+ * Same as tool_tvdiff but with full usec resolution.
  *
  * Returns: the time difference in seconds with subsecond resolution.
  */
-double cutil_tvdiff_secs(struct timeval newer, struct timeval older)
+double tool_tvdiff_secs(struct timeval newer, struct timeval older)
 {
   return (double)(newer.tv_sec-older.tv_sec)+
     (double)(newer.tv_usec-older.tv_usec)/1000000.0;
 }
 
 /* return the number of seconds in the given input timeval struct */
-long cutil_tvlong(struct timeval t1)
+long tool_tvlong(struct timeval t1)
 {
   return t1.tv_sec;
 }
similarity index 69%
rename from src/curlutil.h
rename to src/tool_util.h
index e0d9cb1..7c2a297 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_SRC_UTIL_H
-#define HEADER_CURL_SRC_UTIL_H
+#ifndef HEADER_CURL_TOOL_UTIL_H
+#define HEADER_CURL_TOOL_UTIL_H
 /***************************************************************************
  *                                  _   _ ____  _
  *  Project                     ___| | | |  _ \| |
@@ -23,8 +23,7 @@
  ***************************************************************************/
 #include "setup.h"
 
-
-struct timeval cutil_tvnow(void);
+struct timeval tool_tvnow(void);
 
 /*
  * Make sure that the first argument (t1) is the more recent time and t2 is
@@ -32,17 +31,26 @@ struct timeval cutil_tvnow(void);
  *
  * Returns: the time difference in number of milliseconds.
  */
-long cutil_tvdiff(struct timeval t1, struct timeval t2);
+long tool_tvdiff(struct timeval t1, struct timeval t2);
 
 /*
- * Same as cutil_tvdiff but with full usec resolution.
+ * Same as tool_tvdiff but with full usec resolution.
  *
  * Returns: the time difference in seconds with subsecond resolution.
  */
-double cutil_tvdiff_secs(struct timeval t1, struct timeval t2);
+double tool_tvdiff_secs(struct timeval t1, struct timeval t2);
+
+long tool_tvlong(struct timeval t1);
 
-long cutil_tvlong(struct timeval t1);
+#undef tvnow
+#undef tvdiff
+#undef tvdiff_secs
+#undef tvlong
 
+#define tvnow()           tool_tvnow()
+#define tvdiff(a,b)       tool_tvdiff((a), (b))
+#define tvdiff_secs(a,b)  tool_tvdiff_secs((a), (b))
+#define tvlong(a)         tool_tvlong((a))
 
-#endif  /* HEADER_CURL_SRC_UTIL_H */
+#endif /* HEADER_CURL_TOOL_UTIL_H */
 
similarity index 100%
rename from src/version.h
rename to src/tool_version.h
similarity index 98%
rename from src/writeenv.c
rename to src/tool_writeenv.c
index b509449..232ab69 100644 (file)
@@ -24,7 +24,7 @@
 #ifdef USE_ENVIRONMENT
 
 #ifdef __riscos__
-#include <kernel.h>
+#  include <kernel.h>
 #endif
 
 #include <curl/curl.h>
@@ -32,7 +32,7 @@
 #define _MPRINTF_REPLACE /* use our functions only */
 #include <curl/mprintf.h>
 
-#include "writeenv.h"
+#include "tool_writeenv.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
similarity index 84%
rename from src/writeenv.h
rename to src/tool_writeenv.h
index 0816c34..74fdc97 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_WRITEENV_H
-#define HEADER_CURL_WRITEENV_H
+#ifndef HEADER_CURL_TOOL_WRITEENV_H
+#define HEADER_CURL_TOOL_WRITEENV_H
 /***************************************************************************
  *                                  _   _ ____  _
  *  Project                     ___| | | |  _ \| |
  ***************************************************************************/
 #include "setup.h"
 
+#ifdef USE_ENVIRONMENT
+
 void ourWriteEnv(CURL *curl);
 
-#endif /* HEADER_CURL_WRITEENV_H */
+#else
+#  define ourWriteEnv(x)  Curl_nop_stmt
+#endif
+
+#endif /* HEADER_CURL_TOOL_WRITEENV_H */
+
similarity index 96%
rename from src/writeout.c
rename to src/tool_writeout.c
index 7e41050..1ea1c98 100644 (file)
  ***************************************************************************/
 #include "setup.h"
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
 #include <curl/curl.h>
 
 #define _MPRINTF_REPLACE /* we want curl-functions instead of native ones */
 #include <curl/mprintf.h>
 
-#include "writeout.h"
+#include "tool_writeout.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
@@ -100,7 +93,7 @@ static const struct variable replacements[]={
 void ourWriteOut(CURL *curl, const char *writeinfo)
 {
   FILE *stream = stdout;
-  const char *ptr=writeinfo;
+  const char *ptr = writeinfo;
   char *stringp;
   long longinfo;
   double doubleinfo;
@@ -110,7 +103,7 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
       if('%' == ptr[1]) {
         /* an escaped %-letter */
         fputc('%', stream);
-        ptr+=2;
+        ptr += 2;
       }
       else {
         /* this is meant as a variable to output */
@@ -119,10 +112,10 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
         int i;
         if(('{' == ptr[1]) && ((end = strchr(ptr, '}')) != NULL)) {
           bool match = FALSE;
-          ptr+=2; /* pass the % and the { */
-          keepit=*end;
-          *end=0; /* zero terminate */
-          for(i=0; replacements[i].name; i++) {
+          ptr += 2; /* pass the % and the { */
+          keepit = *end;
+          *end = 0; /* zero terminate */
+          for(i = 0; replacements[i].name; i++) {
             if(curl_strequal(ptr, replacements[i].name)) {
               match = TRUE;
               switch(replacements[i].id) {
@@ -258,14 +251,14 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
           if(!match) {
             fprintf(stderr, "curl: unknown --write-out variable: '%s'\n", ptr);
           }
-          ptr=end+1; /* pass the end */
+          ptr = end + 1; /* pass the end */
           *end = keepit;
         }
         else {
           /* illegal syntax, then just output the characters that are used */
           fputc('%', stream);
           fputc(ptr[1], stream);
-          ptr+=2;
+          ptr += 2;
         }
       }
     }
@@ -286,7 +279,7 @@ void ourWriteOut(CURL *curl, const char *writeinfo)
         fputc(ptr[1], stream);
         break;
       }
-      ptr+=2;
+      ptr += 2;
     }
     else {
       fputc(*ptr, stream);
similarity index 90%
rename from src/writeout.h
rename to src/tool_writeout.h
index 92d8ea5..815cfcf 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_WRITEOUT_H
-#define HEADER_CURL_WRITEOUT_H
+#ifndef HEADER_CURL_TOOL_WRITEOUT_H
+#define HEADER_CURL_TOOL_WRITEOUT_H
 /***************************************************************************
  *                                  _   _ ____  _
  *  Project                     ___| | | |  _ \| |
@@ -25,4 +25,4 @@
 
 void ourWriteOut(CURL *curl, const char *out);
 
-#endif /* HEADER_CURL_WRITEOUT_H */
+#endif /* HEADER_CURL_TOOL_WRITEOUT_H */
similarity index 85%
rename from src/xattr.c
rename to src/tool_xattr.c
index 146acf9..1f3883f 100644 (file)
 #include "setup.h"
 
 #ifdef HAVE_FSETXATTR
-#include <sys/types.h>
-#include <sys/xattr.h> /* include header from libc, not from libattr */
+#  include <sys/xattr.h> /* header from libc, not from libattr */
 #endif
 
 #include <curl/curl.h>
-#include "xattr.h"
+
+#include "tool_xattr.h"
 
 #include "memdebug.h" /* keep this as LAST include */
 
@@ -42,8 +42,8 @@ static const struct xattr_mapping {
    * http://freedesktop.org/wiki/CommonExtendedAttributes
    */
   { "user.xdg.origin.url", CURLINFO_EFFECTIVE_URL },
-  { "user.mime_type", CURLINFO_CONTENT_TYPE },
-  { NULL, CURLINFO_NONE } /* last element, abort loop here */
+  { "user.mime_type",      CURLINFO_CONTENT_TYPE },
+  { NULL,                  CURLINFO_NONE } /* last element, abort loop here */
 };
 
 /* store metadata from the curl request alongside the downloaded
@@ -59,9 +59,9 @@ int fwrite_xattr(CURL *curl, int fd)
     CURLcode rc = curl_easy_getinfo(curl, mappings[i].info, &value);
     if(rc == CURLE_OK && value) {
 #ifdef HAVE_FSETXATTR_6
-      err = fsetxattr( fd, mappings[i].attr, value, strlen(value), 0, 0 );
+      err = fsetxattr(fd, mappings[i].attr, value, strlen(value), 0, 0);
 #elif defined(HAVE_FSETXATTR_5)
-      err = fsetxattr( fd, mappings[i].attr, value, strlen(value), 0 );
+      err = fsetxattr(fd, mappings[i].attr, value, strlen(value), 0);
 #endif
     }
     i++;
similarity index 91%
rename from src/xattr.h
rename to src/tool_xattr.h
index ef528ea..14c8c94 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_XATTR_H
-#define HEADER_CURL_XATTR_H
+#ifndef HEADER_CURL_TOOL_XATTR_H
+#define HEADER_CURL_TOOL_XATTR_H
 /***************************************************************************
  *                                  _   _ ____  _
  *  Project                     ___| | | |  _ \| |
@@ -25,4 +25,4 @@
 
 int fwrite_xattr(CURL *curl, int fd);
 
-#endif /* HEADER_CURL_XATTR_H */
+#endif /* HEADER_CURL_TOOL_XATTR_H */
index d2f6a2f..4711703 100644 (file)
@@ -139,18 +139,6 @@ LINK32=link.exe
 # PROP Default_Filter ""\r
 # Begin Source File\r
 \r
-SOURCE=.\curlutil.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\getpass.c\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\homedir.c\r
-# End Source File\r
-# Begin Source File\r
-\r
 SOURCE=.\hugehelp.c\r
 # End Source File\r
 # Begin Source File\r
@@ -231,6 +219,10 @@ SOURCE=.\tool_getparam.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\tool_getpass.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\tool_help.c\r
 # End Source File\r
 # Begin Source File\r
@@ -239,6 +231,10 @@ SOURCE=.\tool_helpers.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\tool_homedir.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\tool_libinfo.c\r
 # End Source File\r
 # Begin Source File\r
@@ -287,19 +283,23 @@ SOURCE=.\tool_urlglob.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\tool_util.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\tool_vms.c\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\writeenv.c\r
+SOURCE=.\tool_writeenv.c\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\writeout.c\r
+SOURCE=.\tool_writeout.c\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\xattr.c\r
+SOURCE=.\tool_xattr.c\r
 # End Source File\r
 # End Group\r
 # Begin Group "Header Files"\r
@@ -311,18 +311,6 @@ SOURCE=".\config-win32.h"
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\curlutil.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\getpass.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\homedir.h\r
-# End Source File\r
-# Begin Source File\r
-\r
 SOURCE=.\hugehelp.h\r
 # End Source File\r
 # Begin Source File\r
@@ -407,6 +395,10 @@ SOURCE=.\tool_getparam.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\tool_getpass.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\tool_help.h\r
 # End Source File\r
 # Begin Source File\r
@@ -415,6 +407,10 @@ SOURCE=.\tool_helpers.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\tool_homedir.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\tool_libinfo.h\r
 # End Source File\r
 # Begin Source File\r
@@ -467,23 +463,27 @@ SOURCE=.\tool_urlglob.h
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\tool_vms.h\r
+SOURCE=.\tool_util.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\version.h\r
+SOURCE=.\tool_version.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\tool_vms.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\writeenv.h\r
+SOURCE=.\tool_writeenv.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\writeout.h\r
+SOURCE=.\tool_writeout.h\r
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\xattr.h\r
+SOURCE=.\tool_xattr.h\r
 # End Source File\r
 # End Group\r
 # Begin Group "Resource Files"\r