freebsd-dev/contrib/ntp/libntp/modetoa.c

36 lines
507 B
C
Raw Normal View History

1999-12-09 13:01:21 +00:00
/*
* modetoa - return an asciized mode
*/
#include <config.h>
1999-12-09 13:01:21 +00:00
#include <stdio.h>
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
const char *
modetoa(
size_t mode
1999-12-09 13:01:21 +00:00
)
{
char *bp;
static const char * const modestrings[] = {
1999-12-09 13:01:21 +00:00
"unspec",
"sym_active",
"sym_passive",
"client",
"server",
"broadcast",
"control",
"private",
"bclient",
};
if (mode >= COUNTOF(modestrings)) {
1999-12-09 13:01:21 +00:00
LIB_GETBUF(bp);
snprintf(bp, LIB_BUFLENGTH, "mode#%zu", mode);
1999-12-09 13:01:21 +00:00
return bp;
}
return modestrings[mode];
}