-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathsvhub_warn.c
More file actions
50 lines (36 loc) · 921 Bytes
/
svhub_warn.c
File metadata and controls
50 lines (36 loc) · 921 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
41
42
43
44
45
46
47
48
49
50
#include <format.h>
#include <util.h>
#include "svhub.h"
/* Error reporting. PID 1 cannot use fail() so no point in bringing
that here. Also at some point reprec should probably start sending
messages to syslog if it's available. */
static const char tag[] = "svhub";
static char warnbuf[200];
void report(char* msg, char* arg, int err)
{
char* p = warnbuf;
char* e = warnbuf + sizeof(warnbuf) - 1;
p = fmtstr(p, e, tag);
p = fmtstr(p, e, ": ");
p = fmtstr(p, e, msg);
if(arg) {
p = fmtstr(p, e, " ");
p = fmtstr(p, e, arg);
};
if(err) {
p = fmtstr(p, e, ": ");
p = fmtint(p, e, err);
};
*p++ = '\n';
writeall(STDERR, warnbuf, p - warnbuf);
}
void reprec(struct proc* rc, char* msg)
{
char* p = warnbuf;
char* e = warnbuf + sizeof(warnbuf) - 1;
p = fmtstr(p, e, rc->name);
p = fmtstr(p, e, ": ");
p = fmtstr(p, e, msg);
*p++ = '\n';
writeall(STDERR, warnbuf, p - warnbuf);
}