summaryrefslogtreecommitdiff
path: root/src/utils.h
blob: e9ab44dc10677b415c09c5ea68663bb709947e62 (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

#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include <arpa/inet.h>

#ifndef __UTILS_H
#define __UTILS_H

#define match(a, b) (!strcmp(a, b))
#define matchn(a, b, n) (!strncmp(a, b, n))

int host_to_inet(const char *host, struct in_addr *in);
int systemf(const char *fmt, ...);
ssize_t safe_read(int fd, void *buf, size_t count);
ssize_t safe_readn(int fd, void *buf, size_t len);
ssize_t safe_write(int fd, const void *buf, size_t count);
ssize_t full_write(int fd, const void *buf, size_t len);
int set_nonblocking(int fd);
int inet_conn_str(const char *host, int port, int type);
int inet_conn_ia(struct in_addr *host, int port, int type);

#endif /* ~__UTILS_H */