home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / errmode.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  3KB  |  91 lines

  1. /***
  2. *errmode.c - modify __error_mode and __app_type
  3. *
  4. *       Copyright (c) 1994-1997, 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. *******************************************************************************/
  13.  
  14. #include <cruntime.h>
  15. #include <internal.h>
  16. #include <stdlib.h>
  17.  
  18. /***
  19. *int _set_error_mode(int modeval) - interface to change __error_mode
  20. *
  21. *Purpose:
  22. *       Control the error (output) sink by setting the value of __error_mode.
  23. *       Explicit controls are to direct output t o standard error (FILE * or
  24. *       C handle or NT HANDLE) or to use the MessageBox API. This routine is
  25. *       exposed and documented for the users.
  26. *
  27. *Entry:
  28. *       int modeval =   _OUT_TO_DEFAULT, error sink is determined by __app_type
  29. *                       _OUT_TO_STDERR,  error sink is standard error
  30. *                       _OUT_TO_MSGBOX,  error sink is a message box
  31. *                       _REPORT_ERRMODE, report the current __error_mode value
  32. *
  33. *Exit:
  34. *       Returns old setting or -1 if an error occurs.
  35. *
  36. *Exceptions:
  37. *
  38. *******************************************************************************/
  39.  
  40. _CRTIMP int __cdecl _set_error_mode (
  41.         int em
  42.         )
  43. {
  44.         int retval;
  45.  
  46.         switch (em) {
  47.             case _OUT_TO_DEFAULT:
  48.             case _OUT_TO_STDERR:
  49.             case _OUT_TO_MSGBOX:
  50.             retval = __error_mode;
  51.             __error_mode = em;
  52.             break;
  53.             case _REPORT_ERRMODE:
  54.             retval = __error_mode;
  55.             break;
  56.             default:
  57.             retval = -1;
  58.         }
  59.  
  60.         return retval;
  61. }
  62.  
  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.  
  85. _CRTIMP void __cdecl __set_app_type (
  86.         int at
  87.         )
  88. {
  89.         __app_type = at;
  90. }
  91.