/ Check-in [761396f8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:For Windows VFS, modified xGetLastError() to call FormatMessage() with the FORMAT_MESSAGE_IGNORE_INSERTS option. Additionally updated to ensure strings are returned as UTF8. Ticket [39c85e8a4e].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 761396f8cb79be34853ba698a65af54874c3c10e
User & Date: shane 2009-10-21 02:00:48
Original Comment: For Windows VFS, modified xGetLastError() to call FormatMessage() with the FORMAT_MESSAGE_IGNORE_INSERTS option. Additionally updated to ensure strings are returned as UTF8. Ticket 39c85e8a4e.
References
2009-10-21
01:59 Fixed ticket [39c85e8a]: FormatMessage incorrectly used (Windows VFS) plus 3 other changes artifact: 4d0dea8d user: shane
Context
2009-10-21
03:42
For Windows version of shell, add support for .timer command using the GetProcessTimes() API if available (in the same way getrusage() is used on UNIX.) Ticket [89668ca167]. check-in: 83216fbe user: shane tags: trunk
02:00
For Windows VFS, modified xGetLastError() to call FormatMessage() with the FORMAT_MESSAGE_IGNORE_INSERTS option. Additionally updated to ensure strings are returned as UTF8. Ticket [39c85e8a4e]. check-in: 761396f8 user: shane tags: trunk
2009-10-20
15:27
Clarify the use of sqlite3_shutdown(). Ticket [f9af981dd2a2]. Comment changes only - no changes to code. check-in: b2aa48b5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

configure became a regular file.


install-sh became a regular file.


Changes to src/os_win.c.

    69     69   
    70     70   /*
    71     71   ** Determine if we are dealing with WindowsCE - which has a much
    72     72   ** reduced API.
    73     73   */
    74     74   #if SQLITE_OS_WINCE
    75     75   # define AreFileApisANSI() 1
    76         -# define GetDiskFreeSpaceW() 0
           76  +# define FormatMessageW(a,b,c,d,e,f,g) 0
    77     77   #endif
    78     78   
    79     79   /*
    80     80   ** WinCE lacks native support for file locking so we have to fake it
    81     81   ** with some code of our own.
    82     82   */
    83     83   #if SQLITE_OS_WINCE
................................................................................
  1244   1244   
  1245   1245   /*
  1246   1246   ** The return value of getLastErrorMsg
  1247   1247   ** is zero if the error message fits in the buffer, or non-zero
  1248   1248   ** otherwise (if the message was truncated).
  1249   1249   */
  1250   1250   static int getLastErrorMsg(int nBuf, char *zBuf){
  1251         -  DWORD error = GetLastError();
  1252         -
  1253         -#if SQLITE_OS_WINCE
  1254         -  sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error);
  1255         -#else
  1256   1251     /* FormatMessage returns 0 on failure.  Otherwise it
  1257   1252     ** returns the number of TCHARs written to the output
  1258   1253     ** buffer, excluding the terminating null char.
  1259   1254     */
  1260         -  if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM,
  1261         -                      NULL,
  1262         -                      error,
  1263         -                      0,
  1264         -                      zBuf,
  1265         -                      nBuf-1,
  1266         -                      0))
  1267         -  {
         1255  +  DWORD error = GetLastError();
         1256  +  DWORD dwLen = 0;
         1257  +  char *zOut;
         1258  +
         1259  +  if( isNT() ){
         1260  +    WCHAR *zTempWide = NULL;
         1261  +    dwLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
         1262  +                           NULL,
         1263  +                           error,
         1264  +                           0,
         1265  +                           (LPWSTR) &zTempWide,
         1266  +                           0,
         1267  +                           0);
         1268  +    if( dwLen > 0 ){
         1269  +      /* allocate a buffer and convert to UTF8 */
         1270  +      zOut = unicodeToUtf8(zTempWide);
         1271  +      /* free the system buffer allocated by FormatMessage */
         1272  +      LocalFree(zTempWide);
         1273  +    }
         1274  +/* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. 
         1275  +** Since the ASCII version of these Windows API do not exist for WINCE,
         1276  +** it's important to not reference them for WINCE builds.
         1277  +*/
         1278  +#if SQLITE_OS_WINCE==0
         1279  +  }else{
         1280  +    char *zTemp = NULL;
         1281  +    dwLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
         1282  +                           NULL,
         1283  +                           error,
         1284  +                           0,
         1285  +                           (LPSTR) &zTemp,
         1286  +                           0,
         1287  +                           0);
         1288  +    if( dwLen > 0 ){
         1289  +      /* allocate a buffer and convert to UTF8 */
         1290  +      zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
         1291  +      /* free the system buffer allocated by FormatMessage */
         1292  +      LocalFree(zTemp);
         1293  +    }
         1294  +#endif
         1295  +  }
         1296  +  if( 0 == dwLen ){
  1268   1297       sqlite3_snprintf(nBuf, zBuf, "OsError 0x%x (%u)", error, error);
         1298  +  }else{
         1299  +    /* copy a maximum of nBuf chars to output buffer */
         1300  +    sqlite3_snprintf(nBuf, zBuf, "%s", zOut);
         1301  +    /* free the UTF8 buffer */
         1302  +    free(zOut);
  1269   1303     }
  1270         -#endif
  1271         -
  1272   1304     return 0;
  1273   1305   }
  1274   1306   
  1275   1307   /*
  1276   1308   ** Open a file.
  1277   1309   */
  1278   1310   static int winOpen(
................................................................................
  1632   1664           dwRet = GetDiskFreeSpaceW((WCHAR*)zConverted,
  1633   1665                                     &dwDummy,
  1634   1666                                     &bytesPerSector,
  1635   1667                                     &dwDummy,
  1636   1668                                     &dwDummy);
  1637   1669         }else{
  1638   1670           /* trim path to just drive reference */
  1639         -        CHAR *p = (CHAR *)zConverted;
         1671  +        char *p = (char *)zConverted;
  1640   1672           for(;*p;p++){
  1641   1673             if( *p == '\\' ){
  1642   1674               *p = '\0';
  1643   1675               break;
  1644   1676             }
  1645   1677           }
  1646         -        dwRet = GetDiskFreeSpaceA((CHAR*)zConverted,
         1678  +        dwRet = GetDiskFreeSpaceA((char*)zConverted,
  1647   1679                                     &dwDummy,
  1648   1680                                     &bytesPerSector,
  1649   1681                                     &dwDummy,
  1650   1682                                     &dwDummy);
  1651   1683         }
  1652   1684         free(zConverted);
  1653   1685       }

tool/fragck.tcl became a regular file.


tool/mkopts.tcl became a regular file.


tool/mkspeedsql.tcl became a regular file.


tool/mksqlite3c.tcl became a regular file.


tool/mksqlite3h.tcl became a regular file.


tool/mksqlite3internalh.tcl became a regular file.


tool/omittest.tcl became a regular file.


tool/soak1.tcl became a regular file.


tool/space_used.tcl became a regular file.


tool/spaceanal.tcl became a regular file.


tool/speedtest.tcl became a regular file.


tool/speedtest2.tcl became a regular file.


tool/vdbe-compress.tcl became a regular file.