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 0af5c6a84e1e16dde52249ecb3df169401ca3708
parent d3afd5f50c6beed1b99023ab2d100f3755d4af89
Author: Christoph Lohmann <20h@r-36.net>
Date:   Mon,  8 Sep 2014 20:26:11 +0200

Add suffix capabilities and sieve highlight.

Now with suffix functions in place it is possible to trick editors to
highlight the sieve files properly.

Diffstat:
ind.c | 5+++--
ind.h | 2+-
pager.c | 21+++++++++++++++++----
pager.h | 2++
sieve.c | 2+-
5 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/ind.c b/ind.c @@ -503,7 +503,7 @@ findlimitws(char *str, int limit) } char * -mktmpfile(char *prefix, int *fd) +mktmpfile(char *prefix, char *suffix, int *fd) { char *name; time_t tm; @@ -513,7 +513,8 @@ mktmpfile(char *prefix, int *fd) srand(tm); for (tfd = -1; tfd < 0;) { - name = smprintf("/tmp/%s.%d.%d", prefix, getpid(), rand()); + name = smprintf("/tmp/%s.%d.%d.%s", prefix, getpid(), rand(), + suffix); tfd = open(name, O_EXCL|O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); if (tfd >= 0) diff --git a/ind.h b/ind.h @@ -47,7 +47,7 @@ char *strrlnspn(char *p, char *chars, int limit); int strisascii(char *str); char *findlimitws(char *str, int limit); -char *mktmpfile(char *prefix, int *fd); +char *mktmpfile(char *prefix, char *suffix, int *fd); int intcmp(const void *p1, const void *p2); diff --git a/pager.c b/pager.c @@ -60,12 +60,13 @@ pagefile(char *file) } char * -runstring(void (*runner)(char *), char *str, int docmp) +runstring(void (*runner)(char *), char *str, char *ext, int docmp) { char *tname, *nstr; int tfd, len; - tname = mktmpfile("rohrpost", &tfd); + + tname = mktmpfile("rohrpost", ext, &tfd); if (writefile(tname, str, strlen(str), "w+")) edie("runstring writefile"); runner(tname); @@ -91,12 +92,24 @@ runstring(void (*runner)(char *), char *str, int docmp) char * editstring(char *str) { - return runstring(editfile, str, 1); + return runstring(editfile, str, "", 1); +} + +char * +editstringext(char *str, char *ext) +{ + return runstring(editfile, str, ext, 1); } void pagestring(char *str) { - runstring(pagefile, str, 0); + runstring(pagefile, str, "", 0); +} + +void +pagestringext(char *str, char *ext) +{ + runstring(pagefile, str, ext, 0); } diff --git a/pager.h b/pager.h @@ -15,7 +15,9 @@ void pagefile(char *file); char *runstring(void (*runner)(char *), char *str, int docmp); char *editstring(char *str); +char *editstringext(char *str, char *ext); void pagestring(char *str); +void pagestringext(char *str, char *ext); #endif diff --git a/sieve.c b/sieve.c @@ -598,7 +598,7 @@ sievemain(int argc, char *argv[]) sieve_die("sieve_getscript"); sieve_close(sieve); - file = editstring(data); + file = editstringext(data, "siv"); free(data); if (file != NULL) {