forked from jonas/tig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.c
61 lines (51 loc) · 1.31 KB
/
util.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Copyright (c) 2006-2013 Jonas Fonseca <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "tig.h"
#include "util.h"
static const char *status_messages[] = {
"Success",
#define STATUS_CODE_MESSAGE(name, msg) msg
STATUS_CODE_INFO(STATUS_CODE_MESSAGE)
};
const char *
get_status_message(enum status_code code)
{
if (code == SUCCESS)
return "";
return status_messages[code];
}
void
warn(const char *msg, ...)
{
va_list args;
va_start(args, msg);
fputs("tig warning: ", stderr);
vfprintf(stderr, msg, args);
fputs("\n", stderr);
va_end(args);
}
die_fn die_callback = NULL;
void TIG_NORETURN
die(const char *err, ...)
{
va_list args;
if (die_callback)
die_callback();
va_start(args, err);
fputs("tig: ", stderr);
vfprintf(stderr, err, args);
fputs("\n", stderr);
va_end(args);
exit(1);
}
/* vim: set ts=8 sw=8 noexpandtab: */