diff options
author | 2023-10-28 19:55:26 +0600 | |
---|---|---|
committer | 2023-10-28 19:55:26 +0600 | |
commit | eca864a05e92639b343baa1883bb90c0b0bdb5e5 (patch) | |
tree | cb021c2c3f505197e78f0ffc4bae9248b9068e46 | |
parent | 3b796b3be7fcdd8f6335474dae07c9a0ddd31f6c (diff) | |
download | c-obp-example-eca864a05e92639b343baa1883bb90c0b0bdb5e5.tar.gz c-obp-example-eca864a05e92639b343baa1883bb90c0b0bdb5e5.zip |
Add new helper header
Signed-off-by: Mubashshir <ahmubashshir@gmail.com>
-rw-r--r-- | src/common.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..b0f9e7f --- /dev/null +++ b/src/common.h @@ -0,0 +1,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__ */ |