Initial upload

This commit is contained in:
r4
2021-07-01 17:04:13 +02:00
parent 366bd4ad30
commit 574cf9219e
15 changed files with 958 additions and 0 deletions

23
error.h Normal file
View File

@@ -0,0 +1,23 @@
/* vim: set filetype=c: */
#ifndef _ERROR_H_
#define _ERROR_H_
#include <stdbool.h>
#include <stdio.h>
typedef struct Result Result;
struct Result {
bool has_err;
char* err_str;
};
extern Result Result_err(char* err_str);
extern Result Result_noerr();
/* err_prefix: string to print before the error, if on occurred; prints nothing if it has value NULL
* no_err: string to print if no error occured; prints nothing if it has value NULL
* err_file: where to output the string, if an error has occurred
* no_err_file: where to output, if no error has occurred */
extern void Result_print_err_or(const Result obj, const char* err_prefix, const char* no_err, FILE* err_file, FILE* no_err_file);
#endif /* _ERROR_H_ */