version 1.14, 2004/10/10 03:29:29 |
version 1.15, 2006/05/04 05:55:33 |
|
|
static char rcsid[] = "$OpenBSD$"; |
static char rcsid[] = "$OpenBSD$"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
|
#include <sys/queue.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#include <err.h> |
#include <err.h> |
#include <errno.h> |
#include <errno.h> |
|
|
exit(0); |
exit(0); |
} |
} |
|
|
typedef struct _list { |
struct list { |
struct _list *next; |
SIMPLEQ_ENTRY(list) entries; |
FILE *fp; |
FILE *fp; |
int cnt; |
int cnt; |
char *name; |
char *name; |
} LIST; |
}; |
|
|
void |
void |
parallel(char **argv) |
parallel(char **argv) |
{ |
{ |
LIST *lp; |
SIMPLEQ_HEAD(, list) head = SIMPLEQ_HEAD_INITIALIZER(head); |
|
struct list *lp; |
int cnt; |
int cnt; |
char ch, *p; |
char ch, *p; |
LIST *head, *tmp; |
|
int opencnt, output; |
int opencnt, output; |
char *buf, *lbuf; |
char *buf, *lbuf; |
size_t len; |
size_t len; |
|
|
for (cnt = 0, head = NULL; (p = *argv); ++argv, ++cnt) { |
for (cnt = 0; (p = *argv); ++argv, ++cnt) { |
if (!(lp = (LIST *)malloc((u_int)sizeof(LIST)))) |
if (!(lp = malloc(sizeof(struct list)))) |
err(1, "malloc"); |
err(1, "malloc"); |
|
|
if (p[0] == '-' && !p[1]) |
if (p[0] == '-' && !p[1]) |
lp->fp = stdin; |
lp->fp = stdin; |
else if (!(lp->fp = fopen(p, "r"))) |
else if (!(lp->fp = fopen(p, "r"))) |
err(1, "%s", p); |
err(1, "%s", p); |
lp->next = NULL; |
|
lp->cnt = cnt; |
lp->cnt = cnt; |
lp->name = p; |
lp->name = p; |
if (!head) |
SIMPLEQ_INSERT_TAIL(&head, lp, entries); |
head = tmp = lp; |
|
else { |
|
tmp->next = lp; |
|
tmp = lp; |
|
} |
|
} |
} |
|
|
for (opencnt = cnt; opencnt;) { |
for (opencnt = cnt; opencnt;) { |
for (output = 0, lp = head; lp; lp = lp->next) { |
output = 0; |
|
SIMPLEQ_FOREACH(lp, &head, entries) { |
lbuf = NULL; |
lbuf = NULL; |
if (!lp->fp) { |
if (!lp->fp) { |
if (output && lp->cnt && |
if (output && lp->cnt && |