varargs int cmd(string str){ string tmp, thing, file, *inheriteds; object ob; if(!str || sscanf(str,"%s %s",file,thing) != 2){ write("Syntax: inherits FILE THING"); return 1; } ob = get_object(thing); if(!ob){ write("Sorry I can't find that thing."); return 1; } thing = (ob->GetShort() || thing); if(last(file,2) == ".c") file = truncate(file,2); tmp = DEFINES_D->GetDefine(file); if(tmp) file = tmp; write("Checking " + identify(ob) + " for inheritance of " + file + " , just a moment..."); if(file){ if(inherits(file, ob)){ write(thing+" inherits "+file+"."); return 1; } inheriteds = deep_inherit_list(ob); foreach(string item in inheriteds){ if(!grepp(item, file)) inheriteds -= ({ item }); } }
int cmd_ilist(string str) { object ob; string file, *files; int deep_list, i, s; notify_fail(SYNTAX); if(!str) return 0; seteuid(geteuid(previous_object())); if(sscanf(str, "-R %s", file)) deep_list = 1; else if(sscanf(str, "-T %s", file)) deep_list = 2; else file = str; ob = ref_ob(file); if(!ob || !objectp(ob)) { notify_fail("Couldn't find object.\n"); return 0; } write(wrap("Files inherited by " + dump_variable(ob))); if(!deep_list) files = inherit_list(ob); else if(deep_list == 1) files = deep_inherit_list(ob); else if(deep_list == 2) return show_tree(ob, 1); for(i = 0, s = sizeof(files); i < s; i ++) printf(" %d: %s\n", i + 1, files[i]); return 1; } // do_cmd
int main(object me, string arg) { object ob; if( !arg ) return notify_fail("指令格式:ilist <物件或档名>\n"); ob = present(arg, me); if( !ob ) ob = present(arg, environment(me)); if( !ob ) ob = find_object(resolve_path(me->query("cwd"), arg)); if( !ob ) return notify_fail("没有这样物件或这样物件没有被载入。\n"); printf("%O直接或间接继承以下档案:\n %s\n", ob, implode(deep_inherit_list(ob), "\n ")); return 1; }
void deep_destruct(object o) { mixed *ancestors; mixed ancestor; if (!o) { return; } ancestors = deep_inherit_list(o); foreach (ancestor in ancestors) { ancestor = find_object(ancestor); if (ancestor) { destruct(ancestor); } }