elks-enhanced
public
Read
Owner: themaster
Branch: master
Commits: 6893
Updated: 2026-04-19 00:15
Git CLI clone URL
git clone https://www.xt-emporium.com/git/elks-enhanced.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
elks-enhanced
/
elkscmd
/
file_utils
/
cat.c
File editor
/* * /bin/cat for ELKS; mark II * * 1997 MTK, other insignificant people */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> static char readbuf[BUFSIZ]; /* use disk block size for stack limit and efficiency*/ static int copyfd(int fd) { int n; while ((n = read(fd, readbuf, sizeof(readbuf))) > 0) { if (write(STDOUT_FILENO, readbuf, n) != n) return 1; } return n < 0? 1: 0; } int main(int argc, char **argv) { int i, fd; if (argc <= 1) { if (copyfd(STDIN_FILENO)) { perror("stdin"); return 1; } } else { for (i = 1; i < argc; i++) { errno = 0; if (argv[i][0] == '-' && argv[i][1] == '\0') fd = STDIN_FILENO; else if ((fd = open(argv[i], O_RDONLY)) < 0) { perror(argv[i]); return 1; } if (copyfd(fd)) { perror(argv[i]); close(fd); return 1; } if (fd != STDIN_FILENO) close(fd); } } return 0; }
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
master
Visibility
public
Your access
Read
Remote
Configured
File activity
View file history