aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules/cat.c
blob: 8df476751c5b98804a81f6c80ec5a8ef72fac341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <stdlib.h>
#include <console.h>

int main(int argc, char *argv[])
{
    FILE *f;
    int ch;
    int i;

    openconsole(&dev_stdcon_r, &dev_stdcon_w);

    if (argc < 2) {
	fprintf(stderr, "Usage: cat.c32 filename\n");
	return 1;
    }

    f = fopen(argv[1], "r");
    if (!f) {
	fprintf(stderr, "File \"%s\" does not exist.\n", argv[1]);
	return 1;
    }

    while ((ch = getc(f)) != EOF)
	putchar(ch);

    fclose(f);

    return 0;
}