xref: /freebsd/contrib/ntp/libntp/modetoa.c (revision 56b17de1e8360fe131d425de20b5e75ff3ea897c)
1 /*
2  * modetoa - return an asciized mode
3  */
4 #include <config.h>
5 #include <stdio.h>
6 
7 #include "ntp_stdlib.h"
8 
9 const char *
10 modetoa(
11 	size_t mode
12 	)
13 {
14 	char *bp;
15 	static const char * const modestrings[] = {
16 		"unspec",
17 		"sym_active",
18 		"sym_passive",
19 		"client",
20 		"server",
21 		"broadcast",
22 		"control",
23 		"private",
24 		"bclient",
25 	};
26 
27 	if (mode >= COUNTOF(modestrings)) {
28 		LIB_GETBUF(bp);
29 		snprintf(bp, LIB_BUFLENGTH, "mode#%zu", mode);
30 		return bp;
31 	}
32 
33 	return modestrings[mode];
34 }
35