-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathfail.c
More file actions
40 lines (35 loc) · 713 Bytes
/
Copy pathfail.c
File metadata and controls
40 lines (35 loc) · 713 Bytes
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
#include <sys/file.h>
#include <errtag.h>
#include <format.h>
#include <util.h>
#define ERRBUF 512
void warn(const char* msg, const char* obj, int ret)
{
char buf[ERRBUF];
char* end = buf + sizeof(buf) - 1;
char* b = buf;
char* p = buf;
if(errtag[0]) {
p = fmtstr(p, end, errtag);
p = fmtstr(p, end, ":");
}
if(msg) {
p = fmtstr(p, end, " ");
p = fmtstr(p, end, msg);
} if(obj) {
p = fmtstr(p, end, " ");
p = fmtstr(p, end, obj);
} if(ret && (msg || obj)) {
p = fmtstr(p, end, ":");
} if(ret) {
p = fmtstr(p, end, " ");
p = fmterr(p, end, ret);
}
*p++ = '\n';
sys_write(2, b, p - b);
}
void fail(const char* msg, const char* obj, int ret)
{
warn(msg, obj, ret);
_exit(-1);
}