| 3709 |
goto error; |
goto error; |
| 3710 |
} |
} |
| 3711 |
|
|
| 3712 |
if (direction == TOLOCAL) { // copy local to remote |
if (direction == TOREMOTE) { // copy local to remote |
| 3713 |
fp = fopen(sendfile, "rb"); |
fp = fopen(sendfile, "rb"); |
| 3714 |
if (fp == NULL) { |
if (fp == NULL) { |
| 3715 |
char buf[80]; |
char buf[80]; |
| 3806 |
|
|
| 3807 |
int SSH_start_scp(PTInstVar pvar, char *sendfile, char *dstfile) |
int SSH_start_scp(PTInstVar pvar, char *sendfile, char *dstfile) |
| 3808 |
{ |
{ |
| 3809 |
return SSH_scp_transaction(pvar, sendfile, dstfile, TOLOCAL); |
return SSH_scp_transaction(pvar, sendfile, dstfile, TOREMOTE); |
| 3810 |
} |
} |
| 3811 |
|
|
| 3812 |
int SSH_start_scp_receive(PTInstVar pvar, char *filename) |
int SSH_start_scp_receive(PTInstVar pvar, char *filename) |
| 7753 |
|
|
| 7754 |
if (c->type == TYPE_SCP) { |
if (c->type == TYPE_SCP) { |
| 7755 |
char sbuf[MAX_PATH + 30]; |
char sbuf[MAX_PATH + 30]; |
| 7756 |
if (c->scp.dir == TOLOCAL) { |
if (c->scp.dir == TOREMOTE) { |
| 7757 |
_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -t %s", c->scp.remotefile); |
_snprintf_s(sbuf, sizeof(sbuf), _TRUNCATE, "scp -t %s", c->scp.remotefile); |
| 7758 |
|
|
| 7759 |
} else { |
} else { |
| 8184 |
} |
} |
| 8185 |
|
|
| 8186 |
|
|
| 8187 |
static void SSH2_scp_tolocal(PTInstVar pvar, Channel_t *c, unsigned char *data, unsigned int buflen) |
static void SSH2_scp_toremote(PTInstVar pvar, Channel_t *c, unsigned char *data, unsigned int buflen) |
| 8188 |
{ |
{ |
| 8189 |
if (c->scp.state == SCP_INIT) { |
if (c->scp.state == SCP_INIT) { |
| 8190 |
char buf[128]; |
char buf[128]; |
| 8387 |
if (SSH2_scp_fromremote(pvar, c, data, buflen) == FALSE) |
if (SSH2_scp_fromremote(pvar, c, data, buflen) == FALSE) |
| 8388 |
goto error; |
goto error; |
| 8389 |
|
|
| 8390 |
} else if (c->scp.dir == TOLOCAL) { |
} else if (c->scp.dir == TOREMOTE) { |
| 8391 |
if (buflen == 1 && data[0] == '\0') { // OK |
if (buflen == 1 && data[0] == '\0') { // OK |
| 8392 |
SSH2_scp_tolocal(pvar, c, data, buflen); |
SSH2_scp_toremote(pvar, c, data, buflen); |
| 8393 |
} else { |
} else { |
| 8394 |
goto error; |
goto error; |
| 8395 |
} |
} |