strcpy(visit64->v_answered, visit32->v_answered);
visit64->v_view = (int) visit32->v_view;
- // printf("\033[32m\033[1mVisit: room %ld, gen %ld, user %ld\033[0m\n", visit64->v_roomnum, visit64->v_roomgen, visit64->v_usernum);
+ // printf("\033[32m\033[1mVisit: room %10ld, gen %10ld, user %10ld\033[0m\n", visit64->v_roomnum, visit64->v_roomgen, visit64->v_usernum);
// create the key (which is based on the data, so there is no need to convert the old key)
out_key->size = sizeof(struct visit_index);
// convert function for a use table record
void convert_usetable(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
- // the key is a string
+ // the key is an int, which is the same size (32 bits) on both 32 and 64 bit systems
out_key->size = in_key->size;
out_key->data = realloc(out_key->data, out_key->size);
memcpy(out_key->data, in_key->data, in_key->size);
struct UseTable *use64 = (struct UseTable *)out_data->data;
// the data
- strcpy(use64->ut_msgid, use32->ut_msgid);
- use64->ut_timestamp = (time_t) use32->ut_timestamp;
+ use64->hash = use32->hash;
+ use64->timestamp = (time_t) use32->timestamp;
+
+ printf("\033[32m\033[1muse table: %d , %s\033[0m\n", use64->hash, asctime(localtime(&use64->timestamp)));
}
abort();
}
+ out_key->size = sizeof(long);
+ out_key->data = realloc(out_key->data, out_key->size);
+ memcpy(out_key->data, &out_msgnum, sizeof(long));
+
// the data is binary-ish but has no packed integers
out_data->size = in_data->size;
out_data->data = realloc(out_data->data, out_data->size);
// Walk through the database, calling convert functions as we go and clearing buffers before each call.
while (out_key.size = 0, out_data.size = 0, (ret = src_dbcp->get(src_dbcp, &in_key, &in_data, DB_NEXT)) == 0) {
-
-
- if (in_key.size == 0) {
- printf("\033[31mzero length key, skipping\033[0m\n");
- }
-
- else if (in_data.size == 0) {
- printf("\033[31mzero length data, skipping\033[0m\n");
+
+ // Knowing the total number of rows isn't critical to the program. It's just for the user to know.
+ ++num_rows;
+ printf(" \033[32m%d\033[0m\r", num_rows);
+ fflush(stdout);
+
+ // If either the key or data are zero length, skip this record
+ if ((in_key.size == 0) || (in_data.size == 0)) {
+ printf("\033[31minput keylen=%d , datalen=%d , skipping record\033[0m\n", in_key.size, in_data.size);
}
else { // Both key and data are >0 length so we're good to go
printf("db: cdb_put(%d): %s", which_cdb, db_strerror(ret));
exit(CTDLEXIT_DB);
}
-
- // Knowing the total number of rows isn't critical to the program. It's just for the user to know.
- ++num_rows;
- printf(" \033[32m%d\033[0m\r", num_rows);
- fflush(stdout);
+ }
+ else {
+ printf("\033[31moutput keylen=%d , skipping record\033[0m\n", out_key.size);
}
}
}
src_dbenv = open_dbenv(src_dir);
dst_dbenv = open_dbenv(dst_dir);
- for (int i = 0; i < MAXCDB; ++i) {
- convert_table(i, src_dbenv, dst_dbenv);
- }
+ //for (int i = 0; i < MAXCDB; ++i) {
+ //convert_table(i, src_dbenv, dst_dbenv);
+ //}
+ convert_table(7, src_dbenv, dst_dbenv);
close_dbenv(src_dbenv);
close_dbenv(dst_dbenv);