diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-26 13:19:17 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-26 13:19:17 +0200 |
commit | cafda3e8a60043629cd9a51490496b8cfd3cd921 (patch) | |
tree | 09389746ea5a0ff37e772abbf7275da306456606 /v2/common.h | |
parent | 90c30017e035810321083b3beb772ca37a1dede8 (diff) |
Put v2 code in root folder
Diffstat (limited to 'v2/common.h')
-rw-r--r-- | v2/common.h | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/v2/common.h b/v2/common.h deleted file mode 100644 index 60d8984..0000000 --- a/v2/common.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef COMMON_H -#define COMMON_H - -#include <stdarg.h> -#include <stdio.h> -#include <time.h> -#include <unistd.h> -#include <stdint.h> -#include <stddef.h> -#include <wchar.h> - -#define AUTHOR_LEN 13 -#define TIMESTAMP_LEN 9 -// port to listen on -#define PORT 9983 -// buffer size for holding data received from recv() -// TODO: choose a good size -#define STREAM_BUF 1024 -// max data received in one recv() call on serverfd -// TODO: choose a good size -#define STREAM_LIMIT 1024 - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef int64_t s64; - -struct Message { - u8 author[AUTHOR_LEN]; - u8 timestamp[TIMESTAMP_LEN]; - // includes null terminator - u16 text_len; - wchar_t *text; -} typedef Message; - -#define MESSAGELEN(m) (AUTHOR_LEN + TIMESTAMP_LEN + sizeof(m.text_len)*sizeof(wchar_t) + m.text_len) -#define MESSAGELENP(m) (AUTHOR_LEN + TIMESTAMP_LEN + sizeof(m->text_len) + m->text_len*(sizeof(wchar_t))) - -void message_timestamp(u8 str[TIMESTAMP_LEN]) -{ - time_t now; - struct tm *ltime; - time(&now); - ltime = localtime(&now); - strftime((char *)str, TIMESTAMP_LEN, "%H:%M:%S", ltime); -} - -#endif |