Used without switches, @attribute shows info about a standard attrib.
@attribute/access adds a new standard attribute into the table,
- associating it with the given space-separated list of flags.
+ associating it with the given space-separated list of full flag names.
See 'help @set' for possible flags. A flag list of "none" removes
all flag associations.
If the /retroactive switch is added, the flags are assigned to every copy
#define PrivShowBits(x) ((x)->bits_to_show)
extern int string_to_privs(PRIV *table, const char *str, long int origprivs);
+extern int list_to_privs(PRIV *table, const char *str, long int origprivs);
extern int string_to_privsets(PRIV *table, const char *str, int *setprivs,
int *clrprivs);
extern int letter_to_privs(PRIV *table, const char *str, long int origprivs);
return;
}
if (strcasecmp(perms, "none")) {
- flags = string_to_privs(attr_privs_set, perms, 0);
+ flags = list_to_privs(attr_privs_set, perms, 0);
if (!flags) {
notify(player, T("I don't understand those permissions."));
return;
/** Convert a string to a set of privilege bits, masked by an original set.
* Given a privs table, a string, and an original set of privileges,
* return a modified set of privileges by applying the privs in the
- * string to the original set of privileges.
+ * string to the original set of privileges. IF A SINGLE WORD STRING
+ * IS GIVEN AND IT ISN'T THE NAME OF A PRIV, PARSE IT AS INDIVIDUAL
+ * PRIV CHARS.
* \param table pointer to a privtab.
* \param str a space-separated string of privilege names to apply.
* \param origprivs the original privileges.
return ((origprivs | yes) & ~no);
}
+/** Convert a list to a set of privilege bits, masked by an original set.
+ * Given a privs table, a list, and an original set of privileges,
+ * return a modified set of privileges by applying the privs in the
+ * string to the original set of privileges. No prefix-matching is
+ * permitted in this list.
+ * \param table pointer to a privtab.
+ * \param str a space-separated string of privilege names to apply.
+ * \param origprivs the original privileges.
+ * \return a privilege bitmask.
+ */
+int
+list_to_privs(PRIV *table, const char *str, long int origprivs)
+{
+ PRIV *c;
+ long int yes = 0;
+ long int no = 0;
+ char *p, *r;
+ char tbuf1[BUFFER_LEN];
+ int not;
+ int words = 0;
+
+ if (!str || !*str)
+ return origprivs;
+ strcpy(tbuf1, str);
+ r = trim_space_sep(tbuf1, ' ');
+ while ((p = split_token(&r, ' '))) {
+ words++;
+ not = 0;
+ if (*p == '!') {
+ not = 1;
+ if (!*++p)
+ continue;
+ }
+ for (c = table; c->name; c++) {
+ if (!strcasecmp(c->name, p)) {
+ if (not)
+ no |= c->bits_to_set;
+ else
+ yes |= c->bits_to_set;
+ break;
+ }
+ }
+ }
+ return ((origprivs | yes) & ~no);
+}
+
+
/** Convert a string to 2 sets of privilege bits, privs to set and
* privs to clear.
* \param table pointer to a privtab.