text:
import ctypes
import sys

from nova.openstack.common.gettextutils import _

if sys.platform == 'darwin':
    vixpath = ('/Applications/VMware Fusion.app/Contents/'
               'Frameworks/libvix.dylib')
elif sys.platform == 'win32':
    vixpath = 'vix.dll'
else:
    vixpath = 'libvix.so'

try:
    vix = ctypes.CDLL(vixpath)
except Exception:
    raise IOError(_('Cannot load Vix: %s') % vixpath)

VixHandle = ctypes.c_int
VixHandleType = ctypes.c_int
VixError = ctypes.c_uint64
VixPropertyType = ctypes.c_int
VixPropertyID = ctypes.c_int
VixEventType = ctypes.c_int
VixHostOptions = ctypes.c_int
VixServiceProvider = ctypes.c_int
VixFindItemType = ctypes.c_int
VixVMOpenOptions = ctypes.c_int
VixPumpEventsOptions = ctypes.c_int
VixVMPowerOpOptions = ctypes.c_int
VixVMDeleteOptions = ctypes.c_int
VixPowerState = ctypes.c_int
VixToolsState = ctypes.c_int
VixRunProgramOptions = ctypes.c_int
VixRemoveSnapshotOptions = ctypes.c_int
VixCreateSnapshotOptions = ctypes.c_int
VixMsgSharedFolderOptions = ctypes.c_int
VixCloneType = ctypes.c_int
VixEventProc = ctypes.CFUNCTYPE(
    None,
    VixHandle,
    VixEventType,
    VixHandle,
    ctypes.c_void_p)

VIX_INVALID_HANDLE = 0
VIX_HANDLETYPE_NONE = 0
VIX_HANDLETYPE_HOST = 2
VIX_HANDLETYPE_VM = 3
VIX_HANDLETYPE_NETWORK = 5
VIX_HANDLETYPE_JOB = 6
VIX_HANDLETYPE_SNAPSHOT = 7
VIX_HANDLETYPE_PROPERTY_LIST = 9
VIX_HANDLETYPE_METADATA_CONTAINER = 11
VIX_OK = 0
VIX_E_FAIL = 1
VIX_E_OUT_OF_MEMORY = 2
VIX_E_INVALID_ARG = 3
VIX_E_FILE_NOT_FOUND = 4
VIX_E_OBJECT_IS_BUSY = 5
VIX_E_NOT_SUPPORTED = 6
VIX_E_FILE_ERROR = 7
VIX_E_DISK_FULL = 8
VIX_E_INCORRECT_FILE_TYPE = 9
VIX_E_CANCELLED = 10
VIX_E_FILE_READ_ONLY = 11
VIX_E_FILE_ALREADY_EXISTS = 12
VIX_E_FILE_ACCESS_ERROR = 13
VIX_E_REQUIRES_LARGE_FILES = 14
VIX_E_FILE_ALREADY_LOCKED = 15
VIX_E_VMDB = 16
VIX_E_NOT_SUPPORTED_ON_REMOTE_OBJECT = 20
VIX_E_FILE_TOO_BIG = 21
VIX_E_FILE_NAME_INVALID = 22
VIX_E_ALREADY_EXISTS = 23
VIX_E_BUFFER_TOOSMALL = 24
VIX_E_OBJECT_NOT_FOUND = 25
VIX_E_HOST_NOT_CONNECTED = 26
VIX_E_INVALID_UTF8_STRING = 27
VIX_E_OPERATION_ALREADY_IN_PROGRESS = 31
VIX_E_UNFINISHED_JOB = 29
VIX_E_NEED_KEY = 30
VIX_E_LICENSE = 32
VIX_E_VM_HOST_DISCONNECTED = 34
VIX_E_AUTHENTICATION_FAIL = 35
VIX_E_HOST_CONNECTION_LOST = 36
VIX_E_DUPLICATE_NAME = 41
VIX_E_INVALID_HANDLE = 1000
VIX_E_NOT_SUPPORTED_ON_HANDLE_TYPE = 1001
VIX_E_TOO_MANY_HANDLES = 1002
VIX_E_NOT_FOUND = 2000
VIX_E_TYPE_MISMATCH = 2001
VIX_E_INVALID_XML = 2002
VIX_E_TIMEOUT_WAITING_FOR_TOOLS = 3000
VIX_E_UNRECOGNIZED_COMMAND = 3001
VIX_E_OP_NOT_SUPPORTED_ON_GUEST = 3003
VIX_E_PROGRAM_NOT_STARTED = 3004
VIX_E_CANNOT_START_READ_ONLY_VM = 3005
VIX_E_VM_NOT_RUNNING = 3006
VIX_E_VM_IS_RUNNING = 3007
VIX_E_CANNOT_CONNECT_TO_VM = 3008
VIX_E_POWEROP_SCRIPTS_NOT_AVAILABLE = 3009
VIX_E_NO_GUEST_OS_INSTALLED = 3010
VIX_E_VM_INSUFFICIENT_HOST_MEMORY = 3011
VIX_E_SUSPEND_ERROR = 3012
VIX_E_VM_NOT_ENOUGH_CPUS = 3013
VIX_E_HOST_USER_PERMISSIONS = 3014
VIX_E_GUEST_USER_PERMISSIONS = 3015
VIX_E_TOOLS_NOT_RUNNING = 3016
VIX_E_GUEST_OPERATIONS_PROHIBITED = 3017
VIX_E_ANON_GUEST_OPERATIONS_PROHIBITED = 3018
VIX_E_ROOT_GUEST_OPERATIONS_PROHIBITED = 3019
VIX_E_MISSING_ANON_GUEST_ACCOUNT = 3023
VIX_E_CANNOT_AUTHENTICATE_WITH_GUEST = 3024
VIX_E_UNRECOGNIZED_COMMAND_IN_GUEST = 3025
VIX_E_CONSOLE_GUEST_OPERATIONS_PROHIBITED = 3026
VIX_E_MUST_BE_CONSOLE_USER = 3027
VIX_E_VMX_MSG_DIALOG_AND_NO_UI = 3028
VIX_E_NOT_ALLOWED_DURING_VM_RECORDING = 3029
VIX_E_NOT_ALLOWED_DURING_VM_REPLAY = 3030
VIX_E_OPERATION_NOT_ALLOWED_FOR_LOGIN_TYPE = 3031
VIX_E_LOGIN_TYPE_NOT_SUPPORTED = 3032
VIX_E_EMPTY_PASSWORD_NOT_ALLOWED_IN_GUEST = 3033
VIX_E_INTERACTIVE_SESSION_NOT_PRESENT = 3034
VIX_E_INTERACTIVE_SESSION_USER_MISMATCH = 3035
VIX_E_UNABLE_TO_REPLAY_VM = 3039
VIX_E_CANNOT_POWER_ON_VM = 3041
VIX_E_NO_DISPLAY_SERVER = 3043
VIX_E_VM_NOT_RECORDING = 3044
VIX_E_VM_NOT_REPLAYING = 3045
VIX_E_VM_NOT_FOUND = 4000
VIX_E_NOT_SUPPORTED_FOR_VM_VERSION = 4001
VIX_E_CANNOT_READ_VM_CONFIG = 4002
VIX_E_TEMPLATE_VM = 4003
VIX_E_VM_ALREADY_LOADED = 4004
VIX_E_VM_ALREADY_UP_TO_DATE = 4006
VIX_E_VM_UNSUPPORTED_GUEST = 4011
VIX_E_UNRECOGNIZED_PROPERTY = 6000
VIX_E_INVALID_PROPERTY_VALUE = 6001
VIX_E_READ_ONLY_PROPERTY = 6002
VIX_E_MISSING_REQUIRED_PROPERTY = 6003
VIX_E_INVALID_SERIALIZED_DATA = 6004
VIX_E_PROPERTY_TYPE_MISMATCH = 6005
VIX_E_BAD_VM_INDEX = 8000
VIX_E_INVALID_MESSAGE_HEADER = 10000
VIX_E_INVALID_MESSAGE_BODY = 10001
VIX_E_SNAPSHOT_INVAL = 13000
VIX_E_SNAPSHOT_DUMPER = 13001
VIX_E_SNAPSHOT_DISKLIB = 13002
VIX_E_SNAPSHOT_NOTFOUND = 13003
VIX_E_SNAPSHOT_EXISTS = 13004
VIX_E_SNAPSHOT_VERSION = 13005
VIX_E_SNAPSHOT_NOPERM = 13006
VIX_E_SNAPSHOT_CONFIG = 13007
VIX_E_SNAPSHOT_NOCHANGE = 13008
VIX_E_SNAPSHOT_CHECKPOINT = 13009
VIX_E_SNAPSHOT_LOCKED = 13010
VIX_E_SNAPSHOT_INCONSISTENT = 13011
VIX_E_SNAPSHOT_NAMETOOLONG = 13012
VIX_E_SNAPSHOT_VIXFILE = 13013
VIX_E_SNAPSHOT_DISKLOCKED = 13014
VIX_E_SNAPSHOT_DUPLICATEDDISK = 13015
VIX_E_SNAPSHOT_INDEPENDENTDISK = 13016
VIX_E_SNAPSHOT_NONUNIQUE_NAME = 13017
VIX_E_SNAPSHOT_MEMORY_ON_INDEPENDENT_DISK = 13018
VIX_E_SNAPSHOT_MAXSNAPSHOTS = 13019
VIX_E_SNAPSHOT_MIN_FREE_SPACE = 13020
VIX_E_SNAPSHOT_HIERARCHY_TOODEEP = 13021
VIX_E_HOST_DISK_INVALID_VALUE = 14003
VIX_E_HOST_DISK_SECTORSIZE = 14004
VIX_E_HOST_FILE_ERROR_EOF = 14005
VIX_E_HOST_NETBLKDEV_HANDSHAKE = 14006
VIX_E_HOST_SOCKET_CREATION_ERROR = 14007
VIX_E_HOST_SERVER_NOT_FOUND = 14008
VIX_E_HOST_NETWORK_CONN_REFUSED = 14009
VIX_E_HOST_TCP_SOCKET_ERROR = 14010
VIX_E_HOST_TCP_CONN_LOST = 14011
VIX_E_HOST_NBD_HASHFILE_VOLUME = 14012
VIX_E_HOST_NBD_HASHFILE_INIT = 14013
VIX_E_DISK_INVAL = 16000
VIX_E_DISK_NOINIT = 16001
VIX_E_DISK_NOIO = 16002
VIX_E_DISK_PARTIALCHAIN = 16003
VIX_E_DISK_NEEDSREPAIR = 16006
VIX_E_DISK_OUTOFRANGE = 16007
VIX_E_DISK_CID_MISMATCH = 16008
VIX_E_DISK_CANTSHRINK = 16009
VIX_E_DISK_PARTMISMATCH = 16010
VIX_E_DISK_UNSUPPORTEDDISKVERSION = 16011
VIX_E_DISK_OPENPARENT = 16012
VIX_E_DISK_NOTSUPPORTED = 16013
VIX_E_DISK_NEEDKEY = 16014
VIX_E_DISK_NOKEYOVERRIDE = 16015
VIX_E_DISK_NOTENCRYPTED = 16016
VIX_E_DISK_NOKEY = 16017
VIX_E_DISK_INVALIDPARTITIONTABLE = 16018
VIX_E_DISK_NOTNORMAL = 16019
VIX_E_DISK_NOTENCDESC = 16020
VIX_E_DISK_NEEDVMFS = 16022
VIX_E_DISK_RAWTOOBIG = 16024
VIX_E_DISK_TOOMANYOPENFILES = 16027
VIX_E_DISK_TOOMANYREDO = 16028
VIX_E_DISK_RAWTOOSMALL = 16029
VIX_E_DISK_INVALIDCHAIN = 16030
VIX_E_DISK_KEY_NOTFOUND = 16052
VIX_E_DISK_SUBSYSTEM_INIT_FAIL = 16053
VIX_E_DISK_INVALID_CONNECTION = 16054
VIX_E_DISK_ENCODING = 16061
VIX_E_DISK_CANTREPAIR = 16062
VIX_E_DISK_INVALIDDISK = 16063
VIX_E_DISK_NOLICENSE = 16064
VIX_E_DISK_NODEVICE = 16065
VIX_E_DISK_UNSUPPORTEDDEVICE = 16066
VIX_E_CRYPTO_UNKNOWN_ALGORITHM = 17000
VIX_E_CRYPTO_BAD_BUFFER_SIZE = 17001
VIX_E_CRYPTO_INVALID_OPERATION = 17002
VIX_E_CRYPTO_RANDOM_DEVICE = 17003
VIX_E_CRYPTO_NEED_PASSWORD = 17004
VIX_E_CRYPTO_BAD_PASSWORD = 17005
VIX_E_CRYPTO_NOT_IN_DICTIONARY = 17006
VIX_E_CRYPTO_NO_CRYPTO = 17007
VIX_E_CRYPTO_ERROR = 17008
VIX_E_CRYPTO_BAD_FORMAT = 17009
VIX_E_CRYPTO_LOCKED = 17010
VIX_E_CRYPTO_EMPTY = 17011
VIX_E_CRYPTO_KEYSAFE_LOCATOR = 17012
VIX_E_CANNOT_CONNECT_TO_HOST = 18000
VIX_E_NOT_FOR_REMOTE_HOST = 18001
VIX_E_INVALID_HOSTNAME_SPECIFICATION = 18002
VIX_E_SCREEN_CAPTURE_ERROR = 19000
VIX_E_SCREEN_CAPTURE_BAD_FORMAT = 19001
VIX_E_SCREEN_CAPTURE_COMPRESSION_FAIL = 19002
VIX_E_SCREEN_CAPTURE_LARGE_DATA = 19003
VIX_E_GUEST_VOLUMES_NOT_FROZEN = 20000
VIX_E_NOT_A_FILE = 20001
VIX_E_NOT_A_DIRECTORY = 20002
VIX_E_NO_SUCH_PROCESS = 20003
VIX_E_FILE_NAME_TOO_LONG = 20004
VIX_E_TOOLS_INSTALL_NO_IMAGE = 21000
VIX_E_TOOLS_INSTALL_IMAGE_INACCESIBLE = 21001
VIX_E_TOOLS_INSTALL_NO_DEVICE = 21002
VIX_E_TOOLS_INSTALL_DEVICE_NOT_CONNECTED = 21003
VIX_E_TOOLS_INSTALL_CANCELLED = 21004
VIX_E_TOOLS_INSTALL_INIT_FAILED = 21005
VIX_E_TOOLS_INSTALL_AUTO_NOT_SUPPORTED = 21006
VIX_E_TOOLS_INSTALL_GUEST_NOT_READY = 21007
VIX_E_TOOLS_INSTALL_SIG_CHECK_FAILED = 21008
VIX_E_TOOLS_INSTALL_ERROR = 21009
VIX_E_TOOLS_INSTALL_ALREADY_UP_TO_DATE = 21010
VIX_E_TOOLS_INSTALL_IN_PROGRESS = 21011
VIX_E_WRAPPER_WORKSTATION_NOT_INSTALLED = 22001
VIX_E_WRAPPER_VERSION_NOT_FOUND = 22002
VIX_E_WRAPPER_SERVICEPROVIDER_NOT_FOUND = 22003
VIX_E_WRAPPER_PLAYER_NOT_INSTALLED = 22004
VIX_E_WRAPPER_RUNTIME_NOT_INSTALLED = 22005
VIX_E_WRAPPER_MULTIPLE_SERVICEPROVIDERS = 22006
VIX_E_MNTAPI_MOUNTPT_NOT_FOUND = 24000
VIX_E_MNTAPI_MOUNTPT_IN_USE = 24001
VIX_E_MNTAPI_DISK_NOT_FOUND = 24002
VIX_E_MNTAPI_DISK_NOT_MOUNTED = 24003
VIX_E_MNTAPI_DISK_IS_MOUNTED = 24004
VIX_E_MNTAPI_DISK_NOT_SAFE = 24005
VIX_E_MNTAPI_DISK_CANT_OPEN = 24006
VIX_E_MNTAPI_CANT_READ_PARTS = 24007
VIX_E_MNTAPI_UMOUNT_APP_NOT_FOUND = 24008
VIX_E_MNTAPI_UMOUNT = 24009
VIX_E_MNTAPI_NO_MOUNTABLE_PARTITONS = 24010
VIX_E_MNTAPI_PARTITION_RANGE = 24011
VIX_E_MNTAPI_PERM = 24012
VIX_E_MNTAPI_DICT = 24013
VIX_E_MNTAPI_DICT_LOCKED = 24014
VIX_E_MNTAPI_OPEN_HANDLES = 24015
VIX_E_MNTAPI_CANT_MAKE_VAR_DIR = 24016
VIX_E_MNTAPI_NO_ROOT = 24017
VIX_E_MNTAPI_LOOP_FAILED = 24018
VIX_E_MNTAPI_DAEMON = 24019
VIX_E_MNTAPI_INTERNAL = 24020
VIX_E_MNTAPI_SYSTEM = 24021
VIX_E_MNTAPI_NO_CONNECTION_DETAILS = 24022
VIX_E_MNTAPI_INCOMPATIBLE_VERSION = 24300
VIX_E_MNTAPI_OS_ERROR = 24301
VIX_E_MNTAPI_DRIVE_LETTER_IN_USE = 24302
VIX_E_MNTAPI_DRIVE_LETTER_ALREADY_ASSIGNED = 24303
VIX_E_MNTAPI_VOLUME_NOT_MOUNTED = 24304
VIX_E_MNTAPI_VOLUME_ALREADY_MOUNTED = 24305
VIX_E_MNTAPI_FORMAT_FAILURE = 24306
VIX_E_MNTAPI_NO_DRIVER = 24307
VIX_E_MNTAPI_ALREADY_OPENED = 24308
VIX_E_MNTAPI_ITEM_NOT_FOUND = 24309
VIX_E_MNTAPI_UNSUPPROTED_BOOT_LOADER = 24310
VIX_E_MNTAPI_UNSUPPROTED_OS = 24311
VIX_E_MNTAPI_CODECONVERSION = 24312
VIX_E_MNTAPI_REGWRITE_ERROR = 24313
VIX_E_MNTAPI_UNSUPPORTED_FT_VOLUME = 24314
VIX_E_MNTAPI_PARTITION_NOT_FOUND = 24315
VIX_E_MNTAPI_PUTFILE_ERROR = 24316
VIX_E_MNTAPI_GETFILE_ERROR = 24317
VIX_E_MNTAPI_REG_NOT_OPENED = 24318
VIX_E_MNTAPI_REGDELKEY_ERROR = 24319
VIX_E_MNTAPI_CREATE_PARTITIONTABLE_ERROR = 24320
VIX_E_MNTAPI_OPEN_FAILURE = 24321
VIX_E_MNTAPI_VOLUME_NOT_WRITABLE = 24322
VIX_E_NET_HTTP_UNSUPPORTED_PROTOCOL = 30001
VIX_E_NET_HTTP_URL_MALFORMAT = 30003
VIX_E_NET_HTTP_COULDNT_RESOLVE_PROXY = 30005
VIX_E_NET_HTTP_COULDNT_RESOLVE_HOST = 30006
VIX_E_NET_HTTP_COULDNT_CONNECT = 30007
VIX_E_NET_HTTP_HTTP_RETURNED_ERROR = 30022
VIX_E_NET_HTTP_OPERATION_TIMEDOUT = 30028
VIX_E_NET_HTTP_SSL_CONNECT_ERROR = 30035
VIX_E_NET_HTTP_TOO_MANY_REDIRECTS = 30047
VIX_E_NET_HTTP_TRANSFER = 30200
VIX_E_NET_HTTP_SSL_SECURITY = 30201
VIX_E_NET_HTTP_GENERIC = 30202
VIX_PROPERTYTYPE_ANY = 0
VIX_PROPERTYTYPE_INTEGER = 1
VIX_PROPERTYTYPE_STRING = 2
VIX_PROPERTYTYPE_BOOL = 3
VIX_PROPERTYTYPE_HANDLE = 4
VIX_PROPERTYTYPE_INT64 = 5
VIX_PROPERTYTYPE_BLOB = 6
VIX_PROPERTY_NONE = 0
VIX_PROPERTY_META_DATA_CONTAINER = 2
VIX_PROPERTY_HOST_HOSTTYPE = 50
VIX_PROPERTY_HOST_API_VERSION = 51
VIX_PROPERTY_HOST_SOFTWARE_VERSION = 52
VIX_PROPERTY_VM_NUM_VCPUS = 101
VIX_PROPERTY_VM_VMX_PATHNAME = 103
VIX_PROPERTY_VM_VMTEAM_PATHNAME = 105
VIX_PROPERTY_VM_MEMORY_SIZE = 106
VIX_PROPERTY_VM_READ_ONLY = 107
VIX_PROPERTY_VM_NAME = 108
VIX_PROPERTY_VM_GUESTOS = 109
VIX_PROPERTY_VM_IN_VMTEAM = 128
VIX_PROPERTY_VM_POWER_STATE = 129
VIX_PROPERTY_VM_TOOLS_STATE = 152
VIX_PROPERTY_VM_IS_RUNNING = 196
VIX_PROPERTY_VM_SUPPORTED_FEATURES = 197
VIX_PROPERTY_VM_IS_RECORDING = 236
VIX_PROPERTY_VM_IS_REPLAYING = 237
VIX_PROPERTY_JOB_RESULT_ERROR_CODE = 3000
VIX_PROPERTY_JOB_RESULT_VM_IN_GROUP = 3001
VIX_PROPERTY_JOB_RESULT_USER_MESSAGE = 3002
VIX_PROPERTY_JOB_RESULT_EXIT_CODE = 3004
VIX_PROPERTY_JOB_RESULT_COMMAND_OUTPUT = 3005
VIX_PROPERTY_JOB_RESULT_HANDLE = 3010
VIX_PROPERTY_JOB_RESULT_GUEST_OBJECT_EXISTS = 3011
VIX_PROPERTY_JOB_RESULT_GUEST_PROGRAM_ELAPSED_TIME = 3017
VIX_PROPERTY_JOB_RESULT_GUEST_PROGRAM_EXIT_CODE = 3018
VIX_PROPERTY_JOB_RESULT_ITEM_NAME = 3035
VIX_PROPERTY_JOB_RESULT_FOUND_ITEM_DESCRIPTION = 3036
VIX_PROPERTY_JOB_RESULT_SHARED_FOLDER_COUNT = 3046
VIX_PROPERTY_JOB_RESULT_SHARED_FOLDER_HOST = 3048
VIX_PROPERTY_JOB_RESULT_SHARED_FOLDER_FLAGS = 3049
VIX_PROPERTY_JOB_RESULT_PROCESS_ID = 3051
VIX_PROPERTY_JOB_RESULT_PROCESS_OWNER = 3052
VIX_PROPERTY_JOB_RESULT_PROCESS_COMMAND = 3053
VIX_PROPERTY_JOB_RESULT_FILE_FLAGS = 3054
VIX_PROPERTY_JOB_RESULT_PROCESS_START_TIME = 3055
VIX_PROPERTY_JOB_RESULT_VM_VARIABLE_STRING = 3056
VIX_PROPERTY_JOB_RESULT_PROCESS_BEING_DEBUGGED = 3057
VIX_PROPERTY_JOB_RESULT_SCREEN_IMAGE_SIZE = 3058
VIX_PROPERTY_JOB_RESULT_SCREEN_IMAGE_DATA = 3059
VIX_PROPERTY_JOB_RESULT_FILE_SIZE = 3061
VIX_PROPERTY_JOB_RESULT_FILE_MOD_TIME = 3062
VIX_PROPERTY_JOB_RESULT_EXTRA_ERROR_INFO = 3084
VIX_PROPERTY_FOUND_ITEM_LOCATION = 4010
VIX_PROPERTY_SNAPSHOT_DISPLAYNAME = 4200
VIX_PROPERTY_SNAPSHOT_DESCRIPTION = 4201
VIX_PROPERTY_SNAPSHOT_POWERSTATE = 4205
VIX_PROPERTY_SNAPSHOT_IS_REPLAYABLE = 4207
VIX_PROPERTY_GUEST_SHAREDFOLDERS_SHARES_PATH = 4525
VIX_PROPERTY_VM_ENCRYPTION_PASSWORD = 7001
VIX_EVENTTYPE_JOB_COMPLETED = 2
VIX_EVENTTYPE_JOB_PROGRESS = 3
VIX_EVENTTYPE_FIND_ITEM = 8
VIX_EVENTTYPE_CALLBACK_SIGNALLED = 2
VIX_FILE_ATTRIBUTES_DIRECTORY = 0x0001
VIX_FILE_ATTRIBUTES_SYMLINK = 0x0002
VIX_HOSTOPTION_USE_EVENT_PUMP = 0x0008
VIX_SERVICEPROVIDER_DEFAULT = 1
VIX_SERVICEPROVIDER_VMWARE_SERVER = 2
VIX_SERVICEPROVIDER_VMWARE_WORKSTATION = 3
VIX_SERVICEPROVIDER_VMWARE_PLAYER = 4
VIX_SERVICEPROVIDER_VMWARE_VI_SERVER = 10
VIX_API_VERSION = -1
VIX_FIND_RUNNING_VMS = 1
VIX_FIND_REGISTERED_VMS = 4
VIX_VMOPEN_NORMAL = 0x0
VIX_PUMPEVENTOPTION_NONE = 0
VIX_VMPOWEROP_NORMAL = 0
VIX_VMPOWEROP_FROM_GUEST = 0x0004
VIX_VMPOWEROP_SUPPRESS_SNAPSHOT_POWERON = 0x0080
VIX_VMPOWEROP_LAUNCH_GUI = 0x0200
VIX_VMPOWEROP_START_VM_PAUSED = 0x1000
VIX_VMDELETE_DISK_FILES = 0x0002
VIX_POWERSTATE_POWERING_OFF = 0x0001
VIX_POWERSTATE_POWERED_OFF = 0x0002
VIX_POWERSTATE_POWERING_ON = 0x0004
VIX_POWERSTATE_POWERED_ON = 0x0008
VIX_POWERSTATE_SUSPENDING = 0x0010
VIX_POWERSTATE_SUSPENDED = 0x0020
VIX_POWERSTATE_TOOLS_RUNNING = 0x0040
VIX_POWERSTATE_RESETTING = 0x0080
VIX_POWERSTATE_BLOCKED_ON_MSG = 0x0100
VIX_POWERSTATE_PAUSED = 0x0200
VIX_POWERSTATE_RESUMING = 0x0800
VIX_TOOLSSTATE_UNKNOWN = 0x0001
VIX_TOOLSSTATE_RUNNING = 0x0002
VIX_TOOLSSTATE_NOT_INSTALLED = 0x0004
VIX_VM_SUPPORT_SHARED_FOLDERS = 0x0001
VIX_VM_SUPPORT_MULTIPLE_SNAPSHOTS = 0x0002
VIX_VM_SUPPORT_TOOLS_INSTALL = 0x0004
VIX_VM_SUPPORT_HARDWARE_UPGRADE = 0x0008
VIX_LOGIN_IN_GUEST_REQUIRE_INTERACTIVE_ENVIRONMENT = 0x08
VIX_RUNPROGRAM_RETURN_IMMEDIATELY = 0x0001
VIX_RUNPROGRAM_ACTIVATE_WINDOW = 0x0002
VIX_VM_GUEST_VARIABLE = 1
VIX_VM_CONFIG_RUNTIME_ONLY = 2
VIX_GUEST_ENVIRONMENT_VARIABLE = 3
VIX_SNAPSHOT_REMOVE_CHILDREN = 0x0001
VIX_SNAPSHOT_INCLUDE_MEMORY = 0x0002
VIX_SHAREDFOLDER_WRITE_ACCESS = 0x04
VIX_CAPTURESCREENFORMAT_PNG = 0x01
VIX_CAPTURESCREENFORMAT_PNG_NOCOMPRESS = 0x02
VIX_CLONETYPE_FULL = 0
VIX_CLONETYPE_LINKED = 1
VIX_INSTALLTOOLS_MOUNT_TOOLS_INSTALLER = 0x00
VIX_INSTALLTOOLS_AUTO_UPGRADE = 0x01
VIX_INSTALLTOOLS_RETURN_IMMEDIATELY = 0x02

vix.Vix_GetErrorText.restype = ctypes.c_char_p
vix.Vix_GetErrorText.argtypes = [VixError, ctypes.c_char_p]
Vix_GetErrorText = vix.Vix_GetErrorText

vix.Vix_ReleaseHandle.restype = None
vix.Vix_ReleaseHandle.argtypes = [VixHandle]
Vix_ReleaseHandle = vix.Vix_ReleaseHandle

vix.Vix_AddRefHandle.restype = None
vix.Vix_AddRefHandle.argtypes = [VixHandle]
Vix_AddRefHandle = vix.Vix_AddRefHandle

vix.Vix_GetHandleType.restype = VixHandleType
vix.Vix_GetHandleType.argtypes = [VixHandle]
vix.Vix_GetProperties.restype = VixError

vix.Vix_GetProperties.argtypes = [VixHandle, VixPropertyID]
vix.Vix_GetPropertyType.restype = VixError
Vix_GetProperties = vix.Vix_GetProperties

vix.Vix_GetPropertyType.argtypes = [VixHandle, VixPropertyID,
                                    ctypes.POINTER(VixPropertyType)]
vix.Vix_FreeBuffer.restype = None
vix.Vix_FreeBuffer.argtypes = [ctypes.c_void_p]
Vix_FreeBuffer = vix.Vix_FreeBuffer

vix.VixHost_Connect.restype = VixHandle
vix.VixHost_Connect.argtypes = [ctypes.c_int, VixServiceProvider,
                                ctypes.c_char_p, ctypes.c_int,
                                ctypes.c_char_p, ctypes.c_char_p,
                                VixHostOptions, VixHandle,
                                ctypes.POINTER(VixEventProc),
                                ctypes.c_void_p]
VixHost_Connect = vix.VixHost_Connect

vix.VixHost_Disconnect.restype = None
vix.VixHost_Disconnect.argtypes = [VixHandle]
VixHost_Disconnect = vix.VixHost_Disconnect

vix.VixHost_RegisterVM.restype = VixHandle
vix.VixHost_RegisterVM.argtypes = [VixHandle, ctypes.c_char_p,
                                   ctypes.POINTER(VixEventProc),
                                   ctypes.c_void_p]
VixHost_RegisterVM = vix.VixHost_RegisterVM

vix.VixHost_UnregisterVM.restype = VixHandle
vix.VixHost_UnregisterVM.argtypes = [VixHandle, ctypes.c_char_p,
                                     ctypes.POINTER(VixEventProc),
                                     ctypes.c_void_p]
VixHost_UnregisterVM = vix.VixHost_UnregisterVM

vix.VixHost_FindItems.restype = VixHandle
vix.VixHost_FindItems.argtypes = [VixHandle, VixFindItemType, VixHandle,
                                  ctypes.c_int32, VixEventProc,
                                  ctypes.c_void_p]
VixHost_FindItems = vix.VixHost_FindItems

vix.VixHost_OpenVM.restype = VixHandle
vix.VixHost_OpenVM.argtypes = [VixHandle, ctypes.c_char_p, VixVMOpenOptions,
                               VixHandle, ctypes.POINTER(VixEventProc),
                               ctypes.c_void_p]

vix.VixPropertyList_AllocPropertyList.restype = VixError
vix.VixPropertyList_AllocPropertyList.argtypes = [VixHandle,
                                                  ctypes.POINTER(VixHandle),
                                                  ctypes.c_int]
vix.VixVM_Open.restype = VixHandle
vix.VixVM_Open.argtypes = [VixHandle, ctypes.c_char_p,
                           ctypes.POINTER(VixEventProc), ctypes.c_void_p]
VixVM_Open = vix.VixVM_Open

vix.VixVM_PowerOn.restype = VixHandle
vix.VixVM_PowerOn.argtypes = [VixHandle, VixVMPowerOpOptions,
                              VixHandle, ctypes.POINTER(VixEventProc),
                              ctypes.c_void_p]
VixVM_PowerOn = vix.VixVM_PowerOn

vix.VixVM_PowerOff.restype = VixHandle
vix.VixVM_PowerOff.argtypes = [VixHandle, VixVMPowerOpOptions,
                               ctypes.POINTER(VixEventProc),
                               ctypes.c_void_p]
VixVM_PowerOff = vix.VixVM_PowerOff

vix.VixVM_Reset.restype = VixHandle
vix.VixVM_Reset.argtypes = [VixHandle, VixVMPowerOpOptions,
                            ctypes.POINTER(VixEventProc),
                            ctypes.c_void_p]
VixVM_Reset = vix.VixVM_Reset

vix.VixVM_Suspend.restype = VixHandle
vix.VixVM_Suspend.argtypes = [VixHandle, VixVMPowerOpOptions,
                              ctypes.POINTER(VixEventProc),
                              ctypes.c_void_p]
VixVM_Suspend = vix.VixVM_Suspend

vix.VixVM_Pause.restype = VixHandle
vix.VixVM_Pause.argtypes = [VixHandle, ctypes.c_int, VixHandle,
                            ctypes.POINTER(VixEventProc),
                            ctypes.c_void_p]
VixVM_Pause = vix.VixVM_Pause

vix.VixVM_Unpause.restype = VixHandle
vix.VixVM_Unpause.argtypes = [VixHandle, ctypes.c_int,
                              VixHandle, ctypes.POINTER(VixEventProc),
                              ctypes.c_void_p]
VixVM_Unpause = vix.VixVM_Unpause

vix.VixVM_Delete.restype = VixHandle
vix.VixVM_Delete.argtypes = [VixHandle, VixVMDeleteOptions,
                             ctypes.POINTER(VixEventProc),
                             ctypes.c_void_p]
VixVM_Delete = vix.VixVM_Delete

vix.VixVM_BeginRecording.restype = VixHandle
vix.VixVM_BeginRecording.argtypes = [VixHandle, ctypes.c_char_p,
                                     ctypes.c_char_p, ctypes.c_int,
                                     VixHandle, ctypes.POINTER(VixEventProc),
                                     ctypes.c_void_p]

vix.VixVM_EndRecording.restype = VixHandle
vix.VixVM_EndRecording.argtypes = [VixHandle, ctypes.c_int,
                                   VixHandle, ctypes.POINTER(VixEventProc),
                                   ctypes.c_void_p]

vix.VixVM_BeginReplay.restype = VixHandle
vix.VixVM_BeginReplay.argtypes = [VixHandle, VixHandle, ctypes.c_int,
                                  VixHandle, ctypes.POINTER(VixEventProc),
                                  ctypes.c_void_p]

vix.VixVM_EndReplay.restype = VixHandle
vix.VixVM_EndReplay.argtypes = [VixHandle, ctypes.c_int,
                                VixHandle, ctypes.POINTER(VixEventProc),
                                ctypes.c_void_p]

vix.VixVM_WaitForToolsInGuest.restype = VixHandle
vix.VixVM_WaitForToolsInGuest.argtypes = [VixHandle, ctypes.c_int,
                                          ctypes.POINTER(VixEventProc),
                                          ctypes.c_void_p]
VixVM_WaitForToolsInGuest = vix.VixVM_WaitForToolsInGuest

vix.VixVM_LoginInGuest.restype = VixHandle
vix.VixVM_LoginInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                   ctypes.c_char_p, ctypes.c_int,
                                   ctypes.POINTER(VixEventProc),
                                   ctypes.c_void_p]

vix.VixVM_LogoutFromGuest.restype = VixHandle
vix.VixVM_LogoutFromGuest.argtypes = [VixHandle, ctypes.POINTER(VixEventProc),
                                      ctypes.c_void_p]

vix.VixVM_RunProgramInGuest.restype = VixHandle
vix.VixVM_RunProgramInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                        ctypes.c_char_p, VixRunProgramOptions,
                                        VixHandle,
                                        ctypes.POINTER(VixEventProc),
                                        ctypes.c_void_p]

vix.VixVM_ListProcessesInGuest.restype = VixHandle
vix.VixVM_ListProcessesInGuest.argtypes = [VixHandle, ctypes.c_int,
                                           ctypes.POINTER(VixEventProc),
                                           ctypes.c_void_p]

vix.VixVM_KillProcessInGuest.restype = VixHandle
vix.VixVM_KillProcessInGuest.argtypes = [VixHandle, ctypes.c_uint64,
                                         ctypes.c_int,
                                         ctypes.POINTER(VixEventProc),
                                         ctypes.c_void_p]

vix.VixVM_RunScriptInGuest.restype = VixHandle
vix.VixVM_RunScriptInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                       ctypes.c_char_p, VixRunProgramOptions,
                                       VixHandle, ctypes.POINTER(VixEventProc),
                                       ctypes.c_void_p]

vix.VixVM_CopyFileFromHostToGuest.restype = VixHandle
vix.VixVM_CopyFileFromHostToGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                              ctypes.c_char_p, ctypes.c_int,
                                              VixHandle,
                                              ctypes.POINTER(VixEventProc),
                                              ctypes.c_void_p]

vix.VixVM_CopyFileFromGuestToHost.restype = VixHandle
vix.VixVM_CopyFileFromGuestToHost.argtypes = [VixHandle, ctypes.c_char_p,
                                              ctypes.c_char_p, ctypes.c_int,
                                              VixHandle,
                                              ctypes.POINTER(VixEventProc),
                                              ctypes.c_void_p]

vix.VixVM_DeleteFileInGuest.restype = VixHandle
vix.VixVM_DeleteFileInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                        ctypes.POINTER(VixEventProc),
                                        ctypes.c_void_p]

vix.VixVM_FileExistsInGuest.restype = VixHandle
vix.VixVM_FileExistsInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                        ctypes.POINTER(VixEventProc),
                                        ctypes.c_void_p]

vix.VixVM_RenameFileInGuest.restype = VixHandle
vix.VixVM_RenameFileInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                        ctypes.c_char_p, ctypes.c_int,
                                        VixHandle,
                                        ctypes.POINTER(VixEventProc),
                                        ctypes.c_void_p]

vix.VixVM_CreateTempFileInGuest.restype = VixHandle
vix.VixVM_CreateTempFileInGuest.argtypes = [VixHandle,
                                            ctypes.c_int, VixHandle,
                                            ctypes.POINTER(VixEventProc),
                                            ctypes.c_void_p]

vix.VixVM_GetFileInfoInGuest.restype = VixHandle
vix.VixVM_GetFileInfoInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                         ctypes.POINTER(VixEventProc),
                                         ctypes.c_void_p]

vix.VixVM_ListDirectoryInGuest.restype = VixHandle
vix.VixVM_ListDirectoryInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                           ctypes.c_int,
                                           ctypes.POINTER(VixEventProc),
                                           ctypes.c_void_p]

vix.VixVM_CreateDirectoryInGuest.restype = VixHandle
vix.VixVM_CreateDirectoryInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                             VixHandle,
                                             ctypes.POINTER(VixEventProc),
                                             ctypes.c_void_p]

vix.VixVM_DeleteDirectoryInGuest.restype = VixHandle
vix.VixVM_DeleteDirectoryInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                             ctypes.c_int,
                                             ctypes.POINTER(VixEventProc),
                                             ctypes.c_void_p]

vix.VixVM_DirectoryExistsInGuest.restype = VixHandle
vix.VixVM_DirectoryExistsInGuest.argtypes = [VixHandle, ctypes.c_char_p,
                                             ctypes.POINTER(VixEventProc),
                                             ctypes.c_void_p]

vix.VixVM_ReadVariable.restype = VixHandle
vix.VixVM_ReadVariable.argtypes = [VixHandle, ctypes.c_int, ctypes.c_char_p,
                                   ctypes.c_int, ctypes.POINTER(VixEventProc),
                                   ctypes.c_void_p]
VixVM_ReadVariable = vix.VixVM_ReadVariable

vix.VixVM_WriteVariable.restype = VixHandle
vix.VixVM_WriteVariable.argtypes = [VixHandle, ctypes.c_int, ctypes.c_char_p,
                                    ctypes.c_char_p, ctypes.c_int,
                                    ctypes.POINTER(VixEventProc),
                                    ctypes.c_void_p]

vix.VixVM_GetNumRootSnapshots.restype = VixError
vix.VixVM_GetNumRootSnapshots.argtypes = [VixHandle,
                                          ctypes.POINTER(ctypes.c_int)]

vix.VixVM_GetRootSnapshot.restype = VixError
vix.VixVM_GetRootSnapshot.argtypes = [VixHandle, ctypes.c_int,
                                      ctypes.POINTER(VixHandle)]

vix.VixVM_GetCurrentSnapshot.restype = VixError
vix.VixVM_GetCurrentSnapshot.argtypes = [VixHandle, ctypes.POINTER(VixHandle)]

vix.VixVM_GetNamedSnapshot.restype = VixError
vix.VixVM_GetNamedSnapshot.argtypes = [VixHandle, ctypes.c_char_p,
                                       ctypes.POINTER(VixHandle)]

vix.VixVM_RemoveSnapshot.restype = VixHandle
vix.VixVM_RemoveSnapshot.argtypes = [VixHandle, VixHandle,
                                     VixRemoveSnapshotOptions,
                                     ctypes.POINTER(VixEventProc),
                                     ctypes.c_void_p]
VixVM_RemoveSnapshot = vix.VixVM_RemoveSnapshot

vix.VixVM_RevertToSnapshot.restype = VixHandle
vix.VixVM_RevertToSnapshot.argtypes = [VixHandle, VixHandle,
                                       VixVMPowerOpOptions, VixHandle,
                                       ctypes.POINTER(VixEventProc),
                                       ctypes.c_void_p]

vix.VixVM_CreateSnapshot.restype = VixHandle
vix.VixVM_CreateSnapshot.argtypes = [VixHandle, ctypes.c_char_p,
                                     ctypes.c_char_p, VixCreateSnapshotOptions,
                                     VixHandle, ctypes.POINTER(VixEventProc),
                                     ctypes.c_void_p]
VixVM_CreateSnapshot = vix.VixVM_CreateSnapshot

vix.VixVM_EnableSharedFolders.restype = VixHandle
vix.VixVM_EnableSharedFolders.argtypes = [VixHandle, ctypes.c_byte,
                                          ctypes.c_int,
                                          ctypes.POINTER(VixEventProc),
                                          ctypes.c_void_p]

vix.VixVM_GetNumSharedFolders.restype = VixHandle
vix.VixVM_GetNumSharedFolders.argtypes = [VixHandle,
                                          ctypes.POINTER(VixEventProc),
                                          ctypes.c_void_p]

vix.VixVM_GetSharedFolderState.restype = VixHandle
vix.VixVM_GetSharedFolderState.argtypes = [VixHandle, ctypes.c_int,
                                           ctypes.POINTER(VixEventProc),
                                           ctypes.c_void_p]

vix.VixVM_SetSharedFolderState.restype = VixHandle
vix.VixVM_SetSharedFolderState.argtypes = [VixHandle, ctypes.c_char_p,
                                           ctypes.c_char_p,
                                           VixMsgSharedFolderOptions,
                                           ctypes.POINTER(VixEventProc),
                                           ctypes.c_void_p]

vix.VixVM_AddSharedFolder.restype = VixHandle
vix.VixVM_AddSharedFolder.argtypes = [VixHandle, ctypes.c_char_p,
                                      ctypes.c_char_p,
                                      VixMsgSharedFolderOptions,
                                      ctypes.POINTER(VixEventProc),
                                      ctypes.c_void_p]

vix.VixVM_RemoveSharedFolder.restype = VixHandle
vix.VixVM_RemoveSharedFolder.argtypes = [VixHandle, ctypes.c_char_p,
                                         ctypes.c_int,
                                         ctypes.POINTER(VixEventProc),
                                         ctypes.c_void_p]

vix.VixVM_CaptureScreenImage.restype = VixHandle
vix.VixVM_CaptureScreenImage.argtypes = [VixHandle, ctypes.c_int,
                                         VixHandle,
                                         ctypes.POINTER(VixEventProc),
                                         ctypes.c_void_p]

vix.VixVM_Clone.restype = VixHandle
vix.VixVM_Clone.argtypes = [VixHandle, VixHandle, VixCloneType,
                            ctypes.c_char_p, ctypes.c_int,
                            VixHandle, ctypes.POINTER(VixEventProc),
                            ctypes.c_void_p]
VixVM_Clone = vix.VixVM_Clone

vix.VixVM_UpgradeVirtualHardware.restype = VixHandle
vix.VixVM_UpgradeVirtualHardware.argtypes = [VixHandle, ctypes.c_int,
                                             ctypes.POINTER(VixEventProc),
                                             ctypes.c_void_p]

vix.VixVM_InstallTools.restype = VixHandle
vix.VixVM_InstallTools.argtypes = [VixHandle, ctypes.c_int, ctypes.c_char_p,
                                   ctypes.POINTER(VixEventProc),
                                   ctypes.c_void_p]

vix.VixJob_Wait.restype = VixError
vix.VixJob_Wait.argtypes = [VixHandle, VixPropertyID]
VixJob_Wait = vix.VixJob_Wait

vix.VixJob_CheckCompletion.restype = VixError
vix.VixJob_CheckCompletion.argtypes = [VixHandle,
                                       ctypes.POINTER(ctypes.c_byte)]

vix.VixJob_GetError.restype = VixError
vix.VixJob_GetError.argtypes = [VixHandle]

vix.VixJob_GetNumProperties.restype = ctypes.c_int
vix.VixJob_GetNumProperties.argtypes = [VixHandle, ctypes.c_int]

vix.VixJob_GetNthProperties.restype = VixError
vix.VixJob_GetNthProperties.argtypes = [VixHandle, ctypes.c_int, ctypes.c_int]

vix.VixSnapshot_GetNumChildren.restype = VixError
vix.VixSnapshot_GetNumChildren.argtypes = [VixHandle,
                                           ctypes.POINTER(ctypes.c_int)]

vix.VixSnapshot_GetChild.restype = VixError
vix.VixSnapshot_GetChild.argtypes = [VixHandle, ctypes.c_int,
                                     ctypes.POINTER(VixHandle)]

vix.VixSnapshot_GetParent.restype = VixError
vix.VixSnapshot_GetParent.argtypes = [VixHandle, ctypes.POINTER(VixHandle)]


text:
@interface SGCacheTask ()
@property (nonatomic, strong) SGHTTPRequest *request;
@property (nonatomic, strong) NSError *currentErrorStatus;
@property (nonatomic, assign) BOOL currentErrorRetry;
@end

@implementation SGCacheTask {
    BOOL _isExecuting, _isFinished;
    NSMutableOrderedSet *_completions;
    NSMutableOrderedSet *_failBlocks;
    NSMutableOrderedSet *_retryBlocks;
}

- (id)init {
    self = [super init];
    _completions = NSMutableOrderedSet.new;
    _failBlocks = NSMutableOrderedSet.new;
    _retryBlocks = NSMutableOrderedSet.new;
    _cacheClass = SGCache.class;
    return self;
}

+ (instancetype)taskForURL:(NSString *)url requestHeaders:(NSDictionary *)headers
      cacheKey:(NSString *)cacheKey attempt:(int)attempt {
    SGCacheTask *task = self.new;
    task.attempt = attempt;
    task.url = url;
    task.requestHeaders = headers;
    task.cacheKey = cacheKey;
    return task;
}

- (void)addCompletion:(SGCacheFetchCompletion)completion {
    if (completion) {
        @synchronized (self) {
            [_completions addObject:[completion copy]];
        }
    }
}

- (void)addCompletions:(NSMutableOrderedSet *)completions {
    if (completions.count) {
        @synchronized (self) {
            [_completions unionOrderedSet:completions];
        }
    }
}

- (void)addFailBlock:(SGCacheFetchFail)fail {
    if (fail) {
        @synchronized (self) {
            [_failBlocks addObject:[fail copy]];
        }
    }
}

- (void)addFailBlocks:(NSMutableOrderedSet *)fails {
    if (fails.count) {
        @synchronized (self) {
            [_failBlocks unionOrderedSet:fails];
        }
    }
}

- (void)addRetryBlock:(SGCacheFetchOnRetry)retry {
    if (retry) {
        @synchronized (self) {
            [_retryBlocks addObject:[retry copy]];
        }
    }
}

- (void)addRetryBlocks:(NSMutableOrderedSet *)retries {
    if (retries.count) {
        @synchronized (self) {
            [_retryBlocks unionOrderedSet:retries];
        }
    }
}

- (void)start {
    self.executing = YES;
    if (self.isCancelled) {
        [self finish];
        return;
    }
    if (!self.remoteFetchOnly && [self.cacheClass haveFileForURL:self.url]) {
        [self completedWithFile:[self.cacheClass fileForURL:self.url]];
    } else {
        [self fetchRemoteFile];
    }
}

- (void)fetchRemoteFile {
    self.currentErrorStatus = nil;
    self.request = [SGHTTPRequest requestWithURL:[NSURL URLWithString:self.url]];
    self.request.responseFormat = SGHTTPDataTypeHTTP;
    self.request.allowCacheToDisk = NO;

    if (self.requestHeaders) {
        self.request.requestHeaders = self.requestHeaders;
    }

    self.request.logging = SGHTTPLogNothing;
    if (SGCache.logging & SGImageCacheLogErrors) {
        self.request.logging |= SGHTTPLogErrors;
    }
    if (SGCache.logging & SGImageCacheLogRequests) {
        self.request.logging |= SGHTTPLogRequests;
    }
    if (SGCache.logging & SGImageCacheLogResponses) {
        self.request.logging |= SGHTTPLogResponses;
    }

    __weakSelf me = self;
    self.request.onSuccess = ^(SGHTTPRequest *req) {
        me.currentErrorStatus = nil;
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            [me completedWithFile:req.responseData];
        });
    };
    self.request.onNetworkReachable = ^{
        [me willRetry];
        [me fetchRemoteFile];
    };
    self.request.onFailure = ^(SGHTTPRequest *req) {
        me.currentErrorStatus = req.error;
        NSInteger code = req.statusCode;
        if (code >= 400 && code < 408) { // give up on 4XX http errors
            me.currentErrorRetry = NO;
            [me failedWithError:req.error allowRetry:NO];
        } else {
            me.currentErrorRetry = YES;
            [me failedWithError:req.error allowRetry:YES];
        }
    };
    [self.request start];
}

- (void)completedWithFile:(NSData *)data {
    [self.cacheClass addData:data forCacheKey:self.cacheKey];

    // call the completion blocks on the main thread
    dispatch_async(dispatch_get_main_queue(), ^{
        for (SGCacheFetchCompletion completion in self.completions) {
            completion(data);
        }
    });

    self.succeeded = YES;
    [self finish];
}

- (void)failedWithError:(NSError *)error allowRetry:(BOOL)allowRetry {
    self.succeeded = NO;

    // call the completion blocks on the main thread
    dispatch_async(dispatch_get_main_queue(), ^{
        for (SGCacheFetchFail failBlock in self.onFailBlocks) {
            failBlock(error, !allowRetry);
        }
    });

    if (!allowRetry) {
        [self finish];
    }
}

- (void)willRetry {
    dispatch_async(dispatch_get_main_queue(), ^{
        for (SGCacheFetchOnRetry retryBlock in self.onRetryBlocks) {
            retryBlock();
        }
    });
}

- (void)finish {
    self.executing = NO;
    self.finished = YES;
}

- (void)cancel {
    if (self.isExecuting) {
        [self.request cancel];
        [self finish];
    }
    [super cancel];
}

#pragma mark - Equivalence

- (BOOL)matchesCacheKey:(NSString *)cacheKey {
    return [cacheKey isEqualToString:self.cacheKey];
}

#pragma mark - Setters

- (void)setExecuting:(BOOL)executing {
    [self willChangeValueForKey:@"isExecuting"];
    _isExecuting = executing;
    [self didChangeValueForKey:@"isExecuting"];
}

- (void)setFinished:(BOOL)finished {
    [self willChangeValueForKey:@"isFinished"];
    _isFinished = finished;
    [self didChangeValueForKey:@"isFinished"];
}

- (void)setPromise:(SGCachePromise *)promise {
    _promise = promise;
    if (promise.onRetry) {
        [self addRetryBlock:promise.onRetry];
    }
    if (promise.onFail) {
        [self addFailBlock:promise.onFail];
    }
    if (self.request && self.currentErrorStatus) {
        [self failedWithError:self.currentErrorStatus allowRetry:self.currentErrorRetry];
        [self fetchRemoteFile];
    }
}

#pragma mark - Getters

- (NSArray *)completions {
    @synchronized (self) {
        return _completions.copy;
    }
}

- (NSArray *)onFailBlocks {
    @synchronized (self) {
        return _failBlocks.copy;
    }
}

- (NSArray *)onRetryBlocks {
    @synchronized (self) {
        return _retryBlocks.copy;
    }
}

- (BOOL)isExecuting {
    return _isExecuting;
}

- (BOOL)isFinished {
    return _isFinished;
}

- (BOOL)isConcurrent {
    return YES;
}

@end

redpajama_set_name: RedPajamaGithub


text:
See above, the categories have changed.  The items for sorting have changed as well.
The rules, however, are the same.

When the items belong to a category on the left press the E key;
when the item belongs to a category on the right, press the I key.
Items belong to only one category.  An X appears after an
error - fix the error by hitting the other key.  GO AS FAST AS YOU CAN.

Press the space bar to begin.


text:
package v1alpha1

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/runtime/schema"
)

var (
	GroupName     = "config.openshift.io"
	GroupVersion  = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
	schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
	// Install is a function which adds this version to a scheme
	Install = schemeBuilder.AddToScheme

	// SchemeGroupVersion generated code relies on this name
	// Deprecated
	SchemeGroupVersion = GroupVersion
	// AddToScheme exists solely to keep the old generators creating valid code
	// DEPRECATED
	AddToScheme = schemeBuilder.AddToScheme
)

// Resource generated code relies on this being here, but it logically belongs to the group
// DEPRECATED
func Resource(resource string) schema.GroupResource {
	return schema.GroupResource{Group: GroupName, Resource: resource}
}

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
	scheme.AddKnownTypes(GroupVersion,
		&InsightsDataGather{},
		&InsightsDataGatherList{},
	)
	metav1.AddToGroupVersion(scheme, GroupVersion)
	return nil
}


text:
goog.provide('pl.retained.ElementParent');

goog.require('goog.array');
goog.require('goog.asserts');

/**
 * @interface
 */
pl.retained.ElementParent = function() {};

/**
 * @param {!pl.retained.Element} child
 */
pl.retained.ElementParent.prototype.childInvalidated = function(child) { };


text:
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright 2016 Hippo Seven
  ~
  ~ Licensed 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.
  -->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingLeft="@dimen/keyline_margin"
        android:paddingRight="@dimen/keyline_margin"
        android:paddingTop="8dp">

        <TextView
            android:id="@+id/cancel"
            style="@style/ButtonInCard.Accent"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@android:string/cancel"/>

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:background="?attr/dividerColor"/>

        <TextView
            android:id="@+id/ok"
            style="@style/ButtonInCard.Accent"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@android:string/ok"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingLeft="@dimen/keyline_margin"
        android:paddingRight="@dimen/keyline_margin"
        android:paddingTop="8dp">

        <TextView
            android:id="@+id/select_all"
            style="@style/ButtonInCard"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/select_all"/>

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:background="?attr/dividerColor"/>

        <TextView
            android:id="@+id/deselect_all"
            style="@style/ButtonInCard"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/deselect_all"/>

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:background="?attr/dividerColor"/>

        <TextView
            android:id="@+id/invert_selection"
            style="@style/ButtonInCard"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:text="@string/invert_selection"/>

    </LinearLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:paddingLeft="@dimen/keyline_margin"
        android:paddingRight="@dimen/keyline_margin"
        android:paddingTop="8dp"
        android:paddingBottom="8dp">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/language"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/original"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/translated"/>

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/rewrite"/>

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginLeft="@dimen/keyline_margin"
        android:layout_marginRight="@dimen/keyline_margin"
        android:background="?attr/dividerColor"/>

    <com.hippo.easyrecyclerview.EasyRecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:paddingLeft="@dimen/keyline_margin"
        android:paddingRight="@dimen/keyline_margin"
        android:paddingBottom="8dp"/>

</LinearLayout>


text:
function [J, grad] = costFunctionReg(theta, X, y, lambda)
%COSTFUNCTIONREG Compute cost and gradient for logistic regression with regularization
%   J = COSTFUNCTIONREG(theta, X, y, lambda) computes the cost of using
%   theta as the parameter for regularized logistic regression and the
%   gradient of the cost w.r.t. to the parameters.

% Initialize some useful values
m = length(y); % number of training examples

% You need to return the following variables correctly
J = 0;
grad = zeros(size(theta));

% ====================== YOUR CODE HERE ======================
% Instructions: Compute the cost of a particular choice of theta.
%               You should set J to the cost.
%               Compute the partial derivatives and set grad to the partial
%               derivatives of the cost w.r.t. each parameter in theta

newtheta = theta;
newtheta(1) = 0;
sig = sigmoid(X * theta);

J = sum((-y .* log(sig) - (1 - y) .* log(1 - sig)))/m + (sum(newtheta .* newtheta)*lambda/(2*m));

for i = 1:size(theta)
    if i == 1
        grad(i) = (X(:,i)' * (sig - y))/m;
    else
        grad(i) = (X(:,i)' * (sig - y))/m + theta(i)*(lambda/m);
    end
end

% =============================================================

end


text:
package org.helianto.finance.repository;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.helianto.finance.domain.Payable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

/**
 * Payable Repository.
 *
 * @author Eldevan Nery Junior
 *
 */
public interface PayableRepository extends JpaRepository<Payable, Serializable> {

	/**
	 * Entities queries.
	 */

	/*
	 * SUM'S
	 */

	/**
	 * Sum faceValue by entityId and Resolution.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin "
		+ " WHERE fin.entity.id = ?1 "
		+ " AND fin.resolution in (?2) ")
	BigDecimal sumFaceValueByEntityIdAndResolutionIn(Integer entityId, Set<Character> resolutions);

	/**
	 * Sum faceValue by entityId issueDate after startDate.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin "
		+ " WHERE fin.entity.id = ?1 "
		+ " AND fin.issueDate > ?2 "
		+ " AND fin.resolution in (?3) ")
	BigDecimal sumFaceValueByEntityIdAndIssueDateAfter(Integer entityId, Date start, Set<Character> resolutions);

	/**
	 * Sum faceValue by entityId nextCheckDate after startDate.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue)"
		+ " FROM Payable fin "
		+ " WHERE fin.entity.id = ?1 "
		+ " AND fin.nextCheckDate > ?2 "
		+ " AND fin.resolution in (?3)")
	BigDecimal sumFaceValueByEntityIdAndNextCheckDateAfter(Integer entityId, Date start, Set<Character> resolutions);

	/**
	 * Sum faceValue by entityId PaymentDate after startDate.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin "
		+ " WHERE fin.entity.id = ?1 "
		+ " AND fin.paymentDate > ?2 "
		+ " AND fin.resolution in (?3) ")
	BigDecimal sumFaceValueByEntityIdAndPaymentDateAfter(Integer entityId, Date start, Set<Character> resolutions);

	/**
	 * Sum faceValue by entityId issueDate between dates.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin "
		+ " WHERE fin.entity.id = ?1 "
		+ " AND (fin.issueDate BETWEEN ?2 AND ?3) "
		+ " AND fin.resolution in (?4)  ")
	BigDecimal sumFaceValueByEntityIdAndIssueDateBetween(Integer entityId, Date start, Date end, Set<Character> resolutions);

	/**
	 * Sum faceValue by entityId nextCheckDate between dates.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin "
		+ " WHERE fin.entity.id = ?1 "
		+ " AND (fin.nextCheckDate BETWEEN ?2 AND ?3) "
		+ "	AND fin.resolution in (?4) ")
	BigDecimal sumFaceValueByEntityIdAndNextCheckDateBetween(Integer entityId, Date start, Date end, Set<Character> resolutions);

	/**
	 * Sum faceValue by entityId PaymentDate between dates.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin "
		+ " WHERE fin.entity.id = ?1 "
		+ " AND (fin.paymentDate BETWEEN ?2 AND ?3) "
		+ " AND fin.resolution in (?4)  ")
	BigDecimal sumFaceValueByEntityIdAndPaymentDateBetween(Integer entityId, Date start, Date end, Set<Character> resolutions);

	/*
	 * FIND'S
	 */

	/**
	 * Find list by entity.
	 *
	 * @param entityId
	 *
	 */
	List<Payable> findByEntity_Id(Integer entityId);

	/**
	 * Find list by entity and Resolution.
	 *
	 * @param entityId
	 *
	 */
	List<Payable> findByEntity_IdAndResolutionIn(Integer entityId, Set<Character> resolutions);

	/**
	 * Find by entity between issue date.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByEntity_IdAndResolutionInAndIssueDateBetween(Integer entityId, Set<Character> resolutions , Date start, Date end);

	/**
	 * Find by entity between next check date.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByEntity_IdAndResolutionInAndNextCheckDateBetween(Integer entityId, Set<Character> resolutions, Date start, Date end);

	/**
	 * Find by private entity between PaymentDate.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByEntity_IdAndResolutionInAndPaymentDateBetween(Integer privateEntityId, Set<Character> resolutions, Date start, Date end);

	/**
	 * Find by entity issue date after startDate.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByEntity_IdAndResolutionInAndIssueDateAfter(Integer entityId, Set<Character> resolutions, Date start);

	/**
	 * Find by entity issue date after startDate.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByEntity_IdAndResolutionInAndNextCheckDateAfter(Integer entityId, Set<Character> resolutions, Date start);

	/**
	 * Find by entity PaymentDate after startDate.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByEntity_IdAndResolutionInAndPaymentDateAfter(Integer entityId, Set<Character> resolutions, Date start);

	/**
	 * Private Entities queries.
	 */

	/*
	 * SUM'S
	 */

	/**
	 * Sum faceValue by entityId.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) FROM Payable fin WHERE fin.entity.id = ?1 ")
	BigDecimal sumFaceValueByEntityId(Integer entityId);

	/**
	 * Sum faceValue by privateEntityId.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) FROM Payable fin WHERE fin.privateEntity.id = ?1 ")
	BigDecimal sumFaceValueByPrivateEntityId(Integer privateEntityId);

	/**
	 * Sum faceValue by privateEntityId and Resolution.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin "
		+ " WHERE fin.privateEntity.id = ?1 "
		+ " AND fin.resolution in (?2) ")
	BigDecimal sumFaceValueByPrivateEntityIdAndResolutionIn(Integer privateEntityId, Set<Character> resolutions);

	/**
	 * Sum faceValue by privateEntityId issueDate after startDate.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin"
		+ " WHERE fin.privateEntity.id = ?1 "
		+ " AND fin.issueDate > ?2"
		+ " AND fin.resolution in (?3)")
	BigDecimal sumFaceValueByPrivateEntityIdAndIssueDateAfter(Integer privateEntityId, Date start, Set<Character> resolutions);

	/**
	 * Sum faceValue by privateEntityId nextCheckDate after startDate.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin"
		+ " WHERE fin.privateEntity.id = ?1 "
		+ " AND fin.nextCheckDate > ?2 "
		+ " AND fin.resolution in (?3)")
	BigDecimal sumFaceValueByPrivateEntityIdAndNextCheckDateAfter(Integer privateEntityId, Date start, Set<Character> resolutions);

	/**
	 * Sum faceValue by privateEntityId PaymentDate after startDate.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ " FROM Payable fin"
		+ " WHERE fin.privateEntity.id = ?1 "
		+ " AND fin.paymentDate > ?2"
		+ " AND fin.resolution in (?3)")
	BigDecimal sumFaceValueByPrivateEntityIdAndPaymentDateAfter(Integer privateEntityId, Date start, Set<Character> resolutions);

	/**
	 * Sum faceValue by privateEntityId issueDate between dates.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ "	FROM Payable fin "
		+ " WHERE fin.privateEntity.id = ?1 "
		+ " AND (fin.issueDate BETWEEN ?2 AND ?3) "
		+ " AND fin.resolution in (?4)")
	BigDecimal sumFaceValueByPrivateEntityIdAndIssueDateBetween(Integer privateEntityId, Date start, Date end, Set<Character> resolutions);

	/**
	 * Sum faceValue by privateEntityId nextCheckDate between dates.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		 + " FROM Payable fin "
		 + " WHERE fin.privateEntity.id = ?1 "
		 + " AND (fin.nextCheckDate BETWEEN ?2 AND ?3) "
		 + " AND fin.resolution in (?4) ")
	BigDecimal sumFaceValueByPrivateEntityIdAndNextCheckDateBetween(Integer privateEntityId, Date start, Date end, Set<Character> resolutions);

	/**
	 * Sum faceValue by privateEntityId PaymentDate between dates.
	 *
	 * @param entityId
	 *
	 */
	@Query("SELECT SUM(fin.faceValue) "
		+ "	FROM Payable fin "
		+ " WHERE fin.privateEntity.id = ?1 "
		+ " AND (fin.paymentDate BETWEEN ?2 AND ?3) "
		+ " AND fin.resolution in (?4)")
	BigDecimal sumFaceValueByPrivateEntityIdAndPaymentDateBetween(Integer privateEntityId, Date start, Date end, Set<Character> resolutions);

	/*
	 * FIND'S
	 */

	/**
	 * Find by privateEntity.
	 *
	 * @param privateEntityId
	 */
	List<Payable> findByPrivateEntity_Id(Integer privateEntityId);

	/**
	 * Find by privateEntity and Resolution.
	 *
	 * @param privateEntityId
	 */
	List<Payable> findByPrivateEntity_IdAndResolutionIn(Integer privateEntityId, Set<Character> resolutions);

	/**
	 * Find by private entity between issue date.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByPrivateEntity_IdAndResolutionInAndIssueDateBetween(Integer privateEntityId, Set<Character> resolutions, Date start, Date end);

	/**
	 * Find by private entity between next check date.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByPrivateEntity_IdAndResolutionInAndNextCheckDateBetween(Integer privateEntityId, Set<Character> resolutions, Date start, Date end);

	/**
	 * Find by private entity between PaymentDate.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByPrivateEntity_IdAndResolutionInAndPaymentDateBetween(Integer privateEntityId, Set<Character> resolutions, Date start, Date end);

	/**
	 * Find by private entity issue date after startDate.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByPrivateEntity_IdAndResolutionInAndIssueDateAfter(Integer privateEntityId, Set<Character> resolutions, Date start);

	/**
	 * Find by private entity nextcheckDate after startDate.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByPrivateEntity_IdAndResolutionInAndNextCheckDateAfter(Integer privateEntityId, Set<Character> resolutions, Date start);

	/**
	 * Find by private entity PaymentDate after startDate.
	 *
	 * @param entityId
	 * @param start
	 * @param end
	 */
	List<Payable> findByPrivateEntity_IdAndResolutionInAndPaymentDateAfter(Integer privateEntityId, Set<Character> resolutions, Date start);

}


text:
package org.apache.wink.providers.jettison.internal;

import java.io.IOException;
import java.io.StringReader;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.xml.bind.JAXBElement;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.wink.common.model.atom.AtomEntry;
import org.apache.wink.common.model.synd.SyndEntry;
import org.apache.wink.providers.jettison.JettisonJAXBElementProvider;
import org.apache.wink.providers.jettison.JettisonJAXBProvider;
import org.apache.wink.providers.jettison.internal.jaxb.Person;
import org.apache.wink.providers.json.JSONUtils;
import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
import org.apache.wink.test.mock.MockRequestConstructor;
import org.codehaus.jettison.mapped.Configuration;
import org.json.JSONObject;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

public class JettisonJAXBMappedTest extends MockServletInvocationTest {

    @Override
    protected Class<?>[] getClasses() {
        return new Class<?>[] {TestResource.class, PersonResource.class,
            FormattingOptionsContextResolver.class};
    }

    @Override
    protected Object[] getSingletons() {
        Map<String, String> namespaceMap = new HashMap<String, String>();
        namespaceMap.put("http://www.w3.org/2005/Atom", "http://www.w3.org/2005/Atom");
        namespaceMap.put("http://b216:8080/reporting/reports/toptenvalidators",
                         "http://b216:8080/reporting/reports/toptenvalidators");
        namespaceMap.put("http://www.w3.org/XML/1998/namespace",
                         "http://www.w3.org/XML/1998/namespace");
        namespaceMap = Collections.unmodifiableMap(namespaceMap);

        Map<String, String> outputNamespaceMap = new HashMap<String, String>();
        outputNamespaceMap.put("http://www.w3.org/2005/Atom", "http://www.w3.org/2005/Atom");
        outputNamespaceMap.put("http://b216:8080/reporting/reports/toptenvalidators",
                               "http://b216:8080/reporting/reports/toptenvalidators");
        outputNamespaceMap.put("http://www.w3.org/XML/1998/namespace",
                               "http://www.w3.org/XML/1998/namespace");
        outputNamespaceMap = Collections.unmodifiableMap(outputNamespaceMap);

        JettisonJAXBProvider jaxbProvider =
            new JettisonJAXBProvider(false, new Configuration(namespaceMap),
                                     new Configuration(outputNamespaceMap));
        jaxbProvider.setUseAsReader(true);
        JettisonJAXBElementProvider jaxbElementProvider =
            new JettisonJAXBElementProvider(false, new Configuration(namespaceMap),
                                            new Configuration(outputNamespaceMap));
        jaxbElementProvider.setUseAsReader(true);
        return new Object[] {jaxbProvider, jaxbElementProvider};
    }

    @Override
    public String getPropertiesFile() {
        return "META-INF/wink.properties";
    }

    @Path("/test/person")
    public static class PersonResource {

        @GET
        public Person getPerson() throws IOException {
            Person p = new Person();
            p.setName("My Name");
            p.setDesc("My desc");
            return p;
        }

        @POST
        public Person postPerson(Person p) {
            return p;
        }
    }

    @Path("test")
    public static class TestResource {

        @GET
        @Path("atomentry")
        @Produces("application/json")
        public AtomEntry getAtomEntry() throws IOException {
            AtomEntry entry = AtomEntry.unmarshal(new StringReader(ENTRY));
            return entry;
        }

        @GET
        @Path("atomentryelement")
        @Produces("application/json")
        public JAXBElement<AtomEntry> getAtomEntryElement() throws IOException {
            AtomEntry entry = AtomEntry.unmarshal(new StringReader(ENTRY));
            org.apache.wink.common.model.atom.ObjectFactory of =
                new org.apache.wink.common.model.atom.ObjectFactory();
            return of.createEntry(entry);
        }

        @GET
        @Path("atomsyndentry")
        @Produces("application/json")
        public SyndEntry getSyndEntry() throws IOException {
            AtomEntry entry = AtomEntry.unmarshal(new StringReader(ENTRY));
            return entry.toSynd(new SyndEntry());
        }

        @POST
        @Path("atomentry")
        @Produces("application/json")
        @Consumes("application/json")
        public AtomEntry postAtomEntry(AtomEntry entry) throws IOException {
            return entry;
        }

        @POST
        @Path("atomentryelement")
        @Produces("application/json")
        @Consumes("application/json")
        public JAXBElement<AtomEntry> postAtomEntryElement(JAXBElement<AtomEntry> entry) {
            return entry;
        }

        @POST
        @Path("atomsyndentry")
        @Produces("application/json")
        @Consumes("application/json")
        public SyndEntry postAtomSyndEntry(SyndEntry entry) {
            return entry;
        }

    }

    /**
     * Tests a simple single JAXB Object to write.
     *
     * @throws Exception
     */
    public void testGetPerson() throws Exception {
        MockHttpServletRequest request =
            MockRequestConstructor.constructMockRequest("GET", "/test/person", "application/json");
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());

        assertTrue(JSONUtils
            .equals(new JSONObject(
                                   " { \"person\" : { \"desc\" : \"My desc\", \"name\" : \"My Name\" } } "),
                    new JSONObject(response.getContentAsString())));
    }

    /**
     * Tests a simple single JAXB Object to both read and write.
     *
     * @throws Exception
     */
    public void testPostPerson() throws Exception {
        MockHttpServletRequest request =
            MockRequestConstructor.constructMockRequest("POST", "/test/person", "application/json");
        request.setContentType("application/json");
        request.setContent(" { \"person\" : { \"desc\" : \"My desc\", \"name\" : \"My Name\" } } "
            .getBytes());
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());
        assertTrue(JSONUtils
            .equals(new JSONObject("{\"person\":{\"desc\":\"My desc\",\"name\":\"My Name\"}}"),
                    new JSONObject(response.getContentAsString())));
    }

    public void testGetAtomEntry() throws Exception {
        MockHttpServletRequest request =
            MockRequestConstructor.constructMockRequest("GET",
                                                        "/test/atomentry",
                                                        "application/json");
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());

        assertTrue(JSONUtils.equals(new JSONObject(ENTRY_JSON), new JSONObject(response
            .getContentAsString())));
    }

    public void testGetAtomEntryElement() throws Exception {
        MockHttpServletRequest request =
            MockRequestConstructor.constructMockRequest("GET",
                                                        "/test/atomentryelement",
                                                        "application/json");
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());
        assertTrue(JSONUtils.equals(new JSONObject(ENTRY_JSON), new JSONObject(response
            .getContentAsString())));
    }

    public void testPostAtomEntry() throws Exception {
        MockHttpServletRequest request =
            MockRequestConstructor.constructMockRequest("POST",
                                                        "/test/atomentry",
                                                        "application/json");
        request.setContentType("application/json");

        request.setContent(ENTRY_JSON.getBytes());
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());
        assertTrue(JSONUtils.equals(JSONUtils.objectForString(ENTRY_JSON), JSONUtils
            .objectForString(response.getContentAsString())));
    }

    public void testPostAtomEntryElement() throws Exception {
        MockHttpServletRequest request =
            MockRequestConstructor.constructMockRequest("POST",
                                                        "/test/atomentryelement",
                                                        "application/json");
        request.setContentType("application/json");
        request.setContent(ENTRY_JSON.getBytes());
        MockHttpServletResponse response = invoke(request);
        assertEquals(200, response.getStatus());
        assertTrue(JSONUtils.equals(JSONUtils.objectForString(ENTRY_JSON), JSONUtils
            .objectForString(response.getContentAsString())));
    }

    private static final String ENTRY_STR      =
                                                   "<entry xml:base=\"http://b216:8080/reporting/reports\" xmlns=\"http://www.w3.org/2005/Atom\">\n" + "    <id>toptenvalidators</id>\n"
                                                       + "    <updated>@TIME@</updated>\n"
                                                       + "    <title type=\"text\" xml:lang=\"en\">top ten validators</title>\n"
                                                       + "    <published>@TIME@</published>\n"
                                                       + "    <link href=\"http://b216:8080/reporting/reports/toptenvalidators?alt=application/json\" type=\"application/json\" rel=\"alternate\"/>\n"
                                                       + "    <author>\n"
                                                       + "        <name>admin</name>\n"
                                                       + "    </author>\n"
                                                       + "    <category label=\"report definition\" scheme=\"urn:com:systinet:reporting:kind\" term=\"urn:com:systinet:reporting:kind:definition\"/>\n"
                                                       + "</entry>\n";

    private static String       ENTRY_STR_JSON =

                                                   "{" + "\"http:\\/\\/www.w3.org\\/2005\\/Atom.entry\":"
                                                       + "{"
                                                       + "\"@http:\\/\\/www.w3.org\\/XML\\/1998\\/namespace.base\":\"http:\\/\\/b216:8080\\/reporting\\/reports\","
                                                       + "\"http:\\/\\/www.w3.org\\/2005\\/Atom.id\":\"toptenvalidators\","
                                                       + "\"http:\\/\\/www.w3.org\\/2005\\/Atom.updated\":\"@TIME@\","
                                                       + "\"http:\\/\\/www.w3.org\\/2005\\/Atom.title\":{"
                                                       + "\"@type\":\"text\","
                                                       + "\"@http:\\/\\/www.w3.org\\/XML\\/1998\\/namespace.lang\":\"en\","
                                                       + "\"$\":\"top ten validators\"},"
                                                       + "\"http:\\/\\/www.w3.org\\/2005\\/Atom.published\":\"@TIME@\","
                                                       + "\"http:\\/\\/www.w3.org\\/2005\\/Atom.link\":"
                                                       + "{\"@href\":\"http:\\/\\/b216:8080\\/reporting\\/reports\\/toptenvalidators?alt=application\\/json\","
                                                       + "\"@type\":\"application\\/json\","
                                                       + "\"@rel\":\"alternate\"},"
                                                       + "\"http:\\/\\/www.w3.org\\/2005\\/Atom.author\":"
                                                       + "{\"http:\\/\\/www.w3.org\\/2005\\/Atom.name\":\"admin\"},"
                                                       + "\"http:\\/\\/www.w3.org\\/2005\\/Atom.category\":"
                                                       + "{\"@label\":\"report definition\","
                                                       + "\"@scheme\":\"urn:com:systinet:reporting:kind\","
                                                       + "\"@term\":\"urn:com:systinet:reporting:kind:definition\"},"
                                                       + "}"
                                                       + "}";

    private static final String ENTRY;

    private static final String ENTRY_JSON;

    static {
        try {
            GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTimeInMillis((new Date()).getTime());
            XMLGregorianCalendar xmlGregCal =
                DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
            ENTRY = ENTRY_STR.replaceAll("@TIME@", xmlGregCal.toString());
            ENTRY_JSON = ENTRY_STR_JSON.replaceAll("@TIME@", xmlGregCal.toString());
        } catch (DatatypeConfigurationException e) {
            throw new RuntimeException(e);
        }
    }
}


text:
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.AspNetCore.SignalR.Infrastructure
{
    // Similar to MemoryStream, but tries to allocate as few objects as possible on the LOH

    internal sealed class ByteBuffer
    {
        private int _currentLength;
        private readonly int? _maxLength;
        private readonly List<byte[]> _segments = new List<byte[]>();

        public ByteBuffer(int? maxLength)
        {
            _maxLength = maxLength;
        }

        public void Append(byte[] segment)
        {
            checked { _currentLength += segment.Length; }
            if (_maxLength.HasValue && _currentLength > _maxLength)
            {
                throw new InvalidOperationException("Buffer length exceeded");
            }

            _segments.Add(segment);
        }

        // returns the segments as a single byte array
        public byte[] GetByteArray()
        {
            byte[] newArray = new byte[_currentLength];
            int lastOffset = 0;

            for (int i = 0; i < _segments.Count; i++)
            {
                byte[] thisSegment = _segments[i];
                Buffer.BlockCopy(thisSegment, 0, newArray, lastOffset, thisSegment.Length);
                lastOffset += thisSegment.Length;
            }

            return newArray;
        }

        // treats the segments as UTF8-encoded information and returns the resulting string
        public string GetString()
        {
            StringBuilder builder = new StringBuilder();
            Decoder decoder = Encoding.UTF8.GetDecoder();

            for (int i = 0; i < _segments.Count; i++)
            {
                bool flush = (i == _segments.Count - 1);
                byte[] thisSegment = _segments[i];
                int charsRequired = decoder.GetCharCount(thisSegment, 0, thisSegment.Length, flush);
                char[] thisSegmentAsChars = new char[charsRequired];
                int numCharsConverted = decoder.GetChars(thisSegment, 0, thisSegment.Length, thisSegmentAsChars, 0, flush);
                builder.Append(thisSegmentAsChars, 0, numCharsConverted);
            }

            return builder.ToString();
        }

    }
}


text: <ng-transclude></ng-transclude>


text:
package org.red5.io.amf3;

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;

import org.apache.mina.core.buffer.IoBuffer;
import org.red5.io.amf.AMF;
import org.red5.io.object.Serializer;

/**
 * Implementation of the IDataOutput interface. Can be used to store an IExternalizable object.
 *
 * @author The Red5 Project (red5@osflash.org)
 * @author Joachim Bauch (jojo@struktur.de)
 *
 */
public class DataOutput implements IDataOutput {

	/** The output stream. */
	private Output output;

	/** The serializer to use. */
	private Serializer serializer;

	/** Raw data of output destination. */
	private IoBuffer buffer;

	/**
	 * Create a new DataOutput.
	 *
	 * @param output		destination to write to
	 * @param serializer	the serializer to use
	 */
	protected DataOutput(Output output, Serializer serializer) {
		this.output = output;
		this.serializer = serializer;
		buffer = output.getBuffer();
	}

	/** {@inheritDoc} */
	public ByteOrder getEndian() {
		return buffer.order();
	}

	/** {@inheritDoc} */
	public void setEndian(ByteOrder endian) {
		buffer.order(endian);
	}

    /** {@inheritDoc} */
	public void writeBoolean(boolean value) {
		buffer.put((byte) (value ? 1 : 0));
	}

    /** {@inheritDoc} */
	public void writeByte(byte value) {
		buffer.put(value);
	}

    /** {@inheritDoc} */
	public void writeBytes(byte[] bytes) {
		buffer.put(bytes);
	}

    /** {@inheritDoc} */
	public void writeBytes(byte[] bytes, int offset) {
		buffer.put(bytes, offset, bytes.length - offset);
	}

    /** {@inheritDoc} */
	public void writeBytes(byte[] bytes, int offset, int length) {
		buffer.put(bytes, offset, length);
	}

    /** {@inheritDoc} */
	public void writeDouble(double value) {
		buffer.putDouble(value);
	}

    /** {@inheritDoc} */
	public void writeFloat(float value) {
		buffer.putFloat(value);
	}

    /** {@inheritDoc} */
	public void writeInt(int value) {
		buffer.putInt(value);
	}

    /** {@inheritDoc} */
	public void writeMultiByte(String value, String encoding) {
		final Charset cs = Charset.forName(encoding);
		final ByteBuffer strBuf = cs.encode(value);
		buffer.put(strBuf);
	}

    /** {@inheritDoc} */
	public void writeObject(Object value) {
		serializer.serialize(output, value);
	}

    /** {@inheritDoc} */
	public void writeShort(short value) {
		buffer.putShort(value);
	}

    /** {@inheritDoc} */
	public void writeUnsignedInt(long value) {
		buffer.putInt((int) value);
	}

    /** {@inheritDoc} */
	public void writeUTF(String value) {
		// fix from issue #97
		try {
			byte[] strBuf = value.getBytes(AMF.CHARSET.name());
	        buffer.putShort((short) strBuf.length);
	        buffer.put(strBuf);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}

    /** {@inheritDoc} */
	public void writeUTFBytes(String value) {
		final java.nio.ByteBuffer strBuf = AMF.CHARSET.encode(value);
		buffer.put(strBuf);
	}

}


text:
package org.pathvisio.libgpml.model.type;

import java.util.Map;
import java.util.TreeMap;

import org.pathvisio.libgpml.debug.Logger;

/**
 * This class contains extensible enum for Group type property. Groups can have
 * different biological meanings (e.g. protein Complex), and can be rendered in
 * different ways based on that.
 *
 * NB: group type previously named group style.
 *
 * @author unknown, finterly
 */
public class GroupType {

	private static Map<String, GroupType> nameToGroupType = new TreeMap<String, GroupType>(
			String.CASE_INSENSITIVE_ORDER);

	public static final GroupType GROUP = new GroupType("Group"); // default: replaces "NONE" of 2013a
	public static final GroupType TRANSPARENT = new GroupType("Transparent"); // replaces "GROUP" of 2013a
	public static final GroupType COMPLEX = new GroupType("Complex");
	public static final GroupType PATHWAY = new GroupType("Pathway");
	public static final GroupType ANALOG = new GroupType("Analog");
	public static final GroupType PARALOG = new GroupType("Paralog");

	private String name;

	/**
	 * The constructor is private. GroupType cannot be directly instantiated. Use
	 * create() method to instantiate GroupType.
	 *
	 * @param name the string key.
	 */
	private GroupType(String name) {
		if (name == null) {
			throw new NullPointerException();
		}
		this.name = name;
		nameToGroupType.put(name, this); // adds this name and GroupType to map.
	}

	/**
	 * Returns a GroupType from a given string identifier name. If the GroupType
	 * doesn't exist yet, it is created to extend the enum. The method makes sure
	 * that the same object is not added twice.
	 *
	 * @param name the string key.
	 * @return the GroupType for given name. If name does not exist, creates and
	 *         returns a new GroupType.
	 */
	public static GroupType register(String name) {
		if (nameToGroupType.containsKey(name)) {
			return nameToGroupType.get(name);
		} else {
			Logger.log.trace("Registered group type " + name);
			return new GroupType(name);
		}
	}

	/**
	 * Returns the name key for this GroupType.
	 *
	 * @return name the key for this GroupType.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Looks up the ConnectorType corresponding to that name.
	 */
	public static GroupType fromName(String name) {
		return nameToGroupType.get(name);
	}

	/**
	 * Returns the names of all registered GroupTypes as a list.
	 *
	 * @return names the names of all registered GroupTypes in order of insertion.
	 */
	static public String[] getNames() {
		return nameToGroupType.keySet().toArray(new String[nameToGroupType.size()]);
	}

	/**
	 * Returns the group type values of all GroupTypes as a list.
	 *
	 * @return groupTypes the list of all registered GroupTypes.
	 */
	static public GroupType[] getValues() {
		return nameToGroupType.values().toArray(new GroupType[0]);
	}

	/**
	 * Returns a string representation of this GroupType.
	 *
	 * @return name the identifier of this GroupType.
	 */
	public String toString() {
		return name;
	}

	/**
	 * Compares string representations of given GroupType lexicographically.
	 *
	 * @return positive number (integer difference of character value) if first
	 *         string is lexicographically greater than second string, negative
	 *         number if first string is less than second string lexicographically,
	 *         and 0 if first string is lexicographically equal to second string.
	 */
	public int compareTo(GroupType groupType) {
		return toString().compareTo(groupType.toString());
	}

}


text:
// *****************************************************************************
//
//  © Component Factory Pty Ltd 2017. All rights reserved.
//	The software and associated documentation supplied hereunder are the
//  proprietary information of Component Factory Pty Ltd, 13 Swallows Close,
//  Mornington, Vic 3931, Australia and are supplied subject to licence terms.
//
//  Version 4.6.0.0 	www.ComponentFactory.com
// *****************************************************************************

using System;
using System.Text;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Drawing2D;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;

namespace ComponentFactory.Krypton.Toolkit
{
    /// <summary>
    /// Redirect back/border/content based on the incoming grid state and style.
    /// </summary>
    public class PaletteRedirectBreadCrumb : PaletteRedirect
    {
        #region Instance Fields
        private bool _left;
        private bool _right;
        private bool _topBottom;
        #endregion

        #region Identity
        /// <summary>
        /// Initialize a new instance of the PaletteRedirectBreadCrumb class.
        /// </summary>
        /// <param name="target">Initial palette target for redirection.</param>
        public PaletteRedirectBreadCrumb(IPalette target)
            : base(target)
        {
            _left = false;
            _right = false;
            _topBottom = true;
        }
		#endregion

        #region Left
        /// <summary>
        /// Gets and sets if the left border should be removed.
        /// </summary>
        public bool Left
        {
            get { return _left; }
            set { _left = value; }
        }
        #endregion

        #region Right
        /// <summary>
        /// Gets and sets if the right border should be removed.
        /// </summary>
        public bool Right
        {
            get { return _right; }
            set { _right = value; }
        }
        #endregion

        #region TopBottom
        /// <summary>
        /// Gets and sets if the top and bottom borders should be removed.
        /// </summary>
        public bool TopBottom
        {
            get { return _topBottom; }
            set { _topBottom = value; }
        }
        #endregion

        #region GetBorderDrawBorders
        /// <summary>
        /// Gets a value indicating which borders to draw.
        /// </summary>
        /// <param name="style">Border style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>PaletteDrawBorders value.</returns>
        public override PaletteDrawBorders GetBorderDrawBorders(PaletteBorderStyle style, PaletteState state)
        {
            PaletteDrawBorders borders = base.GetBorderDrawBorders(style, state);

            // We are only interested in bread crums buttons
            if (style == PaletteBorderStyle.ButtonBreadCrumb)
            {
                if (Left)
                    borders &= ~PaletteDrawBorders.Left;

                if (Right)
                    borders &= ~PaletteDrawBorders.Right;

                if (TopBottom)
                    borders &= ~PaletteDrawBorders.TopBottom;
            }

            return borders;
        }
        #endregion
    }
}


text:
#include "../mumble_plugin_win32.h"

BYTE *posptr;
BYTE *frontptr;
BYTE *topptr;
BYTE *contextptr;

static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &identity) {
	char logincheck;
	char state;
	bool ok;
	// containers that will hold raw unedited data.
	char ccontext[64];
	float pos_corrector[3];
	float front_corrector[3];
	float top_corrector[3];

	for (int i=0;i<3;i++)
		avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;

	// When your are not logged in and the context pointer will not work.
	ok = peekProc((BYTE *) 0x01fce170, &logincheck, 1);
	if (! ok)
		return false;

	if (logincheck == 0)
		return false;

	// State value is working most of the time.
	ok = peekProc((BYTE *) 0x01fb1b99, &state, 1); // Magical state value
	if (! ok)
		return false;

	// When state is 0 your are loaded into a map, when it is 1 your are not in a map.
	if (state == 1)
		return true; // This results in all vectors beeing zero which tells Mumble to ignore them.

	ok = peekProc(posptr, &pos_corrector, 12) &&
	     peekProc(frontptr, &front_corrector, 12) &&
	     peekProc(topptr, &top_corrector, 12) &&
	     peekProc(contextptr, ccontext, 64);

	if (! ok)
		return false;

	// coordinate systems:
	// "ENU"	"Mumble"	"In game"
	// East		x+ [0]		z+ [2]
	// North	z+ [2]		x+ [0]
	// Up		y+ [1]		y+ [1]
	avatar_pos[0] = pos_corrector[2];
	avatar_pos[1] = pos_corrector[1];
	avatar_pos[2] = pos_corrector[0];

	for (int i=0;i<3;i++)
		avatar_pos[i]/=100.0f; // Unreal Unit is set to centimeters

	avatar_front[0] = front_corrector[2];
	avatar_front[1] = front_corrector[1];
	avatar_front[2] = front_corrector[0];

	avatar_top[0] = top_corrector[2];
	avatar_top[1] = top_corrector[1];
	avatar_top[2] = top_corrector[0];

	for (int i=0;i<3;i++) {
		camera_pos[i] = avatar_pos[i];
		camera_front[i] = avatar_front[i];
		camera_top[i] = avatar_top[i];
	}

	ccontext[63] = 0;
	context = std::string(ccontext);
	if (context.find("bderlandspc") != std::string::npos)
		context.erase(0, context.find("bderlandspc"));
	if (context.find(":7777") != std::string::npos)
		context.erase(context.find(":7777") + 5);

	return ok;
}

static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
	posptr = frontptr = topptr = contextptr = NULL;

	if (!initialize(pids, L"Borderlands.exe", L"Borderlands.exe"))
		return false;

	BYTE *ptr1 = peekProc<BYTE *>(pModule +  0x01b69564);

	posptr = ptr1 + 0x9200;
	frontptr = ptr1 + 0x9248;
	topptr = ptr1 + 0x9230;

	ptr1 = peekProc<BYTE *>(pModule + 0x01bcd184);
	BYTE *ptr2 = peekProc<BYTE *>(ptr1 + 0x28c);
	BYTE *ptr3 = peekProc<BYTE *>(ptr2 + 0x210);

	contextptr = ptr3 + 0x2c;

	float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3];
	std::string context;
	std::wstring identity;

	if (fetch(apos, afront, atop, cpos, cfront, ctop, context, identity)) {
		return true;
	} else {
		generic_unlock();
		return false;
	}
}

static const std::wstring longdesc() {
	return std::wstring(L"Supports Borderlands v1.30. No identity support, but is also not needed.");
}

static std::wstring description(L"Borderlands v1.30");
static std::wstring shortname(L"Borderlands");

static int trylock1() {
	return trylock(std::multimap<std::wstring, unsigned long long int>());
}

static MumblePlugin borderlandsplug = {
	MUMBLE_PLUGIN_MAGIC,
	description,
	shortname,
	NULL,
	NULL,
	trylock1,
	generic_unlock,
	longdesc,
	fetch
};

static MumblePlugin2 borderlandsplug2 = {
	MUMBLE_PLUGIN_MAGIC_2,
	MUMBLE_PLUGIN_VERSION,
	trylock
};

extern "C" __declspec(dllexport) MumblePlugin *getMumblePlugin() {
	return &borderlandsplug;
}

extern "C" __declspec(dllexport) MumblePlugin2 *getMumblePlugin2() {
	return &borderlandsplug2;
}


text:
package net.soundvibe.reacto.errors;

/**
 * @author Linas on 2017.01.18.
 */
public class CannotFindEventHandlers extends RuntimeException {

    public CannotFindEventHandlers(String message) {
        super(message);
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/sem_title_text"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="bottom"
        android:layout_marginBottom="4dp"
        android:layout_marginLeft="6dp"
		android:textStyle="bold"
		android:text="TextView" />

</LinearLayout>


text:
TEST_CASE("SourceUpdater")
{
	SECTION("No update")
	{
		SourceUpdater updater("Danbooru (2.0)", "tests/resources/sites/Danbooru (2.0)", "http://raw.githubusercontent.com/Bionus/imgbrd-grabber/master/src/sites");

		// Wait for updater
		QSignalSpy spy(&updater, SIGNAL(finished(QString, bool)));
		updater.checkForUpdates();
		REQUIRE(spy.wait());

		// Get results
		QList<QVariant> arguments = spy.takeFirst();
		bool isNew = arguments.at(1).toBool();

		REQUIRE(!isNew);
	}

	SECTION("Changed")
	{
		SourceUpdater updater("Danbooru", "tests/resources/sites/Danbooru", "http://raw.githubusercontent.com/Bionus/imgbrd-grabber/master/src/sites");

		// Wait for updater
		QSignalSpy spy(&updater, SIGNAL(finished(QString, bool)));
		updater.checkForUpdates();
		REQUIRE(spy.wait());

		// Get results
		QList<QVariant> arguments = spy.takeFirst();
		bool isNew = arguments.at(1).toBool();

		REQUIRE(isNew);
	}
}


text:
<!DOCTYPE html>

    <title>Suzaku Web Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>


text:
/**
 * Provides classes for configuring HazelcastInstance.
 */
package com.hazelcast.config;


text:
@interface CabernetSauvignon : Beverage

@end


text:
{-# LANGUAGE CPP #-}
module GHCJS.DOM.XMLHttpRequestProgressEvent (
#if (defined(ghcjs_HOST_OS) && defined(USE_JAVASCRIPTFFI)) || !defined(USE_WEBKIT)
  module GHCJS.DOM.JSFFI.Generated.XMLHttpRequestProgressEvent
#else
#endif
  ) where
#if (defined(ghcjs_HOST_OS) && defined(USE_JAVASCRIPTFFI)) || !defined(USE_WEBKIT)
import GHCJS.DOM.JSFFI.Generated.XMLHttpRequestProgressEvent
#else
#endif