/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
- /*
- * modetoa - return an asciized mode
- */
- #include <stdio.h>
- #include "lib_strbuf.h"
- #include "ntp_stdlib.h"
- const char *
- modetoa(
- int mode
- )
- {
- char *bp;
- static const char *modestrings[] = {
- "unspec",
- "sym_active",
- "sym_passive",
- "client",
- "server",
- "broadcast",
- "control",
- "private",
- "bclient",
- };
- if (mode < 0 || mode >= (sizeof modestrings)/sizeof(char *)) {
- LIB_GETBUF(bp);
- (void)sprintf(bp, "mode#%d", mode);
- return bp;
- }
- return modestrings[mode];
- }