/contrib/ntp/libntp/strerror.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 48 lines · 25 code · 7 blank · 16 comment · 2 complexity · 21f5e9dacaf755fef6d40c231b50ebb8 MD5 · raw file

  1. #include <config.h>
  2. #if !HAVE_STRERROR
  3. /*
  4. * Copyright (c) 1988 Regents of the University of California.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms are permitted
  8. * provided that the above copyright notice and this paragraph are
  9. * duplicated in all such forms and that any documentation,
  10. * advertising materials, and other materials related to such
  11. * distribution and use acknowledge that the software was developed
  12. * by the University of California, Berkeley. The name of the
  13. * University may not be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  17. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18. */
  19. #if defined(LIBC_SCCS) && !defined(lint)
  20. static const char sccsid[] = "@(#)strerror.c 5.1 (Berkeley) 4/9/89";
  21. #endif /* LIBC_SCCS and not lint */
  22. #include <sys/types.h>
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include "l_stdlib.h"
  26. char *
  27. strerror(
  28. int errnum
  29. )
  30. {
  31. extern int sys_nerr;
  32. extern char *sys_errlist[];
  33. static char ebuf[20];
  34. if ((unsigned int)errnum < sys_nerr)
  35. return(sys_errlist[errnum]);
  36. (void)sprintf(ebuf, "Unknown error: %d", errnum);
  37. return(ebuf);
  38. }
  39. #else
  40. int strerror_bs;
  41. #endif