Read/parse/write an NNTP config file of subscribed newsgroups. More...
#include "config.h"
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.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 "mutt.h"
#include "lib.h"
#include "bcache/lib.h"
#include "expando/lib.h"
#include "adata.h"
#include "edata.h"
#include "expando_newsrc.h"
#include "mdata.h"
#include "mutt_logging.h"
#include "mutt_socket.h"
#include "muttlib.h"
#include "protos.h"
#include "hcache/lib.h"
Go to the source code of this file.
Functions | |
static struct NntpMboxData * | mdata_find (struct NntpAccountData *adata, const char *group) |
Find NntpMboxData for given newsgroup or add it. | |
void | nntp_acache_free (struct NntpMboxData *mdata) |
Remove all temporarily cache files. | |
void | nntp_newsrc_close (struct NntpAccountData *adata) |
Unlock and close .newsrc file. | |
void | nntp_group_unread_stat (struct NntpMboxData *mdata) |
Count number of unread articles using .newsrc data. | |
int | nntp_newsrc_parse (struct NntpAccountData *adata) |
Parse .newsrc file. | |
void | nntp_newsrc_gen_entries (struct Mailbox *m) |
Generate array of .newsrc entries. | |
static int | update_file (char *filename, char *buf) |
Update file with new contents. | |
int | nntp_newsrc_update (struct NntpAccountData *adata) |
Update .newsrc file. | |
static void | cache_expand (char *dst, size_t dstlen, struct ConnAccount *cac, const char *src) |
Make fully qualified cache file name. | |
void | nntp_expand_path (char *buf, size_t buflen, struct ConnAccount *cac) |
Make fully qualified url from newsgroup name. | |
int | nntp_add_group (char *line, void *data) |
Parse newsgroup. | |
static int | active_get_cache (struct NntpAccountData *adata) |
Load list of all newsgroups from cache. | |
int | nntp_active_save_cache (struct NntpAccountData *adata) |
Save list of all newsgroups to cache. | |
static void | nntp_hcache_namer (const char *path, struct Buffer *dest) |
Compose hcache file names - Implements hcache_namer_t -. | |
struct HeaderCache * | nntp_hcache_open (struct NntpMboxData *mdata) |
Open newsgroup hcache. | |
void | nntp_hcache_update (struct NntpMboxData *mdata, struct HeaderCache *hc) |
Remove stale cached headers. | |
static int | nntp_bcache_delete (const char *id, struct BodyCache *bcache, void *data) |
Delete an entry from the message cache - Implements bcache_list_t -. | |
void | nntp_bcache_update (struct NntpMboxData *mdata) |
Remove stale cached messages. | |
void | nntp_delete_group_cache (struct NntpMboxData *mdata) |
Remove hcache and bcache of newsgroup. | |
void | nntp_clear_cache (struct NntpAccountData *adata) |
Clear the NNTP cache. | |
static const char * | nntp_get_field (enum ConnAccountField field, void *gf_data) |
Get connection login credentials - Implements ConnAccount::get_field() -. | |
struct NntpAccountData * | nntp_select_server (struct Mailbox *m, const char *server, bool leave_lock) |
Open a connection to an NNTP server. | |
void | nntp_article_status (struct Mailbox *m, struct Email *e, char *group, anum_t anum) |
Get status of articles from .newsrc. | |
struct NntpMboxData * | mutt_newsgroup_subscribe (struct NntpAccountData *adata, char *group) |
Subscribe newsgroup. | |
struct NntpMboxData * | mutt_newsgroup_unsubscribe (struct NntpAccountData *adata, char *group) |
Unsubscribe newsgroup. | |
struct NntpMboxData * | mutt_newsgroup_catchup (struct Mailbox *m, struct NntpAccountData *adata, char *group) |
Catchup newsgroup. | |
struct NntpMboxData * | mutt_newsgroup_uncatchup (struct Mailbox *m, struct NntpAccountData *adata, char *group) |
Uncatchup newsgroup. | |
void | nntp_mailbox (struct Mailbox *m, char *buf, size_t buflen) |
Get first newsgroup with new messages. | |
Read/parse/write an NNTP config file of subscribed newsgroups.
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 newsrc.c.
|
static |
Find NntpMboxData for given newsgroup or add it.
adata | NNTP server |
group | Newsgroup |
ptr | NNTP data |
NULL | Error |
Definition at line 74 of file newsrc.c.
void nntp_acache_free | ( | struct NntpMboxData * | mdata | ) |
void nntp_newsrc_close | ( | struct NntpAccountData * | adata | ) |
Unlock and close .newsrc file.
adata | NNTP server |
Definition at line 120 of file newsrc.c.
void nntp_group_unread_stat | ( | struct NntpMboxData * | mdata | ) |
Count number of unread articles using .newsrc data.
mdata | NNTP Mailbox data |
Definition at line 134 of file newsrc.c.
int nntp_newsrc_parse | ( | struct NntpAccountData * | adata | ) |
Parse .newsrc file.
adata | NNTP server |
0 | Not changed |
1 | Parsed |
-1 | Error |
Definition at line 164 of file newsrc.c.
void nntp_newsrc_gen_entries | ( | struct Mailbox * | m | ) |
Generate array of .newsrc entries.
m | Mailbox |
Definition at line 301 of file newsrc.c.
|
static |
Update file with new contents.
filename | File to update |
buf | New context |
0 | Success |
-1 | Failure |
Definition at line 393 of file newsrc.c.
int nntp_newsrc_update | ( | struct NntpAccountData * | adata | ) |
Update .newsrc file.
adata | NNTP server |
0 | Success |
-1 | Failure |
Definition at line 443 of file newsrc.c.
|
static |
Make fully qualified cache file name.
Definition at line 524 of file newsrc.c.
void nntp_expand_path | ( | char * | buf, |
size_t | buflen, | ||
struct ConnAccount * | cac | ||
) |
Make fully qualified url from newsgroup name.
Definition at line 556 of file newsrc.c.
int nntp_add_group | ( | char * | line, |
void * | data | ||
) |
Parse newsgroup.
line | String to parse |
data | NNTP data |
0 | Always |
Definition at line 572 of file newsrc.c.
|
static |
Load list of all newsgroups from cache.
adata | NNTP server |
0 | Success |
-1 | Failure |
Definition at line 613 of file newsrc.c.
int nntp_active_save_cache | ( | struct NntpAccountData * | adata | ) |
Save list of all newsgroups to cache.
adata | NNTP server |
0 | Success |
-1 | Failure |
Definition at line 647 of file newsrc.c.
struct HeaderCache * nntp_hcache_open | ( | struct NntpMboxData * | mdata | ) |
Open newsgroup hcache.
mdata | NNTP Mailbox data |
ptr | Header cache |
NULL | Error |
Definition at line 707 of file newsrc.c.
void nntp_hcache_update | ( | struct NntpMboxData * | mdata, |
struct HeaderCache * | hc | ||
) |
Remove stale cached headers.
mdata | NNTP Mailbox data |
hc | Header cache |
Definition at line 731 of file newsrc.c.
void nntp_bcache_update | ( | struct NntpMboxData * | mdata | ) |
Remove stale cached messages.
mdata | NNTP Mailbox data |
Definition at line 799 of file newsrc.c.
void nntp_delete_group_cache | ( | struct NntpMboxData * | mdata | ) |
Remove hcache and bcache of newsgroup.
mdata | NNTP Mailbox data |
Definition at line 808 of file newsrc.c.
void nntp_clear_cache | ( | struct NntpAccountData * | adata | ) |
Clear the NNTP cache.
adata | NNTP server |
Remove hcache and bcache of all unexistent and unsubscribed newsgroups
Definition at line 841 of file newsrc.c.
struct NntpAccountData * nntp_select_server | ( | struct Mailbox * | m, |
const char * | server, | ||
bool | leave_lock | ||
) |
Open a connection to an NNTP server.
m | Mailbox |
server | Server URL |
leave_lock | Leave the server locked? |
ptr | NNTP server |
NULL | Error |
Automatically loads a newsrc into memory, if necessary. Checks the size/mtime of a newsrc file, if it doesn't match, load again. Hmm, if a system has broken mtimes, this might mean the file is reloaded every time, which we'd have to fix.
Definition at line 945 of file newsrc.c.
Get status of articles from .newsrc.
Full status flags are not supported by nntp, but we can fake some of them: Read = a read message number is in the .newsrc New = not read and not cached Old = not read but cached
Definition at line 1138 of file newsrc.c.
struct NntpMboxData * mutt_newsgroup_subscribe | ( | struct NntpAccountData * | adata, |
char * | group | ||
) |
Subscribe newsgroup.
adata | NNTP server |
group | Newsgroup |
ptr | NNTP data |
NULL | Error |
Definition at line 1175 of file newsrc.c.
struct NntpMboxData * mutt_newsgroup_unsubscribe | ( | struct NntpAccountData * | adata, |
char * | group | ||
) |
Unsubscribe newsgroup.
adata | NNTP server |
group | Newsgroup |
ptr | NNTP data |
NULL | Error |
Definition at line 1199 of file newsrc.c.
struct NntpMboxData * mutt_newsgroup_catchup | ( | struct Mailbox * | m, |
struct NntpAccountData * | adata, | ||
char * | group | ||
) |
Catchup newsgroup.
m | Mailbox |
adata | NNTP server |
group | Newsgroup |
ptr | NNTP data |
NULL | Error |
Definition at line 1226 of file newsrc.c.
struct NntpMboxData * mutt_newsgroup_uncatchup | ( | struct Mailbox * | m, |
struct NntpAccountData * | adata, | ||
char * | group | ||
) |
Uncatchup newsgroup.
m | Mailbox |
adata | NNTP server |
group | Newsgroup |
ptr | NNTP data |
NULL | Error |
Definition at line 1265 of file newsrc.c.
void nntp_mailbox | ( | struct Mailbox * | m, |
char * | buf, | ||
size_t | buflen | ||
) |
Get first newsgroup with new messages.
Definition at line 1308 of file newsrc.c.