diff options
| author | gingerBill <bill@gingerbill.org> | 2022-06-02 13:02:16 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-06-02 13:02:16 +0100 |
| commit | fb49841b1d8e84cb721f5f73200d4c8158cbb4fa (patch) | |
| tree | a89451b5b3195b6e8160a39fc34e3a846cdcded8 /core/sys/windows/util.odin | |
| parent | 01ea0d6f1e0b32c248d5ddfc0980a350361f9414 (diff) | |
Remove `strings` dependency from `core:sys/windows`
Diffstat (limited to 'core/sys/windows/util.odin')
| -rw-r--r-- | core/sys/windows/util.odin | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/core/sys/windows/util.odin b/core/sys/windows/util.odin index 1c8b9175b..c350032f0 100644 --- a/core/sys/windows/util.odin +++ b/core/sys/windows/util.odin @@ -1,7 +1,6 @@ // +build windows package sys_windows -import "core:strings" import "core:runtime" import "core:intrinsics" @@ -100,6 +99,20 @@ utf16_to_utf8 :: proc(s: []u16, allocator := context.temp_allocator) -> (res: st // AdvAPI32, NetAPI32 and UserENV helpers. allowed_username :: proc(username: string) -> bool { + contains_any :: proc(s, chars: string) -> bool { + if chars == "" { + return false + } + for c in transmute([]byte)s { + for b in transmute([]byte)chars { + if c == b { + return true + } + } + } + return false + } + /* User account names are limited to 20 characters and group names are limited to 256 characters. In addition, account names cannot be terminated by a period and they cannot include commas or any of the following printable characters: @@ -120,7 +133,7 @@ allowed_username :: proc(username: string) -> bool { return false } } - if strings.contains_any(username, _DISALLOWED) { + if contains_any(username, _DISALLOWED) { return false } |