aboutsummaryrefslogtreecommitdiffstats
path: root/com32/samples/cat.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/samples/cat.c')
-rw-r--r--com32/samples/cat.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/com32/samples/cat.c b/com32/samples/cat.c
new file mode 100644
index 00000000..277427ff
--- /dev/null
+++ b/com32/samples/cat.c
@@ -0,0 +1,31 @@
+#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);
+
+ printf("argv = %p\n", argv);
+ for ( i = 0 ; i <= argc ; i++ )
+ printf("argv[%d] = %p = \"%s\"\n", i, argv[i], argv[i]);
+
+ if ( argc < 2 ) {
+ fprintf(stderr, "Missing file name!\n");
+ exit(1);
+ }
+
+ printf("File = %s\n", argv[1]);
+
+ f = fopen(argv[1], "r");
+ while ( (ch = getc(f)) != EOF )
+ putchar(ch);
+
+ fclose(f);
+
+ return 0;
+}