}
-// convert function for a message in msgmain
+// export function for a message in msgmain
void export_msgmain(int which_cdb, DBT *in_key, DBT *in_data) {
long in_msgnum;
}
-// convert function for a user record
+// export function for a user record
void export_user(int which_cdb, DBT *in_key, DBT *in_data) {
struct ctdluser *user = (struct ctdluser *)in_data->data;
}
-// convert function for a room record
+// export function for a room record
void export_room(int which_cdb, DBT *in_key, DBT *in_data) {
struct ctdlroom *room = (struct ctdlroom *)in_data->data;
}
-#if 0
-// convert function for a floor record
-void export_floors(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
+// export function for a floor record
+void export_floor(int which_cdb, DBT *in_key, DBT *in_data) {
- // the key is an "int", and "int" is 32-bits on both 32 and 64 bit platforms.
- 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);
+ int floor_num;
+ memcpy(&floor_num, in_key->data, sizeof(int));
- // data
- struct floor_32 *floor32 = (struct floor_32 *)in_data->data;
- out_data->size = sizeof(struct floor);
- out_data->data = realloc(out_data->data, out_data->size);
- struct floor *floor64 = (struct floor *)out_data->data;
-
- // these are probably bit-for-bit identical, actually ... but we do it the "right" way anyway
- floor64->f_flags = (unsigned short) floor32->f_flags;
- strcpy(floor64->f_name, floor32->f_name);
- floor64->f_ref_count = (int) floor32->f_ref_count;
- floor64->f_ep.expire_mode = (int) floor32->f_ep.expire_mode;
- floor64->f_ep.expire_value = (int) floor32->f_ep.expire_value;
+ struct floor *floor = (struct floor *)in_data->data;
- // printf("\033[32m\033[1mFloor: %s\033[0m\n", floor64->f_name);
+ printf("floor|%d|%u|%s|%d|%d|%d\n",
+ floor_num,
+ floor->f_flags,
+ floor->f_name,
+ floor->f_ref_count,
+ floor->f_ep.expire_mode,
+ floor->f_ep.expire_value
+ );
}
-// convert function for a msglist or a fulltext index record
+#if 0
+// export function for a msglist or a fulltext index record
// (both are indexed by a long and the data is arrays of longs)
void export_msglists(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
int i;
}
-// convert function for a visit record
+// export function for a visit record
void export_visits(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
// data
}
-// convert function for a directory record
+// export function for a directory record
void export_dir(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
// the key is a string
}
-// convert function for a use table record
+// export function for a use table record
void export_usetable(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
// the key is an int, which is the same size (32 bits) on both 32 and 64 bit systems
}
-// convert function for large message texts
+// export function for large message texts
void export_bigmsgs(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
// The key is a packed long
}
-// convert function for EUID Index records
+// export function for EUID Index records
void export_euidindex(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
// The structure of an euidindex record *key* is:
}
-// convert function for a config record
+// export function for a config record
void export_config(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
// the key is a string
export_msgmain, // CDB_MSGMAIN
export_user, // CDB_USERS
export_room, // CDB_ROOMS
- zero_function, // CDB_FLOORTAB
+ export_floor, // CDB_FLOORTAB
zero_function, // CDB_MSGLISTS
zero_function, // CDB_VISIT
zero_function, // CDB_DIRECTORY
memset(&in_data, 0, sizeof(DBT));
memset(&uncomp_data, 0, sizeof(DBT)); // decompressed input (the key doesn't change)
- // Walk through the database, calling convert functions as we go and clearing buffers before each call.
+ // Walk through the database, calling export functions as we go and clearing buffers before each call.
while (ret = src_dbcp->get(src_dbcp, &in_key, &in_data, DB_NEXT) == 0) {
// If either the key or data are zero length, skip this record
}
}
- // Call the convert function registered to this table
+ // Call the export function registered to this table
export_functions[which_cdb](which_cdb, &in_key, (compressed ? &uncomp_data : &in_data));
// Knowing the total number of rows isn't critical to the program. It's just for the user to know.