Implement userctl user registering

This commit is contained in:
2026-06-17 17:34:07 +02:00
parent 68bb993d1a
commit 998c0bd994
3 changed files with 164 additions and 36 deletions

View File

@@ -1,3 +1,5 @@
#include "path.c"
typedef struct {
bool is_dir;
SV name;
@@ -41,34 +43,6 @@ static void set_modified_time(Library_Entry *entry) {
}
}
#define build_path(url, first, ...) build_path_((url), (first), __VA_ARGS__, NULL)
static Noh_String build_path_(bool url, SV *first, ...) {
va_list args;
SV *elem_ = first;
va_start(args, first);
bool start = true;
Noh_String result = {0};
if (url) noh_string_append_cstr(&result, "/");
while (elem_ != NULL) {
SV elem = *elem_;
while (elem.count > 0) {
SV component = noh_sv_chop_by_delim(&elem, '/');
if (noh_sv_eq(component, sv(".."))) continue;
if (component.count > 0) {
if (start) start = false; else noh_string_append_cstr(&result, "/");
noh_string_append_sv(&result, component);
}
}
elem_ = va_arg(args, SV *);
}
va_end(args);
return result;
}
/**
* Creates a Library entry from a dirent structure.
*/