| 91 |
enum scp_state state; // SCP state |
enum scp_state state; // SCP state |
| 92 |
char sendfile[MAX_PATH]; // sending filename |
char sendfile[MAX_PATH]; // sending filename |
| 93 |
char sendfilefull[MAX_PATH]; // sending filename fullpath |
char sendfilefull[MAX_PATH]; // sending filename fullpath |
| 94 |
|
char dstfile[MAX_PATH]; // sending filename |
| 95 |
FILE *sendfp; // file pointer |
FILE *sendfp; // file pointer |
| 96 |
struct _stat filestat; // file status information |
struct _stat filestat; // file status information |
| 97 |
HWND progress; |
HWND progress; |
| 3376 |
// |
// |
| 3377 |
// (2007.12.21 yutaka) |
// (2007.12.21 yutaka) |
| 3378 |
// |
// |
| 3379 |
static int SSH_scp_transaction(PTInstVar pvar, char *sendfile, enum scp_dir direction) |
static int SSH_scp_transaction(PTInstVar pvar, char *sendfile, char *dstfile, enum scp_dir direction) |
| 3380 |
{ |
{ |
| 3381 |
buffer_t *msg; |
buffer_t *msg; |
| 3382 |
char *s; |
char *s; |
| 3409 |
|
|
| 3410 |
strncpy_s(c->scp.sendfilefull, sizeof(c->scp.sendfilefull), sendfile, _TRUNCATE); // full path |
strncpy_s(c->scp.sendfilefull, sizeof(c->scp.sendfilefull), sendfile, _TRUNCATE); // full path |
| 3411 |
ExtractFileName(sendfile, c->scp.sendfile, sizeof(c->scp.sendfile)); // file name only |
ExtractFileName(sendfile, c->scp.sendfile, sizeof(c->scp.sendfile)); // file name only |
| 3412 |
|
if (dstfile == NULL || dstfile[0] == '\0') { // remote file path |
| 3413 |
|
strncpy_s(c->scp.dstfile, sizeof(c->scp.dstfile), c->scp.sendfile, _TRUNCATE); // full path |
| 3414 |
|
} else { |
| 3415 |
|
strncpy_s(c->scp.dstfile, sizeof(c->scp.dstfile), dstfile, _TRUNCATE); // full path |
| 3416 |
|
} |
| 3417 |
c->scp.sendfp = fp; // file pointer |
c->scp.sendfp = fp; // file pointer |
| 3418 |
|
|
| 3419 |
if (_stat(c->scp.sendfilefull, &st) == 0) { |
if (_stat(c->scp.sendfilefull, &st) == 0) { |
| 3464 |
return FALSE; |
return FALSE; |
| 3465 |
} |
} |
| 3466 |
|
|
| 3467 |
int SSH_start_scp(PTInstVar pvar, char *sendfile) |
int SSH_start_scp(PTInstVar pvar, char *sendfile, char *dstfile) |
| 3468 |
{ |
{ |
| 3469 |
return SSH_scp_transaction(pvar, sendfile, TOLOCAL); |
return SSH_scp_transaction(pvar, sendfile, dstfile, TOLOCAL); |
| 3470 |
|
|
| 3471 |
#if 0 |
#if 0 |
| 3472 |
//return SSH_scp_transaction(pvar, "bigfile30.dat", FROMREMOTE); |
//return SSH_scp_transaction(pvar, "bigfile30.dat", FROMREMOTE); |
| 6882 |
if (c->type == TYPE_SCP) { |
if (c->type == TYPE_SCP) { |
| 6883 |
char sbuf[MAX_PATH + 30]; |
char sbuf[MAX_PATH + 30]; |
| 6884 |
if (c->scp.dir == TOLOCAL) { |
if (c->scp.dir == TOLOCAL) { |
| 6885 |
_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -t %s", c->scp.sendfile); |
_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -t %s", c->scp.dstfile); |
| 6886 |
|
|
| 6887 |
} else { |
} else { |
| 6888 |
_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -f %s", c->scp.sendfile); |
_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -f %s", c->scp.dstfile); |
| 6889 |
|
|
| 6890 |
} |
} |
| 6891 |
buffer_put_string(msg, sbuf, strlen(sbuf)); |
buffer_put_string(msg, sbuf, strlen(sbuf)); |