mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Consolidate / fix UUID formatting
This commit is contained in:
parent
2887fa49ed
commit
7b51824c89
@ -492,6 +492,7 @@ int mdb_bind_column_by_name(MdbTableDef *table, gchar *col_name, void *bind_ptr,
|
||||
void mdb_data_dump(MdbTableDef *table);
|
||||
void mdb_date_to_tm(double td, struct tm *t);
|
||||
void mdb_tm_to_date(struct tm *t, double *td);
|
||||
char *mdb_uuid_to_string(const void *buf, int start);
|
||||
void mdb_bind_column(MdbTableDef *table, int col_num, void *bind_ptr, int *len_ptr);
|
||||
int mdb_rewind_table(MdbTableDef *table);
|
||||
int mdb_fetch_row(MdbTableDef *table);
|
||||
|
@ -889,25 +889,19 @@ mdb_date_to_string(void *buf, int start)
|
||||
return text;
|
||||
}
|
||||
|
||||
static char *
|
||||
mdb_uuid_to_string(MdbHandle *mdb, int start)
|
||||
char *mdb_uuid_to_string(const void *buf, int pos)
|
||||
{
|
||||
char *text = NULL;
|
||||
unsigned short uuid1, uuid2, uuid3, uuid4, uuid5, uuid6, uuid7, uuid8;
|
||||
const unsigned char *kkd = (const unsigned char *)buf;
|
||||
return g_strdup_printf("{%02X%02X%02X%02X" "-" "%02X%02X" "-" "%02X%02X"
|
||||
"-" "%02X%02X" "%02X%02X%02X%02X%02X%02X}",
|
||||
kkd[pos+3], kkd[pos+2], kkd[pos+1], kkd[pos], // little-endian
|
||||
kkd[pos+5], kkd[pos+4], // little-endian
|
||||
kkd[pos+7], kkd[pos+6], // little-endian
|
||||
kkd[pos+8], kkd[pos+9], // big-endian
|
||||
|
||||
uuid1 = mdb_get_int16(mdb->pg_buf, start);
|
||||
uuid2 = mdb_get_int16(mdb->pg_buf, start + 2);
|
||||
uuid3 = mdb_get_int16(mdb->pg_buf, start + 4);
|
||||
uuid4 = mdb_get_int16(mdb->pg_buf, start + 6);
|
||||
uuid5 = mdb_get_int16(mdb->pg_buf, start + 8);
|
||||
uuid6 = mdb_get_int16(mdb->pg_buf, start + 10);
|
||||
uuid7 = mdb_get_int16(mdb->pg_buf, start + 12);
|
||||
uuid8 = mdb_get_int16(mdb->pg_buf, start + 14);
|
||||
|
||||
text = g_strdup_printf("{%04x%04x-%04x-%04x-%04x-%04x%04x%04x}",
|
||||
uuid1, uuid2, uuid3, uuid4, uuid5, uuid6, uuid7, uuid8);
|
||||
|
||||
return text;
|
||||
kkd[pos+10], kkd[pos+11],
|
||||
kkd[pos+12], kkd[pos+13],
|
||||
kkd[pos+14], kkd[pos+15]); // big-endian
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -1000,7 +994,7 @@ char *mdb_col_to_string(MdbHandle *mdb, void *buf, int start, int datatype, int
|
||||
case MDB_NUMERIC:
|
||||
break;
|
||||
case MDB_REPID:
|
||||
text = mdb_uuid_to_string(mdb, start);
|
||||
text = mdb_uuid_to_string(mdb->pg_buf, start);
|
||||
break;
|
||||
default:
|
||||
text = g_strdup("");
|
||||
|
@ -137,21 +137,7 @@ mdb_read_props(MdbHandle *mdb, GPtrArray *names, gchar *kkd, int len)
|
||||
g_hash_table_insert(props->hash, g_strdup(name),
|
||||
g_strdup(kkd[pos + 8] ? "yes" : "no"));
|
||||
} else if (dtype == MDB_BINARY && dsize == 16 && strcmp(name, "GUID") == 0) {
|
||||
gchar *guid = g_malloc0(39);
|
||||
snprintf(guid, 39, "{%02X%02X%02X%02X" "-" "%02X%02X" "-" "%02X%02X"
|
||||
"-" "%02X%02X" "%02X%02X%02X%02X%02X%02X}",
|
||||
(unsigned char)kkd[pos+11], (unsigned char)kkd[pos+10],
|
||||
(unsigned char)kkd[pos+9], (unsigned char)kkd[pos+8], // little-endian
|
||||
|
||||
(unsigned char)kkd[pos+13], (unsigned char)kkd[pos+12], // little-endian
|
||||
|
||||
(unsigned char)kkd[pos+15], (unsigned char)kkd[pos+14], // little-endian
|
||||
|
||||
(unsigned char)kkd[pos+16], (unsigned char)kkd[pos+17], // big-endian
|
||||
|
||||
(unsigned char)kkd[pos+18], (unsigned char)kkd[pos+19],
|
||||
(unsigned char)kkd[pos+20], (unsigned char)kkd[pos+21],
|
||||
(unsigned char)kkd[pos+22], (unsigned char)kkd[pos+23]); // big-endian
|
||||
gchar *guid = mdb_uuid_to_string(kkd, pos+8);
|
||||
g_hash_table_insert(props->hash, g_strdup(name), guid);
|
||||
} else {
|
||||
g_hash_table_insert(props->hash, g_strdup(name),
|
||||
|
Loading…
Reference in New Issue
Block a user