struct BodyCache;
/**
- * nntp_data_find - Find NntpData for given newsgroup or add it
+ * mdata_find - Find NntpMboxData for given newsgroup or add it
* @param nserv NNTP server
* @param group Newsgroup
* @retval ptr NNTP data
* @retval NULL Error
*/
-static struct NntpData *nntp_data_find(struct NntpServer *nserv, const char *group)
+static struct NntpMboxData *mdata_find(struct NntpServer *nserv, const char *group)
{
- struct NntpData *nntp_data = mutt_hash_find(nserv->groups_hash, group);
- if (nntp_data)
- return nntp_data;
+ struct NntpMboxData *mdata = mutt_hash_find(nserv->groups_hash, group);
+ if (mdata)
+ return mdata;
size_t len = strlen(group) + 1;
- /* create NntpData structure and add it to hash */
- nntp_data = mutt_mem_calloc(1, sizeof(struct NntpData) + len);
- nntp_data->group = (char *) nntp_data + sizeof(struct NntpData);
- mutt_str_strfcpy(nntp_data->group, group, len);
- nntp_data->nserv = nserv;
- nntp_data->deleted = true;
- mutt_hash_insert(nserv->groups_hash, nntp_data->group, nntp_data);
-
- /* add NntpData to list */
+ /* create NntpMboxData structure and add it to hash */
+ mdata = mutt_mem_calloc(1, sizeof(struct NntpMboxData) + len);
+ mdata->group = (char *) mdata + sizeof(struct NntpMboxData);
+ mutt_str_strfcpy(mdata->group, group, len);
+ mdata->nserv = nserv;
+ mdata->deleted = true;
+ mutt_hash_insert(nserv->groups_hash, mdata->group, mdata);
+
+ /* add NntpMboxData to list */
if (nserv->groups_num >= nserv->groups_max)
{
nserv->groups_max *= 2;
- mutt_mem_realloc(&nserv->groups_list, nserv->groups_max * sizeof(nntp_data));
+ mutt_mem_realloc(&nserv->groups_list, nserv->groups_max * sizeof(mdata));
}
- nserv->groups_list[nserv->groups_num++] = nntp_data;
+ nserv->groups_list[nserv->groups_num++] = mdata;
- return nntp_data;
+ return mdata;
}
/**
* nntp_acache_free - Remove all temporarily cache files
- * @param nntp_data NNTP data
+ * @param mdata NNTP Mailbox data
*/
-void nntp_acache_free(struct NntpData *nntp_data)
+void nntp_acache_free(struct NntpMboxData *mdata)
{
for (int i = 0; i < NNTP_ACACHE_LEN; i++)
{
- if (nntp_data->acache[i].path)
+ if (mdata->acache[i].path)
{
- unlink(nntp_data->acache[i].path);
- FREE(&nntp_data->acache[i].path);
+ unlink(mdata->acache[i].path);
+ FREE(&mdata->acache[i].path);
}
}
}
/**
- * nntp_data_free - Free NntpData, used to destroy hash elements
+ * nntp_data_free - Free NntpMboxData, used to destroy hash elements
* @param data NNTP data
*/
void nntp_data_free(void *data)
{
- struct NntpData *nntp_data = data;
+ struct NntpMboxData *mdata = data;
- if (!nntp_data)
+ if (!mdata)
return;
- nntp_acache_free(nntp_data);
- mutt_bcache_close(&nntp_data->bcache);
- FREE(&nntp_data->newsrc_ent);
- FREE(&nntp_data->desc);
+ nntp_acache_free(mdata);
+ mutt_bcache_close(&mdata->bcache);
+ FREE(&mdata->newsrc_ent);
+ FREE(&mdata->desc);
FREE(&data);
}
/**
* nntp_group_unread_stat - Count number of unread articles using .newsrc data
- * @param nntp_data NNTP data
+ * @param mdata NNTP Mailbox data
*/
-void nntp_group_unread_stat(struct NntpData *nntp_data)
+void nntp_group_unread_stat(struct NntpMboxData *mdata)
{
- nntp_data->unread = 0;
- if (nntp_data->last_message == 0 || nntp_data->first_message > nntp_data->last_message)
+ mdata->unread = 0;
+ if (mdata->last_message == 0 || mdata->first_message > mdata->last_message)
return;
- nntp_data->unread = nntp_data->last_message - nntp_data->first_message + 1;
- for (unsigned int i = 0; i < nntp_data->newsrc_len; i++)
+ mdata->unread = mdata->last_message - mdata->first_message + 1;
+ for (unsigned int i = 0; i < mdata->newsrc_len; i++)
{
- anum_t first = nntp_data->newsrc_ent[i].first;
- if (first < nntp_data->first_message)
- first = nntp_data->first_message;
- anum_t last = nntp_data->newsrc_ent[i].last;
- if (last > nntp_data->last_message)
- last = nntp_data->last_message;
+ anum_t first = mdata->newsrc_ent[i].first;
+ if (first < mdata->first_message)
+ first = mdata->first_message;
+ anum_t last = mdata->newsrc_ent[i].last;
+ if (last > mdata->last_message)
+ last = mdata->last_message;
if (first <= last)
- nntp_data->unread -= last - first + 1;
+ mdata->unread -= last - first + 1;
}
}
/* .newsrc has been externally modified or hasn't been loaded yet */
for (unsigned int i = 0; i < nserv->groups_num; i++)
{
- struct NntpData *nntp_data = nserv->groups_list[i];
+ struct NntpMboxData *mdata = nserv->groups_list[i];
- if (!nntp_data)
+ if (!mdata)
continue;
- nntp_data->subscribed = false;
- nntp_data->newsrc_len = 0;
- FREE(&nntp_data->newsrc_ent);
+ mdata->subscribed = false;
+ mdata->newsrc_len = 0;
+ FREE(&mdata->newsrc_ent);
}
line = mutt_mem_malloc(sb.st_size + 1);
*p++ = '\0';
/* get newsgroup data */
- struct NntpData *nntp_data = nntp_data_find(nserv, line);
- FREE(&nntp_data->newsrc_ent);
+ struct NntpMboxData *mdata = mdata_find(nserv, line);
+ FREE(&mdata->newsrc_ent);
/* count number of entries */
b = p;
while (*b)
if (*b++ == ',')
j++;
- nntp_data->newsrc_ent = mutt_mem_calloc(j, sizeof(struct NewsrcEntry));
- nntp_data->subscribed = subs;
+ mdata->newsrc_ent = mutt_mem_calloc(j, sizeof(struct NewsrcEntry));
+ mdata->subscribed = subs;
/* parse entries */
j = 0;
else
h = b;
- if (sscanf(b, ANUM, &nntp_data->newsrc_ent[j].first) == 1 &&
- sscanf(h, ANUM, &nntp_data->newsrc_ent[j].last) == 1)
+ if (sscanf(b, ANUM, &mdata->newsrc_ent[j].first) == 1 &&
+ sscanf(h, ANUM, &mdata->newsrc_ent[j].last) == 1)
{
j++;
}
}
if (j == 0)
{
- nntp_data->newsrc_ent[j].first = 1;
- nntp_data->newsrc_ent[j].last = 0;
+ mdata->newsrc_ent[j].first = 1;
+ mdata->newsrc_ent[j].last = 0;
j++;
}
- if (nntp_data->last_message == 0)
- nntp_data->last_message = nntp_data->newsrc_ent[j - 1].last;
- nntp_data->newsrc_len = j;
- mutt_mem_realloc(&nntp_data->newsrc_ent, j * sizeof(struct NewsrcEntry));
- nntp_group_unread_stat(nntp_data);
- mutt_debug(2, "%s\n", nntp_data->group);
+ if (mdata->last_message == 0)
+ mdata->last_message = mdata->newsrc_ent[j - 1].last;
+ mdata->newsrc_len = j;
+ mutt_mem_realloc(&mdata->newsrc_ent, j * sizeof(struct NewsrcEntry));
+ nntp_group_unread_stat(mdata);
+ mutt_debug(2, "%s\n", mdata->group);
}
FREE(&line);
return 1;
*/
void nntp_newsrc_gen_entries(struct Context *ctx)
{
- struct NntpData *nntp_data = ctx->mailbox->data;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
anum_t last = 0, first = 1;
bool series;
int save_sort = SORT_ORDER;
mutt_sort_headers(ctx, false);
}
- entries = nntp_data->newsrc_len;
+ entries = mdata->newsrc_len;
if (!entries)
{
entries = 5;
- nntp_data->newsrc_ent = mutt_mem_calloc(entries, sizeof(struct NewsrcEntry));
+ mdata->newsrc_ent = mutt_mem_calloc(entries, sizeof(struct NewsrcEntry));
}
/* Set up to fake initial sequence from 1 to the article before the
* first article in our list */
- nntp_data->newsrc_len = 0;
+ mdata->newsrc_len = 0;
series = true;
for (int i = 0; i < ctx->mailbox->msg_count; i++)
{
{
/* We don't actually check sequential order, since we mark
* "missing" entries as read/deleted */
- last = NHDR(ctx->mailbox->hdrs[i])->article_num;
- if (last >= nntp_data->first_message && !ctx->mailbox->hdrs[i]->deleted &&
+ last = NNTP_EDATA(ctx->mailbox->hdrs[i])->article_num;
+ if (last >= mdata->first_message && !ctx->mailbox->hdrs[i]->deleted &&
!ctx->mailbox->hdrs[i]->read)
{
- if (nntp_data->newsrc_len >= entries)
+ if (mdata->newsrc_len >= entries)
{
entries *= 2;
- mutt_mem_realloc(&nntp_data->newsrc_ent, entries * sizeof(struct NewsrcEntry));
+ mutt_mem_realloc(&mdata->newsrc_ent, entries * sizeof(struct NewsrcEntry));
}
- nntp_data->newsrc_ent[nntp_data->newsrc_len].first = first;
- nntp_data->newsrc_ent[nntp_data->newsrc_len].last = last - 1;
- nntp_data->newsrc_len++;
+ mdata->newsrc_ent[mdata->newsrc_len].first = first;
+ mdata->newsrc_ent[mdata->newsrc_len].last = last - 1;
+ mdata->newsrc_len++;
series = false;
}
}
first = last + 1;
series = true;
}
- last = NHDR(ctx->mailbox->hdrs[i])->article_num;
+ last = NNTP_EDATA(ctx->mailbox->hdrs[i])->article_num;
}
}
- if (series && first <= nntp_data->last_loaded)
+ if (series && first <= mdata->last_loaded)
{
- if (nntp_data->newsrc_len >= entries)
+ if (mdata->newsrc_len >= entries)
{
entries++;
- mutt_mem_realloc(&nntp_data->newsrc_ent, entries * sizeof(struct NewsrcEntry));
+ mutt_mem_realloc(&mdata->newsrc_ent, entries * sizeof(struct NewsrcEntry));
}
- nntp_data->newsrc_ent[nntp_data->newsrc_len].first = first;
- nntp_data->newsrc_ent[nntp_data->newsrc_len].last = nntp_data->last_loaded;
- nntp_data->newsrc_len++;
+ mdata->newsrc_ent[mdata->newsrc_len].first = first;
+ mdata->newsrc_ent[mdata->newsrc_len].last = mdata->last_loaded;
+ mdata->newsrc_len++;
}
- mutt_mem_realloc(&nntp_data->newsrc_ent, nntp_data->newsrc_len * sizeof(struct NewsrcEntry));
+ mutt_mem_realloc(&mdata->newsrc_ent, mdata->newsrc_len * sizeof(struct NewsrcEntry));
if (save_sort != Sort)
{
/* we will generate full newsrc here */
for (unsigned int i = 0; i < nserv->groups_num; i++)
{
- struct NntpData *nntp_data = nserv->groups_list[i];
+ struct NntpMboxData *mdata = nserv->groups_list[i];
- if (!nntp_data || !nntp_data->newsrc_ent)
+ if (!mdata || !mdata->newsrc_ent)
continue;
/* write newsgroup name */
- if (off + strlen(nntp_data->group) + 3 > buflen)
+ if (off + strlen(mdata->group) + 3 > buflen)
{
buflen *= 2;
mutt_mem_realloc(&buf, buflen);
}
- snprintf(buf + off, buflen - off, "%s%c ", nntp_data->group,
- nntp_data->subscribed ? ':' : '!');
+ snprintf(buf + off, buflen - off, "%s%c ", mdata->group,
+ mdata->subscribed ? ':' : '!');
off += strlen(buf + off);
/* write entries */
- for (unsigned int j = 0; j < nntp_data->newsrc_len; j++)
+ for (unsigned int j = 0; j < mdata->newsrc_len; j++)
{
if (off + LONG_STRING > buflen)
{
}
if (j)
buf[off++] = ',';
- if (nntp_data->newsrc_ent[j].first == nntp_data->newsrc_ent[j].last)
- snprintf(buf + off, buflen - off, "%u", nntp_data->newsrc_ent[j].first);
- else if (nntp_data->newsrc_ent[j].first < nntp_data->newsrc_ent[j].last)
+ if (mdata->newsrc_ent[j].first == mdata->newsrc_ent[j].last)
+ snprintf(buf + off, buflen - off, "%u", mdata->newsrc_ent[j].first);
+ else if (mdata->newsrc_ent[j].first < mdata->newsrc_ent[j].last)
{
snprintf(buf + off, buflen - off, "%u-%u",
- nntp_data->newsrc_ent[j].first, nntp_data->newsrc_ent[j].last);
+ mdata->newsrc_ent[j].first, mdata->newsrc_ent[j].last);
}
off += strlen(buf + off);
}
int nntp_add_group(char *line, void *data)
{
struct NntpServer *nserv = data;
- struct NntpData *nntp_data = NULL;
+ struct NntpMboxData *mdata = NULL;
char group[LONG_STRING] = "";
char desc[HUGE_STRING] = "";
char mod;
return 0;
}
- nntp_data = nntp_data_find(nserv, group);
- nntp_data->deleted = false;
- nntp_data->first_message = first;
- nntp_data->last_message = last;
- nntp_data->allowed = (mod == 'y') || (mod == 'm');
- mutt_str_replace(&nntp_data->desc, desc);
- if (nntp_data->newsrc_ent || nntp_data->last_cached)
- nntp_group_unread_stat(nntp_data);
- else if (nntp_data->last_message && nntp_data->first_message <= nntp_data->last_message)
- nntp_data->unread = nntp_data->last_message - nntp_data->first_message + 1;
+ mdata = mdata_find(nserv, group);
+ mdata->deleted = false;
+ mdata->first_message = first;
+ mdata->last_message = last;
+ mdata->allowed = (mod == 'y') || (mod == 'm');
+ mutt_str_replace(&mdata->desc, desc);
+ if (mdata->newsrc_ent || mdata->last_cached)
+ nntp_group_unread_stat(mdata);
+ else if (mdata->last_message && mdata->first_message <= mdata->last_message)
+ mdata->unread = mdata->last_message - mdata->first_message + 1;
else
- nntp_data->unread = 0;
+ mdata->unread = 0;
return 0;
}
for (unsigned int i = 0; i < nserv->groups_num; i++)
{
- struct NntpData *nntp_data = nserv->groups_list[i];
+ struct NntpMboxData *mdata = nserv->groups_list[i];
- if (!nntp_data || nntp_data->deleted)
+ if (!mdata || mdata->deleted)
continue;
- if (off + strlen(nntp_data->group) + (nntp_data->desc ? strlen(nntp_data->desc) : 0) + 50 > buflen)
+ if (off + strlen(mdata->group) + (mdata->desc ? strlen(mdata->desc) : 0) + 50 > buflen)
{
buflen *= 2;
mutt_mem_realloc(&buf, buflen);
}
- snprintf(buf + off, buflen - off, "%s %u %u %c%s%s\n", nntp_data->group,
- nntp_data->last_message, nntp_data->first_message,
- nntp_data->allowed ? 'y' : 'n', nntp_data->desc ? " " : "",
- nntp_data->desc ? nntp_data->desc : "");
+ snprintf(buf + off, buflen - off, "%s %u %u %c%s%s\n", mdata->group,
+ mdata->last_message, mdata->first_message,
+ mdata->allowed ? 'y' : 'n', mdata->desc ? " " : "",
+ mdata->desc ? mdata->desc : "");
off += strlen(buf + off);
}
/**
* nntp_hcache_open - Open newsgroup hcache
- * @param nntp_data NNTP data
+ * @param mdata NNTP Mailbox data
* @retval ptr Header cache
* @retval NULL Error
*/
-header_cache_t *nntp_hcache_open(struct NntpData *nntp_data)
+header_cache_t *nntp_hcache_open(struct NntpMboxData *mdata)
{
struct Url url;
char file[PATH_MAX];
- if (!nntp_data->nserv || !nntp_data->nserv->cacheable ||
- !nntp_data->nserv->conn || !nntp_data->group ||
- !(nntp_data->newsrc_ent || nntp_data->subscribed || SaveUnsubscribed))
+ if (!mdata->nserv || !mdata->nserv->cacheable ||
+ !mdata->nserv->conn || !mdata->group ||
+ !(mdata->newsrc_ent || mdata->subscribed || SaveUnsubscribed))
{
return NULL;
}
- mutt_account_tourl(&nntp_data->nserv->conn->account, &url);
- url.path = nntp_data->group;
+ mutt_account_tourl(&mdata->nserv->conn->account, &url);
+ url.path = mdata->group;
url_tostring(&url, file, sizeof(file), U_PATH);
return mutt_hcache_open(NewsCacheDir, file, nntp_hcache_namer);
}
/**
* nntp_hcache_update - Remove stale cached headers
- * @param nntp_data NNTP data
- * @param hc Header cache
+ * @param mdata NNTP Mailbox data
+ * @param hc Header cache
*/
-void nntp_hcache_update(struct NntpData *nntp_data, header_cache_t *hc)
+void nntp_hcache_update(struct NntpMboxData *mdata, header_cache_t *hc)
{
char buf[16];
bool old = false;
if (sscanf(hdata, ANUM " " ANUM, &first, &last) == 2)
{
old = true;
- nntp_data->last_cached = last;
+ mdata->last_cached = last;
/* clean removed headers from cache */
for (anum_t current = first; current <= last; current++)
{
- if (current >= nntp_data->first_message && current <= nntp_data->last_message)
+ if (current >= mdata->first_message && current <= mdata->last_message)
continue;
snprintf(buf, sizeof(buf), "%u", current);
}
/* store current values of first and last */
- if (!old || nntp_data->first_message != first || nntp_data->last_message != last)
+ if (!old || mdata->first_message != first || mdata->last_message != last)
{
- snprintf(buf, sizeof(buf), "%u %u", nntp_data->first_message, nntp_data->last_message);
+ snprintf(buf, sizeof(buf), "%u %u", mdata->first_message, mdata->last_message);
mutt_debug(2, "mutt_hcache_store index: %s\n", buf);
mutt_hcache_store_raw(hc, "index", 5, buf, strlen(buf));
}
*/
static int nntp_bcache_delete(const char *id, struct BodyCache *bcache, void *data)
{
- struct NntpData *nntp_data = data;
+ struct NntpMboxData *mdata = data;
anum_t anum;
char c;
- if (!nntp_data || sscanf(id, ANUM "%c", &anum, &c) != 1 ||
- anum < nntp_data->first_message || anum > nntp_data->last_message)
+ if (!mdata || sscanf(id, ANUM "%c", &anum, &c) != 1 ||
+ anum < mdata->first_message || anum > mdata->last_message)
{
- if (nntp_data)
+ if (mdata)
mutt_debug(2, "mutt_bcache_del %s\n", id);
mutt_bcache_del(bcache, id);
}
/**
* nntp_bcache_update - Remove stale cached messages
- * @param nntp_data NNTP data
+ * @param mdata NNTP Mailbox data
*/
-void nntp_bcache_update(struct NntpData *nntp_data)
+void nntp_bcache_update(struct NntpMboxData *mdata)
{
- mutt_bcache_list(nntp_data->bcache, nntp_bcache_delete, nntp_data);
+ mutt_bcache_list(mdata->bcache, nntp_bcache_delete, mdata);
}
/**
* nntp_delete_group_cache - Remove hcache and bcache of newsgroup
- * @param nntp_data NNTP data
+ * @param mdata NNTP Mailbox data
*/
-void nntp_delete_group_cache(struct NntpData *nntp_data)
+void nntp_delete_group_cache(struct NntpMboxData *mdata)
{
- if (!nntp_data || !nntp_data->nserv || !nntp_data->nserv->cacheable)
+ if (!mdata || !mdata->nserv || !mdata->nserv->cacheable)
return;
#ifdef USE_HCACHE
char file[PATH_MAX];
- nntp_hcache_namer(nntp_data->group, file, sizeof(file));
- cache_expand(file, sizeof(file), &nntp_data->nserv->conn->account, file);
+ nntp_hcache_namer(mdata->group, file, sizeof(file));
+ cache_expand(file, sizeof(file), &mdata->nserv->conn->account, file);
unlink(file);
- nntp_data->last_cached = 0;
+ mdata->last_cached = 0;
mutt_debug(2, "%s\n", file);
#endif
- if (!nntp_data->bcache)
+ if (!mdata->bcache)
{
- nntp_data->bcache =
- mutt_bcache_open(&nntp_data->nserv->conn->account, nntp_data->group);
+ mdata->bcache = mutt_bcache_open(&mdata->nserv->conn->account, mdata->group);
}
- if (nntp_data->bcache)
+ if (mdata->bcache)
{
- mutt_debug(2, "%s/*\n", nntp_data->group);
- mutt_bcache_list(nntp_data->bcache, nntp_bcache_delete, NULL);
- mutt_bcache_close(&nntp_data->bcache);
+ mutt_debug(2, "%s/*\n", mdata->group);
+ mutt_bcache_list(mdata->bcache, nntp_bcache_delete, NULL);
+ mutt_bcache_close(&mdata->bcache);
}
}
{
char *group = entry->d_name;
struct stat sb;
- struct NntpData *nntp_data = NULL;
- struct NntpData nntp_tmp;
+ struct NntpMboxData *mdata = NULL;
+ struct NntpMboxData nntp_tmp;
if ((mutt_str_strcmp(group, ".") == 0) || (mutt_str_strcmp(group, "..") == 0))
continue;
if (!S_ISDIR(sb.st_mode))
continue;
- nntp_data = mutt_hash_find(nserv->groups_hash, group);
- if (!nntp_data)
+ mdata = mutt_hash_find(nserv->groups_hash, group);
+ if (!mdata)
{
- nntp_data = &nntp_tmp;
- nntp_data->nserv = nserv;
- nntp_data->group = group;
- nntp_data->bcache = NULL;
+ mdata = &nntp_tmp;
+ mdata->nserv = nserv;
+ mdata->group = group;
+ mdata->bcache = NULL;
}
- else if (nntp_data->newsrc_ent || nntp_data->subscribed || SaveUnsubscribed)
+ else if (mdata->newsrc_ent || mdata->subscribed || SaveUnsubscribed)
continue;
- nntp_delete_group_cache(nntp_data);
+ nntp_delete_group_cache(mdata);
if (S_ISDIR(sb.st_mode))
{
rmdir(file);
int rc;
struct ConnAccount acct;
struct NntpServer *nserv = NULL;
- struct NntpData *nntp_data = NULL;
+ struct NntpMboxData *mdata = NULL;
struct Connection *conn = NULL;
struct Url url;
nserv->groups_hash = mutt_hash_create(1009, 0);
mutt_hash_set_destructor(nserv->groups_hash, nntp_hash_destructor_t, 0);
nserv->groups_max = 16;
- nserv->groups_list = mutt_mem_malloc(nserv->groups_max * sizeof(nntp_data));
+ nserv->groups_list = mutt_mem_malloc(nserv->groups_max * sizeof(mdata));
rc = nntp_open_connection(nserv);
if (strlen(group) < 8 || (strcmp(p, ".hcache") != 0))
continue;
*p = '\0';
- nntp_data = mutt_hash_find(nserv->groups_hash, group);
- if (!nntp_data)
+ mdata = mutt_hash_find(nserv->groups_hash, group);
+ if (!mdata)
continue;
- hc = nntp_hcache_open(nntp_data);
+ hc = nntp_hcache_open(mdata);
if (!hc)
continue;
if (sscanf(hdata, ANUM " " ANUM, &first, &last) == 2)
{
- if (nntp_data->deleted)
+ if (mdata->deleted)
{
- nntp_data->first_message = first;
- nntp_data->last_message = last;
+ mdata->first_message = first;
+ mdata->last_message = last;
}
- if (last >= nntp_data->first_message && last <= nntp_data->last_message)
+ if (last >= mdata->first_message && last <= mdata->last_message)
{
- nntp_data->last_cached = last;
- mutt_debug(2, "%s last_cached=%u\n", nntp_data->group, last);
+ mdata->last_cached = last;
+ mutt_debug(2, "%s last_cached=%u\n", mdata->group, last);
}
}
mutt_hcache_free(hc, &hdata);
/**
* nntp_article_status - Get status of articles from .newsrc
* @param mailbox Mailbox
- * @param e Email Header
+ * @param e Email
* @param group Newsgroup
* @param anum Article number
*
*/
void nntp_article_status(struct Mailbox *mailbox, struct Email *e, char *group, anum_t anum)
{
- struct NntpData *nntp_data = mailbox->data;
+ struct NntpMboxData *mdata = mailbox->data;
if (group)
- nntp_data = mutt_hash_find(nntp_data->nserv->groups_hash, group);
+ mdata = mutt_hash_find(mdata->nserv->groups_hash, group);
- if (!nntp_data)
+ if (!mdata)
return;
- for (unsigned int i = 0; i < nntp_data->newsrc_len; i++)
+ for (unsigned int i = 0; i < mdata->newsrc_len; i++)
{
- if ((anum >= nntp_data->newsrc_ent[i].first) &&
- (anum <= nntp_data->newsrc_ent[i].last))
+ if ((anum >= mdata->newsrc_ent[i].first) &&
+ (anum <= mdata->newsrc_ent[i].last))
{
/* can't use mutt_set_flag() because mx_update_context()
didn't get called yet */
}
/* article was not cached yet, it's new */
- if (anum > nntp_data->last_cached)
+ if (anum > mdata->last_cached)
return;
/* article isn't read but cached, it's old */
* @retval ptr NNTP data
* @retval NULL Error
*/
-struct NntpData *mutt_newsgroup_subscribe(struct NntpServer *nserv, char *group)
+struct NntpMboxData *mutt_newsgroup_subscribe(struct NntpServer *nserv, char *group)
{
- struct NntpData *nntp_data = NULL;
+ struct NntpMboxData *mdata = NULL;
if (!nserv || !nserv->groups_hash || !group || !*group)
return NULL;
- nntp_data = nntp_data_find(nserv, group);
- nntp_data->subscribed = true;
- if (!nntp_data->newsrc_ent)
+ mdata = mdata_find(nserv, group);
+ mdata->subscribed = true;
+ if (!mdata->newsrc_ent)
{
- nntp_data->newsrc_ent = mutt_mem_calloc(1, sizeof(struct NewsrcEntry));
- nntp_data->newsrc_len = 1;
- nntp_data->newsrc_ent[0].first = 1;
- nntp_data->newsrc_ent[0].last = 0;
+ mdata->newsrc_ent = mutt_mem_calloc(1, sizeof(struct NewsrcEntry));
+ mdata->newsrc_len = 1;
+ mdata->newsrc_ent[0].first = 1;
+ mdata->newsrc_ent[0].last = 0;
}
- return nntp_data;
+ return mdata;
}
/**
* @retval ptr NNTP data
* @retval NULL Error
*/
-struct NntpData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *group)
+struct NntpMboxData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *group)
{
- struct NntpData *nntp_data = NULL;
+ struct NntpMboxData *mdata = NULL;
if (!nserv || !nserv->groups_hash || !group || !*group)
return NULL;
- nntp_data = mutt_hash_find(nserv->groups_hash, group);
- if (!nntp_data)
+ mdata = mutt_hash_find(nserv->groups_hash, group);
+ if (!mdata)
return NULL;
- nntp_data->subscribed = false;
+ mdata->subscribed = false;
if (!SaveUnsubscribed)
{
- nntp_data->newsrc_len = 0;
- FREE(&nntp_data->newsrc_ent);
+ mdata->newsrc_len = 0;
+ FREE(&mdata->newsrc_ent);
}
- return nntp_data;
+ return mdata;
}
/**
* @retval ptr NNTP data
* @retval NULL Error
*/
-struct NntpData *mutt_newsgroup_catchup(struct Context *ctx,
+struct NntpMboxData *mutt_newsgroup_catchup(struct Context *ctx,
struct NntpServer *nserv, char *group)
{
- struct NntpData *nntp_data = NULL;
+ struct NntpMboxData *mdata = NULL;
if (!nserv || !nserv->groups_hash || !group || !*group)
return NULL;
- nntp_data = mutt_hash_find(nserv->groups_hash, group);
- if (!nntp_data)
+ mdata = mutt_hash_find(nserv->groups_hash, group);
+ if (!mdata)
return NULL;
- if (nntp_data->newsrc_ent)
+ if (mdata->newsrc_ent)
{
- mutt_mem_realloc(&nntp_data->newsrc_ent, sizeof(struct NewsrcEntry));
- nntp_data->newsrc_len = 1;
- nntp_data->newsrc_ent[0].first = 1;
- nntp_data->newsrc_ent[0].last = nntp_data->last_message;
+ mutt_mem_realloc(&mdata->newsrc_ent, sizeof(struct NewsrcEntry));
+ mdata->newsrc_len = 1;
+ mdata->newsrc_ent[0].first = 1;
+ mdata->newsrc_ent[0].last = mdata->last_message;
}
- nntp_data->unread = 0;
- if (ctx && ctx->mailbox->data == nntp_data)
+ mdata->unread = 0;
+ if (ctx && ctx->mailbox->data == mdata)
{
for (unsigned int i = 0; i < ctx->mailbox->msg_count; i++)
mutt_set_flag(ctx, ctx->mailbox->hdrs[i], MUTT_READ, 1);
}
- return nntp_data;
+ return mdata;
}
/**
* @retval ptr NNTP data
* @retval NULL Error
*/
-struct NntpData *mutt_newsgroup_uncatchup(struct Context *ctx,
+struct NntpMboxData *mutt_newsgroup_uncatchup(struct Context *ctx,
struct NntpServer *nserv, char *group)
{
- struct NntpData *nntp_data = NULL;
+ struct NntpMboxData *mdata = NULL;
if (!nserv || !nserv->groups_hash || !group || !*group)
return NULL;
- nntp_data = mutt_hash_find(nserv->groups_hash, group);
- if (!nntp_data)
+ mdata = mutt_hash_find(nserv->groups_hash, group);
+ if (!mdata)
return NULL;
- if (nntp_data->newsrc_ent)
+ if (mdata->newsrc_ent)
{
- mutt_mem_realloc(&nntp_data->newsrc_ent, sizeof(struct NewsrcEntry));
- nntp_data->newsrc_len = 1;
- nntp_data->newsrc_ent[0].first = 1;
- nntp_data->newsrc_ent[0].last = nntp_data->first_message - 1;
+ mutt_mem_realloc(&mdata->newsrc_ent, sizeof(struct NewsrcEntry));
+ mdata->newsrc_len = 1;
+ mdata->newsrc_ent[0].first = 1;
+ mdata->newsrc_ent[0].last = mdata->first_message - 1;
}
- if (ctx && ctx->mailbox->data == nntp_data)
+ if (ctx && ctx->mailbox->data == mdata)
{
- nntp_data->unread = ctx->mailbox->msg_count;
+ mdata->unread = ctx->mailbox->msg_count;
for (unsigned int i = 0; i < ctx->mailbox->msg_count; i++)
mutt_set_flag(ctx, ctx->mailbox->hdrs[i], MUTT_READ, 0);
}
else
{
- nntp_data->unread = nntp_data->last_message;
- if (nntp_data->newsrc_ent)
- nntp_data->unread -= nntp_data->newsrc_ent[0].last;
+ mdata->unread = mdata->last_message;
+ if (mdata->newsrc_ent)
+ mdata->unread -= mdata->newsrc_ent[0].last;
}
- return nntp_data;
+ return mdata;
}
/**
for (unsigned int i = 0; i < CurrentNewsSrv->groups_num; i++)
{
- struct NntpData *nntp_data = CurrentNewsSrv->groups_list[i];
+ struct NntpMboxData *mdata = CurrentNewsSrv->groups_list[i];
- if (!nntp_data || !nntp_data->subscribed || !nntp_data->unread)
+ if (!mdata || !mdata->subscribed || !mdata->unread)
continue;
if ((mailbox->magic == MUTT_NNTP) &&
- (mutt_str_strcmp(nntp_data->group, ((struct NntpData *) mailbox->data)->group) == 0))
+ (mutt_str_strcmp(mdata->group, ((struct NntpMboxData *) mailbox->data)->group) == 0))
{
unsigned int unread = 0;
if (!unread)
continue;
}
- mutt_str_strfcpy(buf, nntp_data->group, buflen);
+ mutt_str_strfcpy(buf, mdata->group, buflen);
break;
}
}
anum_t *child;
};
+/**
+ * free_emaildata - Free data attached to an Email
+ * @param data Email data
+ */
+static void free_emaildata(void **data)
+{
+ FREE(data);
+}
+
+/**
+ * new_emaildata - Create a new NntpEmailData for an Email
+ * @retval ptr New NntpEmailData struct
+ */
+static struct NntpEmailData *new_emaildata(void)
+{
+ return mutt_mem_calloc(1, sizeof(struct NntpEmailData));
+}
+
/**
* nntp_connect_error - Signal a failed connection
* @param nserv NNTP server
/**
* nntp_query - Send data from buffer and receive answer to same buffer
- * @param nntp_data NNTP server data
+ * @param mdata NNTP Mailbox data
* @param line Buffer containing data
* @param linelen Length of buffer
* @retval 0 Success
* @retval -1 Failure
*/
-static int nntp_query(struct NntpData *nntp_data, char *line, size_t linelen)
+static int nntp_query(struct NntpMboxData *mdata, char *line, size_t linelen)
{
- struct NntpServer *nserv = nntp_data->nserv;
+ struct NntpServer *nserv = mdata->nserv;
char buf[LONG_STRING] = { 0 };
if (nserv->status == NNTP_BYE)
if (*line)
rc = mutt_socket_send(nserv->conn, line);
- else if (nntp_data->group)
+ else if (mdata->group)
{
- snprintf(buf, sizeof(buf), "GROUP %s\r\n", nntp_data->group);
+ snprintf(buf, sizeof(buf), "GROUP %s\r\n", mdata->group);
rc = mutt_socket_send(nserv->conn, buf);
}
if (rc >= 0)
}
/* select newsgroup after reconnection */
- if (nntp_data->group)
+ if (mdata->group)
{
- snprintf(buf, sizeof(buf), "GROUP %s\r\n", nntp_data->group);
+ snprintf(buf, sizeof(buf), "GROUP %s\r\n", mdata->group);
if (mutt_socket_send(nserv->conn, buf) < 0 ||
mutt_socket_readln(buf, sizeof(buf), nserv->conn) < 0)
{
/**
* nntp_fetch_lines - Read lines, calling a callback function for each
- * @param nntp_data NNTP server data
+ * @param mdata NNTP Mailbox data
* @param query Query to match
* @param qlen Length of query
* @param msg Progess message (OPTIONAL)
* This function calls func(*line, *data) for each received line,
* func(NULL, *data) if rewind(*data) needs, exits when fail or done:
*/
-static int nntp_fetch_lines(struct NntpData *nntp_data, char *query, size_t qlen,
+static int nntp_fetch_lines(struct NntpMboxData *mdata, char *query, size_t qlen,
const char *msg, int (*func)(char *, void *), void *data)
{
int done = false;
mutt_progress_init(&progress, msg, MUTT_PROGRESS_MSG, ReadInc, 0);
mutt_str_strfcpy(buf, query, sizeof(buf));
- if (nntp_query(nntp_data, buf, sizeof(buf)) < 0)
+ if (nntp_query(mdata, buf, sizeof(buf)) < 0)
return -1;
if (buf[0] != '2')
{
while (true)
{
char *p = NULL;
- int chunk = mutt_socket_readln_d(buf, sizeof(buf), nntp_data->nserv->conn,
+ int chunk = mutt_socket_readln_d(buf, sizeof(buf), mdata->nserv->conn,
MUTT_SOCK_LOG_HDR);
if (chunk < 0)
{
- nntp_data->nserv->status = NNTP_NONE;
+ mdata->nserv->status = NNTP_NONE;
break;
}
static int fetch_description(char *line, void *data)
{
struct NntpServer *nserv = data;
- struct NntpData *nntp_data = NULL;
+ struct NntpMboxData *mdata = NULL;
char *desc = NULL;
if (!line)
else
desc = strchr(line, '\0');
- nntp_data = mutt_hash_find(nserv->groups_hash, line);
- if (nntp_data && (mutt_str_strcmp(desc, nntp_data->desc) != 0))
+ mdata = mutt_hash_find(nserv->groups_hash, line);
+ if (mdata && (mutt_str_strcmp(desc, mdata->desc) != 0))
{
- mutt_str_replace(&nntp_data->desc, desc);
+ mutt_str_replace(&mdata->desc, desc);
mutt_debug(2, "group: %s, desc: %s\n", line, desc);
}
return 0;
/**
* get_description - Fetch newsgroups descriptions
- * @param nntp_data NNTP data
+ * @param mdata NNTP Mailbox data
* @param wildmat String to match
* @param msg Progress message
* @retval 0 Success
* @retval -1 Connection lost
* @retval -2 Error
*/
-static int get_description(struct NntpData *nntp_data, const char *wildmat, const char *msg)
+static int get_description(struct NntpMboxData *mdata, const char *wildmat, const char *msg)
{
char buf[STRING];
const char *cmd = NULL;
/* get newsgroup description, if possible */
- struct NntpServer *nserv = nntp_data->nserv;
+ struct NntpServer *nserv = mdata->nserv;
if (!wildmat)
- wildmat = nntp_data->group;
+ wildmat = mdata->group;
if (nserv->hasLIST_NEWSGROUPS)
cmd = "LIST NEWSGROUPS";
else if (nserv->hasXGTITLE)
return 0;
snprintf(buf, sizeof(buf), "%s %s\r\n", cmd, wildmat);
- int rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), msg, fetch_description, nserv);
+ int rc = nntp_fetch_lines(mdata, buf, sizeof(buf), msg, fetch_description, nserv);
if (rc > 0)
{
mutt_error("%s: %s", cmd, buf);
/**
* nntp_parse_xref - Parse cross-reference
* @param mailbox Mailbox
- * @param e Email header
+ * @param e Email
*
* Update read flag and set article number if empty
*/
static void nntp_parse_xref(struct Mailbox *mailbox, struct Email *e)
{
- struct NntpData *nntp_data = mailbox->data;
+ struct NntpMboxData *mdata = mailbox->data;
char *buf = mutt_str_strdup(e->env->xref);
char *p = buf;
continue;
nntp_article_status(mailbox, e, grp, anum);
- if (!NHDR(e)->article_num && (mutt_str_strcmp(nntp_data->group, grp) == 0))
- NHDR(e)->article_num = anum;
+ if (!NNTP_EDATA(e)->article_num && (mutt_str_strcmp(mdata->group, grp) == 0))
+ NNTP_EDATA(e)->article_num = anum;
}
FREE(&buf);
}
{
struct FetchCtx *fc = data;
struct Context *ctx = fc->ctx;
- struct NntpData *nntp_data = ctx->mailbox->data;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
struct Email *e = NULL;
char *header = NULL, *field = NULL;
bool save = true;
if (!fp)
return -1;
- header = nntp_data->nserv->overview_fmt;
+ header = mdata->nserv->overview_fmt;
while (field)
{
char *b = field;
ctx->mailbox->hdrs[ctx->mailbox->msg_count] = mutt_email_new();
e = ctx->mailbox->hdrs[ctx->mailbox->msg_count];
e->env = mutt_rfc822_read_header(fp, e, false, false);
- e->env->newsgroups = mutt_str_strdup(nntp_data->group);
+ e->env->newsgroups = mutt_str_strdup(mdata->group);
e->received = e->date_sent;
mutt_file_fclose(&fp);
/* skip header marked as deleted in cache */
if (e->deleted && !fc->restore)
{
- if (nntp_data->bcache)
+ if (mdata->bcache)
{
mutt_debug(2, "mutt_bcache_del %s\n", buf);
- mutt_bcache_del(nntp_data->bcache, buf);
+ mutt_bcache_del(mdata->bcache, buf);
}
save = false;
}
e->read = false;
e->old = false;
e->deleted = false;
- e->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData));
- NHDR(e)->article_num = anum;
+ e->data = new_emaildata();
+ e->free_data = free_emaildata;
+ NNTP_EDATA(e)->article_num = anum;
if (fc->restore)
e->changed = true;
else
if (!e->read)
nntp_parse_xref(ctx->mailbox, e);
}
- if (anum > nntp_data->last_loaded)
- nntp_data->last_loaded = anum;
+ if (anum > mdata->last_loaded)
+ mdata->last_loaded = anum;
}
else
mutt_email_free(&e);
static int nntp_fetch_headers(struct Context *ctx, void *hc, anum_t first,
anum_t last, int restore)
{
- struct NntpData *nntp_data = ctx->mailbox->data;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
struct FetchCtx fc;
struct Email *e = NULL;
char buf[HUGE_STRING];
#endif
/* fetch list of articles */
- if (NntpListgroup && nntp_data->nserv->hasLISTGROUP && !nntp_data->deleted)
+ if (NntpListgroup && mdata->nserv->hasLISTGROUP && !mdata->deleted)
{
if (!ctx->mailbox->quiet)
mutt_message(_("Fetching list of articles..."));
- if (nntp_data->nserv->hasLISTGROUPrange)
- snprintf(buf, sizeof(buf), "LISTGROUP %s %u-%u\r\n", nntp_data->group, first, last);
+ if (mdata->nserv->hasLISTGROUPrange)
+ snprintf(buf, sizeof(buf), "LISTGROUP %s %u-%u\r\n", mdata->group, first, last);
else
- snprintf(buf, sizeof(buf), "LISTGROUP %s\r\n", nntp_data->group);
- rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_numbers, &fc);
+ snprintf(buf, sizeof(buf), "LISTGROUP %s\r\n", mdata->group);
+ rc = nntp_fetch_lines(mdata, buf, sizeof(buf), NULL, fetch_numbers, &fc);
if (rc > 0)
{
mutt_error("LISTGROUP: %s", buf);
continue;
snprintf(buf, sizeof(buf), "%u", current);
- if (nntp_data->bcache)
+ if (mdata->bcache)
{
mutt_debug(2, "#1 mutt_bcache_del %s\n", buf);
- mutt_bcache_del(nntp_data->bcache, buf);
+ mutt_bcache_del(mdata->bcache, buf);
}
#ifdef USE_HCACHE
if (e->deleted && !restore)
{
mutt_email_free(&e);
- if (nntp_data->bcache)
+ if (mdata->bcache)
{
mutt_debug(2, "#2 mutt_bcache_del %s\n", buf);
- mutt_bcache_del(nntp_data->bcache, buf);
+ mutt_bcache_del(mdata->bcache, buf);
}
continue;
}
#endif
/* don't try to fetch header from removed newsgroup */
- if (nntp_data->deleted)
+ if (mdata->deleted)
continue;
/* fallback to fetch overview */
- else if (nntp_data->nserv->hasOVER || nntp_data->nserv->hasXOVER)
+ else if (mdata->nserv->hasOVER || mdata->nserv->hasXOVER)
{
- if (NntpListgroup && nntp_data->nserv->hasLISTGROUP)
+ if (NntpListgroup && mdata->nserv->hasLISTGROUP)
break;
else
continue;
}
snprintf(buf, sizeof(buf), "HEAD %u\r\n", current);
- rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_tempfile, fp);
+ rc = nntp_fetch_lines(mdata, buf, sizeof(buf), NULL, fetch_tempfile, fp);
if (rc)
{
mutt_file_fclose(&fp);
}
/* no such article */
- if (nntp_data->bcache)
+ if (mdata->bcache)
{
snprintf(buf, sizeof(buf), "%u", current);
mutt_debug(2, "#3 mutt_bcache_del %s\n", buf);
- mutt_bcache_del(nntp_data->bcache, buf);
+ mutt_bcache_del(mdata->bcache, buf);
}
rc = 0;
continue;
e->read = false;
e->old = false;
e->deleted = false;
- e->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData));
- NHDR(e)->article_num = current;
+ e->data = new_emaildata();
+ e->free_data = free_emaildata;
+ NNTP_EDATA(e)->article_num = current;
if (restore)
e->changed = true;
else
{
- nntp_article_status(ctx->mailbox, e, NULL, NHDR(e)->article_num);
+ nntp_article_status(ctx->mailbox, e, NULL, NNTP_EDATA(e)->article_num);
if (!e->read)
nntp_parse_xref(ctx->mailbox, e);
}
- if (current > nntp_data->last_loaded)
- nntp_data->last_loaded = current;
+ if (current > mdata->last_loaded)
+ mdata->last_loaded = current;
first_over = current + 1;
}
- if (!NntpListgroup || !nntp_data->nserv->hasLISTGROUP)
+ if (!NntpListgroup || !mdata->nserv->hasLISTGROUP)
current = first_over;
/* fetch overview information */
- if (current <= last && rc == 0 && !nntp_data->deleted)
+ if (current <= last && rc == 0 && !mdata->deleted)
{
- char *cmd = nntp_data->nserv->hasOVER ? "OVER" : "XOVER";
+ char *cmd = mdata->nserv->hasOVER ? "OVER" : "XOVER";
snprintf(buf, sizeof(buf), "%s %u-%u\r\n", cmd, current, last);
- rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, parse_overview_line, &fc);
+ rc = nntp_fetch_lines(mdata, buf, sizeof(buf), NULL, parse_overview_line, &fc);
if (rc > 0)
{
mutt_error("%s: %s", cmd, buf);
/**
* nntp_group_poll - Check newsgroup for new articles
- * @param nntp_data NNTP server data
+ * @param mdata NNTP Mailbox data
* @param update_stat Update the stats?
* @retval 1 New articles found
* @retval 0 No change
* @retval -1 Lost connection
*/
-static int nntp_group_poll(struct NntpData *nntp_data, int update_stat)
+static int nntp_group_poll(struct NntpMboxData *mdata, int update_stat)
{
char buf[LONG_STRING] = "";
anum_t count, first, last;
/* use GROUP command to poll newsgroup */
- if (nntp_query(nntp_data, buf, sizeof(buf)) < 0)
+ if (nntp_query(mdata, buf, sizeof(buf)) < 0)
return -1;
if (sscanf(buf, "211 " ANUM " " ANUM " " ANUM, &count, &first, &last) != 3)
return 0;
- if (first == nntp_data->first_message && last == nntp_data->last_message)
+ if (first == mdata->first_message && last == mdata->last_message)
return 0;
/* articles have been renumbered */
- if (last < nntp_data->last_message)
+ if (last < mdata->last_message)
{
- nntp_data->last_cached = 0;
- if (nntp_data->newsrc_len)
+ mdata->last_cached = 0;
+ if (mdata->newsrc_len)
{
- mutt_mem_realloc(&nntp_data->newsrc_ent, sizeof(struct NewsrcEntry));
- nntp_data->newsrc_len = 1;
- nntp_data->newsrc_ent[0].first = 1;
- nntp_data->newsrc_ent[0].last = 0;
+ mutt_mem_realloc(&mdata->newsrc_ent, sizeof(struct NewsrcEntry));
+ mdata->newsrc_len = 1;
+ mdata->newsrc_ent[0].first = 1;
+ mdata->newsrc_ent[0].last = 0;
}
}
- nntp_data->first_message = first;
- nntp_data->last_message = last;
+ mdata->first_message = first;
+ mdata->last_message = last;
if (!update_stat)
return 1;
/* update counters */
- else if (!last || (!nntp_data->newsrc_ent && !nntp_data->last_cached))
- nntp_data->unread = count;
+ else if (!last || (!mdata->newsrc_ent && !mdata->last_cached))
+ mdata->unread = count;
else
- nntp_group_unread_stat(nntp_data);
+ nntp_group_unread_stat(mdata);
return 1;
}
*/
static int check_mailbox(struct Context *ctx)
{
- struct NntpData *nntp_data = ctx->mailbox->data;
- struct NntpServer *nserv = nntp_data->nserv;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
+ struct NntpServer *nserv = mdata->nserv;
time_t now = time(NULL);
int rc, ret = 0;
void *hc = NULL;
return -1;
nserv->check_time = now;
- rc = nntp_group_poll(nntp_data, 0);
+ rc = nntp_group_poll(mdata, 0);
if (rc < 0)
{
nntp_newsrc_close(nserv);
nntp_active_save_cache(nserv);
/* articles have been renumbered, remove all headers */
- if (nntp_data->last_message < nntp_data->last_loaded)
+ if (mdata->last_message < mdata->last_loaded)
{
for (int i = 0; i < ctx->mailbox->msg_count; i++)
mutt_email_free(&ctx->mailbox->hdrs[i]);
ctx->mailbox->msg_count = 0;
ctx->tagged = 0;
- if (nntp_data->last_message < nntp_data->last_loaded)
+ if (mdata->last_message < mdata->last_loaded)
{
- nntp_data->last_loaded = nntp_data->first_message - 1;
- if (NntpContext && nntp_data->last_message - nntp_data->last_loaded > NntpContext)
- nntp_data->last_loaded = nntp_data->last_message - NntpContext;
+ mdata->last_loaded = mdata->first_message - 1;
+ if (NntpContext && mdata->last_message - mdata->last_loaded > NntpContext)
+ mdata->last_loaded = mdata->last_message - NntpContext;
}
ret = MUTT_REOPENED;
}
char buf[16];
void *hdata = NULL;
struct Email *e = NULL;
- anum_t first = nntp_data->first_message;
+ anum_t first = mdata->first_message;
- if (NntpContext && nntp_data->last_message - first + 1 > NntpContext)
- first = nntp_data->last_message - NntpContext + 1;
- messages = mutt_mem_calloc(nntp_data->last_loaded - first + 1, sizeof(unsigned char));
- hc = nntp_hcache_open(nntp_data);
- nntp_hcache_update(nntp_data, hc);
+ if (NntpContext && mdata->last_message - first + 1 > NntpContext)
+ first = mdata->last_message - NntpContext + 1;
+ messages = mutt_mem_calloc(mdata->last_loaded - first + 1, sizeof(unsigned char));
+ hc = nntp_hcache_open(mdata);
+ nntp_hcache_update(mdata, hc);
#endif
/* update flags according to .newsrc */
for (int i = 0; i < ctx->mailbox->msg_count; i++)
{
bool flagged = false;
- anum = NHDR(ctx->mailbox->hdrs[i])->article_num;
+ anum = NNTP_EDATA(ctx->mailbox->hdrs[i])->article_num;
#ifdef USE_HCACHE
/* check hcache for flagged and deleted flags */
if (hc)
{
- if (anum >= first && anum <= nntp_data->last_loaded)
+ if (anum >= first && anum <= mdata->last_loaded)
messages[anum - first] = 1;
snprintf(buf, sizeof(buf), "%u", anum);
ctx->mailbox->msg_count = j;
/* restore headers without "deleted" flag */
- for (anum = first; anum <= nntp_data->last_loaded; anum++)
+ for (anum = first; anum <= mdata->last_loaded; anum++)
{
if (messages[anum - first])
continue;
if (e->deleted)
{
mutt_email_free(&e);
- if (nntp_data->bcache)
+ if (mdata->bcache)
{
mutt_debug(2, "mutt_bcache_del %s\n", buf);
- mutt_bcache_del(nntp_data->bcache, buf);
+ mutt_bcache_del(mdata->bcache, buf);
}
continue;
}
ctx->mailbox->msg_count++;
e->read = false;
e->old = false;
- e->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData));
- NHDR(e)->article_num = anum;
+ e->data = new_emaildata();
+ e->free_data = free_emaildata;
+ NNTP_EDATA(e)->article_num = anum;
nntp_article_status(ctx->mailbox, e, NULL, anum);
if (!e->read)
nntp_parse_xref(ctx->mailbox, e);
}
/* fetch headers of new articles */
- if (nntp_data->last_message > nntp_data->last_loaded)
+ if (mdata->last_message > mdata->last_loaded)
{
int oldmsgcount = ctx->mailbox->msg_count;
bool quiet = ctx->mailbox->quiet;
#ifdef USE_HCACHE
if (!hc)
{
- hc = nntp_hcache_open(nntp_data);
- nntp_hcache_update(nntp_data, hc);
+ hc = nntp_hcache_open(mdata);
+ nntp_hcache_update(mdata, hc);
}
#endif
- rc = nntp_fetch_headers(ctx, hc, nntp_data->last_loaded + 1, nntp_data->last_message, 0);
+ rc = nntp_fetch_headers(ctx, hc, mdata->last_loaded + 1, mdata->last_message, 0);
ctx->mailbox->quiet = quiet;
if (rc >= 0)
- nntp_data->last_loaded = nntp_data->last_message;
+ mdata->last_loaded = mdata->last_message;
if (ret == 0 && ctx->mailbox->msg_count > oldmsgcount)
ret = MUTT_NEW_MAIL;
}
{
if (nserv->hasDATE)
{
- struct NntpData nntp_data;
+ struct NntpMboxData mdata;
char buf[LONG_STRING];
struct tm tm;
memset(&tm, 0, sizeof(tm));
- nntp_data.nserv = nserv;
- nntp_data.group = NULL;
+ mdata.nserv = nserv;
+ mdata.group = NULL;
mutt_str_strfcpy(buf, "DATE\r\n", sizeof(buf));
- if (nntp_query(&nntp_data, buf, sizeof(buf)) < 0)
+ if (nntp_query(&mdata, buf, sizeof(buf)) < 0)
return -1;
if (sscanf(buf, "111 %4d%2d%2d%2d%2d%2d%*s", &tm.tm_year, &tm.tm_mon,
if (!line || sscanf(line, ANUM, &anum) != 1)
return 0;
for (unsigned int i = 0; i < cc->mailbox->msg_count; i++)
- if (NHDR(cc->mailbox->hdrs[i])->article_num == anum)
+ if (NNTP_EDATA(cc->mailbox->hdrs[i])->article_num == anum)
return 0;
if (cc->num >= cc->max)
{
*/
int nntp_post(struct Mailbox *mailbox, const char *msg)
{
- struct NntpData *nntp_data = NULL;
- struct NntpData nntp_tmp = { 0 };
+ struct NntpMboxData *mdata = NULL;
+ struct NntpMboxData nntp_tmp = { 0 };
char buf[LONG_STRING];
if (mailbox && (mailbox->magic == MUTT_NNTP))
- nntp_data = mailbox->data;
+ mdata = mailbox->data;
else
{
CurrentNewsSrv = nntp_select_server(mailbox, NewsServer, false);
if (!CurrentNewsSrv)
return -1;
- nntp_data = &nntp_tmp;
- nntp_data->nserv = CurrentNewsSrv;
- nntp_data->group = NULL;
+ mdata = &nntp_tmp;
+ mdata->nserv = CurrentNewsSrv;
+ mdata->group = NULL;
}
FILE *fp = mutt_file_fopen(msg, "r");
}
mutt_str_strfcpy(buf, "POST\r\n", sizeof(buf));
- if (nntp_query(nntp_data, buf, sizeof(buf)) < 0)
+ if (nntp_query(mdata, buf, sizeof(buf)) < 0)
{
mutt_file_fclose(&fp);
return -1;
len++;
buf[len] = '\0';
}
- if (mutt_socket_send_d(nntp_data->nserv->conn,
+ if (mutt_socket_send_d(mdata->nserv->conn,
buf[1] == '.' ? buf : buf + 1, MUTT_SOCK_LOG_HDR) < 0)
{
mutt_file_fclose(&fp);
- return nntp_connect_error(nntp_data->nserv);
+ return nntp_connect_error(mdata->nserv);
}
}
mutt_file_fclose(&fp);
if ((buf[strlen(buf) - 1] != '\n' &&
- mutt_socket_send_d(nntp_data->nserv->conn, "\r\n", MUTT_SOCK_LOG_HDR) < 0) ||
- mutt_socket_send_d(nntp_data->nserv->conn, ".\r\n", MUTT_SOCK_LOG_HDR) < 0 ||
- mutt_socket_readln(buf, sizeof(buf), nntp_data->nserv->conn) < 0)
+ mutt_socket_send_d(mdata->nserv->conn, "\r\n", MUTT_SOCK_LOG_HDR) < 0) ||
+ mutt_socket_send_d(mdata->nserv->conn, ".\r\n", MUTT_SOCK_LOG_HDR) < 0 ||
+ mutt_socket_readln(buf, sizeof(buf), mdata->nserv->conn) < 0)
{
- return nntp_connect_error(nntp_data->nserv);
+ return nntp_connect_error(mdata->nserv);
}
if (buf[0] != '2')
{
*/
int nntp_active_fetch(struct NntpServer *nserv, bool new)
{
- struct NntpData nntp_data;
+ struct NntpMboxData mdata;
char msg[STRING];
char buf[LONG_STRING];
unsigned int i;
if (nntp_date(nserv, &nserv->newgroups_time) < 0)
return -1;
- nntp_data.nserv = nserv;
- nntp_data.group = NULL;
+ mdata.nserv = nserv;
+ mdata.group = NULL;
i = nserv->groups_num;
mutt_str_strfcpy(buf, "LIST\r\n", sizeof(buf));
- rc = nntp_fetch_lines(&nntp_data, buf, sizeof(buf), msg, nntp_add_group, nserv);
+ rc = nntp_fetch_lines(&mdata, buf, sizeof(buf), msg, nntp_add_group, nserv);
if (rc)
{
if (rc > 0)
{
for (; i < nserv->groups_num; i++)
{
- struct NntpData *data = nserv->groups_list[i];
+ struct NntpMboxData *data = nserv->groups_list[i];
data->new = true;
}
}
for (i = 0; i < nserv->groups_num; i++)
{
- struct NntpData *data = nserv->groups_list[i];
+ struct NntpMboxData *data = nserv->groups_list[i];
if (data && data->deleted && !data->newsrc_ent)
{
}
if (NntpLoadDescription)
- rc = get_description(&nntp_data, "*", _("Loading descriptions..."));
+ rc = get_description(&mdata, "*", _("Loading descriptions..."));
nntp_active_save_cache(nserv);
if (rc < 0)
*/
int nntp_check_new_groups(struct Mailbox *mailbox, struct NntpServer *nserv)
{
- struct NntpData nntp_data;
+ struct NntpMboxData mdata;
time_t now;
struct tm *tm = NULL;
char buf[LONG_STRING];
mutt_message(_("Checking for new messages..."));
for (i = 0; i < nserv->groups_num; i++)
{
- struct NntpData *data = nserv->groups_list[i];
+ struct NntpMboxData *data = nserv->groups_list[i];
if (data && data->subscribed)
{
mutt_message(msg);
if (nntp_date(nserv, &now) < 0)
return -1;
- nntp_data.nserv = nserv;
+ mdata.nserv = nserv;
if (mailbox && (mailbox->magic == MUTT_NNTP))
- nntp_data.group = ((struct NntpData *) mailbox->data)->group;
+ mdata.group = ((struct NntpMboxData *) mailbox->data)->group;
else
- nntp_data.group = NULL;
+ mdata.group = NULL;
i = nserv->groups_num;
tm = gmtime(&nserv->newgroups_time);
snprintf(buf, sizeof(buf), "NEWGROUPS %02d%02d%02d %02d%02d%02d GMT\r\n",
tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
tm->tm_min, tm->tm_sec);
- rc = nntp_fetch_lines(&nntp_data, buf, sizeof(buf), msg, nntp_add_group, nserv);
+ rc = nntp_fetch_lines(&mdata, buf, sizeof(buf), msg, nntp_add_group, nserv);
if (rc)
{
if (rc > 0)
nserv->newgroups_time = now;
for (; i < nserv->groups_num; i++)
{
- struct NntpData *data = nserv->groups_list[i];
+ struct NntpMboxData *data = nserv->groups_list[i];
data->new = true;
}
MUTT_PROGRESS_MSG, ReadInc, nserv->groups_num - i);
for (i = groups_num; i < nserv->groups_num; i++)
{
- struct NntpData *data = nserv->groups_list[i];
+ struct NntpMboxData *data = nserv->groups_list[i];
if (get_description(data, NULL, NULL) < 0)
return -1;
*/
int nntp_check_msgid(struct Context *ctx, const char *msgid)
{
- struct NntpData *nntp_data = ctx->mailbox->data;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
char buf[LONG_STRING];
FILE *fp = mutt_file_mkstemp();
}
snprintf(buf, sizeof(buf), "HEAD %s\r\n", msgid);
- int rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_tempfile, fp);
+ int rc = nntp_fetch_lines(mdata, buf, sizeof(buf), NULL, fetch_tempfile, fp);
if (rc)
{
mutt_file_fclose(&fp);
mx_alloc_memory(ctx->mailbox);
ctx->mailbox->hdrs[ctx->mailbox->msg_count] = mutt_email_new();
struct Email *e = ctx->mailbox->hdrs[ctx->mailbox->msg_count];
- e->data = mutt_mem_calloc(1, sizeof(struct NntpHeaderData));
+ e->data = new_emaildata();
+ e->free_data = free_emaildata;
e->env = mutt_rfc822_read_header(fp, e, false, false);
mutt_file_fclose(&fp);
else
{
snprintf(buf, sizeof(buf), "STAT %s\r\n", msgid);
- if (nntp_query(nntp_data, buf, sizeof(buf)) < 0)
+ if (nntp_query(mdata, buf, sizeof(buf)) < 0)
{
mutt_email_free(&e);
return -1;
}
- sscanf(buf + 4, ANUM, &NHDR(e)->article_num);
+ sscanf(buf + 4, ANUM, &NNTP_EDATA(e)->article_num);
}
/* reset flags */
*/
int nntp_check_children(struct Context *ctx, const char *msgid)
{
- struct NntpData *nntp_data = ctx->mailbox->data;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
struct ChildCtx cc;
char buf[STRING];
int rc;
bool quiet;
void *hc = NULL;
- if (!nntp_data || !nntp_data->nserv)
+ if (!mdata || !mdata->nserv)
return -1;
- if (nntp_data->first_message > nntp_data->last_loaded)
+ if (mdata->first_message > mdata->last_loaded)
return 0;
/* init context */
/* fetch numbers of child messages */
snprintf(buf, sizeof(buf), "XPAT References %u-%u *%s*\r\n",
- nntp_data->first_message, nntp_data->last_loaded, msgid);
- rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), NULL, fetch_children, &cc);
+ mdata->first_message, mdata->last_loaded, msgid);
+ rc = nntp_fetch_lines(mdata, buf, sizeof(buf), NULL, fetch_children, &cc);
if (rc)
{
FREE(&cc.child);
quiet = ctx->mailbox->quiet;
ctx->mailbox->quiet = true;
#ifdef USE_HCACHE
- hc = nntp_hcache_open(nntp_data);
+ hc = nntp_hcache_open(mdata);
#endif
for (int i = 0; i < cc.num; i++)
{
struct Email **ea = (struct Email **) a;
struct Email **eb = (struct Email **) b;
- anum_t na = NHDR(*ea)->article_num;
- anum_t nb = NHDR(*eb)->article_num;
+ anum_t na = NNTP_EDATA(*ea)->article_num;
+ anum_t nb = NNTP_EDATA(*eb)->article_num;
int result = (na == nb) ? 0 : (na > nb) ? 1 : -1;
result = perform_auxsort(result, a, b);
return SORTCODE(result);
static int nntp_mbox_open(struct Context *ctx)
{
struct NntpServer *nserv = NULL;
- struct NntpData *nntp_data = NULL;
+ struct NntpMboxData *mdata = NULL;
char buf[HUGE_STRING];
char server[LONG_STRING];
char *group = NULL;
CurrentNewsSrv = nserv;
/* find news group data structure */
- nntp_data = mutt_hash_find(nserv->groups_hash, group);
- if (!nntp_data)
+ mdata = mutt_hash_find(nserv->groups_hash, group);
+ if (!mdata)
{
nntp_newsrc_close(nserv);
mutt_error(_("Newsgroup %s not found on the server"), group);
}
mutt_bit_unset(ctx->mailbox->rights, MUTT_ACL_INSERT);
- if (!nntp_data->newsrc_ent && !nntp_data->subscribed && !SaveUnsubscribed)
+ if (!mdata->newsrc_ent && !mdata->subscribed && !SaveUnsubscribed)
ctx->mailbox->readonly = true;
/* select newsgroup */
mutt_message(_("Selecting %s..."), group);
buf[0] = '\0';
- if (nntp_query(nntp_data, buf, sizeof(buf)) < 0)
+ if (nntp_query(mdata, buf, sizeof(buf)) < 0)
{
nntp_newsrc_close(nserv);
return -1;
/* newsgroup not found, remove it */
if (mutt_str_strncmp("411", buf, 3) == 0)
{
- mutt_error(_("Newsgroup %s has been removed from the server"), nntp_data->group);
- if (!nntp_data->deleted)
+ mutt_error(_("Newsgroup %s has been removed from the server"), mdata->group);
+ if (!mdata->deleted)
{
- nntp_data->deleted = true;
+ mdata->deleted = true;
nntp_active_save_cache(nserv);
}
- if (nntp_data->newsrc_ent && !nntp_data->subscribed && !SaveUnsubscribed)
+ if (mdata->newsrc_ent && !mdata->subscribed && !SaveUnsubscribed)
{
- FREE(&nntp_data->newsrc_ent);
- nntp_data->newsrc_len = 0;
- nntp_delete_group_cache(nntp_data);
+ FREE(&mdata->newsrc_ent);
+ mdata->newsrc_len = 0;
+ nntp_delete_group_cache(mdata);
nntp_newsrc_update(nserv);
}
}
mutt_error("GROUP: %s", buf);
return -1;
}
- nntp_data->first_message = first;
- nntp_data->last_message = last;
- nntp_data->deleted = false;
+ mdata->first_message = first;
+ mdata->last_message = last;
+ mdata->deleted = false;
/* get description if empty */
- if (NntpLoadDescription && !nntp_data->desc)
+ if (NntpLoadDescription && !mdata->desc)
{
- if (get_description(nntp_data, NULL, NULL) < 0)
+ if (get_description(mdata, NULL, NULL) < 0)
{
nntp_newsrc_close(nserv);
return -1;
}
- if (nntp_data->desc)
+ if (mdata->desc)
nntp_active_save_cache(nserv);
}
}
time(&nserv->check_time);
- ctx->mailbox->data = nntp_data;
- if (!nntp_data->bcache && (nntp_data->newsrc_ent || nntp_data->subscribed || SaveUnsubscribed))
- nntp_data->bcache = mutt_bcache_open(&nserv->conn->account, nntp_data->group);
+ ctx->mailbox->data = mdata;
+ if (!mdata->bcache && (mdata->newsrc_ent || mdata->subscribed || SaveUnsubscribed))
+ mdata->bcache = mutt_bcache_open(&nserv->conn->account, mdata->group);
/* strip off extra articles if adding context is greater than $nntp_context */
- first = nntp_data->first_message;
- if (NntpContext && nntp_data->last_message - first + 1 > NntpContext)
- first = nntp_data->last_message - NntpContext + 1;
- nntp_data->last_loaded = first ? first - 1 : 0;
- count = nntp_data->first_message;
- nntp_data->first_message = first;
- nntp_bcache_update(nntp_data);
- nntp_data->first_message = count;
+ first = mdata->first_message;
+ if (NntpContext && mdata->last_message - first + 1 > NntpContext)
+ first = mdata->last_message - NntpContext + 1;
+ mdata->last_loaded = first ? first - 1 : 0;
+ count = mdata->first_message;
+ mdata->first_message = first;
+ nntp_bcache_update(mdata);
+ mdata->first_message = count;
#ifdef USE_HCACHE
- hc = nntp_hcache_open(nntp_data);
- nntp_hcache_update(nntp_data, hc);
+ hc = nntp_hcache_open(mdata);
+ nntp_hcache_update(mdata, hc);
#endif
if (!hc)
{
mutt_bit_unset(ctx->mailbox->rights, MUTT_ACL_DELETE);
}
nntp_newsrc_close(nserv);
- rc = nntp_fetch_headers(ctx, hc, first, nntp_data->last_message, 0);
+ rc = nntp_fetch_headers(ctx, hc, first, mdata->last_message, 0);
#ifdef USE_HCACHE
mutt_hcache_close(hc);
#endif
if (rc < 0)
return -1;
- nntp_data->last_loaded = nntp_data->last_message;
+ mdata->last_loaded = mdata->last_message;
nserv->newsrc_modified = false;
return 0;
}
int ret = check_mailbox(ctx);
if (ret == 0)
{
- struct NntpData *nntp_data = ctx->mailbox->data;
- struct NntpServer *nserv = nntp_data->nserv;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
+ struct NntpServer *nserv = mdata->nserv;
nntp_newsrc_close(nserv);
}
return ret;
*/
static int nntp_mbox_sync(struct Context *ctx, int *index_hint)
{
- struct NntpData *nntp_data = ctx->mailbox->data;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
int rc;
#ifdef USE_HCACHE
header_cache_t *hc = NULL;
#endif
/* check for new articles */
- nntp_data->nserv->check_time = 0;
+ mdata->nserv->check_time = 0;
rc = check_mailbox(ctx);
if (rc)
return rc;
#ifdef USE_HCACHE
- nntp_data->last_cached = 0;
- hc = nntp_hcache_open(nntp_data);
+ mdata->last_cached = 0;
+ hc = nntp_hcache_open(mdata);
#endif
for (int i = 0; i < ctx->mailbox->msg_count; i++)
struct Email *e = ctx->mailbox->hdrs[i];
char buf[16];
- snprintf(buf, sizeof(buf), "%d", NHDR(e)->article_num);
- if (nntp_data->bcache && e->deleted)
+ snprintf(buf, sizeof(buf), "%d", NNTP_EDATA(e)->article_num);
+ if (mdata->bcache && e->deleted)
{
mutt_debug(2, "mutt_bcache_del %s\n", buf);
- mutt_bcache_del(nntp_data->bcache, buf);
+ mutt_bcache_del(mdata->bcache, buf);
}
#ifdef USE_HCACHE
if (hc && (e->changed || e->deleted))
{
if (e->deleted && !e->read)
- nntp_data->unread--;
+ mdata->unread--;
mutt_debug(2, "mutt_hcache_store %s\n", buf);
mutt_hcache_store(hc, buf, strlen(buf), e, 0);
}
if (hc)
{
mutt_hcache_close(hc);
- nntp_data->last_cached = nntp_data->last_loaded;
+ mdata->last_cached = mdata->last_loaded;
}
#endif
/* save .newsrc entries */
nntp_newsrc_gen_entries(ctx);
- nntp_newsrc_update(nntp_data->nserv);
- nntp_newsrc_close(nntp_data->nserv);
+ nntp_newsrc_update(mdata->nserv);
+ nntp_newsrc_close(mdata->nserv);
return 0;
}
*/
static int nntp_mbox_close(struct Context *ctx)
{
- struct NntpData *nntp_data = ctx->mailbox->data, *nntp_tmp = NULL;
-
- if (!nntp_data)
+ struct NntpMboxData *mdata = ctx->mailbox->data, *nntp_tmp = NULL;
+ if (!mdata)
return 0;
- nntp_data->unread = ctx->mailbox->msg_unread;
+ mdata->unread = ctx->mailbox->msg_unread;
- nntp_acache_free(nntp_data);
- if (!nntp_data->nserv || !nntp_data->nserv->groups_hash || !nntp_data->group)
+ nntp_acache_free(mdata);
+ if (!mdata->nserv || !mdata->nserv->groups_hash || !mdata->group)
return 0;
- nntp_tmp = mutt_hash_find(nntp_data->nserv->groups_hash, nntp_data->group);
- if (!nntp_tmp || nntp_tmp != nntp_data)
- nntp_data_free(nntp_data);
+ nntp_tmp = mutt_hash_find(mdata->nserv->groups_hash, mdata->group);
+ if (!nntp_tmp || nntp_tmp != mdata)
+ nntp_data_free(mdata);
return 0;
}
*/
static int nntp_msg_open(struct Context *ctx, struct Message *msg, int msgno)
{
- struct NntpData *nntp_data = ctx->mailbox->data;
+ struct NntpMboxData *mdata = ctx->mailbox->data;
struct Email *e = ctx->mailbox->hdrs[msgno];
char article[16];
/* try to get article from cache */
- struct NntpAcache *acache = &nntp_data->acache[e->index % NNTP_ACACHE_LEN];
+ struct NntpAcache *acache = &mdata->acache[e->index % NNTP_ACACHE_LEN];
if (acache->path)
{
if (acache->index == e->index)
FREE(&acache->path);
}
}
- snprintf(article, sizeof(article), "%d", NHDR(e)->article_num);
- msg->fp = mutt_bcache_get(nntp_data->bcache, article);
+ snprintf(article, sizeof(article), "%d", NNTP_EDATA(e)->article_num);
+ msg->fp = mutt_bcache_get(mdata->bcache, article);
if (msg->fp)
{
- if (NHDR(e)->parsed)
+ if (NNTP_EDATA(e)->parsed)
return 0;
}
else
{
char buf[PATH_MAX];
/* don't try to fetch article from removed newsgroup */
- if (nntp_data->deleted)
+ if (mdata->deleted)
return -1;
/* create new cache file */
const char *fetch_msg = _("Fetching message...");
mutt_message(fetch_msg);
- msg->fp = mutt_bcache_put(nntp_data->bcache, article);
+ msg->fp = mutt_bcache_put(mdata->bcache, article);
if (!msg->fp)
{
mutt_mktemp(buf, sizeof(buf));
/* fetch message to cache file */
snprintf(buf, sizeof(buf), "ARTICLE %s\r\n",
- NHDR(e)->article_num ? article : e->env->message_id);
- const int rc = nntp_fetch_lines(nntp_data, buf, sizeof(buf), fetch_msg,
+ NNTP_EDATA(e)->article_num ? article : e->env->message_id);
+ const int rc = nntp_fetch_lines(mdata, buf, sizeof(buf), fetch_msg,
fetch_tempfile, msg->fp);
if (rc)
{
}
if (rc > 0)
{
- if (mutt_str_strncmp(NHDR(e)->article_num ? "423" : "430", buf, 3) == 0)
+ if (mutt_str_strncmp(NNTP_EDATA(e)->article_num ? "423" : "430", buf, 3) == 0)
{
mutt_error(_("Article %d not found on the server"),
- NHDR(e)->article_num ? article : e->env->message_id);
+ NNTP_EDATA(e)->article_num ? article : e->env->message_id);
}
else
mutt_error("ARTICLE: %s", buf);
}
if (!acache->path)
- mutt_bcache_commit(nntp_data->bcache, article);
+ mutt_bcache_commit(mdata->bcache, article);
}
/* replace envelope with new one
/* this is called in neomutt before the open which fetches the message,
* which is probably wrong, but we just call it again here to handle
* the problem instead of fixing it */
- NHDR(e)->parsed = true;
+ NNTP_EDATA(e)->parsed = true;
mutt_parse_mime_message(ctx, e);
/* these would normally be updated in mx_update_context(), but the