aboutsummaryrefslogtreecommitdiff
path: root/config.h
blob: 6f8a240a5390c8257572f4ea4c134716e3746597 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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];
};