Reworking project.

This commit is contained in:
Max 2023-07-30 23:01:41 +02:00
parent 5022d1b096
commit b5349a8f05
8 changed files with 38 additions and 22 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15)
project(cexp LANGUAGES C)
project(netex LANGUAGES C)
add_compile_options(-pthread)

View File

@ -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)

View File

@ -1,6 +1,7 @@
#include "stdlib.h"
#include "string.h"
#include "cexp.h"
#include "netex.h"
#define INCREMENT_SIZE 5

View File

@ -1,4 +1,6 @@
target_sources(cexp PUBLIC
"net.h"
"netex.h"
"cexp.h"
"sockets.h")

6
src/include/net.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef NET_H
#define NET_H
#define PORTNR 6969
#endif //NET_H

9
src/include/netex.h Normal file
View File

@ -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

View File

@ -3,31 +3,29 @@
#include <unistd.h>
#include <string.h>
#include <signal.h>
#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);
}

0
src/net/CMakeLists.txt Normal file
View File