aboutsummaryrefslogtreecommitdiff
path: root/contrib/ntp/libntp/modetoa.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/libntp/modetoa.c')
-rw-r--r--contrib/ntp/libntp/modetoa.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/contrib/ntp/libntp/modetoa.c b/contrib/ntp/libntp/modetoa.c
new file mode 100644
index 000000000000..de14c9edd34c
--- /dev/null
+++ b/contrib/ntp/libntp/modetoa.c
@@ -0,0 +1,34 @@
+/*
+ * modetoa - return an asciized mode
+ */
+#include <config.h>
+#include <stdio.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];
+}