+ werror(E_UNKNOWN_TARGET,name);
+ exit(1);
+}
+
+static void _buildCmdLine(char *into, char **args, const char **cmds,
+ const char *p1, const char *p2,
+ const char *p3, const char **list)
+{
+ const char *p, *from;
+
+ while (*cmds) {
+ *args = into;
+ args++;
+
+ from = *cmds;
+ cmds++;
+ *into = '\0';
+
+ /* See if it has a '$' anywhere - if not, just copy */
+ if ((p = strchr(from, '$'))) {
+ strncpy(into, from, p - from);
+ from = p+2;
+ p++;
+ switch (*p) {
+ case '1':
+ if (p1)
+ strcat(into, p1);
+ break;
+ case '2':
+ if (p2)
+ strcat(into, p2);
+ break;
+ case '3':
+ if (p3)
+ strcat(into, p3);
+ break;
+ case 'l': {
+ const char **tmp = list;
+ if (tmp) {
+ while (*tmp) {
+ strcpy(into, *tmp);
+ into += strlen(into)+1;
+ *args = into;
+ args++;
+ tmp++;
+ }
+ }
+ break;
+ }
+ default:
+ assert(0);
+ }
+ }
+ strcat(into, from);
+ if (strlen(into) == 0)
+ args--;
+ into += strlen(into)+1;
+ }
+ *args = NULL;