qbsp: create an Error() function similar to the other tools

Call it Error_() for now while I work on transitioning away from the
arrays of global strings hidden away by error enums.

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-04-22 11:40:17 +09:30
parent bb02e6d20a
commit 39ccae145a
2 changed files with 20 additions and 0 deletions

View File

@ -683,6 +683,8 @@ extern void PrintMem(void);
extern void Message(int MsgType, ...);
extern void Error(int ErrType, ...) __attribute__((noreturn));
extern void Error_(const char *error, ...)
__attribute__((format(printf,1,2),noreturn));
extern FILE *logfile;

View File

@ -227,6 +227,24 @@ Error(int ErrType, ...)
exit(1);
}
void
Error_(const char *error, ...)
{
va_list argptr;
char message[512];
va_start(argptr, error);
vsnprintf(message, sizeof(message), error, argptr);
va_end(argptr);
fprintf(stderr, "\nERROR: %s\n\n", message);
if (logfile) {
fprintf(logfile, "\nERROR: %s\n\n", message);
fclose(logfile);
}
exit(1);
}
/*
=================
Message