diff options
Diffstat (limited to 'contrib/syslinux-4.02/com32/modules/cat.c')
-rw-r--r-- | contrib/syslinux-4.02/com32/modules/cat.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/com32/modules/cat.c b/contrib/syslinux-4.02/com32/modules/cat.c new file mode 100644 index 0000000..0a9514c --- /dev/null +++ b/contrib/syslinux-4.02/com32/modules/cat.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <stdlib.h> +#include <console.h> + +int main(int argc, char *argv[]) +{ + FILE *f; + int i; + int len; + char buf[4096]; + + openconsole(&dev_stdcon_r, &dev_stdcon_w); + + if (argc < 2) { + fprintf(stderr, "Usage: %s filename...\n", argv[0]); + return 1; + } + + for (i = 1; i < argc; i++) { + f = fopen(argv[i], "r"); + if (!f) { + fprintf(stderr, "%s: %s: file not found\n", argv[0], argv[i]); + return 1; + } + + while ((len = fread(buf, 1, sizeof buf, f)) > 0) + fwrite(buf, 1, len, stdout); + + fclose(f); + } + + return 0; +} |