Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

824 lines
21 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. JetWalk.cxx
  5. Abstract:
  6. Dumps a Jet database
  7. Author:
  8. Rajivendra Nath (RajNath) 18-Aug-1989
  9. Revision History:
  10. David Orbits (davidor) 6-March-1997
  11. Revised for NTFRS database and major rework.
  12. --*/
  13. #include <windows.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <esent.h>
  17. #define BUFFER_SIZE 1024
  18. JET_ERR DbStats( JET_SESID jsesid, char * szDbName );
  19. void TblStats( JET_SESID jsesid, JET_DBID jdbid, int iTable, char *szTblName, unsigned long *pcPages );
  20. void DumpAttributes( JET_SESID jsesid, JET_COLUMNLIST colinfo );
  21. void DumpIndex( JET_SESID jsesid, JET_INDEXLIST colinfo );
  22. void DBDumpTable( JET_SESID jsesid,JET_TABLEID jtid, char* rgb);
  23. void DBDumpRecord( JET_SESID jsesid,JET_TABLEID jtid);
  24. typedef char* SZ;
  25. typedef ULONG CCH;
  26. typedef struct
  27. {
  28. char AttribName[64];
  29. JET_COLUMNID colid;
  30. JET_COLTYP coltyp;
  31. JET_GRBIT grbit;
  32. BOOL Display;
  33. }ATTRIBLIST;
  34. typedef struct
  35. {
  36. char AttribName[64];
  37. char key[256];
  38. JET_COLUMNID colid;
  39. JET_COLTYP coltyp;
  40. JET_GRBIT grbit;
  41. BOOL Display;
  42. }INDEXLIST;
  43. DWORD List[1024];
  44. ATTRIBLIST AList[1024];
  45. DWORD AListUsed;
  46. INDEXLIST IList[1024];
  47. DWORD IListUsed;
  48. BOOL NeedShutdown = FALSE;
  49. char *JetColumnTypeNames[] = {
  50. "coltypNil ",
  51. "coltypBit ",
  52. "coltypUnsignedByte",
  53. "coltypShort ",
  54. "coltypLong ",
  55. "coltypCurrency ",
  56. "coltypIEEESingle ",
  57. "coltypIEEEDouble ",
  58. "coltypDateTime ",
  59. "coltypBinary ",
  60. "coltypText ",
  61. "coltypLongBinary ",
  62. "coltypLongText ",
  63. "coltypMax "};
  64. #define TIMECALL(CallX) \
  65. { \
  66. DWORD start,end; \
  67. start = GetTickCount(); \
  68. CallX; \
  69. end = GetTickCount(); \
  70. printf("[%5d MilliSec] <<%s>> \n",end-start,#CallX);\
  71. }
  72. void
  73. ReadSzFromRegKey(SZ szKey, SZ szValue, SZ szBuf, CCH cchBuf)
  74. {
  75. HKEY hkey = NULL;
  76. // User specified that we use the regular registry variables.
  77. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &hkey) == ERROR_SUCCESS)
  78. {
  79. DWORD dwType;
  80. ULONG cb;
  81. cb = cchBuf;
  82. if ((RegQueryValueEx(hkey, szValue, 0, &dwType, (LPBYTE) szBuf, &cb)
  83. == ERROR_SUCCESS)
  84. && cb > 0 && (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
  85. {
  86. return;
  87. }
  88. }
  89. printf("Couldn't read value %s from registry key %s.", szValue, szKey);
  90. exit(1);
  91. }
  92. BOOL fDumpRecords=FALSE;
  93. BOOL fDumpAll=FALSE;
  94. BOOL fDumpColId=FALSE;
  95. ULONG
  96. _cdecl
  97. main(
  98. IN INT argc,
  99. IN PCHAR argv[]
  100. )
  101. {
  102. JET_ERR jerr;
  103. JET_INSTANCE jinstance;
  104. JET_SESID jsesid;
  105. char szBuffer[BUFFER_SIZE];
  106. char * szUserName = "admin";
  107. char * szPassword = "password";
  108. int nTotalLen;
  109. jerr = JetSetSystemParameter(&jinstance, 0, JET_paramRecovery, 0, "off");
  110. if (jerr != JET_errSuccess) {
  111. printf( "jetwalk: JetSetSystemParameter returned %d\n", jerr );
  112. return jerr;
  113. }
  114. //
  115. // Open JET session
  116. //
  117. TIMECALL(jerr = JetInit(&jinstance));
  118. if (jerr != JET_errSuccess) {
  119. printf("JetInit error: %d\n", jerr);
  120. return jerr;
  121. }
  122. //
  123. // If we fail after here, our caller should go through full shutdown
  124. // so JetTerm will be called to release any file locks
  125. //
  126. NeedShutdown = TRUE;
  127. if ((jerr = JetBeginSession(jinstance, &jsesid, NULL, NULL))
  128. != JET_errSuccess) {
  129. printf("JetBeginSession error: %d\n", jerr);
  130. return jerr;
  131. }
  132. if (argc<2) {
  133. printf("Usage:%0 [/R] <JetDataBaseName>");
  134. }
  135. char* FileName="e:\\ntfrs.jdb";
  136. for (int i=1;i<argc;i++) {
  137. if (argv[i][0]=='/') {
  138. switch(tolower(argv[i][1])) {
  139. case 'r': fDumpRecords= TRUE; if (isupper(argv[i][1])) fDumpAll=TRUE; break;
  140. case 'c': fDumpColId=TRUE;break;
  141. }
  142. }
  143. else
  144. {
  145. FileName=argv[i];
  146. }
  147. }
  148. printf( "-------------------------------------\n" );
  149. printf( "DATABASE: %s\n", FileName );
  150. printf( "-------------------------------------\n" );
  151. // Attach database
  152. jerr = JetAttachDatabase(jsesid, FileName, 0);
  153. if (jerr == JET_errSuccess) {
  154. // Dump the database
  155. jerr = DbStats(jsesid, FileName);
  156. jerr = JetDetachDatabase(jsesid, FileName );
  157. if (jerr != JET_errSuccess) {
  158. printf( "jetwalk: JetDetachDatabase returned %d\n", jerr );
  159. }
  160. } else {
  161. printf("jetwalk: JetAttachDatabase (%s) returned %d\n", FileName, jerr);
  162. }
  163. TIMECALL(jerr = JetEndSession(jsesid, 0 ));
  164. if (jerr != JET_errSuccess) {
  165. printf( "jetwalk: JetEndSession returned %d\n", jerr );
  166. }
  167. jerr = JetTerm( jinstance );
  168. if (jerr != JET_errSuccess) {
  169. printf( "jetwalk: JetTerm returned %d\n", jerr );
  170. }
  171. return jerr;
  172. }
  173. JET_ERR DbStats( JET_SESID jsesid, char * szDbName )
  174. {
  175. JET_ERR jerr;
  176. JET_DBID jdbid;
  177. JET_OBJECTLIST jobjectlist;
  178. unsigned long iTable;
  179. unsigned long cTotalPages = 0;
  180. unsigned long cPages;
  181. //
  182. // Open database
  183. //
  184. jerr = JetOpenDatabase( jsesid, szDbName, "", &jdbid, JET_bitDbReadOnly );
  185. if (jerr != JET_errSuccess) {
  186. printf( "jetwalk: JetOpenDatabase returned %d\n", jerr );
  187. goto CLOSEDB;
  188. }
  189. jerr = JetGetObjectInfo(
  190. jsesid,
  191. jdbid,
  192. JET_objtypTable,
  193. NULL,
  194. NULL,
  195. &jobjectlist,
  196. sizeof(jobjectlist),
  197. JET_ObjInfoListNoStats );
  198. if (jerr != JET_errSuccess) {
  199. printf( "jetwalk: JetGetObjectInfo returned %d\n", jerr );
  200. goto CLOSEDB;
  201. }
  202. printf( "Database contains %d tables\n", jobjectlist.cRecord );
  203. iTable = 1;
  204. jerr = JetMove( jsesid, jobjectlist.tableid, JET_MoveFirst, 0 );
  205. while( jerr == JET_errSuccess ) {
  206. unsigned long cb;
  207. unsigned char rgb[1024];
  208. jerr = JetRetrieveColumn(
  209. jsesid,
  210. jobjectlist.tableid,
  211. jobjectlist.columnidobjectname,
  212. rgb,
  213. sizeof(rgb),
  214. &cb,
  215. 0, NULL );
  216. if (jerr != JET_errSuccess) {
  217. printf( "jetwalk: JetMove returned %d\n", jerr );
  218. goto CLOSEDB;
  219. }
  220. rgb[cb] = '\0';
  221. TblStats( jsesid, jdbid, iTable++, (char *)rgb, &cPages );
  222. if (fDumpRecords) {
  223. DBDumpTable(jsesid,jdbid,(char *)rgb);
  224. }
  225. cTotalPages += cPages;
  226. jerr = JetMove( jsesid, jobjectlist.tableid, JET_MoveNext, 0 );
  227. }
  228. if (jerr != JET_errNoCurrentRecord) {
  229. printf( "jetwalk: JetMove returned %d\n", jerr );
  230. goto CLOSEDB;
  231. }
  232. if ( iTable != jobjectlist.cRecord+1 ) {
  233. printf( "jetwalk: # of rows didn't match what JET said there were" );
  234. goto CLOSEDB;
  235. }
  236. printf( "Total pages owned in database = %d\n", cTotalPages );
  237. CLOSEDB:
  238. jerr = JetCloseDatabase( jsesid, jdbid, 0 );
  239. if (jerr != JET_errSuccess) {
  240. printf( "jetwalk: JetCloseDatabase returned %d\n", jerr );
  241. }
  242. return jerr;
  243. }
  244. void TblStats(
  245. JET_SESID jsesid,
  246. JET_DBID jdbid,
  247. int iTable,
  248. char *szTblName,
  249. unsigned long *pcPages
  250. )
  251. {
  252. JET_ERR jerr;
  253. JET_TABLEID jtableid;
  254. JET_OBJECTINFO jobjectinfo;
  255. JET_COLUMNLIST jcolumnlist;
  256. JET_INDEXLIST jindexlist;
  257. unsigned char rgb[4096];
  258. unsigned long *pul = (unsigned long *)rgb;
  259. printf( "-------------------------------------\n" );
  260. printf( "Table #%d: %s\n", iTable, szTblName );
  261. printf( "-------------------------------------\n" );
  262. jerr = JetOpenTable( jsesid, jdbid, szTblName, NULL, 0, JET_bitTableReadOnly, &jtableid );
  263. if (jerr != JET_errSuccess) {
  264. printf( "jetwalk: JetOpenTable returned %d\n", jerr );
  265. goto CLOSE_TABLE;
  266. }
  267. jerr = JetComputeStats( jsesid, jtableid );
  268. if (jerr != JET_errSuccess) {
  269. printf( "jetwalk: JetComputeStats returned %d\n", jerr );
  270. //workaround goto CLOSE_TABLE;
  271. }
  272. jerr = JetGetTableInfo( jsesid, jtableid, &jobjectinfo, sizeof(jobjectinfo), JET_TblInfo );
  273. if (jerr != JET_errSuccess) {
  274. printf( "jetwalk: JetGetTableInfo returned %d\n", jerr );
  275. goto CLOSE_TABLE;
  276. }
  277. printf( "cRecord = %d\n", jobjectinfo.cRecord );
  278. printf( "cPage = %d\n", jobjectinfo.cPage );
  279. //
  280. // bugbug - result seems wrong -- check the call.
  281. //
  282. jerr = JetGetTableInfo( jsesid, jtableid, rgb, sizeof(rgb), JET_TblInfoSpaceUsage );
  283. if (jerr != JET_errSuccess) {
  284. printf( "jetwalk: JetGetTableInfo returned %d\n", jerr );
  285. goto CLOSE_TABLE;
  286. }
  287. printf( "cTotalPagesOwned = %d\n", pul[0] );
  288. printf( "cTotalPagesAvail = %d\n", pul[1] );
  289. *pcPages = pul[0];
  290. jerr = JetGetTableColumnInfo( jsesid, jtableid, NULL, &jcolumnlist, sizeof(jcolumnlist), JET_ColInfoList );
  291. if (jerr != JET_errSuccess) {
  292. printf( "jetwalk: JetGetTableColumnInfo returned %d\n", jerr );
  293. goto CLOSE_TABLE;
  294. }
  295. DumpAttributes( jsesid, jcolumnlist);
  296. jerr = JetCloseTable( jsesid, jcolumnlist.tableid );
  297. if (jerr != JET_errSuccess) {
  298. printf( "jetwalk: JetCloseTable returned %d\n", jerr );
  299. goto CLOSE_TABLE;
  300. }
  301. jerr = JetGetTableIndexInfo( jsesid, jtableid, NULL, &jindexlist, sizeof(jindexlist), JET_IdxInfoList );
  302. if (jerr != JET_errSuccess) {
  303. printf( "jetwalk: JetGetTableIndexInfo returned %d\n", jerr );
  304. goto CLOSE_TABLE;
  305. }
  306. DumpIndex( jsesid, jindexlist);
  307. jerr = JetCloseTable( jsesid, jindexlist.tableid );
  308. if (jerr != JET_errSuccess) {
  309. printf( "jetwalk: JetCloseTable returned %d\n", jerr );
  310. goto CLOSE_TABLE;
  311. }
  312. CLOSE_TABLE:
  313. jerr = JetCloseTable( jsesid, jtableid );
  314. if (jerr != JET_errSuccess) {
  315. printf( "jetwalk: JetCloseTable returned %d\n", jerr );
  316. }
  317. }
  318. void
  319. DumpIndex(
  320. JET_SESID jsesid,
  321. JET_INDEXLIST colinfo
  322. )
  323. {
  324. JET_ERR jerr;
  325. unsigned long iRecord;
  326. JET_RETRIEVECOLUMN rcarray[5];
  327. DWORD i=0;
  328. /*
  329. typedef struct
  330. {
  331. unsigned long cbStruct;
  332. JET_TABLEID tableid;
  333. unsigned long cRecord;
  334. JET_COLUMNID columnidPresentationOrder;
  335. JET_COLUMNID columnidcolumnname;
  336. JET_COLUMNID columnidcolumnid;
  337. JET_COLUMNID columnidcoltyp;
  338. JET_COLUMNID columnidCountry;
  339. JET_COLUMNID columnidLangid;
  340. JET_COLUMNID columnidCp;
  341. JET_COLUMNID columnidCollate;
  342. JET_COLUMNID columnidcbMax;
  343. JET_COLUMNID columnidgrbit;
  344. JET_COLUMNID columnidDefault;
  345. JET_COLUMNID columnidBaseTableName;
  346. JET_COLUMNID columnidBaseColumnName;
  347. JET_COLUMNID columnidDefinitionName;
  348. } JET_COLUMNLIST;
  349. */
  350. /*
  351. typedef struct
  352. {
  353. unsigned long cbStruct;
  354. JET_TABLEID tableid;
  355. unsigned long cRecord;
  356. JET_COLUMNID columnidindexname;
  357. JET_COLUMNID columnidgrbitIndex;
  358. JET_COLUMNID columnidcKey;
  359. JET_COLUMNID columnidcEntry;
  360. JET_COLUMNID columnidcPage;
  361. JET_COLUMNID columnidcColumn;
  362. JET_COLUMNID columnidiColumn;
  363. JET_COLUMNID columnidcolumnid;
  364. JET_COLUMNID columnidcoltyp;
  365. JET_COLUMNID columnidCountry;
  366. JET_COLUMNID columnidLangid;
  367. JET_COLUMNID columnidCp;
  368. JET_COLUMNID columnidCollate;
  369. JET_COLUMNID columnidgrbitColumn;
  370. JET_COLUMNID columnidcolumnname;
  371. } JET_INDEXLIST;
  372. */
  373. printf("-------------------\n INDEXES \n-------------------\n");
  374. jerr = JetMove( jsesid, colinfo.tableid, JET_MoveFirst, 0 );
  375. IListUsed = 0;
  376. while( jerr == JET_errSuccess ) {
  377. unsigned long cb;
  378. ZeroMemory(rcarray, sizeof(rcarray));
  379. rcarray[4].pvData = IList[IListUsed].AttribName;
  380. rcarray[4].cbData = sizeof(IList[0].AttribName);
  381. rcarray[4].columnid = colinfo.columnidindexname;
  382. rcarray[4].itagSequence = 1;
  383. rcarray[1].pvData = &IList[IListUsed].colid;
  384. rcarray[1].cbData = sizeof(IList[0].colid);
  385. rcarray[1].columnid = colinfo.columnidcolumnid;
  386. rcarray[1].itagSequence = 1;
  387. rcarray[2].pvData = &IList[IListUsed].coltyp;
  388. rcarray[2].cbData = sizeof(IList[0].coltyp);
  389. rcarray[2].columnid = colinfo.columnidcoltyp;
  390. rcarray[2].itagSequence = 1;
  391. rcarray[3].pvData = &IList[IListUsed].grbit;
  392. rcarray[3].cbData = sizeof(IList[0].grbit);
  393. rcarray[3].columnid = colinfo.columnidgrbitIndex;
  394. rcarray[3].itagSequence = 1;
  395. rcarray[0].pvData = &IList[IListUsed].key;
  396. rcarray[0].cbData = sizeof(IList[0].key);
  397. rcarray[0].columnid = colinfo.columnidcKey;
  398. rcarray[0].itagSequence = 1;
  399. jerr = JetRetrieveColumns(jsesid, colinfo.tableid, rcarray, 5 );
  400. jerr = JetMove( jsesid, colinfo.tableid, JET_MoveNext, 0 );
  401. IListUsed++;
  402. }
  403. for (i=0;i<IListUsed;i++) {
  404. printf("%25s %s %08x %3d\n",
  405. IList[i].AttribName,
  406. JetColumnTypeNames[IList[i].coltyp],
  407. IList[i].grbit,
  408. fDumpColId?IList[i].colid:0);
  409. }
  410. }
  411. void
  412. DumpAttributes(
  413. JET_SESID jsesid,
  414. JET_COLUMNLIST colinfo
  415. )
  416. {
  417. JET_ERR jerr;
  418. unsigned long iRecord;
  419. JET_RETRIEVECOLUMN rcarray[4];
  420. DWORD i=0;
  421. unsigned long cb;
  422. /*
  423. typedef struct
  424. {
  425. unsigned long cbStruct;
  426. JET_TABLEID tableid;
  427. unsigned long cRecord;
  428. JET_COLUMNID columnidPresentationOrder;
  429. JET_COLUMNID columnidcolumnname;
  430. JET_COLUMNID columnidcolumnid;
  431. JET_COLUMNID columnidcoltyp;
  432. JET_COLUMNID columnidCountry;
  433. JET_COLUMNID columnidLangid;
  434. JET_COLUMNID columnidCp;
  435. JET_COLUMNID columnidCollate;
  436. JET_COLUMNID columnidcbMax;
  437. JET_COLUMNID columnidgrbit;
  438. JET_COLUMNID columnidDefault;
  439. JET_COLUMNID columnidBaseTableName;
  440. JET_COLUMNID columnidBaseColumnName;
  441. JET_COLUMNID columnidDefinitionName;
  442. } JET_COLUMNLIST;
  443. */
  444. jerr = JetMove( jsesid, colinfo.tableid, JET_MoveFirst, 0 );
  445. AListUsed = 0;
  446. while( jerr == JET_errSuccess ) {
  447. ZeroMemory(rcarray, sizeof(rcarray));
  448. rcarray[0].pvData = AList[AListUsed].AttribName;
  449. rcarray[0].cbData = sizeof(AList[0].AttribName);
  450. rcarray[0].columnid = colinfo.columnidcolumnname;
  451. rcarray[0].itagSequence = 1;
  452. rcarray[1].pvData = &AList[AListUsed].colid;
  453. rcarray[1].cbData = sizeof(AList[0].colid);
  454. rcarray[1].columnid = colinfo.columnidcolumnid;
  455. rcarray[1].itagSequence = 1;
  456. rcarray[2].pvData = &AList[AListUsed].coltyp;
  457. rcarray[2].cbData = sizeof(AList[0].coltyp);
  458. rcarray[2].columnid = colinfo.columnidcoltyp;
  459. rcarray[2].itagSequence = 1;
  460. rcarray[3].pvData = &AList[AListUsed].grbit;
  461. rcarray[3].cbData = sizeof(AList[0].grbit);
  462. rcarray[3].columnid = colinfo.columnidgrbit;
  463. rcarray[3].itagSequence = 1;
  464. jerr = JetRetrieveColumns(jsesid, colinfo.tableid, rcarray, 4);
  465. jerr = JetMove( jsesid, colinfo.tableid, JET_MoveNext, 0 );
  466. AListUsed++;
  467. }
  468. int next=0;
  469. for (i=0;i<AListUsed;i++)
  470. {
  471. printf("%25s %s %08x %3d\n",
  472. AList[i].AttribName,
  473. JetColumnTypeNames[AList[i].coltyp],
  474. AList[i].grbit,
  475. fDumpColId?AList[i].colid:0);
  476. List[next]=i;
  477. AList[i].Display=TRUE;
  478. //
  479. // If it's a favorite stick it out first in the record dump.
  480. //
  481. if (strcmp(AList[i].AttribName,"FileName")==0) {
  482. List[next] = List[0]; List[0] = i;
  483. }
  484. else if (strcmp(AList[i].AttribName,"VersionNumber")==0) {
  485. List[next] = List[1]; List[1]=i;
  486. }
  487. else if (strcmp(AList[i].AttribName,"FileGuid")==0) {
  488. List[next] = List[2]; List[2]=i;
  489. }
  490. else if (strcmp(AList[i].AttribName,"FileID")==0) {
  491. List[next] = List[3]; List[3]=i;
  492. }
  493. else if (strcmp(AList[i].AttribName,"EventTime")==0) {
  494. List[next] = List[4]; List[4]=i;
  495. }
  496. else if (strcmp(AList[i].AttribName,"FileWriteTime")==0) {
  497. List[next] = List[5]; List[5]=i;
  498. }
  499. else if (strcmp(AList[i].AttribName,"ParentGuid")==0) {
  500. List[next] = List[6]; List[6]=i;
  501. }
  502. else if (strcmp(AList[i].AttribName,"ParentFileID")==0) {
  503. List[next] = List[7]; List[7]=i;
  504. }
  505. next += 1;
  506. }
  507. }
  508. void DBDumpTable(
  509. JET_SESID jsesid,
  510. JET_DBID jdbid,
  511. char * szTbName
  512. )
  513. {
  514. JET_ERR jerr;
  515. JET_TABLEID jtid;
  516. jerr = JetOpenTable(jsesid, jdbid, szTbName, NULL, 0, 0, &jtid);
  517. if (jerr != JET_errSuccess) {
  518. printf( "DBDumpTable: JetOpenTable returned %d\n", jerr );
  519. goto CLOSE_TABLE;
  520. }
  521. jerr = JetMove( jsesid, jtid, JET_MoveFirst, 0 );
  522. while (!jerr) {
  523. DBDumpRecord( jsesid,jtid);
  524. jerr = JetMove( jsesid, jtid, JET_MoveNext, 0 );
  525. }
  526. CLOSE_TABLE:
  527. jerr = JetCloseTable( jsesid, jtid );
  528. if (jerr != JET_errSuccess) {
  529. printf( "DBDumpTable: JetCloseTable returned %d\n", jerr );
  530. }
  531. return;
  532. }
  533. char*
  534. PVoidToStr(
  535. PVOID obuff,
  536. JET_COLTYP coltyp,
  537. DWORD cbActual
  538. )
  539. {
  540. static char buff[512];
  541. ULONG data;
  542. LONGLONG lidata;
  543. ZeroMemory(buff,sizeof(buff));
  544. switch (coltyp) {
  545. case JET_coltypNil:
  546. sprintf(buff,"%s","NULL ");
  547. break;
  548. case JET_coltypBit:
  549. data = (ULONG) *(PCHAR)obuff;
  550. sprintf(buff," %d ", data);
  551. break;
  552. case JET_coltypUnsignedByte:
  553. sprintf(buff," %d ", *(DWORD*)obuff);
  554. break;
  555. case JET_coltypShort:
  556. sprintf(buff," %d ", *(DWORD*)obuff);
  557. break;
  558. case JET_coltypLong:
  559. sprintf(buff," %d ", *( DWORD *) obuff);
  560. break;
  561. case JET_coltypCurrency:
  562. CopyMemory(&lidata, obuff, 8);
  563. sprintf(buff," %12Ld ", lidata);
  564. break;
  565. case JET_coltypIEEESingle:
  566. sprintf(buff," %s ", "???");
  567. break;
  568. case JET_coltypIEEEDouble:
  569. sprintf(buff," %s ", "???");
  570. break;
  571. case JET_coltypDateTime:
  572. CopyMemory(&lidata, obuff, 8);
  573. sprintf(buff," %12Ld ", lidata);
  574. break;
  575. case JET_coltypBinary:
  576. sprintf(buff," %s ", "???");
  577. break;
  578. case JET_coltypText:
  579. sprintf(buff," %*.*ws ",cbActual, cbActual, ( WCHAR *) obuff);
  580. //sprintf(buff," %25ws ", (WCHAR*)obuff);
  581. break;
  582. case JET_coltypLongBinary:
  583. sprintf(buff," %25ws ", "???");
  584. break;
  585. case JET_coltypLongText:
  586. sprintf(buff," %25ws ", (WCHAR*)obuff);
  587. break;
  588. case JET_coltypMax:
  589. sprintf(buff," %s ", "???");
  590. break;
  591. default:
  592. sprintf(buff,"UNKNOWN %d ", coltyp);
  593. }
  594. return buff;
  595. }
  596. void DBDumpRecord( JET_SESID jsesid,JET_TABLEID jtid)
  597. {
  598. JET_RETINFO ri;
  599. DWORD i;
  600. char obuff[2048];
  601. JET_ERR jerr;
  602. DWORD cbActual;
  603. char recbuff[2048];
  604. char* ptr=recbuff;
  605. ZeroMemory(&ri,sizeof(ri));
  606. for (i=0;i<AListUsed;i++)
  607. {
  608. if (!fDumpAll && !AList[List[i]].Display) {
  609. continue;
  610. }
  611. jerr = JetRetrieveColumn (
  612. jsesid,
  613. jtid,
  614. AList[List[i]].colid,
  615. obuff,
  616. sizeof(obuff),
  617. &cbActual,
  618. 0,
  619. NULL);
  620. if (jerr != 0) {
  621. continue;
  622. }
  623. ptr += sprintf(ptr,"%s = %s",
  624. AList[List[i]].AttribName,
  625. PVoidToStr(obuff,AList[List[i]].coltyp,cbActual));
  626. }
  627. *ptr='\0';
  628. printf(">>%s\n",recbuff);
  629. }