X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c08cb60fe34b42b0a83bc88b57fd41b07793863f..ec173fd2c:/uip/new.c?ds=sidebyside diff --git a/uip/new.c b/uip/new.c index a787806d..b18a99b3 100644 --- a/uip/new.c +++ b/uip/new.c @@ -11,11 +11,29 @@ #include -#include -#include -#include -#include "../sbr/lock_file.h" -#include "../sbr/m_maildir.h" +#include "h/mh.h" +#include "sbr/m_getfld.h" +#include "sbr/getarguments.h" +#include "sbr/concat.h" +#include "sbr/smatch.h" +#include "sbr/r1bindex.h" +#include "sbr/trimcpy.h" +#include "sbr/vfgets.h" +#include "sbr/getcpy.h" +#include "sbr/m_atoi.h" +#include "sbr/context_save.h" +#include "sbr/context_replace.h" +#include "sbr/context_find.h" +#include "sbr/brkstring.h" +#include "sbr/ambigsw.h" +#include "sbr/print_version.h" +#include "sbr/print_help.h" +#include "sbr/error.h" +#include "sbr/crawl_folders.h" +#include "h/done.h" +#include "h/utils.h" +#include "sbr/lock_file.h" +#include "sbr/m_maildir.h" #define NEW_SWITCHES \ X("mode", 1, MODESW) \ @@ -114,7 +132,7 @@ get_msgnums(char *folder, char *sequences[]) return NULL; /* get filename of sequence file */ - seqfile = concat(m_maildir(folder), "/", mh_seq, (void *)NULL); + seqfile = concat(m_maildir(folder), "/", mh_seq, NULL); if (seqfile == NULL) return NULL; @@ -150,7 +168,7 @@ get_msgnums(char *folder, char *sequences[]) } else { old_msgnums = msgnums; msgnums = concat(old_msgnums, " ", - this_msgnums, (void *)NULL); + this_msgnums, NULL); free(old_msgnums); free(this_msgnums); } @@ -165,7 +183,7 @@ get_msgnums(char *folder, char *sequences[]) } else { old_msgnums = msgnums; msgnums = concat(old_msgnums, " ", - this_msgnums, (void *)NULL); + this_msgnums, NULL); free(old_msgnums); free(this_msgnums); } @@ -175,14 +193,14 @@ get_msgnums(char *folder, char *sequences[]) continue; case BODY: - adios (NULL, "no blank lines are permitted in %s", seqfile); + die("no blank lines are permitted in %s", seqfile); break; case FILEEOF: break; default: - adios (NULL, "%s is poorly formatted", seqfile); + die("%s is poorly formatted", seqfile); } break; /* break from for loop */ } @@ -273,7 +291,7 @@ check_folders(struct node **first, struct node **last, } else { fp = fopen(folders, "r"); if (fp == NULL) { - adios(NULL, "failed to read %s", folders); + die("failed to read %s", folders); } while (vfgets(fp, &line) == OK) { len = strlen(line) - 1; @@ -370,10 +388,9 @@ doit(char *cur, char *folders, char *sequences[]) /* Found current folder in fprev mode; if we have a * previous node in the list, return it; else return * the last node. */ - if (prev == NULL) { - return last; - } - return prev; + if (prev) + return prev; + return last; } } else if (run_mode == RM_UNSEEN) { int status; @@ -395,7 +412,7 @@ doit(char *cur, char *folders, char *sequences[]) /* TODO: Split enough of scan.c out so that we can call it here. */ command = concat("scan +", node->n_name, " ", sequences_s, - (void *)NULL); + NULL); status = system(command); if (! WIFEXITED (status)) { adios (command, "system"); @@ -444,7 +461,7 @@ main(int argc, char **argv) char *unseen; struct node *folder; - if (nmh_init(argv[0], 1)) { return 1; } + if (nmh_init(argv[0], true, true)) { return 1; } arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; @@ -459,7 +476,7 @@ main(int argc, char **argv) ambigsw (cp, switches); done (1); case UNKWNSW: - adios (NULL, "-%s unknown", cp); + die("-%s unknown", cp); case HELPSW: snprintf (help, sizeof(help), "%s [switches] [sequences]", @@ -472,11 +489,11 @@ main(int argc, char **argv) case FOLDERSSW: if (!(folders = *argp++) || *folders == '-') - adios(NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); continue; case MODESW: if (!(invo_name = *argp++) || *invo_name == '-') - adios(NULL, "missing argument to %s", argp[-2]); + die("missing argument to %s", argp[-2]); invo_name = r1bindex(invo_name, '/'); continue; } @@ -508,7 +525,7 @@ main(int argc, char **argv) /* no sequence arguments; use unseen */ unseen = context_find(usequence); if (unseen == NULL || unseen[0] == '\0') { - adios(NULL, "must specify sequences or set %s", usequence); + die("must specify sequences or set %s", usequence); } for (ap = brkstring(unseen, " ", "\n"); *ap; ap++) { svector_push_back (sequences, *ap);