Signed-off-by: Pierre Habouzit <madcoder@debian.org>
(state->entry)[state->entrylen].imap = 0;
#ifdef USE_NNTP
if (option (OPTNEWS))
(state->entry)[state->entrylen].imap = 0;
#ifdef USE_NNTP
if (option (OPTNEWS))
- (state->entry)[state->entrylen].nd = (NNTP_DATA *) data;
+ (state->entry)[state->entrylen].nd = (nntp_data_t *) data;
#endif
(state->entrylen)++;
}
#endif
(state->entrylen)++;
}
{
#ifdef USE_NNTP
if (option (OPTNEWS)) {
{
#ifdef USE_NNTP
if (option (OPTNEWS)) {
- string_list_t *tmp;
- NNTP_DATA *data;
NNTP_SERVER *news = CurrentNewsSrv;
/* buffy_check (0); */
init_state (state, menu);
NNTP_SERVER *news = CurrentNewsSrv;
/* buffy_check (0); */
init_state (state, menu);
- for (tmp = news->list; tmp; tmp = tmp->next) {
- if (!(data = (NNTP_DATA *) tmp->data))
- continue;
- nntp_sync_sidebar (data);
+ for (data = news->list; data; data = data->next) {
+ nntp_sync_sidebar(data);
if (m_strncmp (prefix, data->group, m_strlen(prefix)) != 0)
continue;
if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.neg))
if (m_strncmp (prefix, data->group, m_strlen(prefix)) != 0)
continue;
if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.neg))
#ifdef USE_NNTP
if (option (OPTNEWS)) {
#ifdef USE_NNTP
if (option (OPTNEWS)) {
- string_list_t *tmp;
- NNTP_DATA *data;
NNTP_SERVER *news = CurrentNewsSrv;
/* buffy_check (0); */
init_state (state, menu);
NNTP_SERVER *news = CurrentNewsSrv;
/* buffy_check (0); */
init_state (state, menu);
- for (tmp = news->list; tmp; tmp = tmp->next) {
- if ((data = (NNTP_DATA*) tmp->data) == NULL)
- continue;
+ for (data = news->list; data; data = data->next) {
nntp_sync_sidebar (data);
if ((data->new || (data->subscribed &&
(!option (OPTSHOWONLYUNREAD)|| data->unread))))
nntp_sync_sidebar (data);
if ((data->new || (data->subscribed &&
(!option (OPTSHOWONLYUNREAD)|| data->unread))))
if (*f)
m_strcpy(prefix, sizeof(prefix), f);
else {
if (*f)
m_strcpy(prefix, sizeof(prefix), f);
else {
/* default state for news reader mode is browse subscribed newsgroups */
buffy = 0;
for (list = CurrentNewsSrv->list; list; list = list->next) {
/* default state for news reader mode is browse subscribed newsgroups */
buffy = 0;
for (list = CurrentNewsSrv->list; list; list = list->next) {
- NNTP_DATA *data = (NNTP_DATA *) list->data;
-
- if (data && data->subscribed) {
+ if (list->subscribed) {
case OP_UNCATCHUP:
if (option (OPTNEWS)) {
struct folder_file *folder_f = &state.entry[menu->current];
case OP_UNCATCHUP:
if (option (OPTNEWS)) {
struct folder_file *folder_f = &state.entry[menu->current];
if (i == OP_CATCHUP)
nd = mutt_newsgroup_catchup (CurrentNewsSrv, folder_f->name);
if (i == OP_CATCHUP)
nd = mutt_newsgroup_catchup (CurrentNewsSrv, folder_f->name);
- string_list_t *tmp;
- NNTP_DATA *data;
- for (tmp = CurrentNewsSrv->list; tmp; tmp = tmp->next) {
- if ((data = (NNTP_DATA *) tmp->data))
- data->deleted = 1;
+ for (data = CurrentNewsSrv->list; data; data = data->next) {
+ data->deleted = 1;
}
}
nntp_get_active (CurrentNewsSrv);
}
}
nntp_get_active (CurrentNewsSrv);
regex_t *rx = p_new(regex_t, 1);
char *s = buf;
int j = menu->current;
regex_t *rx = p_new(regex_t, 1);
char *s = buf;
int j = menu->current;
NNTP_SERVER *news = CurrentNewsSrv;
if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) {
NNTP_SERVER *news = CurrentNewsSrv;
if (i == OP_SUBSCRIBE_PATTERN || i == OP_UNSUBSCRIBE_PATTERN) {
}
}
if (i == OP_SUBSCRIBE_PATTERN) {
}
}
if (i == OP_SUBSCRIBE_PATTERN) {
- string_list_t *grouplist = NULL;
-
- if (news)
- grouplist = news->list;
- for (; grouplist; grouplist = grouplist->next) {
- nd = (NNTP_DATA *) grouplist->data;
- if (nd && nd->group && !nd->subscribed) {
+ nd = news ? news->list : NULL;
+ for (; nd; nd = nd->next) {
+ if (nd->group && !nd->subscribed) {
if (regexec (rx, nd->group, 0, NULL, 0) == 0) {
mutt_newsgroup_subscribe (news, nd->group);
add_folder (menu, &state, nd->group, NULL, nd, nd->new);
if (regexec (rx, nd->group, 0, NULL, 0) == 0) {
mutt_newsgroup_subscribe (news, nd->group);
add_folder (menu, &state, nd->group, NULL, nd, nd->new);
unsigned selectable:1;
unsigned inferiors:1;
#ifdef USE_NNTP
unsigned selectable:1;
unsigned inferiors:1;
#ifdef USE_NNTP
#endif
unsigned tagged:1;
};
#endif
unsigned tagged:1;
};
#ifdef USE_NNTP
if (option (OPTNEWS)) {
#ifdef USE_NNTP
if (option (OPTNEWS)) {
- string_list_t *l = CurrentNewsSrv->list;
+ nntp_data_t *l = CurrentNewsSrv->list;
m_strcpy(filepart, sizeof(filepart), s);
m_strcpy(filepart, sizeof(filepart), s);
*/
if ((len = m_strlen(filepart)) == 0) {
for (; l; l = l->next) {
*/
if ((len = m_strlen(filepart)) == 0) {
for (; l; l = l->next) {
- NNTP_DATA *data = (NNTP_DATA *) l->data;
-
- if (data && data->subscribed) {
- m_strcpy(filepart, sizeof(filepart), data->group);
+ if (l->subscribed) {
+ m_strcpy(filepart, sizeof(filepart), l->group);
init++;
l = l->next;
break;
init++;
l = l->next;
break;
}
for (; l; l = l->next) {
}
for (; l; l = l->next) {
- NNTP_DATA *data = (NNTP_DATA *) l->data;
-
- if (data && data->subscribed &&
- m_strncmp(data->group, filepart, len) == 0) {
+ if (l->subscribed && m_strncmp(l->group, filepart, len) == 0) {
- for (i = 0; filepart[i] && data->group[i]; i++) {
- if (filepart[i] != data->group[i]) {
+ for (i = 0; filepart[i] && l->group[i]; i++) {
+ if (filepart[i] != l->group[i]) {
filepart[i] = 0;
break;
}
}
filepart[i] = 0;
filepart[i] = 0;
break;
}
}
filepart[i] = 0;
- }
- else {
- m_strcpy(filepart, sizeof(filepart), data->group);
+ } else {
+ m_strcpy(filepart, sizeof(filepart), l->group);
case OP_CATCHUP:
if (Context && Context->magic == M_NNTP) {
if (mutt_newsgroup_catchup (CurrentNewsSrv,
case OP_CATCHUP:
if (Context && Context->magic == M_NNTP) {
if (mutt_newsgroup_catchup (CurrentNewsSrv,
- ((NNTP_DATA *) Context->data)->group))
+ ((nntp_data_t *) Context->data)->group))
menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
}
break;
menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
}
break;
_("Reply by mail as poster prefers?")) !=
M_YES) {
if (Context && Context->magic == M_NNTP
_("Reply by mail as poster prefers?")) !=
M_YES) {
if (Context && Context->magic == M_NNTP
- && !((NNTP_DATA *) Context->data)->allowed
+ && !((nntp_data_t *) Context->data)->allowed
&& query_quadoption (OPT_TOMODERATED,
_
("Posting to this group not allowed, may be moderated. Continue?"))
&& query_quadoption (OPT_TOMODERATED,
_
("Posting to this group not allowed, may be moderated. Continue?"))
static int nntp_get_cache_all (NNTP_SERVER *);
static int nntp_check_newgroups (NNTP_SERVER *, int);
static int nntp_get_cache_all (NNTP_SERVER *);
static int nntp_check_newgroups (NNTP_SERVER *, int);
-static void mutt_newsgroup_stat (NNTP_DATA *);
-static void nntp_delete_cache (NNTP_DATA *);
-static void nntp_delete_data (void *p);
+static void mutt_newsgroup_stat (nntp_data_t *);
+static void nntp_delete_cache (nntp_data_t *);
-static void nntp_add_to_list(NNTP_SERVER *s, NNTP_DATA *d)
-{
- *s->tail = p_new(string_list_t, 1);
- (*s->tail)->data = (void *)d;
- s->tail = &(*s->tail)->next;
-}
-
static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
{
static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
{
char group[LONG_STRING];
int x = 1;
char group[LONG_STRING];
int x = 1;
- char *p = line, *b, *h;
- ssize_t len;
- while (*p) {
- if (*p++ == ',')
- x++;
+ for (p = line; p; p = strchr(p, ',')) {
+ x++;
- p = line;
- while (*p && (*p != ':' && *p != '!'))
- p++;
- if (!*p)
+ p = strpbrk(line, ":!");
+ if (!p)
- len = MIN(p + 1 - line, ssizeof(group));
- m_strcpy(group, len, line);
- if ((data = (NNTP_DATA *) hash_find (news->newsgroups, group)) == NULL) {
- data = xmalloc(sizeof(NNTP_DATA) + m_strlen(group) + 1);
- data->group = (char *) data + sizeof (NNTP_DATA);
+
+ m_strncpy(group, ssizeof(group), line, p - line);
+ if ((data = (nntp_data_t *) hash_find (news->newsgroups, group)) == NULL) {
+ data = xmalloc(sizeof(nntp_data_t) + m_strlen(group) + 1);
+ data->group = (char *) data + sizeof (nntp_data_t);
strcpy (data->group, group);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
hash_insert (news->newsgroups, data->group, data);
strcpy (data->group, group);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
hash_insert (news->newsgroups, data->group, data);
- nntp_add_to_list (news, data);
- }
- else
+ nntp_data_list_append(&news->list, data);
+ } else {
p_delete(&data->entries);
p_delete(&data->entries);
data->rc = 1;
data->entries = p_new(NEWSRC_ENTRY, x * 2);
data->max = x * 2;
data->rc = 1;
data->entries = p_new(NEWSRC_ENTRY, x * 2);
data->max = x * 2;
- if (*p == ':')
- data->subscribed = 1;
- else
- data->subscribed = 0;
+ data->subscribed = (*p++ == ':');
b = p;
x = 0;
while (*b) {
b = p;
x = 0;
while (*b) {
char buf[HUGE_STRING], *cp;
char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
FILE *idx;
char buf[HUGE_STRING], *cp;
char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
FILE *idx;
int l, m, t;
/* check is server name defined or not */
int l, m, t;
/* check is server name defined or not */
news->newgroups_time = m;
}
else if (news->newsgroups) {
news->newgroups_time = m;
}
else if (news->newsgroups) {
- if ((data = (NNTP_DATA *) hash_find (news->newsgroups, buf)) == NULL) {
- data = xmalloc(sizeof(NNTP_DATA) + m_strlen(buf) + 1);
- data->group = (char *) data + sizeof (NNTP_DATA);
+ if ((data = (nntp_data_t *) hash_find (news->newsgroups, buf)) == NULL) {
+ data = xmalloc(sizeof(nntp_data_t) + m_strlen(buf) + 1);
+ data->group = (char *) data + sizeof (nntp_data_t);
strcpy (data->group, buf);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
hash_insert (news->newsgroups, data->group, data);
strcpy (data->group, buf);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
hash_insert (news->newsgroups, data->group, data);
- nntp_add_to_list (news, data);
+ nntp_data_list_append(&news->list, data);
}
data->cache = m_strdup(file);
t = 0;
}
data->cache = m_strdup(file);
t = 0;
{
char file[_POSIX_PATH_MAX];
char *buf, *p;
{
char file[_POSIX_PATH_MAX];
char *buf, *p;
ACCOUNT act;
NNTP_SERVER *serv;
CONNECTION *conn;
ACCOUNT act;
NNTP_SERVER *serv;
CONNECTION *conn;
struct stat sb;
/* externally modified? */
struct stat sb;
/* externally modified? */
- if (serv->stat != stat (file, &sb) || (!serv->stat &&
+ if (serv->stat != stat(file, &sb) || (!serv->stat &&
(serv->size != sb.st_size
(serv->size != sb.st_size
- || serv->mtime != sb.st_mtime))) {
+ || serv->mtime != sb.st_mtime)))
+ {
for (list = serv->list; list; list = list->next) {
for (list = serv->list; list; list = list->next) {
- NNTP_DATA *data = (NNTP_DATA *) list->data;
-
- if (data) {
- data->subscribed = 0;
- data->rc = 0;
- data->num = 0;
- }
+ list->subscribed = 0;
+ list->rc = 0;
+ list->num = 0;
}
slurp_newsrc (serv);
nntp_clear_cacheindex (serv);
}
slurp_newsrc (serv);
nntp_clear_cacheindex (serv);
/* New newsserver */
serv = p_new(NNTP_SERVER, 1);
/* New newsserver */
serv = p_new(NNTP_SERVER, 1);
- serv->tail = &serv->list;
serv->conn = conn;
serv->newsrc = m_strdup(file);
serv->newsgroups = hash_new(1009, false);
serv->conn = conn;
serv->newsrc = m_strdup(file);
serv->newsgroups = hash_new(1009, false);
if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
nntp_check_newgroups (serv, 1);
else if (nntp_get_active (serv) < 0) {
if (option (OPTNEWSCACHE) && serv->cache && nntp_get_cache_all (serv) >= 0)
nntp_check_newgroups (serv, 1);
else if (nntp_get_active (serv) < 0) {
- hash_delete (&serv->newsgroups, nntp_delete_data);
- for (list = serv->list; list; list = list->next)
- list->data = NULL;
- string_list_wipe(&serv->list);
+ hash_delete(&serv->newsgroups, NULL);
+ nntp_data_list_wipe(&serv->list);
p_delete(&serv->newsrc);
p_delete(&serv->cache);
p_delete(&serv);
p_delete(&serv->newsrc);
p_delete(&serv->cache);
p_delete(&serv);
*/
static void nntp_get_status(CONTEXT *ctx, HEADER *h, char *group, int article)
{
*/
static void nntp_get_status(CONTEXT *ctx, HEADER *h, char *group, int article)
{
- NNTP_DATA *data = (NNTP_DATA *) ctx->data;
+ nntp_data_t *data = (nntp_data_t *) ctx->data;
- data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
+ data = (nntp_data_t *) hash_find (data->nserv->newsgroups, group);
-static void mutt_newsgroup_stat (NNTP_DATA * data)
+static void mutt_newsgroup_stat (nntp_data_t * data)
-static void nntp_create_newsrc_line (NNTP_DATA * data, char **buf,
+static void nntp_create_newsrc_line (nntp_data_t * data, char **buf,
char **pline, ssize_t * buflen)
{
char *line = *pline;
char **pline, ssize_t * buflen)
{
char *line = *pline;
static void newsrc_gen_entries (CONTEXT * ctx)
{
static void newsrc_gen_entries (CONTEXT * ctx)
{
- NNTP_DATA *data = (NNTP_DATA *) ctx->data;
+ nntp_data_t *data = (nntp_data_t *) ctx->data;
int series, x;
int last = 0, first = 1;
int save_sort = SORT_ORDER;
int series, x;
int last = 0, first = 1;
int save_sort = SORT_ORDER;
int mutt_newsrc_update (NNTP_SERVER * news)
{
char *buf, *line;
int mutt_newsrc_update (NNTP_SERVER * news)
{
char *buf, *line;
- NNTP_DATA *data;
- string_list_t *tmp;
int r = -1;
ssize_t len, llen;
int r = -1;
ssize_t len, llen;
llen = len = 10 * LONG_STRING;
line = buf = p_new(char, len);
/* we will generate full newsrc here */
llen = len = 10 * LONG_STRING;
line = buf = p_new(char, len);
/* we will generate full newsrc here */
- for (tmp = news->list; tmp; tmp = tmp->next) {
- data = (NNTP_DATA *) tmp->data;
+ for (data = news->list; data; data = data->next) {
if (!data || !data->rc)
continue;
nntp_create_newsrc_line (data, &buf, &line, &llen);
if (!data || !data->rc)
continue;
nntp_create_newsrc_line (data, &buf, &line, &llen);
}
/* Updates info into .index file: ALL or about selected newsgroup */
}
/* Updates info into .index file: ALL or about selected newsgroup */
-static int nntp_update_cacheindex (NNTP_SERVER * serv, NNTP_DATA * data)
+static int nntp_update_cacheindex (NNTP_SERVER * serv, nntp_data_t * data)
{
char buf[LONG_STRING];
char file[_POSIX_PATH_MAX];
{
char buf[LONG_STRING];
char file[_POSIX_PATH_MAX];
/* Remove cache files of unsubscribed newsgroups */
void nntp_clear_cacheindex (NNTP_SERVER * news)
{
/* Remove cache files of unsubscribed newsgroups */
void nntp_clear_cacheindex (NNTP_SERVER * news)
{
- NNTP_DATA *data;
- string_list_t *tmp;
if (option (OPTSAVEUNSUB) || !news)
return;
if (option (OPTSAVEUNSUB) || !news)
return;
- for (tmp = news->list; tmp; tmp = tmp->next) {
- data = (NNTP_DATA *) tmp->data;
+ for (data = news->list; data; data = data->next) {
if (!data || data->subscribed || !data->cache)
continue;
nntp_delete_cache (data);
if (!data || data->subscribed || !data->cache)
continue;
nntp_delete_cache (data);
{
char buf[HUGE_STRING];
char file[_POSIX_PATH_MAX];
{
char buf[HUGE_STRING];
char file[_POSIX_PATH_MAX];
if (!news || !news->newsgroups)
return -1;
if (!news || !news->newsgroups)
return -1;
- for (l = news->list; l; l = l->next) {
- if ((d = (NNTP_DATA *) l->data) && !d->deleted) {
+ for (d = news->list; d; d = d->next) {
+ if (!d->deleted) {
if (d->desc)
snprintf (buf, sizeof (buf), "%s %d %d %c %s\n", d->group,
d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
if (d->desc)
snprintf (buf, sizeof (buf), "%s %d %d %c %s\n", d->group,
d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n',
if (!ctx || !ctx->data || ctx->magic != M_NNTP)
return -1;
if (!ctx || !ctx->data || ctx->magic != M_NNTP)
return -1;
- if (((NNTP_DATA *) ctx->data)->cache) {
- nntp_cache_expand (file, ((NNTP_DATA *) ctx->data)->cache);
+ if (((nntp_data_t *) ctx->data)->cache) {
+ nntp_cache_expand (file, ((nntp_data_t *) ctx->data)->cache);
unlink (file);
f = safe_fopen (file, "w");
}
else {
snprintf (buf, sizeof (buf), "%s-%s",
unlink (file);
f = safe_fopen (file, "w");
}
else {
snprintf (buf, sizeof (buf), "%s-%s",
- ((NNTP_DATA *) ctx->data)->nserv->conn->account.host,
- ((NNTP_DATA *) ctx->data)->group);
+ ((nntp_data_t *) ctx->data)->nserv->conn->account.host,
+ ((nntp_data_t *) ctx->data)->group);
- ((NNTP_DATA *) ctx->data)->cache = m_strdup(buf);
+ ((nntp_data_t *) ctx->data)->cache = m_strdup(buf);
nntp_cache_expand (file, buf);
}
if (!f)
nntp_cache_expand (file, buf);
}
if (!f)
}
/* Save only $nntp_context messages... */
}
/* Save only $nntp_context messages... */
- ((NNTP_DATA *) ctx->data)->lastCached = 0;
+ ((nntp_data_t *) ctx->data)->lastCached = 0;
if (NntpContext && ctx->msgcount > NntpContext)
i = ctx->msgcount - NntpContext;
for (; i < ctx->msgcount; i++) {
if (NntpContext && ctx->msgcount > NntpContext)
i = ctx->msgcount - NntpContext;
for (; i < ctx->msgcount; i++) {
- if (nntp_update_cacheindex (((NNTP_DATA *) ctx->data)->nserv,
- (NNTP_DATA *) ctx->data)) {
+ if (nntp_update_cacheindex (((nntp_data_t *) ctx->data)->nserv,
+ (nntp_data_t *) ctx->data)) {
unlink (file);
return -1;
}
unlink (file);
return -1;
}
- ((NNTP_DATA *) ctx->data)->lastCached =
- ((NNTP_DATA *) ctx->data)->lastLoaded;
+ ((nntp_data_t *) ctx->data)->lastCached =
+ ((nntp_data_t *) ctx->data)->lastLoaded;
-static void nntp_delete_cache (NNTP_DATA * data)
+static void nntp_delete_cache (nntp_data_t * data)
{
char buf[_POSIX_PATH_MAX];
{
char buf[_POSIX_PATH_MAX];
-NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER * news, char *group)
+nntp_data_t *mutt_newsgroup_subscribe (NNTP_SERVER * news, char *group)
if (!news || !news->newsgroups || !group || !*group)
return NULL;
if (!news || !news->newsgroups || !group || !*group)
return NULL;
- if (!(data = (NNTP_DATA *) hash_find (news->newsgroups, group))) {
- data = xmalloc(sizeof(NNTP_DATA) + m_strlen(group) + 1);
- data->group = (char *) data + sizeof (NNTP_DATA);
+ if (!(data = (nntp_data_t *) hash_find (news->newsgroups, group))) {
+ data = xmalloc(sizeof(nntp_data_t) + m_strlen(group) + 1);
+ data->group = (char *) data + sizeof (nntp_data_t);
strcpy (data->group, group);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
hash_insert (news->newsgroups, data->group, data);
strcpy (data->group, group);
data->nserv = news;
data->deleted = 1;
if (news->newsgroups->nelem < news->newsgroups->curnelem * 2)
hash_resize (news->newsgroups, news->newsgroups->nelem * 2);
hash_insert (news->newsgroups, data->group, data);
- nntp_add_to_list (news, data);
+ nntp_data_list_append(&news->list, data);
}
if (!data->subscribed) {
data->subscribed = 1;
}
if (!data->subscribed) {
data->subscribed = 1;
-NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER * news, char *group)
+nntp_data_t *mutt_newsgroup_unsubscribe (NNTP_SERVER * news, char *group)
if (!news || !news->newsgroups || !group || !*group ||
if (!news || !news->newsgroups || !group || !*group ||
- !(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
+ !(data = (nntp_data_t *) hash_find (news->newsgroups, group)))
return NULL;
if (data->subscribed) {
data->subscribed = 0;
return NULL;
if (data->subscribed) {
data->subscribed = 0;
-NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER * news, char *group)
+nntp_data_t *mutt_newsgroup_catchup (NNTP_SERVER * news, char *group)
if (!news || !news->newsgroups || !group || !*group ||
if (!news || !news->newsgroups || !group || !*group ||
- !(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
+ !(data = (nntp_data_t *) hash_find (news->newsgroups, group)))
return NULL;
if (!data->max) {
data->entries = p_new(NEWSRC_ENTRY, 5);
return NULL;
if (!data->max) {
data->entries = p_new(NEWSRC_ENTRY, 5);
-NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER * news, char *group)
+nntp_data_t *mutt_newsgroup_uncatchup (NNTP_SERVER * news, char *group)
if (!news || !news->newsgroups || !group || !*group ||
if (!news || !news->newsgroups || !group || !*group ||
- !(data = (NNTP_DATA *) hash_find (news->newsgroups, group)))
+ !(data = (nntp_data_t *) hash_find (news->newsgroups, group)))
return NULL;
if (!data->max) {
data->entries = p_new(NEWSRC_ENTRY, 5);
return NULL;
if (!data->max) {
data->entries = p_new(NEWSRC_ENTRY, 5);
/* this routine gives the first newsgroup with new messages */
void nntp_buffy (char* dst, ssize_t dstlen) {
/* this routine gives the first newsgroup with new messages */
void nntp_buffy (char* dst, ssize_t dstlen) {
int count = 0;
/* forward to current group */
for (list = CurrentNewsSrv->list; list; list = list->next) {
int count = 0;
/* forward to current group */
for (list = CurrentNewsSrv->list; list; list = list->next) {
- NNTP_DATA *data = (NNTP_DATA *) list->data;
- if (data && data->subscribed && data->unread &&
- Context && Context->magic == M_NNTP &&
- m_strcmp(data->group, ((NNTP_DATA *) Context->data)->group) == 0) {
+ if (list->subscribed && list->unread
+ && Context && Context->magic == M_NNTP
+ && m_strcmp(list->group, ((nntp_data_t *)Context->data)->group) == 0)
+ {
list = list->next;
break;
}
list = list->next;
break;
}
list = CurrentNewsSrv->list;
for (; list; list = list->next) {
list = CurrentNewsSrv->list;
for (; list; list = list->next) {
- NNTP_DATA *data = (NNTP_DATA *) list->data;
-
- if (data && data->subscribed && data->unread) {
+ if (list->subscribed && list->unread) {
if (Context && Context->magic == M_NNTP &&
if (Context && Context->magic == M_NNTP &&
- !m_strcmp(data->group, ((NNTP_DATA *) Context->data)->group)) {
+ !m_strcmp(list->group, ((nntp_data_t *)Context->data)->group)) {
int i, unread = 0;
for (i = 0; i < Context->msgcount; i++)
int i, unread = 0;
for (i = 0; i < Context->msgcount; i++)
- m_strcpy(dst, dstlen, data->group);
+ m_strcpy(dst, dstlen, list->group);
static unsigned int _checked = 0;
static unsigned int _checked = 0;
-void nntp_sync_sidebar (NNTP_DATA* data) {
+void nntp_sync_sidebar (nntp_data_t* data) {
int i = 0;
BUFFY* tmp = NULL;
char buf[STRING];
int i = 0;
BUFFY* tmp = NULL;
char buf[STRING];
}
/* Send data from line[LONG_STRING] and receive answer to same line */
}
/* Send data from line[LONG_STRING] and receive answer to same line */
-static int mutt_nntp_query (NNTP_DATA * data, char *line, size_t linelen)
+static int mutt_nntp_query (nntp_data_t * data, char *line, size_t linelen)
{
char buf[LONG_STRING];
int done = TRUE;
{
char buf[LONG_STRING];
int done = TRUE;
* -2 - invalid command or execution error,
* -3 - error in funct(*line, *data).
*/
* -2 - invalid command or execution error,
* -3 - error in funct(*line, *data).
*/
-static int mutt_nntp_fetch (NNTP_DATA * nntp_data, const char *query,
+static int mutt_nntp_fetch (nntp_data_t * nntp_data, const char *query,
const char *msg, progress_t* bar,
int (*funct) (char *, void *),
void *data, int tagged)
const char *msg, progress_t* bar,
int (*funct) (char *, void *),
void *data, int tagged)
static int nntp_read_header (CONTEXT * ctx, const char *msgid,
int article_num)
{
static int nntp_read_header (CONTEXT * ctx, const char *msgid,
int article_num)
{
- NNTP_DATA *nntp_data = ((NNTP_DATA *) ctx->data);
+ nntp_data_t *nntp_data = ((nntp_data_t *) ctx->data);
FILE *f;
char buf[LONG_STRING];
char tempfile[_POSIX_PATH_MAX];
FILE *f;
char buf[LONG_STRING];
char tempfile[_POSIX_PATH_MAX];
static int parse_description (char *line, void *n)
{
register char *d = line;
static int parse_description (char *line, void *n)
{
register char *d = line;
NNTP_SERVER *news = n;
if (!line)
NNTP_SERVER *news = n;
if (!line)
d++;
while (*d && (*d == '\t' || *d == ' '))
d++;
d++;
while (*d && (*d == '\t' || *d == ' '))
d++;
- if ((data = (NNTP_DATA *) hash_find (news->newsgroups, line)) != NULL &&
+ if ((data = (nntp_data_t *) hash_find (news->newsgroups, line)) != NULL &&
m_strcmp(d, data->desc)) {
p_delete(&data->desc);
data->desc = m_strdup(d);
m_strcmp(d, data->desc)) {
p_delete(&data->desc);
data->desc = m_strdup(d);
-static void nntp_get_desc (NNTP_DATA * data, const char *mask, char *msg, progress_t* bar)
+static void nntp_get_desc (nntp_data_t * data, const char *mask, char *msg, progress_t* bar)
*/
static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr)
{
*/
static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr)
{
- NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
+ nntp_data_t *nntp_data = (nntp_data_t *) ctx->data;
char *p, *b;
int x, done = 0;
char *p, *b;
int x, done = 0;
int num, total;
FETCH_CONTEXT *fc = c;
CONTEXT *ctx = fc->ctx;
int num, total;
FETCH_CONTEXT *fc = c;
CONTEXT *ctx = fc->ctx;
- NNTP_DATA *data = (NNTP_DATA *) ctx->data;
+ nntp_data_t *data = (nntp_data_t *) ctx->data;
char buf[HUGE_STRING];
const char *msg = _("Fetching message headers...");
const char *msg2 = _("Fetching headers from cache...");
char buf[HUGE_STRING];
const char *msg = _("Fetching message headers...");
const char *msg2 = _("Fetching headers from cache...");
- NNTP_DATA *nntp_data = ((NNTP_DATA *) ctx->data);
+ nntp_data_t *nntp_data = ((nntp_data_t *) ctx->data);
int ret, num, oldmsgcount, current;
FILE *f;
FETCH_CONTEXT fc;
int ret, num, oldmsgcount, current;
FILE *f;
FETCH_CONTEXT fc;
*/
static int nntp_open_mailbox (CONTEXT * ctx)
{
*/
static int nntp_open_mailbox (CONTEXT * ctx)
{
+ nntp_data_t *nntp_data;
NNTP_SERVER *serv;
char buf[HUGE_STRING];
char server[LONG_STRING];
NNTP_SERVER *serv;
char buf[HUGE_STRING];
char server[LONG_STRING];
CurrentNewsSrv = serv;
/* create NNTP-specific state struct if nof found in list */
CurrentNewsSrv = serv;
/* create NNTP-specific state struct if nof found in list */
- if ((nntp_data = (NNTP_DATA *) hash_find (serv->newsgroups, buf)) == NULL) {
- nntp_data = xmalloc(sizeof(NNTP_DATA) + m_strlen(buf) + 1);
- nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
+ if ((nntp_data = (nntp_data_t *) hash_find (serv->newsgroups, buf)) == NULL) {
+ nntp_data = xmalloc(sizeof(nntp_data_t) + m_strlen(buf) + 1);
+ nntp_data->group = (char *) nntp_data + sizeof (nntp_data_t);
strcpy (nntp_data->group, buf);
hash_insert (serv->newsgroups, nntp_data->group, nntp_data);
strcpy (nntp_data->group, buf);
hash_insert (serv->newsgroups, nntp_data->group, nntp_data);
- nntp_add_to_list (serv, nntp_data);
+ nntp_data_list_append(&serv->list, nntp_data);
}
ctx->data = nntp_data;
nntp_data->nserv = serv;
}
ctx->data = nntp_data;
nntp_data->nserv = serv;
}
if (m_strncmp("211", buf, 3)) {
}
if (m_strncmp("211", buf, 3)) {
- string_list_t *l = serv->list;
/* GROUP command failed */
if (!m_strncmp("411", buf, 3)) {
/* GROUP command failed */
if (!m_strncmp("411", buf, 3)) {
/* CACHE: delete cache and line from .index */
nntp_delete_cache (nntp_data);
/* CACHE: delete cache and line from .index */
nntp_delete_cache (nntp_data);
- hash_remove (serv->newsgroups, nntp_data->group, NULL,
- nntp_delete_data);
- while (l && l->data != (void *) nntp_data)
- l = l->next;
- if (l)
- l->data = NULL;
-
+ hash_remove(serv->newsgroups, nntp_data->group, NULL, NULL);
+ for (l = &serv->list; *l; l = &(*l)->next) {
+ if ((*l) == nntp_data) {
+ nntp_data_list_pop(l);
+ nntp_data_delete(&nntp_data);
+ break;
+ }
+ }
+ nntp_data_delete(&nntp_data);
/* see if we already have the message in our cache */
cache =
/* see if we already have the message in our cache */
cache =
- &((NNTP_DATA *) ctx->data)->acache[ctx->hdrs[msgno]->index %
+ &((nntp_data_t *) ctx->data)->acache[ctx->hdrs[msgno]->index %
NNTP_CACHE_LEN];
/* if everything is fine, assign msg->fp and return */
NNTP_CACHE_LEN];
/* if everything is fine, assign msg->fp and return */
bar.size = 0;
mutt_progress_bar (&bar, 0);
bar.size = 0;
mutt_progress_bar (&bar, 0);
- ret = mutt_nntp_fetch ((NNTP_DATA *) ctx->data, buf, NULL, &bar, nntp_read_tempfile,
+ ret = mutt_nntp_fetch ((nntp_data_t *) ctx->data, buf, NULL, &bar, nntp_read_tempfile,
msg->fp, ctx->tagged);
if (ret == 1) {
mutt_error (_("Article %d not found on server"),
msg->fp, ctx->tagged);
if (ret == 1) {
mutt_error (_("Article %d not found on server"),
char buf[LONG_STRING];
size_t len;
FILE *f;
char buf[LONG_STRING];
size_t len;
FILE *f;
+ nntp_data_t *nntp_data;
if (Context && Context->magic == M_NNTP)
if (Context && Context->magic == M_NNTP)
- nntp_data = (NNTP_DATA *) Context->data;
+ nntp_data = (nntp_data_t *)Context->data;
- if (!(CurrentNewsSrv = mutt_select_newsserver (NewsServer)) ||
- !CurrentNewsSrv->list || !CurrentNewsSrv->list->data) {
+ if (!(CurrentNewsSrv = mutt_select_newsserver(NewsServer)) ||
+ !CurrentNewsSrv->list)
+ {
mutt_error (_("Can't post article. No connection to news server."));
return -1;
}
mutt_error (_("Can't post article. No connection to news server."));
return -1;
}
- nntp_data = (NNTP_DATA *) CurrentNewsSrv->list->data;
+ nntp_data = CurrentNewsSrv->list;
}
if (!(f = safe_fopen (msg, "r"))) {
}
if (!(f = safe_fopen (msg, "r"))) {
-static void nntp_free_acache (NNTP_DATA * data)
+static void nntp_free_acache (nntp_data_t * data)
-static void nntp_delete_data (void *p)
+void nntp_data_wipe(nntp_data_t *data)
- NNTP_DATA *data = (NNTP_DATA *)p;
-
- if (!p)
- return;
- p_delete(&data->entries);
- p_delete(&data->desc);
- p_delete(&data->cache);
- nntp_free_acache (data);
- p_delete(&data);
+ p_delete(&data->entries);
+ p_delete(&data->desc);
+ p_delete(&data->cache);
+ nntp_free_acache(data);
}
static int nntp_sync_mailbox (CONTEXT * ctx, int unused1, int* unused2)
{
}
static int nntp_sync_mailbox (CONTEXT * ctx, int unused1, int* unused2)
{
- NNTP_DATA *data = ctx->data;
+ nntp_data_t *data = ctx->data;
/* CACHE: update cache and .index files */
if ((option (OPTSAVEUNSUB) || data->subscribed))
/* CACHE: update cache and .index files */
if ((option (OPTSAVEUNSUB) || data->subscribed))
static void nntp_fastclose_mailbox (CONTEXT * ctx)
{
static void nntp_fastclose_mailbox (CONTEXT * ctx)
{
- NNTP_DATA *data = (NNTP_DATA *) ctx->data, *tmp;
+ nntp_data_t *data = (nntp_data_t *) ctx->data, *tmp;
nntp_save_cache_index (data->nserv);
if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
|| tmp != data)
nntp_save_cache_index (data->nserv);
if ((tmp = hash_find (data->nserv->newsgroups, data->group)) == NULL
|| tmp != data)
- nntp_delete_data (data);
+ nntp_data_delete(&data);
else
nntp_sync_sidebar (data);
}
else
nntp_sync_sidebar (data);
}
mutt_message _("Quitting newsgroup...");
if (ctx->data) {
mutt_message _("Quitting newsgroup...");
if (ctx->data) {
- NNTP_DATA *data = (NNTP_DATA *) ctx->data;
+ nntp_data_t *data = (nntp_data_t *) ctx->data;
int ret;
if (data->nserv && data->nserv->conn && ctx->unread) {
int ret;
if (data->nserv && data->nserv->conn && ctx->unread) {
}
}
nntp_sync_mailbox (ctx, 0, NULL);
}
}
nntp_sync_mailbox (ctx, 0, NULL);
- if (ctx->data && ((NNTP_DATA *) ctx->data)->nserv) {
+ if (ctx->data && ((nntp_data_t *) ctx->data)->nserv) {
- news = ((NNTP_DATA *) ctx->data)->nserv;
+ news = ((nntp_data_t *) ctx->data)->nserv;
newsrc_gen_entries (ctx);
newsrc_gen_entries (ctx);
- ((NNTP_DATA *) ctx->data)->unread = ctx->unread;
+ ((nntp_data_t *) ctx->data)->unread = ctx->unread;
mutt_newsrc_update (news);
}
mutt_clear_error ();
mutt_newsrc_update (news);
}
mutt_clear_error ();
}
/* use the GROUP command to poll for new mail */
}
/* use the GROUP command to poll for new mail */
-static int _nntp_check_mailbox (CONTEXT * ctx, NNTP_DATA * nntp_data)
+static int _nntp_check_mailbox (CONTEXT * ctx, nntp_data_t * nntp_data)
{
char buf[LONG_STRING];
int count = 0;
{
char buf[LONG_STRING];
int count = 0;
static int nntp_check_mailbox (CONTEXT * ctx, int* unused1, int unused2)
{
static int nntp_check_mailbox (CONTEXT * ctx, int* unused1, int unused2)
{
- return _nntp_check_mailbox (ctx, (NNTP_DATA *) ctx->data);
+ return _nntp_check_mailbox (ctx, (nntp_data_t *) ctx->data);
}
static int add_group (char *buf, void *serv)
}
static int add_group (char *buf, void *serv)
NNTP_SERVER *s = serv;
char group[LONG_STRING], mod, desc[HUGE_STRING];
int first, last;
NNTP_SERVER *s = serv;
char group[LONG_STRING], mod, desc[HUGE_STRING];
int first, last;
+ nntp_data_t *nntp_data;
static int n = 0;
_checked = n; /* _checked have N, where N = number of groups */
static int n = 0;
_checked = n; /* _checked have N, where N = number of groups */
sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
if (!group)
return 0;
sscanf (buf, "%s %d %d %c %[^\n]", group, &last, &first, &mod, desc);
if (!group)
return 0;
- if ((nntp_data = (NNTP_DATA *) hash_find (s->newsgroups, group)) == NULL) {
+ if ((nntp_data = (nntp_data_t *) hash_find (s->newsgroups, group)) == NULL) {
- nntp_data = xmalloc(sizeof(NNTP_DATA) + m_strlen(group) + 1);
- nntp_data->group = (char *) nntp_data + sizeof (NNTP_DATA);
+ nntp_data = xmalloc(sizeof(nntp_data_t) + m_strlen(group) + 1);
+ nntp_data->group = (char *) nntp_data + sizeof (nntp_data_t);
strcpy (nntp_data->group, group);
nntp_data->nserv = s;
if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
hash_insert (s->newsgroups, nntp_data->group, nntp_data);
strcpy (nntp_data->group, group);
nntp_data->nserv = s;
if (s->newsgroups->nelem < s->newsgroups->curnelem * 2)
hash_resize (s->newsgroups, s->newsgroups->nelem * 2);
hash_insert (s->newsgroups, nntp_data->group, nntp_data);
- nntp_add_to_list (s, nntp_data);
+ nntp_data_list_append(&s->list, nntp_data);
}
nntp_data->deleted = 0;
nntp_data->firstMessage = first;
}
nntp_data->deleted = 0;
nntp_data->firstMessage = first;
static int nntp_check_newgroups (NNTP_SERVER * serv, int force)
{
char buf[LONG_STRING];
static int nntp_check_newgroups (NNTP_SERVER * serv, int force)
{
char buf[LONG_STRING];
- NNTP_DATA nntp_data;
- string_list_t *l, **emp;
+ nntp_data_t nntp_data;
+ nntp_data_t *l, **emp;
time_t now;
struct tm *t;
time_t now;
struct tm *t;
for (l = serv->list; l; l = l->next) {
serv->check_time = 0; /* really check! */
for (l = serv->list; l; l = l->next) {
serv->check_time = 0; /* really check! */
- if (l->data && ((NNTP_DATA *) l->data)->subscribed)
- _nntp_check_mailbox (NULL, (NNTP_DATA *) l->data);
+ if (l->subscribed)
+ _nntp_check_mailbox (NULL, l);
t->tm_min, t->tm_sec);
nntp_data.nserv = serv;
if (Context && Context->magic == M_NNTP)
t->tm_min, t->tm_sec);
nntp_data.nserv = serv;
if (Context && Context->magic == M_NNTP)
- nntp_data.group = ((NNTP_DATA *) Context->data)->group;
+ nntp_data.group = ((nntp_data_t *) Context->data)->group;
else
nntp_data.group = NULL;
else
nntp_data.group = NULL;
+ emp = nntp_data_list_last(&serv->list);
if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."), NULL,
add_group, serv, 0) != 0) {
return -1;
if (mutt_nntp_fetch (&nntp_data, buf, _("Adding new newsgroups..."), NULL,
add_group, serv, 0) != 0) {
return -1;
mutt_message _("Loading descriptions...");
for (l = *emp; l; l = l->next) {
mutt_message _("Loading descriptions...");
for (l = *emp; l; l = l->next) {
- ((NNTP_DATA *)l->data)->new = 1;
- nntp_get_desc((NNTP_DATA *) l->data, ((NNTP_DATA *)l->data)->group,
- NULL, NULL);
+ l->new = 1;
+ nntp_get_desc(l, l->group, NULL, NULL);
}
if (*emp)
nntp_save_cache_index(serv);
}
if (*emp)
nntp_save_cache_index(serv);
int nntp_get_active (NNTP_SERVER * serv)
{
char msg[STRING];
int nntp_get_active (NNTP_SERVER * serv)
{
char msg[STRING];
- NNTP_DATA nntp_data;
- string_list_t *tmp;
+ nntp_data_t nntp_data, **tmp = &serv->list;
if (nntp_open_connection (serv) < 0)
return -1;
if (nntp_open_connection (serv) < 0)
return -1;
mutt_message (msg);
nntp_get_desc (&nntp_data, "*", msg, NULL);
mutt_message (msg);
nntp_get_desc (&nntp_data, "*", msg, NULL);
- for (tmp = serv->list; tmp; tmp = tmp->next) {
- NNTP_DATA *data = (NNTP_DATA *) tmp->data;
-
- if (data && data->deleted && !data->rc) {
- nntp_delete_cache (data);
- hash_remove (serv->newsgroups, data->group, NULL, nntp_delete_data);
- tmp->data = NULL;
+ while (*tmp) {
+ if ((*tmp)->deleted && !(*tmp)->rc) {
+ nntp_data_t *d = nntp_data_list_pop(tmp);
+ nntp_delete_cache(d);
+ hash_remove(serv->newsgroups, d->group, NULL, NULL);
+ nntp_data_delete(&d);
+ } else {
+ tmp = &(*tmp)->next;
}
}
nntp_save_cache_index (serv);
}
}
nntp_save_cache_index (serv);
int nntp_check_children (CONTEXT * ctx, const char *msgid)
{
int nntp_check_children (CONTEXT * ctx, const char *msgid)
{
- NNTP_DATA *nntp_data = (NNTP_DATA *) ctx->data;
+ nntp_data_t *nntp_data = (nntp_data_t *) ctx->data;
char buf[STRING];
int i, ret = 0, tmp = 0;
CHILD_CONTEXT cc = { ctx, 0, 0, NULL };
char buf[STRING];
int i, ret = 0, tmp = 0;
CHILD_CONTEXT cc = { ctx, 0, 0, NULL };
#define NNTP_CACHE_LEN 10
enum {
#define NNTP_CACHE_LEN 10
enum {
- NNTP_NONE = 0,
- NNTP_OK,
- NNTP_BYE
+ NNTP_NONE = 0,
+ NNTP_OK,
+ NNTP_BYE
+typedef struct nntp_data_t nntp_data_t;
+
- unsigned feat_known : 1;
- unsigned hasXPAT : 1;
- unsigned hasXGTITLE : 1;
- unsigned hasXOVER : 1;
- unsigned hasLISTGROUP : 1;
- unsigned status : 3;
- char *newsrc;
- char *cache;
- int stat;
- off_t size;
- time_t mtime;
- time_t newgroups_time;
- time_t check_time;
- hash_t *newsgroups;
- string_list_t *list; /* list of newsgroups */
- string_list_t **tail; /* last entry of list */
- CONNECTION *conn;
+ unsigned feat_known : 1;
+ unsigned hasXPAT : 1;
+ unsigned hasXGTITLE : 1;
+ unsigned hasXOVER : 1;
+ unsigned hasLISTGROUP : 1;
+ unsigned status : 3;
+ char *newsrc;
+ char *cache;
+ int stat;
+ off_t size;
+ time_t mtime;
+ time_t newgroups_time;
+ time_t check_time;
+ hash_t *newsgroups;
+ nntp_data_t *list; /* list of newsgroups */
+ CONNECTION *conn;
} NNTP_SERVER;
typedef struct {
} NNTP_SERVER;
typedef struct {
- int index;
- char *path;
+ int index;
+ char *path;
} NNTP_CACHE;
typedef struct {
} NNTP_CACHE;
typedef struct {
-typedef struct {
- NEWSRC_ENTRY *entries;
- int num; /* number of used entries */
- int max; /* number of allocated entries */
- int unread;
- int firstMessage;
- int lastMessage;
- int lastLoaded;
- int lastCached;
- unsigned subscribed:1;
- unsigned rc:1;
- unsigned new:1;
- unsigned allowed:1;
- unsigned deleted:1;
- char *group;
- char *desc;
- char *cache;
- NNTP_SERVER *nserv;
- NNTP_CACHE acache[NNTP_CACHE_LEN];
-} NNTP_DATA;
+struct nntp_data_t {
+ struct nntp_data_t *next;
+
+ NEWSRC_ENTRY *entries;
+ int num; /* number of used entries */
+ int max; /* number of allocated entries */
+ int unread;
+ int firstMessage;
+ int lastMessage;
+ int lastLoaded;
+ int lastCached;
+ unsigned subscribed:1;
+ unsigned rc:1;
+ unsigned new:1;
+ unsigned allowed:1;
+ unsigned deleted:1;
+ char *group;
+ char *desc;
+ char *cache;
+ NNTP_SERVER *nserv;
+ NNTP_CACHE acache[NNTP_CACHE_LEN];
+};
+
+DO_INIT(nntp_data_t, nntp_data);
+void nntp_data_wipe(nntp_data_t *);
+DO_NEW(nntp_data_t, nntp_data);
+DO_DELETE(nntp_data_t, nntp_data);
+DO_SLIST(nntp_data_t, nntp_data, nntp_data_delete);
NNTP_SERVER *mutt_select_newsserver (char *);
NNTP_SERVER *mutt_select_newsserver (char *);
-NNTP_DATA *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
-NNTP_DATA *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
-NNTP_DATA *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
-NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
+nntp_data_t *mutt_newsgroup_subscribe (NNTP_SERVER *, char *);
+nntp_data_t *mutt_newsgroup_unsubscribe (NNTP_SERVER *, char *);
+nntp_data_t *mutt_newsgroup_catchup (NNTP_SERVER *, char *);
+nntp_data_t *mutt_newsgroup_uncatchup (NNTP_SERVER *, char *);
void nntp_clear_cacheindex (NNTP_SERVER *);
int mutt_newsrc_update (NNTP_SERVER *);
int nntp_close_mailbox (CONTEXT *);
void nntp_clear_cacheindex (NNTP_SERVER *);
int mutt_newsrc_update (NNTP_SERVER *);
int nntp_close_mailbox (CONTEXT *);
void nntp_logout_all(void);
const char *nntp_format_str(char *, ssize_t, char, const char *, const char *,
const char *, const char *, anytype, format_flag);
void nntp_logout_all(void);
const char *nntp_format_str(char *, ssize_t, char, const char *, const char *,
const char *, const char *, anytype, format_flag);
-void nntp_sync_sidebar (NNTP_DATA*);
+void nntp_sync_sidebar (nntp_data_t*);
WHERE NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
WHERE NNTP_SERVER *CurrentNewsSrv INITVAL (NULL);
CHECK_MODE (IsHeader (extra) && !IsAttach (extra));
CHECK_ATTACH;
if (extra->ctx && extra->ctx->magic == M_NNTP &&
CHECK_MODE (IsHeader (extra) && !IsAttach (extra));
CHECK_ATTACH;
if (extra->ctx && extra->ctx->magic == M_NNTP &&
- !((NNTP_DATA *) extra->ctx->data)->allowed &&
+ !((nntp_data_t *) extra->ctx->data)->allowed &&
query_quadoption (OPT_TOMODERATED,
_
("Posting to this group not allowed, may be moderated. Continue?"))
query_quadoption (OPT_TOMODERATED,
_
("Posting to this group not allowed, may be moderated. Continue?"))
CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
CHECK_ATTACH;
if (extra->ctx && extra->ctx->magic == M_NNTP &&
CHECK_MODE (IsHeader (extra) || IsMsgAttach (extra));
CHECK_ATTACH;
if (extra->ctx && extra->ctx->magic == M_NNTP &&
- !((NNTP_DATA *) extra->ctx->data)->allowed &&
+ !((nntp_data_t *) extra->ctx->data)->allowed &&
query_quadoption (OPT_TOMODERATED,
_
("Posting to this group not allowed, may be moderated. Continue?"))
query_quadoption (OPT_TOMODERATED,
_
("Posting to this group not allowed, may be moderated. Continue?"))
query_quadoption (OPT_FOLLOWUPTOPOSTER,
_("Reply by mail as poster prefers?")) != M_YES) {
if (extra->ctx && extra->ctx->magic == M_NNTP
query_quadoption (OPT_FOLLOWUPTOPOSTER,
_("Reply by mail as poster prefers?")) != M_YES) {
if (extra->ctx && extra->ctx->magic == M_NNTP
- && !((NNTP_DATA *) extra->ctx->data)->allowed
+ && !((nntp_data_t *) extra->ctx->data)->allowed
&& query_quadoption (OPT_TOMODERATED,
_
("Posting to this group not allowed, may be moderated. Continue?"))
&& query_quadoption (OPT_TOMODERATED,
_
("Posting to this group not allowed, may be moderated. Continue?"))
#ifdef USE_NNTP
if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP
&& !msg->env->newsgroups)
#ifdef USE_NNTP
if ((flags & SENDNEWS) && ctx && ctx->magic == M_NNTP
&& !msg->env->newsgroups)
- msg->env->newsgroups = m_strdup(((NNTP_DATA *) ctx->data)->group);
+ msg->env->newsgroups = m_strdup(((nntp_data_t *)ctx->data)->group);
#endif
if (!(option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&
#endif
if (!(option (OPTAUTOEDIT) && option (OPTEDITHDRS)) &&