1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

smb: download resuming

This commit is contained in:
Witold Filipczyk 2007-03-09 20:18:38 +01:00 committed by Witold Filipczyk
parent 991427f967
commit 967a15b7f4

View File

@ -26,6 +26,7 @@
#include "main/module.h"
#include "main/select.h"
#include "network/connection.h"
#include "network/progress.h"
#include "network/socket.h"
#include "osdep/osdep.h"
#include "protocol/auth/auth.h"
@ -342,6 +343,9 @@ do_smb(struct connection *conn)
fprintf(stderr, "%" OFF_T_FORMAT, sb.st_size);
fclose(stderr);
if (conn->progress->start > 0) {
smbc_lseek(file, conn->progress->start, SEEK_SET);
}
while ((r = smbc_read(file, buf, READ_SIZE)) > 0) {
if (safe_write(STDOUT_FILENO, buf, r) <= 0)
break;
@ -427,7 +431,7 @@ smb_got_header(struct socket *socket, struct read_buffer *rb)
{
struct connection *conn = socket->conn;
struct read_buffer *buf;
int error = 0;
int type_of_data = 0;
conn->cached = get_cache_entry(conn->uri);
if (!conn->cached) {
@ -448,7 +452,7 @@ smb_got_header(struct socket *socket, struct read_buffer *rb)
if (ctype && *ctype) {
if (!strcmp(ctype, "text/x-error")) {
error = 1;
type_of_data = 1;
mem_free(ctype);
} else {
if (ctype[0] >= '0' && ctype[0] <= '9') {
@ -464,6 +468,7 @@ smb_got_header(struct socket *socket, struct read_buffer *rb)
abort_connection(conn, S_OK);
return;
}
type_of_data = 2;
}
else mem_free_set(&conn->cached->content_type, ctype);
}
@ -479,10 +484,16 @@ smb_got_header(struct socket *socket, struct read_buffer *rb)
abort_connection(conn, S_OUT_OF_MEM);
return;
}
if (error) {
switch (type_of_data) {
case 1:
mem_free_set(&conn->cached->content_type, stracpy("text/html"));
read_from_socket(conn->data_socket, buf, S_CONN, smb_got_error);
} else {
break;
case 2:
if (conn->progress->start > 0) {
conn->progress->seek = conn->from = conn->progress->start;
} /* no break here! --witekfl */
default:
read_from_socket(conn->data_socket, buf, S_CONN, smb_got_data);
}
}
@ -504,8 +515,6 @@ smb_protocol_handler(struct connection *conn)
abort_connection(conn, -s_errno);
return;
}
conn->from = 0;
conn->unrestartable = 1;
find_auth(conn->uri); /* remember username and password */
cpid = fork();