#define UTIL_H
#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#define min(x, y) ((x)<(y)?(x):(y))
void die(const char *msg, ...);
void pdie(const char *msg);
+/* if buf == NULL, a fresh buffer is allocated */
+char *escape_char(char c, char *buf, bool str);
+/* unescaped character will be in position 0 and the rest from position 1 on */
+char *unescape_char(char *c);
+/* Remove the last and first character from the string */
+char *trimquotes(char *c);
void pindent(int indent, FILE *out);
+
void safe_fprintf(FILE *out, const char *msg, ...);
void *safe_malloc(size_t size);
void *safe_strdup(const char *c);
+FILE *safe_fopen(const char *path, const char *mode);
+void safe_fclose(FILE *file);
#endif