summaryrefslogtreecommitdiff
path: root/src/common.h
blob: b0f9e7ff7c101668355f9961e0d68133170a8142 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef __COMMON_H__
#define __COMMON_H__

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define getline(x, y, z) \
	while(((x)[strcspn((x), "\r\n")] = 0) == 0 && strncmp((x), "", (y)) == 0) \
		fgets((x), (y), (z))

#define consume(ptr, size, consumer, ...) \
	(consumer)((ptr), ## __VA_ARGS__); \
	strncpy((ptr), "", (size))

#define array(type, size) ((type *) calloc (sizeof(type), (size)))
#define ref(x) x * const
#define mut(x) x *

#endif /* __COMMON_H__ */