include/: refactor header files

This commit is contained in:
Johan Malm 2020-07-31 21:31:03 +01:00
parent 82dc192217
commit 53266a0d5a
8 changed files with 27 additions and 14 deletions

23
include/common/buf.h Normal file
View file

@ -0,0 +1,23 @@
/*
* Very simple C buffer implementation
*
* Copyright Johan Malm 2020
*/
#ifndef BUF_H
#define BUF_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct buf {
char *buf;
int alloc;
int len;
};
void buf_init(struct buf *s);
void buf_add(struct buf *s, const char *data);
#endif /* BUF_H */

13
include/common/bug-on.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef __LABWC_BUG_ON_H
#define __LABWC_BUG_ON_H
#define BUG_ON(condition) \
do { \
if ((condition) != 0) { \
fprintf(stderr, "Badness in %s() at %s:%d\n", \
__func__, __FILE__, __LINE__); \
} \
} while (0)
#endif /* __LABWC_BUT_ON_H */