aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
blob: b4053fd7a4476bb0929bb2c875cafc5c2eeaf697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>

#include "util.h"
#include "constant.h"

void panic(const char *msg)
{
    perror(msg);
    exit(EXIT_FAILURE);
}

int setblocking(int fd, bool blocking)
{
    u_long mode = blocking ? 0 : 1;
    if (ioctl(fd, FIONBIO, &mode) == -1)
        return ERROR;

    return OK;
}