rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | LICENSE

commit beaef0773ca348cf3d8a5dca947190ac5aa3c601
parent f1416a4752954e5c0a3806f04821871a7f3406e3
Author: Christoph Lohmann <20h@r-36.net>
Date:   Wed, 19 Apr 2017 17:07:24 +0200

Proper sequence support in rppick.

Diffstat:
pick.c | 34++++++++++++++++++++++++----------
pick.h | 2+-
2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/pick.c b/pick.c @@ -108,11 +108,12 @@ static char *threadalgorithms[] = { }; char * -pick_mksearchstring(char **argv[]) +pick_mksearchstring(char *cfgn, char *mailbox, char **argv[]) { int j; expression_t *expr; - char *rstr, *estr, *nestr, *astr; + char *rstr, *estr, *nestr, *astr, *idss; + llist_t *ids; rstr = NULL; estr = NULL; @@ -164,15 +165,22 @@ pick_mksearchstring(char **argv[]) estr = smprintf("%s \"%s\"", estr, (*argv)[0]); *argv = &(*argv)[1]; break; + case PICK_SEQ: + ids = imap_str2ids(cfgn, mailbox, (*argv)[0]); + idss = imap_ids2str(ids); + estr = smprintf("%s %s", estr, idss); + free(idss); + llist_free(ids); + *argv = &(*argv)[1]; + break; case PICK_NUM: case PICK_KEY: - case PICK_SEQ: case PICK_DATE: estr = smprintf("%s %s", estr, (*argv)[0]); *argv = &(*argv)[1]; break; case PICK_EXPR: - rstr = pick_mksearchstring(argv); + rstr = pick_mksearchstring(cfgn, mailbox, argv); estr = smprintf("%s %s", estr, rstr); free(rstr); free(astr); @@ -390,13 +398,18 @@ pickmain(int argc, char *argv[]) pickusage(); cfg = config_init(cfgn); - user = (config_checkget(cfg, "imapuser"))->data; - pass = (config_checkget(cfg, "imappass"))->data; - netspec = (config_checkget(cfg, "imapnet"))->data; + user = config_checkgetstr(cfg, "imapuser"); + pass = config_checkgetstr(cfg, "imappass"); + netspec = config_checkgetstr(cfg, "imapnet"); if (selected == NULL) { - selected = (config_checkget(cfg, "selected"))->data; + selected = config_checkgetstr(cfg, "selected"); + } else { + selected = memdups(selected); + } + if (cfg->name != NULL) { + cfgn = memdups(cfg->name); } else { - selected = memdup(selected, strlen(selected)+1); + cfgn = memdups(cfgn); } marks = mark_init(cfg->name, selected); @@ -411,7 +424,8 @@ pickmain(int argc, char *argv[]) imap_die(imap, "imap_select"); config_free(cfg); - sstr = pick_mksearchstring(&argv); + sstr = pick_mksearchstring(cfgn, selected, &argv); + free(cfgn); if (status & DOTHREAD) { talg = pick_threadalgorithm(imap); if (talg == NULL) { diff --git a/pick.h b/pick.h @@ -6,7 +6,7 @@ #ifndef __PICK_H__ #define __PICK_H__ -char *pick_mksearchstring(char **argv[]); +char *pick_mksearchstring(char *cfgn, char *mailbox, char **argv[]); int pickmain(int argc, char *argv[]);