2005-09-15 09:58:31 -04:00
|
|
|
/* Network news transport protocol implementation (RFC 977 and 2980) */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "elinks.h"
|
|
|
|
|
|
|
|
#include "config/options.h"
|
2021-08-08 15:25:08 -04:00
|
|
|
#include "intl/libintl.h"
|
2005-09-15 09:58:31 -04:00
|
|
|
#include "main/module.h"
|
|
|
|
#include "protocol/nntp/nntp.h"
|
|
|
|
|
|
|
|
/* The official color for this planet is green,
|
|
|
|
* which grows in pockets of them people willing to scheme. --delasoul */
|
|
|
|
|
|
|
|
#define NNTP_HEADER_ENTRIES "Subject,From,Date,Message-ID,Newsgroups"
|
|
|
|
|
|
|
|
/* Module and option stuff: */
|
|
|
|
|
|
|
|
enum nntp_protocol_option {
|
|
|
|
NNTP_PROTOCOL_TREE,
|
|
|
|
|
|
|
|
NNTP_PROTOCOL_SERVER,
|
|
|
|
NNTP_PROTOCOL_HEADER_ENTRIES,
|
|
|
|
|
|
|
|
NNTP_PROTOCOL_OPTIONS,
|
|
|
|
};
|
|
|
|
|
bug 764: Initialize the right member of union option_value
INIT_OPTION used to initialize union option_value at compile time by
casting the default value to LIST_OF(struct option) *, which is the
type of the first member. On sparc64 and other big-endian systems
where sizeof(int) < sizeof(struct list_head *), this tended to leave
option->value.number as zero, thus messing up OPT_INT and OPT_BOOL
at least. OPT_LONG however tended to work right.
This would be easy to fix with C99 designated initializers,
but doc/hacking.txt says ELinks must be kept C89 compatible.
Another solution would be to make register_options() read the
value from option->value.tree (the first member), cast it back
to the right type, and write it to the appropriate member;
but that would still require somewhat dubious conversions
between integers, data pointers, and function pointers.
So here's a rather more invasive solution. Add struct option_init,
which is somewhat similar to struct option but has non-overlapping
members for different types of values, to ensure nothing is lost
in compile-time conversions. Move unsigned char *path from struct
option_info to struct option_init, and replace struct option_info
with a union that contains struct option_init and struct option.
Now, this union can be initialized with no portability problems,
and register_options() then moves the values from struct option_init
to their final places in struct option.
In my x86 ELinks build with plenty of options configured in, this
change bloated the text section by 340 bytes but compressed the data
section by 2784 bytes, presumably because union option_info is a
pointer smaller than struct option_info was.
(cherry picked from elinks-0.12 commit e5f6592ee20780a61f70feeb1f9e17631b9c5835)
Conflicts:
src/protocol/fsp/fsp.c: All options had been removed in 0.13.GIT.
src/protocol/smb/smb2.c: Ditto.
2009-08-15 15:39:07 -04:00
|
|
|
static union option_info nntp_protocol_options[] = {
|
2005-09-15 09:58:31 -04:00
|
|
|
INIT_OPT_TREE("protocol", N_("NNTP"),
|
2022-01-15 14:10:37 -05:00
|
|
|
"nntp", OPT_ZERO,
|
2005-09-15 09:58:31 -04:00
|
|
|
N_("NNTP and news specific options.")),
|
|
|
|
|
|
|
|
INIT_OPT_STRING("protocol.nntp", N_("Default news server"),
|
2022-01-15 14:10:37 -05:00
|
|
|
"server", OPT_ZERO, "",
|
Rewrap lines in option documentation.
Documentation strings of most options used to contain a "\n" at the
end of each source line. When the option manager displayed these
strings, it treated each "\n" as a hard newline. On 80x24 terminals
however, the option description window has only 60 columes available
for the text (with the default setup.h), and the hard newlines were
further apart, so the option manager wrapped the text a second time,
resulting in rather ugly output where long lones are interleaved with
short ones. This could also cause the text to take up too much
vertical space and not fit in the window.
Replace most of those hard newlines with spaces so that the option
manager (or perhaps BFU) will take care of the wrapping. At the same
time, rewrap the strings in source code so that the source lines are
at most 79 columns wide.
In some options though, there is a list of possible values and their
meanings. In those lists, if the description of one value does not
fit in one line, then continuation lines should be indented. The
option manager and BFU are not currently able to do that. So, keep
the hard newlines in those lists, but rewrap them to 60 columns so
that they are less likely to require further wrapping at runtime.
2009-03-07 13:48:38 -05:00
|
|
|
N_("Used when resolving news: URIs. "
|
|
|
|
"If set to the empty string the value of the NNTPSERVER "
|
|
|
|
"environment variable will be used.")),
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
INIT_OPT_STRING("protocol.nntp", N_("Message header entries"),
|
2022-01-15 14:10:37 -05:00
|
|
|
"header_entries", OPT_ZERO, NNTP_HEADER_ENTRIES,
|
Rewrap lines in option documentation.
Documentation strings of most options used to contain a "\n" at the
end of each source line. When the option manager displayed these
strings, it treated each "\n" as a hard newline. On 80x24 terminals
however, the option description window has only 60 columes available
for the text (with the default setup.h), and the hard newlines were
further apart, so the option manager wrapped the text a second time,
resulting in rather ugly output where long lones are interleaved with
short ones. This could also cause the text to take up too much
vertical space and not fit in the window.
Replace most of those hard newlines with spaces so that the option
manager (or perhaps BFU) will take care of the wrapping. At the same
time, rewrap the strings in source code so that the source lines are
at most 79 columns wide.
In some options though, there is a list of possible values and their
meanings. In those lists, if the description of one value does not
fit in one line, then continuation lines should be indented. The
option manager and BFU are not currently able to do that. So, keep
the hard newlines in those lists, but rewrap them to 60 columns so
that they are less likely to require further wrapping at runtime.
2009-03-07 13:48:38 -05:00
|
|
|
N_("Comma separated list of which entries in the article "
|
|
|
|
"header to show. E.g. 'Subject' and 'From'. "
|
2005-09-15 09:58:31 -04:00
|
|
|
"All header entries can be read in the header info dialog.")),
|
|
|
|
|
|
|
|
NULL_OPTION_INFO,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define get_opt_nntp(which) nntp_protocol_options[(which)].option
|
|
|
|
|
2021-01-02 10:20:27 -05:00
|
|
|
char *
|
2005-09-15 09:58:31 -04:00
|
|
|
get_nntp_server(void)
|
|
|
|
{
|
|
|
|
return get_opt_nntp(NNTP_PROTOCOL_SERVER).value.string;
|
|
|
|
}
|
|
|
|
|
2021-01-02 10:20:27 -05:00
|
|
|
char *
|
2005-09-15 09:58:31 -04:00
|
|
|
get_nntp_header_entries(void)
|
|
|
|
{
|
|
|
|
return get_opt_nntp(NNTP_PROTOCOL_HEADER_ENTRIES).value.string;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct module nntp_protocol_module = struct_module(
|
|
|
|
/* name: */ N_("NNTP"),
|
|
|
|
/* options: */ nntp_protocol_options,
|
|
|
|
/* hooks: */ NULL,
|
|
|
|
/* submodules: */ NULL,
|
|
|
|
/* data: */ NULL,
|
|
|
|
/* init: */ NULL,
|
|
|
|
/* done: */ NULL
|
|
|
|
);
|