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