diff options
Diffstat (limited to 'libntp/modetoa.c')
| -rw-r--r-- | libntp/modetoa.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libntp/modetoa.c b/libntp/modetoa.c new file mode 100644 index 000000000000..6f13d20580bf --- /dev/null +++ b/libntp/modetoa.c @@ -0,0 +1,35 @@ +/* + * modetoa - return an asciized mode + */ +#include <config.h> +#include <stdio.h> + +#include "lib_strbuf.h" +#include "ntp_stdlib.h" + +const char * +modetoa( + size_t mode + ) +{ + char *bp; + static const char * const modestrings[] = { + "unspec", + "sym_active", + "sym_passive", + "client", + "server", + "broadcast", + "control", + "private", + "bclient", + }; + + if (mode >= COUNTOF(modestrings)) { + LIB_GETBUF(bp); + snprintf(bp, LIB_BUFLENGTH, "mode#%zu", mode); + return bp; + } + + return modestrings[mode]; +} |
