mirror of
https://github.com/hmaxnl/netex.git
synced 2025-02-22 21:55:02 +01:00
parent
4850ee2c86
commit
659ca2b76f
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -46,6 +46,7 @@
|
||||||
*.mod*
|
*.mod*
|
||||||
*.cmd
|
*.cmd
|
||||||
.tmp_versions/
|
.tmp_versions/
|
||||||
|
.cmake/
|
||||||
modules.order
|
modules.order
|
||||||
Module.symvers
|
Module.symvers
|
||||||
Mkfile.old
|
Mkfile.old
|
||||||
|
|
|
@ -2,19 +2,22 @@ cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
project(netex LANGUAGES C)
|
project(netex LANGUAGES C)
|
||||||
|
|
||||||
add_compile_options(-pthread)
|
add_compile_options(-pthread -Wall -Wextra -Werror -Wshadow -Wfloat-equal -Wpointer-arith -Wpedantic -pedantic-errors
|
||||||
|
"$<$<CONFIG:RELEASE>:-s;-O3;-DNDEBUG>"
|
||||||
|
"$<$<CONFIG:DEBUG>:-O0;-g>"
|
||||||
|
"$<$<CONFIG:RELWITHDEBINFO>:-O2;-g;-DNDEBUG>")
|
||||||
|
|
||||||
set(PROJ_BUILD_DIR ${CMAKE_BINARY_DIR})
|
set(PROJ_BUILD_DIR ${CMAKE_BINARY_DIR}/build)
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJ_BUILD_DIR}/lib)
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJ_BUILD_DIR}/lib)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJ_BUILD_DIR}/bin)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJ_BUILD_DIR}/bin)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJ_BUILD_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJ_BUILD_DIR}/bin)
|
||||||
|
|
||||||
set(PROJ_REL_BUILD_DIR ${CMAKE_BINARY_DIR}/release)
|
set(PROJ_REL_BUILD_DIR ${PROJ_BUILD_DIR}/release)
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJ_REL_BUILD_DIR}/lib)
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJ_REL_BUILD_DIR}/lib)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJ_REL_BUILD_DIR}/bin)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJ_REL_BUILD_DIR}/bin)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJ_REL_BUILD_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJ_REL_BUILD_DIR}/bin)
|
||||||
|
|
||||||
set(PROJ_DEB_BUILD_DIR ${CMAKE_BINARY_DIR}/debug)
|
set(PROJ_DEB_BUILD_DIR ${PROJ_BUILD_DIR}/debug)
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/lib)
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/lib)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/bin)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/bin)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJ_DEB_BUILD_DIR}/bin)
|
||||||
|
|
2
script/.gdbinit
Normal file
2
script/.gdbinit
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
set debuginfod enabled on
|
||||||
|
set disassembly intel
|
1
script/dbg.gdb
Normal file
1
script/dbg.gdb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
target remote localhost:2345
|
23
script/debug_srv.sh
Normal file
23
script/debug_srv.sh
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
LIGHT_BLUE='\033[0;94m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
|
DBG_LOG="[${LIGHT_BLUE}DBG${NC}] "
|
||||||
|
|
||||||
|
DBG_PATH="build/debug/bin/"
|
||||||
|
|
||||||
|
echo -e "${DBG_LOG}Copy dbg files..."
|
||||||
|
cp ./script/dbg.gdb ${DBG_PATH}/dbg.gdb
|
||||||
|
|
||||||
|
echo -e "${DBG_LOG}Moving to debug location: '${GREEN}${DBG_PATH}${NC}'..."
|
||||||
|
cd ${DBG_PATH}
|
||||||
|
|
||||||
|
#tmux splitw -h -p 50 "gdbserver :2345 ./netex_svr"
|
||||||
|
#tmux selectp -t 0
|
||||||
|
konsole -e "gdbserver :2345 ./netex_svr" &
|
||||||
|
gdb -x dbg.gdb
|
||||||
|
echo -e "${DBG_LOG}Killing ${RED}gdbserver${NC} if running..."
|
||||||
|
pkill -f "gdbserver"
|
||||||
|
echo -e "${GREEN}Done!${NC}"
|
|
@ -4,5 +4,7 @@
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -4,10 +4,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
|
|
||||||
#define PRINT(msg, args...) printw(msg, ##args); refresh()
|
#define PRINT(msg, ...) printw(msg, ##__VA_ARGS__); refresh()
|
||||||
#define PRINT_LINE(msg, args...) printw(msg "\n", ##args); refresh()
|
#define PRINT_LINE(msg, ...) printw(msg "\n", ##__VA_ARGS__); refresh()
|
||||||
#define WARN(msg, args...) printw("[Warning]: " msg "\n", ##args); refresh()
|
#define WARN(msg, ...) printw("[Warning]: " msg "\n", ##__VA_ARGS__); refresh()
|
||||||
#define ERROR(msg, args...) printw("[ERROR]: " msg "\n", ##args); refresh()
|
#define ERROR(msg, ...) printw("[ERROR]: " msg "\n", ##__VA_ARGS__); refresh()
|
||||||
|
|
||||||
|
|
||||||
#define GET_PERC(num, perc) num * perc / 100
|
#define GET_PERC(num, perc) num * perc / 100
|
||||||
|
|
|
@ -195,10 +195,12 @@ void free_host_info(HOST_INFO* host_info)
|
||||||
|
|
||||||
void handle_exit(int c)
|
void handle_exit(int c)
|
||||||
{
|
{
|
||||||
|
(void)c;
|
||||||
netex_shutdown();
|
netex_shutdown();
|
||||||
exit(OK);
|
exit(OK);
|
||||||
}
|
}
|
||||||
void handle_term_resize(int c)
|
void handle_term_resize(int c)
|
||||||
{
|
{
|
||||||
|
(void)c;
|
||||||
//TODO: Set parameter for ncurses code to check if window is resized.
|
//TODO: Set parameter for ncurses code to check if window is resized.
|
||||||
}
|
}
|
|
@ -6,3 +6,8 @@ add_executable(netex_svr
|
||||||
|
|
||||||
target_include_directories(netex_svr PRIVATE ${CMAKE_SOURCE_DIR}/src/net/include)
|
target_include_directories(netex_svr PRIVATE ${CMAKE_SOURCE_DIR}/src/net/include)
|
||||||
target_link_libraries(netex_svr netex)
|
target_link_libraries(netex_svr netex)
|
||||||
|
|
||||||
|
#add_custom_command(TARGET netex_svr POST_BUILD
|
||||||
|
# COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
# ${CMAKE_BINARY_DIR}/script/.gdbinit
|
||||||
|
# ${CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG}/.gdbinit)
|
||||||
|
|
|
@ -21,10 +21,12 @@ int server_sockfd;
|
||||||
struct sockaddr_in server_sockaddr;
|
struct sockaddr_in server_sockaddr;
|
||||||
pthread_t listen_thread;
|
pthread_t listen_thread;
|
||||||
|
|
||||||
void server_listen();
|
void* server_listen(void* args);
|
||||||
|
|
||||||
int initialize_server(int argc, char* argv[])
|
int initialize_server(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
(void)argc;
|
||||||
|
(void)argv;
|
||||||
// Config
|
// Config
|
||||||
srv_configuration = config_load_from_path(CONFIG_PATH);
|
srv_configuration = config_load_from_path(CONFIG_PATH);
|
||||||
if (srv_configuration == NULL)
|
if (srv_configuration == NULL)
|
||||||
|
@ -62,7 +64,7 @@ int initialize_server(int argc, char* argv[])
|
||||||
|
|
||||||
int server_execute(void)
|
int server_execute(void)
|
||||||
{
|
{
|
||||||
const int thread_create_result = pthread_create(&listen_thread, NULL, (void*)server_listen, NULL);
|
const int thread_create_result = pthread_create(&listen_thread, NULL, server_listen, NULL);
|
||||||
if (thread_create_result != 0)
|
if (thread_create_result != 0)
|
||||||
{
|
{
|
||||||
ERROR("Failed to create main listening thread, pthread error: %i", thread_create_result);
|
ERROR("Failed to create main listening thread, pthread error: %i", thread_create_result);
|
||||||
|
@ -75,8 +77,9 @@ int server_execute(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void server_listen()
|
void* server_listen(void* args)
|
||||||
{
|
{
|
||||||
|
(void)args;
|
||||||
PRINT_LINE("Listening...");
|
PRINT_LINE("Listening...");
|
||||||
int some_return_code = 0;
|
int some_return_code = 0;
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -98,8 +101,8 @@ void server_listen()
|
||||||
// Test response
|
// Test response
|
||||||
PRINT_LINE("Accepted clientfd: %i", accepted_fd);
|
PRINT_LINE("Accepted clientfd: %i", accepted_fd);
|
||||||
const char* header = "HTTP/1.1 200 OK\r\nContent-Length: 14\r\nConnection: close\r\n\r\nHello, world!\n";
|
const char* header = "HTTP/1.1 200 OK\r\nContent-Length: 14\r\nConnection: close\r\n\r\nHello, world!\n";
|
||||||
const int header_len = strlen(header);
|
const size_t header_len = strlen(header);
|
||||||
const int send_result = send(accepted_fd, header, header_len, 0);
|
const ssize_t send_result = send(accepted_fd, header, header_len, 0);
|
||||||
if (send_result == -1)
|
if (send_result == -1)
|
||||||
WARN("Error sending message to client!");
|
WARN("Error sending message to client!");
|
||||||
close(accepted_fd);
|
close(accepted_fd);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user