diff --git a/Makefile b/Makefile index 4f289b2..d0c0307 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ CFLAGS ?= -Wextra -Wall -O2 .PHONY: all install uninstall clean -nms: $(OBJ)/input.o $(OBJ)/error.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN) +nms: $(OBJ)/error.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN) $(CC) $(CFLAGS) -o $(BIN)/$@ $^ target/release/libnmsrust.a sneakers: $(OBJ)/nmscharset.o $(OBJ)/nmstermio.o $(OBJ)/nmseffect.o $(OBJ)/sneakers.o | $(BIN) @@ -27,7 +27,7 @@ all: nms sneakers all-ncurses: nms-ncurses sneakers-ncurses -nms-ncurses: $(OBJ)/input.o $(OBJ)/error.o $(OBJ)/nmstermio_ncurses.o $(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN) +nms-ncurses: $(OBJ)/error.o $(OBJ)/nmstermio_ncurses.o $(OBJ)/nmseffect.o $(OBJ)/nms.o | $(BIN) $(CC) $(CFLAGS) -o $(BIN)/nms $^ -lncursesw target/release/libnmsrust.a sneakers-ncurses: $(OBJ)/nmscharset.o $(OBJ)/nmstermio_ncurses.o $(OBJ)/nmseffect.o $(OBJ)/sneakers.o | $(BIN) diff --git a/src/input.c b/src/input.c deleted file mode 100644 index 7a84d6b..0000000 --- a/src/input.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2017 Brian Barto - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GPL License. See LICENSE for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "input.h" -#include "error.h" - -int input_get(unsigned char** dest, char *prompt) -{ - int r, input_len; - fd_set input_stream; - struct timeval timeout; - void *timeout_p; - - FD_ZERO(&input_stream); - input_len = 0; - - timeout.tv_sec = 10; - timeout.tv_usec = 0; - - if (isatty(STDIN_FILENO)) - { - timeout_p = NULL; - if (prompt != NULL) - { - printf("%s", prompt); - fflush(stdout); - } - } - else - { - timeout_p = &timeout; - } - - FD_SET(STDIN_FILENO, &input_stream); - r = select(FD_SETSIZE, &input_stream, NULL, NULL, timeout_p); - if (r < 0) - { - error_log("Error while waiting for input data. Errno: %i", errno); - return -1; - } - if (r > 0) - { - r = ioctl(STDIN_FILENO, FIONREAD, &input_len); - if (r < 0) - { - error_log("Could not determine length of input. Errno: %i", errno); - return -1; - } - if (input_len > 0) - { - *dest = malloc(input_len); - if (*dest == NULL) - { - error_log("Memory allocation error."); - return -1; - } - r = read(STDIN_FILENO, *dest, input_len); - if (r < 0) - { - error_log("Input read error. Errno: %i", errno); - return -1; - } - } - } - - FD_CLR(STDIN_FILENO, &input_stream); - - return input_len; -} - diff --git a/src/input.h b/src/input.h deleted file mode 100644 index ad6f528..0000000 --- a/src/input.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright (c) 2017 Brian Barto - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GPL License. See LICENSE for more details. - */ - -#ifndef INPUT_H -#define INPUT_H 1 - -int input_get(unsigned char** dest, char *prompt); - -#endif