Prepare for cleanup
This commit is contained in:
parent
e3cd770566
commit
46b5a66bb0
|
@ -1,19 +1,19 @@
|
||||||
// ANSI color escape code definitions.
|
// ANSI color escape code definitions.
|
||||||
|
|
||||||
#ifdef BBS_COLOR
|
#ifdef BBS_COLOR
|
||||||
#define ANSI_RED "\x1b[91m"
|
#define ANSI_RED "\x1b[91m"
|
||||||
#define ANSI_GREEN "\x1b[92m"
|
#define ANSI_GREEN "\x1b[92m"
|
||||||
#define ANSI_YELLOW "\x1b[93m"
|
#define ANSI_YELLOW "\x1b[93m"
|
||||||
#define ANSI_BLUE "\x1b[94m"
|
#define ANSI_BLUE "\x1b[94m"
|
||||||
#define ANSI_MAGENTA "\x1b[95m"
|
#define ANSI_MAGENTA "\x1b[95m"
|
||||||
#define ANSI_CYAN "\x1b[96m"
|
#define ANSI_CYAN "\x1b[96m"
|
||||||
#define ANSI_RESET "\x1b[0m"
|
#define ANSI_RESET "\x1b[0m"
|
||||||
#else
|
#else
|
||||||
#define ANSI_RED
|
#define ANSI_RED
|
||||||
#define ANSI_GREEN
|
#define ANSI_GREEN
|
||||||
#define ANSI_YELLOW
|
#define ANSI_YELLOW
|
||||||
#define ANSI_BLUE
|
#define ANSI_BLUE
|
||||||
#define ANSI_MAGENTA
|
#define ANSI_MAGENTA
|
||||||
#define ANSI_CYAN
|
#define ANSI_CYAN
|
||||||
#define ANSI_RESET
|
#define ANSI_RESET
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// LEMONBBS MODULES: CONNLIST
|
// LEMONBBS MODULES: CONNLIST
|
||||||
// This module allows for storing connection information statically instead of
|
// 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 <pthread.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
struct Connection {
|
struct Connection {
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
struct LemonClientSocket socket;
|
struct LemonClientSocket socket;
|
||||||
pthread_t connThread;
|
|
||||||
int64_t userId; // -1 if not logged in
|
int64_t userId; // -1 if not logged in
|
||||||
char username[64]; // to reduce db calls
|
char username[64]; // to reduce db calls
|
||||||
};
|
};
|
||||||
|
|
24
src/main.c
24
src/main.c
|
@ -17,7 +17,7 @@
|
||||||
// config values
|
// config values
|
||||||
unsigned short configPort;
|
unsigned short configPort;
|
||||||
unsigned int configConnlimit;
|
unsigned int configConnlimit;
|
||||||
char *configCertfile, *configKeyfile, *configPassword;
|
char *configCertfile, *configKeyfile, *configPassword, sslInUse;
|
||||||
|
|
||||||
// return value: 0 = succeeded ; 1 = failed
|
// return value: 0 = succeeded ; 1 = failed
|
||||||
uint8_t initConfigFromFile(const char* configPath) {
|
uint8_t initConfigFromFile(const char* configPath) {
|
||||||
|
@ -37,19 +37,19 @@ uint8_t initConfigFromFile(const char* configPath) {
|
||||||
configPort = confPort.u.b;
|
configPort = confPort.u.b;
|
||||||
|
|
||||||
toml_table_t* ssl = toml_table_in(conf, "ssl");
|
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");
|
toml_datum_t confKeyfile = toml_string_in(ssl, "keyfile");
|
||||||
if (!confCertfile.ok) {logMessage(error, "Config parsing error: missing 'certfile' field"); return 1;}
|
if (!confKeyfile.ok) {logMessage(error, "Config parsing error: missing 'keyfile' field"); return 1;}
|
||||||
configCertfile = confCertfile.u.s;
|
configKeyfile = confKeyfile.u.s;
|
||||||
|
|
||||||
toml_datum_t confKeyfile = toml_string_in(ssl, "keyfile");
|
toml_datum_t confPassword = toml_string_in(ssl, "password");
|
||||||
if (!confKeyfile.ok) {logMessage(error, "Config parsing error: missing 'keyfile' field"); return 1;}
|
if (!confPassword.ok) {logMessage(error, "Config parsing error: missing 'password' field"); return 1;}
|
||||||
configKeyfile = confKeyfile.u.s;
|
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");
|
toml_table_t* bbs = toml_table_in(conf, "bbs");
|
||||||
if (!bbs) {logMessage(error, "Config parsing error: missing [bbs]"); return 1;}
|
if (!bbs) {logMessage(error, "Config parsing error: missing [bbs]"); return 1;}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef CHATSERVER_UTILS_H
|
#ifndef CHATSERVER_UTILS_H
|
||||||
#define CHATSERVER_UTILS_H
|
#define CHATSERVER_UTILS_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#define METASTRING(x) x,sizeof(x)-1
|
#define METASTRING(x) x,sizeof(x)-1
|
||||||
#define STR_HELPER(x) #x
|
#define STR_HELPER(x) #x
|
||||||
#define STR(x) STR_HELPER(x)
|
#define STR(x) STR_HELPER(x)
|
||||||
|
|
Reference in a new issue