mirror of
https://github.com/depp/syncfiles.git
synced 2026-04-24 10:16:28 +00:00
Reorganize
- Extracted functions to //lib:test for writing tests - Extracted functions to lib/util.h if they are useful outside tests
This commit is contained in:
+26
@@ -0,0 +1,26 @@
|
||||
#include "lib/util.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void Fatalf(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
fputs("Error: ", stderr);
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr, msg, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static const char *const kErrorNames[] = {"ok", "no memory", "bad data"};
|
||||
|
||||
const char *ErrorDescription(ErrorCode err)
|
||||
{
|
||||
if (err < 0 || (int)(sizeof(kErrorNames) / sizeof(*kErrorNames)) <= err) {
|
||||
return NULL;
|
||||
}
|
||||
return kErrorNames[err];
|
||||
}
|
||||
Reference in New Issue
Block a user