1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#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 ((size), sizeof(type)))
#define ref(x) const x * const
#define mut(x) const x *
#define ptr(x) x *
#define dref(x) *x
#endif /* __COMMON_H__ */
|