aboutsummaryrefslogtreecommitdiffstats
path: root/src/user.c
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2024-01-11 04:40:31 -0600
committerLibravatar bigfoot547 <[email protected]>2024-01-11 04:40:31 -0600
commit8fd75f88d2c9fc3be927c620cf57bd47bb8984ef (patch)
tree108d21d53487e769c34a8e130b00acbc3a6904aa /src/user.c
parentadd auth (diff)
add launch command
Diffstat (limited to 'src/user.c')
-rw-r--r--src/user.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/user.c b/src/user.c
index fd1acd5..eaaadf6 100644
--- a/src/user.c
+++ b/src/user.c
@@ -591,6 +591,32 @@ void l2_user_delete(struct l2_user *user)
}
}
+struct l2_user *l2_user_search(const char *searchstr)
+{
+ uuid_t uuid;
+ bool have_uuid = false;
+
+ if (l2_uuid_from_string(&uuid, searchstr) == 0) {
+ have_uuid = true;
+ } else {
+ if (l2_uuid_from_string_short(&uuid, searchstr) == 0) {
+ have_uuid = true;
+ }
+ }
+
+ for (struct l2_user *cur = l2_state.users_head; cur; cur = cur->next) {
+ if (have_uuid && !l2_uuid_compare(&cur->profile.uuid, &uuid)) {
+ return cur;
+ } else if (cur->nickname && !strcmp(searchstr, cur->nickname)) {
+ return cur;
+ } else if (!strcmp(searchstr, cur->profile.name)) {
+ return cur;
+ }
+ }
+
+ return NULL;
+}
+
void l2_user_init(struct l2_user *user)
{
/* using calloc works as well, so that's what we do in this file (elsewhere should use this function though) */