diff --git a/Makefile b/Makefile index 36b1e05..21d69f6 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ CXXFLAGS = -Wall -Wextra LDLIBS = $(shell sdl2-config --libs) $(shell sdl2-config --libs)_mixer SRC_DIR = src -CLIENT_SRC := $(wildcard $(SRC_DIR)/client.cpp) +CLIENT_SRC := $(wildcard $(SRC_DIR)/client*.cpp) SERVER_SRC := $(wildcard $(SRC_DIR)/server*.cpp) # Heavily inspired by https://stackoverflow.com/a/30602701 @@ -18,7 +18,7 @@ OBJ_DIR = $(BUILD_DIR)/obj CLIENT_OBJ := $(CLIENT_SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o) SERVER_OBJ := $(SERVER_SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o) -PROGRAM = $(BIN_DIR)/client $(BIN_DIR)/server $(BIN_DIR)/client2 +PROGRAM = $(BIN_DIR)/client $(BIN_DIR)/server .DELETE_ON_ERROR: .PHONY: all clean diff --git a/src/client.cpp b/src/client.cpp index 58f299c..a0f522e 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -5,54 +5,29 @@ You should have received a copy of the GNU General Public License along with thi */ #include -#include #include #include -#include +#include "client_functions.h" #include "signals.h" using namespace std; int main(int argc, char* argv[]) { - if (argc != 3) { - cerr << "Invalid options\n"; + string path, directory; + + if (!getInformation(path, directory, argc, argv)) { + cerr << "Failed to get information\n"; exit(-1); } int server = fork(); - if (server == 0) { - execl(argv[1], argv[1], argv[2], nullptr); - } else { - char input; - cout << "Gained control of server " << server << "\nEnter instructions: [R]esume, [P]ause, re[W]ind, [S]kip, [E]xit (or Ctrl+C to close)\n"; - cin >> input; - - while (tolower(input) != 'e') { - switch(tolower(input)) { - case 'w': - kill(server, REWIND); - break; - case 'p': - kill(server, PAUSE); - break; - case 'r': - kill(server, RESUME); - break; - case 's': - kill(server, SKIP); - break; - default: - cout << "Misunderstood input, enter R, P, S, or E only:\n"; - } - - cin >> input; - } - - kill(server, EXIT); - } + if (server == 0) + execl(path.c_str(), path.c_str(), directory.c_str(), nullptr); + + controlServer(server); return 0; }