Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a875615
fix: fix some clang-tidy related stuff
Totto16 Apr 15, 2026
314a47e
fix: make all dependencies explicit versioned
Totto16 Apr 15, 2026
f7200d8
feat: remove variant from in repo generations
Totto16 Apr 15, 2026
6be0762
feat: use variant generator
Totto16 Apr 15, 2026
aaba348
feat: use the json library
Totto16 Apr 15, 2026
e847d95
fix: don't use generic macro, prefix it with "_SIMPLE_SERVER_"
Totto16 Apr 15, 2026
ca9c108
fix: remove in build dependencies and replace them with wrap files
Totto16 Apr 15, 2026
8382f8f
feat: replace internal functions by libraries
Totto16 Apr 16, 2026
09ad9cf
fix: small typo fix
Totto16 Apr 22, 2026
58efb8b
fix: some improvements
Totto16 Apr 23, 2026
b2824f1
chore: add another http test suite
Totto16 Apr 30, 2026
71aa9aa
fix: fix many strict errors
Totto16 May 10, 2026
3dd0987
fix: fix more strict errors
Totto16 May 10, 2026
1946bb4
fix: fix more strict errors
Totto16 May 10, 2026
7f9635b
fix: fix more strict errors
Totto16 May 10, 2026
9acef5c
feat: use trtti rtti library for some void* or generic argument repla…
Totto16 May 10, 2026
2ecdd5d
feat: use trtti rtti library for some void* or generic argument repla…
Totto16 May 12, 2026
9cc47c1
feat: use newer trtti library and adopt to it
Totto16 May 12, 2026
1046dbd
feat: replace many occurrences of void* with typedefs, if they are da…
Totto16 May 12, 2026
e40a285
feat: use trtti for FTPControlConnectionArgument and it's functions
Totto16 May 12, 2026
c1a1ce6
fix: make JobError an enum and use impl functions for passing in rtti…
Totto16 May 12, 2026
9e0bbf7
fix: more refactoring for rtti usage
Totto16 May 12, 2026
96cb00c
fix: fix some meson related stuff
Totto16 May 12, 2026
b287ad6
feat: use newer json library
Totto16 May 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Checks: >
-portability-avoid-pragma-once,
-readability-use-concise-preprocessor-directives,
-modernize-redundant-void-arg,
-readability-trailing-comma,
-readability-redundant-parentheses,
-cppcoreguidelines-avoid-magic-numbers,
custom-*,
Expand Down Expand Up @@ -241,7 +240,7 @@ CustomChecks:
Message: Function that uses this parameter
Level: Note
- Name: no-auto-usage-c
# matches any variable delcaration, which type is auto, canonical type means, it resolves tru typedefs and macros
# matches any variable declaration, which type is auto, canonical type means, it resolves tru typedefs and macros
Query: |
match varDecl(
hasType(
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ jobs:

meson compile -C build generated_sources

- name: Verify clang-tidy
run: |
clang-tidy-22 --experimental-custom-checks --verify-config

- uses: cpp-linter/cpp-linter-action@v2
id: linter
continue-on-error: true
Expand Down
45 changes: 41 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ project(

deps = []
compile_flags = [
'-DPROGRAM_NAME=' + meson.project_name(),
'-DVERSION_STRING=' + meson.project_version(),
'-D_SIMPLE_SERVER_PROGRAM_NAME=' + meson.project_name(),
'-D_SIMPLE_SERVER_VERSION_STRING=' + meson.project_version(),
]

deps += dependency('threads')
Expand All @@ -27,7 +27,7 @@ secure_option = get_option('secure')
openssl_dep = dependency(
'openssl',
required: secure_option,
version: '>=3.0',
version: ['>=3.0', '<4'],
)

if openssl_dep.found()
Expand Down Expand Up @@ -68,6 +68,7 @@ libbcrypt_dep = dependency(
'libbcrypt',
required: other_features_dict['bcrypt'],
allow_fallback: true,
version: ['>=1.0.0', '<2'],
)

if libbcrypt_dep.found()
Expand All @@ -79,13 +80,15 @@ pam_dep = dependency(
'pam',
required: other_features_dict['pam'],
allow_fallback: true,
version: ['>=1.0.0', '<2'],
)

if pam_dep.found()
pam_misc_dep = dependency(
'pam_misc',
required: other_features_dict['pam'],
allow_fallback: true,
version: ['>=1.0.0', '<2'],
)
if pam_misc_dep.found()
deps += [pam_dep, pam_misc_dep]
Expand Down Expand Up @@ -117,6 +120,7 @@ endforeach
zlib_dep = dependency(
'zlib',
required: compression_features_dict['gzip'] or compression_features_dict['deflate'],
version: ['>=1.0.0', '<2'],
)

if zlib_dep.found()
Expand All @@ -129,6 +133,7 @@ brotli_dep = dependency(
'brotli',
'libbrotlienc',
required: compression_features_dict['br'],
version: ['>=1.0.0', '<2'],
)

if brotli_dep.found()
Expand All @@ -139,6 +144,7 @@ endif
zstd_dep = dependency(
'libzstd',
required: compression_features_dict['zstd'],
version: ['>=1.0.0', '<2'],
)

if zstd_dep.found()
Expand All @@ -149,6 +155,7 @@ endif
lzws_dep = dependency(
'lzws',
required: compression_features_dict['compress'],
version: ['>=1.0.0', '<2'],
)

if lzws_dep.found()
Expand All @@ -163,21 +170,31 @@ deps += dependency(
default_options: {
'tests': 'disabled',
},
version: ['>=2.0.0', '<3'],
)

deps += dependency(
'cwalk',
allow_fallback: true,
version: ['>=1.0.0', '<2'],
)

deps += dependency(
'tvec.h',
allow_fallback: true,
version: ['>=1.0.0', '<2'],
)

deps += dependency(
'trtti',
allow_fallback: true,
version: ['>=1.0.0', '<2'],
)

deps += dependency(
'tmap.h',
allow_fallback: true,
version: ['>=1.0.0', '<2'],
)

deps += dependency(
Expand All @@ -186,8 +203,25 @@ deps += dependency(
default_options: {
'static_string_modification_behavior': 'error',
},
version: ['>=1.0.0', '<2'],
)

deps += dependency(
'tjson',
allow_fallback: true,
default_options: {
'tests': get_option('tests'),
},
version: ['>=1.0.0', '<2'],
)

deps += dependency(
'tstr_builder',
allow_fallback: true,
version: ['>=1.0.0', '<2'],
)


cc = meson.get_compiler('c')

deps += cc.find_library(
Expand Down Expand Up @@ -255,6 +289,10 @@ internal_c_args += cc.get_supported_arguments(
'-Wcast-qual',
'-Wwrite-strings',
'-Wdiscarded-qualifiers',
'-Wconversion',
'-Wsign-conversion',
'-Waddress',
'-Wfloat-equal',
)

if cc.get_id() == 'gcc'
Expand All @@ -278,7 +316,6 @@ endif
subdir('tools/helper')

deps += all_variants_dep
deps += json_variants_dep
deps += generated_hpack_huffman_dep
deps += generated_hpack_dep

Expand Down
28 changes: 20 additions & 8 deletions src/ftp/file_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#include "./file_ops.h"
#include "generic/send.h"
#include "utils/clock.h"
#include "utils/log.h"
#include "utils/path.h"
#include "utils/string_builder.h"
#include "utils/utils.h"

#include <cwalk.h>
#include <dirent.h>
Expand All @@ -13,6 +14,7 @@
#include <stdio.h>
#include <sys/stat.h>
#include <time.h>
#include <tstr_builder.h>
#include <unistd.h>

typedef struct {
Expand Down Expand Up @@ -371,9 +373,9 @@ NODISCARD static FilePermissions permissions_from_mode(mode_t mode) {

FilePermissions file_permissions = { .special_type = special_type, .permissions = {} };

int masks[3] = { S_IRWXU, S_IRWXG, S_IRWXO };
mode_t masks[3] = { S_IRWXU, S_IRWXG, S_IRWXO };
for(size_t i = 0; i < 3; ++i) {
int mask = masks[i];
mode_t mask = masks[i];
mode_t value =
(mode & mask) >> ((2 - i) * 3); // NOLINT(readability-implicit-bool-conversion)
file_permissions.permissions[i] = (OnePermission){ .read = (value & 0b100) != 0,
Expand All @@ -392,7 +394,7 @@ NODISCARD static FileWithMetadata* get_metadata_for_file_abs(const char* const a

// TODO(Totto). factor out into helper function or use cwalk
while(true) {
char* result = strstr(name_ptr, "/");
const char* result = strstr(name_ptr, "/");

if(result == NULL) {
break;
Expand Down Expand Up @@ -484,7 +486,16 @@ NODISCARD FileWithMetadata* get_metadata_for_file(

if(result != 0) {
LOG_MESSAGE(COMBINE_LOG_FLAGS(LogLevelError, LogPrintLocation),
"Couldn't stat folder '%s': %s\n", absolute_path, strerror(errno));
"Couldn't stat file '%s': %s\n", absolute_path, strerror(errno));

free(metadata);
return NULL;
}

if(stat_result.st_size < 0) {
LOG_MESSAGE(COMBINE_LOG_FLAGS(LogLevelError, LogPrintLocation),
"Couldn't stat file '%s': file size is negative: %ld\n", absolute_path,
stat_result.st_size);

free(metadata);
return NULL;
Expand All @@ -508,7 +519,7 @@ NODISCARD FileWithMetadata* get_metadata_for_file(
metadata->mode = stat_result.st_mode;
metadata->link_amount = stat_result.st_nlink;
metadata->owners = owners;
metadata->size = stat_result.st_size;
metadata->size = (size_t)stat_result.st_size;
#ifdef __APPLE__
metadata->last_mod = time_from_struct(stat_result.st_mtimespec);
#else
Expand Down Expand Up @@ -703,7 +714,7 @@ NODISCARD SendData* get_data_to_send_for_retr(const char* path) {

size_t file_size = 0;

void* file_data = read_entire_file(path, &file_size);
GenericData file_data = read_entire_file(path, &file_size);

if(file_data == NULL) {

Expand Down Expand Up @@ -936,7 +947,8 @@ NODISCARD bool send_data_to_send(const SendData* const data, ConnectionDescripto

size_t offset = progress->data.sent_count;

const void* const to_send = ((const uint8_t*)raw_data.data.data) + offset;
const GenericDataConst to_send =
(const GenericDataConst)(((const uint8_t* const)raw_data.data.data) + offset);

size_t send_length = SEND_CHUNK_SIZE;

Expand Down
6 changes: 4 additions & 2 deletions src/ftp/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ NODISCARD GenericResult send_ftp_message_to_connection_buffer(
GenericResult send_ftp_message_to_connection_sb(const ConnectionDescriptor* const descriptor,
FtpReturnCode status, StringBuilder* body) {

const SizedBuffer val = string_builder_release_into_sized_buffer(&body);
tstr val = string_builder_release_into_tstr(&body);

return send_ftp_message_to_connection_buffer(descriptor, status, val);
const SizedBuffer buf = sized_buffer_from_tstr(&val);

return send_ftp_message_to_connection_buffer(descriptor, status, buf);
}
3 changes: 2 additions & 1 deletion src/ftp/send.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

#include "./protocol.h"
#include "generic/secure.h"
#include "utils/string_builder.h"
#include "utils/utils.h"

#include <tstr_builder.h>

NODISCARD GenericResult send_ftp_message_to_connection_tstr(const ConnectionDescriptor* descriptor,
FtpReturnCode status, tstr body);

Expand Down
Loading
Loading