From 469a4163c2a1a43731d412eaa5d9cae7d670c48b Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Fri, 23 Mar 2012 16:06:23 +0100 Subject: [PATCH] whatnow: call external anno(1) instead of internal annotate(). --- uip/Makefile.in | 4 ++-- uip/whatnow.c | 53 ++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/uip/Makefile.in b/uip/Makefile.in index 2eabf62..7d4f422 100644 --- a/uip/Makefile.in +++ b/uip/Makefile.in @@ -222,8 +222,8 @@ sortm: sortm.o $(LOCALLIBS) spost: spost.o aliasbr.o $(LOCALLIBS) $(LINK) spost.o aliasbr.o $(LINKLIBS) -whatnow: whatnow.o annosbr.o $(LOCALLIBS) - $(LINK) whatnow.o annosbr.o $(LINKLIBS) +whatnow: whatnow.o $(LOCALLIBS) + $(LINK) whatnow.o $(LINKLIBS) # ========== DEPENDENCIES FOR INSTALLING ========== diff --git a/uip/whatnow.c b/uip/whatnow.c index 874a787..ae0c30b 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -349,7 +349,16 @@ main(int argc, char **argv) advise(NULL, "usage is alist [-ln]."); else - annolist(drft, attach_hdr, l, n); + snprintf(buf, sizeof buf, + "anno -list -comp '%s' " + "%s%s '%s'", + attach_hdr, + n ? "-number all" : "", + l ? "-text IGNORE " : "", + drft); + if (system(buf) != 0) { + advise(NULL, "Could not list attachment headers."); + } break; @@ -381,6 +390,8 @@ main(int argc, char **argv) ** Add the attachment annotation to the draft. */ if ((f = popen_in_dir(cwd, buf, "r"))) { + char buf[BUFSIZ]; + while (fgets(shell, sizeof(shell), f)) { *(strchr(shell, '\n')) = '\0'; @@ -390,8 +401,15 @@ main(int argc, char **argv) sprintf(file, "%s/%s", cwd, shell); } - annotate(drft, attach_hdr, file, 0, - -2, 1, 0); + snprintf(buf, sizeof buf, + "anno -nodate -append " + "-comp '%s' -text '%s'" + " '%s'", + attach_hdr, file, + drft); + if (system(buf) != 0) { + advise(NULL, "Could not add attachment header."); + } } pclose(f); @@ -409,7 +427,6 @@ main(int argc, char **argv) ** names and numbers aren't allowed, so this ** catches a -n anywhere in the argument list. */ - for (n = 0, arguments = argp + 1; *arguments != NULL; arguments++) { @@ -426,21 +443,23 @@ main(int argc, char **argv) ** just processed after processing each one so ** that the numbering stays correct. */ - if (n == 1) { - for (arguments = argp + 1; - *arguments != NULL; + for (arguments=argp+1; *arguments; arguments++) { if (strcmp(*arguments, "-n") == 0) continue; if (**arguments != '\0') { + char buf[BUFSIZ]; + n = atoi(*arguments); - annotate(drft, attach_hdr, - NULL, 0, - n, 1, 0); + snprintf(buf, sizeof buf, "anno -delete -comp '%s' -number '%d' '%s'", attach_hdr, n, drft); + if (system(buf) != 0) { + advise(NULL, "Could not delete attachment header."); + } - for (argp = arguments + 1; *argp; argp++) { + for (argp=arguments+1; *argp; + argp++) { if (atoi(*argp) > n) { if (atoi(*argp) == 1) *argp = ""; @@ -450,7 +469,9 @@ main(int argc, char **argv) } } } + break; } + /* else */ /* ** The arguments are interpreted as file names. @@ -468,8 +489,14 @@ main(int argc, char **argv) if ((f = popen_in_dir(cwd, buf, "r"))) { while (fgets(shell, sizeof (shell), f)) { *(strchr(shell, '\n')) = '\0'; - annotate(drft, attach_hdr, shell, - 0, 0, 1, 0); + snprintf(buf, sizeof buf, + "anno -delete -comp " + "'%s' -text '%s' '%s'", + attach_hdr, shell, + drft); + if (system(buf) != 0) { + advise(NULL, "Could not delete attachment header."); + } } pclose(f); } else { -- 1.7.10.4