version 1.21, 2014/12/16 18:36:46 |
version 1.22, 2015/01/20 16:59:07 |
|
|
} |
} |
|
|
/* |
/* |
* Unpack the name list onto a vector of strings. |
|
* Return an error if the name list won't fit. |
|
*/ |
|
char ** |
|
unpack(struct name *sm, struct name *np) |
|
{ |
|
char **ap, **top; |
|
int t, extra, metoo, verbose; |
|
|
|
if ((t = count(np)) == 0) |
|
errx(1, "No names to unpack"); |
|
t += count(sm); |
|
|
|
/* |
|
* Compute the number of extra arguments we will need. |
|
* We need at least four extra -- one for "send-mail", one for the |
|
* "-i" flag, one for the "--" to signal end of command line |
|
* arguments, and one for the terminating 0 pointer. |
|
*/ |
|
extra = 4; |
|
metoo = value("metoo") != NULL; |
|
if (metoo) |
|
extra++; |
|
verbose = value("verbose") != NULL; |
|
if (verbose) |
|
extra++; |
|
top = (char **)salloc((t + extra) * sizeof(*top)); |
|
ap = top; |
|
*ap++ = "send-mail"; |
|
*ap++ = "-i"; |
|
if (metoo) |
|
*ap++ = "-m"; |
|
if (verbose) |
|
*ap++ = "-v"; |
|
for (; sm != NULL; sm = sm->n_flink) |
|
if ((sm->n_type & GDEL) == 0) |
|
*ap++ = sm->n_name; |
|
*ap++ = "--"; |
|
for (; np != NULL; np = np->n_flink) |
|
if ((np->n_type & GDEL) == 0) |
|
*ap++ = np->n_name; |
|
*ap = NULL; |
|
return(top); |
|
} |
|
|
|
/* |
|
* Remove all of the duplicates from the passed name list by |
* Remove all of the duplicates from the passed name list by |
* insertion sorting them, then checking for dups. |
* insertion sorting them, then checking for dups. |
* Return the head of the new list. |
* Return the head of the new list. |