X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=nntp%2Fnewsrc.c;h=1af28c285f57d01ce3c0c1e3e501191c2e9f9b7c;hp=fb5fc1bf6cd7a5c91389579a9a0866e64469cfe0;hb=2a06362a155582cd59ae2ef6f0df71694a7eede3;hpb=9274cbe8e6410ddb95ddc667faa678a29da85420 diff --git a/nntp/newsrc.c b/nntp/newsrc.c index fb5fc1b..1af28c2 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -15,13 +15,15 @@ #include #include +#include #include +#include + #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" @@ -73,7 +75,7 @@ static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line) 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) + m_strlen(group) + 1); data->group = (char *) data + sizeof (NNTP_DATA); @@ -183,7 +185,7 @@ static int nntp_parse_cacheindex (NNTP_SERVER * 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) { @@ -207,8 +209,8 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) rewind (index); while (fgets (buf, sizeof (buf), index)) { buf[m_strlen(buf) - 1] = 0; /* strip ending '\n' */ - if (!str_ncmp (buf, "#: ", 3) && - !str_casecmp (buf + 3, news->conn->account.host)) + if (!m_strncmp(buf, "#: ", 3) && + !m_strcasecmp(buf + 3, news->conn->account.host)) break; } while (fgets (buf, sizeof (buf), index)) { @@ -218,10 +220,10 @@ static int nntp_parse_cacheindex (NNTP_SERVER * news) 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")) { + if (!m_strcmp(buf, "ALL")) { news->cache = m_strdup(file); news->newgroups_time = m; } @@ -264,7 +266,7 @@ const char *nntp_format_str (char *dest, size_t destlen, char op, switch (op) { case 's': - strncpy (fn, NewsServer, sizeof (fn) - 1); + m_strcpy(fn, sizeof (fn), NewsServer); str_tolower (fn); snprintf (tmp, sizeof (tmp), "%%%ss", fmt); snprintf (dest, destlen, tmp, fn); @@ -298,7 +300,7 @@ int nntp_parse_url (const char *server, ACCOUNT * acct, *group = '\0'; if (url.path) - strfcpy (group, url.path, group_len); + m_strcpy(group, group_len, url.path); ret = mutt_account_fromurl (acct, &url); } @@ -629,7 +631,7 @@ void newsrc_gen_entries (CONTEXT * ctx) } 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]; @@ -655,8 +657,8 @@ static int mutt_update_list_file (char *filename, char *section, * 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"))) { @@ -671,7 +673,7 @@ static int mutt_update_list_file (char *filename, char *section, 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) { @@ -764,7 +766,7 @@ int mutt_newsrc_update (NNTP_SERVER * news) } /* 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); @@ -796,8 +798,9 @@ static FILE *mutt_mkname (char *s) /* 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; @@ -808,7 +811,7 @@ static int nntp_update_cacheindex (NNTP_SERVER * serv, NNTP_DATA * data) 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); } @@ -854,7 +857,7 @@ int nntp_save_cache_index (NNTP_SERVER * news) 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 = m_strdup(buf); nntp_cache_expand (file, buf); @@ -1085,7 +1088,7 @@ void nntp_buffy (char* dst, size_t dstlen) { 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; } @@ -1103,7 +1106,7 @@ void nntp_buffy (char* dst, size_t dstlen) { 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++) @@ -1112,7 +1115,7 @@ void nntp_buffy (char* dst, size_t dstlen) { if (!unread) continue; } - strncpy (dst, data->group, dstlen); + m_strcpy(dst, dstlen, data->group); break; } }