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:
1 parent
0b588bf715
commit
4c930e3b82
53 files changed
+81
-81
No files matched your search
+3
-3
@@ -9,9 +9,9 @@ elseif (UNIX)
|
|||||||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections")
|
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections")
|
||||||
endif()
|
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_SQLITE3 "Enable SQLite3 support" OFF)
|
||||||
option(USE_WERROR "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)
|
if(USE_SQLITE3)
|
||||||
find_package(SQLite3 REQUIRED)
|
find_package(SQLite3 REQUIRED)
|
||||||
add_definitions(-DUSE_SQLITE3)
|
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()
|
endif()
|
||||||
|
|
||||||
if(USE_WERROR)
|
if(USE_WERROR)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ CC = gcc
|
|||||||
CFLAGS = -Wall -g -std=gnu2x -DMG_TLS=MG_TLS_OPENSSL -ffunction-sections -fdata-sections
|
CFLAGS = -Wall -g -std=gnu2x -DMG_TLS=MG_TLS_OPENSSL -ffunction-sections -fdata-sections
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
INCLUDES = -I./src/lib -I./src
|
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)
|
OBJS = $(SRCS:.c=.o)
|
||||||
TARGET = auth_service
|
TARGET = auth_service
|
||||||
BUILD_DIR=./build
|
BUILD_DIR=./build
|
||||||
@@ -18,7 +18,7 @@ endif
|
|||||||
ifeq ($(USE_SQLITE3), 1)
|
ifeq ($(USE_SQLITE3), 1)
|
||||||
CFLAGS += -DUSE_SQLITE3
|
CFLAGS += -DUSE_SQLITE3
|
||||||
LIBS += -lsqlite3
|
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
|
endif
|
||||||
|
|
||||||
ifeq ($(WERROR), 1)
|
ifeq ($(WERROR), 1)
|
||||||
|
|||||||
+27
-27
@@ -13,35 +13,35 @@ use_sqlite3 = get_option('use_sqlite3')
|
|||||||
use_werror = get_option('use_werror')
|
use_werror = get_option('use_werror')
|
||||||
sources = [
|
sources = [
|
||||||
'src/main.c',
|
'src/main.c',
|
||||||
'src/user.c',
|
'src/api/user.c',
|
||||||
'src/add_user.c',
|
'src/api/add_user.c',
|
||||||
'src/change_password.c',
|
'src/api/change_password.c',
|
||||||
'src/change_user.c',
|
'src/api/change_user.c',
|
||||||
'src/delete_user.c',
|
'src/api/delete_user.c',
|
||||||
'src/get_all_users.c',
|
'src/api/get_all_users.c',
|
||||||
'src/get_token.c',
|
'src/api/get_token.c',
|
||||||
'src/get_user.c',
|
'src/api/get_user.c',
|
||||||
'src/register_user.c',
|
'src/api/register_user.c',
|
||||||
'src/verify_token.c',
|
'src/api/verify_token.c',
|
||||||
'src/utils.c',
|
'src/utils/utils.c',
|
||||||
'src/jwt.c',
|
'src/security/jwt.c',
|
||||||
'src/lib/mongoose.c',
|
'src/lib/mongoose.c',
|
||||||
'src/lib/cJSON.c',
|
'src/lib/cJSON.c',
|
||||||
'src/database.c',
|
'src/database/database.c',
|
||||||
'src/db_get_all_users.c',
|
'src/database/db_get_all_users.c',
|
||||||
'src/db_get_user_by_username.c',
|
'src/database/db_get_user_by_username.c',
|
||||||
'src/db_get_users_from_file.c',
|
'src/database/db_get_users_from_file.c',
|
||||||
'src/file.c',
|
'src/utils/file.c',
|
||||||
'src/db_insert_user.c',
|
'src/database/db_insert_user.c',
|
||||||
'src/db_update_user.c',
|
'src/database/db_update_user.c',
|
||||||
'src/db_delete_user.c',
|
'src/database/db_delete_user.c',
|
||||||
'src/db_get_user_by_id.c',
|
'src/database/db_get_user_by_id.c',
|
||||||
'src/ConfigManager.c',
|
'src/config/ConfigManager.c',
|
||||||
'src/config.c',
|
'src/config/config.c',
|
||||||
'src/static.c',
|
'src/api/static.c',
|
||||||
'src/cors.c',
|
'src/security/cors.c',
|
||||||
'src/db_get_user_field_by_id.c',
|
'src/database/db_get_user_field_by_id.c',
|
||||||
'src/db_update_user_field.c',
|
'src/database/db_update_user_field.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
with_filedb_sources = [
|
with_filedb_sources = [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "jwt.h"
|
#include "security/jwt.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
void add_user(struct mg_connection *c, struct mg_http_message *hm) {
|
void add_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||||
request_with_token *requestdata = check_body(hm);
|
request_with_token *requestdata = check_body(hm);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
#include "jwt.h"
|
#include "security/jwt.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
void change_password(struct mg_connection *c, struct mg_http_message *hm) {
|
void change_password(struct mg_connection *c, struct mg_http_message *hm) {
|
||||||
if (hm->body.len == 0) {
|
if (hm->body.len == 0) {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "jwt.h"
|
#include "security/jwt.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
void change_user(struct mg_connection *c, struct mg_http_message *hm) {
|
void change_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||||
if (hm->body.len == 0) {
|
if (hm->body.len == 0) {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "jwt.h"
|
#include "security/jwt.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
void delete_user(struct mg_connection *c, struct mg_http_message *hm) {
|
void delete_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||||
if (hm->body.len == 0) {
|
if (hm->body.len == 0) {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "jwt.h"
|
#include "security/jwt.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
void get_all_users(struct mg_connection *c, struct mg_http_message *hm) {
|
void get_all_users(struct mg_connection *c, struct mg_http_message *hm) {
|
||||||
request_with_token *data = check_body(hm);
|
request_with_token *data = check_body(hm);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "jwt.h"
|
#include "security/jwt.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
|
||||||
void get_token(struct mg_connection *c, struct mg_http_message *hm) {
|
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 "user.h"
|
||||||
#include "utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
void get_user(struct mg_connection *c, struct mg_http_message *hm) {
|
void get_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||||
if (hm->body.len == 0) {
|
if (hm->body.len == 0) {
|
||||||
File renamed without changes.
File renamed without changes.
@@ -1,9 +1,9 @@
|
|||||||
#include "static.h"
|
#include "static.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config/config.h"
|
||||||
|
|
||||||
void root_handler(struct mg_connection *c, struct mg_http_message *hm) {
|
void root_handler(struct mg_connection *c, struct mg_http_message *hm) {
|
||||||
struct mg_http_serve_opts opts = {
|
struct mg_http_serve_opts opts = {
|
||||||
.root_dir = cm_get_parameter_as_string(config, "web")};
|
.root_dir = cm_get_parameter_as_string(config, "web")};
|
||||||
mg_http_serve_dir(c, hm, &opts);
|
mg_http_serve_dir(c, hm, &opts);
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
|||||||
#include "jwt.h"
|
#include "security/jwt.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
#include "utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
void verify_token(struct mg_connection *c, struct mg_http_message *hm) {
|
void verify_token(struct mg_connection *c, struct mg_http_message *hm) {
|
||||||
request_with_token *data = check_body(hm);
|
request_with_token *data = check_body(hm);
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "file.h"
|
#include "utils/file.h"
|
||||||
|
|
||||||
typedef struct ConfigManager {
|
typedef struct ConfigManager {
|
||||||
cJSON *config;
|
cJSON *config;
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "sqlite_db/sqlite.h"
|
#include "sqlite_db/sqlite.h"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "sqlite_db/sqlite.h"
|
#include "sqlite_db/sqlite.h"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "sqlite_db/sqlite.h"
|
#include "sqlite_db/sqlite.h"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "sqlite_db/sqlite.h"
|
#include "sqlite_db/sqlite.h"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "sqlite_db/sqlite.h"
|
#include "sqlite_db/sqlite.h"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <cJSON.h>
|
#include <cJSON.h>
|
||||||
#include "file.h"
|
#include "utils/file.h"
|
||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
void db_get_users_from_file(const char *path) {
|
void db_get_users_from_file(const char *path) {
|
||||||
char *users_string = read_file(path);
|
char *users_string = read_file(path);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "sqlite_db/sqlite.h"
|
#include "sqlite_db/sqlite.h"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "sqlite_db/sqlite.h"
|
#include "sqlite_db/sqlite.h"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
#ifdef USE_SQLITE3
|
#ifdef USE_SQLITE3
|
||||||
#include "sqlite_db/sqlite.h"
|
#include "sqlite_db/sqlite.h"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
extern pthread_mutex_t users_file_mutex;
|
extern pthread_mutex_t users_file_mutex;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "../file.h"
|
#include "utils/file.h"
|
||||||
#include "cJSON.h"
|
#include "cJSON.h"
|
||||||
#include "filedb.h"
|
#include "filedb.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "../file.h"
|
#include "utils/file.h"
|
||||||
#include "filedb.h"
|
#include "filedb.h"
|
||||||
|
|
||||||
char *filedb_get_all_users() {
|
char *filedb_get_all_users() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "../file.h"
|
#include "utils/file.h"
|
||||||
#include "filedb.h"
|
#include "filedb.h"
|
||||||
|
|
||||||
User *filedb_get_user_by_id(const int id) {
|
User *filedb_get_user_by_id(const int id) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "../file.h"
|
#include "utils/file.h"
|
||||||
#include "filedb.h"
|
#include "filedb.h"
|
||||||
|
|
||||||
User *filedb_get_user_by_username(const char *username) {
|
User *filedb_get_user_by_username(const char *username) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "../file.h"
|
#include "utils/file.h"
|
||||||
#include "filedb.h"
|
#include "filedb.h"
|
||||||
|
|
||||||
char *filedb_get_user_field_by_id(const int id, const char *field) {
|
char *filedb_get_user_field_by_id(const int id, const char *field) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "../file.h"
|
#include "utils/file.h"
|
||||||
#include "filedb.h"
|
#include "filedb.h"
|
||||||
|
|
||||||
User *filedb_insert_user(const char *username, const char *email,
|
User *filedb_insert_user(const char *username, const char *email,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "../file.h"
|
#include "utils/file.h"
|
||||||
#include "filedb.h"
|
#include "filedb.h"
|
||||||
|
|
||||||
User *filedb_update_user(const int userid, const char *username,
|
User *filedb_update_user(const int userid, const char *username,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include "../file.h"
|
#include "utils/file.h"
|
||||||
#include "filedb.h"
|
#include "filedb.h"
|
||||||
|
|
||||||
bool filedb_update_user_field(const int id, const char *field,
|
bool filedb_update_user_field(const int id, const char *field,
|
||||||
|
|||||||
+7
-7
@@ -5,13 +5,13 @@
|
|||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "config.h"
|
#include "config/config.h"
|
||||||
#include "cors.h"
|
#include "security/cors.h"
|
||||||
#include "database.h"
|
#include "database/database.h"
|
||||||
#include "file.h"
|
#include "utils/file.h"
|
||||||
#include "route.h"
|
#include "api/route.h"
|
||||||
#include "static.h"
|
#include "api/static.h"
|
||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
static const struct route routes[] = {
|
static const struct route routes[] = {
|
||||||
{"GET", "/#", root_handler},
|
{"GET", "/#", root_handler},
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#include "../user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
extern sqlite3 *db;
|
extern sqlite3 *db;
|
||||||
extern pthread_mutex_t db_mutex;
|
extern pthread_mutex_t db_mutex;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../database.h"
|
#include "database/database.h"
|
||||||
#include "sql.h"
|
#include "sql.h"
|
||||||
#include "sqlite.h"
|
#include "sqlite.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "../config.h"
|
#include "../config/config.h"
|
||||||
#include "sqlite.h"
|
#include "sqlite.h"
|
||||||
|
|
||||||
void sqlite_init_db() {
|
void sqlite_init_db() {
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
@@ -3,7 +3,7 @@
|
|||||||
#include <cJSON.h>
|
#include <cJSON.h>
|
||||||
#include <mongoose.h>
|
#include <mongoose.h>
|
||||||
|
|
||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
request_with_token *check_body(const struct mg_http_message *hm) {
|
request_with_token *check_body(const struct mg_http_message *hm) {
|
||||||
if (hm->body.len == 0) {
|
if (hm->body.len == 0) {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "user.h"
|
#include "api/user.h"
|
||||||
|
|
||||||
request_with_token *check_body(const struct mg_http_message *hm);
|
request_with_token *check_body(const struct mg_http_message *hm);
|
||||||
Reference in new issue
Block a user