- if (!strcasecmp(record_type, "msgtext")) row_was_good = convert_msgtext(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "msgmeta")) row_was_good = convert_msgmeta(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "user")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "room")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "floor")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "msglist")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "visit")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "dir")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "use")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "bigmsg")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "euidindex")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "usersbynumber")) row_was_good = convert_foo(line, &out_key, &out_data);
- else if (!strcasecmp(record_type, "config")) row_was_good = convert_foo(line, &out_key, &out_data);
- else row_was_good = 0;
-
- if (row_was_good) {
- ret = dst_dbp->put(dst_dbp, NULL, &out_key, &out_data, 0);
- if (ret) {
- fprintf(stderr, "db: cdb_put(%d): %s", current_cdb, db_strerror(ret));
- exit(CTDLEXIT_DB);
- }
+
+ // Identify the record type we are currently working with,
+ // then call the correct conversion function to load up our record buffer.
+ extract_token(record_type, line, 0, '|', sizeof record_type);
+ if (!strcasecmp(record_type, "msgtext")) {
+ current_cdb = CDB_MSGMAIN;
+ row_was_good = import_msgtext(line, kv);
+ }
+ else if (!strcasecmp(record_type, "msgmeta")) {
+ current_cdb = CDB_MSGMAIN;
+ row_was_good = import_msgmeta(line, kv);
+ }
+ else if (!strcasecmp(record_type, "user")) {
+ current_cdb = CDB_USERS;
+ row_was_good = import_user(line, kv);
+ }
+ else if (!strcasecmp(record_type, "room")) {
+ current_cdb = CDB_ROOMS;
+ row_was_good = import_room(line, kv);
+ }
+ else if (!strcasecmp(record_type, "floor")) {
+ current_cdb = CDB_FLOORTAB;
+ row_was_good = import_floor(line, kv);
+ }
+ else if (!strcasecmp(record_type, "msglist")) {
+ current_cdb = CDB_MSGLISTS;
+ row_was_good = import_msglist(line, kv);
+ }
+ else if (!strcasecmp(record_type, "visit")) {
+ current_cdb = CDB_VISIT;
+ row_was_good = import_visit(line, kv);
+ }
+ else if (!strcasecmp(record_type, "dir")) {
+ current_cdb = CDB_DIRECTORY;
+ row_was_good = import_dir(line, kv);
+ }
+ else if (!strcasecmp(record_type, "use")) {
+ current_cdb = CDB_USETABLE;
+ row_was_good = import_usetable(line, kv);
+ }
+ else if (!strcasecmp(record_type, "bigmsg")) {
+ current_cdb = CDB_BIGMSGS;
+ row_was_good = import_msgtext(line, kv);
+ }
+ else if (!strcasecmp(record_type, "fulltext")) {
+ current_cdb = CDB_FULLTEXT;
+ row_was_good = import_fulltext(line, kv);
+ }
+ else if (!strcasecmp(record_type, "euidindex")) {
+ current_cdb = CDB_EUIDINDEX;
+ row_was_good = import_euidindex(line, kv);
+ }
+ else if (!strcasecmp(record_type, "usersbynumber")) {
+ current_cdb = CDB_USERSBYNUMBER;
+ row_was_good = import_usersbynumber(line, kv);
+ }
+ else if (!strcasecmp(record_type, "config")) {
+ current_cdb = CDB_CONFIG;
+ row_was_good = import_config(line, kv);
+ }
+ else {
+ current_cdb = -1 ;
+ }
+
+ // If the conversion function was successful, write the record to the database.
+ if ( (row_was_good) && (current_cdb >= 0) ) {
+ cdb_store(current_cdb, kv->key.ptr, kv->key.len, kv->val.ptr, kv->val.len);
+ ++good_rows;
+ }
+ else {
+ ++bad_rows;