static void _water_get_flags(u32b flgs[TR_FLAG_SIZE]) 
{
    add_flag(flgs, TR_RES_ACID);

    if (p_ptr->lev >= 25)
        add_flag(flgs, TR_SPEED);

    _get_flags(flgs);
}
static void _earth_get_flags(u32b flgs[TR_FLAG_SIZE]) 
{
    add_flag(flgs, TR_RES_FIRE);
    add_flag(flgs, TR_RES_COLD);
    add_flag(flgs, TR_RES_ELEC);
    add_flag(flgs, TR_RES_SHARDS);
    add_flag(flgs, TR_SPEED);
    add_flag(flgs, TR_REGEN);

    _get_flags(flgs);
}
static void _fire_get_flags(u32b flgs[TR_FLAG_SIZE]) 
{
    add_flag(flgs, TR_RES_FIRE);
    add_flag(flgs, TR_SH_FIRE);

    if (p_ptr->lev >= 25)
        add_flag(flgs, TR_SPEED);

    if (p_ptr->lev >= 40)
        add_flag(flgs, TR_RES_ELEC);

    _get_flags(flgs);
}
static void _air_get_flags(u32b flgs[TR_FLAG_SIZE]) 
{
    add_flag(flgs, TR_RES_ELEC);
    add_flag(flgs, TR_SPEED);

    if (p_ptr->lev >= 25)
    {
        add_flag(flgs, TR_RES_ACID);
        add_flag(flgs, TR_RES_FIRE);
        add_flag(flgs, TR_RES_COLD);
        add_flag(flgs, TR_SH_ELEC);
    }

    _get_flags(flgs);
}
Esempio n. 5
0
int read_flags(uint64_t *status, enum pv_vg_lv_e type, int mask, const struct dm_config_value *cv)
{
	unsigned f;
	uint64_t s = UINT64_C(0);
	const struct flag *flags;

	if (!(flags = _get_flags(type)))
		return_0;

	if (cv->type == DM_CFG_EMPTY_ARRAY)
		goto out;

	while (cv) {
		if (cv->type != DM_CFG_STRING) {
			log_error("Status value is not a string.");
			return 0;
		}

		for (f = 0; flags[f].description; f++)
			if ((flags[f].kind & mask) &&
			    !strcmp(flags[f].description, cv->v.str)) {
				s |= flags[f].mask;
				break;
			}

		if (type == VG_FLAGS && !strcmp(cv->v.str, "PARTIAL")) {
			/*
			 * Exception: We no longer write this flag out, but it
			 * might be encountered in old backup files, so restore
			 * it in that case. It is never part of live metadata
			 * though, so only vgcfgrestore needs to be concerned
			 * by this case.
			 */
			s |= PARTIAL_VG;
		} else if (!flags[f].description && (mask & STATUS_FLAG)) {
			log_error("Unknown status flag '%s'.", cv->v.str);
			return 0;
		}

		cv = cv->next;
	}

      out:
	*status |= s;
	return 1;
}
Esempio n. 6
0
/*
 * Converts a bitset to an array of string values,
 * using one of the tables defined at the top of
 * the file.
 */
int print_flags(uint64_t status, int type, char *buffer, size_t size)
{
	int f, first = 1;
	const struct flag *flags;

	if (!(flags = _get_flags(type)))
		return_0;

	if (!emit_to_buffer(&buffer, &size, "["))
		return 0;

	for (f = 0; flags[f].mask; f++) {
		if (status & flags[f].mask) {
			status &= ~flags[f].mask;

			if ((type & STATUS_FLAG) != flags[f].kind)
				continue;

			/* Internal-only flag? */
			if (!flags[f].description)
				continue;

			if (!first) {
				if (!emit_to_buffer(&buffer, &size, ", "))
					return 0;
			} else
				first = 0;
	
			if (!emit_to_buffer(&buffer, &size, "\"%s\"",
			    flags[f].description))
				return 0;
		}
	}

	if (!emit_to_buffer(&buffer, &size, "]"))
		return 0;

	if (status)
		log_error("Metadata inconsistency: Not all flags successfully "
			  "exported.");

	return 1;
}
Esempio n. 7
0
/*
 * Converts a bitset to an array of string values,
 * using one of the tables defined at the top of
 * the file.
 */
int print_flags(char *buffer, size_t size, enum pv_vg_lv_e type, int mask, uint64_t status)
{
	int f, first = 1;
	const struct flag *flags;

	if (!(flags = _get_flags(type)))
		return_0;

	if (!emit_to_buffer(&buffer, &size, "["))
		return_0;

	for (f = 0; flags[f].mask; f++) {
		if (status & flags[f].mask) {
			status &= ~flags[f].mask;

			if (mask != flags[f].kind)
				continue;

			/* Internal-only flag? */
			if (!flags[f].description)
				continue;

			if (!first) {
				if (!emit_to_buffer(&buffer, &size, ", "))
					return_0;
			} else
				first = 0;
	
			if (!emit_to_buffer(&buffer, &size, "\"%s\"",
					    flags[f].description))
				return_0;
		}
	}

	if (!emit_to_buffer(&buffer, &size, "]"))
		return_0;

	if (status)
		log_warn(INTERNAL_ERROR "Metadata inconsistency: "
			 "Not all flags successfully exported.");

	return 1;
}