sbase/cat.c

38 lines
581 B
C
Raw Normal View History

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>
2011-05-26 13:18:42 -04:00
#include "text.h"
2011-05-22 21:36:34 -04:00
#include "util.h"
static void
usage(void)
{
eprintf("usage: %s [file...]\n", argv0);
}
2011-05-22 21:36:34 -04:00
int
main(int argc, char *argv[])
{
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:
usage();
2012-05-31 14:38:18 -04:00
} ARGEND;
if(argc == 0) {
2011-05-26 13:18:42 -04:00
concat(stdin, "<stdin>", stdout, "<stdout>");
} else for(i = 0; i < argc; i++) {
2012-05-31 14:38:18 -04:00
if(!(fp = fopen(argv[i], "r")))
eprintf("fopen %s:", argv[i]);
2012-05-31 14:38:18 -04:00
concat(fp, argv[i], stdout, "<stdout>");
2011-05-22 21:36:34 -04:00
fclose(fp);
}
return EXIT_SUCCESS;
2011-05-22 21:36:34 -04:00
}