X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/d5cde8ce1b902158b1e99ee97d8ae72999b4dc14..b46d49ba:/uip/new.c?ds=inline diff --git a/uip/new.c b/uip/new.c index ff9c398b..d608883d 100644 --- a/uip/new.c +++ b/uip/new.c @@ -1,6 +1,4 @@ - -/* - * new.c -- as new, list all folders with unseen messages +/* new.c -- as new, list all folders with unseen messages * -- as fnext, move to next folder with unseen messages * -- as fprev, move to previous folder with unseen messages * -- as unseen, scan all unseen messages @@ -15,7 +13,10 @@ #include #include +#include "h/done.h" #include +#include "sbr/lock_file.h" +#include "sbr/m_maildir.h" #define NEW_SWITCHES \ X("mode", 1, MODESW) \ @@ -75,19 +76,19 @@ count_messages(char *field) return total; } -/* Return TRUE if the sequence 'name' is in 'sequences'. */ -static boolean +/* Return true if the sequence 'name' is in 'sequences'. */ +static bool seq_in_list(char *name, char *sequences[]) { int i; for (i = 0; sequences[i] != NULL; i++) { if (strcmp(name, sequences[i]) == 0) { - return TRUE; + return true; } } - return FALSE; + return false; } /* Return the string list of message numbers from the sequences file, or NULL @@ -98,11 +99,11 @@ get_msgnums(char *folder, char *sequences[]) char *seqfile = NULL; FILE *fp; int state; - char name[NAMESZ], field[BUFSIZ]; + char name[NAMESZ], field[NMH_BUFSIZ]; char *cp; char *msgnums = NULL, *this_msgnums, *old_msgnums; int failed_to_lock = 0; - m_getfld_state_t gstate = 0; + m_getfld_state_t gstate; /* copied from seq_read.c:seq_public */ /* @@ -114,32 +115,30 @@ 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; if ((fp = lkfopendata (seqfile, "r", & failed_to_lock)) == NULL) { - - if (failed_to_lock) { + if (failed_to_lock) adios (seqfile, "failed to lock"); - } else { - free(seqfile); - return NULL; - } + free(seqfile); + return NULL; } - /* Use m_getfld to scan sequence file */ + /* Use m_getfld2 to scan sequence file */ + gstate = m_getfld_state_init(fp); for (;;) { int fieldsz = sizeof field; - switch (state = m_getfld (&gstate, name, field, &fieldsz, fp)) { + switch (state = m_getfld2(&gstate, name, field, &fieldsz)) { case FLD: case FLDPLUS: if (state == FLDPLUS) { cp = getcpy (field); while (state == FLDPLUS) { fieldsz = sizeof field; - state = m_getfld (&gstate, name, field, &fieldsz, fp); + state = m_getfld2(&gstate, name, field, &fieldsz); cp = add (field, cp); } @@ -152,7 +151,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); } @@ -167,7 +166,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); } @@ -178,7 +177,7 @@ get_msgnums(char *folder, char *sequences[]) case BODY: adios (NULL, "no blank lines are permitted in %s", seqfile); - /* fall */ + break; case FILEEOF: break; @@ -227,11 +226,11 @@ check_folder(char *folder, size_t len, struct list_state *b) } } -static boolean +static bool crawl_callback(char *folder, void *baton) { check_folder(folder, strlen(folder), baton); - return TRUE; + return true; } /* Scan folders, returning: @@ -372,10 +371,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; @@ -391,13 +389,13 @@ doit(char *cur, char *folders, char *sequences[]) if (strcmp(node->n_name, cur) == 0) { puts(" (*: current folder)"); } else { - puts(""); + putchar('\n'); } fflush(stdout); /* 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");