Fix transfer summary
[reactos.git] / reactos / apps / utils / net / ftp / ftp.c
index 1fa0f0d..640e1af 100644 (file)
@@ -25,7 +25,7 @@ static char sccsid[] = "@(#)ftp.c     5.28 (Berkeley) 4/20/89";
 
 #include <sys/stat.h>
 
-#if !defined(WIN32)
+#ifndef _WIN32
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/time.h>
@@ -98,9 +98,9 @@ sig_t lostpeer();
 off_t  restart_point = 0;
 
 SOCKET cin, cout;
-int    dataconn(char *mode);
+int    dataconn(const char *mode);
 
-int command(char *fmt, ...);
+int command(const char *fmt, ...);
 
 char *hostname;
 
@@ -203,19 +203,23 @@ bad:
        return ((char *)0);
 }
 
-int login(char *host)
+int login(const char *host)
 {
        char tmp[80];
-       char *user, *pass, *acct;
+       char *puser, *ppass, *pacct;
+       const char *user, *pass, *acct;
        int n, aflag = 0;
 
        user = pass = acct = 0;
-       if (ruserpass(host, &user, &pass, &acct) < 0) {
+       if (ruserpass(host, &puser, &ppass, &pacct) < 0) {
                code = -1;
                return(0);
        }
+       user = puser;
+       pass = ppass;
+       acct = pacct;
        while (user == NULL) {
-           char *myname = "none"; // This needs to become the usename env
+           const char *myname = "none"; // This needs to become the usename env
 
            if (myname)
               printf("Name (%s:%s): ", host, myname);
@@ -260,7 +264,7 @@ int login(char *host)
        return (1);
 }
 
-void
+static void
 cmdabort(int sig)
 {
        extern jmp_buf ptabort;
@@ -273,7 +277,7 @@ cmdabort(int sig)
 }
 
 /*VARARGS1*/
-int command(char *fmt, ...)
+int command(const char *fmt, ...)
 {
        va_list ap;
        int r;
@@ -422,7 +426,7 @@ getreply(expecteof)
        }
 }
 
-int
+static int
 empty(mask, sec)
        struct fd_set *mask;
        int sec;
@@ -436,6 +440,7 @@ empty(mask, sec)
 
 jmp_buf        sendabort;
 
+#if 0
 void abortsend()
 {
 
@@ -445,22 +450,22 @@ void abortsend()
        (void) fflush(stdout);
        longjmp(sendabort, 1);
 }
+#endif
 
 #define HASHBYTES 1024
 
-void sendrequest(char *cmd, char *local, char *remote, int printnames)
+void sendrequest(const char *cmd, const char *local, const char *remote, int printnames)
 {
        FILE *fin;
         int dout = 0;
        int (*closefunc)(), _pclose(), fclose();
        sig_t (*oldintr)(), (*oldintp)();
-       void abortsend();
        char buf[BUFSIZ], *bufp;
        long bytes = 0, hashbytes = HASHBYTES;
        register int c, d;
        struct stat st;
        struct timeval start, stop;
-       char *mode;
+       const char *mode;
 
        if (verbose && printnames) {
                if (local && *local != '-')
@@ -710,7 +715,7 @@ null();//           (void) signal(SIGPIPE, oldintp);
 
 jmp_buf        recvabort;
 
-
+#if 0
 void abortrecv()
 {
 
@@ -720,17 +725,17 @@ void abortrecv()
        (void) fflush(stdout);
        longjmp(recvabort, 1);
 }
+#endif
 
-void recvrequest(char *cmd, char *local, char *remote, char *mode,
+void recvrequest(const char *cmd, const char *local, const char *remote, const char *mode,
                 int printnames)
 {
-       FILE *fout;
+       FILE *fout = stdout;
         int din = 0;
        int (*closefunc)(), _pclose(), fclose();
        void (*oldintr)(int), (*oldintp)(int);
-       void abortrecv();
        int oldverbose = 0, oldtype = 0, is_retr, tcrflag, nfnd, bare_lfs = 0;
-       char *gunique(), msg;
+       char msg;
 //     static char *buf; // Szurgot: Shouldn't this go SOMEWHERE?
         char buf[1024];
        static int bufsize = 1024;
@@ -1252,7 +1257,7 @@ bad:
        return (1);
 }
 
-int dataconn(char *mode)
+int dataconn(const char *mode)
 {
    struct sockaddr_in from;
    int s, fromlen = sizeof (from);
@@ -1277,7 +1282,7 @@ int dataconn(char *mode)
 }
 
 void ptransfer(direction, bytes, t0, t1)
-       char *direction;
+       const char *direction;
        long bytes;
        struct timeval *t0, *t1;
 {
@@ -1289,7 +1294,7 @@ void ptransfer(direction, bytes, t0, t1)
                s = td.tv_sec + (td.tv_usec / 1000000.);
 #define        nz(x)   ((x) == 0 ? 1 : (x))
                bs = bytes / nz(s);
-               printf("%ld bytes %s in %.2g seconds (%.2g Kbytes/s)\n",
+               printf("%ld bytes %s in %.1f seconds (%.0f Kbytes/s)\n",
                    bytes, direction, s, bs / 1024.);
                (void) fflush(stdout);
        }
@@ -1417,6 +1422,7 @@ void pswitch(int flag)
 jmp_buf ptabort;
 int ptabflg;
 
+#if 0
 void
 abortpt()
 {
@@ -1427,15 +1433,15 @@ abortpt()
        abrtflag = 0;
        longjmp(ptabort, 1);
 }
+#endif
 
 void proxtrans(cmd, local, remote)
-       char *cmd, *local, *remote;
+       const char *cmd, *local, *remote;
 {
 //     void (*oldintr)(int);
-       //void abortpt(int);
        int tmptype, oldtype = 0, secndflag = 0, nfnd;
        extern jmp_buf ptabort;
-       char *cmd2;
+       const char *cmd2;
 //     struct
        fd_set mask;
 
@@ -1756,6 +1762,7 @@ void reset()
        }
 }
 
+#if 0
 char *
 gunique(local)
        char *local;
@@ -1802,6 +1809,7 @@ gunique(local)
        }
        return(new);
 }
+#endif
 
 int null(void)
 {