Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.2 KiB

4 years ago
  1. /***
  2. *perror.c - print system error message
  3. *
  4. * Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines perror() - print system error message
  8. * System error message are indexed by errno; conforms to XENIX
  9. * standard, with much compatability with 1983 uniforum draft standard.
  10. *
  11. *Revision History:
  12. * 09-02-83 RN initial version
  13. * 04-13-87 JCR added const to declaration
  14. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  15. * 12-29-87 JCR Multi-thread support
  16. * 05-31-88 PHG Merged DLL and normal versions
  17. * 06-03-88 JCR Added <io.h> to so _write_lk evaluates correctly and
  18. * added (char *)message casts to get rid of warnings
  19. * 03-15-90 GJF Replace _LOAD_DS with _CALLTYPE1, added #include
  20. * <cruntime.h>, removed #include <register.h> and fixed
  21. * the copyright. Also, cleaned up the formatting a bit.
  22. * 04-05-90 GJF Added #include <string.h>.
  23. * 08-14-90 SBM Removed unneeded #include <errmsg.h>
  24. * 10-04-90 GJF New-style function declarator.
  25. * 08-26-92 GJF Include unistd.h for POSIX build.
  26. *
  27. *******************************************************************************/
  28. #include <cruntime.h>
  29. #ifdef _POSIX_
  30. #include <unistd.h>
  31. #endif
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <string.h>
  35. #include <syserr.h>
  36. #include <os2dll.h>
  37. #include <io.h>
  38. /***
  39. *void perror(message) - print system error message
  40. *
  41. *Purpose:
  42. * prints user's error message, then follows it with ": ", then the system
  43. * error message, then a newline. All output goes to stderr. If user's
  44. * message is NULL or a null string, only the system error message is
  45. * printer. If errno is weird, prints "Unknown error".
  46. *
  47. *Entry:
  48. * const char *message - users message to prefix system error message
  49. *
  50. *Exit:
  51. * Prints message; no return value.
  52. *
  53. *Exceptions:
  54. *
  55. *******************************************************************************/
  56. void _CALLTYPE1 perror (
  57. REG1 const char *message
  58. )
  59. {
  60. REG2 int fh = 2;
  61. _lock_fh(fh); /* acquire file handle lock */
  62. if (message && *message)
  63. {
  64. _write_lk(fh,(char *)message,strlen(message));
  65. _write_lk(fh,": ",2);
  66. }
  67. message = _sys_err_msg( errno );
  68. _write_lk(fh,(char *)message,strlen(message));
  69. _write_lk(fh,"\n",1);
  70. _unlock_fh(fh); /* release file handle lock */
  71. }