Adding upstream version 4.02+dfsg.
[syslinux-debian/hramrach.git] / com32 / modules / cat.c
blob0a9514c4753adcaa0f2ee14afbc8d296772d94a6
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <console.h>
5 int main(int argc, char *argv[])
7 FILE *f;
8 int i;
9 int len;
10 char buf[4096];
12 openconsole(&dev_stdcon_r, &dev_stdcon_w);
14 if (argc < 2) {
15 fprintf(stderr, "Usage: %s filename...\n", argv[0]);
16 return 1;
19 for (i = 1; i < argc; i++) {
20 f = fopen(argv[i], "r");
21 if (!f) {
22 fprintf(stderr, "%s: %s: file not found\n", argv[0], argv[i]);
23 return 1;
26 while ((len = fread(buf, 1, sizeof buf, f)) > 0)
27 fwrite(buf, 1, len, stdout);
29 fclose(f);
32 return 0;