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:
parent
bb02e6d20a
commit
39ccae145a
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
18
qbsp/util.c
18
qbsp/util.c
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue