parent $libraries object $code var $root child_index 0 var $root owners [$code] var $root fertile 0 var $root inited 1 var $root owned [$code] var $root manager $code var $root writable [$code] var $root readable ['parameters, 'methods, 'code] var $code quotes [["\"Abandon all hope, ye who enter here.\""], ["\"Pull out Wedge, your not doing any more good back there.\"", "", "- Luke Skywalker, StarWars"], ["\"God is in the details.\""], ["\"I don't practice what I preach,", "because I'm not the type of person I'm preaching too.\"", "", "- Bob Dobbs"], ["\"I haven't shaved for six years.", "I seem to be cursed with a thin beard.\"", "", "- Calvin, Age 6 (of Calvin & Hobbes)"], ["\"I may be a Dreamer, but I'm not the only one.\"", "", "- John Lennon"], ["\"C code. C code run. Run, Code, Run! Please!?\"", "", "- Anonymous C hacker."], ["\"They who dream by day are cognizant of many things", "which escape those who dream only by night.\"", "", "- Edgar Allan Poe"], ["\"The good die first,", "and they whose hearts are dry as a summer dust", "burn to the socket.\"", "", "- William Wordsworth"], ["\"Banning guns to prevent murder", "is like banning word processors to prevent libel.\"", "", "- Unknown"], ["\"You will not be punished for your anger,", "you will be punished by your anger.\"", "", "- Buddha"], ["What part of:", "", "main() { printf(&unix[\"\\021%six\\012\\0\"],(unix)[\"have\"]+\"fun\"-0x60);}", "", "do you not understand?", "", "(taken from the 1987 Obfuscated C Code Contest)"], ["\"The goal of computer science is to build something that will", "last at least until we've finished building it.\""], ["\"Give me ambiguity or give me something else.\""], ["\"We are born naked, wet and hungry. Then things get worse.\""], ["\"Make it idiot proof and someone will make a better idiot.\""], ["\"Lottery: A tax on people who are bad at math.\""], ["\"There's too much blood in my caffeine system.\""], ["\"Artificial Intelligence usually beats real stupidity.\""], ["\"Ever notice how fast MS-Windows runs? Neither did I.\""], ["\"Very funny, Scotty. Now beam down my clothes.\""], ["\"Consciousness: that annoying time between naps.\""], ["\"The gene pool could use a little chlorine.\""], ["\"When there's a will, I want to be in it.\""], ["\"Change is inevitable, except from a vending machine.\""], ["\"MS-Windows is a virus:", "it takes over your computer and makes it run bad.\""], ["\"I have not failed 10,000 times,", "I have sucessfully found 10,000 ways that do not work.\"", "- Thomas Edison"], ["\"The difference between literature and journalism is", "that journalism is unreadable and literature is not read.\"", "", "- Oscar Wilde (1854-1900)"], ["\"The man who reads nothing at all is better educated", "than the man who reads nothing but newspapers.\"", "", "- Thomas Jefferson (1743-1826)"]] var $root dbref 'code var $code command_argument_types [['any, "any"], ['text, "text"], ['object, "object"], ['thing, "thing"], ['user, "user"], ['descendant, "descendant of *"], ['this, "this"], ['number, "number"]] method set_obj_param arg obj, param, val; var set_code; // set param on obj to val if (!((sender() == $root) || ($sys.is_admin(sender())))) throw(~perm, "Sender not admin or $root"); if (!valid(obj)) throw(~objnf, ("Object " + ($data.unparse(obj))) + " is not a valid object."); if (!(param in (obj.parameters()))) throw(~parmnf, ((("Parameter " + ($data.unparse(param))) + " is not a parmater on ") + ($data.unparse(obj))) + "."); if ('__set_any in ($obj.methods())) throw(~methexist, "Method '__set_any already defined on target object."); // Copy _set_any to obj set_code = .list_method('_set_var); obj.compile(set_code, '__set_var); // Set and delete method catch any { obj.__set_var(param, val); obj.del_method('__set_var); } with handler { obj.del_method('__set_var); rethrow(error()); } . method _set_var arg param, val; if (sender() != $code) throw(~perm, "Sender not $code"); return set_var(param, val); . method quotes return quotes; . method add_random_quote arg quote, [from]; if (!($sys.is_admin(sender()))) throw(~perm, "Sender is not an owner"); if (type(quote) != 'string) throw(~type, "Quote must be given as a string."); quote = ("\"" + quote) + "\""; quote = $string.wrap_line(quote, 70); quote = from ? [@quote, " - " + (from[1])] | quote; quotes = quotes + [quote]; . method generate_listing arg who, [args]; var meths, methval, input, output, element, header, title, cols, x, z, len, line, linea, y; // called by one of the who_cmds, does all the grunge work. title = [@args, "Connected Users"][1]; meths = [@args, [['name], ['connected_time], ['idle_time], ['realm_name]], [['name], ['connected_time], ['idle_time], ['realm_name]]][2]; header = [@args, ["Name", "On for", "Idle", "Location"], ["Name", "On for", "Idle", "Location"], ["Name", "On for", "Idle", "Location"]][3]; cols = [@args, [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]][4]; // get values using $list.map element = $list.map(who, (meths[1])[1], @sublist(meths[1], 2)); input = []; for x in (element) { input = [@input, [x]]; if (strlen(x) > (cols[1])) cols = replace(cols, 1, strlen(x)); } // ok, get on with it. for x in [2 .. listlen(meths)] { methval = $list.map(who, (meths[x])[1], @sublist(meths[x], 2)); for z in [1 .. listlen(methval)] { if (strlen(methval[z]) > (cols[x])) cols = replace(cols, x, strlen(methval[z])); input = replace(input, z, [@input[z], methval[z]]); } } // this will remove columns with no information in them. z = []; for x in [1 .. listlen(cols)] { if (!(cols[x])) z = [@z, x]; } for x in (z) { cols = delete(cols, x); meths = delete(meths, x); header = delete(header, x); for y in [1 .. listlen(input)] input = replace(input, y, delete(input[y], x)); } // the header. len = (| sender().linelen() |) || 79; line = ""; linea = ""; for x in [1 .. listlen(cols)] { line = line + pad(header[x], (cols[x]) + 2); linea = linea + pad(pad("", strlen(header[x]), "-"), (cols[x]) + 2); } output = [((("--- " + title) + " (") + tostr(listlen(input))) + ") ---"]; output = [@output, pad(line, len)]; output = [@output, pad(linea, len)]; // tell the rest: for x in (input) { line = ""; for z in [1 .. listlen(cols)] line = line + pad(x[z], (cols[z]) + 2); output = [@output, pad(line, len).trim()]; } return [@output]; . method random_quote var which; which = random(listlen(quotes)); if (which) return quotes[which]; return []; . method valid_email arg email; var host, user, ip, tmp; email = explode(email, "@"); if (listlen(email) != 2) return ['invalid, email, ""]; // if we want we can do something overly extensive with this, but we will not user = email[1]; host = email[2]; if (toint(host[1])) { tmp = hostname(host); if (tmp == "-1") return ['invip, user, host]; } else { tmp = ip(host); if (tmp == "-1") return ['invhostname, user, host]; } return ['valid, user, host]; . method unparse_command arg command; var x, line; // command should be passed as a list, and can either be a command // or shortcut. This will return a string. if (listlen(command) == 2) return toliteral(command[1]); line = ""; for x in (command[3]) { if (type(x) == 'string) line = (line + (line ? " " | "")) + x; else line = ((line + (line ? " " | "")) + "%") + tostr(x); } return ((("\"" + (command[1])) + "\" => \"") + line) + "\""; . method parse_name arg name; var article, str; // used to parse $named names and aliases. name = name.explode_english_list(); article = 'prop; if (name && (((name[1])[1]) == "-")) { str = substr(((name[1]).explode())[1], 2); name = replace(name, 1, (((name[1]).explode()).delete(1)).to_string()); if (match_template("u?nique", str)) article = 'uniq; } if (!name) throw(~name, "Emtpy name."); return [[name[1], article], sublist(name, 2)]; . method generate_family_listing arg obj, [type]; var line, obj, colx, col, family, x, out; type = [@type, 'children][1]; family = obj.(type)(); if (!family) { out = ["** None **"]; } else { col = ((| sender().linelen() |) || 79) / 8; colx = col * 3; line = pad(" Name", colx + 2) + pad(" Perms", col - 2); out = [(line + pad("Size ", -col)) + "Manager"]; for obj in (family) { line = " " + (obj.namef('xref)); line = pad(line, colx + 2); line = line + pad(" " + ($object.see_perms(obj)), col - 2); line = line + pad(tostr(obj.size()) + " ", -col); line = line + pad($object.get_name(obj.manager(), 'namef, ['xref]), colx); out = [@out, line]; } } return out; . method random_word arg [args]; var x, out, min, max, con, vow, flag, lcon, lvow, extra; min = [@args, 5][1]; max = [@args, 9, 9][2]; extra = [@args, "", "", ""][3]; x = random(max - min) + min; out = ""; con = "bcdfghjklmnpqrstvwxz" + extra; vow = "aeiouy"; lcon = strlen(con); lvow = strlen(vow); while (strlen(out) < x) { if (!flag) out = out + (con[random(lcon)]); else out = out + (vow[random(lvow)]); flag = !flag; } return out; . method punctuation_type arg str; var end; end = strlen(str); switch (str[end]) { case "!": return "exclaim"; case "?": return "ask"; case ".": return "say"; case ")": if (end > 1) { switch (str[end - 1]) { case ";": return "wink"; case ":", "8": return ["grin", "smile", "smirk"][random(3)]; default: return "say"; } } case "(": if ((end > 1) && ((str[end - 1]) in [":", "8"])) return "frown"; } return "say"; . method check_encrypted arg cstr, str; return crypt(str, substr(cstr, 1, 2)) == cstr; . method user_type arg user; var p; // The reason for this is because the parents list may get messed up // if they add/remove parents. p = user.parents(); if ($user in p) return 'user; else if ($builder in p) return 'builder; else if ($programmer in p) return 'programmer; else if ($admin in p) return 'admin; else return 'none; . method command_argument_types return command_argument_types; . method get_command_argument_type arg type; var x, m; for x in [1 .. listlen(command_argument_types)] { m = match_pattern((command_argument_types[x])[2], type); if (type(m) == 'list) return [(command_argument_types[x])[1], m]; } throw(~command, ("Invalid command argument type \"" + type) + "\""); .