mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Gradual rendering in pager mode. ELinks is almost as good as less.
TODO: cg-log -c | elinks
This commit is contained in:
parent
6ead4e9c65
commit
c283f8cfd9
@ -316,15 +316,8 @@ read_encoded_file(struct string *filename, struct string *page)
|
||||
encoding = guess_encoding(filename->source);
|
||||
}
|
||||
|
||||
if (fd == -1) {
|
||||
#ifdef HAVE_SYS_CYGWIN_H
|
||||
/* There is no /dev/stdin on Cygwin. */
|
||||
if (!strlcmp(filename->source, filename->length, "/dev/stdin", 10)) {
|
||||
fd = STDIN_FILENO;
|
||||
} else
|
||||
#endif
|
||||
if (fd == -1)
|
||||
return state;
|
||||
}
|
||||
|
||||
/* Some file was opened so let's get down to bi'ness */
|
||||
set_bin(fd);
|
||||
|
@ -25,9 +25,12 @@
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/module.h"
|
||||
#include "network/connection.h"
|
||||
#include "network/socket.h"
|
||||
#include "osdep/osdep.h"
|
||||
#include "protocol/common.h"
|
||||
#include "protocol/file/cgi.h"
|
||||
#include "protocol/file/file.h"
|
||||
#include "protocol/http/http.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "util/conv.h"
|
||||
#include "util/file.h"
|
||||
@ -201,6 +204,29 @@ list_directory(struct connection *conn, unsigned char *dirpath,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
read_special(struct connection *conn, int fd)
|
||||
{
|
||||
struct read_buffer *rb;
|
||||
|
||||
if (!init_http_connection_info(conn, 1, 0, 1)) {
|
||||
abort_connection(conn, S_OUT_OF_MEM);
|
||||
return;
|
||||
}
|
||||
set_nonblocking_fd(fd);
|
||||
conn->socket->fd = fd;
|
||||
rb = alloc_read_buffer(conn->socket);
|
||||
if (!rb) {
|
||||
abort_connection(conn, S_OUT_OF_MEM);
|
||||
return;
|
||||
}
|
||||
memcpy(rb->data, "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\n", 45);
|
||||
rb->length = 45;
|
||||
rb->freespace -= 45;
|
||||
|
||||
conn->socket->state = SOCKET_END_ONCLOSE;
|
||||
read_from_socket(conn->socket, rb, S_SENT, http_got_header);
|
||||
}
|
||||
|
||||
/* To reduce redundant error handling code [calls to abort_connection()]
|
||||
* most of the function is build around conditions that will assign the error
|
||||
@ -256,6 +282,20 @@ file_protocol_handler(struct connection *connection)
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!strcmp(name.source, "/dev/stdin")) {
|
||||
done_string(&name);
|
||||
read_special(connection, STDIN_FILENO);
|
||||
return;
|
||||
}
|
||||
if (!strncmp(name.source, "/dev/fd/", 8)) {
|
||||
int fd = atoi(name.source + 8);
|
||||
|
||||
if (fd > 0) {
|
||||
done_string(&name);
|
||||
read_special(connection, fd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
state = read_encoded_file(&name, &page);
|
||||
/* FIXME: If state is now S_ENCODE_ERROR we should try loading
|
||||
* the file undecoded. --jonas */
|
||||
|
Loading…
Reference in New Issue
Block a user