projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sort out some prototypes, put them where they belong.
[apps/madmutt.git]
/
nntp
/
newsrc.c
diff --git
a/nntp/newsrc.c
b/nntp/newsrc.c
index
1f9bd5b
..
1a868bd
100644
(file)
--- a/
nntp/newsrc.c
+++ b/
nntp/newsrc.c
@@
-13,23
+13,6
@@
#include <config.h>
#endif
#include <config.h>
#endif
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-#include <lib-lib/file.h>
-#include <lib-lib/macros.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/debug.h"
-
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
@@
-37,14
+20,25
@@
#include <libgen.h>
#include <sys/stat.h>
#include <libgen.h>
#include <sys/stat.h>
+#include <lib-lib/lib-lib.h>
+
+#include <lib-mime/mime.h>
+
+#include <lib-ui/curses.h>
+
+#include "mutt.h"
+#include "sort.h"
+#include "mx.h"
+#include "nntp.h"
+
void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d)
{
void nntp_add_to_list (NNTP_SERVER * s, NNTP_DATA * d)
{
-
LIST
*l;
+
string_list_t
*l;
if (!s || !d)
return;
if (!s || !d)
return;
- l = p_new(
LIST
, 1);
+ l = p_new(
string_list_t
, 1);
if (s->list)
s->tail->next = l;
else
if (s->list)
s->tail->next = l;
else
@@
-59,7
+53,7
@@
static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
char group[LONG_STRING];
int x = 1;
char *p = line, *b, *h;
char group[LONG_STRING];
int x = 1;
char *p = line, *b, *h;
- size_t len;
+ s
s
ize_t len;
while (*p) {
if (*p++ == ',')
while (*p) {
if (*p++ == ',')
@@
-74,7
+68,7
@@
static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
len = p + 1 - line;
if (len > sizeof (group))
len = sizeof (group);
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);
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);
@@
-127,7
+121,6
@@
static int nntp_parse_newsrc_line (NNTP_SERVER * news, char *line)
data->lastMessage = data->entries[x - 1].last;
data->num = x;
mutt_newsgroup_stat (data);
data->lastMessage = data->entries[x - 1].last;
data->num = x;
mutt_newsgroup_stat (data);
- debug_print (2, ("Newsgroup %s\n", data->group));
return 0;
}
return 0;
}
@@
-173,7
+166,7
@@
static int nntp_parse_cacheindex (NNTP_SERVER * news)
struct stat st;
char buf[HUGE_STRING], *cp;
char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
struct stat st;
char buf[HUGE_STRING], *cp;
char dir[_POSIX_PATH_MAX], file[_POSIX_PATH_MAX];
- FILE *i
nde
x;
+ FILE *i
d
x;
NNTP_DATA *data;
int l, m, t;
NNTP_DATA *data;
int l, m, t;
@@
-184,7
+177,7
@@
static int nntp_parse_cacheindex (NNTP_SERVER * news)
if (!NewsCacheDir || !*NewsCacheDir)
return 0;
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) {
mutt_expand_path (dir, sizeof (dir));
if (lstat (dir, &st) || (st.st_mode & S_IFDIR) == 0) {
@@
-203,16
+196,16
@@
static int nntp_parse_cacheindex (NNTP_SERVER * news)
p_delete(&news->cache);
snprintf (buf, sizeof (buf), "%s/.index", dir);
p_delete(&news->cache);
snprintf (buf, sizeof (buf), "%s/.index", dir);
- if (!(i
nde
x = safe_fopen (buf, "a+")))
+ if (!(i
d
x = safe_fopen (buf, "a+")))
return 0;
return 0;
- rewind (i
nde
x);
- while (fgets (buf, sizeof (buf), i
nde
x)) {
+ rewind (i
d
x);
+ while (fgets (buf, sizeof (buf), i
d
x)) {
buf[m_strlen(buf) - 1] = 0; /* strip ending '\n' */
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;
}
break;
}
- while (fgets (buf, sizeof (buf), i
nde
x)) {
+ while (fgets (buf, sizeof (buf), i
d
x)) {
cp = buf;
while (*cp && *cp != ' ')
cp++;
cp = buf;
while (*cp && *cp != ' ')
cp++;
@@
-252,11
+245,11
@@
static int nntp_parse_cacheindex (NNTP_SERVER * news)
mutt_newsgroup_stat (data);
}
}
mutt_newsgroup_stat (data);
}
}
- fclose (i
nde
x);
+ fclose (i
d
x);
return 0;
}
return 0;
}
-const char *nntp_format_str (char *dest, size_t destlen, char op,
+const char *nntp_format_str (char *dest, s
s
ize_t destlen, char op,
const char *src, const char *fmt,
const char *ifstring, const char *elsestring,
unsigned long data, format_flag flags)
const char *src, const char *fmt,
const char *ifstring, const char *elsestring,
unsigned long data, format_flag flags)
@@
-265,8
+258,8
@@
const char *nntp_format_str (char *dest, size_t destlen, char op,
switch (op) {
case 's':
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;
snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
snprintf (dest, destlen, tmp, fn);
break;
@@
-276,44
+269,44
@@
const char *nntp_format_str (char *dest, size_t destlen, char op,
/* nntp_parse_url: given an NNPT URL, return host, port,
* username, password and newsgroup will recognise. */
/* nntp_parse_url: given an NNPT URL, return host, port,
* username, password and newsgroup will recognise. */
-int nntp_parse_url (const char *server, ACCOUNT * ac
c
t,
- char *group, size_t group_len)
+int nntp_parse_url (const char *server, ACCOUNT * act,
+ char *group, s
s
ize_t group_len)
{
ciss_url_t url;
char *c;
int ret = -1;
/* Defaults */
{
ciss_url_t url;
char *c;
int ret = -1;
/* Defaults */
- ac
c
t->flags = 0;
- ac
c
t->port = NNTP_PORT;
- ac
c
t->type = M_ACCT_TYPE_NNTP;
+ act->flags = 0;
+ act->port = NNTP_PORT;
+ act->type = M_ACCT_TYPE_NNTP;
c = m_strdup(server);
url_parse_ciss (&url, c);
if (url.scheme == U_NNTP || url.scheme == U_NNTPS) {
if (url.scheme == U_NNTPS) {
c = m_strdup(server);
url_parse_ciss (&url, c);
if (url.scheme == U_NNTP || url.scheme == U_NNTPS) {
if (url.scheme == U_NNTPS) {
- ac
c
t->flags |= M_ACCT_SSL;
- ac
c
t->port = NNTP_SSL_PORT;
+ act->flags |= M_ACCT_SSL;
+ act->port = NNTP_SSL_PORT;
}
*group = '\0';
if (url.path)
}
*group = '\0';
if (url.path)
-
strfcpy (group, url.path, group_len
);
+
m_strcpy(group, group_len, url.path
);
- ret = mutt_account_fromurl (ac
c
t, &url);
+ ret = mutt_account_fromurl (act, &url);
}
p_delete(&c);
return ret;
}
}
p_delete(&c);
return ret;
}
-void nntp_expand_path (char *line, s
ize_t len, ACCOUNT * ac
ct)
+void nntp_expand_path (char *line, s
size_t len, ACCOUNT * a
ct)
{
ciss_url_t url;
url.path = m_strdup(line);
{
ciss_url_t url;
url.path = m_strdup(line);
- mutt_account_tourl (ac
c
t, &url);
+ mutt_account_tourl (act, &url);
url_ciss_tostring (&url, line, len, 0);
p_delete(&url.path);
}
url_ciss_tostring (&url, line, len, 0);
p_delete(&url.path);
}
@@
-332,12
+325,12
@@
NNTP_SERVER *mutt_select_newsserver (char *server)
{
char file[_POSIX_PATH_MAX];
char *buf, *p;
{
char file[_POSIX_PATH_MAX];
char *buf, *p;
-
LIST
*list;
- ACCOUNT ac
c
t;
+
string_list_t
*list;
+ ACCOUNT act;
NNTP_SERVER *serv;
CONNECTION *conn;
NNTP_SERVER *serv;
CONNECTION *conn;
- p_clear(&ac
c
t, 1);
+ p_clear(&act, 1);
if (!server || !*server) {
mutt_error _("No newsserver defined!");
if (!server || !*server) {
mutt_error _("No newsserver defined!");
@@
-352,14
+345,14
@@
NNTP_SERVER *mutt_select_newsserver (char *server)
}
strcpy (p, server);
}
strcpy (p, server);
- if ((nntp_parse_url (buf, &ac
c
t, file, sizeof (file))) < 0 || *file) {
+ if ((nntp_parse_url (buf, &act, file, sizeof (file))) < 0 || *file) {
p_delete(&buf);
mutt_error (_("%s is an invalid newsserver specification!"), server);
return NULL;
}
p_delete(&buf);
p_delete(&buf);
mutt_error (_("%s is an invalid newsserver specification!"), server);
return NULL;
}
p_delete(&buf);
- conn = mutt_conn_find (NULL, &ac
c
t);
+ conn = mutt_conn_find (NULL, &act);
if (!conn)
return NULL;
if (!conn)
return NULL;
@@
-407,7
+400,7
@@
NNTP_SERVER *mutt_select_newsserver (char *server)
hash_destroy (&serv->newsgroups, nntp_delete_data);
for (list = serv->list; list; list = list->next)
list->data = NULL;
hash_destroy (&serv->newsgroups, nntp_delete_data);
for (list = serv->list; list; list = list->next)
list->data = NULL;
-
mutt_free_list
(&serv->list);
+
string_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);
@@
-438,10
+431,6
@@
void nntp_get_status (CONTEXT * ctx, HEADER * h, char *group, int article)
data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
if (!data) {
data = (NNTP_DATA *) hash_find (data->nserv->newsgroups, group);
if (!data) {
-#ifdef DEBUG
- if (group)
- debug_print (3, ("newsgroup %s not found\n", group));
-#endif
return;
}
return;
}
@@
-500,10
+489,10
@@
static int puti (char *line, int num)
}
static void nntp_create_newsrc_line (NNTP_DATA * data, char **buf,
}
static void nntp_create_newsrc_line (NNTP_DATA * data, char **buf,
- char **pline, size_t * buflen)
+ char **pline, s
s
ize_t * buflen)
{
char *line = *pline;
{
char *line = *pline;
- size_t len = *buflen - (*pline - *buf);
+ s
s
ize_t len = *buflen - (*pline - *buf);
int x, i;
if (len < LONG_STRING * 10) {
int x, i;
if (len < LONG_STRING * 10) {
@@
-641,7
+630,6
@@
static int mutt_update_list_file (char *filename, char *section,
/* if file not exist, create it */
if ((ifp = safe_fopen (filename, "a")))
fclose (ifp);
/* if file not exist, create it */
if ((ifp = safe_fopen (filename, "a")))
fclose (ifp);
- debug_print (1, ("Opening %s\n", filename));
if (!(ifp = safe_fopen (filename, "r"))) {
mutt_error (_("Unable to open %s for reading"), filename);
return -1;
if (!(ifp = safe_fopen (filename, "r"))) {
mutt_error (_("Unable to open %s for reading"), filename);
return -1;
@@
-656,10
+644,9
@@
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
*/
* 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 (tmpfil
e));
+
m_strcpy(buf, sizeof(buf), filename
);
+
m_strcpy(tmpfile, sizeof(tmpfile), basename(filenam
e));
mutt_adv_mktemp ((const char*) dirname (buf), tmpfile, sizeof (tmpfile));
mutt_adv_mktemp ((const char*) dirname (buf), tmpfile, sizeof (tmpfile));
- debug_print (1, ("Opening %s\n", tmpfile));
if (!(ofp = fopen (tmpfile, "w"))) {
fclose (ifp);
mutt_error (_("Unable to open %s for writing"), tmpfile);
if (!(ofp = fopen (tmpfile, "w"))) {
fclose (ifp);
mutt_error (_("Unable to open %s for writing"), tmpfile);
@@
-672,7
+659,7
@@
static int mutt_update_list_file (char *filename, char *section,
c = buf;
while (*c && *c != '\n') c++;
c[0] = 0; /* strip EOL */
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) {
done++;
}
if (r != EOF && !done) {
@@
-733,7
+720,6
@@
static int mutt_update_list_file (char *filename, char *section,
link[0] = '\0';
if ((l = readlink (filename, link, sizeof (link)-1)) > 0)
link[l] = '\0';
link[0] = '\0';
if ((l = readlink (filename, link, sizeof (link)-1)) > 0)
link[l] = '\0';
- debug_print (1, ("Renaming %s to %s\n",tmpfile, l > 0 ? link : filename));
if (rename (tmpfile, l > 0 ? link : filename) < 0) {
unlink (tmpfile);
mutt_error (_("Can't rename %s to %s"), tmpfile, l > 0 ? link : filename);
if (rename (tmpfile, l > 0 ? link : filename) < 0) {
unlink (tmpfile);
mutt_error (_("Can't rename %s to %s"), tmpfile, l > 0 ? link : filename);
@@
-746,9
+732,9
@@
int mutt_newsrc_update (NNTP_SERVER * news)
{
char *buf, *line;
NNTP_DATA *data;
{
char *buf, *line;
NNTP_DATA *data;
-
LIST
*tmp;
+
string_list_t
*tmp;
int r = -1;
int r = -1;
- size_t len, llen;
+ s
s
ize_t len, llen;
if (!news)
return -1;
if (!news)
return -1;
@@
-760,7
+746,6
@@
int mutt_newsrc_update (NNTP_SERVER * news)
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);
- debug_print (2, ("Added to newsrc: %s\n", line));
line += m_strlen(line);
}
/* newrc being fully rewritten */
line += m_strlen(line);
}
/* newrc being fully rewritten */
@@
-810,7
+795,7
@@
static int nntp_update_cacheindex (NNTP_SERVER * serv, NNTP_DATA * data)
data->firstMessage, data->lastLoaded);
}
else {
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);
}
snprintf (buf, sizeof (buf), "ALL %s 0 %d", file,
(int) serv->newgroups_time);
}
@@
-822,7
+807,7
@@
static int nntp_update_cacheindex (NNTP_SERVER * serv, NNTP_DATA * data)
void nntp_clear_cacheindex (NNTP_SERVER * news)
{
NNTP_DATA *data;
void nntp_clear_cacheindex (NNTP_SERVER * news)
{
NNTP_DATA *data;
-
LIST
*tmp;
+
string_list_t
*tmp;
if (option (OPTSAVEUNSUB) || !news)
return;
if (option (OPTSAVEUNSUB) || !news)
return;
@@
-832,7
+817,6
@@
void nntp_clear_cacheindex (NNTP_SERVER * news)
if (!data || data->subscribed || !data->cache)
continue;
nntp_delete_cache (data);
if (!data || data->subscribed || !data->cache)
continue;
nntp_delete_cache (data);
- debug_print (2, ("Removed from .index: %s\n", data->group));
}
return;
}
}
return;
}
@@
-843,7
+827,7
@@
int nntp_save_cache_index (NNTP_SERVER * news)
char file[_POSIX_PATH_MAX];
NNTP_DATA *d;
FILE *f;
char file[_POSIX_PATH_MAX];
NNTP_DATA *d;
FILE *f;
-
LIST
*l;
+
string_list_t
*l;
if (!news || !news->newsgroups)
return -1;
if (!news || !news->newsgroups)
return -1;
@@
-856,7
+840,7
@@
int nntp_save_cache_index (NNTP_SERVER * news)
f = safe_fopen (file, "w");
}
else {
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);
f = mutt_mkname (buf);
news->cache = m_strdup(buf);
nntp_cache_expand (file, buf);
@@
-1078,8
+1062,8
@@
NNTP_DATA *mutt_newsgroup_uncatchup (NNTP_SERVER * news, char *group)
}
/* this routine gives the first newsgroup with new messages */
}
/* this routine gives the first newsgroup with new messages */
-void nntp_buffy (char* dst, size_t dstlen) {
-
LIST
*list;
+void nntp_buffy (char* dst, s
s
ize_t dstlen) {
+
string_list_t
*list;
int count = 0;
/* forward to current group */
int count = 0;
/* forward to current group */
@@
-1114,7
+1098,7
@@
void nntp_buffy (char* dst, size_t dstlen) {
if (!unread)
continue;
}
if (!unread)
continue;
}
-
strncpy (dst, data->group, dstlen
);
+
m_strcpy(dst, dstlen, data->group
);
break;
}
}
break;
}
}