From f3c66ce449c67869a2fa6a949e6695789aaa8598 Mon Sep 17 00:00:00 2001 From: Lorenzo Torres Date: Thu, 8 Jan 2026 19:18:33 +0100 Subject: [PATCH] removed ERR_OK --- .gitignore | 1 + PROTOCOL | 25 ++++++++++++------------- network.h | 27 +++++++++++++-------------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 7a43dd2..5636db9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/*.o +**/*.db **/*.swp **/*.pem asfur diff --git a/PROTOCOL b/PROTOCOL index 1843fc0..c3ec4e0 100644 --- a/PROTOCOL +++ b/PROTOCOL @@ -41,19 +41,18 @@ PACKET_ERROR (0) [u8 code] Error codes: - 0 = ERR_OK (no error) - 1 = ERR_UNKNOWN (unknown error) - 2 = ERR_INVALID_PACKET (malformed packet) - 3 = ERR_NOT_AUTHENTICATED (action requires authentication) - 4 = ERR_ALREADY_REGISTERED (username already taken) - 5 = ERR_INVALID_CREDENTIALS (wrong username/password) - 6 = ERR_REGISTRATION_DISABLED (server disabled registration) - 7 = ERR_DATABASE (internal database error) - 8 = ERR_USER_NOT_FOUND (target user does not exist) - 9 = ERR_ACCESS_DENIED (not allowed to access resource) - 10 = ERR_ROOM_NOT_FOUND (room does not exist) - 11 = ERR_ROOM_NAME_TAKEN (room name already in use) - 12 = ERR_NOT_ROOM_OWNER (action requires room ownership) + 0 = ERR_UNKNOWN (unknown error) + 1 = ERR_INVALID_PACKET (malformed packet) + 2 = ERR_NOT_AUTHENTICATED (action requires authentication) + 3 = ERR_ALREADY_REGISTERED (username already taken) + 4 = ERR_INVALID_CREDENTIALS (wrong username/password) + 5 = ERR_REGISTRATION_DISABLED (server disabled registration) + 6 = ERR_DATABASE (internal database error) + 7 = ERR_USER_NOT_FOUND (target user does not exist) + 8 = ERR_ACCESS_DENIED (not allowed to access resource) + 9 = ERR_ROOM_NOT_FOUND (room does not exist) + 10 = ERR_ROOM_NAME_TAKEN (room name already in use) + 11 = ERR_NOT_ROOM_OWNER (action requires room ownership) PACKET_REGISTER (1) Register a new user account. diff --git a/network.h b/network.h index eae8bd7..a12a936 100644 --- a/network.h +++ b/network.h @@ -23,25 +23,24 @@ typedef enum { } packet_type; typedef enum { - ERR_OK = 0, - ERR_UNKNOWN = 1, - ERR_INVALID_PACKET = 2, - ERR_NOT_AUTHENTICATED = 3, - ERR_ALREADY_REGISTERED = 4, - ERR_INVALID_CREDENTIALS = 5, - ERR_REGISTRATION_DISABLED = 6, - ERR_DATABASE = 7, - ERR_USER_NOT_FOUND = 8, - ERR_ACCESS_DENIED = 9, - ERR_ROOM_NOT_FOUND = 10, - ERR_ROOM_NAME_TAKEN = 11, - ERR_NOT_ROOM_OWNER = 12 + ERR_UNKNOWN = 0, + ERR_INVALID_PACKET = 1, + ERR_NOT_AUTHENTICATED = 2, + ERR_ALREADY_REGISTERED = 3, + ERR_INVALID_CREDENTIALS = 4, + ERR_REGISTRATION_DISABLED = 5, + ERR_DATABASE = 5, + ERR_USER_NOT_FOUND = 7, + ERR_ACCESS_DENIED = 8, + ERR_ROOM_NOT_FOUND = 9, + ERR_ROOM_NAME_TAKEN = 10, + ERR_NOT_ROOM_OWNER = 11 } error_code; struct packet_header { uint16_t size; uint8_t type; -}; +} __attribute__((packed)); struct packet_register { char username[20];