mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-05-17 05:59:32 +08:00
patch from gb@hugo.westfalen.de
This commit is contained in:
parent
6714088c27
commit
282902b6e3
@ -121,4 +121,8 @@ extern MdbTableDef *mdb_read_table(MdbCatalogEntry *entry);
|
|||||||
|
|
||||||
/* data.c */
|
/* data.c */
|
||||||
extern void mdb_data_dump(MdbTableDef *table);
|
extern void mdb_data_dump(MdbTableDef *table);
|
||||||
|
|
||||||
|
/* dump.c */
|
||||||
|
void buffer_dump(const char* buf, int start, int end);
|
||||||
|
|
||||||
#endif /* _mdbtools_h_ */
|
#endif /* _mdbtools_h_ */
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
INC = -I ../include `glib-config --cflags`
|
INC = -I ../include `glib-config --cflags`
|
||||||
OBJS = catalog.o mem.o file.o kkd.o table.o data.o
|
OBJS = catalog.o mem.o file.o kkd.o table.o data.o dump.o
|
||||||
|
|
||||||
all: libmdb
|
all: libmdb
|
||||||
|
|
||||||
|
@ -31,16 +31,32 @@ int row_start, row_end;
|
|||||||
int fixed_cols_found, var_cols_found;
|
int fixed_cols_found, var_cols_found;
|
||||||
int col_start, len;
|
int col_start, len;
|
||||||
int eod; /* end of data */
|
int eod; /* end of data */
|
||||||
|
int delflag, lookupflag;
|
||||||
|
|
||||||
for (pg_num=1;pg_num<=table->num_pgs;pg_num++) {
|
for (pg_num=1;pg_num<=table->num_pgs;pg_num++) {
|
||||||
mdb_read_pg(mdb,table->first_data_pg + pg_num);
|
mdb_read_pg(mdb,table->first_data_pg + pg_num);
|
||||||
rows = mdb_get_int16(mdb,8);
|
rows = mdb_get_int16(mdb,8);
|
||||||
fprintf(stdout,"Rows on page %d: %d\n", pg_num, rows);
|
fprintf(stdout,"Rows on page %d: %d\n",
|
||||||
|
pg_num + table->first_data_pg,
|
||||||
|
rows);
|
||||||
row_end=2047;
|
row_end=2047;
|
||||||
for (i=0;i<rows;i++) {
|
for (i=0;i<rows;i++) {
|
||||||
row_start = mdb_get_int16(mdb,10+i*2);
|
row_start = mdb_get_int16(mdb,10+i*2);
|
||||||
fprintf(stdout,"Pg %d Row %d bytes %d to %d\n", pg_num, i, row_start, row_end);
|
delflag = lookupflag = 0;
|
||||||
|
if (row_start & 0x8000) delflag++;
|
||||||
|
if (row_start & 0x4000) lookupflag++;
|
||||||
|
row_start &= 0x0FFF; /* remove flags */
|
||||||
|
fprintf(stdout,"Pg %d Row %d bytes %d to %d %s %s\n",
|
||||||
|
pg_num, i, row_start, row_end,
|
||||||
|
lookupflag ? "[lookup]" : "",
|
||||||
|
delflag ? "[delflag]" : "");
|
||||||
|
|
||||||
|
if (delflag || lookupflag) {
|
||||||
|
row_end = row_start-1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
buffer_dump(mdb->pg_buf, row_start, row_end);
|
||||||
|
|
||||||
num_cols = mdb->pg_buf[row_start];
|
num_cols = mdb->pg_buf[row_start];
|
||||||
var_cols = mdb->pg_buf[row_end-1];
|
var_cols = mdb->pg_buf[row_end-1];
|
||||||
fixed_cols = num_cols - var_cols;
|
fixed_cols = num_cols - var_cols;
|
||||||
@ -55,7 +71,7 @@ int eod; /* end of data */
|
|||||||
col = g_array_index(table->columns,MdbColumn,j);
|
col = g_array_index(table->columns,MdbColumn,j);
|
||||||
if (mdb_is_fixed_col(&col) &&
|
if (mdb_is_fixed_col(&col) &&
|
||||||
++fixed_cols_found <= fixed_cols) {
|
++fixed_cols_found <= fixed_cols) {
|
||||||
fprintf(stdout,"fixed col %s = %s\n",col.name,mdb_col_to_string(&mdb->pg_buf[row_start + col_start],col.col_type,NULL));
|
fprintf(stdout,"fixed col %s = %s\n",col.name,mdb_col_to_string(&mdb->pg_buf[row_start + col_start],col.col_type,0));
|
||||||
col_start += col.col_size;
|
col_start += col.col_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
src/libmdb/dump.c
Normal file
35
src/libmdb/dump.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void buffer_dump(const char* buf, int start, int end)
|
||||||
|
{
|
||||||
|
char asc[20];
|
||||||
|
int j, k;
|
||||||
|
|
||||||
|
memset(asc, 0, sizeof(asc));
|
||||||
|
k = 0;
|
||||||
|
for (j=start; j<=end; j++) {
|
||||||
|
if (k == 0) {
|
||||||
|
fprintf(stdout, "%04x ", j);
|
||||||
|
}
|
||||||
|
fprintf(stdout, "%02x ", buf[j]);
|
||||||
|
asc[k] = isprint(buf[j]) ? buf[j] : '.';
|
||||||
|
k++;
|
||||||
|
if (k == 8) {
|
||||||
|
fprintf(stdout, " ");
|
||||||
|
}
|
||||||
|
if (k == 16) {
|
||||||
|
fprintf(stdout, " %s\n", asc);
|
||||||
|
memset(asc, 0, sizeof(asc));
|
||||||
|
k = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (j=k; j<16; j++) {
|
||||||
|
fprintf(stdout, " ");
|
||||||
|
}
|
||||||
|
if (k < 8) {
|
||||||
|
fprintf(stdout, " ");
|
||||||
|
}
|
||||||
|
fprintf(stdout, " %s\n", asc);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user