ms-runner/starter/util.h
2024-06-20 21:41:25 +05:00

23 lines
546 B
C

//#ifndef ISOLATE_UTIL_H
//#define ISOLATE_UTIL_H
static void die(const char *fmt, ...)
{
va_list params;
va_start(params, fmt);
vfprintf(stderr, fmt, params);
va_end(params);
exit(1);
}
static void write_file(char* path, char* line)
{
FILE *f = fopen(path, "w");
if (f == NULL) {die("Failed to open file %s: %m\n", path);}
if (fwrite(line, 1, strlen(line), f) < 0) {die("Failed to write to file %s:\n", path);}
if (fclose(f) != 0) {die("Failed to close file %s: %m\n", path);}
}
//#endif //ISOLATE_UTIL_H