mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
1008: s/big_file/file/g .
This commit is contained in:
parent
9f768354b9
commit
f09a5f235e
@ -83,16 +83,16 @@ close_pipe_and_read(struct socket *data_socket)
|
|||||||
|
|
||||||
#define POST_BUFFER_SIZE 4096
|
#define POST_BUFFER_SIZE 4096
|
||||||
#define BIG_READ 65536
|
#define BIG_READ 65536
|
||||||
static void send_big_files2(struct socket *socket);
|
static void send_files2(struct socket *socket);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_big_files(struct socket *socket)
|
send_files(struct socket *socket)
|
||||||
{
|
{
|
||||||
struct connection *conn = socket->conn;
|
struct connection *conn = socket->conn;
|
||||||
struct http_connection_info *http = conn->info;
|
struct http_connection_info *http = conn->info;
|
||||||
unsigned char *post = http->post_data;
|
unsigned char *post = http->post_data;
|
||||||
unsigned char buffer[POST_BUFFER_SIZE];
|
unsigned char buffer[POST_BUFFER_SIZE];
|
||||||
unsigned char *big_file = strchr(post, BIG_FILE_CHAR);
|
unsigned char *file = strchr(post, FILE_CHAR);
|
||||||
struct string data;
|
struct string data;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int finish = 0;
|
int finish = 0;
|
||||||
@ -102,12 +102,12 @@ send_big_files(struct socket *socket)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!big_file) {
|
if (!file) {
|
||||||
finish = 1;
|
finish = 1;
|
||||||
big_file = strchr(post, '\0');
|
file = strchr(post, '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
while (post < big_file) {
|
while (post < file) {
|
||||||
int h1, h2;
|
int h1, h2;
|
||||||
|
|
||||||
h1 = unhx(post[0]);
|
h1 = unhx(post[0]);
|
||||||
@ -131,12 +131,12 @@ send_big_files(struct socket *socket)
|
|||||||
write_to_socket(socket, data.source, data.length, S_SENT,
|
write_to_socket(socket, data.source, data.length, S_SENT,
|
||||||
close_pipe_and_read);
|
close_pipe_and_read);
|
||||||
} else {
|
} else {
|
||||||
unsigned char *end = strchr(big_file + 1, BIG_FILE_CHAR);
|
unsigned char *end = strchr(file + 1, FILE_CHAR);
|
||||||
|
|
||||||
assert(end);
|
assert(end);
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
conn->post_fd = open(big_file + 1, O_RDONLY);
|
conn->post_fd = open(file + 1, O_RDONLY);
|
||||||
*end = BIG_FILE_CHAR;
|
*end = FILE_CHAR;
|
||||||
if (conn->post_fd < 0) {
|
if (conn->post_fd < 0) {
|
||||||
done_string(&data);
|
done_string(&data);
|
||||||
/* FIXME: proper error code */
|
/* FIXME: proper error code */
|
||||||
@ -146,13 +146,13 @@ send_big_files(struct socket *socket)
|
|||||||
http->post_data = end + 1;
|
http->post_data = end + 1;
|
||||||
socket->state = SOCKET_END_ONCLOSE;
|
socket->state = SOCKET_END_ONCLOSE;
|
||||||
write_to_socket(socket, data.source, data.length, S_TRANS,
|
write_to_socket(socket, data.source, data.length, S_TRANS,
|
||||||
send_big_files2);
|
send_files2);
|
||||||
}
|
}
|
||||||
done_string(&data);
|
done_string(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_big_files2(struct socket *socket)
|
send_files2(struct socket *socket)
|
||||||
{
|
{
|
||||||
struct connection *conn = socket->conn;
|
struct connection *conn = socket->conn;
|
||||||
unsigned char buffer[BIG_READ];
|
unsigned char buffer[BIG_READ];
|
||||||
@ -161,11 +161,11 @@ send_big_files2(struct socket *socket)
|
|||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
socket->state = SOCKET_END_ONCLOSE;
|
socket->state = SOCKET_END_ONCLOSE;
|
||||||
write_to_socket(socket, buffer, n, S_TRANS,
|
write_to_socket(socket, buffer, n, S_TRANS,
|
||||||
send_big_files2);
|
send_files2);
|
||||||
} else {
|
} else {
|
||||||
close(conn->post_fd);
|
close(conn->post_fd);
|
||||||
conn->post_fd = -1;
|
conn->post_fd = -1;
|
||||||
send_big_files(socket);
|
send_files(socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,13 +183,13 @@ send_post_data(struct connection *conn)
|
|||||||
if (postend) post = postend + 1;
|
if (postend) post = postend + 1;
|
||||||
|
|
||||||
if (post) {
|
if (post) {
|
||||||
unsigned char *big_file = strchr(post, BIG_FILE_CHAR);
|
unsigned char *file = strchr(post, FILE_CHAR);
|
||||||
|
|
||||||
if (big_file) {
|
if (file) {
|
||||||
struct http_connection_info *http = conn->info;
|
struct http_connection_info *http = conn->info;
|
||||||
|
|
||||||
http->post_data = post;
|
http->post_data = post;
|
||||||
send_big_files(conn->data_socket);
|
send_files(conn->data_socket);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,7 @@ accept_encoding_header(struct string *header)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This sets the Content-Length of POST data and counts big files. */
|
/* This sets the Content-Length of POST data and counts files. */
|
||||||
static size_t
|
static size_t
|
||||||
post_length(unsigned char *post_data, unsigned int *count)
|
post_length(unsigned char *post_data, unsigned int *count)
|
||||||
{
|
{
|
||||||
@ -593,13 +593,13 @@ post_length(unsigned char *post_data, unsigned int *count)
|
|||||||
unsigned char *begin;
|
unsigned char *begin;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
begin = strchr(end, BIG_FILE_CHAR);
|
begin = strchr(end, FILE_CHAR);
|
||||||
if (!begin) break;
|
if (!begin) break;
|
||||||
end = strchr(begin + 1, BIG_FILE_CHAR);
|
end = strchr(begin + 1, FILE_CHAR);
|
||||||
if (!end) break;
|
if (!end) break;
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
res = stat(begin + 1, &sb);
|
res = stat(begin + 1, &sb);
|
||||||
*end = BIG_FILE_CHAR;
|
*end = FILE_CHAR;
|
||||||
if (res) break;
|
if (res) break;
|
||||||
(*count)++;
|
(*count)++;
|
||||||
size += sb.st_size;
|
size += sb.st_size;
|
||||||
@ -613,16 +613,16 @@ post_length(unsigned char *post_data, unsigned int *count)
|
|||||||
#define POST_BUFFER_SIZE 4096
|
#define POST_BUFFER_SIZE 4096
|
||||||
#define BIG_READ 655360
|
#define BIG_READ 655360
|
||||||
|
|
||||||
static void send_big_files2(struct socket *socket);
|
static void send_files2(struct socket *socket);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_big_files(struct socket *socket)
|
send_files(struct socket *socket)
|
||||||
{
|
{
|
||||||
struct connection *conn = socket->conn;
|
struct connection *conn = socket->conn;
|
||||||
struct http_connection_info *http = conn->info;
|
struct http_connection_info *http = conn->info;
|
||||||
unsigned char *post = http->post_data;
|
unsigned char *post = http->post_data;
|
||||||
unsigned char buffer[POST_BUFFER_SIZE];
|
unsigned char buffer[POST_BUFFER_SIZE];
|
||||||
unsigned char *big_file = strchr(post, BIG_FILE_CHAR);
|
unsigned char *file = strchr(post, FILE_CHAR);
|
||||||
struct string data;
|
struct string data;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int finish = 0;
|
int finish = 0;
|
||||||
@ -632,12 +632,12 @@ send_big_files(struct socket *socket)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!big_file) {
|
if (!file) {
|
||||||
finish = 1;
|
finish = 1;
|
||||||
big_file = strchr(post, '\0');
|
file = strchr(post, '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
while (post < big_file) {
|
while (post < file) {
|
||||||
int h1, h2;
|
int h1, h2;
|
||||||
|
|
||||||
h1 = unhx(post[0]);
|
h1 = unhx(post[0]);
|
||||||
@ -662,12 +662,12 @@ send_big_files(struct socket *socket)
|
|||||||
request_from_socket(socket, data.source, data.length, S_SENT,
|
request_from_socket(socket, data.source, data.length, S_SENT,
|
||||||
SOCKET_END_ONCLOSE, http_got_header);
|
SOCKET_END_ONCLOSE, http_got_header);
|
||||||
} else {
|
} else {
|
||||||
unsigned char *end = strchr(big_file + 1, BIG_FILE_CHAR);
|
unsigned char *end = strchr(file + 1, FILE_CHAR);
|
||||||
|
|
||||||
assert(end);
|
assert(end);
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
conn->post_fd = open(big_file + 1, O_RDONLY);
|
conn->post_fd = open(file + 1, O_RDONLY);
|
||||||
*end = BIG_FILE_CHAR;
|
*end = FILE_CHAR;
|
||||||
if (conn->post_fd < 0) {
|
if (conn->post_fd < 0) {
|
||||||
done_string(&data);
|
done_string(&data);
|
||||||
/* FIXME: proper error code */
|
/* FIXME: proper error code */
|
||||||
@ -678,13 +678,13 @@ send_big_files(struct socket *socket)
|
|||||||
socket->state = SOCKET_END_ONCLOSE;
|
socket->state = SOCKET_END_ONCLOSE;
|
||||||
http->uploaded += data.length;
|
http->uploaded += data.length;
|
||||||
write_to_socket(socket, data.source, data.length, S_TRANS,
|
write_to_socket(socket, data.source, data.length, S_TRANS,
|
||||||
send_big_files2);
|
send_files2);
|
||||||
}
|
}
|
||||||
done_string(&data);
|
done_string(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_big_files2(struct socket *socket)
|
send_files2(struct socket *socket)
|
||||||
{
|
{
|
||||||
struct connection *conn = socket->conn;
|
struct connection *conn = socket->conn;
|
||||||
struct http_connection_info *http = conn->info;
|
struct http_connection_info *http = conn->info;
|
||||||
@ -695,11 +695,11 @@ send_big_files2(struct socket *socket)
|
|||||||
socket->state = SOCKET_END_ONCLOSE;
|
socket->state = SOCKET_END_ONCLOSE;
|
||||||
http->uploaded += n;
|
http->uploaded += n;
|
||||||
write_to_socket(socket, buffer, n, S_TRANS,
|
write_to_socket(socket, buffer, n, S_TRANS,
|
||||||
send_big_files2);
|
send_files2);
|
||||||
} else {
|
} else {
|
||||||
close(conn->post_fd);
|
close(conn->post_fd);
|
||||||
conn->post_fd = -1;
|
conn->post_fd = -1;
|
||||||
send_big_files(socket);
|
send_files(socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -717,7 +717,7 @@ http_send_header(struct socket *socket)
|
|||||||
struct uri *uri = conn->proxied_uri; /* Set to the real uri */
|
struct uri *uri = conn->proxied_uri; /* Set to the real uri */
|
||||||
unsigned char *optstr;
|
unsigned char *optstr;
|
||||||
int use_connect, talking_to_proxy;
|
int use_connect, talking_to_proxy;
|
||||||
unsigned int big_files = 0;
|
unsigned int files = 0;
|
||||||
|
|
||||||
/* Sanity check for a host */
|
/* Sanity check for a host */
|
||||||
if (!uri || !uri->host || !*uri->host || !uri->hostlen) {
|
if (!uri || !uri->host || !*uri->host || !uri->hostlen) {
|
||||||
@ -1061,7 +1061,7 @@ http_send_header(struct socket *socket)
|
|||||||
|
|
||||||
post_data = postend ? postend + 1 : uri->post;
|
post_data = postend ? postend + 1 : uri->post;
|
||||||
add_to_string(&header, "Content-Length: ");
|
add_to_string(&header, "Content-Length: ");
|
||||||
size = post_length(post_data, &big_files);
|
size = post_length(post_data, &files);
|
||||||
http->total_upload_length = size;
|
http->total_upload_length = size;
|
||||||
add_long_to_string(&header, size);
|
add_long_to_string(&header, size);
|
||||||
add_crlf_to_string(&header);
|
add_crlf_to_string(&header);
|
||||||
@ -1083,7 +1083,7 @@ http_send_header(struct socket *socket)
|
|||||||
|
|
||||||
add_crlf_to_string(&header);
|
add_crlf_to_string(&header);
|
||||||
|
|
||||||
if (big_files) {
|
if (files) {
|
||||||
assert(!use_connect && post_data);
|
assert(!use_connect && post_data);
|
||||||
assert(conn->post_fd == -1);
|
assert(conn->post_fd == -1);
|
||||||
http->post_data = post_data;
|
http->post_data = post_data;
|
||||||
@ -1091,7 +1091,7 @@ http_send_header(struct socket *socket)
|
|||||||
if (!conn->upload_progress)
|
if (!conn->upload_progress)
|
||||||
conn->upload_progress = init_progress(0);
|
conn->upload_progress = init_progress(0);
|
||||||
write_to_socket(socket, header.source, header.length, S_TRANS,
|
write_to_socket(socket, header.source, header.length, S_TRANS,
|
||||||
send_big_files);
|
send_files);
|
||||||
done_string(&header);
|
done_string(&header);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ struct string;
|
|||||||
|
|
||||||
#define POST_CHAR 1
|
#define POST_CHAR 1
|
||||||
#define POST_CHAR_S "\001"
|
#define POST_CHAR_S "\001"
|
||||||
#define BIG_FILE_CHAR '\002'
|
#define FILE_CHAR '\002'
|
||||||
|
|
||||||
/* The uri structure is used to store the start position and length of commonly
|
/* The uri structure is used to store the start position and length of commonly
|
||||||
* used uri fields. It is initialized by parse_uri(). It is possible that the
|
* used uri fields. It is initialized by parse_uri(). It is possible that the
|
||||||
|
@ -58,8 +58,8 @@
|
|||||||
/* TODO: Some of these (particulary those encoding routines) would feel better
|
/* TODO: Some of these (particulary those encoding routines) would feel better
|
||||||
* in viewer/common/. --pasky */
|
* in viewer/common/. --pasky */
|
||||||
|
|
||||||
struct big_files_offset {
|
struct files_offset {
|
||||||
LIST_HEAD(struct big_files_offset);
|
LIST_HEAD(struct files_offset);
|
||||||
int begin;
|
int begin;
|
||||||
int end;
|
int end;
|
||||||
};
|
};
|
||||||
@ -915,7 +915,7 @@ check_boundary(struct string *data, struct boundary_info *boundary)
|
|||||||
static void
|
static void
|
||||||
encode_multipart(struct session *ses, LIST_OF(struct submitted_value) *l,
|
encode_multipart(struct session *ses, LIST_OF(struct submitted_value) *l,
|
||||||
struct string *data, struct boundary_info *boundary,
|
struct string *data, struct boundary_info *boundary,
|
||||||
LIST_OF(struct big_files_offset) *bfs, int cp_from, int cp_to)
|
LIST_OF(struct files_offset) *bfs, int cp_from, int cp_to)
|
||||||
{
|
{
|
||||||
struct conv_table *convert_table = NULL;
|
struct conv_table *convert_table = NULL;
|
||||||
struct submitted_value *sv;
|
struct submitted_value *sv;
|
||||||
@ -973,7 +973,7 @@ encode_multipart(struct session *ses, LIST_OF(struct submitted_value) *l,
|
|||||||
|
|
||||||
if (*sv->value) {
|
if (*sv->value) {
|
||||||
unsigned char *filename;
|
unsigned char *filename;
|
||||||
struct big_files_offset *bfs_new;
|
struct files_offset *bfs_new;
|
||||||
|
|
||||||
if (get_cmd_opt_bool("anonymous")) {
|
if (get_cmd_opt_bool("anonymous")) {
|
||||||
errno = EPERM;
|
errno = EPERM;
|
||||||
@ -993,9 +993,9 @@ encode_multipart(struct session *ses, LIST_OF(struct submitted_value) *l,
|
|||||||
goto encode_error;
|
goto encode_error;
|
||||||
}
|
}
|
||||||
bfs_new->begin = data->length;
|
bfs_new->begin = data->length;
|
||||||
add_char_to_string(data, BIG_FILE_CHAR);
|
add_char_to_string(data, FILE_CHAR);
|
||||||
add_to_string(data, filename);
|
add_to_string(data, filename);
|
||||||
add_char_to_string(data, BIG_FILE_CHAR);
|
add_char_to_string(data, FILE_CHAR);
|
||||||
bfs_new->end = data->length;
|
bfs_new->end = data->length;
|
||||||
add_to_list_end(*bfs, bfs_new);
|
add_to_list_end(*bfs, bfs_new);
|
||||||
mem_free(filename);
|
mem_free(filename);
|
||||||
@ -1151,7 +1151,7 @@ get_form_uri(struct session *ses, struct document_view *doc_view,
|
|||||||
{
|
{
|
||||||
struct boundary_info boundary;
|
struct boundary_info boundary;
|
||||||
INIT_LIST_OF(struct submitted_value, submit);
|
INIT_LIST_OF(struct submitted_value, submit);
|
||||||
INIT_LIST_OF(struct big_files_offset, bfs);
|
INIT_LIST_OF(struct files_offset, bfs);
|
||||||
struct string data;
|
struct string data;
|
||||||
struct string go;
|
struct string go;
|
||||||
int cp_from, cp_to;
|
int cp_from, cp_to;
|
||||||
@ -1267,7 +1267,7 @@ get_form_uri(struct session *ses, struct document_view *doc_view,
|
|||||||
add_to_string(&go, p);
|
add_to_string(&go, p);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct big_files_offset *b;
|
struct files_offset *b;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
foreach (b, bfs) {
|
foreach (b, bfs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user