diff options
Diffstat (limited to '')
-rw-r--r-- | src/dutil/eseutil.cpp | 101 |
1 files changed, 58 insertions, 43 deletions
diff --git a/src/dutil/eseutil.cpp b/src/dutil/eseutil.cpp index 599a3943..d2bd7dc5 100644 --- a/src/dutil/eseutil.cpp +++ b/src/dutil/eseutil.cpp | |||
@@ -2,6 +2,21 @@ | |||
2 | 2 | ||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | |||
6 | // Exit macros | ||
7 | #define EseExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_ESEUTIL, x, s, __VA_ARGS__) | ||
8 | #define EseExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_ESEUTIL, x, s, __VA_ARGS__) | ||
9 | #define EseExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_ESEUTIL, x, s, __VA_ARGS__) | ||
10 | #define EseExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_ESEUTIL, x, s, __VA_ARGS__) | ||
11 | #define EseExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_ESEUTIL, x, s, __VA_ARGS__) | ||
12 | #define EseExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_ESEUTIL, x, s, __VA_ARGS__) | ||
13 | #define EseExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_ESEUTIL, p, x, e, s, __VA_ARGS__) | ||
14 | #define EseExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_ESEUTIL, p, x, s, __VA_ARGS__) | ||
15 | #define EseExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_ESEUTIL, p, x, e, s, __VA_ARGS__) | ||
16 | #define EseExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_ESEUTIL, p, x, s, __VA_ARGS__) | ||
17 | #define EseExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_ESEUTIL, e, x, s, __VA_ARGS__) | ||
18 | #define EseExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_ESEUTIL, g, x, s, __VA_ARGS__) | ||
19 | |||
5 | struct ESE_QUERY | 20 | struct ESE_QUERY |
6 | { | 21 | { |
7 | ESE_QUERY_TYPE qtQueryType; | 22 | ESE_QUERY_TYPE qtQueryType; |
@@ -85,13 +100,13 @@ HRESULT HresultFromJetError(JET_ERR jEr) | |||
85 | } | 100 | } |
86 | 101 | ||
87 | // Log the actual Jet error code so we have record of it before it's morphed into an HRESULT to be compatible with the rest of our code | 102 | // Log the actual Jet error code so we have record of it before it's morphed into an HRESULT to be compatible with the rest of our code |
88 | ExitTraceSource(DUTIL_SOURCE_DEFAULT, hr, "Encountered Jet Error: 0x%08x", jEr); | 103 | ExitTraceSource(DUTIL_SOURCE_ESEUTIL, hr, "Encountered Jet Error: 0x%08x", jEr); |
89 | 104 | ||
90 | return hr; | 105 | return hr; |
91 | } | 106 | } |
92 | 107 | ||
93 | #define ExitOnJetFailure(e, x, s, ...) { x = HresultFromJetError(e); if (S_OK != x) { ExitTraceSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__); goto LExit; }} | 108 | #define ExitOnJetFailure(e, x, s, ...) { x = HresultFromJetError(e); if (S_OK != x) { ExitTraceSource(DUTIL_SOURCE_ESEUTIL, x, s, __VA_ARGS__); goto LExit; }} |
94 | #define ExitOnRootJetFailure(e, x, s, ...) { x = HresultFromJetError(e); if (S_OK != x) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(DUTIL_SOURCE_DEFAULT, x, s, __VA_ARGS__); goto LExit; }} | 109 | #define ExitOnRootJetFailure(e, x, s, ...) { x = HresultFromJetError(e); if (S_OK != x) { Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(DUTIL_SOURCE_ESEUTIL, x, s, __VA_ARGS__); goto LExit; }} |
95 | 110 | ||
96 | HRESULT DAPI EseBeginSession( | 111 | HRESULT DAPI EseBeginSession( |
97 | __out JET_INSTANCE *pjiInstance, | 112 | __out JET_INSTANCE *pjiInstance, |
@@ -106,15 +121,15 @@ HRESULT DAPI EseBeginSession( | |||
106 | LPSTR pszAnsiPath = NULL; | 121 | LPSTR pszAnsiPath = NULL; |
107 | 122 | ||
108 | hr = DirEnsureExists(pszPath, NULL); | 123 | hr = DirEnsureExists(pszPath, NULL); |
109 | ExitOnFailure(hr, "Failed to ensure database directory exists"); | 124 | EseExitOnFailure(hr, "Failed to ensure database directory exists"); |
110 | 125 | ||
111 | // Sigh. JETblue requires Vista and up for the wide character version of this function, so we'll convert to ANSI before calling, | 126 | // Sigh. JETblue requires Vista and up for the wide character version of this function, so we'll convert to ANSI before calling, |
112 | // likely breaking everyone with unicode characters in their path. | 127 | // likely breaking everyone with unicode characters in their path. |
113 | hr = StrAnsiAllocString(&pszAnsiInstance, pszInstance, 0, CP_ACP); | 128 | hr = StrAnsiAllocString(&pszAnsiInstance, pszInstance, 0, CP_ACP); |
114 | ExitOnFailure(hr, "Failed converting instance name to ansi"); | 129 | EseExitOnFailure(hr, "Failed converting instance name to ansi"); |
115 | 130 | ||
116 | hr = StrAnsiAllocString(&pszAnsiPath, pszPath, 0, CP_ACP); | 131 | hr = StrAnsiAllocString(&pszAnsiPath, pszPath, 0, CP_ACP); |
117 | ExitOnFailure(hr, "Failed converting session path name to ansi"); | 132 | EseExitOnFailure(hr, "Failed converting session path name to ansi"); |
118 | 133 | ||
119 | jEr = JetCreateInstanceA(pjiInstance, pszAnsiInstance); | 134 | jEr = JetCreateInstanceA(pjiInstance, pszAnsiInstance); |
120 | ExitOnJetFailure(jEr, hr, "Failed to create instance"); | 135 | ExitOnJetFailure(jEr, hr, "Failed to create instance"); |
@@ -173,17 +188,17 @@ HRESULT AllocColumnCreateStruct( | |||
173 | size_t cbAllocSize = 0; | 188 | size_t cbAllocSize = 0; |
174 | 189 | ||
175 | hr = ::SizeTMult(ptsSchema->dwColumns, sizeof(JET_COLUMNCREATE), &(cbAllocSize)); | 190 | hr = ::SizeTMult(ptsSchema->dwColumns, sizeof(JET_COLUMNCREATE), &(cbAllocSize)); |
176 | ExitOnFailure(hr, "Maximum allocation exceeded."); | 191 | EseExitOnFailure(hr, "Maximum allocation exceeded."); |
177 | 192 | ||
178 | *ppjccColumnCreate = static_cast<JET_COLUMNCREATE*>(MemAlloc(cbAllocSize, TRUE)); | 193 | *ppjccColumnCreate = static_cast<JET_COLUMNCREATE*>(MemAlloc(cbAllocSize, TRUE)); |
179 | ExitOnNull(*ppjccColumnCreate, hr, E_OUTOFMEMORY, "Failed to allocate column create structure for database"); | 194 | EseExitOnNull(*ppjccColumnCreate, hr, E_OUTOFMEMORY, "Failed to allocate column create structure for database"); |
180 | 195 | ||
181 | for (i = 0; i < ptsSchema->dwColumns; ++i) | 196 | for (i = 0; i < ptsSchema->dwColumns; ++i) |
182 | { | 197 | { |
183 | (*ppjccColumnCreate)[i].cbStruct = sizeof(JET_COLUMNCREATE); | 198 | (*ppjccColumnCreate)[i].cbStruct = sizeof(JET_COLUMNCREATE); |
184 | 199 | ||
185 | hr = StrAnsiAllocString(&(*ppjccColumnCreate)[i].szColumnName, ptsSchema->pcsColumns[i].pszName, 0, CP_ACP); | 200 | hr = StrAnsiAllocString(&(*ppjccColumnCreate)[i].szColumnName, ptsSchema->pcsColumns[i].pszName, 0, CP_ACP); |
186 | ExitOnFailure(hr, "Failed to allocate ansi column name: %ls", ptsSchema->pcsColumns[i].pszName); | 201 | EseExitOnFailure(hr, "Failed to allocate ansi column name: %ls", ptsSchema->pcsColumns[i].pszName); |
187 | 202 | ||
188 | (*ppjccColumnCreate)[i].coltyp = ptsSchema->pcsColumns[i].jcColumnType; | 203 | (*ppjccColumnCreate)[i].coltyp = ptsSchema->pcsColumns[i].jcColumnType; |
189 | 204 | ||
@@ -237,7 +252,7 @@ HRESULT FreeColumnCreateStruct( | |||
237 | } | 252 | } |
238 | 253 | ||
239 | hr = MemFree(pjccColumnCreate); | 254 | hr = MemFree(pjccColumnCreate); |
240 | ExitOnFailure(hr, "Failed to release core column create struct"); | 255 | EseExitOnFailure(hr, "Failed to release core column create struct"); |
241 | 256 | ||
242 | LExit: | 257 | LExit: |
243 | return hr; | 258 | return hr; |
@@ -261,20 +276,20 @@ HRESULT AllocIndexCreateStruct( | |||
261 | if (ptsSchema->pcsColumns[i].fKey) | 276 | if (ptsSchema->pcsColumns[i].fKey) |
262 | { | 277 | { |
263 | hr = StrAnsiAllocString(&pszTempString, ptsSchema->pcsColumns[i].pszName, 0, CP_ACP); | 278 | hr = StrAnsiAllocString(&pszTempString, ptsSchema->pcsColumns[i].pszName, 0, CP_ACP); |
264 | ExitOnFailure(hr, "Failed to convert string to ansi: %ls", ptsSchema->pcsColumns[i].pszName); | 279 | EseExitOnFailure(hr, "Failed to convert string to ansi: %ls", ptsSchema->pcsColumns[i].pszName); |
265 | 280 | ||
266 | hr = StrAnsiAllocConcat(&pszMultiSzKeys, "+", 0); | 281 | hr = StrAnsiAllocConcat(&pszMultiSzKeys, "+", 0); |
267 | ExitOnFailure(hr, "Failed to append plus sign to multisz string: %s", pszTempString); | 282 | EseExitOnFailure(hr, "Failed to append plus sign to multisz string: %s", pszTempString); |
268 | 283 | ||
269 | hr = StrAnsiAllocConcat(&pszMultiSzKeys, pszTempString, 0); | 284 | hr = StrAnsiAllocConcat(&pszMultiSzKeys, pszTempString, 0); |
270 | ExitOnFailure(hr, "Failed to append column name to multisz string: %s", pszTempString); | 285 | EseExitOnFailure(hr, "Failed to append column name to multisz string: %s", pszTempString); |
271 | 286 | ||
272 | ReleaseNullStr(pszTempString); | 287 | ReleaseNullStr(pszTempString); |
273 | 288 | ||
274 | // All question marks will be converted to null characters later; this is just to trick dutil | 289 | // All question marks will be converted to null characters later; this is just to trick dutil |
275 | // into letting us create an ansi, double-null-terminated list of single-null-terminated strings | 290 | // into letting us create an ansi, double-null-terminated list of single-null-terminated strings |
276 | hr = StrAnsiAllocConcat(&pszMultiSzKeys, "?", 0); | 291 | hr = StrAnsiAllocConcat(&pszMultiSzKeys, "?", 0); |
277 | ExitOnFailure(hr, "Failed to append placeholder character to multisz string: %ls", pszMultiSzKeys); | 292 | EseExitOnFailure(hr, "Failed to append placeholder character to multisz string: %hs", pszMultiSzKeys); |
278 | 293 | ||
279 | // Record that at least one key column was found | 294 | // Record that at least one key column was found |
280 | fKeyColumns = TRUE; | 295 | fKeyColumns = TRUE; |
@@ -288,18 +303,18 @@ HRESULT AllocIndexCreateStruct( | |||
288 | } | 303 | } |
289 | 304 | ||
290 | hr = StrAnsiAllocString(&pszIndexName, ptsSchema->pszName, 0, CP_ACP); | 305 | hr = StrAnsiAllocString(&pszIndexName, ptsSchema->pszName, 0, CP_ACP); |
291 | ExitOnFailure(hr, "Failed to allocate ansi string version of %ls", ptsSchema->pszName); | 306 | EseExitOnFailure(hr, "Failed to allocate ansi string version of %ls", ptsSchema->pszName); |
292 | 307 | ||
293 | hr = StrAnsiAllocConcat(&pszIndexName, "_Index", 0); | 308 | hr = StrAnsiAllocConcat(&pszIndexName, "_Index", 0); |
294 | ExitOnFailure(hr, "Failed to append table name string version of %ls", ptsSchema->pszName); | 309 | EseExitOnFailure(hr, "Failed to append table name string version of %ls", ptsSchema->pszName); |
295 | 310 | ||
296 | *ppjicIndexCreate = static_cast<JET_INDEXCREATE*>(MemAlloc(sizeof(JET_INDEXCREATE), TRUE)); | 311 | *ppjicIndexCreate = static_cast<JET_INDEXCREATE*>(MemAlloc(sizeof(JET_INDEXCREATE), TRUE)); |
297 | ExitOnNull(*ppjicIndexCreate, hr, E_OUTOFMEMORY, "Failed to allocate index create structure for database"); | 312 | EseExitOnNull(*ppjicIndexCreate, hr, E_OUTOFMEMORY, "Failed to allocate index create structure for database"); |
298 | 313 | ||
299 | // Record the size including both null terminators - the struct requires this | 314 | // Record the size including both null terminators - the struct requires this |
300 | DWORD dwSize = 0; | 315 | DWORD dwSize = 0; |
301 | dwSize = lstrlen(pszMultiSzKeys) + 1; // add 1 to include null character at the end | 316 | dwSize = lstrlen(pszMultiSzKeys) + 1; // add 1 to include null character at the end |
302 | ExitOnFailure(hr, "Failed to get size of keys string"); | 317 | EseExitOnFailure(hr, "Failed to get size of keys string"); |
303 | 318 | ||
304 | // At this point convert all question marks to null characters | 319 | // At this point convert all question marks to null characters |
305 | for (i = 0; i < dwSize; ++i) | 320 | for (i = 0; i < dwSize; ++i) |
@@ -349,7 +364,7 @@ HRESULT EnsureSchema( | |||
349 | jtTableCreate.cIndexes = 1; | 364 | jtTableCreate.cIndexes = 1; |
350 | 365 | ||
351 | hr = EseBeginTransaction(jsSession); | 366 | hr = EseBeginTransaction(jsSession); |
352 | ExitOnFailure(hr, "Failed to begin transaction to create tables"); | 367 | EseExitOnFailure(hr, "Failed to begin transaction to create tables"); |
353 | fTransaction = TRUE; | 368 | fTransaction = TRUE; |
354 | 369 | ||
355 | for (dwTable = 0;dwTable < pdsSchema->dwTables; ++dwTable) | 370 | for (dwTable = 0;dwTable < pdsSchema->dwTables; ++dwTable) |
@@ -363,13 +378,13 @@ HRESULT EnsureSchema( | |||
363 | { | 378 | { |
364 | // Fill out the JET_TABLECREATE struct | 379 | // Fill out the JET_TABLECREATE struct |
365 | hr = StrAnsiAllocString(&jtTableCreate.szTableName, pdsSchema->ptsTables[dwTable].pszName, 0, CP_ACP); | 380 | hr = StrAnsiAllocString(&jtTableCreate.szTableName, pdsSchema->ptsTables[dwTable].pszName, 0, CP_ACP); |
366 | ExitOnFailure(hr, "Failed converting table name to ansi"); | 381 | EseExitOnFailure(hr, "Failed converting table name to ansi"); |
367 | 382 | ||
368 | hr = AllocColumnCreateStruct(&(pdsSchema->ptsTables[dwTable]), &jtTableCreate.rgcolumncreate); | 383 | hr = AllocColumnCreateStruct(&(pdsSchema->ptsTables[dwTable]), &jtTableCreate.rgcolumncreate); |
369 | ExitOnFailure(hr, "Failed to allocate column create struct"); | 384 | EseExitOnFailure(hr, "Failed to allocate column create struct"); |
370 | 385 | ||
371 | hr = AllocIndexCreateStruct(&(pdsSchema->ptsTables[dwTable]), &jtTableCreate.rgindexcreate); | 386 | hr = AllocIndexCreateStruct(&(pdsSchema->ptsTables[dwTable]), &jtTableCreate.rgindexcreate); |
372 | ExitOnFailure(hr, "Failed to allocate index create struct"); | 387 | EseExitOnFailure(hr, "Failed to allocate index create struct"); |
373 | 388 | ||
374 | jtTableCreate.cColumns = pdsSchema->ptsTables[dwTable].dwColumns; | 389 | jtTableCreate.cColumns = pdsSchema->ptsTables[dwTable].dwColumns; |
375 | jtTableCreate.tableid = NULL; | 390 | jtTableCreate.tableid = NULL; |
@@ -392,7 +407,7 @@ HRESULT EnsureSchema( | |||
392 | ReleaseNullStr(jtTableCreate.szTableName); | 407 | ReleaseNullStr(jtTableCreate.szTableName); |
393 | 408 | ||
394 | hr = FreeColumnCreateStruct(jtTableCreate.rgcolumncreate, jtTableCreate.cColumns); | 409 | hr = FreeColumnCreateStruct(jtTableCreate.rgcolumncreate, jtTableCreate.cColumns); |
395 | ExitOnFailure(hr, "Failed to free column create struct"); | 410 | EseExitOnFailure(hr, "Failed to free column create struct"); |
396 | jtTableCreate.rgcolumncreate = NULL; | 411 | jtTableCreate.rgcolumncreate = NULL; |
397 | } | 412 | } |
398 | else | 413 | else |
@@ -422,7 +437,7 @@ HRESULT EnsureSchema( | |||
422 | } | 437 | } |
423 | 438 | ||
424 | hr = EseEnsureColumn(jsSession, pdsSchema->ptsTables[dwTable].jtTable, pcsColumn->pszName, pcsColumn->jcColumnType, ulColumnSize, pcsColumn->fFixed, fNullable, &pcsColumn->jcColumn); | 439 | hr = EseEnsureColumn(jsSession, pdsSchema->ptsTables[dwTable].jtTable, pcsColumn->pszName, pcsColumn->jcColumnType, ulColumnSize, pcsColumn->fFixed, fNullable, &pcsColumn->jcColumn); |
425 | ExitOnFailure(hr, "Failed to create column %u of %ls table", dwColumn, pwzTableName); | 440 | EseExitOnFailure(hr, "Failed to create column %u of %ls table", dwColumn, pwzTableName); |
426 | } | 441 | } |
427 | } | 442 | } |
428 | } | 443 | } |
@@ -464,13 +479,13 @@ HRESULT DAPI EseEnsureDatabase( | |||
464 | // Sigh. JETblue requires Vista and up for the wide character version of this function, so we'll convert to ANSI before calling, | 479 | // Sigh. JETblue requires Vista and up for the wide character version of this function, so we'll convert to ANSI before calling, |
465 | // likely breaking all those with unicode characters in their path. | 480 | // likely breaking all those with unicode characters in their path. |
466 | hr = StrAnsiAllocString(&pszAnsiFile, pszFile, 0, CP_ACP); | 481 | hr = StrAnsiAllocString(&pszAnsiFile, pszFile, 0, CP_ACP); |
467 | ExitOnFailure(hr, "Failed converting database name to ansi"); | 482 | EseExitOnFailure(hr, "Failed converting database name to ansi"); |
468 | 483 | ||
469 | hr = PathGetDirectory(pszFile, &pszDir); | 484 | hr = PathGetDirectory(pszFile, &pszDir); |
470 | ExitOnFailure(hr, "Failed to get directory that will contain database file"); | 485 | EseExitOnFailure(hr, "Failed to get directory that will contain database file"); |
471 | 486 | ||
472 | hr = DirEnsureExists(pszDir, NULL); | 487 | hr = DirEnsureExists(pszDir, NULL); |
473 | ExitOnFailure(hr, "Failed to ensure directory exists for database: %ls", pszDir); | 488 | EseExitOnFailure(hr, "Failed to ensure directory exists for database: %ls", pszDir); |
474 | 489 | ||
475 | if (FileExistsEx(pszFile, NULL)) | 490 | if (FileExistsEx(pszFile, NULL)) |
476 | { | 491 | { |
@@ -498,7 +513,7 @@ HRESULT DAPI EseEnsureDatabase( | |||
498 | } | 513 | } |
499 | 514 | ||
500 | hr = EnsureSchema(*pjdbDb, jsSession, pdsSchema); | 515 | hr = EnsureSchema(*pjdbDb, jsSession, pdsSchema); |
501 | ExitOnFailure(hr, "Failed to ensure database schema matches expectations"); | 516 | EseExitOnFailure(hr, "Failed to ensure database schema matches expectations"); |
502 | 517 | ||
503 | LExit: | 518 | LExit: |
504 | ReleaseStr(pszDir); | 519 | ReleaseStr(pszDir); |
@@ -535,7 +550,7 @@ HRESULT DAPI EseCreateTable( | |||
535 | LPSTR pszAnsiTable = NULL; | 550 | LPSTR pszAnsiTable = NULL; |
536 | 551 | ||
537 | hr = StrAnsiAllocString(&pszAnsiTable, pszTable, 0, CP_ACP); | 552 | hr = StrAnsiAllocString(&pszAnsiTable, pszTable, 0, CP_ACP); |
538 | ExitOnFailure(hr, "Failed converting table name to ansi"); | 553 | EseExitOnFailure(hr, "Failed converting table name to ansi"); |
539 | 554 | ||
540 | jEr = JetCreateTableA(jsSession, jdbDb, pszAnsiTable, 100, 0, pjtTable); | 555 | jEr = JetCreateTableA(jsSession, jdbDb, pszAnsiTable, 100, 0, pjtTable); |
541 | ExitOnJetFailure(jEr, hr, "Failed to create table %s", pszAnsiTable); | 556 | ExitOnJetFailure(jEr, hr, "Failed to create table %s", pszAnsiTable); |
@@ -558,7 +573,7 @@ HRESULT DAPI EseOpenTable( | |||
558 | LPSTR pszAnsiTable = NULL; | 573 | LPSTR pszAnsiTable = NULL; |
559 | 574 | ||
560 | hr = StrAnsiAllocString(&pszAnsiTable, pszTable, 0, CP_ACP); | 575 | hr = StrAnsiAllocString(&pszAnsiTable, pszTable, 0, CP_ACP); |
561 | ExitOnFailure(hr, "Failed converting table name to ansi"); | 576 | EseExitOnFailure(hr, "Failed converting table name to ansi"); |
562 | 577 | ||
563 | jEr = JetOpenTableA(jsSession, jdbDb, pszAnsiTable, NULL, 0, 0, pjtTable); | 578 | jEr = JetOpenTableA(jsSession, jdbDb, pszAnsiTable, NULL, 0, 0, pjtTable); |
564 | ExitOnJetFailure(jEr, hr, "Failed to open table %s", pszAnsiTable); | 579 | ExitOnJetFailure(jEr, hr, "Failed to open table %s", pszAnsiTable); |
@@ -602,7 +617,7 @@ HRESULT DAPI EseEnsureColumn( | |||
602 | JET_COLUMNBASE jcdTempBase = { sizeof(JET_COLUMNBASE) }; | 617 | JET_COLUMNBASE jcdTempBase = { sizeof(JET_COLUMNBASE) }; |
603 | 618 | ||
604 | hr = StrAnsiAllocString(&pszAnsiColumnName, pszColumnName, 0, CP_ACP); | 619 | hr = StrAnsiAllocString(&pszAnsiColumnName, pszColumnName, 0, CP_ACP); |
605 | ExitOnFailure(hr, "Failed converting column name to ansi"); | 620 | EseExitOnFailure(hr, "Failed converting column name to ansi"); |
606 | 621 | ||
607 | jEr = JetGetTableColumnInfoA(jsSession, jtTable, pszAnsiColumnName, &jcdTempBase, sizeof(JET_COLUMNBASE), JET_ColInfoBase); | 622 | jEr = JetGetTableColumnInfoA(jsSession, jtTable, pszAnsiColumnName, &jcdTempBase, sizeof(JET_COLUMNBASE), JET_ColInfoBase); |
608 | if (JET_errSuccess == jEr) | 623 | if (JET_errSuccess == jEr) |
@@ -661,7 +676,7 @@ HRESULT DAPI EseGetColumn( | |||
661 | JET_COLUMNBASE jcdTempBase = { sizeof(JET_COLUMNBASE) }; | 676 | JET_COLUMNBASE jcdTempBase = { sizeof(JET_COLUMNBASE) }; |
662 | 677 | ||
663 | hr = StrAnsiAllocString(&pszAnsiColumnName, pszColumnName, 0, CP_ACP); | 678 | hr = StrAnsiAllocString(&pszAnsiColumnName, pszColumnName, 0, CP_ACP); |
664 | ExitOnFailure(hr, "Failed converting column name to ansi"); | 679 | EseExitOnFailure(hr, "Failed converting column name to ansi"); |
665 | 680 | ||
666 | jEr = JetGetTableColumnInfoA(jsSession, jtTable, pszAnsiColumnName, &jcdTempBase, sizeof(JET_COLUMNBASE), JET_ColInfoBase); | 681 | jEr = JetGetTableColumnInfoA(jsSession, jtTable, pszAnsiColumnName, &jcdTempBase, sizeof(JET_COLUMNBASE), JET_ColInfoBase); |
667 | if (JET_errSuccess == jEr) | 682 | if (JET_errSuccess == jEr) |
@@ -898,7 +913,7 @@ HRESULT DAPI EseGetColumnBinary( | |||
898 | __in JET_SESID jsSession, | 913 | __in JET_SESID jsSession, |
899 | __in ESE_TABLE_SCHEMA tsTable, | 914 | __in ESE_TABLE_SCHEMA tsTable, |
900 | __in DWORD dwColumn, | 915 | __in DWORD dwColumn, |
901 | __deref_out_bcount(*piBuffer) BYTE** ppbBuffer, | 916 | __deref_inout_bcount(*piBuffer) BYTE** ppbBuffer, |
902 | __inout SIZE_T* piBuffer | 917 | __inout SIZE_T* piBuffer |
903 | ) | 918 | ) |
904 | { | 919 | { |
@@ -916,12 +931,12 @@ HRESULT DAPI EseGetColumnBinary( | |||
916 | if (NULL == *ppbBuffer) | 931 | if (NULL == *ppbBuffer) |
917 | { | 932 | { |
918 | *ppbBuffer = reinterpret_cast<BYTE *>(MemAlloc(ulActualSize, FALSE)); | 933 | *ppbBuffer = reinterpret_cast<BYTE *>(MemAlloc(ulActualSize, FALSE)); |
919 | ExitOnNull(*ppbBuffer, hr, E_OUTOFMEMORY, "Failed to allocate memory for reading binary value column"); | 934 | EseExitOnNull(*ppbBuffer, hr, E_OUTOFMEMORY, "Failed to allocate memory for reading binary value column"); |
920 | } | 935 | } |
921 | else | 936 | else |
922 | { | 937 | { |
923 | *ppbBuffer = reinterpret_cast<BYTE *>(MemReAlloc(*ppbBuffer, ulActualSize, FALSE)); | 938 | *ppbBuffer = reinterpret_cast<BYTE *>(MemReAlloc(*ppbBuffer, ulActualSize, FALSE)); |
924 | ExitOnNull(*ppbBuffer, hr, E_OUTOFMEMORY, "Failed to reallocate memory for reading binary value column"); | 939 | EseExitOnNull(*ppbBuffer, hr, E_OUTOFMEMORY, "Failed to reallocate memory for reading binary value column"); |
925 | } | 940 | } |
926 | 941 | ||
927 | jEr = JetRetrieveColumn(jsSession, tsTable.jtTable, tsTable.pcsColumns[dwColumn].jcColumn, *ppbBuffer, ulActualSize, NULL, 0, NULL); | 942 | jEr = JetRetrieveColumn(jsSession, tsTable.jtTable, tsTable.pcsColumns[dwColumn].jcColumn, *ppbBuffer, ulActualSize, NULL, 0, NULL); |
@@ -1001,7 +1016,7 @@ HRESULT DAPI EseGetColumnString( | |||
1001 | ExitOnJetFailure(jEr, hr, "Failed to check size of string value from record"); | 1016 | ExitOnJetFailure(jEr, hr, "Failed to check size of string value from record"); |
1002 | 1017 | ||
1003 | hr = StrAlloc(ppszValue, ulActualSize); | 1018 | hr = StrAlloc(ppszValue, ulActualSize); |
1004 | ExitOnFailure(hr, "Failed to allocate string while retrieving column value"); | 1019 | EseExitOnFailure(hr, "Failed to allocate string while retrieving column value"); |
1005 | 1020 | ||
1006 | jEr = JetRetrieveColumn(jsSession, tsTable.jtTable, tsTable.pcsColumns[dwColumn].jcColumn, *ppszValue, ulActualSize, NULL, 0, NULL); | 1021 | jEr = JetRetrieveColumn(jsSession, tsTable.jtTable, tsTable.pcsColumns[dwColumn].jcColumn, *ppszValue, ulActualSize, NULL, 0, NULL); |
1007 | ExitOnJetFailure(jEr, hr, "Failed to retrieve string value from record"); | 1022 | ExitOnJetFailure(jEr, hr, "Failed to retrieve string value from record"); |
@@ -1023,7 +1038,7 @@ HRESULT DAPI EseBeginQuery( | |||
1023 | HRESULT hr = S_OK; | 1038 | HRESULT hr = S_OK; |
1024 | 1039 | ||
1025 | *peqhHandle = static_cast<ESE_QUERY*>(MemAlloc(sizeof(ESE_QUERY), TRUE)); | 1040 | *peqhHandle = static_cast<ESE_QUERY*>(MemAlloc(sizeof(ESE_QUERY), TRUE)); |
1026 | ExitOnNull(*peqhHandle, hr, E_OUTOFMEMORY, "Failed to allocate new query"); | 1041 | EseExitOnNull(*peqhHandle, hr, E_OUTOFMEMORY, "Failed to allocate new query"); |
1027 | 1042 | ||
1028 | ESE_QUERY *peqHandle = static_cast<ESE_QUERY *>(*peqhHandle); | 1043 | ESE_QUERY *peqHandle = static_cast<ESE_QUERY *>(*peqhHandle); |
1029 | peqHandle->qtQueryType = qtQueryType; | 1044 | peqHandle->qtQueryType = qtQueryType; |
@@ -1050,7 +1065,7 @@ HRESULT DAPI SetQueryColumn( | |||
1050 | if (peqHandle->dwColumns == countof(peqHandle->pvData)) | 1065 | if (peqHandle->dwColumns == countof(peqHandle->pvData)) |
1051 | { | 1066 | { |
1052 | hr = E_NOTIMPL; | 1067 | hr = E_NOTIMPL; |
1053 | ExitOnFailure(hr, "Dutil hasn't implemented support for queries of more than %d columns", countof(peqHandle->pvData)); | 1068 | EseExitOnFailure(hr, "Dutil hasn't implemented support for queries of more than %d columns", countof(peqHandle->pvData)); |
1054 | } | 1069 | } |
1055 | 1070 | ||
1056 | if (0 == peqHandle->dwColumns) // If it's the first column, start a new key | 1071 | if (0 == peqHandle->dwColumns) // If it's the first column, start a new key |
@@ -1065,7 +1080,7 @@ HRESULT DAPI SetQueryColumn( | |||
1065 | if (ESE_QUERY_EXACT != peqHandle->qtQueryType) | 1080 | if (ESE_QUERY_EXACT != peqHandle->qtQueryType) |
1066 | { | 1081 | { |
1067 | peqHandle->pvData[peqHandle->dwColumns] = MemAlloc(cbData, FALSE); | 1082 | peqHandle->pvData[peqHandle->dwColumns] = MemAlloc(cbData, FALSE); |
1068 | ExitOnNull(peqHandle->pvData[peqHandle->dwColumns], hr, E_OUTOFMEMORY, "Failed to allocate memory"); | 1083 | EseExitOnNull(peqHandle->pvData[peqHandle->dwColumns], hr, E_OUTOFMEMORY, "Failed to allocate memory"); |
1069 | 1084 | ||
1070 | memcpy(peqHandle->pvData[peqHandle->dwColumns], pvData, cbData); | 1085 | memcpy(peqHandle->pvData[peqHandle->dwColumns], pvData, cbData); |
1071 | 1086 | ||
@@ -1108,7 +1123,7 @@ HRESULT DAPI EseSetQueryColumnBinary( | |||
1108 | } | 1123 | } |
1109 | 1124 | ||
1110 | hr = SetQueryColumn(eqhHandle, reinterpret_cast<const void *>(pbBuffer), static_cast<DWORD>(cbBuffer), jGrb); | 1125 | hr = SetQueryColumn(eqhHandle, reinterpret_cast<const void *>(pbBuffer), static_cast<DWORD>(cbBuffer), jGrb); |
1111 | ExitOnFailure(hr, "Failed to set value of query colum (as binary) to:"); | 1126 | EseExitOnFailure(hr, "Failed to set value of query colum (as binary) to:"); |
1112 | 1127 | ||
1113 | LExit: | 1128 | LExit: |
1114 | return hr; | 1129 | return hr; |
@@ -1137,7 +1152,7 @@ HRESULT DAPI EseSetQueryColumnDword( | |||
1137 | } | 1152 | } |
1138 | 1153 | ||
1139 | hr = SetQueryColumn(eqhHandle, (const void *)&dwData, sizeof(DWORD), jGrb); | 1154 | hr = SetQueryColumn(eqhHandle, (const void *)&dwData, sizeof(DWORD), jGrb); |
1140 | ExitOnFailure(hr, "Failed to set value of query colum (as dword) to: %u", dwData); | 1155 | EseExitOnFailure(hr, "Failed to set value of query colum (as dword) to: %u", dwData); |
1141 | 1156 | ||
1142 | LExit: | 1157 | LExit: |
1143 | return hr; | 1158 | return hr; |
@@ -1167,7 +1182,7 @@ HRESULT DAPI EseSetQueryColumnBool( | |||
1167 | } | 1182 | } |
1168 | 1183 | ||
1169 | hr = SetQueryColumn(eqhHandle, (const void *)&bByte, 1, jGrb); | 1184 | hr = SetQueryColumn(eqhHandle, (const void *)&bByte, 1, jGrb); |
1170 | ExitOnFailure(hr, "Failed to set value of query colum (as bool) to: %s", fValue ? "TRUE" : "FALSE"); | 1185 | EseExitOnFailure(hr, "Failed to set value of query colum (as bool) to: %s", fValue ? "TRUE" : "FALSE"); |
1171 | 1186 | ||
1172 | LExit: | 1187 | LExit: |
1173 | return hr; | 1188 | return hr; |
@@ -1200,7 +1215,7 @@ HRESULT DAPI EseSetQueryColumnString( | |||
1200 | } | 1215 | } |
1201 | 1216 | ||
1202 | hr = SetQueryColumn(eqhHandle, (const void *)pszString, dwStringSize, jGrb); | 1217 | hr = SetQueryColumn(eqhHandle, (const void *)pszString, dwStringSize, jGrb); |
1203 | ExitOnFailure(hr, "Failed to set value of query colum (as string) to: %ls", pszString); | 1218 | EseExitOnFailure(hr, "Failed to set value of query colum (as string) to: %ls", pszString); |
1204 | 1219 | ||
1205 | LExit: | 1220 | LExit: |
1206 | return hr; | 1221 | return hr; |