/** Check to see that the lock type is a valid type. * If it's not in our lock table, it's not valid, * unless it begins with 'user:'******'t allow '|' in lock names because it * will confuse our db-reading routines. * * Might destructively modify name. * * \param player the enactor, for notification. * \param thing object on which to check the lock. * \param name name of lock type. * \return lock type, or NULL. */ static lock_type check_lock_type(dbref player, dbref thing, lock_type name) { lock_type ll; char *sp; /* Special-case for basic locks. */ if (!name || !*name) return Basic_Lock; /* Normal locks. */ ll = match_lock(name); if (ll != NULL) return ll; /* If the lock is set, it's allowed, whether it exists normally or not. */ if (getlock(thing, name) != TRUE_BOOLEXP) return name; /* Check to see if it's a well-formed user-defined lock. */ sp = strchr(name, ':'); if (!sp) { notify(player, T("Unknown lock type.")); return NULL; } *sp++ = '\0'; if (!string_prefix("User", name)) { notify(player, T("Unknown lock type.")); return NULL; } if (strchr(sp, '|')) { notify(player, T("The character \'|\' may not be used in lock names.")); return NULL; } if (!good_atr_name(sp)) { notify(player, T("That is not a valid lock name.")); return NULL; } return sp; }
/** Check to see that the lock type is a valid type. * If it's not in our lock table, it's not valid, * unless it begins with 'user:'******'t allow '|' in lock names because it * will confuse our db-reading routines. * * * \param player the enactor, for notification. * \param thing object on which to check the lock. * \param name name of lock type. * \return lock type, or NULL. */ static lock_type check_lock_type(dbref player, dbref thing, lock_type name) { lock_type ll; char user_name[BUFFER_LEN]; char *colon; /* Special-case for basic locks. */ if (!name || !*name) return Basic_Lock; /* Normal locks. */ ll = match_lock(name); if (ll != NULL) return ll; /* If the lock is set, it's allowed, whether it exists normally or not. */ if (getlock(thing, name) != TRUE_BOOLEXP) return name; /* Check to see if it's a well-formed user-defined lock. */ if (!string_prefix(name, "User:"******"Unknown lock type.")); return NULL; } if (strchr(name, '|')) { notify(player, T("The character \'|\' may not be used in lock names.")); return NULL; } colon = strchr(name, ':') + 1; mush_strncpy(user_name, colon, BUFFER_LEN); if (!good_atr_name(user_name)) { notify(player, T("That is not a valid lock name.")); return NULL; } return colon; }