Home | History | Annotate | Line # | Download | only in libntp
      1 /*	$NetBSD: modetoa.c,v 1.10 2024/08/18 20:47:13 christos Exp $	*/
      2 
      3 /*
      4  * modetoa - return an asciized mode
      5  */
      6 #include <config.h>
      7 #include <stdio.h>
      8 
      9 #include "ntp_stdlib.h"
     10 
     11 const char *
     12 modetoa(
     13 	size_t mode
     14 	)
     15 {
     16 	char *bp;
     17 	static const char * const modestrings[] = {
     18 		"unspec",
     19 		"sym_active",
     20 		"sym_passive",
     21 		"client",
     22 		"server",
     23 		"broadcast",
     24 		"control",
     25 		"private",
     26 		"bclient",
     27 	};
     28 
     29 	if (mode >= COUNTOF(modestrings)) {
     30 		LIB_GETBUF(bp);
     31 		snprintf(bp, LIB_BUFLENGTH, "mode#%zu", mode);
     32 		return bp;
     33 	}
     34 
     35 	return modestrings[mode];
     36 }
     37