diff options
| author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-16 02:18:30 +0200 | 
|---|---|---|
| committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-10-17 12:36:14 +0200 | 
| commit | 261b81eeaada702eb254e502462ac3a4d1249ec0 (patch) | |
| tree | 9800e91c5182c9273e990929a1f6c8684293db8e /config.h | |
Initial commit
Diffstat (limited to 'config.h')
| -rw-r--r-- | config.h | 34 | 
1 files changed, 34 insertions, 0 deletions
| diff --git a/config.h b/config.h new file mode 100644 index 0000000..6f8a240 --- /dev/null +++ b/config.h @@ -0,0 +1,34 @@ +#include <stdarg.h> +#include <stdio.h> +#include <unistd.h> + +#define PORT 9983 +// max size for a message sent +#define BUF_MAX 255 +// max length of messages +#define MSG_MAX 256 +// current user's name +#define USERNAME "unrtdqttr" + +// wrapper for write +void writef(char *format, ...) +{ +    va_list args; +    char buf[BUF_MAX +1]; +    va_start(args, format); + +    vsnprintf(buf, sizeof(buf), format, args); +    va_end(args); + +    int n = 0; +    while (*(buf + n) != 0) +        n++; +    write(0, buf, n); +} + +struct message { +    char buf[MSG_MAX]; +    int buf_len; +    char timestamp[9]; // HH:MM:SS +    char author[12]; +}; | 
