Usenet network mailbox type; talk to an NNTP server. More...
#include "config.h"
#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include <unistd.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "conn/lib.h"
#include "lib.h"
#include "attach/lib.h"
#include "bcache/lib.h"
#include "hcache/lib.h"
#include "ncrypt/lib.h"
#include "progress/lib.h"
#include "question/lib.h"
#include "adata.h"
#include "edata.h"
#include "hook.h"
#include "mdata.h"
#include "mutt_logging.h"
#include "muttlib.h"
#include "mx.h"
#include "protos.h"
#include "mutt.h"
Go to the source code of this file.
Data Structures | |
struct | FetchCtx |
Keep track when getting data from a server. More... | |
struct | ChildCtx |
Keep track of the children of an article. More... | |
Functions | |
void | nntp_hashelem_free (int type, void *obj, intptr_t data) |
Free our hash table data - Implements hash_hdata_free_t -. | |
static int | nntp_connect_error (struct NntpAccountData *adata) |
Signal a failed connection. | |
static int | nntp_capabilities (struct NntpAccountData *adata) |
Get capabilities. | |
static int | nntp_attempt_features (struct NntpAccountData *adata) |
Detect supported commands. | |
static int | nntp_auth (struct NntpAccountData *adata) |
Get login, password and authenticate. | |
static int | nntp_query (struct NntpMboxData *mdata, char *line, size_t linelen) |
Send data from buffer and receive answer to same buffer. | |
static int | nntp_fetch_lines (struct NntpMboxData *mdata, char *query, size_t qlen, const char *msg, int(*func)(char *, void *), void *data) |
Read lines, calling a callback function for each. | |
static int | fetch_description (char *line, void *data) |
Parse newsgroup description. | |
static int | get_description (struct NntpMboxData *mdata, const char *wildmat, const char *msg) |
Fetch newsgroups descriptions. | |
static void | nntp_parse_xref (struct Mailbox *m, struct Email *e) |
Parse cross-reference. | |
static int | fetch_tempfile (char *line, void *data) |
Write line to temporary file. | |
static int | fetch_numbers (char *line, void *data) |
Parse article number. | |
static int | parse_overview_line (char *line, void *data) |
Parse overview line. | |
static int | nntp_fetch_headers (struct Mailbox *m, void *hc, anum_t first, anum_t last, bool restore) |
Fetch headers. | |
static int | nntp_group_poll (struct NntpMboxData *mdata, bool update_stat) |
Check newsgroup for new articles. | |
static enum MxStatus | check_mailbox (struct Mailbox *m) |
Check current newsgroup for new articles. | |
static int | nntp_date (struct NntpAccountData *adata, time_t *now) |
Get date and time from server. | |
static int | fetch_children (char *line, void *data) |
Parse XPAT line. | |
int | nntp_open_connection (struct NntpAccountData *adata) |
Connect to server, authenticate and get capabilities. | |
int | nntp_post (struct Mailbox *m, const char *msg) |
Post article. | |
int | nntp_active_fetch (struct NntpAccountData *adata, bool mark_new) |
Fetch list of all newsgroups from server. | |
int | nntp_check_new_groups (struct Mailbox *m, struct NntpAccountData *adata) |
Check for new groups/articles in subscribed groups. | |
int | nntp_check_msgid (struct Mailbox *m, const char *msgid) |
Fetch article by Message-ID. | |
int | nntp_check_children (struct Mailbox *m, const char *msgid) |
Fetch children of article with the Message-ID. | |
int | nntp_sort_unsorted (const struct Email *a, const struct Email *b, bool reverse) |
Restore the 'unsorted' order of emails - Implements sort_email_t -. | |
static bool | nntp_ac_owns_path (struct Account *a, const char *path) |
Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path() -. | |
static bool | nntp_ac_add (struct Account *a, struct Mailbox *m) |
Add a Mailbox to an Account - Implements MxOps::ac_add() -. | |
static enum MxOpenReturns | nntp_mbox_open (struct Mailbox *m) |
Open a Mailbox - Implements MxOps::mbox_open() -. | |
static enum MxStatus | nntp_mbox_check (struct Mailbox *m) |
Check for new mail - Implements MxOps::mbox_check() -. | |
static enum MxStatus | nntp_mbox_sync (struct Mailbox *m) |
Save changes to the Mailbox - Implements MxOps::mbox_sync() -. | |
static enum MxStatus | nntp_mbox_close (struct Mailbox *m) |
Close a Mailbox - Implements MxOps::mbox_close() -. | |
static bool | nntp_msg_open (struct Mailbox *m, struct Message *msg, struct Email *e) |
Open an email message in a Mailbox - Implements MxOps::msg_open() -. | |
static int | nntp_msg_close (struct Mailbox *m, struct Message *msg) |
Close an email - Implements MxOps::msg_close() -. | |
enum MailboxType | nntp_path_probe (const char *path, const struct stat *st) |
Is this an NNTP Mailbox? - Implements MxOps::path_probe() -. | |
static int | nntp_path_canon (struct Buffer *path) |
Canonicalise a Mailbox path - Implements MxOps::path_canon() -. | |
Variables | |
struct NntpAccountData * | CurrentNewsSrv = NULL |
Current news server. | |
static const char * | OverviewFmt |
Fields to get from server, if it supports the LIST OVERVIEW.FMT feature. | |
const struct MxOps | MxNntpOps |
NNTP Mailbox - Implements MxOps -. | |
Usenet network mailbox type; talk to an NNTP server.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file nntp.c.
|
static |
|
static |
Get capabilities.
adata | NNTP server |
-1 | Error, connection is closed |
0 | Mode is reader, capabilities set up |
1 | Need to switch to reader mode |
Definition at line 141 of file nntp.c.
|
static |
Detect supported commands.
adata | NNTP server |
0 | Success |
-1 | Failure |
Definition at line 260 of file nntp.c.
|
static |
Get login, password and authenticate.
adata | NNTP server |
0 | Success |
-1 | Failure |
Definition at line 452 of file nntp.c.
|
static |
Send data from buffer and receive answer to same buffer.
0 | Success |
-1 | Failure |
Definition at line 730 of file nntp.c.
|
static |
Read lines, calling a callback function for each.
mdata | NNTP Mailbox data |
query | Query to match |
qlen | Length of query |
msg | Progress message (OPTIONAL) |
func | Callback function |
data | Data for callback function |
0 | Success |
1 | Bad response (answer in query buffer) |
-1 | Connection lost |
-2 | Error in func(*line, *data) |
This function calls func(*line, *data) for each received line, func(NULL, *data) if rewind(*data) needs, exits when fail or done:
Definition at line 814 of file nntp.c.
|
static |
Parse newsgroup description.
line | String to parse |
data | NNTP Server |
0 | Always |
Definition at line 899 of file nntp.c.
|
static |
Fetch newsgroups descriptions.
mdata | NNTP Mailbox data |
wildmat | String to match |
msg | Progress message |
0 | Success |
1 | Bad response (answer in query buffer) |
-1 | Connection lost |
-2 | Error |
Definition at line 936 of file nntp.c.
Parse cross-reference.
Update read flag and set article number if empty
Definition at line 968 of file nntp.c.
|
static |
Write line to temporary file.
line | Text to write |
data | FILE pointer |
0 | Success |
-1 | Failure |
Definition at line 1009 of file nntp.c.
|
static |
|
static |
Parse overview line.
line | String to parse |
data | FetchCtx |
0 | Success |
-1 | Failure |
Definition at line 1048 of file nntp.c.
|
static |
Fetch headers.
m | Mailbox |
hc | Header cache |
first | Number of first header to fetch |
last | Number of last header to fetch |
restore | Restore message listed as deleted |
0 | Success |
-1 | Failure |
Definition at line 1204 of file nntp.c.
|
static |
Check newsgroup for new articles.
mdata | NNTP Mailbox data |
update_stat | Update the stats? |
1 | New articles found |
0 | No change |
-1 | Lost connection |
Definition at line 1441 of file nntp.c.
Check current newsgroup for new articles.
m | Mailbox |
enum | MxStatus |
Leave newsrc locked
Definition at line 1491 of file nntp.c.
|
static |
Get date and time from server.
adata | NNTP server |
now | Server time |
0 | Success |
-1 | Failure |
Definition at line 1699 of file nntp.c.
|
static |
Parse XPAT line.
line | String to parse |
data | ChildCtx |
0 | Always |
Definition at line 1736 of file nntp.c.
int nntp_open_connection | ( | struct NntpAccountData * | adata | ) |
Connect to server, authenticate and get capabilities.
adata | NNTP server |
0 | Success |
-1 | Failure |
Definition at line 1766 of file nntp.c.
int nntp_post | ( | struct Mailbox * | m, |
const char * | msg | ||
) |
Post article.
0 | Success |
-1 | Failure |
Definition at line 1946 of file nntp.c.
int nntp_active_fetch | ( | struct NntpAccountData * | adata, |
bool | mark_new | ||
) |
Fetch list of all newsgroups from server.
adata | NNTP server |
mark_new | Mark the groups as new |
0 | Success |
-1 | Failure |
Definition at line 2037 of file nntp.c.
int nntp_check_new_groups | ( | struct Mailbox * | m, |
struct NntpAccountData * | adata | ||
) |
Check for new groups/articles in subscribed groups.
m | Mailbox |
adata | NNTP server |
1 | New groups found |
0 | No new groups |
-1 | Error |
Definition at line 2105 of file nntp.c.
int nntp_check_msgid | ( | struct Mailbox * | m, |
const char * | msgid | ||
) |
Fetch article by Message-ID.
0 | Success |
1 | No such article |
-1 | Error |
Definition at line 2215 of file nntp.c.
int nntp_check_children | ( | struct Mailbox * | m, |
const char * | msgid | ||
) |
Fetch children of article with the Message-ID.
0 | Success |
-1 | Failure |
Definition at line 2286 of file nntp.c.
struct NntpAccountData* CurrentNewsSrv = NULL |