mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Clean up scp client - re-indent to my coding style and remove
compiler warnings [originally from svn r280]
This commit is contained in:
parent
7809b519d5
commit
3c9b8bff57
34
scp.c
34
scp.c
@ -6,7 +6,6 @@
|
||||
* They, in turn, used stuff from BSD rcp.
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock.h>
|
||||
#include <stdlib.h>
|
||||
@ -18,13 +17,11 @@
|
||||
#include "putty.h"
|
||||
#include "scp.h"
|
||||
|
||||
|
||||
#define TIME_POSIX_TO_WIN(t, ft) (*(LONGLONG*)&(ft) = \
|
||||
((LONGLONG) (t) + (LONGLONG) 11644473600) * (LONGLONG) 10000000)
|
||||
#define TIME_WIN_TO_POSIX(ft, t) ((t) = (unsigned long) \
|
||||
((*(LONGLONG*)&(ft)) / (LONGLONG) 10000000 - (LONGLONG) 11644473600))
|
||||
|
||||
|
||||
int verbose = 0;
|
||||
static int recursive = 0;
|
||||
static int preserve = 0;
|
||||
@ -37,7 +34,6 @@ static void source(char *src);
|
||||
static void rsource(char *src);
|
||||
static void sink(char *targ);
|
||||
|
||||
|
||||
/*
|
||||
* Print an error message and perform a fatal exit.
|
||||
*/
|
||||
@ -52,7 +48,6 @@ void fatalbox(char *fmt, ...)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print an error message and exit after closing the SSH link.
|
||||
*/
|
||||
@ -72,11 +67,11 @@ static void bump(char *fmt, ...)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
void ssh_get_password(char *prompt, char *str, int maxlen)
|
||||
{
|
||||
HANDLE hin, hout;
|
||||
DWORD savemode, i;
|
||||
DWORD savemode;
|
||||
int i;
|
||||
|
||||
hin = GetStdHandle(STD_INPUT_HANDLE);
|
||||
hout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
@ -98,7 +93,6 @@ void ssh_get_password(char *prompt, char *str, int maxlen)
|
||||
WriteFile(hout, "\r\n", 2, &i, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Open an SSH connection to user@host and execute cmd.
|
||||
*/
|
||||
@ -139,12 +133,11 @@ static void do_cmd(char *host, char *user, char *cmd)
|
||||
connection_open = 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update statistic information about current file.
|
||||
*/
|
||||
static void print_stats(char *name, unsigned long size, unsigned long done,
|
||||
unsigned long start, unsigned long now)
|
||||
time_t start, time_t now)
|
||||
{
|
||||
float ratebs;
|
||||
unsigned long eta;
|
||||
@ -159,11 +152,11 @@ static void print_stats(char *name, unsigned long size, unsigned long done,
|
||||
if (ratebs < 1.0)
|
||||
eta = size - done;
|
||||
else
|
||||
eta = (size - done) / ratebs;
|
||||
eta = (unsigned long) ((size - done) / ratebs);
|
||||
sprintf(etastr, "%02d:%02d:%02d",
|
||||
eta / 3600, (eta % 3600) / 60, eta % 60);
|
||||
|
||||
pct = 100.0 * (float) done / size;
|
||||
pct = (int) (100.0 * (float) done / size);
|
||||
|
||||
printf("\r%-25.25s | %10ld kB | %5.1f kB/s | ETA: %8s | %3d%%",
|
||||
name, done / 1024, ratebs / 1024.0,
|
||||
@ -173,7 +166,6 @@ static void print_stats(char *name, unsigned long size, unsigned long done,
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Find a colon in str and return a pointer to the colon.
|
||||
* This is used to seperate hostname from filename.
|
||||
@ -198,7 +190,6 @@ static char * colon(char *str)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Wait for a response from the other side.
|
||||
* Return 0 if ok, -1 if error.
|
||||
@ -235,7 +226,6 @@ static int response(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send an error message to the other side and to the screen.
|
||||
* Increment error counter.
|
||||
@ -255,7 +245,6 @@ static void run_err(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Execute the source part of the SCP protocol.
|
||||
*/
|
||||
@ -268,7 +257,7 @@ static void source(char *src)
|
||||
DWORD attr;
|
||||
unsigned long i;
|
||||
unsigned long stat_bytes;
|
||||
unsigned long stat_starttime, stat_lasttime;
|
||||
time_t stat_starttime, stat_lasttime;
|
||||
|
||||
attr = GetFileAttributes(src);
|
||||
if (attr == -1) {
|
||||
@ -351,7 +340,6 @@ static void source(char *src)
|
||||
(void) response();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Recursively send the contents of a directory.
|
||||
*/
|
||||
@ -403,7 +391,6 @@ static void rsource(char *src)
|
||||
(void) response();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Execute the sink part of the SCP protocol.
|
||||
*/
|
||||
@ -422,7 +409,7 @@ static void sink(char *targ)
|
||||
unsigned long size, i;
|
||||
int wrerror = 0;
|
||||
unsigned long stat_bytes;
|
||||
unsigned long stat_starttime, stat_lasttime;
|
||||
time_t stat_starttime, stat_lasttime;
|
||||
char *stat_name;
|
||||
|
||||
attr = GetFileAttributes(targ);
|
||||
@ -435,7 +422,7 @@ static void sink(char *targ)
|
||||
ssh_send("", 1);
|
||||
while (1) {
|
||||
settime = 0;
|
||||
gottime:
|
||||
gottime:
|
||||
if (ssh_recv(&ch, 1) <= 0)
|
||||
return;
|
||||
if (ch == '\n')
|
||||
@ -569,7 +556,6 @@ gottime:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We will copy local files to a remote server.
|
||||
*/
|
||||
@ -669,7 +655,6 @@ static void toremote(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* We will copy files from a remote server to the local machine.
|
||||
*/
|
||||
@ -719,7 +704,6 @@ static void tolocal(int argc, char *argv[])
|
||||
sink(targ);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize the Win$ock driver.
|
||||
*/
|
||||
@ -736,7 +720,6 @@ static void init_winsock()
|
||||
bump("WinSock version is incompatible with 1.1");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Short description of parameters.
|
||||
*/
|
||||
@ -750,7 +733,6 @@ static void usage()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main program (no, really?)
|
||||
*/
|
||||
|
8
scpssh.c
8
scpssh.c
@ -37,10 +37,10 @@
|
||||
((unsigned long)(unsigned char)(cp)[3]))
|
||||
|
||||
#define PUT_32BIT(cp, value) { \
|
||||
(cp)[0] = (value) >> 24; \
|
||||
(cp)[1] = (value) >> 16; \
|
||||
(cp)[2] = (value) >> 8; \
|
||||
(cp)[3] = (value); }
|
||||
(cp)[0] = (unsigned char)((value) >> 24); \
|
||||
(cp)[1] = (unsigned char)((value) >> 16); \
|
||||
(cp)[2] = (unsigned char)((value) >> 8); \
|
||||
(cp)[3] = (unsigned char)(value); }
|
||||
|
||||
static SOCKET s = INVALID_SOCKET;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user