aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules/cat.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/modules/cat.c')
-rw-r--r--com32/modules/cat.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/com32/modules/cat.c b/com32/modules/cat.c
new file mode 100644
index 00000000..8df47675
--- /dev/null
+++ b/com32/modules/cat.c
@@ -0,0 +1,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;
+}