diff --git a/.gitignore b/.gitignore index 4974e64..c795b05 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -*.o -xnoircd +build \ No newline at end of file diff --git a/Makefile b/Makefile index 52da20e..755cdaa 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,18 @@ FLAGS = -pthread OFLAGS = -g -xnoircd: user.o nameable.o channel.o connection.o ircserver.o irccommand.o userconnection.o main.o - g++ $(FLAGS) user.o nameable.o channel.o connection.o ircserver.o irccommand.o userconnection.o main.o -o $@ +XNOIRDC_CPP_SRCS = $(shell find src/ -name '*.cpp') +XNOIRDC_CPP_OBJS = $(patsubst src/%.cpp,build/%.o,$(XNOIRDC_CPP_SRCS)) -user.o: user.cpp user.h - g++ $(OFLAGS) -c $*.cpp +XNOIRDC_OBJS = $(XNOIRDC_CPP_OBJS) -connection.o: connection.cpp connection.h - g++ $(OFLAGS) -c $*.cpp +.PHONY: clean -ircserver.o: ircserver.cpp ircserver.h - g++ $(OFLAGS) -c $*.cpp +build/xnoircd: $(XNOIRDC_OBJS) + g++ $(FLAGS) $^ -o $@ -irccommand.o: irccommand.cpp irccommand.h - g++ $(OFLAGS) -c $*.cpp +build/%.o: src/%.cpp + g++ -c $< -o $@ -userconnection.o: userconnection.cpp userconnection.h - g++ $(OFLAGS) -c $*.cpp - -nameable.o: nameable.cpp nameable.h - g++ $(OFLAGS) -c $*.cpp - -channel.o: channel.cpp channel.h - g++ $(OFLAGS) -c $*.cpp - -main.o: main.cpp - g++ $(OFLAGS) -c $*.cpp \ No newline at end of file +clean: + rm *.o diff --git a/channel.cpp b/src/channel.cpp similarity index 100% rename from channel.cpp rename to src/channel.cpp diff --git a/channel.h b/src/channel.h similarity index 100% rename from channel.h rename to src/channel.h diff --git a/connection.cpp b/src/connection.cpp similarity index 100% rename from connection.cpp rename to src/connection.cpp diff --git a/connection.h b/src/connection.h similarity index 100% rename from connection.h rename to src/connection.h diff --git a/irccommand.cpp b/src/irccommand.cpp similarity index 91% rename from irccommand.cpp rename to src/irccommand.cpp index f0b0dd3..34ac63d 100644 --- a/irccommand.cpp +++ b/src/irccommand.cpp @@ -1,7 +1,5 @@ #include "irccommand.h" -#include - IRCCommand::IRCCommand() {} IRCCommand::IRCCommand(std::string raw_command) { if (raw_command[0] == '@') { @@ -56,14 +54,6 @@ IRCCommand::IRCCommand(std::string source, std::string command) { this->source = source; this->command = command; } -/* -template -IRCCommand::IRCCommand(std::string source, std::string command, T... params) { - this->source = source; - this->command = command; - this->parameters = {params...}; -} -*/ IRCCommand::~IRCCommand() { this->parameters.clear(); diff --git a/irccommand.h b/src/irccommand.h similarity index 100% rename from irccommand.h rename to src/irccommand.h diff --git a/ircserver.cpp b/src/ircserver.cpp similarity index 100% rename from ircserver.cpp rename to src/ircserver.cpp diff --git a/ircserver.h b/src/ircserver.h similarity index 100% rename from ircserver.h rename to src/ircserver.h diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp diff --git a/nameable.cpp b/src/nameable.cpp similarity index 100% rename from nameable.cpp rename to src/nameable.cpp diff --git a/nameable.h b/src/nameable.h similarity index 100% rename from nameable.h rename to src/nameable.h diff --git a/user.cpp b/src/user.cpp similarity index 98% rename from user.cpp rename to src/user.cpp index 61f1ba5..7e54f51 100644 --- a/user.cpp +++ b/src/user.cpp @@ -62,6 +62,7 @@ std::vector User::user_cmd(IRCCommand cmd) { auto motd = motd_cmd(IRCCommand()); to_return.insert(to_return.end(), motd.begin(), motd.end()); + return to_return; } @@ -200,13 +201,11 @@ std::vector User::motd_cmd(IRCCommand cmd) { std::vector User::process_cmd(IRCCommand cmd) { auto command = commands.find(cmd.get_command()); - if (command == commands.end()) { + if (command == commands.end()) return {IRCCommand(server->get_hostname(), "421", get_nick(), cmd.get_command(), "Unknown Command.")}; - } - if (cmd.get_parameter_count() < std::get<0>(command->second)) { + if (cmd.get_parameter_count() < std::get<0>(command->second)) return {IRCCommand(server->get_hostname(), "461", get_nick(), cmd.get_command(), "Too few parameters.")}; - } if (this->state == Initial && std::get<2>(command->second)) return {}; diff --git a/user.h b/src/user.h similarity index 100% rename from user.h rename to src/user.h diff --git a/userconnection.cpp b/src/userconnection.cpp similarity index 100% rename from userconnection.cpp rename to src/userconnection.cpp diff --git a/userconnection.h b/src/userconnection.h similarity index 100% rename from userconnection.h rename to src/userconnection.h