2011-05-22 21:36:34 -04:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2011-05-24 06:05:36 -04:00
|
|
|
#include <unistd.h>
|
2013-03-05 15:46:48 -05:00
|
|
|
|
2011-05-26 13:18:42 -04:00
|
|
|
#include "text.h"
|
2011-05-22 21:36:34 -04:00
|
|
|
#include "util.h"
|
|
|
|
|
2013-10-07 11:07:19 -04:00
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
eprintf("usage: %s [file...]\n", argv0);
|
|
|
|
}
|
|
|
|
|
2011-05-22 21:36:34 -04:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2014-07-04 11:45:20 -04:00
|
|
|
char *p;
|
2011-05-22 21:36:34 -04:00
|
|
|
FILE *fp;
|
2012-05-31 14:38:18 -04:00
|
|
|
int i;
|
2011-05-22 21:36:34 -04:00
|
|
|
|
2012-05-31 14:38:18 -04:00
|
|
|
ARGBEGIN {
|
|
|
|
default:
|
2013-10-07 11:07:19 -04:00
|
|
|
usage();
|
2012-05-31 14:38:18 -04:00
|
|
|
} ARGEND;
|
|
|
|
|
2013-03-05 15:46:48 -05:00
|
|
|
if(argc == 0) {
|
2011-05-26 13:18:42 -04:00
|
|
|
concat(stdin, "<stdin>", stdout, "<stdout>");
|
2014-04-22 06:43:01 -04:00
|
|
|
} else {
|
|
|
|
for(i = 0; i < argc; i++) {
|
2014-07-04 11:45:20 -04:00
|
|
|
p = argv[i];
|
|
|
|
if (argv[i][0] == '-')
|
2014-07-04 18:10:14 -04:00
|
|
|
p = "/dev/fd/0";
|
2014-07-04 11:45:20 -04:00
|
|
|
if(!(fp = fopen(p, "r"))) {
|
2014-04-22 06:43:01 -04:00
|
|
|
weprintf("fopen %s:", argv[i]);
|
|
|
|
continue;
|
|
|
|
}
|
2014-07-04 11:45:20 -04:00
|
|
|
concat(fp, p, stdout, "<stdout>");
|
2014-04-22 06:43:01 -04:00
|
|
|
fclose(fp);
|
2013-11-13 06:39:24 -05:00
|
|
|
}
|
2011-05-22 21:36:34 -04:00
|
|
|
}
|
2014-10-02 18:46:04 -04:00
|
|
|
return 0;
|
2011-05-22 21:36:34 -04:00
|
|
|
}
|