Implement userctl user registering

This commit is contained in:
Your Name
2026-05-30 14:06:23 +02:00
parent 68bb993d1a
commit b5225812e6
3 changed files with 164 additions and 36 deletions

27
src/path.c Normal file
View File

@@ -0,0 +1,27 @@
#define build_path(url, first, ...) build_path_((url), (first), __VA_ARGS__, NULL)
static Noh_String build_path_(bool url, Noh_String_View *first, ...) {
va_list args;
Noh_String_View *elem_ = first;
va_start(args, first);
bool start = true;
Noh_String result = {0};
if (url) noh_string_append_cstr(&result, "/");
while (elem_ != NULL) {
Noh_String_View elem = *elem_;
while (elem.count > 0) {
Noh_String_View 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, Noh_String_View *);
}
va_end(args);
return result;
}