/** Display information on an attribute from the table. * \verbatim * Top-level function for @attribute. * \endverbatim * \param player the enactor. * \param name the name of the attribute. */ void do_attribute_info(dbref player, char *name) { ATTR *ap; if (!name || !*name) { notify(player, T("Which attribute do you mean?")); return; } /* Is this attribute in the table? */ if (*name == '@') name++; ap = aname_hash_lookup(name); if (!ap) { notify(player, T("That attribute isn't in the attribute table")); return; } notify_format(player, "%9s: %s", T("Attribute"), AL_NAME(ap)); if (ap->flags & AF_RLIMIT) { notify_format(player, "%9s: %s", T("Limit"), display_attr_limit(ap)); } else if (ap->flags & AF_ENUM) { notify_format(player, "%9s: %s", T("Enum"), display_attr_limit(ap)); } notify_format(player, "%9s: %s", T("Flags"), privs_to_string(attr_privs_view, AL_FLAGS(ap))); notify_format(player, "%9s: %s", T("Creator"), unparse_dbref(AL_CREATOR(ap))); return; }
/** Decompile the standard attribute table, as per \@attribute/decompile * \param player The enactor * \param pattern Wildcard pattern of attrnames to decompile * \param retroactive Include the /retroactive switch? */ void do_decompile_attribs(dbref player, char *pattern, int retroactive) { ATTR *ap; const char *name; notify(player, T("@@ Standard Attributes:")); for (ap = ptab_firstentry_new(&ptab_attrib, &name); ap; ap = ptab_nextentry_new(&ptab_attrib, &name)) { if (strcmp(name, AL_NAME(ap))) continue; if (pattern && *pattern && !quick_wild(pattern, AL_NAME(ap))) continue; notify_format(player, "@attribute/access%s %s=%s", (retroactive ? "/retroactive" : ""), AL_NAME(ap), privs_to_string(attr_privs_view, AL_FLAGS(ap))); if (ap->flags & AF_RLIMIT) { notify_format(player, "@attribute/limit %s=%s", AL_NAME(ap), display_attr_limit(ap)); } else if (ap->flags & AF_ENUM) { notify_format(player, "@attribute/enum %s=%s", AL_NAME(ap), display_attr_limit(ap)); } } }
static void display_attr_info(dbref player, ATTR *ap) { notify_format(player, "%9s: %s", T("Attribute"), AL_NAME(ap)); if (ap->flags & AF_RLIMIT) { notify_format(player, "%9s: %s", T("Limit"), display_attr_limit(ap)); } else if (ap->flags & AF_ENUM) { notify_format(player, "%9s: %s", T("Enum"), display_attr_limit(ap)); } notify_format(player, "%9s: %s", T("Flags"), privs_to_string(attr_privs_view, AL_FLAGS(ap))); notify_format(player, "%9s: %s", T("Creator"), unparse_dbref(AL_CREATOR(ap))); return; }
void attr_write_all(PENNFILE *f) { int attrcount = 0, aliascount = 0; ATTR *a; const char *attrname; char *data; for (a = ptab_firstentry_new(&ptab_attrib, &attrname); a; a = ptab_nextentry_new(&ptab_attrib, &attrname)) { if (!strcmp(attrname, AL_NAME(a))) attrcount++; else aliascount++; } db_write_labeled_int(f, "attrcount", attrcount); for (a = ptab_firstentry_new(&ptab_attrib, &attrname); a; a = ptab_nextentry_new(&ptab_attrib, &attrname)) { if (strcmp(attrname, AL_NAME(a))) continue; /* skip aliases */ db_write_labeled_string(f, " name", AL_NAME(a)); db_write_labeled_string(f, " flags", privs_to_string(attr_privs_db, AL_FLAGS(a))); db_write_labeled_dbref(f, " creator", AL_CREATOR(a)); data = atr_value(a); db_write_labeled_string(f, " data", data); } db_write_labeled_int(f, "attraliascount", aliascount); for (a = ptab_firstentry_new(&ptab_attrib, &attrname); a; a = ptab_nextentry_new(&ptab_attrib, &attrname)) { if (!strcmp(attrname, AL_NAME(a))) continue; /* skip non-aliases */ db_write_labeled_string(f, " name", AL_NAME(a)); db_write_labeled_string(f, " alias", attrname); } }
/** Add new standard attributes, or change permissions on them. * \verbatim * Given the name and permission string for an attribute, add it to * the attribute table (or modify the permissions if it's already * there). Permissions may be changed retroactively, which modifies * permissions on any copies of that attribute set on objects in the * database. This is the top-level code for @attribute/access. * \endverbatim * \param player the enactor. * \param name the attribute name. * \param perms a string of attribute permissions, space-separated. * \param retroactive if true, apply the permissions retroactively. */ void do_attribute_access(dbref player, char *name, char *perms, int retroactive) { ATTR *ap, *ap2; privbits flags = 0; int i; int insert = 0; /* Parse name and perms */ if (!name || !*name) { notify(player, T("Which attribute do you mean?")); return; } if (strcasecmp(perms, "none")) { flags = list_to_privs(attr_privs_set, perms, 0); if (!flags) { notify(player, T("I don't understand those permissions.")); return; } } upcasestr(name); /* Is this attribute already in the table? */ ap = (ATTR *) ptab_find_exact(&ptab_attrib, name); if (ap) { if (AF_Internal(ap)) { /* Don't muck with internal attributes */ notify(player, T("That attribute's permissions can not be changed.")); return; } } else { /* Create fresh if the name is ok */ if (!good_atr_name(name)) { notify(player, T("Invalid attribute name.")); return; } insert = 1; ap = (ATTR *) mush_malloc(sizeof(ATTR), "ATTR"); if (!ap) { notify(player, T("Critical memory failure - Alert God!")); do_log(LT_ERR, 0, 0, "do_attribute_access: unable to malloc ATTR"); return; } AL_NAME(ap) = strdup(name); ap->data = NULL_CHUNK_REFERENCE; } AL_FLAGS(ap) = flags; AL_CREATOR(ap) = player; /* Only insert when it's not already in the table */ if (insert) { ptab_insert_one(&ptab_attrib, name, ap); } /* Ok, now we need to see if there are any attributes of this name * set on objects in the db. If so, and if we're retroactive, set * perms/creator */ if (retroactive) { for (i = 0; i < db_top; i++) { if ((ap2 = atr_get_noparent(i, name))) { if (AL_FLAGS(ap2) & AF_ROOT) AL_FLAGS(ap2) = flags | AF_ROOT; else AL_FLAGS(ap2) = flags; AL_CREATOR(ap2) = player; } } } notify_format(player, T("%s -- Attribute permissions now: %s"), name, privs_to_string(attr_privs_view, flags)); }
/** Return a list of lock flag names. * \param ll pointer to a lock. * \return string of lock flag names, space-separated. */ const char * lock_flags_long(lock_list *ll) { return privs_to_string(lock_privs, L_FLAGS(ll)); }