Leaked source code of windows server 2003
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.

97 lines
2.8 KiB

  1. /***
  2. *errmode.c - modify __error_mode and __app_type
  3. *
  4. * Copyright (c) 1994-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Defines _set_error_mode() and __set_app_type(), the routines used
  8. * to modify __error_mode and __app_type variables. Together, these
  9. * two variables determine how/where the C runtime writes error
  10. * messages.
  11. *
  12. *Revision History:
  13. * 09-06-94 GJF Module created.
  14. * 01-16-95 CFW Set default debug output for console.
  15. * 01-24-95 CFW Some debug name changes.
  16. * 03-21-95 CFW Add _CRT_ASSERT report type.
  17. * 07-07-95 CFW Simplify default report mode scheme.
  18. *
  19. *******************************************************************************/
  20. #include <cruntime.h>
  21. #include <internal.h>
  22. #include <stdlib.h>
  23. /***
  24. *int _set_error_mode(int modeval) - interface to change __error_mode
  25. *
  26. *Purpose:
  27. * Control the error (output) sink by setting the value of __error_mode.
  28. * Explicit controls are to direct output t o standard error (FILE * or
  29. * C handle or NT HANDLE) or to use the MessageBox API. This routine is
  30. * exposed and documented for the users.
  31. *
  32. *Entry:
  33. * int modeval = _OUT_TO_DEFAULT, error sink is determined by __app_type
  34. * _OUT_TO_STDERR, error sink is standard error
  35. * _OUT_TO_MSGBOX, error sink is a message box
  36. * _REPORT_ERRMODE, report the current __error_mode value
  37. *
  38. *Exit:
  39. * Returns old setting or -1 if an error occurs.
  40. *
  41. *Exceptions:
  42. *
  43. *******************************************************************************/
  44. _CRTIMP int __cdecl _set_error_mode (
  45. int em
  46. )
  47. {
  48. int retval;
  49. switch (em) {
  50. case _OUT_TO_DEFAULT:
  51. case _OUT_TO_STDERR:
  52. case _OUT_TO_MSGBOX:
  53. retval = __error_mode;
  54. __error_mode = em;
  55. break;
  56. case _REPORT_ERRMODE:
  57. retval = __error_mode;
  58. break;
  59. default:
  60. retval = -1;
  61. }
  62. return retval;
  63. }
  64. /***
  65. *void __set_app_type(int apptype) - interface to change __app_type
  66. *
  67. *Purpose:
  68. * Set, or change, the value of __app_type.
  69. *
  70. * Set the default debug lib report destination for console apps.
  71. *
  72. * This function is for INTERNAL USE ONLY.
  73. *
  74. *Entry:
  75. * int modeval = _UNKNOWN_APP, unknown
  76. * _CONSOLE_APP, console, or command line, application
  77. * _GUI_APP, GUI, or Windows, application
  78. *
  79. *Exit:
  80. *
  81. *Exceptions:
  82. *
  83. *******************************************************************************/
  84. _CRTIMP void __cdecl __set_app_type (
  85. int at
  86. )
  87. {
  88. __app_type = at;
  89. }