mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
DIRLIST:Use directory listing initializer in the Gopher protocol module
This commit is contained in:
parent
94f4b2fd1d
commit
ba2b6e633a
@ -62,6 +62,12 @@ init_directory_listing(struct string *page, struct uri *uri)
|
|||||||
&& !add_char_to_string(&dirpath, '/'))
|
&& !add_char_to_string(&dirpath, '/'))
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
|
if (uri->protocol == PROTOCOL_GOPHER) {
|
||||||
|
/* A little hack to get readable Gopher names. We should find a
|
||||||
|
* way to do it more general. */
|
||||||
|
decode_uri_string(&dirpath);
|
||||||
|
}
|
||||||
|
|
||||||
if (!local && !add_char_to_string(&location, '/'))
|
if (!local && !add_char_to_string(&location, '/'))
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
@ -81,15 +87,19 @@ init_directory_listing(struct string *page, struct uri *uri)
|
|||||||
if (!add_to_string(page, "\" />\n</head>\n<body>\n<h2>"))
|
if (!add_to_string(page, "\" />\n</head>\n<body>\n<h2>"))
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
|
/* Use module names? */
|
||||||
switch (uri->protocol) {
|
switch (uri->protocol) {
|
||||||
case PROTOCOL_FILE:
|
case PROTOCOL_FILE:
|
||||||
info = "Local";
|
info = "Local";
|
||||||
break;
|
break;
|
||||||
|
case PROTOCOL_FSP:
|
||||||
|
info = "FSP";
|
||||||
|
break;
|
||||||
case PROTOCOL_FTP:
|
case PROTOCOL_FTP:
|
||||||
info = "FTP";
|
info = "FTP";
|
||||||
break;
|
break;
|
||||||
case PROTOCOL_FSP:
|
case PROTOCOL_GOPHER:
|
||||||
info = "FSP";
|
info = "Gopher";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
info = "?";
|
info = "?";
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "main/module.h"
|
#include "main/module.h"
|
||||||
#include "network/connection.h"
|
#include "network/connection.h"
|
||||||
#include "network/socket.h"
|
#include "network/socket.h"
|
||||||
|
#include "protocol/common.h"
|
||||||
#include "protocol/gopher/gopher.h"
|
#include "protocol/gopher/gopher.h"
|
||||||
#include "protocol/protocol.h"
|
#include "protocol/protocol.h"
|
||||||
#include "protocol/uri.h"
|
#include "protocol/uri.h"
|
||||||
@ -599,25 +600,15 @@ read_gopher_directory_data(struct connection *conn, struct read_buffer *rb)
|
|||||||
struct string buffer;
|
struct string buffer;
|
||||||
unsigned char *end;
|
unsigned char *end;
|
||||||
|
|
||||||
if (!init_string(&buffer))
|
|
||||||
return S_OUT_OF_MEM;
|
|
||||||
|
|
||||||
if (conn->from == 0) {
|
if (conn->from == 0) {
|
||||||
unsigned char *where = get_uri_string(conn->uri, URI_PUBLIC);
|
enum connection_state state;
|
||||||
|
|
||||||
if (where) decode_uri_for_display(where);
|
state = init_directory_listing(&buffer, conn->uri);
|
||||||
|
if (state != S_OK)
|
||||||
|
return state;
|
||||||
|
|
||||||
add_format_to_string(&buffer,
|
} else if (!init_string(&buffer)) {
|
||||||
"<html>\n"
|
return S_OUT_OF_MEM;
|
||||||
"<head>\n"
|
|
||||||
"<title>Gopher menu at %s</title>\n"
|
|
||||||
"</head>\n"
|
|
||||||
"<body>\n"
|
|
||||||
"<h1>Gopher menu at %s</h1>\n"
|
|
||||||
"<pre>",
|
|
||||||
empty_string_or_(where), empty_string_or_(where));
|
|
||||||
|
|
||||||
mem_free_if(where);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((end = get_gopher_line_end(rb->data, rb->length))) {
|
while ((end = get_gopher_line_end(rb->data, rb->length))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user