diff options
-rw-r--r-- | server/include/logging.h | 2 | ||||
-rw-r--r-- | server/include/mini-rat.h | 56 | ||||
-rw-r--r-- | server/include/server.h | 2 | ||||
-rw-r--r-- | server/src/logging.c | 4 | ||||
-rw-r--r-- | server/src/mini-rat.c | 13 | ||||
-rw-r--r-- | server/src/session.c | 4 |
6 files changed, 72 insertions, 9 deletions
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 <stdio.h> +#include <mini-rat.h> #include <stdarg.h> 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 <dholman@gymli.org> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef MINI_RAT_H +#define MINI_RAT_H + +#include "config.h" + +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif + +#ifdef HAVE_PTHREAD_H +#include <pthread.h> +#endif + +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif + +#ifdef HAVE_STDIO_H +#include <stdio.h> +#endif + +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#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 <stdint.h> +#include <mini-rat.h> 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 <logging.h> -#include <stdio.h> -#include <pthread.h> -#include <time.h> -#include <string.h> 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 <logging.h> +#include <server.h> +#include <mini-rat.h> + +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 <session.h> #include <util.h> -#include <stdlib.h> -#include <unistd.h> -#include <stdint.h> +#include <mini-rat.h> struct list_head sessions; uint16_t next_id = 1; |