xref: /netbsd-src/external/bsd/ntp/dist/libntp/modetoa.c (revision 53b02e147d4ed531c0d2a5ca9b3e8026ba3e99b5)
1 /*	$NetBSD: modetoa.c,v 1.9 2020/05/25 20:47:24 christos Exp $	*/
2 
3 /*
4  * modetoa - return an asciized mode
5  */
6 #include <config.h>
7 #include <stdio.h>
8 
9 #include "lib_strbuf.h"
10 #include "ntp_stdlib.h"
11 
12 const char *
13 modetoa(
14 	size_t mode
15 	)
16 {
17 	char *bp;
18 	static const char * const modestrings[] = {
19 		"unspec",
20 		"sym_active",
21 		"sym_passive",
22 		"client",
23 		"server",
24 		"broadcast",
25 		"control",
26 		"private",
27 		"bclient",
28 	};
29 
30 	if (mode >= COUNTOF(modestrings)) {
31 		LIB_GETBUF(bp);
32 		snprintf(bp, LIB_BUFLENGTH, "mode#%zu", mode);
33 		return bp;
34 	}
35 
36 	return modestrings[mode];
37 }
38