Index: trunk/src/tools/qsysxcpt_pm.cpp
===================================================================
--- trunk/src/tools/qsysxcpt_pm.cpp	(revision 148)
+++ trunk/src/tools/qsysxcpt_pm.cpp	(revision 149)
@@ -60,13 +60,13 @@
 //     contexts to the trap file when a real exception happens on one thread
 
-/*! \class QtOS2SysXcptMainHandler qt_os2.h
-
-    @todo (r=dmik) describe...
-    
-    - must be instantiated on the stack of the main thread only
-    - should be instantiated before a QAplication instance is created
-      (does nothing otherwise)
-    - note that callback can be called on any thread
-*/
+/** @class QtOS2SysXcptMainHandler qt_os2.h
+ *
+ *  @todo (r=dmik) describe...
+ *
+ *  - must be instantiated on the stack of the main thread only
+ *  - should be instantiated before a QAplication instance is created
+ *    (does nothing otherwise)
+ *  - note that callback can be called on any thread
+ */
 
 /* static */
@@ -75,8 +75,8 @@
 ERR QtOS2SysXcptMainHandler::libcHandler = NULL;
 
-/*!
-    @todo (r=dmik) describe...        
-*/
-QtOS2SysXcptMainHandler::QtOS2SysXcptMainHandler( QtOS2SysXcptCallback cb )
+/**
+ *  @todo (r=dmik) describe...        
+ */
+QtOS2SysXcptMainHandler::QtOS2SysXcptMainHandler (QtOS2SysXcptCallback cb)
 {
     rec.prev_structure = NULL;
@@ -84,38 +84,38 @@
     
     PTIB ptib = NULL;
-    DosGetInfoBlocks( &ptib, NULL );
-    Q_ASSERT( ptib && ptib->tib_ptib2 );
-
-    if ( ptib && ptib->tib_ptib2 )
-    {
-        // must be instantiated only on the main (first) thread 
-        Q_ASSERT( ptib->tib_ptib2->tib2_ultid == 1 );
-        if ( ptib->tib_ptib2->tib2_ultid == 1 )
-        {
-            // must not be already instantiated
-            Q_ASSERT( installed == FALSE );
-            Q_ASSERT( libcHandler == NULL );
-            if ( installed == FALSE && libcHandler == NULL )
+    DosGetInfoBlocks (&ptib, NULL);
+    Q_ASSERT (ptib && ptib->tib_ptib2);
+
+    if (ptib && ptib->tib_ptib2)
+    {
+        /* must be instantiated only on the main (first) thread */ 
+        Q_ASSERT (ptib->tib_ptib2->tib2_ultid == 1);
+        if (ptib->tib_ptib2->tib2_ultid == 1)
+        {
+            /* must not be already instantiated */
+            Q_ASSERT (installed == FALSE);
+            Q_ASSERT (libcHandler == NULL);
+            if (installed == FALSE && libcHandler == NULL)
             {
                 installed = TRUE;
                 callback = cb;
-                // install the exception handler for the main thread 
+                /* install the exception handler for the main thread */ 
                 rec.ExceptionHandler = handler;
-                DosSetExceptionHandler( &rec );
-            }
-        }
-    }
-}
-
-/*!
-    @todo (r=dmik) describe...        
-*/
+                DosSetExceptionHandler (&rec);
+            }
+        }
+    }
+}
+
+/**
+ *  @todo (r=dmik) describe...        
+ */
 QtOS2SysXcptMainHandler::~QtOS2SysXcptMainHandler()
 {
-    Q_ASSERT( rec.ExceptionHandler == handler || rec.ExceptionHandler == NULL );
-    if ( rec.ExceptionHandler == handler )
-    {
-        // uninstall the exception handler for the main thread
-        DosUnsetExceptionHandler( &rec );
+    Q_ASSERT (rec.ExceptionHandler == handler || rec.ExceptionHandler == NULL);
+    if (rec.ExceptionHandler == handler)
+    {
+        /* uninstall the exception handler for the main thread */
+        DosUnsetExceptionHandler (&rec);
         rec.ExceptionHandler = NULL;
         callback = NULL; 
@@ -124,5 +124,5 @@
 }
 
-static void qt_excEscapeString( FILE *file, const char *pcszStr );
+static void qt_excEscapeString (FILE *file, const char *pcszStr);
 
 #define XcptPvt QtOS2SysXcptMainHandler::Private
@@ -131,17 +131,17 @@
 {
 public:
-    static void callbackWriter( const char *msg );
-
-    static inline int askCallback( QtOS2SysXcptReq req )
-    {
-        if ( callback )
-            return callback( req, NULL, 0 );
+    static void callbackWriter (const char *msg);
+
+    static inline int askCallback (QtOS2SysXcptReq req)
+    {
+        if (callback)
+            return callback (req, NULL, 0);
         return FALSE; 
     }
 
-    static inline int letCallback( QtOS2SysXcptReq req )
-    {
-        if ( callback )
-            return callback( req, callbackWriter, 0 );
+    static inline int letCallback (QtOS2SysXcptReq req)
+    {
+        if (callback)
+            return callback (req, callbackWriter, 0);
         return FALSE; 
     }
@@ -154,14 +154,14 @@
 
 /* static */
-void XcptPvt::callbackWriter( const char *msg )
-{
-    if ( file )
-        qt_excEscapeString( file, msg );
-}
-
-/*! \internal
-    Writes the given string with [<>&'"] characters escaped for XML.
-*/
-static void qt_excEscapeString( FILE *file, const char *pcszStr )
+void XcptPvt::callbackWriter (const char *msg)
+{
+    if (file)
+        qt_excEscapeString (file, msg);
+}
+
+/** \internal
+ *  Writes the given string with [<>&'"] characters escaped for XML.
+ */
+static void qt_excEscapeString (FILE *file, const char *pcszStr)
 {
     const char *pcszChars = "<>&'\"";
@@ -172,82 +172,82 @@
     size_t cbLen = 0;
 
-    if ( !pcsz )
+    if (!pcsz)
         return;
 
-    while( *pcsz )
-    {
-        cbLen = strcspn( pcsz, pcszChars );
-        fwrite( pcsz, 1, cbLen, file );
+    while (*pcsz)
+    {
+        cbLen = strcspn (pcsz, pcszChars);
+        fwrite (pcsz, 1, cbLen, file);
         pcsz += cbLen;
-        if ( !*pcsz )
+        if (!*pcsz)
             break;
-        cbLen = strchr( pcszChars, *pcsz ) - pcszChars;
+        cbLen = strchr (pcszChars, *pcsz) - pcszChars;
         pcszRepl = aszEntities[cbLen];
-        fwrite( pcszRepl, 1, strlen(pcszRepl), file );
+        fwrite (pcszRepl, 1, strlen(pcszRepl), file);
         ++ pcsz;
     }
 }
 
-/*! \internal
-    Writes the given error message.
-*/
-static void qt_excWriteErrorMsg( FILE *file, ULONG ulIndent, const char *pcszMsg,
-                                 ... )
+/** \internal
+ *  Writes the given error message.
+ */
+static void qt_excWriteErrorMsg (FILE *file, ULONG ulIndent, const char *pcszMsg,
+                                 ...)
 {
     char szBuf[1024];
     va_list args;
-    va_start( args, pcszMsg );
-    fprintf( file, "%*s<Error message=\"", ulIndent, "" );
-    vsnprintf( szBuf, sizeof(szBuf), pcszMsg, args );
+    va_start (args, pcszMsg);
+    fprintf (file, "%*s<Error message=\"", ulIndent, "");
+    vsnprintf (szBuf, sizeof(szBuf), pcszMsg, args);
     szBuf[sizeof(szBuf) - 1] = '\0';
-    qt_excEscapeString( file, szBuf );
-    fprintf( file, "\"/>\n" );
-    va_end( args );
-}
-
-/*! \internal
-    Writes the register name, value and optionally memory flags
-*/
-static void qt_excWriteReg( FILE *file, const char *pszName, ULONG ulValue,
-                            BOOL bQueryMem = TRUE )
-{
-    fprintf( file, "      <Register name=\"%s\" value=\"%08lX\"", 
-             pszName, ulValue );
-
-    if ( bQueryMem )
+    qt_excEscapeString (file, szBuf);
+    fprintf (file, "\"/>\n");
+    va_end (args);
+}
+
+/** \internal
+ *  Writes the register name, value and optionally memory flags
+ */
+static void qt_excWriteReg (FILE *file, const char *pszName, ULONG ulValue,
+                            BOOL bQueryMem = TRUE)
+{
+    fprintf (file, "      <Register name=\"%s\" value=\"%08lX\"", 
+             pszName, ulValue);
+
+    if (bQueryMem)
     {
         APIRET arc;
         ULONG ulCount = 4;
         ULONG ulFlags = 0;
-        arc = DosQueryMem( (PVOID) ulValue, &ulCount, &ulFlags );
-    
-        if ( arc == NO_ERROR || arc == ERROR_INVALID_ADDRESS )
-        {
-            if ( arc == NO_ERROR )
-            {
-                fprintf( file, " flags=\"%08lX\"", ulFlags );
-                if ( ulFlags & (PAG_COMMIT | PAG_READ) == (PAG_COMMIT | PAG_READ) )
-                    fprintf( file, " word=\"%08lX\"/>\n", *(ULONG *) ulValue );
+        arc = DosQueryMem ((PVOID) ulValue, &ulCount, &ulFlags);
+    
+        if (arc == NO_ERROR || arc == ERROR_INVALID_ADDRESS)
+        {
+            if (arc == NO_ERROR)
+            {
+                fprintf (file, " flags=\"%08lX\"", ulFlags);
+                if (ulFlags & (PAG_COMMIT | PAG_READ) == (PAG_COMMIT | PAG_READ))
+                    fprintf (file, " word=\"%08lX\"/>\n", *(ULONG *) ulValue);
                 else
-                    fprintf( file, "/>\n" );
+                    fprintf (file, "/>\n");
             }
             else
-                fprintf( file, " flags=\"invalid\"/>\n" );
+                fprintf (file, " flags=\"invalid\"/>\n");
         }
         else
         {
-            fprintf( file, ">\n" );
-            qt_excWriteErrorMsg( file, 7, "DosQueryMem returned %lu"
-                                 "and flags %08lX", arc, ulFlags );
-            fprintf( file, "      </Register>\n" );
+            fprintf (file, ">\n");
+            qt_excWriteErrorMsg (file, 7, "DosQueryMem returned %lu"
+                                 "and flags %08lX", arc, ulFlags);
+            fprintf (file, "      </Register>\n");
         }
     }
     else
-        fprintf( file, "/>\n" );
-}
-
-/*! \internal
-    Writes information about a signle stack frame.
-*/
+        fprintf (file, "/>\n");
+}
+
+/** \internal
+ *  Writes information about a signle stack frame.
+ */
 static void qt_excWriteStackFrame (FILE *file, ULONG ulRegEbp, ULONG ulRegEip)
 {
@@ -327,7 +327,7 @@
 }
 
-/*! \internal
-    Walks the stack and writes information about stack frames.
-*/
+/** \internal
+ *  Walks the stack and writes information about stack frames.
+ */
 static void qt_excWriteStackFrames (FILE *file, PTIB ptib,
                                     PCONTEXTRECORD pContextRec)
@@ -383,9 +383,9 @@
 }
 
-/*! \internal
-    Writes the thread information.
-    If ptib is not NULL, the current thread's information is to be written.
-    If ptib is NULL, pThrdRec is guaranted not to be NULL.
-*/
+/** \internal
+ *  Writes the thread information.
+ *  If ptib is not NULL, the current thread's information is to be written.
+ *  If ptib is NULL, pThrdRec is guaranted not to be NULL.
+ */
 static void qt_excWriteThreadInfo (FILE *file, PTIB ptib, QSTREC *pThrdRec,
                                    PCONTEXTRECORD pContextRec)
@@ -416,5 +416,5 @@
                    "     <Registers>\n");
 
-    if  (pContextRec->ContextFlags & CONTEXT_SEGMENTS)
+    if (pContextRec->ContextFlags & CONTEXT_SEGMENTS)
     {
         qt_excWriteReg (file, "DS", pContextRec->ctx_SegDs, FALSE);
@@ -424,5 +424,5 @@
     }
     
-    if  (pContextRec->ContextFlags & CONTEXT_INTEGER)
+    if (pContextRec->ContextFlags & CONTEXT_INTEGER)
     {
         qt_excWriteReg (file, "EAX", pContextRec->ctx_RegEax);
@@ -434,5 +434,5 @@
     }
 
-    if  (pContextRec->ContextFlags & CONTEXT_CONTROL)
+    if (pContextRec->ContextFlags & CONTEXT_CONTROL)
     {
         qt_excWriteReg (file, "CS", pContextRec->ctx_SegCs, FALSE);
@@ -561,9 +561,9 @@
 }
 
-/*! \internal
-    Writes module information to the log file.
-    \a ulOrigin is 1 (self), 2 (imported), or 3 (loaded). Other values are
-    ignored.
-*/
+/** \internal
+ *  Writes module information to the log file.
+ *  \a ulOrigin is 1 (self), 2 (imported), or 3 (loaded). Other values are
+ *  ignored.
+ */
 static void qt_excWriteModule (FILE *file, USHORT hmte, char *pszName,
                                ULONG ulOrigin = 0)
@@ -580,5 +580,5 @@
     arc = DosQueryPathInfo (pszName, FIL_STANDARD, &Status, sizeof (Status));
 
-    if ((ulOrigin >= 1 && ulOrigin <= 3) || arc == NO_ERROR )
+    if ((ulOrigin >= 1 && ulOrigin <= 3) || arc == NO_ERROR)
     {
         fprintf (file, "\n           ");
@@ -599,8 +599,8 @@
 }
 
-/*! \internal
-    Writes module and all its imports information to the log file.
-    \a ulOrigin is 1 (self), or 3 (loaded), other values are ignored.
-*/
+/** \internal
+ *  Writes module and all its imports information to the log file.
+ *  \a ulOrigin is 1 (self), or 3 (loaded), other values are ignored.
+ */
 static void qt_excWriteModules (FILE *file, USHORT hmte, QSLREC *pFirstLibRec,
                                 ULONG ulOrigin)
@@ -643,9 +643,9 @@
 } WMOS_STATE;
 
-/*! \internal
-    Walks the stack and writes information about all encountered modules.
-    Used only when DosQuerySysState() fails (so qt_excWriteModules() is not
-    applicable). We use recursiveness to avoid module record duplicates.
-*/
+/** \internal
+ *  Walks the stack and writes information about all encountered modules.
+ *  Used only when DosQuerySysState() fails (so qt_excWriteModules() is not
+ *  applicable). We use recursiveness to avoid module record duplicates.
+ */
 static void qt_excWriteModulesOnStack (WMOS_STATE *pState)
 {
@@ -742,7 +742,7 @@
 } PROCESSINFO;
 
-/*! \internal
-    Writes exception information to the log file.
-*/
+/** \internal
+ *  Writes exception information to the log file.
+ */
 static void qt_excWriteException (FILE *file,
                                   PROCESSINFO *pInfo,
@@ -868,10 +868,10 @@
  *  log file. Note that \a pszFileName must be at least CCHMAXPATH bytes length.
  */
-static FILE *qt_excOpenLogFile( const char *pcszBasePath, char *pszFileName )
+static FILE *qt_excOpenLogFile (const char *pcszBasePath, char *pszFileName)
 {
     FILE *file = NULL;
 
     char szFileName[CCHMAXPATH];
-    char szDir[] = "\\.qt3traps";
+    char szDir[] = "\\.systrap";
     char szFile[] = "\\12345678.123";
     enum { cbFileName = sizeof(szFileName) };
@@ -885,83 +885,84 @@
     char *pszStamp = NULL; 
     
-    if ( pcszBasePath == NULL || pszFileName == NULL )
+    if (pcszBasePath == NULL || pszFileName == NULL)
         return NULL;
     
-    if ( access( pcszBasePath, F_OK ) != 0 )
+    if (access (pcszBasePath, F_OK) != 0)
         return NULL;
     
-    if ( strlen( pcszBasePath ) + cbDir + cbFile - 2 >= CCHMAXPATH )
+    if (strlen (pcszBasePath) + cbDir + cbFile - 2 >= CCHMAXPATH)
         return NULL;
 
-    // get the full path if it's not 'X:'
-    if ( strlen(pcszBasePath) != 2 ||
-         pcszBasePath[1] != ':' )
-    {
-        if( DosQueryPathInfo( pcszBasePath, FIL_QUERYFULLNAME,
-                              szFileName, cbFileName ) != NO_ERROR )
+    /* get the full path if it's not 'X:' */
+    if (strlen(pcszBasePath) != 2 ||
+         pcszBasePath[1] != ':')
+    {
+        if (DosQueryPathInfo (pcszBasePath, FIL_QUERYFULLNAME,
+                              szFileName, cbFileName) != NO_ERROR)
             return NULL;
     }
     else
-        strcpy( szFileName, pcszBasePath );
-    
-    strcat( szFileName, szDir );
-    if ( access( szFileName, F_OK ) != 0 )
-        if ( mkdir( szFileName, 0777 ) != 0 )
+        strcpy (szFileName, pcszBasePath);
+    
+    strcat (szFileName, szDir);
+    if (access (szFileName, F_OK) != 0)
+        if (mkdir (szFileName, 0777) != 0)
             return NULL;
     
-    cbDirLen = strlen( szFileName );
+    cbDirLen = strlen (szFileName);
         
-    // first, try to use the desired base file name
-
-    // we will append -NN to the file name to add some 'fraction of a
-    // second' granularity to avoid name conflicts (0 <= NNN <= 99)
-    cbLen = strlen( pszFileName );
-    if ( cbDirLen + cbLen + 8 /* \-NN.xml */ < CCHMAXPATH )
-    {
-        strcat( szFileName, "\\" );
-        strcat( szFileName, pszFileName );
+    /* first, try to use the desired base file name */
+
+    /* we will append -NN to the file name to add some 'fraction of a
+     * second' granularity to avoid name conflicts (0 <= NNN <= 99) */
+    cbLen = strlen (pszFileName);
+    if (cbDirLen + cbLen + 12 /* \-NN.trp.xml */ < CCHMAXPATH)
+    {
+        strcat (szFileName, "\\");
+        strcat (szFileName, pszFileName);
         cbLen += cbDirLen + 1 /* \ */;
-        for( ul = 0; ul < 100; ++ul )
-        {
-            sprintf( szFileName + cbLen, "-%02ld.xml", ul );
-            if ( access( szFileName, F_OK ) == 0 )
+        for (ul = 0; ul < 100; ++ul)
+        {
+            sprintf (szFileName + cbLen, "-%02ld.trp.xml", ul);
+            if (access (szFileName, F_OK) == 0)
                 continue;
-            file = fopen( szFileName, "wt" );
-            if ( file )
+            file = fopen (szFileName, "wt");
+            if (file)
                 break;
-            if ( errno == ENAMETOOLONG )
+            if (errno == ENAMETOOLONG)
                 break;
         }
     }
 
-    // next, try a time stamp as a 8x3 file name
-    if ( file == NULL )
+    /* next, try a time stamp as a 8x3 file name */
+
+    if (file == NULL)
     {
         pszStamp = szFileName + cbDirLen + 1;
-        strcat( szFileName, szFile );
+        strcat (szFileName, szFile);
         
-        ulStamp = time( NULL );
-    
-        // In order to add some 'fraction of a second' granularity to the
-        // timestamp, we shift it by 5 bits. This gives us 0x07FFFFFF seconds
-        // which is a period of approx. 4,25 years. 5 bits in turn give us 32
-        // fractions of a second.
+        ulStamp = time (NULL);
+    
+        /* In order to add some 'fraction of a second' granularity to the
+         * timestamp, we shift it by 5 bits. This gives us 0x07FFFFFF seconds
+         * which is a period of approx. 4,25 years. 5 bits in turn give us 32
+         * fractions of a second. */
         ulStamp <<= 5;
         
-        // try some few adajcent stamps if the first one fails
-        for ( ul = 0; ul < 32; ++ul, ++ulStamp )
-        {
-            sprintf( pszStamp, "%08lX.xml", ulStamp );
-            if ( access( szFileName, F_OK ) == 0 )
+        /* try some few next stamps if the first one fails */
+        for (ul = 0; ul < 32; ++ul, ++ulStamp)
+        {
+            sprintf (pszStamp, "%08lX.xml", ulStamp);
+            if (access (szFileName, F_OK) == 0)
                 continue;
-            file = fopen( szFileName, "wt" );
-            if ( file )
+            file = fopen (szFileName, "wt");
+            if (file)
                 break;
         }
     }
     
-    if ( file )
-    {
-        strncpy( pszFileName, szFileName, CCHMAXPATH - 1 );
+    if (file)
+    {
+        strncpy (pszFileName, szFileName, CCHMAXPATH - 1);
         pszFileName[CCHMAXPATH - 1] = '\0';
     }
@@ -970,13 +971,13 @@
 }
 
-/*! \internal
-    Qt Exception handler.
-*/
+/** \internal
+ *  Qt Exception handler.
+ */
 /* static */
 ULONG APIENTRY
-QtOS2SysXcptMainHandler::handler( PEXCEPTIONREPORTRECORD pReportRec,
+QtOS2SysXcptMainHandler::handler (PEXCEPTIONREPORTRECORD pReportRec,
                                   PEXCEPTIONREGISTRATIONRECORD pRegRec,
                                   PCONTEXTRECORD pContextRec,
-                                  PVOID pv )
+                                  PVOID pv)
 {
     PROCESSINFO Info = {0};
@@ -1073,7 +1074,7 @@
                 /* find the base name (w/o path and extension) */ 
                 char *psz = strrchr (szFullExeName, '\\');
-                if ( psz )
+                if (psz)
                     ++ psz;
-                if ( !psz )
+                if (!psz)
                     psz = szFullExeName;
                 strcpy (szBaseExeName, psz);
@@ -1115,6 +1116,6 @@
                 char szBootDrive[] = "\0:";
                 ULONG ulBootDrive;
-                DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
-                                 &ulBootDrive, sizeof(ulBootDrive) );
+                DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
+                                 &ulBootDrive, sizeof(ulBootDrive));
                 szBootDrive[0] = (char) ulBootDrive + 'A' - 1;
                 file = qt_excOpenLogFile (szBootDrive, szFileName);
