summaryrefslogtreecommitdiffstats
path: root/tapset/svc_error.stp
blob: f3bace8be02d3d05f329c231432a38f698b50efc (plain)
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

function svcerror:string(err:long) 
%{
	static struct {
		int	svcerr;
		char *string;
	} svc_errtbl[] = {
		{1, "SVC_GARBAGE" },
		{2, "SVC_SYSERR" },
		{3, "SVC_VALID" },
		{4, "SVC_NEGATIVE" },
		{5, "SVC_OK" },
		{6, "SVC_DROP" },
		{7, "SVC_DENIED" },
		{8, "SVC_PENDING" },
		{9, "SVC_COMPLETE" },
	};
	int	i;
	int tabsz = (sizeof(svc_errtbl)/sizeof(svc_errtbl[0]));

	for (i = 0; i < tabsz; i++) {
		if (svc_errtbl[i].svcerr == THIS->err) {
			break;
		}
	}
	if (i == tabsz)
		snprintf(THIS->__retvalue, MAXSTRINGLEN, "svcerr %lld", THIS->err);
	else
		snprintf(THIS->__retvalue, MAXSTRINGLEN, 
			"svcderr %d(%s)", svc_errtbl[i].svcerr, svc_errtbl[i].string);

%}