Ignore:
Timestamp:
Apr 10, 2003, 12:28:07 PM (22 years ago)
Author:
sandervl
Message:

PF: MSVCRT update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/msvcrt/exit.c

    r9633 r10005  
    2323#include "msvcrt/stdlib.h"
    2424#include "mtdll.h"
    25 
     25#include "winuser.h"
     26#include <string.h>
    2627#include "wine/debug.h"
    2728
     
    3738
    3839extern int MSVCRT_app_type;
     40extern char *MSVCRT__pgmptr;
     41
     42static LPCSTR szMsgBoxTitle = "Wine C++ Runtime Library";
    3943
    4044/* INTERNAL: call atexit functions */
     
    9296void MSVCRT__exit(int exitcode)
    9397{
    94   TRACE("(%d)\n", exitcode);
     98  TRACE("MSVCRT: _exit (%d)\n", exitcode);
    9599  ExitProcess(exitcode);
    96100}
    97101
     102/* Print out an error message with an option to debug */
     103static void DoMessageBox(LPCSTR lead, LPCSTR message)
     104{
     105  MSGBOXPARAMSA msgbox;
     106  char text[2048];
     107  INT ret;
     108
     109  _snprintf(text,sizeof(text),"%s\n\nProgram: %s\n%s\n\n"
     110               "Press OK to exit the program, or Cancel to start the Wine debugger.\n ",
     111               lead, MSVCRT__pgmptr, message);
     112
     113  msgbox.cbSize = sizeof(msgbox);
     114  msgbox.hwndOwner = GetActiveWindow();
     115  msgbox.hInstance = 0;
     116  msgbox.lpszText = text;
     117  msgbox.lpszCaption = szMsgBoxTitle;
     118  msgbox.dwStyle = MB_OKCANCEL|MB_ICONERROR;
     119  msgbox.lpszIcon = NULL;
     120  msgbox.dwContextHelpId = 0;
     121  msgbox.lpfnMsgBoxCallback = NULL;
     122  msgbox.dwLanguageId = LANG_NEUTRAL;
     123
     124  ret = MessageBoxIndirectA(&msgbox);
     125  if (ret == IDCANCEL)
     126    DebugBreak();
     127}
     128
    98129/*********************************************************************
    99130 *              _amsg_exit (MSVCRT.@)
     
    101132void MSVCRT__amsg_exit(int errnum)
    102133{
    103   TRACE("(%d)\n", errnum);
     134  TRACE("MSVCRT: _amsg_exit (%d)\n", errnum);
    104135  /* FIXME: text for the error number. */
    105136  if (MSVCRT_app_type == 2)
    106137  {
    107     /* FIXME: MsgBox */
    108   }
    109   _cprintf("\nruntime error R60%d\n",errnum);
     138    char text[32];
     139    sprintf(text, "Error: R60%d",errnum);
     140    DoMessageBox("Runtime error!", text);
     141  }
     142  else
     143    MSVCRT__cprintf("\nruntime error R60%d\n",errnum);
    110144  MSVCRT__exit(255);
    111145}
     
    116150void MSVCRT_abort(void)
    117151{
    118   TRACE("(void)\n");
     152  TRACE("MSVCRT: _abort");
    119153  if (MSVCRT_app_type == 2)
    120154  {
    121     /* FIXME: MsgBox */
    122   }
    123   _cputs("\nabnormal program termination\n");
     155    DoMessageBox("Runtime error!", "abnormal program termination");
     156  }
     157  else
     158    MSVCRT__cputs("\nabnormal program termination\n");
    124159  MSVCRT__exit(3);
    125160}
     
    130165void MSVCRT__assert(const char* str, const char* file, unsigned int line)
    131166{
    132   TRACE("(%s,%s,%d)\n",str,file,line);
     167  TRACE("MSVCRT: _assert (%s,%s,%d)\n",str,file,line);
    133168  if (MSVCRT_app_type == 2)
    134169  {
    135     /* FIXME: MsgBox */
    136   }
    137   _cprintf("Assertion failed: %s, file %s, line %d\n\n",str,file, line);
    138   MSVCRT_abort();
     170    char text[2048];
     171    _snprintf(text, sizeof(text), "File: %s\nLine: %d\n\nEpression: \"%s\"", file, line, str);
     172    DoMessageBox("Assertion failed!", text);
     173  }
     174  else
     175    MSVCRT__cprintf("Assertion failed: %s, file %s, line %d\n\n",str, file, line);
     176  MSVCRT__exit(3);
    139177}
    140178
     
    144182void MSVCRT__c_exit(void)
    145183{
    146   TRACE("(void)\n");
     184  TRACE("MSVCRT: _c_exit (void)\n");
    147185  /* All cleanup is done on DLL detach; Return to caller */
    148186}
     
    153191void MSVCRT__cexit(void)
    154192{
    155   TRACE("(void)\n");
     193  TRACE("MSVCRT: _cexit (void)\n");
    156194  /* All cleanup is done on DLL detach; Return to caller */
    157195}
     
    160198 *              _onexit (MSVCRT.@)
    161199 */
    162 _onexit_t _onexit(_onexit_t func)
    163 {
    164   TRACE("(%p)\n",func);
     200_onexit_t MSVCRT__onexit(_onexit_t func)
     201{
     202  TRACE("MSVCRT: _onexit (%p)\n",func);
    165203
    166204  if (!func)
     
    196234void MSVCRT_exit(int exitcode)
    197235{
    198   TRACE("(%d)\n",exitcode);
     236  TRACE("MSVCRT: _exit (%d)\n",exitcode);
    199237  LOCK_EXIT;
    200238  __MSVCRT__call_atexit();
     
    208246int MSVCRT_atexit(void (*func)(void))
    209247{
    210   TRACE("(%p)\n", func);
    211   return _onexit((_onexit_t)func) == (_onexit_t)func ? 0 : -1;
     248  TRACE("MSVCRT: _atexit (%p)\n", func);
     249  return MSVCRT__onexit((_onexit_t)func) == (_onexit_t)func ? 0 : -1;
    212250}
    213251
     
    218256void _purecall(void)
    219257{
    220   TRACE("(void)\n");
     258  TRACE("MSVCRT: _purecall (void)\n");
    221259  MSVCRT__amsg_exit( 25 );
    222260}
Note: See TracChangeset for help on using the changeset viewer.