strerror.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * libcompat - system compatibility library
  3. *
  4. * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  5. *
  6. * This is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2,
  9. * or (at your option) any later version.
  10. *
  11. * This is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public
  17. * License along with dpkg; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <config.h>
  21. #include <stdio.h>
  22. #include <gettext.h>
  23. #define _(str) gettext(str)
  24. #ifndef HAVE_STRERROR
  25. extern const char *const sys_errlist[];
  26. extern const int sys_nerr;
  27. const char *
  28. strerror(int e)
  29. {
  30. static char buf[100];
  31. if (e >= 0 && e < sys_nerr)
  32. return sys_errlist[e];
  33. sprintf(buf, _("Unknown error %d"), e);
  34. return buf;
  35. }
  36. #endif