X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fanno.c;h=9fbb37f521e0b44e2aa39a28565b4041370a3c80;hp=b92abdc9fb0d50e0af1086ed6790bee3615c9e8b;hb=1513f7668c494c4583141d6115669b7198c14556;hpb=7480dbc14bc90f2d872d434205c0784704213252 diff --git a/uip/anno.c b/uip/anno.c index b92abdc..9fbb37f 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -46,6 +46,7 @@ */ #include +#include /* * We allocate space for messages (msgs array) @@ -81,6 +82,10 @@ static struct swit switches[] = { { "number", 2 }, #define APPENDSW 12 { "append", 1 }, +#define PRESERVESW 13 + { "preserve", 1 }, +#define NOPRESERVESW 14 + { "nopreserve", 3 }, { NULL, 0 } }; @@ -100,7 +105,7 @@ main (int argc, char **argv) char **argp, **arguments, **msgs; struct msgs *mp; int append = 0; /* append annotations instead of default prepend */ - int delete = -1; /* delete header element if set */ + int delete = -2; /* delete header element if set */ char *draft = (char *)0; /* draft file name */ int isdf = 0; /* return needed for m_draft() */ int list = 0; /* list header elements if set */ @@ -123,8 +128,7 @@ main (int argc, char **argv) */ nummsgs = 0; maxmsgs = MAXMSGS; - if (!(msgs = (char **) malloc ((size_t) (maxmsgs * sizeof(*msgs))))) - adios (NULL, "unable to allocate storage"); + msgs = (char **) mh_xmalloc ((size_t) (maxmsgs * sizeof(*msgs))); while ((cp = *argp++)) { if (*cp == '-') { @@ -190,9 +194,16 @@ main (int argc, char **argv) if (argp - arguments == argc - 1 || **argp == '-') number = 1; + + else { + if (strcmp(*argp, "all") == 0) + number = -1; - else if (!(number = atoi(*argp++))) - adios (NULL, "missing argument to %s", argp[-2]); + else if (!(number = atoi(*argp))) + adios (NULL, "missing argument to %s", argp[-2]); + + argp++; + } delete = number; continue; @@ -200,6 +211,14 @@ main (int argc, char **argv) case APPENDSW: /* append annotations instead of default prepend */ append = 1; continue; + + case PRESERVESW: /* preserve access and modification times on annotated message */ + annopreserve(1); + continue; + + case NOPRESERVESW: /* don't preserve access and modification times on annotated message (default) */ + annopreserve(0); + continue; } } if (*cp == '+' || *cp == '@') { @@ -214,9 +233,8 @@ main (int argc, char **argv) */ if (nummsgs >= maxmsgs) { maxmsgs += MAXMSGS; - if (!(msgs = (char **) realloc (msgs, - (size_t) (maxmsgs * sizeof(*msgs))))) - adios (NULL, "unable to reallocate msgs storage"); + msgs = (char **) mh_xrealloc (msgs, + (size_t) (maxmsgs * sizeof(*msgs))); } msgs[nummsgs++] = cp; }