db_verb_handle find_described_verb(Objid oid, Var desc) { if (desc.type == TYPE_INT) return db_find_indexed_verb(oid, desc.v.num); else { int flag = server_flag_option("support_numeric_verbname_strings", 0); return db_find_defined_verb(oid, desc.v.str, flag); } }
static int read_db_file(void) { Objid oid; int nobjs, nprogs, nusers; Var user_list; int i, vnum, dummy; db_verb_handle h; Program *program; waif_before_loading(); if (dbio_scanf(header_format_string, &dbio_input_version) != 1) dbio_input_version = DBV_Prehistory; if (!check_version(dbio_input_version)) { errlog("READ_DB_FILE: Unknown DB version number: %d\n", dbio_input_version); return 0; } /* I use a `dummy' variable here and elsewhere instead of the `*' * assignment-suppression syntax of `scanf' because it allows more * straightforward error checking; unfortunately, the standard says that * suppressed assignments are not counted in determining the returned value * of `scanf'... */ if (dbio_scanf("%d\n%d\n%d\n%d\n", &nobjs, &nprogs, &dummy, &nusers) != 4) { errlog("READ_DB_FILE: Bad header\n"); return 0; } user_list = new_list(nusers); for (i = 1; i <= nusers; i++) { user_list.v.list[i].type = TYPE_OBJ; user_list.v.list[i].v.obj = dbio_read_objid(); } dbpriv_set_all_users(user_list); oklog("LOADING: Reading %d objects...\n", nobjs); for (i = 1; i <= nobjs; i++) { if (!read_object()) { errlog("READ_DB_FILE: Bad object #%d.\n", i - 1); return 0; } if (i % 10000 == 0 || i == nobjs) oklog("LOADING: Done reading %d objects ...\n", i); } if (!validate_hierarchies()) { errlog("READ_DB_FILE: Errors in object hierarchies.\n"); return 0; } oklog("LOADING: Reading %d MOO verb programs...\n", nprogs); for (i = 1; i <= nprogs; i++) { if (dbio_scanf("#%d:%d\n", &oid, &vnum) != 2) { errlog("READ_DB_FILE: Bad program header, i = %d.\n", i); return 0; } if (!valid(oid)) { errlog("READ_DB_FILE: Verb for non-existant object: #%d:%d.\n", oid, vnum); return 0; } h = db_find_indexed_verb(oid, vnum + 1); /* DB file is 0-based. */ if (!h.ptr) { errlog("READ_DB_FILE: Unknown verb index: #%d:%d.\n", oid, vnum); return 0; } program = dbio_read_program(dbio_input_version, fmt_verb_name, &h); if (!program) { errlog("READ_DB_FILE: Unparsable program #%d:%d.\n", oid, vnum); return 0; } db_set_verb_program(h, program); if (i % 5000 == 0 || i == nprogs) oklog("LOADING: Done reading %d verb programs...\n", i); } oklog("LOADING: Reading forked and suspended tasks...\n"); if (!read_task_queue()) { errlog("READ_DB_FILE: Can't read task queue.\n"); return 0; } oklog("LOADING: Reading list of formerly active connections...\n"); if (!read_active_connections()) { errlog("DB_READ: Can't read active connections.\n"); return 0; } waif_after_loading(); return 1; }