From 36d00051de9152546eddfbc84223cee251aee87a Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Wed, 4 Jan 2023 00:56:33 -0600 Subject: server: add a main header and source file Add a main header and source file so that every required header is checked against the config.h generated by autoconf. Signed-off-by: Danny Holman --- server/include/logging.h | 2 +- server/include/mini-rat.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++ server/include/server.h | 2 +- server/src/logging.c | 4 ---- server/src/mini-rat.c | 13 +++++++++++ server/src/session.c | 4 +--- 6 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 server/include/mini-rat.h create mode 100644 server/src/mini-rat.c diff --git a/server/include/logging.h b/server/include/logging.h index 6e8dfaa..39745db 100644 --- a/server/include/logging.h +++ b/server/include/logging.h @@ -1,7 +1,7 @@ #ifndef MRAT_LOGGING_H #define MRAT_LOGGING_H -#include +#include #include enum LOG_LEVEL { diff --git a/server/include/mini-rat.h b/server/include/mini-rat.h new file mode 100644 index 0000000..c3f076e --- /dev/null +++ b/server/include/mini-rat.h @@ -0,0 +1,56 @@ +/* + * Mini-RAT Server + * Copyright (C) 2022 Danny Holman + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef MINI_RAT_H +#define MINI_RAT_H + +#include "config.h" + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_PTHREAD_H +#include +#endif + +#ifdef HAVE_STDINT_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#endif // ifndef MINI_RAT_H diff --git a/server/include/server.h b/server/include/server.h index 8bd0b94..26f9c42 100644 --- a/server/include/server.h +++ b/server/include/server.h @@ -1,7 +1,7 @@ #ifndef MRAT_SERVER_H #define MRAT_SERVER_H -#include +#include void* control_listener(void *port); void* control_worker(void *sock_desc); diff --git a/server/src/logging.c b/server/src/logging.c index 66f1661..5a721b8 100644 --- a/server/src/logging.c +++ b/server/src/logging.c @@ -1,8 +1,4 @@ #include -#include -#include -#include -#include static const char *severe = "SEVERE"; static const char *warn = "WARN"; diff --git a/server/src/mini-rat.c b/server/src/mini-rat.c new file mode 100644 index 0000000..e0fd5d1 --- /dev/null +++ b/server/src/mini-rat.c @@ -0,0 +1,13 @@ +#include +#include +#include + +int main(int argc, char* argv[]) { + FILE *logfile = fopen("log.txt", "w"); + init_logging(stderr); + uint16_t port = 21115; + pthread_t listen_thread; + pthread_create(&listen_thread, NULL, listener, (void*)&port); + + pthread_exit(NULL); +} diff --git a/server/src/session.c b/server/src/session.c index b2b760c..2737f4b 100644 --- a/server/src/session.c +++ b/server/src/session.c @@ -1,8 +1,6 @@ #include #include -#include -#include -#include +#include struct list_head sessions; uint16_t next_id = 1; -- cgit v1.2.3