init
This commit is contained in:
1 parent
8e41b63cc1
commit
32b02a1691
6 files changed
+77
No files matched your search
@@ -0,0 +1,39 @@
|
||||
#ifndef UTIL_H_
|
||||
#define UTIL_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_BUFFER_SIZE 128
|
||||
|
||||
/*
|
||||
* Aliases for concise data types
|
||||
*/
|
||||
|
||||
typedef void u1;
|
||||
typedef char i8;
|
||||
typedef unsigned int u16;
|
||||
typedef int i16;
|
||||
typedef unsigned long u32;
|
||||
typedef long i32;
|
||||
typedef unsigned long long u64;
|
||||
typedef long long i64;
|
||||
|
||||
inline u1
|
||||
die(i8 msg, i16 exitcode)
|
||||
{
|
||||
i8 buffer[128];
|
||||
i8 *s = msg;
|
||||
|
||||
if (sizeof(s) > MAX_BUFFER_SIZE) {
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(buffer, MAX_BUFFER_SIZE, "%s\n\0, s);
|
||||
|
||||
fprintf(stderr, "%s\n", buffer);
|
||||
exit(exitcode);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user