xref: /inferno-os/emu/port/errstr.c (revision 7ef44d652ae9e5e1f5b3465d73684e4a54de73c0)
1 #include	"dat.h"
2 #include	"fns.h"
3 
4 /*
5  * General OS interface to errors
6  */
7 void
8 kwerrstr(char *fmt, ...)
9 {
10 	va_list arg;
11 	char buf[ERRMAX];
12 
13 	va_start(arg, fmt);
14 	vseprint(buf, buf+sizeof(buf), fmt, arg);
15 	va_end(arg);
16 	kstrcpy(up->env->errstr, buf, ERRMAX);
17 }
18 
19 void
20 kerrstr(char *err, uint size)
21 {
22 	char tmp[ERRMAX];
23 
24 	kstrcpy(tmp, up->env->errstr, sizeof(tmp));
25 	kstrcpy(up->env->errstr, err, ERRMAX);
26 	kstrcpy(err, tmp, size);
27 }
28 
29 void
30 kgerrstr(char *err, uint size)
31 {
32 	char *s;
33 
34 	s = "<no-up>";
35 	if(up != nil)
36 		s = up->env->errstr;
37 	kstrcpy(err, s, size);	/* TO DO */
38 }
39