#include #include #include #include #include int main(void) { int i, ret; char buf[4096]; struct pollfd pollfd = {0, POLLIN}; fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK); while (1) { ret = poll(&pollfd, 1, -1); if (ret == -1) { perror("poll"); return EXIT_FAILURE; } else if (ret == 0) { continue; } else { /* Fall through. */ } ret = read(0, buf, 4096); if (ret == -1) { perror("read"); return EXIT_FAILURE; } else if (ret == 0) { return EXIT_SUCCESS; } else { for (i = 0; i < ret; ++i) { if (islower(buf[i])) buf[i] += 'A' - 'a'; else if (isupper(buf[i])) buf[i] += 'a' - 'A'; } write(1, buf, ret); } } return EXIT_SUCCESS; } /* vim: set ts=4 sts=4 sw=4 tw=80 et: */