1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-27 02:56:18 -04:00

Merge branch 'elinks-0.12' into elinks-0.13

Conflicts:

	src/network/connection.h
	src/session/download.c
	src/session/download.h
This commit is contained in:
Kalle Olavi Niemitalo 2008-06-15 21:43:08 +03:00 committed by Kalle Olavi Niemitalo
commit 5b6c913c6a
14 changed files with 41 additions and 140 deletions

6
NEWS
View File

@ -139,8 +139,6 @@ Miscellaneous:
* trivial bug 930: refresh status bar when key prefix is eaten
* trivial bug 776: ``elinks -remote http://elinks.cz/'' no longer clears
the screen
* enhancement 121: if a mailcap entry indicates 'copiousoutput', ELinks
itself acts as a pager
* enhancement 790: If-Modified-Since and If-None-Match
* enhancement: HTTP negotiate-auth using GSSAPI
* enhancement: FSP progress indicator and password prompt
@ -274,6 +272,8 @@ have already been considered.
not sorted
- (bugfix 968) assertion width > 0 failed in copy_chars called from
justify_line
- bug 1015: incompatible pointer type for PyString_AsStringAndSize
- bug 917: Going to unopened /dev/fd/ kills select_loop
* Already backported to a previous release but not listed there:
- (enhancement) Activate link only when onClick returns true.
Fixed bug 786 in ELinks 0.11.2.
@ -304,6 +304,8 @@ have already been considered.
2a6125e3d0407b588eb286d4d0ff5c98c23ebda9
- (enhancement) Support for pasting from GNU screen clipboard,
reverted in 763f03f146cc1391b303c8074556f0ddea1e3c7a
- enhancement 121: if a mailcap entry indicates 'copiousoutput',
ELinks itself acts as a pager
* Unimportant changes:
- (enhancement) If select fails, save its errno.
- (bugfix) Use PF_* instead of AF_* as first parameter of socket(2).

View File

@ -307,8 +307,15 @@ read_encoded_file(struct string *filename, struct string *page)
encoding = guess_encoding(filename->source);
}
if (fd == -1)
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
return state;
}
/* Some file was opened so let's get down to bi'ness */
set_bin(fd);

View File

@ -545,7 +545,7 @@ format_command(unsigned char *command, unsigned char *type, int copiousoutput)
break;
}
}
#if 0
if (copiousoutput) {
unsigned char *pager = getenv("PAGER");
@ -562,7 +562,7 @@ format_command(unsigned char *command, unsigned char *type, int copiousoutput)
add_to_string(&cmd, pager);
}
}
#endif
return cmd.source;
}
@ -768,7 +768,6 @@ get_mime_handler_mailcap(unsigned char *type, int xwin)
handler = init_mime_handler(program, entry->description,
mailcap_mime_module.name,
get_mailcap_ask(), block);
if (handler) handler->copiousoutput = entry->copiousoutput;
mem_free(program);
return handler;

View File

@ -52,7 +52,7 @@ program: view %
type: application/postscript
block: 1
program: ps2ascii %
program: ps2ascii %|copiousoutput_handler
type: application/foo
EOF

View File

@ -11,7 +11,6 @@ struct mime_handler {
unsigned char *backend_name;
unsigned int ask:1;
unsigned int block:1;
unsigned int copiousoutput:1;
unsigned char program[1]; /* XXX: Keep last! */
};

View File

@ -4,7 +4,6 @@
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
@ -405,25 +404,6 @@ shutdown_connection_stream(struct connection *conn)
conn->stream_pipes[0] = conn->stream_pipes[1] = -1;
}
static void
close_popen(int fd)
{
struct popen_data *pop;
foreach (pop, copiousoutput_data) {
if (pop->fd == fd) {
del_from_list(pop);
fclose(pop->stream);
if (pop->filename) {
unlink(pop->filename);
mem_free(pop->filename);
}
mem_free(pop);
break;
}
}
}
static void
free_connection_data(struct connection *conn)
{
@ -444,7 +424,6 @@ free_connection_data(struct connection *conn)
if (conn->done)
conn->done(conn);
if (conn->popen) close_popen(conn->socket->fd);
done_socket(conn->socket);
done_socket(conn->data_socket);

View File

@ -66,7 +66,6 @@ struct connection {
unsigned int running:1;
unsigned int unrestartable:1;
unsigned int detached:1;
unsigned int popen:1;
unsigned int cgi:1;
/* Each document is downloaded with some priority. When downloading a
@ -84,16 +83,6 @@ struct connection {
void *info;
};
struct popen_data {
LIST_HEAD(struct popen_data);
int fd;
FILE *stream;
unsigned char *filename;
};
extern LIST_OF(struct popen_data) copiousoutput_data;
int register_check_queue(void);
int get_connections_count(void);

View File

@ -276,8 +276,7 @@ send_bittorrent_tracker_request(struct connection *conn)
struct bittorrent_connection *bittorrent = conn->info;
/* Kill the timer when we are not sending a periodic request to make
* sure that there are only one tracker request at any time. Besides
* it is not possible to call kill_timer() from a timer handler. */
* sure that there are only one tracker request at any time. */
kill_timer(&bittorrent->tracker.timer);
do_send_bittorrent_tracker_request(conn);

View File

@ -25,12 +25,10 @@
#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"
@ -206,30 +204,6 @@ 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;
}
conn->socket->fd = fd;
if (fd != STDIN_FILENO) conn->popen = 1;
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->unrestartable = 1;
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
@ -288,20 +262,6 @@ 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 */

View File

@ -6,6 +6,19 @@
#include "config.h"
#endif
/* PyString_AsStringAndSize() takes a Py_ssize_t * in Python 2.5 but
* an int * in Python 2.4. To be compatible with both, ELinks uses
* Py_ssize_t and defines it here if necessary. The public-domain
* PEP 353 <http://www.python.org/dev/peps/pep-0353/> suggests the
* following snippet, so we can use the Py_ssize_t name even though
* Python generally reserves names starting with "Py_". */
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#endif
/* End of PEP 353 snippet. */
struct module;
extern struct session *python_ses;

View File

@ -103,11 +103,16 @@ script_hook_pre_format_html(va_list ap, void *data)
if (result != Py_None) {
unsigned char *str;
int len;
Py_ssize_t len;
if (PyString_AsStringAndSize(result, (char **) &str, &len) != 0)
goto error;
/* This assumes the Py_ssize_t len is not too large to
* fit in the off_t parameter of normalize_cache_entry().
* add_fragment() itself seems to assume the same thing,
* and there is no standard OFF_MAX macro against which
* ELinks could check the value. */
(void) add_fragment(cached, 0, str, len);
normalize_cache_entry(cached, len);
}

View File

@ -79,7 +79,8 @@ python_menu(PyObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *items;
enum python_menu_type menu_type = PYTHON_MENU_DEFAULT;
int length, i;
Py_ssize_t length;
int i;
struct menu_item *menu;
struct memory_list *ml = NULL;
static char *kwlist[] = {"items", "type", NULL};
@ -104,7 +105,7 @@ python_menu(PyObject *self, PyObject *args, PyObject *kwargs)
return NULL;
}
length = PySequence_Length(items);
if (length == -1) return NULL;
if (length == -1 || length > INT_MAX) return NULL;
else if (length == 0) goto success;
if (menu_type < 0 || menu_type >= PYTHON_MENU_MAX) {

View File

@ -32,7 +32,6 @@
#include "dialogs/menu.h"
#include "intl/gettext/libintl.h"
#include "main/object.h"
#include "main/select.h"
#include "mime/mime.h"
#include "network/connection.h"
#include "network/progress.h"
@ -65,8 +64,6 @@
INIT_LIST_OF(struct file_download, downloads);
INIT_LIST_OF(struct popen_data, copiousoutput_data);
int
download_is_progressing(struct download *download)
{
@ -304,33 +301,6 @@ abort_download_and_beep(struct file_download *file_download, struct terminal *te
abort_download(file_download);
}
static void
read_from_popen(struct session *ses, unsigned char *handler, unsigned char *filename)
{
FILE *stream = popen(handler, "r");
if (stream) {
int fd = fileno(stream);
if (fd > 0) {
unsigned char buf[48];
struct popen_data *data = mem_calloc(1, sizeof(*data));
if (!data) {
fclose(stream);
return;
}
data->fd = fd;
data->stream = stream;
if (filename) data->filename = stracpy(filename);
add_to_list(copiousoutput_data, data);
snprintf(buf, sizeof(buf), "file:///dev/fd/%d", fd);
goto_url(ses, buf);
}
}
}
static void
download_data_store(struct download *download, struct file_download *file_download)
{
@ -368,15 +338,9 @@ download_data_store(struct download *download, struct file_download *file_downlo
prealloc_truncate(file_download->handle, file_download->seek);
close(file_download->handle);
file_download->handle = -1;
if (file_download->copiousoutput) {
read_from_popen(file_download->ses,
file_download->external_handler,
file_download->file);
} else {
exec_on_terminal(term, file_download->external_handler,
exec_on_terminal(term, file_download->external_handler,
file_download->file,
file_download->block ? TERM_EXEC_FG : TERM_EXEC_BG);
}
file_download->delete = 0;
abort_download_and_beep(file_download, term);
return;
@ -910,7 +874,6 @@ continue_download_do(struct terminal *term, int fd, void *data, download_flags_T
file_download->external_handler = subst_file(type_query->external_handler,
codw_hop->file);
file_download->delete = 1;
file_download->copiousoutput = type_query->copiousoutput;
mem_free(codw_hop->file);
mem_free_set(&type_query->external_handler, NULL);
}
@ -1085,7 +1048,6 @@ tp_display(struct type_query *type_query)
done_type_query(type_query);
}
static void
tp_open(struct type_query *type_query)
{
@ -1105,10 +1067,7 @@ tp_open(struct type_query *type_query)
}
if (handler) {
if (type_query->copiousoutput)
read_from_popen(type_query->ses, handler, NULL);
else
exec_on_terminal(type_query->ses->tab->term,
exec_on_terminal(type_query->ses->tab->term,
handler, "",
type_query->block ? TERM_EXEC_FG : TERM_EXEC_BG);
mem_free(handler);
@ -1214,13 +1173,7 @@ do_type_query(struct type_query *type_query, unsigned char *ct, struct mime_hand
0, 0, NULL, MAX_STR_LEN, field, NULL);
type_query->external_handler = field;
if (type_query->copiousoutput) {
add_dlg_text(dlg, _("The output of the program "
"will be shown in the tab", term),
ALIGN_LEFT, 0);
} else {
add_dlg_radio(dlg, _("Block the terminal", term), 0, 0, &type_query->block);
}
add_dlg_radio(dlg, _("Block the terminal", term), 0, 0, &type_query->block);
selected_widget = 3;
} else if (handler) {
@ -1345,7 +1298,6 @@ setup_download_handler(struct session *ses, struct download *loading,
type_query = init_type_query(ses, loading, cached);
if (type_query) {
ret = 1;
if (handler) type_query->copiousoutput = handler->copiousoutput;
#ifdef CONFIG_BITTORRENT
/* A terrible waste of a good MIME handler here, but we want
* to use the type_query this is easier. */

View File

@ -55,7 +55,6 @@ struct type_query {
unsigned char *target_frame;
unsigned char *external_handler;
int block;
unsigned int copiousoutput:1;
unsigned int cgi:1;
/* int frame; */
};
@ -84,9 +83,6 @@ struct file_download {
/** Whether to block the terminal when running the external handler. */
unsigned int block:1;
/** Whether copiousoutput mode is used by the mailcap entry */
unsigned int copiousoutput:1;
/** The current dialog for this download. Can be NULL. */
struct dialog_data *dlg_data;
struct listbox_item *box_item;