text:
/**
 */
package org_eclipse_smarthome_schemas_thing_description_v1__0Simplified.util;

import java.util.Map;

import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.common.util.ResourceLocator;

import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.util.EObjectValidator;

import org_eclipse_smarthome_schemas_thing_description_v1__0Simplified.*;

/**
 *
 * The Validator for the model.
 *
 * @see org_eclipse_smarthome_schemas_thing_description_v1__0Simplified.org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage
 * @generated
 */
public class org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedValidator extends EObjectValidator {
	/**
	 * The cached model package
	 *
	 *
	 * @generated
	 */
	public static final org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedValidator INSTANCE = new org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedValidator();

	/**
	 * A constant for the {@link org.eclipse.emf.common.util.Diagnostic#getSource() source} of diagnostic {@link org.eclipse.emf.common.util.Diagnostic#getCode() codes} from this package.
	 *
	 *
	 * @see org.eclipse.emf.common.util.Diagnostic#getSource()
	 * @see org.eclipse.emf.common.util.Diagnostic#getCode()
	 * @generated
	 */
	public static final String DIAGNOSTIC_SOURCE = "org_eclipse_smarthome_schemas_thing_description_v1__0Simplified";

	/**
	 * A constant with a fixed name that can be used as the base value for additional hand written constants.
	 *
	 *
	 * @generated
	 */
	private static final int GENERATED_DIAGNOSTIC_CODE_COUNT = 0;

	/**
	 * A constant with a fixed name that can be used as the base value for additional hand written constants in a derived class.
	 *
	 *
	 * @generated
	 */
	protected static final int DIAGNOSTIC_CODE_COUNT = GENERATED_DIAGNOSTIC_CODE_COUNT;

	/**
	 * Creates an instance of the switch.
	 *
	 *
	 * @generated
	 */
	public org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedValidator() {
		super();
	}

	/**
	 * Returns the package of this validator switch.
	 *
	 *
	 * @generated
	 */
	@Override
	protected EPackage getEPackage() {
	  return org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.eINSTANCE;
	}

	/**
	 * Calls validateXXX for the corresponding classifier of the model.
	 *
	 *
	 * @generated
	 */
	@Override
	protected boolean validate(int classifierID, Object value, DiagnosticChain diagnostics, Map<Object, Object> context) {
		switch (classifierID) {
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.BRIDGE_TYPE:
				return validateBridgeType((BridgeType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.BRIDGE_TYPE_REF:
				return validateBridgeTypeRef((BridgeTypeRef)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CHANNEL:
				return validateChannel((Channel)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CHANNEL_GROUP:
				return validateChannelGroup((ChannelGroup)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CHANNEL_GROUPS:
				return validateChannelGroups((ChannelGroups)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CHANNEL_GROUP_TYPE:
				return validateChannelGroupType((ChannelGroupType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CHANNELS:
				return validateChannels((Channels)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CHANNEL_TYPE:
				return validateChannelType((ChannelType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CONFIG_DESCRIPTION:
				return validateConfigDescription((ConfigDescription)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CONFIG_DESCRIPTION_REF:
				return validateConfigDescriptionRef((ConfigDescriptionRef)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CONFIG_DESCRIPTIONS_TYPE:
				return validateConfigDescriptionsType((ConfigDescriptionsType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.CRITERIA_TYPE:
				return validateCriteriaType((CriteriaType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.EVENT:
				return validateEvent((Event)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.FILTER_TYPE:
				return validateFilterType((FilterType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.OPTION:
				return validateOption((Option)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.OPTIONS:
				return validateOptions((Options)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.OPTIONS_TYPE:
				return validateOptionsType((OptionsType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.OPTION_TYPE:
				return validateOptionType((OptionType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.PARAMETER:
				return validateParameter((Parameter)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.PARAMETER_GROUP:
				return validateParameterGroup((ParameterGroup)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.PROPERTIES:
				return validateProperties((Properties)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.PROPERTY:
				return validateProperty((Property)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.STATE:
				return validateState((State)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.SUPPORTED_BRIDGE_TYPE_REFS:
				return validateSupportedBridgeTypeRefs((SupportedBridgeTypeRefs)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.TAGS:
				return validateTags((Tags)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.THING_DESCRIPTIONS_TYPE:
				return validateThingDescriptionsType((ThingDescriptionsType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.THING_TYPE:
				return validateThingType((ThingType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.PARAMETER_TYPE:
				return validateParameterType((ParameterType)value, diagnostics, context);
			case org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.UNIT_TYPE:
				return validateUnitType((UnitType)value, diagnostics, context);
			default:
				return true;
		}
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateBridgeType(BridgeType bridgeType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(bridgeType, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validateThingType_patternExtensible(bridgeType, diagnostics, context);
		if (result || diagnostics != null) result &= validateThingType_patternId(bridgeType, diagnostics, context);
		return result;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateBridgeTypeRef(BridgeTypeRef bridgeTypeRef, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(bridgeTypeRef, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(bridgeTypeRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(bridgeTypeRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(bridgeTypeRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(bridgeTypeRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(bridgeTypeRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(bridgeTypeRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(bridgeTypeRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(bridgeTypeRef, diagnostics, context);
		if (result || diagnostics != null) result &= validateBridgeTypeRef_patternId(bridgeTypeRef, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternId constraint of 'Bridge Type Ref'.
	 *
	 *
	 * @generated
	 */
	protected static final String BRIDGE_TYPE_REF__PATTERN_ID__EEXPRESSION = "self.id.matches('[A-Za-z0-9\\\\-_]+')";

	/**
	 * Validates the patternId constraint of 'Bridge Type Ref'.
	 *
	 *
	 * @generated
	 */
	public boolean validateBridgeTypeRef_patternId(BridgeTypeRef bridgeTypeRef, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.BRIDGE_TYPE_REF,
				 bridgeTypeRef,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternId",
				 BRIDGE_TYPE_REF__PATTERN_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateChannel(Channel channel, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(channel, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validateChannel_patternId(channel, diagnostics, context);
		if (result || diagnostics != null) result &= validateChannel_patternTypeId(channel, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternId constraint of 'Channel'.
	 *
	 *
	 * @generated
	 */
	protected static final String CHANNEL__PATTERN_ID__EEXPRESSION = "self.id.matches('[A-Za-z0-9\\\\-_]+')";

	/**
	 * Validates the patternId constraint of 'Channel'.
	 *
	 *
	 * @generated
	 */
	public boolean validateChannel_patternId(Channel channel, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.CHANNEL,
				 channel,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternId",
				 CHANNEL__PATTERN_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the patternTypeId constraint of 'Channel'.
	 *
	 *
	 * @generated
	 */
	protected static final String CHANNEL__PATTERN_TYPE_ID__EEXPRESSION = "self.typeId.matches('[A-Za-z0-9\\\\-_.]+')";

	/**
	 * Validates the patternTypeId constraint of 'Channel'.
	 *
	 *
	 * @generated
	 */
	public boolean validateChannel_patternTypeId(Channel channel, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.CHANNEL,
				 channel,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternTypeId",
				 CHANNEL__PATTERN_TYPE_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateChannelGroup(ChannelGroup channelGroup, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(channelGroup, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validateChannelGroup_patternId(channelGroup, diagnostics, context);
		if (result || diagnostics != null) result &= validateChannelGroup_patternTypeId(channelGroup, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternId constraint of 'Channel Group'.
	 *
	 *
	 * @generated
	 */
	protected static final String CHANNEL_GROUP__PATTERN_ID__EEXPRESSION = "self.id.matches('[A-Za-z0-9\\\\-_]+')";

	/**
	 * Validates the patternId constraint of 'Channel Group'.
	 *
	 *
	 * @generated
	 */
	public boolean validateChannelGroup_patternId(ChannelGroup channelGroup, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.CHANNEL_GROUP,
				 channelGroup,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternId",
				 CHANNEL_GROUP__PATTERN_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the patternTypeId constraint of 'Channel Group'.
	 *
	 *
	 * @generated
	 */
	protected static final String CHANNEL_GROUP__PATTERN_TYPE_ID__EEXPRESSION = "self.typeId.matches('[A-Za-z0-9\\\\-_]+')";

	/**
	 * Validates the patternTypeId constraint of 'Channel Group'.
	 *
	 *
	 * @generated
	 */
	public boolean validateChannelGroup_patternTypeId(ChannelGroup channelGroup, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.CHANNEL_GROUP,
				 channelGroup,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternTypeId",
				 CHANNEL_GROUP__PATTERN_TYPE_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateChannelGroups(ChannelGroups channelGroups, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(channelGroups, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateChannelGroupType(ChannelGroupType channelGroupType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(channelGroupType, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(channelGroupType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(channelGroupType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(channelGroupType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(channelGroupType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(channelGroupType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(channelGroupType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(channelGroupType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(channelGroupType, diagnostics, context);
		if (result || diagnostics != null) result &= validateChannelGroupType_patternId(channelGroupType, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternId constraint of 'Channel Group Type'.
	 *
	 *
	 * @generated
	 */
	protected static final String CHANNEL_GROUP_TYPE__PATTERN_ID__EEXPRESSION = "self.id.matches('[A-Za-z0-9\\\\-_]+')";

	/**
	 * Validates the patternId constraint of 'Channel Group Type'.
	 *
	 *
	 * @generated
	 */
	public boolean validateChannelGroupType_patternId(ChannelGroupType channelGroupType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.CHANNEL_GROUP_TYPE,
				 channelGroupType,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternId",
				 CHANNEL_GROUP_TYPE__PATTERN_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateChannels(Channels channels, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(channels, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateChannelType(ChannelType channelType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(channelType, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(channelType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(channelType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(channelType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(channelType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(channelType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(channelType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(channelType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(channelType, diagnostics, context);
		if (result || diagnostics != null) result &= validateChannelType_patternId(channelType, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternId constraint of 'Channel Type'.
	 *
	 *
	 * @generated
	 */
	protected static final String CHANNEL_TYPE__PATTERN_ID__EEXPRESSION = "self.id.matches('[A-Za-z0-9\\\\-_]+')";

	/**
	 * Validates the patternId constraint of 'Channel Type'.
	 *
	 *
	 * @generated
	 */
	public boolean validateChannelType_patternId(ChannelType channelType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.CHANNEL_TYPE,
				 channelType,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternId",
				 CHANNEL_TYPE__PATTERN_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateConfigDescription(ConfigDescription configDescription, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(configDescription, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(configDescription, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(configDescription, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(configDescription, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(configDescription, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(configDescription, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(configDescription, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(configDescription, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(configDescription, diagnostics, context);
		if (result || diagnostics != null) result &= validateConfigDescription_patternUri(configDescription, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternUri constraint of 'Config Description'.
	 *
	 *
	 * @generated
	 */
	protected static final String CONFIG_DESCRIPTION__PATTERN_URI__EEXPRESSION = "(self.uri=null) or self.uri.matches('[A-Za-z0-9\\\\-_]+(:[A-Za-z0-9\\\\-_]+){1,2}')";

	/**
	 * Validates the patternUri constraint of 'Config Description'.
	 *
	 *
	 * @generated
	 */
	public boolean validateConfigDescription_patternUri(ConfigDescription configDescription, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.CONFIG_DESCRIPTION,
				 configDescription,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternUri",
				 CONFIG_DESCRIPTION__PATTERN_URI__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateConfigDescriptionRef(ConfigDescriptionRef configDescriptionRef, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(configDescriptionRef, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(configDescriptionRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(configDescriptionRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(configDescriptionRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(configDescriptionRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(configDescriptionRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(configDescriptionRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(configDescriptionRef, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(configDescriptionRef, diagnostics, context);
		if (result || diagnostics != null) result &= validateConfigDescriptionRef_patternUri(configDescriptionRef, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternUri constraint of 'Config Description Ref'.
	 *
	 *
	 * @generated
	 */
	protected static final String CONFIG_DESCRIPTION_REF__PATTERN_URI__EEXPRESSION = "self.uri.matches('[A-Za-z0-9\\\\-_]+(:[A-Za-z0-9\\\\-_]+){1,2}')";

	/**
	 * Validates the patternUri constraint of 'Config Description Ref'.
	 *
	 *
	 * @generated
	 */
	public boolean validateConfigDescriptionRef_patternUri(ConfigDescriptionRef configDescriptionRef, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.CONFIG_DESCRIPTION_REF,
				 configDescriptionRef,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternUri",
				 CONFIG_DESCRIPTION_REF__PATTERN_URI__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateConfigDescriptionsType(ConfigDescriptionsType configDescriptionsType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(configDescriptionsType, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateCriteriaType(CriteriaType criteriaType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(criteriaType, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateEvent(Event event, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(event, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateFilterType(FilterType filterType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(filterType, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateOption(Option option, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(option, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateOptions(Options options, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(options, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateOptionsType(OptionsType optionsType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(optionsType, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateOptionType(OptionType optionType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(optionType, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateParameter(Parameter parameter, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(parameter, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateParameterGroup(ParameterGroup parameterGroup, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(parameterGroup, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateProperties(Properties properties, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(properties, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateProperty(Property property, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(property, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateState(State state, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(state, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateSupportedBridgeTypeRefs(SupportedBridgeTypeRefs supportedBridgeTypeRefs, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(supportedBridgeTypeRefs, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateTags(Tags tags, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return validate_EveryDefaultConstraint(tags, diagnostics, context);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateThingDescriptionsType(ThingDescriptionsType thingDescriptionsType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(thingDescriptionsType, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(thingDescriptionsType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(thingDescriptionsType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(thingDescriptionsType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(thingDescriptionsType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(thingDescriptionsType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(thingDescriptionsType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(thingDescriptionsType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(thingDescriptionsType, diagnostics, context);
		if (result || diagnostics != null) result &= validateThingDescriptionsType_patternBindingId(thingDescriptionsType, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternBindingId constraint of 'Thing Descriptions Type'.
	 *
	 *
	 * @generated
	 */
	protected static final String THING_DESCRIPTIONS_TYPE__PATTERN_BINDING_ID__EEXPRESSION = "self.bindingId.matches('[A-Za-z0-9\\\\-_]+')";

	/**
	 * Validates the patternBindingId constraint of 'Thing Descriptions Type'.
	 *
	 *
	 * @generated
	 */
	public boolean validateThingDescriptionsType_patternBindingId(ThingDescriptionsType thingDescriptionsType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.THING_DESCRIPTIONS_TYPE,
				 thingDescriptionsType,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternBindingId",
				 THING_DESCRIPTIONS_TYPE__PATTERN_BINDING_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateThingType(ThingType thingType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		if (!validate_NoCircularContainment(thingType, diagnostics, context)) return false;
		boolean result = validate_EveryMultiplicityConforms(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryDataValueConforms(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryReferenceIsContained(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryBidirectionalReferenceIsPaired(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryProxyResolves(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_UniqueID(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryKeyUnique(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validate_EveryMapEntryUnique(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validateThingType_patternExtensible(thingType, diagnostics, context);
		if (result || diagnostics != null) result &= validateThingType_patternId(thingType, diagnostics, context);
		return result;
	}

	/**
	 * The cached validation expression for the patternExtensible constraint of 'Thing Type'.
	 *
	 *
	 * @generated
	 */
	protected static final String THING_TYPE__PATTERN_EXTENSIBLE__EEXPRESSION = "(self.extensible=null) or self.extensible.matches('[A-Za-z0-9\\\\-_.]+(,( )?[A-Za-z0-9\\\\-_.]+)*')";

	/**
	 * Validates the patternExtensible constraint of 'Thing Type'.
	 *
	 *
	 * @generated
	 */
	public boolean validateThingType_patternExtensible(ThingType thingType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.THING_TYPE,
				 thingType,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternExtensible",
				 THING_TYPE__PATTERN_EXTENSIBLE__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 * The cached validation expression for the patternId constraint of 'Thing Type'.
	 *
	 *
	 * @generated
	 */
	protected static final String THING_TYPE__PATTERN_ID__EEXPRESSION = "self.id.matches('[A-Za-z0-9\\\\-_]+')";

	/**
	 * Validates the patternId constraint of 'Thing Type'.
	 *
	 *
	 * @generated
	 */
	public boolean validateThingType_patternId(ThingType thingType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return
			validate
				(org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedPackage.Literals.THING_TYPE,
				 thingType,
				 diagnostics,
				 context,
				 "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
				 "patternId",
				 THING_TYPE__PATTERN_ID__EEXPRESSION,
				 Diagnostic.ERROR,
				 DIAGNOSTIC_SOURCE,
				 0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateParameterType(ParameterType parameterType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public boolean validateUnitType(UnitType unitType, DiagnosticChain diagnostics, Map<Object, Object> context) {
		return true;
	}

	/**
	 * Returns the resource locator that will be used to fetch messages for this validator's diagnostics.
	 *
	 *
	 * @generated
	 */
	@Override
	public ResourceLocator getResourceLocator() {
		// TODO
		// Specialize this to return a resource locator for messages specific to this validator.
		// Ensure that you remove @generated or mark it @generated NOT
		return super.getResourceLocator();
	}

} //org_eclipse_smarthome_schemas_thing_description_v1__0SimplifiedValidator


text:
package org.apache.servicecomb.common.rest.definition.path;

import java.util.Map;

import org.apache.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor;
import org.apache.servicecomb.common.rest.codec.query.QueryCodec;
import org.apache.servicecomb.common.rest.definition.RestParam;
import org.apache.servicecomb.common.rest.definition.path.URLPathBuilder.URLPathStringBuilder;

public class QueryVarParamWriter extends AbstractUrlParamWriter {
  private final QueryCodec queryCodec;

  public QueryVarParamWriter(RestParam param) {
    this.param = param;
    this.queryCodec = ((QueryProcessor) param.getParamProcessor()).getQueryCodec();
  }

  @Override
  public void write(URLPathStringBuilder builder, Map<String, Object> args) throws Exception {
    Object value = getParamValue(args);
    queryCodec.encode(builder, param.getParamName(), value);
  }
}

redpajama_set_name: RedPajamaGithub


text:
using System.Linq;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;

namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server;

// This project is a CLI tool, so we don't expect anyone to reference it
// as a runtime library. As such we consider it reasonable to mark the
// following method as public purely so the E2E tests project can invoke it.

/// <summary>
/// Intended for framework test use only.
/// </summary>
public class Program
{
    /// <summary>
    /// Intended for framework test use only.
    /// </summary>
    public static IHost BuildWebHost(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureHostConfiguration(config =>
            {
                var applicationPath = args.SkipWhile(a => a != "--applicationpath").Skip(1).First();
                var applicationDirectory = Path.GetDirectoryName(applicationPath)!;
                var name = Path.ChangeExtension(applicationPath, ".staticwebassets.runtime.json");
                name = !File.Exists(name) ? Path.ChangeExtension(applicationPath, ".StaticWebAssets.xml") : name;

                var inMemoryConfiguration = new Dictionary<string, string?>
                {
                    [WebHostDefaults.EnvironmentKey] = "Development",
                    ["Logging:LogLevel:Microsoft"] = "Warning",
                    ["Logging:LogLevel:Microsoft.Hosting.Lifetime"] = "Information",
                    [WebHostDefaults.StaticWebAssetsKey] = name,
                };

                config.AddInMemoryCollection(inMemoryConfiguration);
                config.AddJsonFile(Path.Combine(applicationDirectory, "blazor-devserversettings.json"), optional: true, reloadOnChange: true);
            })
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStaticWebAssets();
                webBuilder.UseStartup<Startup>();
            }).Build();
}


text: google-site-verification: google3988ae11ee972904.html


text:
/*
 * @description   Práce se dynamickým zásobníkem
 *                pozn. funkce nekontroluji platnost ukazatele na zasobnik
 * @author        Vendula Poncová - xponco00
 * @projekt       IFJ11
 * @date
 */

#ifndef STACK_H_INCLUDED
#define STACK_H_INCLUDED

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#define STACK_EOK     0
#define STACK_ERR    -1
#define STACK_EEMPTY -2
#define STACK_EALLOC -5

typedef struct tSItem {   // struktura pro polo¾ku v zásobníku
   struct tSItem *next;     // ukazatel na dal¹í polo¾ku
   void *data;             // ukazatel na data
} TSItem;

typedef struct {          // struktura pro zásobník
   TSItem *top;          // ukazatel na vrchol zásobníku
} TStack;

// Funkce pro práci se zásobníkem:

void stackInit     (TStack *s);
void stackDelete   (TStack *s);

inline void *stackTop    (TStack *s);
inline int stackPop      (TStack *s);
inline int stackPush     (TStack *s, void *data);

inline void *stackTopPop (TStack *s);

/////////////////////////////////////////////////////////////////
/* inline funkce */

/*
 * Vrátí nulu, pokud je zásobník prázdný, jinak nenulovou hodnotu.
 * Není o¹etøena platnost ukazatele na zásobník.
 * @param   ukazatel na zásobník
 * @return  true/false
 */
#define stackEmpty(S) ((S)->top == NULL)

/*
 * Vrátí ukazatel na data z polo¾ky na vrcholu zásobníku.
 * Pokud je zasobnik prazdny, vrátí se NULL.
 * @param   ukazatel na zásobník
 * @return  ukazatel na data nebo NULL
 */
inline void *stackTop (TStack *s) {

   if (!stackEmpty(s)) {
      return s->top->data;
   } else return NULL;

}

/*
 * Vyjme polo¾ku na vrcholu zásobníku.
 * Pokud je zásobník prázdný, vyvolá se chyba.
 * @param   ukazatel na zásobník
 * @return  kód chyby
 */
inline int stackPop (TStack *s) {

   if (!stackEmpty(s)) {
      TSItem *pom = s->top;
      s->top = s->top->next;
      free(pom);
   } else return STACK_EEMPTY; // pøístup do prázdného zásobníku

   return STACK_EOK;
}

/*
 * Vlo¾í na vrchol zásobníku novou polo¾ku s daty.
 * Pokud je nedostatek pamìti, vyvolá se chyba.
 * @param   ukazatel na zásobník
 * @param   ukazatel na data
 * @return  kód chyby
 */
inline int stackPush (TStack *s, void *data) {

   TSItem *elem;

   if ( (elem = (TSItem *)malloc(sizeof(TSItem))) != NULL ) {
      elem->data = data;
      elem->next = s->top;
      s->top = elem;

   } else return STACK_EALLOC; // nedostatek pamìti

   return STACK_EOK;
}

/*
 * Vrátí ukazatel na data na vrcholu zásobníku
 * a vyjme polo¾ku z vrcholu zásobníku.
 * Pokud dojde k chybì, vrátí NULL.
 * @param   ukazatel na zásobník
 * @return  ukazatel na data nebo NULL
 */
inline void *stackTopPop (TStack *s) {

   void *pom = stackTop(s);
   if ((pom == NULL) || (stackPop(s) != STACK_EOK)) {
      return NULL;
   } else return pom;
}

#endif // STACK_H_INCLUDED


text:
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cloudera.flume.reporter.ganglia;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketAddress;
import java.net.SocketException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.hadoop.metrics.spi.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cloudera.flume.conf.Context;
import com.cloudera.flume.conf.FlumeConfiguration;
import com.cloudera.flume.conf.SinkFactory.SinkBuilder;
import com.cloudera.flume.core.Attributes;
import com.cloudera.flume.core.Event;
import com.cloudera.flume.core.EventSink;
import com.cloudera.flume.core.Attributes.Type;
import com.cloudera.util.NetUtils;
import com.google.common.base.Preconditions;

/**
 * This sink takes a specified list of ganglia gmond servers, a event attribute
 * (from a report/event), a units name, and a Flume attribute type, and emits
 * XDR formatted UDP packets so that the metric can be seen in Ganglia. This
 * specifically supports the ganglia >=3.1.x wire format.
 *
 * Originally based on o.a.h.metrics.ganglia.GangliaContext31 / HADOOP-4675
 *
 * XDR spec http://www.faqs.org/rfcs/rfc1832.html
 *
 * This is not thread safe.
 */
public class GangliaSink extends EventSink.Base {

  private static final String DEFAULT_GROUP = "flume";
  private static final int DEFAULT_TMAX = 60;
  private static final int DEFAULT_DMAX = 0;
  private static final int DEFAULT_PORT = 8649;
  private static final int BUFFER_SIZE = 1500; // as per libgmond.c

  private static final Logger LOG = LoggerFactory.getLogger(GangliaSink.class);
  private final String servers;

  private static final Map<Type, String> typeTable =
      new HashMap<Type, String>() {
        private static final long serialVersionUID = 1L;
        {
          put(Type.STRING, "string");
          put(Type.INT, "int32");
          put(Type.LONG, "float"); // Conversion happens here, originally from
          // hadoop source
          put(Type.DOUBLE, "double");
        }
      };

  private byte[] buffer = new byte[BUFFER_SIZE];
  private int offset;

  private List<? extends SocketAddress> metricsServers;

  private DatagramSocket datagramSocket;
  final private String attr; // turns into the metric name.
  final private String units;
  final private Type type;

  /** Creates a new instance of GangliaContext */
  public GangliaSink(String gangliaSvrs, String attr, String units, Type t) {
    this.servers = gangliaSvrs;
    this.attr = attr;
    this.units = units;
    this.type = t;
  }

  /**
   * This currently only outputs one metric from a report, and relies on the
   * sink constructor to give details about the typing information.
   *
   * This may become moot if typing information is provided by flume's data.
   */
  @Override
  public void append(Event e) throws IOException {
    String value;
    switch (type) {
    case LONG: {
      Long l = Attributes.readLong(e, attr);
      if (l == null) {
        // attribute not present, drop
        return;
      }
      value = l.toString();
      break;
    }
    case INT: {
      Integer i = Attributes.readInt(e, attr);
      if (i == null) {
        // attribute not present, drop
        return;
      }
      value = i.toString();
      break;
    }
    case STRING: {
      String s = Attributes.readString(e, attr);
      if (s == null) {
        // attribute not present, drop
        return;
      }
      value = s;
      break;
    }
    case DOUBLE: {
      Double d = Attributes.readDouble(e, attr);
      if (d == null) {
        // attribute not present,drop
        return;
      }
      value = d.toString();
      break;
    }
    default:
      return;
    }
    emitMetric(attr, typeTable.get(type), value, units);
    super.append(e);
  }

  @Override
  public void open() throws IOException {
    // TODO (jon) need to worry about SecurityException and other
    // RuntimeExceptions.

    // From o.a.h.metrics.spi.Util
    // This can throw IllegalArgumentException or SecurityException
    metricsServers = Util.parse(servers, DEFAULT_PORT);

    try {
      datagramSocket = new DatagramSocket();
    } catch (SocketException se) {
      LOG.warn("problem with ganglia socket", se);
    }

  }

  /**
   * Not thread safe
   */
  @Override
  public void close() throws IOException {
    if (datagramSocket == null) {
      LOG.warn("Double close");
      return;
    }
    datagramSocket.close();
    datagramSocket = null;
  }

  // //////////////////////////////////////////////////////////////////
  // This is ganglia >= 3.1.x wire format. Basically ripped out of
  // HADOOP-4675

  /**
   * This takes a metric and then send it off to the listening ganglia gmond
   * ports via udp.
   *
   * This is not thread safe.
   */
  private void emitMetric(String name, String type, String value, String units)
      throws IOException {
    int slope = 3; // see gmetric.c
    int tmax = DEFAULT_TMAX;
    int dmax = DEFAULT_DMAX;
    String hostName = NetUtils.localhost();

    // First we send out a metadata message
    xdr_int(128); // metric_id = metadata_msg
    xdr_string(hostName); // hostname
    xdr_string(name); // metric name
    xdr_int(0); // spoof = False
    xdr_string(type); // metric type
    xdr_string(name); // metric name
    xdr_string(units); // units
    xdr_int(slope); // slope
    xdr_int(tmax); // tmax, the maximum time between metrics
    xdr_int(dmax); // dmax, the maximum data value
    xdr_int(1); // ???

    /*
     * Num of the entries in extra_value field for Ganglia 3.1.x
     */
    xdr_string("GROUP"); /* Group attribute */
    xdr_string(DEFAULT_GROUP); /* Group value */

    // send to each ganglia metrics listener/server
    for (SocketAddress socketAddress : metricsServers) {
      DatagramPacket packet = new DatagramPacket(buffer, offset, socketAddress);
      datagramSocket.send(packet);
    }

    // Now we send out a message with the actual value.
    // Technically, we only need to send out the metadata message once for
    // each metric, but I don't want to have to record which metrics we did and
    // did not send.
    offset = 0;
    xdr_int(133); // we are sending a string value
    xdr_string(hostName); // hostName
    xdr_string(name); // metric name
    xdr_int(0); // spoof = False
    xdr_string("%s"); // format field
    xdr_string(value); // metric value

    for (SocketAddress socketAddress : metricsServers) {
      DatagramPacket packet = new DatagramPacket(buffer, offset, socketAddress);
      datagramSocket.send(packet);
    }

  }

  /**
   * Puts a string into the buffer by first writing the size of the string as an
   * int, followed by the bytes of the string, padded if necessary to a multiple
   * of 4.
   */
  private void xdr_string(String s) {
    byte[] bytes = s.getBytes();
    int len = bytes.length;
    xdr_int(len);
    System.arraycopy(bytes, 0, buffer, offset, len);
    offset += len;
    pad();
  }

  /**
   * Pads the buffer with zero bytes up to the nearest multiple of 4.
   *
   * Not thread safe
   */
  private void pad() {
    int newOffset = ((offset + 3) / 4) * 4;
    while (offset < newOffset) {
      buffer[offset++] = 0;
    }
  }

  /**
   * Puts an integer into the buffer as 4 bytes, big-endian.
   *
   * Not thread safe
   */
  private void xdr_int(int i) {
    buffer[offset++] = (byte) ((i >> 24) & 0xff);
    buffer[offset++] = (byte) ((i >> 16) & 0xff);
    buffer[offset++] = (byte) ((i >> 8) & 0xff);
    buffer[offset++] = (byte) (i & 0xff);
  }

  // end of rip
  // //////////////////////////////////////////////////////////////////

  public static SinkBuilder builder() {
    return new SinkBuilder() {
      @Override
      public EventSink build(Context context, String... argv) {
        Preconditions.checkArgument(argv.length >= 3 && argv.length <= 4,
            "usage: ganglia(\"attr\", \"units\",\"type\"[, \"gmondservers\"])");

        String ganglias = FlumeConfiguration.get().getGangliaServers(); // default
        String attr = argv[0];
        String units = argv[1];

        String type = argv[2];
        Type t = null;
        // These strings are flume types, not xdr types
        if (type.equals("int")) {
          t = Type.INT;
        } else if (type.equals("long")) {
          t = Type.LONG;
        } else if (type.equals("double")) {
          t = Type.DOUBLE;
        } else if (type.equals("string")) {
          t = Type.STRING;
        } else {
          throw new IllegalArgumentException(
              "Illegal ganglia xdr type: "
                  + type
                  + " != int|long|double|string\n"
                  + "usage: ganglia(\"attr\", \"units\",\"type\"[, \"gmondservers\"]");
        }

        if (argv.length >= 4) {
          ganglias = argv[3];
        }
        EventSink snk = new GangliaSink(ganglias, attr, units, t);
        return snk;

      }
    };
  }
}


text:
title: "Professional Site"
date: 2011-02-21 00:00
---

A few months ago, my friend [Nick](http://blog.nickhoward.ca/) suggested using WordPress for my website, since iWeb wasn't exactly cutting it. I decided not to, since WordPress is blogging software.

I [grew impatient](http://ashfurrow.com/blog/index.php/2011/02/transitioning-from-attero-ingorantiam/) with blogger and finally installed WordPress on my personal website last night.  It's awesome! I'm experimenting with the layout, and I'm thinking about using this WordPress installation as my own site, as a replacement for the current  [ashfurrow.com](http://ashfurrow.com/CoffeeTimer/Ash_Furrow.html). Any thoughts?

<!-- more -->


text:
<?php
/**
 * QuotaServiceResource
 *
 * PHP version 5
 *
 * @category Class
 * @package  Alfaview
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */

/**
 * quotaService/settings.proto
 *
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: version not set
 *
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 * Swagger Codegen version: 2.4.27
 */

/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace Alfaview\Model;
use \Alfaview\ObjectSerializer;

/**
 * QuotaServiceResource Class Doc Comment
 *
 * @category Class
 * @description enums Resource: Unit should be part of the name.
 * @package  Alfaview
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class QuotaServiceResource
{
    /**
     * Possible values of this enum
     */
    const ALL_LIMITS = 'ALL_LIMITS';
    const ROOM_LIMIT = 'ROOM_LIMIT';
    const ROOM_SUBROOM_LIMIT = 'ROOM_SUBROOM_LIMIT';
    const ROOM_ONLINE_SECONDS = 'ROOM_ONLINE_SECONDS';
    const ROOM_CONCURRENT_LIMIT = 'ROOM_CONCURRENT_LIMIT';
    const ROOM_PARTICIPANTS = 'ROOM_PARTICIPANTS';
    const ROOM_SPECTATORS = 'ROOM_SPECTATORS';
    const ROOM_TYPE = 'ROOM_TYPE';
    const MEETING_TYPE = 'MEETING_TYPE';
    const TRANSCRIPTION_SECONDS = 'TRANSCRIPTION_SECONDS';
    const TRANSLATION_LANGUAGE_LIMIT = 'TRANSLATION_LANGUAGE_LIMIT';

    /**
     * Gets allowable values of the enum
     * @return string[]
     */
    public static function getAllowableEnumValues()
    {
        return [
            self::ALL_LIMITS,
            self::ROOM_LIMIT,
            self::ROOM_SUBROOM_LIMIT,
            self::ROOM_ONLINE_SECONDS,
            self::ROOM_CONCURRENT_LIMIT,
            self::ROOM_PARTICIPANTS,
            self::ROOM_SPECTATORS,
            self::ROOM_TYPE,
            self::MEETING_TYPE,
            self::TRANSCRIPTION_SECONDS,
            self::TRANSLATION_LANGUAGE_LIMIT,
        ];
    }
}


text:
		 Loading...

							{{team.name}}


text:
Duis sit amet facilisis ante, ac volutpat ex nullam turpis justo, ultrices non magna

            Posted on 24.July 2016 | Posted in: Miscellaneous

Duis sit amet facilisis ante, ac volutpat ex. Nullam turpis justo, ultrices non magna ac, iaculis posuere nibh. Vestibulum tempor at orci ac fringilla. Nullam rhoncus nunc ac elit tincidunt, egestas congue erat vehicula. Phasellus dui ligula, congue ac arcu ut, pellentesque elementum nunc.

            more »


text:
<?php

namespace FdjBundle\Command;

use FdjBundle\Entity\ClassementJoueurs;
use FdjBundle\Entity\TableCorrespondance;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use FdjBundle\Entity\MatchFini;
use FdjBundle\Entity\Formules;
use FdjBundle\Entity\Sport;
use FdjBundle\Entity\SportCote;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

class ApiClassementJoueursCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('fdj:apiClassementJoueurs')
            ->setDescription('Reception des matchs avec les resultat via l\'api.')
            ->setHelp("Cette commande lance une requette pour recevoir les classements des joueurs");
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln(['cote inputt', '============',]);
        $em = $this->getContainer()->get('doctrine')->getManager();
//        $var = $this->getParameter('api_pass');
//        dump($var);
//        die;

        $api = file_get_contents('https://api.sportradar.com/tennis-t2/en/players/rankings.json?api_key=sax69e9nbmdw8pcuuxucqn6j');
        $classementJoueurs = json_decode($api, true);
//        dump($classementJoueurs["rankings"]);
        $bdds  = $em->getRepository('FdjBundle:ClassementJoueurs')->findBySemaine($classementJoueurs["rankings"][0]['week']);
//        dump($bdds);
        $doublon = null;
        if ($bdds != null){
            foreach ($bdds as $bdd){
                if($bdd->getAnnee() == $classementJoueurs["rankings"][0]['year'] && $bdd->getSemaine() == $classementJoueurs["rankings"][0]['week']){
                    $doublon = 1;
                }
            }
        }
        dump($doublon);
        dump($classementJoueurs["rankings"][0]['week']);
//        dump($bdd->getSemaine());
        dump($classementJoueurs["rankings"][0]['year']);
//        dump($bdd->getAnnee());
        if($doublon == null){
            foreach ($classementJoueurs["rankings"] as $classementJoueur){
//            $classementJoueur['name'];
                dump($classementJoueur["name"]);
                foreach ($classementJoueur["player_rankings"] as $classement){
                    $joueur = new ClassementJoueurs();
                    $joueur->setType($classementJoueur["name"]);
                    $joueur->setAnnee($classementJoueur["year"]);
                    $joueur->setSemaine($classementJoueur["week"]);
                    $joueur->setIdJoueur($classement["player"]["id"]);
                    $joueur->setNomJoueurs($classement["player"]["name"]);
                    $joueur->setNom(explode(', ', $classement["player"]["name"])[0]);
                    $joueur->setPrenom(explode(', ', $classement["player"]["name"])[1]);
                    $joueur->setNationalite($classement["player"]["nationality"]);
                    $joueur->setRang($classement["rank"]);
                    $joueur->setPoints($classement["points"]);
                    $joueur->setRangMouvement($classement["ranking_movement"]);
                    $joueur->setTournoisJoue($classement["tournaments_played"]);
                    $em->persist($joueur);
                    $em->flush();
                    $correspondance  = $em->getRepository('FdjBundle:TableCorrespondance')->findOneBySportRadar($classement["player"]["name"]);
                    if ($correspondance == null){
                        $tableCorrespondance = new TableCorrespondance();
                        $tableCorrespondance->setSportRadar($classement["player"]["name"]);
                        $tableCorrespondance->setIdSportRadar($classement["player"]["id"]);
                        $em->persist($tableCorrespondance);
                        $em->flush();
                    }

                }
            }
        }
        $output->writeln(['============','resultat fin',]);
    }
}


text:
import os
basedir = os.path.abspath(os.path.dirname(__file__))

# BASIC APP CONFIG
WTF_CSRF_ENABLED = True
SECRET_KEY = 'We are the world'
BIND_ADDRESS = '127.0.0.1'
PORT = 9393
LOGIN_TITLE = "PDNS"

# TIMEOUT - for large zones
TIMEOUT = 10

# LOG CONFIG
LOG_LEVEL = 'DEBUG'
LOG_FILE = 'logfile.log'
# For Docker, leave empty string
#LOG_FILE = ''

# Upload
UPLOAD_DIR = os.path.join(basedir, 'upload')

# DATABASE CONFIG
#You'll need MySQL-python
SQLA_DB_USER = 'powerdnsadmin'
SQLA_DB_PASSWORD = 'powerdnsadminpassword'
SQLA_DB_HOST = 'mysqlhostorip'
SQLA_DB_NAME = 'powerdnsadmin'

#MySQL
SQLALCHEMY_DATABASE_URI = 'mysql://'+SQLA_DB_USER+':'\
    +SQLA_DB_PASSWORD+'@'+SQLA_DB_HOST+'/'+SQLA_DB_NAME
#SQLite
#SQLALCHEMY_DATABASE_URI = 'sqlite:////path/to/your/pdns.db'
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
SQLALCHEMY_TRACK_MODIFICATIONS = True

# LDAP CONFIG
LDAP_TYPE = 'ldap'
LDAP_URI = 'ldaps://your-ldap-server:636'
LDAP_USERNAME = 'cn=dnsuser,ou=users,ou=services,dc=duykhanh,dc=me'
LDAP_PASSWORD = 'dnsuser'
LDAP_SEARCH_BASE = 'ou=System Admins,ou=People,dc=duykhanh,dc=me'
# Additional options only if LDAP_TYPE=ldap
LDAP_USERNAMEFIELD = 'uid'
LDAP_FILTER = '(objectClass=inetorgperson)'

## AD CONFIG
#LDAP_TYPE = 'ad'
#LDAP_URI = 'ldaps://your-ad-server:636'
#LDAP_USERNAME = 'cn=dnsuser,ou=Users,dc=domain,dc=local'
#LDAP_PASSWORD = 'dnsuser'
#LDAP_SEARCH_BASE = 'dc=domain,dc=local'
## You may prefer 'userPrincipalName' instead
#LDAP_USERNAMEFIELD = 'sAMAccountName'
## AD Group that you would like to have accesss to web app
#LDAP_FILTER = 'memberof=cn=DNS_users,ou=Groups,dc=domain,dc=local'

# Github Oauth
GITHUB_OAUTH_ENABLE = False
GITHUB_OAUTH_KEY = 'G0j1Q15aRsn36B3aD6nwKLiYbeirrUPU8nDd1wOC'
GITHUB_OAUTH_SECRET = '0WYrKWePeBDkxlezzhFbDn1PBnCwEa0vCwVFvy6iLtgePlpT7WfUlAa9sZgm'
GITHUB_OAUTH_SCOPE = 'email'
GITHUB_OAUTH_URL = 'http://127.0.0.1:5000/api/v3/'
GITHUB_OAUTH_TOKEN = 'http://127.0.0.1:5000/oauth/token'
GITHUB_OAUTH_AUTHORIZE = 'http://127.0.0.1:5000/oauth/authorize'

#Default Auth
BASIC_ENABLED = True
SIGNUP_ENABLED = True

# POWERDNS CONFIG
PDNS_STATS_URL = 'http://172.16.214.131:8081/'
PDNS_API_KEY = 'you never know'
PDNS_VERSION = '3.4.7'

# RECORDS ALLOWED TO EDIT
RECORDS_ALLOW_EDIT = ['A', 'AAAA', 'CNAME', 'SPF', 'PTR', 'MX', 'TXT']

# EXPERIMENTAL FEATURES
PRETTY_IPV6_PTR = False


text:
//Problem 4. Maximal sequence

//Write a program that finds the maximal sequence of equal elements in an array.
//Example:

//input	                            result
//2, 1, 1, 2, 3, 3, 2, 2, 2, 1	    2, 2, 2

using System;

class MaximalSequence
{
    static void Main()
    {

        string input = Console.ReadLine();
        string[] numbersString = input.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

        int[] sequence = new int[numbersString.Length];
        for (int i = 0; i < sequence.Length; i++)
        {
            sequence[i] = int.Parse(numbersString[i]);
        }

        int counter = 1;
        int biggestCounter = 1;
        int currentNumber = 0;

        for (int i = 0; i < sequence.Length - 1; i++)
        {
            if (sequence[i] == sequence[i + 1])
            {
                counter++;
            }
            else
            {
                counter = 1;
            }

            if (counter > biggestCounter)
            {
                biggestCounter = counter;
                currentNumber = sequence[i];
            }
        }
        if (biggestCounter > 1)
        {
            for (int i = 0; i < biggestCounter; i++)
            {
                Console.Write("{0}", currentNumber);
                if (i != biggestCounter - 1)
                {
                    Console.Write(", ");
                }
            }
            Console.WriteLine();
        }
        else
        {
            Console.WriteLine("No maximal sequence in the array.");
        }
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Hypophyllum sericeum Paulet

### Remarks
null


text:
function selfletPlotRequests(requestsTable, maxRtTable, sendToPlotly)

minute = 60000;
serviceName = char(requestsTable.service(1));
serviceMaxRt(1:height(requestsTable),1) = maxRtTable{serviceName, :};

Xdata = requestsTable.timestamp ./ minute;
Ydata = [requestsTable.rt./1000 serviceMaxRt/1000];

selfletCreateFigureReqs(Xdata,Ydata, serviceName, max(Xdata), sendToPlotly);

end


text:
"""
Usage:
  calicoctl endpoint show [--host=<HOSTNAME>] [--orchestrator=<ORCHESTRATOR_ID>]
    [--workload=<WORKLOAD_ID>] [--endpoint=<ENDPOINT_ID>] [--detailed]
  calicoctl endpoint <ENDPOINT_ID> profile (append|remove|set) [--host=<HOSTNAME>]
    [--orchestrator=<ORCHESTRATOR_ID>] [--workload=<WORKLOAD_ID>]  [<PROFILES>...]
  calicoctl endpoint <ENDPOINT_ID> profile show [--host=<HOSTNAME>]
    [--orchestrator=<ORCHESTRATOR_ID>] [--workload=<WORKLOAD_ID>]

Description:
  Configure or show endpoints assigned to existing containers

Options:
 --detailed                         Show additional information
 --host=<HOSTNAME>                  Filters endpoints on a specific host
 --orchestrator=<ORCHESTRATOR_ID>   Filters endpoints created on a specific orchestrator
 --workload=<WORKLOAD_ID>           Filters endpoints on a specific workload
 --endpoint=<ENDPOINT_ID>           Filters endpoints with a specific endpoint ID

Examples:
    Show all endpoints belonging to 'host1':
        $ calicoctl endpoint show --host=host1

    Add a profile called 'profile-A' to the endpoint a1b2c3d4:
        $ calicoctl endpoint a1b2c3d4 profile append profile-A

    Add a profile called 'profile-A' to the endpoint a1b2c3d4, but faster,
    by providing more specific filters:
        $ calicoctl endpoint a1b2c3d4 profile append profile-A --host=host1 --orchestrator=docker --workload=f9e8d7e6
"""
import sys
from collections import defaultdict

from prettytable import PrettyTable
from pycalico.datastore_errors import ProfileAlreadyInEndpoint
from pycalico.datastore_errors import MultipleEndpointsMatch
from pycalico.datastore_errors import ProfileNotInEndpoint

from connectors import client
from utils import print_paragraph
from pycalico.util import validate_characters

def validate_arguments(arguments):
    """
    Validate argument values:
        <PROFILES>

    Arguments not validated:
        <HOSTNAME>
        <ORCHESTRATOR_ID>
        <WORKLOAD_ID>
        <ENDPOINT_ID>

    :param arguments: Docopt processed arguments
    """
    # Validate Profiles
    profile_ok = True
    profiles = arguments.get("<PROFILES>")
    if profiles is not None:
        for profile in profiles:
            profile_ok = validate_characters(profile)

    if not profile_ok:
        print_paragraph("Profile names must be < 40 character long and can "
                        "only contain numbers, letters, dots, dashes and "
                        "underscores.")
        sys.exit(1)

class EndpointSummary(object):
    """
    Simply holder class used to compile workload and endpoint summaries
    (see endpoint_show() command).
    """
    def __init__(self):
        self.workload_ids = set()
        self.num_endpoints = 0

    def add_endpoint(self, endpoint):
        """
        Add an endpoint.  We track unique workload IDs and maintain a count
        of endpoints.

        :param endpoint:  An Endpoint object.
        """
        self.num_endpoints += 1
        self.workload_ids.add(endpoint.workload_id)

def endpoint(arguments):
    """
    Main dispatcher for endpoint commands. Calls the corresponding helper
    function.

    :param arguments: A dictionary of arguments already processed through
    this file's docstring with docopt.
    :return: None
    """
    validate_arguments(arguments)

    if arguments.get("profile"):
        if arguments.get("append"):
            endpoint_profile_append(arguments.get("--host"),
                                    arguments.get("--orchestrator"),
                                    arguments.get("--workload"),
                                    arguments.get("<ENDPOINT_ID>"),
                                    arguments['<PROFILES>'])
        elif arguments.get("remove"):
            endpoint_profile_remove(arguments.get("--host"),
                                    arguments.get("--orchestrator"),
                                    arguments.get("--workload"),
                                    arguments.get("<ENDPOINT_ID>"),
                                    arguments['<PROFILES>'])
        elif arguments.get("set"):
            endpoint_profile_set(arguments.get("--host"),
                                 arguments.get("--orchestrator"),
                                 arguments.get("--workload"),
                                 arguments.get("<ENDPOINT_ID>"),
                                 arguments['<PROFILES>'])
        elif arguments.get("show"):
            endpoint_profile_show(arguments.get("--host"),
                                  arguments.get("--orchestrator"),
                                  arguments.get("--workload"),
                                  arguments.get("<ENDPOINT_ID>"))
    else:
        # calicoctl endpoint show
        endpoint_show(arguments.get("--host"),
                      arguments.get("--orchestrator"),
                      arguments.get("--workload"),
                      arguments.get("--endpoint"),
                      arguments.get("--detailed"))

def endpoint_show(hostname, orchestrator_id, workload_id, endpoint_id,
                  detailed):
    """
    List the profiles for a given endpoint. All parameters will be used to
    filter down which endpoints should be shown.

    :param endpoint_id: The endpoint ID.
    :param workload_id: The workload ID.
    :param orchestrator_id: The orchestrator ID.
    :param hostname: The hostname.
    :param detailed: Optional flag, when set to True, will provide more
    information in the shown table
    :return: Nothing
    """
    endpoints = client.get_endpoints(hostname=hostname,
                                     orchestrator_id=orchestrator_id,
                                     workload_id=workload_id,
                                     endpoint_id=endpoint_id)

    if detailed:
        headings = ["Hostname",
                    "Orchestrator ID",
                    "Workload ID",
                    "Endpoint ID",
                    "Addresses",
                    "MAC",
                    "Profiles",
                    "State"]
        x = PrettyTable(headings, sortby="Hostname")

        for endpoint in endpoints:
            addresses = "\n".join([str(net) for net in
                                   endpoint.ipv4_nets | endpoint.ipv6_nets])
            x.add_row([endpoint.hostname,
                       endpoint.orchestrator_id,
                       endpoint.workload_id,
                       endpoint.endpoint_id,
                       addresses,
                       endpoint.mac,
                       ','.join(endpoint.profile_ids),
                       endpoint.state])
    else:
        headings = ["Hostname",
                    "Orchestrator ID",
                    "Number of Workloads",
                    "Number of Endpoints"]
        x = PrettyTable(headings, sortby="Hostname")

        # The summary table has one entry for each host/orchestrator
        # combination.  We create a dictionary to maintain the summary
        # information, using the (hostname, orchestrator_id) as the unique
        # key, with a value of an EndpointSummary object to store unique
        # workload IDs and a count of endpoint IDs.
        #
        # We use a default dict to automatically create an "empty" (zero count)
        # EndpointSummary for each new table entry.
        host_orch_summary = defaultdict(EndpointSummary)
        for endpoint in endpoints:
            key = (endpoint.hostname, endpoint.orchestrator_id)
            summary = host_orch_summary[key]
            summary.add_endpoint(endpoint)

        # This table has one entry for each host/orchestrator combination.
        for key, summary in host_orch_summary.iteritems():
            hostname, orchestrator_id = key
            x.add_row([hostname,
                       orchestrator_id,
                       len(summary.workload_ids),
                       summary.num_endpoints])

    print str(x) + "\n"

def endpoint_profile_append(hostname, orchestrator_id, workload_id,
                            endpoint_id, profile_names):
    """
    Append a list of profiles to the container endpoint profile list.

    The hostname, orchestrator_id, workload_id, and endpoint_id are all
    optional parameters used to determine which endpoint is being targeted.
    The more parameters used, the faster the endpoint query will be. The
    query must be specific enough to match a single endpoint or it will fail.

    The profile list may not contain duplicate entries, invalid profile names,
    or profiles that are already in the containers list.

    If no profile is specified, nothing happens.

    :param hostname: The host that the targeted endpoint resides on.
    :param orchestrator_id: The orchestrator that created the targeted endpoint.
    :param workload_id: The ID of workload which created the targeted endpoint.
    :param endpoint_id: The endpoint ID of the targeted endpoint.
    :param profile_names: The list of profile names to add to the targeted
                        endpoint.
    :return: None
    """
    # Validate the profile list.
    validate_profile_list(profile_names)

    if not profile_names:
        print_paragraph("No profile specified.")
    else:
        try:
            client.append_profiles_to_endpoint(profile_names,
                                               hostname=hostname,
                                               orchestrator_id=orchestrator_id,
                                               workload_id=workload_id,
                                               endpoint_id=endpoint_id)
            print_paragraph("Profile(s) %s appended." %
                            (", ".join(profile_names)))
        except KeyError:
            print "Failed to append profiles to endpoint.\n"
            print_paragraph("Endpoint %s is unknown to Calico.\n" % endpoint_id)
            sys.exit(1)
        except ProfileAlreadyInEndpoint, e:
            print_paragraph("Profile %s is already in endpoint "
                            "profile list" % e.profile_name)
        except MultipleEndpointsMatch:
            print_paragraph("More than 1 endpoint matches the provided criteria.  "
                            "Please provide additional parameters to refine the "
                            "search.")
            sys.exit(1)

def endpoint_profile_set(hostname, orchestrator_id, workload_id,
                         endpoint_id, profile_names):
    """
    Set the complete list of profiles for the container endpoint profile list.

    The hostname, orchestrator_id, workload_id, and endpoint_id are all optional
    parameters used to determine which endpoint is being targeted.
    The more parameters used, the faster the endpoint query will be. The
    query must be specific enough to match a single endpoint or it will fail.

    The profile list may not contain duplicate entries or invalid profile names.

    If no profile is specified, the profile list is set to be empty.

    :param hostname: The host that the targeted endpoint resides on.
    :param orchestrator_id: The orchestrator that created the targeted endpoint.
    :param workload_id: The ID of workload which created the targeted endpoint.
    :param endpoint_id: The endpoint ID of the targeted endpoint.
    :param profile_names: The list of profile names to set on the targeted
    endpoint.

    :return: None
    """
    # Validate the profile list.
    validate_profile_list(profile_names)

    try:
        client.set_profiles_on_endpoint(profile_names,
                                        hostname=hostname,
                                        orchestrator_id=orchestrator_id,
                                        workload_id=workload_id,
                                        endpoint_id=endpoint_id)
        if not profile_names:
           print_paragraph("Removed all profiles from endpoint.")
        else:
            print_paragraph("Profile(s) set to %s." %
                            (", ".join(profile_names)))
    except KeyError:
        print "Failed to set profiles for endpoint.\n"
        print_paragraph("Endpoint could not be found.\n")
        sys.exit(1)

def endpoint_profile_remove(hostname, orchestrator_id, workload_id,
                            endpoint_id, profile_names):
    """
    Remove a list of profiles from the endpoint profile list.

    The hostname, orchestrator_id, workload_id, and endpoint_id are all optional
    parameters used to determine which endpoint is being targeted.
    The more parameters used, the faster the endpoint query will be. The
    query must be specific enough to match a single endpoint or it will fail.

    The profile list may not contain duplicate entries, invalid profile names,
    or profiles that are not already in the containers list.

    If no profile is specified, nothing happens.

    :param hostname: The host that the targeted endpoint resides on.
    :param orchestrator_id: The orchestrator that created the targeted endpoint.
    :param workload_id: The ID of workload which created the targeted endpoint.
    :param endpoint_id: The endpoint ID of the targeted endpoint.
    :param profile_names: The list of profile names to remove from the targeted
                          endpoint.
    :return: None
    """
    # Validate the profile list.
    validate_profile_list(profile_names)

    if not profile_names:
        print_paragraph("No profile specified.")
    else:
        try:
            client.remove_profiles_from_endpoint(profile_names,
                                                 hostname=hostname,
                                                 orchestrator_id=orchestrator_id,
                                                 workload_id=workload_id,
                                                 endpoint_id=endpoint_id)
            print_paragraph("Profile(s) %s removed." %
                            (",".join(profile_names)))
        except KeyError:
            print "Failed to remove profiles from endpoint.\n"
            print_paragraph("Endpoint could not be found.\n")
            sys.exit(1)
        except ProfileNotInEndpoint, e:
            print_paragraph("Profile %s is not in endpoint profile "
                            "list." % e.profile_name)
        except MultipleEndpointsMatch:
            print "More than 1 endpoint matches the provided criteria. " \
                  "Please provide additional parameters to refine the search."
            sys.exit(1)

def endpoint_profile_show(hostname, orchestrator_id, workload_id, endpoint_id):
    """
    List the profiles assigned to a particular endpoint.

    :param hostname: The hostname.
    :param orchestrator_id: The orchestrator ID.
    :param workload_id: The workload ID.
    :param endpoint_id: The endpoint ID.

    :return: None
    """
    try:
        endpoint = client.get_endpoint(hostname=hostname,
                                       orchestrator_id=orchestrator_id,
                                       workload_id=workload_id,
                                       endpoint_id=endpoint_id)
    except MultipleEndpointsMatch:
        print "Failed to list profiles in endpoint.\n"
        print_paragraph("More than 1 endpoint matches the provided "
                        "criteria.  Please provide additional parameters to "
                        "refine the search.")
        sys.exit(1)
    except KeyError:
        print "Failed to list profiles in endpoint.\n"
        print_paragraph("Endpoint %s is unknown to Calico.\n" % endpoint_id)
        sys.exit(1)

    if endpoint.profile_ids:
        x = PrettyTable(["Name"], sortby="Name")
        for name in endpoint.profile_ids:
            x.add_row([name])
        print str(x) + "\n"
    else:
        print "Endpoint has no profiles associated with it."

def validate_profile_list(profile_names):
    """
    Validate a list of profiles.  This checks that each profile name is
    valid and specified only once in the list.

    This method traces and exits upon failure.

    :param profile_names: The list of profiles to check.
    :return: None
    """
    compiled = set()
    for profile_name in profile_names:
        if not client.profile_exists(profile_name):
            print "Profile with name %s was not found." % profile_name
            sys.exit(1)
        if profile_name in compiled:
            print "Profile with name %s was specified more than " \
                  "once." % profile_name
            sys.exit(1)
        compiled.add(profile_name)


text:
import re
from setuptools import setup, find_packages

pkgname = 'datastore.titan'

# gather the package information
main_py = open('datastore/titan/__init__.py').read()
metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", main_py))
packages = filter(lambda p: p.startswith('datastore'), find_packages())

# convert the readme to pypi compatible rst
try:
  try:
    import pypandoc
    readme = pypandoc.convert('README.md', 'rst')
  except ImportError:
    readme = open('README.md').read()
except:
  print 'something went wrong reading the README.md file.'
  readme = ''

setup(
  name=pkgname,
  version=metadata['version'],
  description='titan datastore implementation',
  long_description=readme,
  author=metadata['author'],
  author_email=metadata['email'],
  url='http://github.com/datastore/datastore.titan',
  keywords=[
    'datastore',
    'titan',
  ],
  packages=packages,
  namespace_packages=['datastore'],
  install_requires=['datastore>=0.3.6', 'thunderdome>=0.4.7'],
  test_suite='datastore.titan.test',
  license='MIT License',
  classifiers=[
    'Topic :: Database',
    'Topic :: Database :: Front-Ends',
  ]
)


text:
<?php
namespace GuzzleHttp\Tests\Psr7;

require __DIR__ . '/../vendor/autoload.php';

class HasToString
{
    public function __toString()
    {
        return 'foo';
    }
}


text:
using Microsoft.Xna.Framework;
using StardewLib;

namespace Replanter.Framework
{
    internal class ModConfig : IConfig
    {
        public string KeyBind { get; set; } = "J";

        public bool Free { get; set; }

        public int SeedDiscount { get; set; }

        public string WhoChecks { get; set; } = "spouse";

        public bool EnableMessages { get; set; } = true;

        // If negative, don't add to inventory.
        public float CostPerCropHarvested { get; set; } = 0.5f;

        public bool SellHarvestedCropsImmediately { get; set; }

        public bool WaterCrops { get; set; }

        public string IgnoreList { get; set; } = "591|593|595|597|376";

        public string AlwaysSellList { get; set; } = "";

        public string NeverSellList { get; set; } = "";

        // The X, Y coordinates of a chest, into which surplus items can be deposited.  The farmers inventory will be tried first, unless bypassInventory is true.
        public Vector2 ChestCoords { get; set; } = new Vector2(70, 14);

        // Whether to bypass the user's inventory and try depositing to the chest first.  Will fall back to the inventory if no chest is present.
        public bool BypassInventory { get; set; }

        public string ChestDefs { get; set; } = "258,70,14|282,70,14";

        public bool ClearDeadPlants { get; set; } = true;

        public bool SmartReplantingEnabled { get; set; } = true;
    }
}


text:
//
//  PopularFoodDetailViewController.h
//  iZJU
//
//  Created by sheng tan on 12-10-8.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "ZJUBaseTableViewController.h"

@interface PopularFoodDetailViewController : ZJUBaseTableViewController <UIActionSheetDelegate>

/*
 detailInfo:
    Telephone,
    Address,
    Average,
    Recommend,
    Discount,
    Scale,
    Userinfo
 */
@property (nonatomic, strong) NSDictionary *detailInfo;

@end


text:
#include <stdio.h>
#include <stdlib.h>

#include <windows.h>
#include <commctrl.h>
#include <winnt.h>

#include "wine/unicode.h"
#include "taskmgr.h"
#include "perfdata.h"

HANDLE        hProcessAffinityHandle;

WCHAR    wszUnable2Access[255];

static INT_PTR CALLBACK
AffinityDialogWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    DWORD_PTR dwProcessAffinityMask = 0;
    DWORD_PTR dwSystemAffinityMask = 0;
    WCHAR     wstrErrorText[256];

    switch (message) {
    case WM_INITDIALOG:

        /*
         * Get the current affinity mask for the process and
         * the number of CPUs present in the system
         */
        if (!GetProcessAffinityMask(hProcessAffinityHandle, &dwProcessAffinityMask, &dwSystemAffinityMask))    {
            GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
            EndDialog(hDlg, 0);
            LoadStringW(hInst, IDS_AFFINITY_UNABLE2ACCESS, wszUnable2Access, sizeof(wszUnable2Access)/sizeof(WCHAR));
            MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Access, MB_OK|MB_ICONSTOP);
        }

        /*
         * Enable a checkbox for each processor present in the system
         */
        if (dwSystemAffinityMask & 0x00000001)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU0), TRUE);
        if (dwSystemAffinityMask & 0x00000002)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU1), TRUE);
        if (dwSystemAffinityMask & 0x00000004)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU2), TRUE);
        if (dwSystemAffinityMask & 0x00000008)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU3), TRUE);
        if (dwSystemAffinityMask & 0x00000010)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU4), TRUE);
        if (dwSystemAffinityMask & 0x00000020)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU5), TRUE);
        if (dwSystemAffinityMask & 0x00000040)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU6), TRUE);
        if (dwSystemAffinityMask & 0x00000080)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU7), TRUE);
        if (dwSystemAffinityMask & 0x00000100)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU8), TRUE);
        if (dwSystemAffinityMask & 0x00000200)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU9), TRUE);
        if (dwSystemAffinityMask & 0x00000400)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU10), TRUE);
        if (dwSystemAffinityMask & 0x00000800)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU11), TRUE);
        if (dwSystemAffinityMask & 0x00001000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU12), TRUE);
        if (dwSystemAffinityMask & 0x00002000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU13), TRUE);
        if (dwSystemAffinityMask & 0x00004000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU14), TRUE);
        if (dwSystemAffinityMask & 0x00008000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU15), TRUE);
        if (dwSystemAffinityMask & 0x00010000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU16), TRUE);
        if (dwSystemAffinityMask & 0x00020000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU17), TRUE);
        if (dwSystemAffinityMask & 0x00040000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU18), TRUE);
        if (dwSystemAffinityMask & 0x00080000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU19), TRUE);
        if (dwSystemAffinityMask & 0x00100000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU20), TRUE);
        if (dwSystemAffinityMask & 0x00200000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU21), TRUE);
        if (dwSystemAffinityMask & 0x00400000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU22), TRUE);
        if (dwSystemAffinityMask & 0x00800000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU23), TRUE);
        if (dwSystemAffinityMask & 0x01000000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU24), TRUE);
        if (dwSystemAffinityMask & 0x02000000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU25), TRUE);
        if (dwSystemAffinityMask & 0x04000000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU26), TRUE);
        if (dwSystemAffinityMask & 0x08000000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU27), TRUE);
        if (dwSystemAffinityMask & 0x10000000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU28), TRUE);
        if (dwSystemAffinityMask & 0x20000000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU29), TRUE);
        if (dwSystemAffinityMask & 0x40000000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU30), TRUE);
        if (dwSystemAffinityMask & 0x80000000)
            EnableWindow(GetDlgItem(hDlg, IDC_CPU31), TRUE);

        /*
         * Check each checkbox that the current process
         * has affinity with
         */
        if (dwProcessAffinityMask & 0x00000001)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU0), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000002)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU1), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000004)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU2), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000008)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU3), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000010)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU4), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000020)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU5), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000040)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU6), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000080)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU7), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000100)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU8), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000200)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU9), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000400)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU10), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00000800)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU11), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00001000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU12), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00002000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU13), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00004000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU14), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00008000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU15), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00010000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU16), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00020000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU17), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00040000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU18), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00080000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU19), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00100000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU20), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00200000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU21), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00400000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU22), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x00800000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU23), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x01000000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU24), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x02000000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU25), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x04000000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU26), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x08000000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU27), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x10000000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU28), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x20000000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU29), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x40000000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU30), BM_SETCHECK, BST_CHECKED, 0);
        if (dwProcessAffinityMask & 0x80000000)
            SendMessageW(GetDlgItem(hDlg, IDC_CPU31), BM_SETCHECK, BST_CHECKED, 0);

        return TRUE;

    case WM_COMMAND:

        /*
         * If the user has cancelled the dialog box
         * then just close it
         */
        if (LOWORD(wParam) == IDCANCEL) {
            EndDialog(hDlg, LOWORD(wParam));
            return TRUE;
        }

        /*
         * The user has clicked OK -- so now we have
         * to adjust the process affinity mask
         */
        if (LOWORD(wParam) == IDOK) {
            /*
             * First we have to create a mask out of each
             * checkbox that the user checked.
             */
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU0), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000001;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU1), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000002;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU2), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000004;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU3), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000008;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU4), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000010;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU5), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000020;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU6), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000040;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU7), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000080;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU8), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000100;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU9), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000200;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU10), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000400;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU11), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00000800;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU12), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00001000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU13), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00002000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU14), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00004000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU15), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00008000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU16), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00010000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU17), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00020000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU18), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00040000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU19), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00080000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU20), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00100000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU21), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00200000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU22), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00400000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU23), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x00800000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU24), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x01000000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU25), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x02000000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU26), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x04000000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU27), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x08000000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU28), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x10000000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU29), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x20000000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU30), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x40000000;
            if (SendMessageW(GetDlgItem(hDlg, IDC_CPU31), BM_GETCHECK, 0, 0))
                dwProcessAffinityMask |= 0x80000000;

            /*
             * Make sure they are giving the process affinity
             * with at least one processor. I'd hate to see a
             * process that is not in a wait state get deprived
             * of it's cpu time.
             */
            if (!dwProcessAffinityMask) {
                WCHAR wszErrorMsg[255];
                WCHAR wszErrorTitle[255];
                LoadStringW(hInst, IDS_AFFINITY_ERROR_MESSAGE, wszErrorMsg, sizeof(wszErrorMsg)/sizeof(WCHAR));
                LoadStringW(hInst, IDS_AFFINITY_ERROR_TITLE, wszErrorTitle, sizeof(wszErrorTitle)/sizeof(WCHAR));
                MessageBoxW(hDlg, wszErrorMsg, wszErrorTitle, MB_OK|MB_ICONSTOP);
                return TRUE;
            }

            /*
             * Try to set the process affinity
             */
            if (!SetProcessAffinityMask(hProcessAffinityHandle, dwProcessAffinityMask)) {
                GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
                EndDialog(hDlg, LOWORD(wParam));
                LoadStringW(hInst, IDS_AFFINITY_UNABLE2ACCESS, wszUnable2Access, sizeof(wszUnable2Access)/sizeof(WCHAR));
                MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Access, MB_OK|MB_ICONSTOP);
            }

            EndDialog(hDlg, LOWORD(wParam));
            return TRUE;
        }

        break;
    }

    return 0;
}

void ProcessPage_OnSetAffinity(void)
{
    LV_ITEMW         lvitem;
    ULONG            Index, Count;
    DWORD            dwProcessId;
    WCHAR            wstrErrorText[256];

    Count = SendMessageW(hProcessPageListCtrl, LVM_GETITEMCOUNT, 0, 0);
    for (Index=0; Index<Count; Index++) {
        memset(&lvitem, 0, sizeof(LV_ITEMW));
        lvitem.mask = LVIF_STATE;
        lvitem.stateMask = LVIS_SELECTED;
        lvitem.iItem = Index;
        SendMessageW(hProcessPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &lvitem);
        if (lvitem.state & LVIS_SELECTED)
            break;
    }

    Count = SendMessageW(hProcessPageListCtrl, LVM_GETSELECTEDCOUNT, 0, 0);
    dwProcessId = PerfDataGetProcessId(Index);
    if ((Count != 1) || (dwProcessId == 0))
        return;
    hProcessAffinityHandle = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_SET_INFORMATION, FALSE, dwProcessId);
    if (!hProcessAffinityHandle) {
        GetLastErrorText(wstrErrorText, sizeof(wstrErrorText)/sizeof(WCHAR));
        LoadStringW(hInst, IDS_AFFINITY_UNABLE2ACCESS, wszUnable2Access, sizeof(wszUnable2Access)/sizeof(WCHAR));
        MessageBoxW(hMainWnd, wstrErrorText, wszUnable2Access, MB_OK|MB_ICONSTOP);
        return;
    }
    DialogBoxW(hInst, MAKEINTRESOURCEW(IDD_AFFINITY_DIALOG), hMainWnd, AffinityDialogWndProc);
    if (hProcessAffinityHandle)    {
        CloseHandle(hProcessAffinityHandle);
        hProcessAffinityHandle = NULL;
    }
}