/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

  1. /*
  2. * modetoa - return an asciized mode
  3. */
  4. #include <stdio.h>
  5. #include "lib_strbuf.h"
  6. #include "ntp_stdlib.h"
  7. const char *
  8. modetoa(
  9. int mode
  10. )
  11. {
  12. char *bp;
  13. static const char *modestrings[] = {
  14. "unspec",
  15. "sym_active",
  16. "sym_passive",
  17. "client",
  18. "server",
  19. "broadcast",
  20. "control",
  21. "private",
  22. "bclient",
  23. };
  24. if (mode < 0 || mode >= (sizeof modestrings)/sizeof(char *)) {
  25. LIB_GETBUF(bp);
  26. (void)sprintf(bp, "mode#%d", mode);
  27. return bp;
  28. }
  29. return modestrings[mode];
  30. }