Classes | |
struct | nntp_groupdesc |
NNTP group descriptor. More... | |
struct | nntp_grouplabel |
NNTP group label (description string) More... | |
Macros | |
#define | NNTP_ANUM_T_MAX ULONG_MAX |
Maximum value this implementation supports for nntp_anum_t. More... | |
#define | MAIN_ERR_PREFIX "NNTP: " |
Message prefix for NNTP module. More... | |
#define | NNTP_HANDLEMAX 1U |
Maximum number of simultaneous NNTP connections. More... | |
#define | NNTP_LINELENGTHMAX (size_t) 512 |
Maximum line length (for command/response, not payload) More... | |
Typedefs | |
typedef unsigned long int | nntp_anum_t |
Article number. More... | |
Functions | |
int | nntp_open (int *handle, const char *servername, const char *service, const char *logfile, int enc, int auth,...) |
Open connection to NNTP server. More... | |
void | nntp_close (int *handle, unsigned int flags) |
Disconnect from NNTP server. More... | |
int | nntp_get_capa_list_motd (int handle) |
Get message of the day capability of NNTP server. More... | |
int | nntp_get_motd (int handle, char **data, size_t *len) |
Get message of the day. More... | |
int | nntp_get_distrib_pats (int handle, const char **data, size_t *len) |
Get distribution patterns. More... | |
int | nntp_get_capa_list_subscriptions (int handle) |
Get message of the day capability of NNTP server. More... | |
int | nntp_get_subscriptions (int handle, char **data, size_t *len) |
Get subscription proposals. More... | |
struct nntp_groupdesc * | nntp_group_descriptor_constructor (const char *name) |
Allocate and initialize a descriptor for group. More... | |
int | nntp_get_grouplist (int handle, size_t *groupcount, struct nntp_groupdesc **p) |
Get group list. More... | |
int | nntp_get_group_labels (int handle, size_t *groupcount, struct nntp_grouplabel **p) |
Get additional group information. More... | |
int | nntp_set_group (int handle, const char *name, struct nntp_groupdesc **gd) |
Set current group. More... | |
int | nntp_get_capa_over (int handle) |
Get overview capability of NNTP server. More... | |
int | nntp_get_overview (int handle, nntp_anum_t first, nntp_anum_t last, char **data, size_t *len) |
Get overview for article range. More... | |
int | nntp_get_article_by_mid (int handle, const char *mid, char **article, size_t *len) |
Get complete article via Message-ID. More... | |
int | nntp_get_article (int handle, const nntp_anum_t *id, char **article, size_t *len) |
Get complete article. More... | |
int | nntp_get_article_header (int handle, const nntp_anum_t *id, char **header, size_t *len) |
Get article header. More... | |
int | nntp_get_article_body (int handle, const nntp_anum_t *id, char **body, size_t *len) |
Get article body. More... | |
int | nntp_post_article (int handle, const char *article) |
Post article. More... | |
Connection closing flags | |
#define | NNTP_CLOSE_NOQUIT 1U |
Newsgroup flags | |
#define | NNTP_GROUP_FLAG_ASCII 0x01U |
#define | NNTP_GROUP_FLAG_PA 0x02U |
NNTP capabilities | |
The flags can be bitwise ORed together. | |
#define | NNTP_CAPA_MODE_READER 0x0001U |
#define | NNTP_CAPA_READER 0x0002U |
#define | NNTP_CAPA_LIST 0x0004U |
#define | NNTP_CAPA_LIST_MOTD 0x0008U |
#define | NNTP_CAPA_LIST_DISTRIB_PATS 0x0010U |
#define | NNTP_CAPA_LIST_SUBSCRIPTIONS 0x0020U |
#define | NNTP_CAPA_OVER 0x0040U |
#define | NNTP_CAPA_POST 0x0080U |
#define | NNTP_CAPA_AUTHINFO_USER 0x0100U |
#define | NNTP_CAPA_COMPRESS 0x0200U |
Algorithms for NNTP compression extension | |
The flags can be bitwise ORed together. | |
#define | NNTP_COMPRESS_DEFLATE 0x0001U |
This transport subsystem should behave RFC 1951, RFC 977, RFC 2980, RFC 3977, RFC 4643 and RFC 6048 conformant.
Secure NNTPS connections can be requested if TLS support is available.
The AUTHINFO USER/PASS extension from RFC 4643 is supported if TLS support is available. The AUTHINFO SASL extension from RFC 4643 is not supported.
Compression support is used according to RFC 8054. Compression is used if advertised by the server (with COMPRESS capability), the required local libraries (e.g. zlib for DEFLATE algorithm) are available and compression isn't disabled by configuration (CONF_COMPRESSION parameter).
RFC 3977 allows non-ASCII encoded group names, but recommend not to use them. They are supported nevertheless by this transport driver
#define MAIN_ERR_PREFIX "NNTP: " |
#define NNTP_ANUM_T_MAX ULONG_MAX |
Maximum value this implementation supports for nntp_anum_t.
#define NNTP_CLOSE_NOQUIT 1U |
#define NNTP_GROUP_FLAG_ASCII 0x01U |
#define NNTP_HANDLEMAX 1U |
#define NNTP_LINELENGTHMAX (size_t) 512 |
typedef unsigned long int nntp_anum_t |
Article number.
RFC 3977 requires at least 31 bit storage for article numbers. The constant NNTP_ANUM_T_MAX must be set to the maximum value that is supported by this implementation. According to RFC 3977, article number zero is reserved.
void nntp_close | ( | int * | handle, |
unsigned int | flags | ||
) |
Disconnect from NNTP server.
[in,out] | handle | Pointer to server descriptor |
[in] | flags | Control flags (use NNTP_CLOSE_xxx constants) |
Definition at line 2042 of file nntp.c.
References NNTP_CLOSE_NOQUIT.
int nntp_get_article | ( | int | handle, |
const nntp_anum_t * | id, | ||
char ** | article, | ||
size_t * | len | ||
) |
Get complete article.
[in] | handle | Server descriptor |
[in] | id | Pointer to article identifier |
[out] | article | Pointer to article buffer pointer |
[out] | len | Pointer to article buffer size |
On success, a pointer to the article buffer is written to article and the caller is responsible to free the associated memory. The size of this buffer is written to len .
int nntp_get_article_body | ( | int | handle, |
const nntp_anum_t * | id, | ||
char ** | body, | ||
size_t * | len | ||
) |
Get article body.
[in] | handle | Server descriptor |
[in] | id | Pointer to article identifier |
[out] | body | Pointer to article body buffer pointer |
[out] | len | Pointer to article body buffer size |
On success, a pointer to the article body buffer is written to body and the caller is responsible to free the associated memory. The size of this buffer is written to len .
int nntp_get_article_by_mid | ( | int | handle, |
const char * | mid, | ||
char ** | article, | ||
size_t * | len | ||
) |
Get complete article via Message-ID.
[in] | handle | Server descriptor |
[in] | mid | Pointer to article Message-ID |
[out] | article | Pointer to article buffer pointer |
[out] | len | Pointer to article buffer size |
On success, a pointer to the article buffer is written to article and the caller is responsible to free the associated memory. The size of this buffer is written to len .
int nntp_get_article_header | ( | int | handle, |
const nntp_anum_t * | id, | ||
char ** | header, | ||
size_t * | len | ||
) |
Get article header.
[in] | handle | Server descriptor |
[in] | id | Pointer to article identifier |
[out] | header | Pointer to article header buffer pointer |
[out] | len | Pointer to article header buffer size |
On success, a pointer to the article header buffer is written to header and the caller is responsible to free the associated memory. The size of this buffer is written to len .
int nntp_get_capa_list_motd | ( | int | handle | ) |
Get message of the day capability of NNTP server.
[in] | handle | Server descriptor |
This function will trigger no communication with the server. It simply reports the currently buffered state for the server associated with handle .
LIST
MOTD capability flag (nonzero if capability is available) int nntp_get_capa_list_subscriptions | ( | int | handle | ) |
Get message of the day capability of NNTP server.
[in] | handle | Server descriptor |
This function will trigger no communication with the server. It simply reports the currently buffered state for the server associated with handle .
LIST
SUBSCRIPTIONS capability flag (nonzero if capability is available) int nntp_get_capa_over | ( | int | handle | ) |
Get overview capability of NNTP server.
[in] | handle | Server descriptor |
This function will trigger no communication with the server. It simply reports the currently buffered state for the server associated with handle .
OVER
capability flag (nonzero if this capability is available) int nntp_get_distrib_pats | ( | int | handle, |
const char ** | data, | ||
size_t * | len | ||
) |
Get distribution patterns.
This option is defined in RFC 3977.
[in] | handle | Server descriptor |
[out] | data | Pointer to pattern data buffer |
[out] | len | Pointer to buffer size |
NULL
for len if the caller is not interested in this value.This function will trigger no communication with the server. On success it returns a pointer to the currently buffered data for the server associated with handle that was retrieved while opening the connection.
Definition at line 2205 of file nntp.c.
References data.
Referenced by core_get_distribution().
int nntp_get_group_labels | ( | int | handle, |
size_t * | groupcount, | ||
struct nntp_grouplabel ** | p | ||
) |
Get additional group information.
[in] | handle | Server descriptor |
[out] | groupcount | Pointer to number of groups |
[out] | p | Pointer to array of group descriptors |
On success, the caller is responsible for releasing the memory allocated for the array p .
NULL
.int nntp_get_grouplist | ( | int | handle, |
size_t * | groupcount, | ||
struct nntp_groupdesc ** | p | ||
) |
Get group list.
[in] | handle | Server descriptor |
[out] | groupcount | Pointer to number of groups |
[out] | p | Pointer to array of group descriptors |
On success, the caller is responsible for releasing the memory allocated for the array p .
NULL
.int nntp_get_motd | ( | int | handle, |
char ** | data, | ||
size_t * | len | ||
) |
Get message of the day.
This option is defined in RFC 6048.
[in] | handle | Server descriptor |
[out] | data | Pointer to MOTD data buffer pointer |
[out] | len | Pointer to buffer size |
On success, the caller is responsible for releasing the memory allocated for the array data .
int nntp_get_overview | ( | int | handle, |
nntp_anum_t | first, | ||
nntp_anum_t | last, | ||
char ** | data, | ||
size_t * | len | ||
) |
Get overview for article range.
[in] | handle | Server descriptor |
[in] | first | First article identifier of range |
[in] | last | Last article identifier of range |
[out] | data | Pointer to overview data buffer pointer |
[out] | len | Pointer to article buffer size |
On success, a pointer to the overview data buffer is written to data and the caller is responsible to free the associated memory. The size of this buffer is written to len .
int nntp_get_subscriptions | ( | int | handle, |
char ** | data, | ||
size_t * | len | ||
) |
Get subscription proposals.
This option is defined in RFC 6048.
[in] | handle | Server descriptor |
[out] | data | Pointer to subscriptions data buffer pointer |
[out] | len | Pointer to buffer size |
On success, the caller is responsible for releasing the memory allocated for the array data .
struct nntp_groupdesc * nntp_group_descriptor_constructor | ( | const char * | name | ) |
Allocate and initialize a descriptor for group.
[in] | name | Group name |
An empty group descriptor is created and name is copied behind this descriptor so that the whole object can be destroyed as a single memory block.
On success, the caller is responsible to destroy the allocated object.
Definition at line 2332 of file nntp.c.
References nntp_groupdesc::name.
int nntp_open | ( | int * | handle, |
const char * | servername, | ||
const char * | service, | ||
const char * | logfile, | ||
int | enc, | ||
int | auth, | ||
... | |||
) |
Open connection to NNTP server.
[out] | handle | Pointer to server descriptor |
[in] | servername | Server name or address string |
[in] | service | Service name or port |
[in] | logfile | Logfile name |
[in] | enc | Encryption algorithm ID (for connection) |
[in] | auth | Authentication algorithm ID (client against server) |
servername must be an IPv4 address in dotted decimal representation, an IPv6 address in colon separated hexadecimal representation or a hostname that can be resolved to an IPv4 address via DNS.
service must be a valid service name like nntp
or nntps
or it must be the target TCP port on which the NNTP or NNTPS service is listening. The default value is 119 (or 563 for NNTP over TLS respectively).
If logfile is NULL
then log data is redirected to /dev/null
.
This function handles optional encryption for the connection to the server if enc is nonzero. The following encryption algorithms are supported:
This function handles optional authentication of the client against the server if auth is nonzero. The following authentication algorithms are supported:
int
that indicates whether authentication should be done immediately. const
char*
that specify username and password as plain text. Both strings are copied and the pointers are not required to stay valid after this function returns.Definition at line 1777 of file nntp.c.
References PRINT_ERROR.
int nntp_post_article | ( | int | handle, |
const char * | article | ||
) |
Post article.
[in] | handle | Server descriptor |
[in] | article | Pointer to article buffer |
article must point to a RFC 5536 conformant article in canonical form. The caller is responsible for the validity check of the article format.
int nntp_set_group | ( | int | handle, |
const char * | name, | ||
struct nntp_groupdesc ** | gd | ||
) |
Set current group.
[in] | handle | Server descriptor |
[in] | name | Group name |
[out] | gd | Pointer to group descriptor |
On success and if gd is not NULL
, a pointer to an initialized group descriptor for the group specified by name is written to gd . The caller is responsible for releasing the memory allocated for this group descriptor.