diff --git a/CMakeLists.txt b/CMakeLists.txt index 22827b5..3ec649c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -project(cexp LANGUAGES C) +project(netex LANGUAGES C) add_compile_options(-pthread) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b2fcf78..8befb70 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ -add_executable(cexp +add_executable(netex "main.c" "exp_list.c") -target_include_directories(cexp PRIVATE ${CMAKE_SOURCE_DIR}/src/include) -add_subdirectory(include) -add_subdirectory(sockets) +target_include_directories(netex PRIVATE ${CMAKE_SOURCE_DIR}/src/include) +add_subdirectory(net) +#add_subdirectory(include) +#add_subdirectory(sockets) diff --git a/src/exp_list.c b/src/exp_list.c index 9d746c9..eba5a7d 100644 --- a/src/exp_list.c +++ b/src/exp_list.c @@ -1,6 +1,7 @@ #include "stdlib.h" #include "string.h" #include "cexp.h" +#include "netex.h" #define INCREMENT_SIZE 5 diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 80c6d61..ab326f9 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -1,4 +1,6 @@ target_sources(cexp PUBLIC + "net.h" + "netex.h" "cexp.h" "sockets.h") diff --git a/src/include/net.h b/src/include/net.h new file mode 100644 index 0000000..53a829d --- /dev/null +++ b/src/include/net.h @@ -0,0 +1,6 @@ +#ifndef NET_H +#define NET_H + +#define PORTNR 6969 + +#endif //NET_H \ No newline at end of file diff --git a/src/include/netex.h b/src/include/netex.h new file mode 100644 index 0000000..b5a3f19 --- /dev/null +++ b/src/include/netex.h @@ -0,0 +1,9 @@ +#ifndef NETEX_H +#define NETEX_H + +#define PRINT(msg, args...) fprintf(stdout, msg, ##args) +#define PRINT_LINE(msg, args...) fprintf(stdout, msg "\n", ##args) +#define WARN(msg, args...) fprintf(stdout, "[Warning]: " msg "\n", ##args) +#define ERROR(msg, args...) fprintf(stderr, "[ERROR]: " msg "\n", ##args) + +#endif //NETEX_H \ No newline at end of file diff --git a/src/main.c b/src/main.c index 8e2d52f..ec3eb96 100644 --- a/src/main.c +++ b/src/main.c @@ -3,31 +3,29 @@ #include #include #include -#include "cexp.h" -#include "sockets.h" +#include "netex.h" -int checkarg(int argc, char* argv[]); -int handleoptions(); +//int checkarg(int argc, char* argv[]); +//int handleoptions(); void app_cleanup(); int main(int argc, char *argv[]) { signal(SIGINT, app_cleanup); - list_add("Socket server", "server", start_server); - list_add("Socket client", "client", clientstart); + //list_add("Socket server", "server", start_server); + //list_add("Socket client", "client", clientstart); - printf(" _____ \n / ____| \n | | _____ ___ __ \n | | / _ \\ \\/ / '_ \\ \n | |___| __/> <| |_) |\n \\_____\\___/_/\\_\\ .__/ \n | | \n |_| \n"); - // Check for argruments and if we can use them. - int result = checkarg(argc, argv); + //int result = checkarg(argc, argv); + int result = 0; if (result == 0) return result; - // If the app does not get args we will display a small options menu. - result = handleoptions(); + + //result = handleoptions(); app_cleanup(); return result; } -int checkarg(int argc, char* argv[]) +/* int checkarg(int argc, char* argv[]) { if (argc == 2) { @@ -37,9 +35,9 @@ int checkarg(int argc, char* argv[]) return command->func_ptr(NULL); } return -1; -} +} */ -int handleoptions() +/* int handleoptions() { PRINT_LINE("Choose a option:"); print_list_items(); @@ -63,10 +61,9 @@ int handleoptions() return data->func_ptr != NULL ? data->func_ptr(NULL) : -1; } - -// Clean and exit the app. + */ void app_cleanup() { - clear_list(); // Clear the exp list. + //clear_list(); exit(0); } diff --git a/src/net/CMakeLists.txt b/src/net/CMakeLists.txt new file mode 100644 index 0000000..e69de29