Diff

Differences From Artifact [9ce909a782]:

To Artifact [4b1e365d89]:


1
2
3
4
5
6
7
8
9
10
/*
 *  scp.c  -  Scp (Secure Copy) client for PuTTY.
 *  Joris van Rantwijk, Aug 1999.
 *
 *  This is mainly based on ssh-1.2.26/scp.c by Timo Rinne & Tatu Ylonen.
 *  They, in turn, used stuff from BSD rcp.
 */

#include <windows.h>
#include <winsock.h>


|







1
2
3
4
5
6
7
8
9
10
/*
 *  scp.c  -  Scp (Secure Copy) client for PuTTY.
 *  Joris van Rantwijk, Aug 1999, Nov 1999.
 *
 *  This is mainly based on ssh-1.2.26/scp.c by Timo Rinne & Tatu Ylonen.
 *  They, in turn, used stuff from BSD rcp.
 */

#include <windows.h>
#include <winsock.h>
23
24
25
26
27
28
29


30
31
32
33
34
35
36
	((*(LONGLONG*)&(ft)) / (LONGLONG) 10000000 - (LONGLONG) 11644473600))

int verbose = 0;
static int recursive = 0;
static int preserve = 0;
static int targetshouldbedirectory = 0;
static int statistics = 1;


static int errs = 0;
static int connection_open = 0;

static void source(char *src);
static void rsource(char *src);
static void sink(char *targ);








>
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
	((*(LONGLONG*)&(ft)) / (LONGLONG) 10000000 - (LONGLONG) 11644473600))

int verbose = 0;
static int recursive = 0;
static int preserve = 0;
static int targetshouldbedirectory = 0;
static int statistics = 1;
static int portnumber = 0;
static char *password = NULL;
static int errs = 0;
static int connection_open = 0;

static void source(char *src);
static void rsource(char *src);
static void sink(char *targ);

66
67
68
69
70
71
72
73
74






75
76
77
78
79
80
81
    }
    exit(1);
}

void ssh_get_password(char *prompt, char *str, int maxlen)
{
    HANDLE hin, hout;
    DWORD savemode;
    int i;







    hin = GetStdHandle(STD_INPUT_HANDLE);
    hout = GetStdHandle(STD_OUTPUT_HANDLE);
    if (hin == INVALID_HANDLE_VALUE || hout == INVALID_HANDLE_VALUE)
	bump("Cannot get standard input/output handles");

    GetConsoleMode(hin, &savemode);







|
|
>
>
>
>
>
>







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
    }
    exit(1);
}

void ssh_get_password(char *prompt, char *str, int maxlen)
{
    HANDLE hin, hout;
    DWORD savemode, i;

    if (password) {
	strncpy(str, password, maxlen);
	str[maxlen-1] = '\0';
	password = NULL;
	return;
    }

    hin = GetStdHandle(STD_INPUT_HANDLE);
    hout = GetStdHandle(STD_OUTPUT_HANDLE);
    if (hin == INVALID_HANDLE_VALUE || hout == INVALID_HANDLE_VALUE)
	bump("Cannot get standard input/output handles");

    GetConsoleMode(hin, &savemode);
108
109
110
111
112
113
114



115
116
117
118
119
120
121
    if (cfg.host[0] == '\0') {
	/* No settings for this host; use defaults */
	strncpy(cfg.host, host, sizeof(cfg.host)-1);
	cfg.host[sizeof(cfg.host)-1] = '\0';
	cfg.port = 22;
    }




    /* Set username */
    if (user != NULL && user[0] != '\0') {
	strncpy(cfg.username, user, sizeof(cfg.username)-1);
	cfg.username[sizeof(cfg.username)-1] = '\0';
	cfg.port = 22;
    } else if (cfg.username[0] == '\0') {
	bump("Empty user name");







>
>
>







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    if (cfg.host[0] == '\0') {
	/* No settings for this host; use defaults */
	strncpy(cfg.host, host, sizeof(cfg.host)-1);
	cfg.host[sizeof(cfg.host)-1] = '\0';
	cfg.port = 22;
    }

    if (portnumber)
	cfg.port = portnumber;

    /* Set username */
    if (user != NULL && user[0] != '\0') {
	strncpy(cfg.username, user, sizeof(cfg.username)-1);
	cfg.username[sizeof(cfg.username)-1] = '\0';
	cfg.port = 22;
    } else if (cfg.username[0] == '\0') {
	bump("Empty user name");
723
724
725
726
727
728
729
730
731
732






733
734
735
736
737
738
739
/*
 *  Short description of parameters.
 */
static void usage()
{
    printf("PuTTY Secure Copy client\n");
    printf("%s\n", ver);
    printf("usage: scp [-p] [-q] [-r] [-v] [user@]host:source target\n");
    printf("       scp [-p] [-q] [-r] [-v] source [source..]"
	   " [user@]host:target\n");






    exit(1);
}

/*
 *  Main program (no, really?)
 */
int main(int argc, char *argv[])







|
|
|
>
>
>
>
>
>







734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
/*
 *  Short description of parameters.
 */
static void usage()
{
    printf("PuTTY Secure Copy client\n");
    printf("%s\n", ver);
    printf("Usage: scp [options] [user@]host:source target\n");
    printf("       scp [options] source [source...] [user@]host:target\n");
    printf("Options:\n");
    printf("  -p        preserve file attributes\n");
    printf("  -q        quiet, don't show statistics\n");
    printf("  -r        copy directories recursively\n");
    printf("  -v        show verbose messages\n");
    printf("  -P port   connect to specified port\n");
    printf("  -pw passw login with specified password\n");
    exit(1);
}

/*
 *  Main program (no, really?)
 */
int main(int argc, char *argv[])
752
753
754
755
756
757
758




759
760
761
762
763
764
765
	else if (strcmp(argv[i], "-p") == 0)
	    preserve = 1;
	else if (strcmp(argv[i], "-q") == 0)
	    statistics = 0;
	else if (strcmp(argv[i], "-h") == 0 ||
		 strcmp(argv[i], "-?") == 0)
	    usage();




	else if (strcmp(argv[i], "--") == 0)
	{ i++; break; }
	else
	    usage();
    }
    argc -= i;
    argv += i;







>
>
>
>







769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
	else if (strcmp(argv[i], "-p") == 0)
	    preserve = 1;
	else if (strcmp(argv[i], "-q") == 0)
	    statistics = 0;
	else if (strcmp(argv[i], "-h") == 0 ||
		 strcmp(argv[i], "-?") == 0)
	    usage();
	else if (strcmp(argv[i], "-P") == 0 && i+1 < argc)
	    portnumber = atoi(argv[++i]);
	else if (strcmp(argv[i], "-pw") == 0 && i+1 < argc)
	    password = argv[++i];
	else if (strcmp(argv[i], "--") == 0)
	{ i++; break; }
	else
	    usage();
    }
    argc -= i;
    argv += i;