Commit 047ac65a authored by stettberger's avatar stettberger

FTP outgoing

parent 5267edac
......@@ -14,9 +14,4 @@ SILC_COMMAND_DETACH
SILC_COMMAND_WATCH
SILC_COMMAND_SILCOPER
SILC_COMMAND_SERVICE
* Misc
Filetransfer SFTP
......@@ -278,7 +278,7 @@ void proc_channels_input(Channel *c, char *buf) {
else if (!strncmp("file ", &buf[1], 5)){
Transfer *t;
if (!strncmp("list", &buf[6], 4)){
print_out("", "-?!- Number User Type Status");
print_out("", "-?!- Number User Type Status");
for (t=transfers; t; t=t->next) {
char *status;
if (t->status == FILE_STATUS_WAIT)
......@@ -289,7 +289,6 @@ void proc_channels_input(Channel *c, char *buf) {
status="error";
else if (t->status == FILE_STATUS_COMP)
status="complete";
print_out("", "-?!- Number User Type Status");
print_out("", "-?!- %-5d %-10s %-10s %-10s", t->number, t->silc->nickname,
t->type==FILE_TYPE_IN?"incoming":"outgoing", status);
}
......@@ -303,18 +302,44 @@ void proc_channels_input(Channel *c, char *buf) {
print_out("", "-!- No such File transfer");
return;
}
char *path=malloc(strlen(getenv("HOME"))+40);
char *path=malloc(strlen(getenv("HOME"))+1);
NULL_TEST(path);
sprintf(path, "%s/.silc/incoming/", getenv("HOME"));
sprintf(path, "%s/", getenv("HOME"));
create_dirtree(path);
int res=silc_client_file_receive(silc_client->client,silc_client->conn,
file_transfer,NULL,path, t->id, NULL, NULL);
if(res!=SILC_CLIENT_FILE_OK){
DEBUG("Error: %d\n", res);
print_out("", "-!- Error: Couldn't start filetransfer");
return;
}
}
else if(!strncmp("send ", &buf[6], 5)) {
char **argv;
SilcUInt32 *argv_lens, *argv_types, argc, id;
SilcClientEntry client;
int bind=TRUE;
silc_parse_command_line((unsigned char *)buf, (void *)&argv, &argv_lens, &argv_types, &argc, 5);
if (argc < 4) {
print_out("", "-!- File: /file send <nick> <path>");
return;
}
if (argc==5)
if (!strcmp("-no-listner", argv[4]))
bind=FALSE;
client=silc_client_get_client_entry(argv[2]);
if(!silc_file_size(argv[3])) {
print_out("", "-!- File: File doesn't exists or is 0 bytes long");
return;
}
int res=silc_client_file_send(silc_client->client, silc_client->conn, file_transfer, NULL, NULL, 0, bind, client, argv[3], &id);
if(res!=SILC_CLIENT_FILE_OK){
print_out("", "-!- Error: Couldn't start filetransfer");
return;
}
add_transfer(transfer_count, id, client, FILE_TYPE_OUT);
print_out("","-!- File: transfer request sent to %s for %s", client->nickname, argv[3]);
transfer_count++;
}
else if(!strncmp("close ", &buf[6], 6)) {
int num=atoi(&buf[12]);
for(t=transfers; t; t=t->next)
......@@ -790,7 +815,8 @@ void file_transfer(SilcClient client,
else
kps = (double)(offset + 1023) / (double)1024;
print_out("", "-!- File: Completed file transfer %d [%.2f kB/s]", t->number, kps);
print_out("", "-!- File: saved to: %s", filepath);
if(status== SILC_CLIENT_FILE_MONITOR_RECEIVE)
print_out("", "-!- File: saved to: %s", filepath);
t->status=FILE_STATUS_COMP;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment