Prepare for cleanup

This commit is contained in:
lemon-sh 2021-12-16 22:16:13 +01:00
parent e3cd770566
commit 46b5a66bb0
5 changed files with 34 additions and 33 deletions

View file

@ -1,19 +1,19 @@
// ANSI color escape code definitions.
#ifdef BBS_COLOR
#define ANSI_RED "\x1b[91m"
#define ANSI_GREEN "\x1b[92m"
#define ANSI_YELLOW "\x1b[93m"
#define ANSI_BLUE "\x1b[94m"
#define ANSI_MAGENTA "\x1b[95m"
#define ANSI_CYAN "\x1b[96m"
#define ANSI_RESET "\x1b[0m"
#else
#define ANSI_RED
#define ANSI_GREEN
#define ANSI_YELLOW
#define ANSI_BLUE
#define ANSI_MAGENTA
#define ANSI_CYAN
#define ANSI_RESET
#endif
// ANSI color escape code definitions.
#ifdef BBS_COLOR
#define ANSI_RED "\x1b[91m"
#define ANSI_GREEN "\x1b[92m"
#define ANSI_YELLOW "\x1b[93m"
#define ANSI_BLUE "\x1b[94m"
#define ANSI_MAGENTA "\x1b[95m"
#define ANSI_CYAN "\x1b[96m"
#define ANSI_RESET "\x1b[0m"
#else
#define ANSI_RED
#define ANSI_GREEN
#define ANSI_YELLOW
#define ANSI_BLUE
#define ANSI_MAGENTA
#define ANSI_CYAN
#define ANSI_RESET
#endif

View file

@ -1,6 +1,6 @@
// LEMONBBS MODULES: CONNLIST
// This module allows for storing connection information statically instead of
// allocating new blocks on every connection and freeing them afterwards.
// allocating on every connection
#include <pthread.h>
#include <memory.h>

View file

@ -7,7 +7,6 @@
struct Connection {
uint8_t state;
struct LemonClientSocket socket;
pthread_t connThread;
int64_t userId; // -1 if not logged in
char username[64]; // to reduce db calls
};

View file

@ -17,7 +17,7 @@
// config values
unsigned short configPort;
unsigned int configConnlimit;
char *configCertfile, *configKeyfile, *configPassword;
char *configCertfile, *configKeyfile, *configPassword, sslInUse;
// return value: 0 = succeeded ; 1 = failed
uint8_t initConfigFromFile(const char* configPath) {
@ -37,19 +37,19 @@ uint8_t initConfigFromFile(const char* configPath) {
configPort = confPort.u.b;
toml_table_t* ssl = toml_table_in(conf, "ssl");
if (!ssl) {logMessage(error, "Config parsing error: missing [ssl]"); return 1;}
if (ssl) {
toml_datum_t confCertfile = toml_string_in(ssl, "certfile");
if (!confCertfile.ok) {logMessage(error, "Config parsing error: missing 'certfile' field"); return 1;}
configCertfile = confCertfile.u.s;
toml_datum_t confCertfile = toml_string_in(ssl, "certfile");
if (!confCertfile.ok) {logMessage(error, "Config parsing error: missing 'certfile' field"); return 1;}
configCertfile = confCertfile.u.s;
toml_datum_t confKeyfile = toml_string_in(ssl, "keyfile");
if (!confKeyfile.ok) {logMessage(error, "Config parsing error: missing 'keyfile' field"); return 1;}
configKeyfile = confKeyfile.u.s;
toml_datum_t confKeyfile = toml_string_in(ssl, "keyfile");
if (!confKeyfile.ok) {logMessage(error, "Config parsing error: missing 'keyfile' field"); return 1;}
configKeyfile = confKeyfile.u.s;
toml_datum_t confPassword = toml_string_in(ssl, "password");
if (!confPassword.ok) {logMessage(error, "Config parsing error: missing 'password' field"); return 1;}
configPassword = confPassword.u.s;
toml_datum_t confPassword = toml_string_in(ssl, "password");
if (!confPassword.ok) {logMessage(error, "Config parsing error: missing 'password' field"); return 1;}
configPassword = confPassword.u.s;
}
toml_table_t* bbs = toml_table_in(conf, "bbs");
if (!bbs) {logMessage(error, "Config parsing error: missing [bbs]"); return 1;}

View file

@ -1,6 +1,8 @@
#ifndef CHATSERVER_UTILS_H
#define CHATSERVER_UTILS_H
#include <stddef.h>
#define METASTRING(x) x,sizeof(x)-1
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)