projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Put structure into anno(1) and its man page.
[mmh]
/
uip
/
rcvstore.c
diff --git
a/uip/rcvstore.c
b/uip/rcvstore.c
index
40adf86
..
fc98b4a
100644
(file)
--- a/
uip/rcvstore.c
+++ b/
uip/rcvstore.c
@@
-11,7
+11,6
@@
#include <h/signals.h>
#include <errno.h>
#include <signal.h>
#include <h/signals.h>
#include <errno.h>
#include <signal.h>
-#include <h/mts.h>
static struct swit switches[] = {
#define CRETSW 0
static struct swit switches[] = {
#define CRETSW 0
@@
-48,11
+47,12
@@
static char *tmpfilenam = NULL;
static void unlink_done(int) NORETURN;
int
static void unlink_done(int) NORETURN;
int
-main (int argc, char **argv)
+main(int argc, char **argv)
{
int publicsw = -1, zerosw = 0;
int create = 1, unseensw = 1;
{
int publicsw = -1, zerosw = 0;
int create = 1, unseensw = 1;
- int fd, msgnum, seqp = 0;
+ int fd, msgnum;
+ size_t seqp = 0;
char *cp, *maildir, *folder = NULL, buf[BUFSIZ];
char **argp, **arguments, *seqs[NUMATTRS+1];
struct msgs *mp;
char *cp, *maildir, *folder = NULL, buf[BUFSIZ];
char **argp, **arguments, *seqs[NUMATTRS+1];
struct msgs *mp;
@@
-63,42
+63,41
@@
main (int argc, char **argv)
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
#ifdef LOCALE
setlocale(LC_ALL, "");
#endif
- invo_name = r1bindex (argv[0], '/');
+ invo_name = mhbasename(argv[0]);
/* read user profile/context */
context_read();
/* read user profile/context */
context_read();
- mts_init (invo_name);
- arguments = getarguments (invo_name, argc, argv, 1);
+ arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
/* parse arguments */
while ((cp = *argp++)) {
if (*cp == '-') {
argp = arguments;
/* parse arguments */
while ((cp = *argp++)) {
if (*cp == '-') {
- switch (smatch (++cp, switches)) {
+ switch (smatch(++cp, switches)) {
case AMBIGSW:
case AMBIGSW:
- ambigsw (cp, switches);
- done (1);
+ ambigsw(cp, switches);
+ done(1);
case UNKWNSW:
case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
+ adios(NULL, "-%s unknown", cp);
case HELPSW:
case HELPSW:
- snprintf (buf, sizeof(buf),
- "%s [+folder] [switches]",
- invo_name);
- print_help (buf, switches, 1);
- done (1);
+ snprintf(buf, sizeof(buf),
+ "%s [+folder] [switches]",
+ invo_name);
+ print_help(buf, switches, 1);
+ done(1);
case VERSIONSW:
print_version(invo_name);
case VERSIONSW:
print_version(invo_name);
- done (1);
+ done(1);
case SEQSW:
if (!(cp = *argp++) || *cp == '-')
case SEQSW:
if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument name to %s", argp[-2]);
+ adios(NULL, "missing argument name to %s", argp[-2]);
/* check if too many sequences specified */
if (seqp >= NUMATTRS)
/* check if too many sequences specified */
if (seqp >= NUMATTRS)
- adios (NULL, "too many sequences (more than %d) specified", NUMATTRS);
+ adios(NULL, "too many sequences (more than %d) specified", NUMATTRS);
seqs[seqp++] = cp;
continue;
seqs[seqp++] = cp;
continue;
@@
-133,100
+132,97
@@
main (int argc, char **argv)
}
if (*cp == '+' || *cp == '@') {
if (folder)
}
if (*cp == '+' || *cp == '@') {
if (folder)
- adios (NULL, "only one folder at a time!");
+ adios(NULL, "only one folder at a time!");
else
else
- folder = pluspath (cp);
+ folder = getcpy(expandfol(cp));
} else {
} else {
- adios (NULL, "usage: %s [+folder] [switches]",
+ adios(NULL, "usage: %s [+folder] [switches]",
invo_name);
}
}
seqs[seqp] = NULL; /* NULL terminate list of sequences */
invo_name);
}
}
seqs[seqp] = NULL; /* NULL terminate list of sequences */
- if (!context_find ("path"))
- free (path ("./", TFOLDER));
-
/* if no folder is given, use default folder */
if (!folder)
/* if no folder is given, use default folder */
if (!folder)
- folder = getfolder (0);
- maildir = m_maildir (folder);
+ folder = getdeffol();
+ maildir = toabsdir(folder);
/* check if folder exists */
/* check if folder exists */
- if (stat (maildir, &st) == NOTOK) {
+ if (stat(maildir, &st) == NOTOK) {
if (errno != ENOENT)
if (errno != ENOENT)
- adios (maildir, "error on folder");
+ adios(maildir, "error on folder");
if (!create)
if (!create)
- adios (NULL, "folder %s doesn't exist", maildir);
- if (!makedir (maildir))
- adios (NULL, "unable to create folder %s", maildir);
+ adios(NULL, "folder %s doesn't exist", maildir);
+ if (!makedir(maildir))
+ adios(NULL, "unable to create folder %s", maildir);
}
}
- if (chdir (maildir) == NOTOK)
- adios (maildir, "unable to change directory to");
+ if (chdir(maildir) == NOTOK)
+ adios(maildir, "unable to change directory to");
/* ignore a few signals */
/* ignore a few signals */
- SIGNAL (SIGHUP, SIG_IGN);
- SIGNAL (SIGINT, SIG_IGN);
- SIGNAL (SIGQUIT, SIG_IGN);
- SIGNAL (SIGTERM, SIG_IGN);
+ SIGNAL(SIGHUP, SIG_IGN);
+ SIGNAL(SIGINT, SIG_IGN);
+ SIGNAL(SIGQUIT, SIG_IGN);
+ SIGNAL(SIGTERM, SIG_IGN);
/* create a temporary file */
/* create a temporary file */
- tmpfilenam = m_mktemp (invo_name, &fd, NULL);
+ tmpfilenam = m_mktemp(invo_name, &fd, NULL);
if (tmpfilenam == NULL) {
if (tmpfilenam == NULL) {
- adios ("rcvstore", "unable to create temporary file");
+ adios("rcvstore", "unable to create temporary file");
}
}
- chmod (tmpfilenam, m_gmprot());
+ chmod(tmpfilenam, m_gmprot());
/* copy the message from stdin into temp file */
/* copy the message from stdin into temp file */
- cpydata (fileno (stdin), fd, "standard input", tmpfilenam);
+ cpydata(fileno(stdin), fd, "standard input", tmpfilenam);
- if (fstat (fd, &st) == NOTOK) {
- unlink (tmpfilenam);
- adios (tmpfilenam, "unable to fstat");
+ if (fstat(fd, &st) == NOTOK) {
+ unlink(tmpfilenam);
+ adios(tmpfilenam, "unable to fstat");
}
}
- if (close (fd) == NOTOK)
- adios (tmpfilenam, "error closing");
+ if (close(fd) == NOTOK)
+ adios(tmpfilenam, "error closing");
/* don't add file if it is empty */
if (st.st_size == 0) {
/* don't add file if it is empty */
if (st.st_size == 0) {
- unlink (tmpfilenam);
- advise (NULL, "empty file");
- done (0);
+ unlink(tmpfilenam);
+ advise(NULL, "empty file");
+ done(0);
}
/*
** read folder and create message structure
*/
}
/*
** read folder and create message structure
*/
- if (!(mp = folder_read (folder)))
- adios (NULL, "unable to read folder %s", folder);
+ if (!(mp = folder_read(folder)))
+ adios(NULL, "unable to read folder %s", folder);
/*
** Link message into folder, and possibly add
** to the Unseen-Sequence's.
*/
/*
** Link message into folder, and possibly add
** to the Unseen-Sequence's.
*/
- if ((msgnum = folder_addmsg (&mp, tmpfilenam, 0, unseensw, 0, 0,
- (char *)0)) == -1)
- done (1);
+ if ((msgnum = folder_addmsg(&mp, tmpfilenam, 0, unseensw, 0, 0, NULL))
+ == -1)
+ done(1);
/*
** Add the message to any extra sequences
** that have been specified.
*/
for (seqp = 0; seqs[seqp]; seqp++) {
/*
** Add the message to any extra sequences
** that have been specified.
*/
for (seqp = 0; seqs[seqp]; seqp++) {
- if (!seq_addmsg (mp, seqs[seqp], msgnum, publicsw, zerosw))
- done (1);
+ if (!seq_addmsg(mp, seqs[seqp], msgnum, publicsw, zerosw))
+ done(1);
}
}
- seq_setunseen (mp, 0); /* synchronize any Unseen-Sequence's */
- seq_save (mp); /* synchronize and save message sequences */
- folder_free (mp); /* free folder/message structure */
+ seq_setunseen(mp, 1); /* add new msgs to unseen sequences */
+ seq_save(mp); /* synchronize and save message sequences */
+ folder_free(mp); /* free folder/message structure */
- context_save (); /* save the global context file */
- unlink (tmpfilenam); /* remove temporary file */
+ context_save(); /* save the global context file */
+ unlink(tmpfilenam); /* remove temporary file */
tmpfilenam = NULL;
tmpfilenam = NULL;
- done (0);
+ done(0);
return 1;
}
return 1;
}
@@
-237,6
+233,6
@@
static void
unlink_done(int status)
{
if (tmpfilenam && *tmpfilenam)
unlink_done(int status)
{
if (tmpfilenam && *tmpfilenam)
- unlink (tmpfilenam);
- exit (status);
+ unlink(tmpfilenam);
+ exit(status);
}
}