Example #1
0
void do_list(struct response *resp)
{
	long long int start = resp->r_start;
	long long int length = resp->r_length;
	int conflict = false;

	if (resp->r_fpos != 0 && fno[resp->r_fpos] == 0) {
		strcpy(errdetail, "Invalid file number");
		sprintf(badtoken, "%ld", resp->r_fpos);
		resp->r_status = STATUS_ERRNO;
		resp->r_errno = EBADF;
		return;
	}

	resp->r_lock_type = F_WRLCK;

	make_test_item(start, lock_end(start, length));

	while (tl_head != NULL) {
		conflict |=
		    list_locks(tl_head->tl_start, tl_head->tl_end, resp);
		remove_test_list_head();
	}

	if (conflict)
		resp->r_status = STATUS_DENIED;
	else
		resp->r_status = STATUS_AVAILABLE;

	resp->r_lock_type = F_WRLCK;
	resp->r_start = start;
	resp->r_length = length;
}
Example #2
0
/** User interface to list locks.
 * \verbatim
 * This function implements @list/locks.
 * \endverbatim
 * \param player the enactor.
 * \param arg wildcard pattern of flag names to list, or NULL for all.
 * \param lc if 1, list flags in lowercase.
 * \param label label to prefix to list.
 */
void
do_list_locks(dbref player, const char *arg, int lc, const char *label)
{
  char buff[BUFFER_LEN];
  char *bp = buff;
  list_locks(buff, &bp, arg);
  *bp = '\0';
  notify_format(player, "%s: %s", label, lc ? strlower(buff) : buff);
}