File: errstr.c

package info (click to toggle)
tra 20020816-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 1,696 kB
  • ctags: 2,623
  • sloc: ansic: 22,519; makefile: 406; asm: 269
file content (36 lines) | stat: -rw-r--r-- 484 bytes parent folder | download
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
#include "os.h"

#define PLAN9ERRNO 123456878

static char xerrstr[ERRMAX];

void
errstr(char *s, uint n)
{
	char tmp[ERRMAX];

	utfecpy(tmp, tmp+ERRMAX, s);
	rerrstr(s, n);
	memmove(xerrstr, tmp, ERRMAX);
}

void
rerrstr(char *s, uint n)
{
	if(errno == PLAN9ERRNO)
		utfecpy(s, s+n, xerrstr);
	else
		utfecpy(s, s+n, strerror(errno));
}

void
werrstr(char *s, ...)
{
	va_list arg;

	va_start(arg, s);
	vseprint(xerrstr, xerrstr+ERRMAX, s, arg);
	va_end(arg);
	errno = PLAN9ERRNO;
}