xref: /netbsd-src/external/bsd/ntp/dist/libntp/modetoa.c (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1 /*	$NetBSD: modetoa.c,v 1.1.1.1 2009/12/13 16:55:03 kardel Exp $	*/
2 
3 /*
4  * modetoa - return an asciized mode
5  */
6 #include <stdio.h>
7 
8 #include "lib_strbuf.h"
9 #include "ntp_stdlib.h"
10 
11 const char *
12 modetoa(
13 	int mode
14 	)
15 {
16 	char *bp;
17 	static const char *modestrings[] = {
18 		"unspec",
19 		"sym_active",
20 		"sym_passive",
21 		"client",
22 		"server",
23 		"broadcast",
24 		"control",
25 		"private",
26 		"bclient",
27 	};
28 
29 	if (mode < 0 || mode >= (sizeof modestrings)/sizeof(char *)) {
30 		LIB_GETBUF(bp);
31 		(void)sprintf(bp, "mode#%d", mode);
32 		return bp;
33 	}
34 
35 	return modestrings[mode];
36 }
37