more refactor
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 9s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 12s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Successful in 11s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make-Without-sqlite3 (push) Successful in 9s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake-Without-sqlite3 (push) Successful in 14s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson-Without-sqlite3 (push) Successful in 12s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 9s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 12s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Successful in 11s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make-Without-sqlite3 (push) Successful in 9s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake-Without-sqlite3 (push) Successful in 14s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson-Without-sqlite3 (push) Successful in 12s
This commit is contained in:
+3
-3
@@ -9,9 +9,9 @@ elseif (UNIX)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections")
|
||||
endif()
|
||||
|
||||
include_directories(./src/lib/ ${SQLite3_INCLUDE_DIRS})
|
||||
include_directories(./src/lib/ ./src ${SQLite3_INCLUDE_DIRS})
|
||||
|
||||
FILE(GLOB SOURCES src/*.c src/lib/*.c src/file_db/*.c)
|
||||
FILE(GLOB SOURCES src/*.c src/lib/*.c src/file_db/*.c src/config/*.c src/api/*.c src/database/*.c src/security/*.c src/utils/*.c)
|
||||
|
||||
option(USE_SQLITE3 "Enable SQLite3 support" OFF)
|
||||
option(USE_WERROR "Enable SQLite3 support" OFF)
|
||||
@@ -19,7 +19,7 @@ option(USE_WERROR "Enable SQLite3 support" OFF)
|
||||
if(USE_SQLITE3)
|
||||
find_package(SQLite3 REQUIRED)
|
||||
add_definitions(-DUSE_SQLITE3)
|
||||
FILE(GLOB SOURCES src/*.c src/lib/*.c src/sqlite_db/*.c src/file_db/*.c)
|
||||
FILE(GLOB SOURCES src/*.c src/lib/*.c src/sqlite_db/*.c src/file_db/*.c src/config/*.c src/api/*.c src/database/*.c src/security/*.c src/utils/*.c)
|
||||
endif()
|
||||
|
||||
if(USE_WERROR)
|
||||
|
||||
@@ -2,7 +2,7 @@ CC = gcc
|
||||
CFLAGS = -Wall -g -std=gnu2x -DMG_TLS=MG_TLS_OPENSSL -ffunction-sections -fdata-sections
|
||||
LDFLAGS =
|
||||
INCLUDES = -I./src/lib -I./src
|
||||
SRCS = $(wildcard src/lib/*.c src/file_db/*.c src/*.c)
|
||||
SRCS = $(wildcard src/lib/*.c src/file_db/*.c src/*.c src/config/*.c src/database/*.c src/api/*.c src/security/*.c src/utils/*.c)
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
TARGET = auth_service
|
||||
BUILD_DIR=./build
|
||||
@@ -18,7 +18,7 @@ endif
|
||||
ifeq ($(USE_SQLITE3), 1)
|
||||
CFLAGS += -DUSE_SQLITE3
|
||||
LIBS += -lsqlite3
|
||||
SRCS = $(wildcard src/lib/*.c src/sqlite_db/*.c src/file_db/*.c src/*.c)
|
||||
SRCS = $(wildcard src/lib/*.c src/sqlite_db/*.c src/file_db/*.c src/*.c src/config/*.c src/database/*.c src/api/*.c src/security/*.c src/utils/*.c)
|
||||
endif
|
||||
|
||||
ifeq ($(WERROR), 1)
|
||||
|
||||
+27
-27
@@ -13,35 +13,35 @@ use_sqlite3 = get_option('use_sqlite3')
|
||||
use_werror = get_option('use_werror')
|
||||
sources = [
|
||||
'src/main.c',
|
||||
'src/user.c',
|
||||
'src/add_user.c',
|
||||
'src/change_password.c',
|
||||
'src/change_user.c',
|
||||
'src/delete_user.c',
|
||||
'src/get_all_users.c',
|
||||
'src/get_token.c',
|
||||
'src/get_user.c',
|
||||
'src/register_user.c',
|
||||
'src/verify_token.c',
|
||||
'src/utils.c',
|
||||
'src/jwt.c',
|
||||
'src/api/user.c',
|
||||
'src/api/add_user.c',
|
||||
'src/api/change_password.c',
|
||||
'src/api/change_user.c',
|
||||
'src/api/delete_user.c',
|
||||
'src/api/get_all_users.c',
|
||||
'src/api/get_token.c',
|
||||
'src/api/get_user.c',
|
||||
'src/api/register_user.c',
|
||||
'src/api/verify_token.c',
|
||||
'src/utils/utils.c',
|
||||
'src/security/jwt.c',
|
||||
'src/lib/mongoose.c',
|
||||
'src/lib/cJSON.c',
|
||||
'src/database.c',
|
||||
'src/db_get_all_users.c',
|
||||
'src/db_get_user_by_username.c',
|
||||
'src/db_get_users_from_file.c',
|
||||
'src/file.c',
|
||||
'src/db_insert_user.c',
|
||||
'src/db_update_user.c',
|
||||
'src/db_delete_user.c',
|
||||
'src/db_get_user_by_id.c',
|
||||
'src/ConfigManager.c',
|
||||
'src/config.c',
|
||||
'src/static.c',
|
||||
'src/cors.c',
|
||||
'src/db_get_user_field_by_id.c',
|
||||
'src/db_update_user_field.c',
|
||||
'src/database/database.c',
|
||||
'src/database/db_get_all_users.c',
|
||||
'src/database/db_get_user_by_username.c',
|
||||
'src/database/db_get_users_from_file.c',
|
||||
'src/utils/file.c',
|
||||
'src/database/db_insert_user.c',
|
||||
'src/database/db_update_user.c',
|
||||
'src/database/db_delete_user.c',
|
||||
'src/database/db_get_user_by_id.c',
|
||||
'src/config/ConfigManager.c',
|
||||
'src/config/config.c',
|
||||
'src/api/static.c',
|
||||
'src/security/cors.c',
|
||||
'src/database/db_get_user_field_by_id.c',
|
||||
'src/database/db_update_user_field.c',
|
||||
]
|
||||
|
||||
with_filedb_sources = [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "jwt.h"
|
||||
#include "security/jwt.h"
|
||||
#include "user.h"
|
||||
#include "utils.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void add_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
request_with_token *requestdata = check_body(hm);
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "cJSON.h"
|
||||
#include "jwt.h"
|
||||
#include "security/jwt.h"
|
||||
#include "user.h"
|
||||
#include "utils.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void change_password(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
if (hm->body.len == 0) {
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "jwt.h"
|
||||
#include "security/jwt.h"
|
||||
#include "user.h"
|
||||
#include "utils.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void change_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
if (hm->body.len == 0) {
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "jwt.h"
|
||||
#include "security/jwt.h"
|
||||
#include "user.h"
|
||||
#include "utils.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void delete_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
if (hm->body.len == 0) {
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "jwt.h"
|
||||
#include "security/jwt.h"
|
||||
#include "user.h"
|
||||
#include "utils.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void get_all_users(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
request_with_token *data = check_body(hm);
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "jwt.h"
|
||||
#include "security/jwt.h"
|
||||
#include "user.h"
|
||||
|
||||
void get_token(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "jwt.h"
|
||||
#include "security/jwt.h"
|
||||
#include "user.h"
|
||||
#include "utils.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void get_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
if (hm->body.len == 0) {
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "static.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "config/config.h"
|
||||
|
||||
void root_handler(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
struct mg_http_serve_opts opts = {
|
||||
.root_dir = cm_get_parameter_as_string(config, "web")};
|
||||
mg_http_serve_dir(c, hm, &opts);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "jwt.h"
|
||||
#include "security/jwt.h"
|
||||
#include "user.h"
|
||||
#include "utils.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
void verify_token(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
request_with_token *data = check_body(hm);
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "file.h"
|
||||
#include "utils/file.h"
|
||||
|
||||
typedef struct ConfigManager {
|
||||
cJSON *config;
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "sqlite_db/sqlite.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "sqlite_db/sqlite.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "sqlite_db/sqlite.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "sqlite_db/sqlite.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "sqlite_db/sqlite.h"
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <cJSON.h>
|
||||
#include "file.h"
|
||||
#include "user.h"
|
||||
#include "utils/file.h"
|
||||
#include "api/user.h"
|
||||
|
||||
void db_get_users_from_file(const char *path) {
|
||||
char *users_string = read_file(path);
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "sqlite_db/sqlite.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "sqlite_db/sqlite.h"
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
#ifdef USE_SQLITE3
|
||||
#include "sqlite_db/sqlite.h"
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
extern pthread_mutex_t users_file_mutex;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include "../file.h"
|
||||
#include "utils/file.h"
|
||||
#include "cJSON.h"
|
||||
#include "filedb.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <pthread.h>
|
||||
#include "../file.h"
|
||||
#include "utils/file.h"
|
||||
#include "filedb.h"
|
||||
|
||||
char *filedb_get_all_users() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <pthread.h>
|
||||
#include "../file.h"
|
||||
#include "utils/file.h"
|
||||
#include "filedb.h"
|
||||
|
||||
User *filedb_get_user_by_id(const int id) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <pthread.h>
|
||||
#include "../file.h"
|
||||
#include "utils/file.h"
|
||||
#include "filedb.h"
|
||||
|
||||
User *filedb_get_user_by_username(const char *username) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <pthread.h>
|
||||
#include "../file.h"
|
||||
#include "utils/file.h"
|
||||
#include "filedb.h"
|
||||
|
||||
char *filedb_get_user_field_by_id(const int id, const char *field) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <pthread.h>
|
||||
#include "../file.h"
|
||||
#include "utils/file.h"
|
||||
#include "filedb.h"
|
||||
|
||||
User *filedb_insert_user(const char *username, const char *email,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <pthread.h>
|
||||
#include "../file.h"
|
||||
#include "utils/file.h"
|
||||
#include "filedb.h"
|
||||
|
||||
User *filedb_update_user(const int userid, const char *username,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <pthread.h>
|
||||
#include "../file.h"
|
||||
#include "utils/file.h"
|
||||
#include "filedb.h"
|
||||
|
||||
bool filedb_update_user_field(const int id, const char *field,
|
||||
|
||||
+7
-7
@@ -5,13 +5,13 @@
|
||||
#include <sqlite3.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "cors.h"
|
||||
#include "database.h"
|
||||
#include "file.h"
|
||||
#include "route.h"
|
||||
#include "static.h"
|
||||
#include "user.h"
|
||||
#include "config/config.h"
|
||||
#include "security/cors.h"
|
||||
#include "database/database.h"
|
||||
#include "utils/file.h"
|
||||
#include "api/route.h"
|
||||
#include "api/static.h"
|
||||
#include "api/user.h"
|
||||
|
||||
static const struct route routes[] = {
|
||||
{"GET", "/#", root_handler},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include "../user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
extern sqlite3 *db;
|
||||
extern pthread_mutex_t db_mutex;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../database.h"
|
||||
#include "database/database.h"
|
||||
#include "sql.h"
|
||||
#include "sqlite.h"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../config.h"
|
||||
#include "../config/config.h"
|
||||
#include "sqlite.h"
|
||||
|
||||
void sqlite_init_db() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <cJSON.h>
|
||||
#include <mongoose.h>
|
||||
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
request_with_token *check_body(const struct mg_http_message *hm) {
|
||||
if (hm->body.len == 0) {
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "user.h"
|
||||
#include "api/user.h"
|
||||
|
||||
request_with_token *check_body(const struct mg_http_message *hm);
|
||||
Reference in New Issue
Block a user