#include <config.h>
#endif
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <sys/stat.h>
+
#include <lib-lib/mem.h>
+#include <lib-lib/str.h>
+#include <lib-lib/file.h>
+#include <lib-lib/macros.h>
+#include <lib-lib/debug.h>
+
+#include <lib-mime/mime.h>
+
+#include <lib-ui/curses.h>
#include "mutt.h"
-#include "mutt_curses.h"
#include "sort.h"
#include "mx.h"
-#include "mime.h"
#include "nntp.h"
-#include "rfc822.h"
#include "rfc1524.h"
-#include "rfc2047.h"
-
-#include "lib/str.h"
-#include "lib/intl.h"
-#include "lib/debug.h"
-
-#include <unistd.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <libgen.h>
-#include <sys/stat.h>
void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d)
{
len = p + 1 - line;
if (len > sizeof (group))
len = sizeof (group);
- strfcpy (group, line, len);
+ m_strcpy(group, len, line);
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, group)) == NULL) {
- data = xmalloc(sizeof(NNTP_DATA) + str_len(group) + 1);
+ data = xmalloc(sizeof(NNTP_DATA) + m_strlen(group) + 1);
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, group);
data->nserv = news;
if (!NewsCacheDir || !*NewsCacheDir)
return 0;
- strfcpy (dir, NewsCacheDir, sizeof (dir));
+ m_strcpy(dir, sizeof(dir), NewsCacheDir);
mutt_expand_path (dir, sizeof (dir));
if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0) {
return 0;
rewind (index);
while (fgets (buf, sizeof (buf), index)) {
- buf[str_len (buf) - 1] = 0; /* strip ending '\n' */
- if (!str_ncmp (buf, "#: ", 3) &&
- !str_casecmp (buf + 3, news->conn->account.host))
+ buf[m_strlen(buf) - 1] = 0; /* strip ending '\n' */
+ if (!m_strncmp(buf, "#: ", 3) &&
+ !m_strcasecmp(buf + 3, news->conn->account.host))
break;
}
while (fgets (buf, sizeof (buf), index)) {
if (!*cp)
continue;
cp[0] = 0;
- if (!str_cmp (buf, "#:"))
+ if (!m_strcmp(buf, "#:"))
break;
sscanf (cp + 1, "%s %d %d", file, &l, &m);
- if (!str_cmp (buf, "ALL")) {
- news->cache = str_dup (file);
+ if (!m_strcmp(buf, "ALL")) {
+ news->cache = m_strdup(file);
news->newgroups_time = m;
}
else if (news->newsgroups) {
if ((data = (NNTP_DATA *) hash_find (news->newsgroups, buf)) == NULL) {
- data = xmalloc(sizeof(NNTP_DATA) + str_len(buf) + 1);
+ data = xmalloc(sizeof(NNTP_DATA) + m_strlen(buf) + 1);
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, buf);
data->nserv = news;
hash_insert (news->newsgroups, data->group, data, 0);
nntp_add_to_list (news, data);
}
- data->cache = str_dup (file);
+ data->cache = m_strdup(file);
t = 0;
if (!data->firstMessage || data->lastMessage < m)
t = 1;
switch (op) {
case 's':
- strncpy (fn, NewsServer, sizeof (fn) - 1);
- str_tolower (fn);
+ m_strcpy(fn, sizeof (fn), NewsServer);
+ m_strtolower(fn);
snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
snprintf (dest, destlen, tmp, fn);
break;
acct->port = NNTP_PORT;
acct->type = M_ACCT_TYPE_NNTP;
- c = str_dup (server);
+ c = m_strdup(server);
url_parse_ciss (&url, c);
if (url.scheme == U_NNTP || url.scheme == U_NNTPS) {
*group = '\0';
if (url.path)
- strfcpy (group, url.path, group_len);
+ m_strcpy(group, group_len, url.path);
ret = mutt_account_fromurl (acct, &url);
}
{
ciss_url_t url;
- url.path = str_dup (line);
+ url.path = m_strdup(line);
mutt_account_tourl (acct, &url);
url_ciss_tostring (&url, line, len, 0);
p_delete(&url.path);
NNTP_SERVER *serv;
CONNECTION *conn;
- memset (&acct, 0, sizeof (ACCOUNT));
+ p_clear(&acct, 1);
if (!server || !*server) {
mutt_error _("No newsserver defined!");
return NULL;
}
- buf = p = p_new(char, str_len (server) + 10);
+ buf = p = p_new(char, m_strlen(server) + 10);
if (url_check_scheme (server) == U_UNKNOWN) {
strcpy (buf, "nntp://");
p = strchr (buf, '\0');
/* New newsserver */
serv = p_new(NNTP_SERVER, 1);
serv->conn = conn;
- serv->newsrc = str_dup (file);
+ serv->newsrc = m_strdup(file);
serv->newsgroups = hash_create (1009);
slurp_newsrc (serv); /* load .newsrc */
nntp_parse_cacheindex (serv); /* load .index */
line = *buf + (*pline - line);
}
strcpy (line, data->group);
- len -= str_len (line) + 1;
- line += str_len (line);
+ len -= m_strlen(line) + 1;
+ line += m_strlen(line);
*line++ = data->subscribed ? ':' : '!';
*line++ = ' ';
*line = '\0';
}
static int mutt_update_list_file (char *filename, char *section,
- char *key, char *line) {
+ const char *key, char *line) {
FILE *ifp;
FILE *ofp;
char buf[HUGE_STRING];
* via rename(2); as dirname(2) may modify its argument,
* temporarily use buf as copy of it
*/
- strncpy (buf, filename, sizeof (buf));
- strncpy (tmpfile, basename (filename), sizeof (tmpfile));
+ m_strcpy(buf, sizeof(buf), filename);
+ m_strcpy(tmpfile, sizeof(tmpfile), basename(filename));
mutt_adv_mktemp ((const char*) dirname (buf), tmpfile, sizeof (tmpfile));
debug_print (1, ("Opening %s\n", tmpfile));
if (!(ofp = fopen (tmpfile, "w"))) {
c = buf;
while (*c && *c != '\n') c++;
c[0] = 0; /* strip EOL */
- if (!strncmp (buf, "#: ", 3) && !str_casecmp (buf+3, section))
+ if (!strncmp (buf, "#: ", 3) && !m_strcasecmp(buf+3, section))
done++;
}
if (r != EOF && !done) {
continue;
nntp_create_newsrc_line (data, &buf, &line, &llen);
debug_print (2, ("Added to newsrc: %s\n", line));
- line += str_len (line);
+ line += m_strlen(line);
}
/* newrc being fully rewritten */
if (news->newsrc &&
- (r = mutt_update_list_file (news->newsrc, NULL, "", buf)) == 0) {
+ (r = mutt_update_list_file(news->newsrc, NULL, "", buf)) == 0) {
struct stat st;
stat (news->newsrc, &st);
return fp;
nntp_cache_expand (buf, "cache-XXXXXX");
- pc = buf + str_len (buf) - 12; /* positioning to "cache-XXXXXX" */
+ pc = buf + m_strlen(buf) - 12; /* positioning to "cache-XXXXXX" */
if ((fd = mkstemp (buf)) == -1)
return NULL;
strcpy (s, pc); /* generated name */
/* Updates info into .index file: ALL or about selected newsgroup */
static int nntp_update_cacheindex (NNTP_SERVER * serv, NNTP_DATA * data)
{
- char buf[LONG_STRING], *key = "ALL";
+ char buf[LONG_STRING];
char file[_POSIX_PATH_MAX];
+ const char *key = "ALL";
if (!serv || !serv->conn || !serv->conn->account.host)
return -1;
data->firstMessage, data->lastLoaded);
}
else {
- strfcpy (file, serv->cache, sizeof (file));
+ m_strcpy(file, sizeof(file), serv->cache);
snprintf (buf, sizeof (buf), "ALL %s 0 %d", file,
(int) serv->newgroups_time);
}
f = safe_fopen (file, "w");
}
else {
- strfcpy (buf, news->conn->account.host, sizeof (buf));
+ m_strcpy(buf, sizeof(buf), news->conn->account.host);
f = mutt_mkname (buf);
- news->cache = str_dup (buf);
+ news->cache = m_strdup(buf);
nntp_cache_expand (file, buf);
}
if (!f)
((NNTP_DATA *) ctx->data)->nserv->conn->account.host,
((NNTP_DATA *) ctx->data)->group);
f = mutt_mkname (buf);
- ((NNTP_DATA *) ctx->data)->cache = str_dup (buf);
+ ((NNTP_DATA *) ctx->data)->cache = m_strdup(buf);
nntp_cache_expand (file, buf);
}
if (!f)
if (!news || !news->newsgroups || !group || !*group)
return NULL;
if (!(data = (NNTP_DATA *) hash_find (news->newsgroups, group))) {
- data = xmalloc(sizeof(NNTP_DATA) + str_len(group) + 1);
+ data = xmalloc(sizeof(NNTP_DATA) + m_strlen(group) + 1);
data->group = (char *) data + sizeof (NNTP_DATA);
strcpy (data->group, group);
data->nserv = news;
NNTP_DATA *data = (NNTP_DATA *) list->data;
if (data && data->subscribed && data->unread &&
Context && Context->magic == M_NNTP &&
- str_cmp (data->group, ((NNTP_DATA *) Context->data)->group) == 0) {
+ m_strcmp(data->group, ((NNTP_DATA *) Context->data)->group) == 0) {
list = list->next;
break;
}
if (data && data->subscribed && data->unread) {
if (Context && Context->magic == M_NNTP &&
- !str_cmp (data->group, ((NNTP_DATA *) Context->data)->group)) {
+ !m_strcmp(data->group, ((NNTP_DATA *) Context->data)->group)) {
unsigned int i, unread = 0;
for (i = 0; i < Context->msgcount; i++)
if (!unread)
continue;
}
- strncpy (dst, data->group, dstlen);
+ m_strcpy(dst, dstlen, data->group);
break;
}
}