PageRenderTime 30ms CodeModel.GetById 20ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/contrib/ntp/libntp/modetoa.c

https://bitbucket.org/freebsd/freebsd-head/
C | 34 lines | 27 code | 4 blank | 3 comment | 2 complexity | 2ca75d9470e10990367420ad2a37a39f MD5 | raw file
 1/*
 2 * modetoa - return an asciized mode
 3 */
 4#include <stdio.h>
 5
 6#include "lib_strbuf.h"
 7#include "ntp_stdlib.h"
 8
 9const char *
10modetoa(
11	int mode
12	)
13{
14	char *bp;
15	static const char *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 < 0 || mode >= (sizeof modestrings)/sizeof(char *)) {
28		LIB_GETBUF(bp);
29		(void)sprintf(bp, "mode#%d", mode);
30		return bp;
31	}
32
33	return modestrings[mode];
34}