Line | Count | Source (jump to first uncovered line) |
1 | /* | |
2 | * modetoa - return an asciized mode | |
3 | */ | |
4 | #include <config.h> | |
5 | #include <stdio.h> | |
6 | ||
7 | #include "lib_strbuf.h" | |
8 | #include "ntp_stdlib.h" | |
9 | ||
10 | const char * | |
11 | modetoa( | |
12 | size_t mode | |
13 | ) | |
14 | 249 | { |
15 | 249 | char *bp; |
16 | 249 | static const char * const modestrings[] = { |
17 | 249 | "unspec", |
18 | 249 | "sym_active", |
19 | 249 | "sym_passive", |
20 | 249 | "client", |
21 | 249 | "server", |
22 | 249 | "broadcast", |
23 | 249 | "control", |
24 | 249 | "private", |
25 | 249 | "bclient", |
26 | 249 | }; |
27 | ||
28 | 249 | if (mode >= COUNTOF(modestrings)) { |
29 | 0 | LIB_GETBUF(bp); |
30 | 0 | snprintf(bp, LIB_BUFLENGTH, "mode#%zu", mode); |
31 | 0 | return bp; |
32 | 0 | } |
33 | ||
34 | 249 | return modestrings[mode]; |
35 | 249 | } |