aboutsummaryrefslogtreecommitdiffstats
path: root/src/user.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/user.h')
-rw-r--r--src/user.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/user.h b/src/user.h
new file mode 100644
index 0000000..f84e3e1
--- /dev/null
+++ b/src/user.h
@@ -0,0 +1,63 @@
+#ifndef L2SU_USER_H_INCLUDED
+#define L2SU_USER_H_INCLUDED
+
+#include "uuid/uuid.h"
+#include "macros.h"
+
+#include <time.h>
+
+#define L2_PROFILE_NAME_STRLEN (16)
+
+typedef void *l2_user_profile_properties_iter_t;
+
+struct l2_user_profile_property {
+ char *name;
+ char *value;
+ char *signature;
+};
+
+struct l2_user_profile {
+ uuid_t uuid;
+ char name[L2_PROFILE_NAME_STRLEN + 1];
+
+ size_t nproperties;
+ struct l2_user_profile_property *properties;
+};
+
+typedef struct l2_user_session_tag l2_user_session_t;
+
+struct l2_user {
+ struct l2_user_profile profile;
+ l2_user_session_t *session; /* NULL for offline users */
+
+ char *nickname;
+
+ struct l2_user *next, *prev;
+};
+
+int l2_user_load(void);
+int l2_user_save(void);
+
+void l2_user_init(struct l2_user *user);
+void l2_user_free(struct l2_user *user);
+struct l2_user *l2_user_clone(const struct l2_user *user);
+
+void l2_user_add(struct l2_user *user);
+
+/* does NOT free the user */
+void l2_user_delete(struct l2_user *user);
+
+l2_user_session_t *l2_user_session_new(void);
+
+/* returns 1 if refresh succeeded, 0 if the session needs login, or -1 if there was an error */
+int l2_user_session_refresh(l2_user_session_t *session);
+
+/* interactively login (probably not a good general interface but whatever) */
+int l2_user_session_login(l2_user_session_t *session);
+
+int l2_user_update_profile(struct l2_user *user);
+
+int l2_user_session_fill_subst(l2_user_session_t *session, void *subst);
+char *l2_user_properties_serialize(const struct l2_user_profile *profile, bool legacy);
+
+#endif /* include guard */