text:
#ifndef __SENSE4_H__
#define __SENSE4_H__

#ifdef  _MSC_VER
#pragma comment(linker, "/defaultlib:setupapi.lib")
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if defined WIN32 || defined _WIN32 || defined _WIN64
#include <windows.h>
typedef HANDLE S4HANDLE;

#elif defined __MACH__
typedef io_connect_t S4HANDLE;

#else
typedef void*           S4HANDLE;
#endif  /* defined WIN32 || defined _WIN32 || defined _WIN64 */

#ifndef         IN
#define         IN
#endif

#ifndef         OUT
#define         OUT
#endif

#if !defined _WINDOWS_

#define WINAPI

#define CONST const

typedef unsigned char   UCHAR;
typedef unsigned short  USHORT;
typedef unsigned int    UINT;
typedef unsigned long   ULONG;

typedef char            CHAR;
typedef char            TCHAR;

typedef void            VOID;

#ifndef _BYTE_DEFINED
#define _BYTE_DEFINED
typedef unsigned char   BYTE;
#endif

#ifndef _WORD_DEFINED
#define _WORD_DEFINED
typedef unsigned short  WORD;
#endif

#ifndef _DWORD_DEFINED
#define _DWORD_DEFINED
typedef unsigned long   DWORD;
#endif

typedef VOID*           LPVOID;
typedef CHAR*           LPSTR;
typedef CONST CHAR*     LPCSTR;
typedef CONST TCHAR*    LPCTSTR;
typedef BYTE*           LPBYTE;
typedef WORD*           LPWORD;
typedef DWORD*          LPDWORD;

#endif /* !defined _WINDOWS */

//@{
/**
        device share mode definition
*/
#define S4_EXCLUSIZE_MODE                       0                               /** exclusive mode*/
#define S4_SHARE_MODE                           1                               /** sharable mode*/
//@}

//@{
/**
        the control code value definition
*/
#define S4_LED_UP                               0x00000004                      /** LED up*/
#define S4_LED_DOWN                             0x00000008                      /** LED down*/
#define S4_LED_WINK                             0x00000028                      /** LED wink*/
#define S4_GET_DEVICE_TYPE                      0x00000025                      /** get the device type*/
#define S4_GET_SERIAL_NUMBER                    0X00000026                      /** get the device serial number*/
#define S4_GET_VM_TYPE                          0X00000027                      /** get the virtual machine type*/
#define S4_GET_DEVICE_USABLE_SPACE              0x00000029                      /** get the total space of the device*/
#define S4_SET_DEVICE_ID                        0x0000002a                      /** set the device ID*/
#define S4_RESET_DEVICE                         0x00000002                      /** reset the device*/
#define S4_DF_AVAILABLE_SPACE                   0x00000031                      /** get the free space of current directory*/
#define S4_EF_INFO                              0x00000032                      /** get specified file information in current directory*/
#define S4_SET_USB_MODE                         0x00000041                      /** set the device as a normal usb device*/
#define S4_SET_HID_MODE                         0x00000042                      /** set the device as a HID device*/
#define S4_GET_CUSTOMER_NAME                    0x0000002b                      /** get the customer number*/
#define S4_GET_MANUFACTURE_DATE                 0x0000002c                      /** get the manufacture date of the device*/
#define S4_GET_CURRENT_TIME                     0x0000002d                      /** get the current time of the clock device*/
#define S4_SET_NET_CONFIG                       0x00000030                      /** set netlock config */
//@}

//@}

//@{
/**
        device type definition
*/
#define S4_LOCAL_DEVICE                         0x00                            /** local device*/
#define S4_MASTER_DEVICE                        0x01                            /** net master device*/
#define S4_SLAVE_DEVICE                         0x02                            /** net slave device*/

//@}

//@{
/**
        virtual machine type definition
*/
#define S4_VM_51                                0x00                            /** inter 51*/
#define S4_VM_251_BINARY                        0x01                            /** inter 251, binary mode*/
#define S4_VM_251_SOURCE                        0X02                            /** inter 251, source mode*/

//@}

//@{
/**
        NetLock license mode
*/
#define S4_MODULE_MODE                          0x00000000                            /** Module mode*/
#define S4_IP_MODE                              0x00000001                            /** IP mode*/

//@}

//@{
/**
        PIN and key type definition
*/
#define S4_USER_PIN                             0x000000a1                      /** user PIN*/
#define S4_DEV_PIN                              0x000000a2                      /** developer PIN*/
#define S4_AUTHEN_PIN                           0x000000a3                      /** authentication key of net device*/

//@}

//@{
/**
        file type definition
*/

#define S4_RSA_PUBLIC_FILE                      0x00000006                      /** RSA public key file*/
#define S4_RSA_PRIVATE_FILE                     0x00000007                      /** RSA private key file*/
#define S4_EXE_FILE                             0x00000008                      /** executable file of virtual machine*/
#define S4_DATA_FILE                            0x00000009                      /** data file*/
#define S4_XA_EXE_FILE                          0x0000000b                      /** executable file of XA User mode*/

//@}

//@{
/**
        flag value definition
*/
#define S4_CREATE_NEW                           0x000000a5                      /** create a new file*/
#define S4_UPDATE_FILE                          0x000000a6                      /** write data to the specified file*/
#define S4_KEY_GEN_RSA_FILE                     0x000000a7                      /** generate RSA key pair files*/
#define S4_SET_LICENCES                         0x000000a8                      /** set the max license number of the current module for the net device*/
#define S4_CREATE_ROOT_DIR                      0x000000ab                      /** create root directory*/
#define S4_CREATE_SUB_DIR                       0x000000ac                      /** create child directory for current directory*/
#define S4_CREATE_MODULE                        0x000000ad                      /** create a module directory for the net device */
/** the following three flags can only be used when creating a new executable file */
#define S4_FILE_READ_WRITE                      0x00000000                      /** the new executable file can be read and written by executable file */
#define S4_FILE_EXECUTE_ONLY                    0x00000100                      /** the new executable file can't be read or written by executable file*/
#define S4_CREATE_PEDDING_FILE                  0x00002000                      /** create a padding file*/

//@}

//@{
/**
        execuable file executing mode definition
*/
#define S4_VM_EXE                               0x00000000                      /** executing on virtual machine*/
#define S4_XA_EXE                               0x00000001                      /** executing on XA User mode   */

//@}

//@{
/**
        return value definition
*/

#define S4_SUCCESS                              0x00000000                      /** success*/
#define S4_UNPOWERED                            0x00000001                      /** the device has been powered off*/
#define S4_INVALID_PARAMETER                    0x00000002                      /** invalid parameter*/
#define S4_COMM_ERROR                           0x00000003                      /** communication error*/
#define S4_PROTOCOL_ERROR                       0x00000004                      /** communication protocol error*/
#define S4_DEVICE_BUSY                          0x00000005                      /** the device is busy*/
#define S4_KEY_REMOVED                          0x00000006                      /** the device has been removed */
#define S4_INSUFFICIENT_BUFFER                  0x00000011                      /** the input buffer is insufficient*/
#define S4_NO_LIST                              0x00000012                      /** find no device*/
#define S4_GENERAL_ERROR                        0x00000013                      /** general error, commonly indicates not enough memory*/
#define S4_UNSUPPORTED                          0x00000014                      /** the function isn't supported*/
#define S4_DEVICE_TYPE_MISMATCH                 0x00000020                      /** the device type doesn't match*/
#define S4_FILE_SIZE_CROSS_7FFF                 0x00000021                      /** the execuable file crosses address 0x7FFF*/
#define S4_CURRENT_DF_ISNOT_MF                  0x00000201                      /** a net module must be child directory of the root directory*/
#define S4_INVAILABLE_MODULE_DF                 0x00000202                      /** the current directory is not a module*/
#define S4_FILE_SIZE_TOO_LARGE                  0x00000203                      /** the file size is beyond address 0x7FFF*/
#define S4_DF_SIZE                              0x00000204                      /** the specified directory size is too small*/
#define S4_DEVICE_UNSUPPORTED                   0x00006a81                      /** the request can't be supported by the device*/
#define S4_FILE_NOT_FOUND                       0x00006a82                      /** the specified file or directory can't be found */
#define S4_INSUFFICIENT_SECU_STATE              0x00006982                      /** the security state doesn't match*/
#define S4_DIRECTORY_EXIST                      0x00006901                      /** the specified directory has already existed*/
#define S4_FILE_EXIST                           0x00006a80                      /** the specified file or directory has already existed*/
#define S4_INSUFFICIENT_SPACE                   0x00006a84                      /** the space is insufficient*/
#define S4_OFFSET_BEYOND                        0x00006B00                      /** the offset is beyond the file size*/
#define S4_PIN_BLOCK                            0x00006983                      /** the specified pin or key has been locked*/
#define S4_FILE_TYPE_MISMATCH                   0x00006981                      /** the file type doesn't match*/
#define S4_CRYPTO_KEY_NOT_FOUND                 0x00009403                      /** the specified pin or key cann't be found*/
#define S4_APPLICATION_TEMP_BLOCK               0x00006985                      /** the directory has been temporarily locked*/
#define S4_APPLICATION_PERM_BLOCK               0x00009303                      /** the directory has been locked*/
#define S4_DATA_BUFFER_LENGTH_ERROR             0x00006700                      /** invalid data length*/
#define S4_CODE_RANGE                           0x00010000                      /** the PC register of the virtual machine is out of range*/
#define S4_CODE_RESERVED_INST                   0x00020000                      /** invalid instruction*/
#define S4_CODE_RAM_RANGE                       0x00040000                      /** internal ram address is out of range*/
#define S4_CODE_BIT_RANGE                       0x00080000                      /** bit address is out of range*/
#define S4_CODE_SFR_RANGE                       0x00100000                      /** SFR address is out of range*/
#define S4_CODE_XRAM_RANGE                      0x00200000                      /** external ram address is out of range*/
#define S4_ERROR_UNKNOWN                        0xffffffff                      /** unknown error*/

/* user define */
#define S4_ERROR_INPUT_TOO_LONG                 0x00000301                      /** input data length must be less than MAX_DATA_BLOCK_LEN*/
#define S4_ERROR_INSUFFICIENT_BUFFER            0x00000302                      /** insufficient out-buffer size*/
#define S4_ERROR_INVALID_DATA                   0x00000303                      /** Invalid data package returned*/
#define S4_ERROR_OUT_BUFFER                     0x00000304                      /** insufficient out-buffer*/
#define S4_ERROR_DEVICE                         0x00000305                      /** OpenS4ByIndex error(device not ready)*/

//@}

#define MAX_ATR_LEN                             56                              /** max ATR length */
#define MAX_ID_LEN                              8                               /** max device ID length */
#define S4_RSA_MODULUS_LEN                      128                             /** RSA key modules length,in bytes */
#define S4_RSA_PRIME_LEN                        64                              /** RSA key prime length,in bytes*/

//@{
/**
        structure definition
*/

/* file information definition*/
typedef struct{
        WORD EfID;                                                              /* file ID*/
        BYTE EfType;                                                            /* file type*/
        WORD EfSize;                                                            /* file size*/
}EFINFO,*PEFINFO;

/* device production date structure definition*/
typedef struct {
        WORD    wYear;                                                          /* year*/
        BYTE    byMonth;                                                        /* month*/
        BYTE    byDay;                                                          /* the day of the month */
}S4_MANUFACTURE_DATE;

/* current time structure definition*/
#ifndef _TM_DEFINED

typedef struct {
        int tm_sec;                                                             /* seconds after the minute - [0,59] */
        int tm_min;                                                             /* minutes after the hour - [0,59] */
        int tm_hour;                                                            /* hours since midnight - [0,23] */
        int tm_mday;                                                            /* day of the month - [1,31] */
        int tm_mon;                                                             /* months since January - [0,11] */
        int tm_year;                                                            /* years since 1900 */
        int tm_wday;                                                            /* days since Sunday - [0,6] */
        int tm_yday;                                                            /* days since January 1 - [0,365] */
        int tm_isdst;                                                           /* daylight savings time flag */
} TM;
#define _TM_DEFINED
#endif

/**
        device version definition
*/
typedef enum{
        SENSE4_CARD_TYPE_V2_00 = 0x00020000,                                    /** version 2.00*/
        SENSE4_CARD_TYPE_V2_01 = 0x00020001,                                    /** version 2.10*/
        SENSE4_CARD_TYPE_V2_02 = 0x00020002,                                    /** version 2.20*/
        SENSE4_CARD_TYPE_V2_05 = 0x00020005,                                    /** version 2.05*/
        SENSE4_CARD_TYPE_V2_30 = 0x00020300                                     /** version 2.30*/
}CARD_VERSION;

/**
        device information structure definition
*/
typedef struct {
        DWORD                   dwIndex;                                        /** device index; index begins at zero*/
        DWORD                   dwVersion;                                      /** device version*/
        S4HANDLE                hLock;                                          /** device handle*/
        BYTE                    reserve[12];                                    /** reserved*/
        BYTE                    bAtr[MAX_ATR_LEN];                              /** ATR*/
        BYTE                    bID[MAX_ID_LEN];                                /** device ID*/
        DWORD                   dwAtrLen;                                       /** ATR length*/
}SENSE4_CONTEXT,*PSENSE4_CONTEXT;

/** RSA public key structure*/
typedef struct {
  unsigned char modulus[S4_RSA_MODULUS_LEN];                                    /* modulus*/
  unsigned char exponent[S4_RSA_MODULUS_LEN];                                   /* public exponent*/
} S4_RSA_PUBLIC_KEY;

/** RSA private key structure*/
typedef struct {
  unsigned char modulus[S4_RSA_MODULUS_LEN];                                    /* modulus*/
  unsigned char publicExponent[S4_RSA_MODULUS_LEN];                             /* public exponent*/
  unsigned char exponent[S4_RSA_MODULUS_LEN];                                   /* private exponent*/
  unsigned char prime[2][S4_RSA_PRIME_LEN];                                     /* prime factors*/
  unsigned char primeExponent[2][S4_RSA_PRIME_LEN];                             /* exponents for CRT*/
  unsigned char coefficient[S4_RSA_PRIME_LEN];                                  /* CRT coefficient*/
} S4_RSA_PRIVATE_KEY;

/** Netlock Module infomation definition*/
typedef struct _S4MODULEINFO {
  WORD  wModuleID;                                                             /* Module ID*/
  WORD  wLicenseCount;                                                         /* License Count */
} S4MODULEINFO;

typedef struct _S4NETCONFIG {
  DWORD         dwLicenseMode;                                                    /* License Mode */
  DWORD         dwModuleCount;                                                    /* Module Count */
  S4MODULEINFO  ModuleInfo[16];                                                   /* Module detail infomation */
} S4NETCONFIG;

/** S4CREATEDIRINFO structure definition*/
typedef struct _S4CREATEDIRINFO {
        DWORD         dwS4CreateDirInfoSize;                                            /* size of the structure*/
        BYTE          szAtr[8];                                                         /* ATR information */
        S4NETCONFIG   NetConfig;                                                        /* netlock config infomation */
} S4CREATEDIRINFO;

/** S4OPENINFO structure definition*/
typedef struct _S4OPENINFO {
        DWORD dwS4OpenInfoSize;                                                 /* size of the structure*/
        DWORD dwShareMode;                                                      /* share mode*/
} S4OPENINFO;

//@}

//@{
/**
        @function interface
*/

/*
                        reserved
*/
unsigned long WINAPI S4Startup(
        VOID
);

/*
                        reserved
*/
unsigned long WINAPI S4Cleanup(
        VOID
);

/**
                enumerate all EliteIV devices plugged in the computer.
                if pS4CtxList is NULL, the pdwCtxListSize will return the required buffer size

                @paramter pS4CtxList             [out]           return the device list
                @paramter pdwCtxListSize         [in][out]       return the amount of storage of device list, in bytes.

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4Enum(
        OUT     SENSE4_CONTEXT   *pS4CtxList,
        IN OUT  DWORD            *pdwCtxListSize
);

/**
                open the EliteIV device with sharable mode

                @paramter pS4Ctx                 [in][out]    the context pointer of the device

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4Open(
        IN OUT  SENSE4_CONTEXT    *pS4Ctx
);

/**
                close the EliteIV device

                @parameter pS4Ctx                [in]  the context pointer of the device

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4Close(
        IN      SENSE4_CONTEXT    *pS4Ctx
);

/**
                Send control command to device

                @parameter pS4Ctx                [in]  the context pointer of the device, the device must has been opened
                @parameter dwCtlCode             [in]  control code
                @parameter pInBuffer             [in]  input buffer
                @parameter dwInBufferLen         [in]  the length of input data,in bytes
                @parameter pOutBuffer            [out] return output data
                @parameter dwOutBufferLen        [in]  output buffer size, in bytes
                @parameter pdwBytesReturned      [out] the length of output data, cannot be NULL

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4Control(
        IN      SENSE4_CONTEXT    *pS4Ctx,
        IN      DWORD             dwCtlCode,
        IN      VOID              *pInBuffer,
        IN      DWORD             dwInBufferLen,
        OUT     VOID              *pOutBuffer,
        IN      DWORD             dwOutBufferLen,
        OUT     DWORD             *pdwBytesReturned
);

/**
                create a new child directory for the current directory, and set current directory to the new directory

                @parameter pS4Ctx               [in]  the context pointer of the device, the device must has been opened
                @parameter lpszDirID            [in]  ID of the new directory
                @parameter dwDirSize            [in]  size of the new directory
                @parameter dwFlags              [in]  flag

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4CreateDir(
        IN      SENSE4_CONTEXT     *pS4Ctx,
        IN      LPCSTR             lpszDirID,
        IN      DWORD              dwDirSize,
        IN      DWORD              dwFlags
);

/**
                set the current directory

                @parameter pS4Ctx                [in]  the context pointer of the device, the device must has been opened
                @parameter lpszPath              [in]  ID of the specified directory

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4ChangeDir(
        IN      SENSE4_CONTEXT     *pS4Ctx,
        IN      LPCSTR             lpszPath
);

/**
                erase the root and empty the device if the specified direcotry is the device root,
                otherwise erase all files or child direcotries of the specified directory.

                @parameter pS4Ctx                [in]  the context pointer of the device, the device must has been opened
                @parameter lpszDirID             [in]  reserved, must be NULL

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4EraseDir(
        IN      SENSE4_CONTEXT     *pS4Ctx,
        IN      LPCTSTR            lpszDirID
);

/**
                verify the pin, to reach a security status before call S4CreateDir,S4EraseDir,S4Execute,S4WriteFile.

                @parameter pS4Ctx                [in]  the context pointer of the device, the device must has been opened
                @parameter pbPin                 [in]  PIN value
                @parameter dwPinLen              [in]  the PIN value length, the length of User PIN is 8 bytes£¬the length of developer PIN is 24 bytes
                @parameter dwPinType             [in]  PIN type

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4VerifyPin(
        IN      SENSE4_CONTEXT     *pS4Ctx,
        IN      BYTE               *pbPin,
        IN      DWORD              dwPinLen,
        IN      DWORD              dwPinType
);

/**
                change PIN or key value¡£

                @parameter pS4Ctx                [in]  the context pointer of the device, the device must has been opened
                @parameter pbOldPin              [in]  old PIN or key value
                @parameter dwOldPinLen           [in]  the length of old PIN or key value
                @parameter pbNewPin              [in]  new PIN or key value
                @parameter dwNewPinLen           [in]  the legnth of new PIN or key value
                @parameter dwPinType             [in]  PIN or key type

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4ChangePin(
        IN      SENSE4_CONTEXT     *pS4Ctx,
        IN      BYTE               *pbOldPin,
        IN      DWORD              dwOldPinLen,
        IN      BYTE               *pbNewPin,
        IN      DWORD              dwNewPinLen,
        IN      DWORD              dwPinType
);

/**
                create a new file or update file data

                @parameter pS4Ctx                [in]  the context pointer of the device, the device must has been opened
                @parameter lpszFileID            [in]  ID of the specified file
                @parameter dwOffset              [in]  offset to write the file
                @parameter pBuffer               [in]  input data buffer
                @parameter dwBufferSize          [in]  input data length
                @parameter dwFileSize            [in]  file size
                @parameter pdwBytesWritten       [out] return the length of data written into the file
                @parameter dwFlags               [in]  flag
                @parameter bFileType             [in]  file type

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4WriteFile(
        IN      SENSE4_CONTEXT     *pS4Ctx,
        IN      LPCSTR             lpszFileID,
        IN      DWORD              dwOffset,
        IN      VOID               *pBuffer,
        IN      DWORD              dwBufferSize,
        IN      DWORD              dwFileSize,
        OUT     DWORD              *pdwBytesWritten,
        IN      DWORD              dwFlags,
        IN      BYTE               bFileType
);

/**
                execute the specified executable file of current directory on virtual machine

                @parameter pS4Ctx                [in]  the context pointer of the device, the device must has been opened
                @parameter lpszFileID            [in]  ID of the executable file
                @parameter pInBuffer             [in]  input data buffer
                @parameter dwInbufferSize        [in]  input data length
                @parameter pOutBuffer            [out] output data buffer
                @parameter dwOutBufferSize       [in]  output data buffer size
                @parameter pdwBytesReturned      [out] output data length

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.
*/
DWORD WINAPI S4Execute(
        IN      SENSE4_CONTEXT     *pS4Ctx,
        IN      LPCSTR             lpszFileID,
        IN      VOID               *pInBuffer,
        IN      DWORD              dwInbufferSize,
        OUT     VOID               *pOutBuffer,
        IN      DWORD              dwOutBufferSize,
        OUT     DWORD              *pdwBytesReturned
);

/**
                execute the specified executable file of current directory on virtual machine
                or on XA User mode

                @parameter pS4Ctx                [in]  the context pointer of the device, the device must has been opened
                @parameter lpszFileID            [in]  ID of the executable file
                @parameter dwFlag                [in]  executing mode
                @parameter pInBuffer             [in]  input data buffer
                @parameter dwInbufferSize        [in]  input data length
                @parameter pOutBuffer            [out] output data buffer
                @parameter dwOutBufferSize       [in]  output data buffer size
                @parameter pdwBytesReturned      [out] output data length

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4ExecuteEx(
        IN      SENSE4_CONTEXT     *pS4Ctx,
        IN      LPCSTR             lpszFileID,
        IN      DWORD              dwFlag,
        IN      VOID               *pInBuffer,
        IN      DWORD              dwInbufferSize,
        OUT     VOID               *pOutBuffer,
        IN      DWORD              dwOutBufferSize,
        OUT     DWORD              *pdwBytesReturned
);

/**
                create a new child directory for the current directory, and set the new
                directory to current directory. if creating the root directory, the function
                will create a ATR file at the same time.

                @parameter pS4Ctx               [in]  the context pointer of the device, the device must has been opened
                @parameter lpszDirID            [in]  ID of the new directory
                @parameter dwDirSize            [in]  size of the new directory
                @parameter dwFlags              [in]  flag
                @parameter pCreateDirInfo       [in]  S4CREATEDIRINFO structure pointer

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4CreateDirEx(
        IN  SENSE4_CONTEXT         *pS4Ctx,
        IN  LPCSTR                 lpszDirID,
        IN  DWORD                  dwDirSize,
        IN  DWORD                  dwFlags,
        IN  S4CREATEDIRINFO        *pCreateDirInfo
);

/**
                open the EliteIV device using specific mode

                @paramter pS4Ctx                 [in][out]    the context pointer of the device
                @paramter pS4OpenInfo            [in]         S4OPENINFO structure pointer

                @return value
                if the function succeeds,the return vlaue is S4_SUCCESS, otherwise return other defined return value.

*/
DWORD WINAPI S4OpenEx(
        IN OUT SENSE4_CONTEXT      *pS4Ctx,
        IN S4OPENINFO              *pS4OpenInfo
);

//@}

#ifdef __cplusplus
}
#endif

#endif  //__SENSE4_H__


text:
import { inject, observer } from "mobx-react"
import React, { Component } from "react"
import {
  MdRadioButtonChecked as IconChecked,
  MdRadioButtonUnchecked as IconUnchecked
} from "react-icons/md"
import { WarningBar } from "../Shared/WarningBar"
import AppStyles from "../Theme/AppStyles"

const Styles = {
  container: { ...AppStyles.Layout.vbox },
  controls: {
    ...AppStyles.Layout.vbox,
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    paddingBottom: 40,
    paddingLeft: 10,
    paddingRight: 10,
  },
  storybookLogo: { width: 564 / 2, height: 152 / 2, paddingBottom: 20 },
  checkBoxContainer: { ...AppStyles.Layout.hbox, flex: 0, paddingTop: 20 },
  checkBoxItemOn: {
    ...AppStyles.Layout.hbox,
    alignItems: "center",
    flex: 0,
    paddingRight: 20,
  },
  checkBoxItemOff: {
    ...AppStyles.Layout.hbox,
    alignItems: "center",
    flex: 0,
    cursor: "pointer",
  },
  checkBoxText: { paddingLeft: 3, fontSize: "1.25rem", cursor: "pointer" },
}

const ICON_SIZE = 32

@inject("session")
@observer
class NativeStorybook extends Component {
  render() {
    const { isStorybookShown, enableStorybook, disableStorybook } = this.props.session.ui
    const img = isStorybookShown ? require("../Theme/storybook-logo-color.png") : require("../Theme/storybook-logo.png")

    return (

              {isStorybookShown ? (
                <IconChecked size={ICON_SIZE} />
              ) : (
                <IconUnchecked size={ICON_SIZE} />
              )}
              On

              {!isStorybookShown ? (
                <IconChecked size={ICON_SIZE} />
              ) : (
                <IconUnchecked size={ICON_SIZE} />
              )}
              Off

        <WarningBar>

            This is preview feature. It requires a specific setup of Storybook within React Native.

        </WarningBar>

    )
  }
}

export default NativeStorybook

redpajama_set_name: RedPajamaGithub


text:
namespace Hjson {

typedef std::vector<std::string> KeyVec;
typedef std::vector<Value> ValueVec;
typedef std::map<std::string, Value> ValueMap;

class ValueVecMap {
public:
  KeyVec v;
  ValueMap m;
};

class Value::ValueImpl {
public:
  Type type;
  union {
    bool b;
    double d;
    std::int64_t i;
    std::string *s;
    ValueVec *v;
    ValueVecMap *m;
  };

  ValueImpl();
  ValueImpl(bool);
  ValueImpl(double);
  explicit ValueImpl(std::int64_t);
  ValueImpl(const std::string&);
  ValueImpl(Type);
  ~ValueImpl();
};

class Value::Comments {
public:
  std::string m_commentBefore, m_commentKey, m_commentInside, m_commentAfter;
};

Value::ValueImpl::ValueImpl()
  : type(Type::Undefined)
{
}

Value::ValueImpl::ValueImpl(bool input)
  : type(Type::Bool),
  b(input)
{
}

Value::ValueImpl::ValueImpl(double input)
  : type(Type::Double),
  d(input)
{
}

Value::ValueImpl::ValueImpl(std::int64_t input)
  : type(Type::Int64),
  i(input)
{
}

Value::ValueImpl::ValueImpl(const std::string &input)
  : type(Type::String),
  s(new std::string(input))
{
}

Value::ValueImpl::ValueImpl(Type _type)
  : type(_type)
{
  switch (_type)
  {
  case Type::String:
    s = new std::string();
    break;
  case Type::Vector:
    v = new ValueVec();
    break;
  case Type::Map:
    m = new ValueVecMap();
    break;
  default:
    break;
  }
}

Value::ValueImpl::~ValueImpl() {
  switch (type)
  {
  case Type::String:
    delete s;
    break;
  case Type::Vector:
    delete v;
    break;
  case Type::Map:
    delete m;
    break;
  default:
    break;
  }
}

// Sacrifice efficiency for predictability: It is allowed to do bracket
// assignment on an Undefined Value, and thereby turn it into a Map Value.
// A Map Value is passed by reference, therefore an Undefined Value should also
// be passed by reference, to avoid surprises when doing bracket assignment
// on a Value that has been passed around but is still of type Undefined.
Value::Value()
  : prv(std::make_shared<ValueImpl>(Type::Undefined))
{
}

Value::Value(bool input)
  : prv(std::make_shared<ValueImpl>(input))
{
}

Value::Value(float input)
  : prv(std::make_shared<ValueImpl>(static_cast<double>(input)))
{
}

Value::Value(double input)
  : prv(std::make_shared<ValueImpl>(input))
{
}

Value::Value(long double input)
  : prv(std::make_shared<ValueImpl>(static_cast<double>(input)))
{
}

Value::Value(char input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(unsigned char input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(short input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(unsigned short input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(int input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(unsigned int input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(long input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(unsigned long input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(long long input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(unsigned long long input)
  : prv(std::make_shared<ValueImpl>(static_cast<std::int64_t>(input)))
{
}

Value::Value(const char *input)
  : prv(std::make_shared<ValueImpl>(std::string(input)))
{
}

Value::Value(const std::string& input)
  : prv(std::make_shared<ValueImpl>(input))
{
}

Value::Value(Type _type)
  : prv(std::make_shared<ValueImpl>(_type))
{
}

Value::Value(const Value& other)
  : prv(other.prv)
{
  if (other.cm) {
    // Clone the comments instead of sharing the reference. This way a change
    // in the other Value does not affect the comments in this Value.
    cm.reset(new Comments(*other.cm));
  }
}

Value::Value(Value&& other)
  : prv(other.prv),
    cm(other.cm)
{
}

// Even though the MapProxy is temporary, it contains references that are owned
// by a non-temporary object. Make sure the lvalue constructor is called.
Value::Value(MapProxy&& other)
  : Value(other)
{
}

Value::Value(std::shared_ptr<ValueImpl> _prv, std::shared_ptr<Comments> _cm)
  : prv(_prv),
    cm(_cm)
{
}

Value::~Value() {
}

Value& Value::operator=(const Value& other) {
  // So that comments are kept when assigning a Value to a new key in a map,
  // or to a variable that has not been assigned any other value yet.
  if (!this->defined()) {
    this->set_comments(other);
  }

  this->prv = other.prv;

  return *this;
}

Value& Value::operator=(Value&& other) {
  // So that comments are kept when assigning a Value to a new key in a map,
  // or to a variable that has not been assigned any other value yet.
  if (!this->defined()) {
    this->cm = other.cm;
  }

  this->prv = other.prv;

  return *this;
}

const Value& Value::at(const std::string& name) const {
  switch (prv->type)
  {
  case Type::Undefined:
    throw index_out_of_bounds("Key not found.");
  case Type::Map:
    try {
      return prv->m->m.at(name);
    } catch(const std::out_of_range&) {}
    throw index_out_of_bounds("Key not found.");
  default:
    throw type_mismatch("Must be of type Map for that operation.");
  }
}

Value& Value::at(const std::string& name) {
  switch (prv->type)
  {
  case Type::Undefined:
    throw index_out_of_bounds("Key not found.");
  case Type::Map:
    try {
      return prv->m->m.at(name);
    } catch(const std::out_of_range&) {}
    throw index_out_of_bounds("Key not found.");
  default:
    throw type_mismatch("Must be of type Map for that operation.");
  }
}

const Value& Value::at(const char *name) const {
  return at(std::string(name));
}

Value& Value::at(const char *name) {
  return at(std::string(name));
}

const Value Value::operator[](const std::string& name) const {
  if (prv->type == Type::Undefined) {
    return Value();
  } else if (prv->type == Type::Map) {
    auto it = prv->m->m.find(name);
    if (it == prv->m->m.end()) {
      return Value();
    }
    return it->second;
  }

  throw type_mismatch("Must be of type Undefined or Map for that operation.");
}

MapProxy Value::operator[](const std::string& name) {
  if (prv->type == Type::Undefined) {
    prv->~ValueImpl();
    // Recreate the private object using the same memory block.
    new(&(*prv)) ValueImpl(Type::Map);
  } else if (prv->type != Type::Map) {
    throw type_mismatch("Must be of type Undefined or Map for that operation.");
  }

  auto it = prv->m->m.find(name);
  if (it == prv->m->m.end()) {
    return MapProxy(prv, name, 0);
  }
  return MapProxy(prv, name, &it->second);
}

const Value Value::operator[](const char *input) const {
  return operator[](std::string(input));
}

MapProxy Value::operator[](const char *input) {
  return operator[](std::string(input));
}

const Value Value::operator[](char *input) const {
  return operator[](std::string(input));
}

MapProxy Value::operator[](char *input) {
  return operator[](std::string(input));
}

const Value& Value::operator[](int index) const {
  switch (prv->type)
  {
  case Type::Undefined:
    throw index_out_of_bounds("Index out of bounds.");
  case Type::Vector:
  case Type::Map:
    if (index < 0 || index >= size()) {
      throw index_out_of_bounds("Index out of bounds.");
    }

    switch (prv->type)
    {
    case Type::Vector:
      return prv->v[0][index];
    case Type::Map:
      {
        auto it = prv->m->m.find(prv->m->v[index]);
        assert(it != prv->m->m.end());
        return it->second;
      }
    default:
      break;
    }
  default:
    throw type_mismatch("Must be of type Undefined, Vector or Map for that operation.");
  }
}

Value& Value::operator[](int index) {
  switch (prv->type)
  {
  case Type::Undefined:
    throw index_out_of_bounds("Index out of bounds.");
  case Type::Vector:
  case Type::Map:
    if (index < 0 || index >= size()) {
      throw index_out_of_bounds("Index out of bounds.");
    }

    switch (prv->type)
    {
    case Type::Vector:
      return prv->v[0][index];
    case Type::Map:
      {
        auto it = prv->m->m.find(prv->m->v[index]);
        assert(it != prv->m->m.end());
        return it->second;
      }
    default:
      break;
    }
  default:
    throw type_mismatch("Must be of type Undefined, Vector or Map for that operation.");
  }
}

bool Value::operator==(bool input) const {
  return operator bool() == input;
}

bool Value::operator!=(bool input) const {
  return !(*this == input);
}

#define RET_VAL(_T, _O) \
Value operator _O(_T a, const Value& b) { \
  return Value(a) _O b; \
} \
Value operator _O(const Value& a, _T b) { \
  return a _O Value(b); \
}

#define RET_BOOL(_T, _O) \
bool operator _O(_T a, const Value& b) { \
  return Value(a) _O b; \
} \
bool operator _O(const Value& a, _T b) { \
  return a _O Value(b); \
}

#define HJSON_OP_IMPL_A(_T) \
RET_BOOL(_T, <) \
RET_BOOL(_T, >) \
RET_BOOL(_T, <=) \
RET_BOOL(_T, >=) \
RET_BOOL(_T, ==) \
RET_BOOL(_T, !=)

#define HJSON_OP_IMPL_B(_T) \
HJSON_OP_IMPL_A(_T) \
RET_VAL(_T, +) \
RET_VAL(_T, -) \
RET_VAL(_T, *) \
RET_VAL(_T, /)

#define HJSON_OP_IMPL_C(_T) \
HJSON_OP_IMPL_B(_T) \
RET_VAL(_T, %)

HJSON_OP_IMPL_A(const char*)
HJSON_OP_IMPL_A(const std::string&)
HJSON_OP_IMPL_B(float)
HJSON_OP_IMPL_B(double)
HJSON_OP_IMPL_B(long double)
HJSON_OP_IMPL_C(char)
HJSON_OP_IMPL_C(unsigned char)
HJSON_OP_IMPL_C(short)
HJSON_OP_IMPL_C(unsigned short)
HJSON_OP_IMPL_C(int)
HJSON_OP_IMPL_C(unsigned int)
HJSON_OP_IMPL_C(long)
HJSON_OP_IMPL_C(unsigned long)
HJSON_OP_IMPL_C(long long)
HJSON_OP_IMPL_C(unsigned long long)

std::string operator+(const char *a, const Value& b) {
  return std::string(a) + b.to_string();
}

std::string operator+(const Value& a ,const char *b) {
  return  a.to_string() + std::string(b);
}

std::string operator+(const std::string &a, const Value& b) {
  return a + b.to_string();
}

std::string operator+(const Value& a, const std::string &b) {
  return a.to_string() + b;
}

Value operator+(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d + b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i + b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    throw type_mismatch("The values must be of the same type for this operation.");
  }

  switch (a.prv->type) {
  case Type::Double:
    return a.prv->d + b.prv->d;
  case Type::Int64:
    return a.prv->i + b.prv->i;
  case Type::String:
    return *a.prv->s + *b.prv->s;
  default:
    break;
  }

  throw type_mismatch("The values must be of type Double, Int64 or String for this operation.");
}

bool operator<(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d < b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i < b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    throw type_mismatch("The values must be of the same type for this operation.");
  }

  switch (a.prv->type) {
  case Type::Double:
    return a.prv->d < b.prv->d;
  case Type::Int64:
    return a.prv->i < b.prv->i;
  case Type::String:
    return *a.prv->s < *b.prv->s;
  default:
    break;
  }

  throw type_mismatch("The values must be of type Double, Int64 or String for this operation.");
}

bool operator>(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d > b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i > b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    throw type_mismatch("The values must be of the same type for this operation.");
  }

  switch (a.prv->type) {
  case Type::Double:
    return a.prv->d > b.prv->d;
  case Type::Int64:
    return a.prv->i > b.prv->i;
  case Type::String:
    return *a.prv->s > *b.prv->s;
  default:
    break;
  }

  throw type_mismatch("The values must be of type Double, Int64 or String for this operation.");
}

bool operator<=(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d <= b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i <= b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    throw type_mismatch("The values must be of the same type for this operation.");
  }

  switch (a.prv->type) {
  case Type::Double:
    return a.prv->d <= b.prv->d;
  case Type::Int64:
    return a.prv->i <= b.prv->i;
  case Type::String:
    return *a.prv->s <= *b.prv->s;
  default:
    break;
  }

  throw type_mismatch("The values must be of type Double, Int64 or String for this operation.");
}

bool operator>=(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d >= b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i >= b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    throw type_mismatch("The values must be of the same type for this operation.");
  }

  switch (a.prv->type) {
  case Type::Double:
    return a.prv->d >= b.prv->d;
  case Type::Int64:
    return a.prv->i >= b.prv->i;
  case Type::String:
    return *a.prv->s >= *b.prv->s;
  default:
    break;
  }

  throw type_mismatch("The values must be of type Double, Int64 or String for this operation.");
}

bool operator==(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d == b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i == b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    return false;
  }

  switch (a.prv->type) {
  case Type::Undefined:
  case Type::Null:
    return true;
  case Type::Bool:
    return a.prv->b == b.prv->b;
  case Type::Double:
    return a.prv->d == b.prv->d;
  case Type::String:
    return *a.prv->s == *b.prv->s;
  case Type::Vector:
    return a.prv->v == b.prv->v;
  case Type::Map:
    return a.prv->m == b.prv->m;
  case Type::Int64:
    return a.prv->i == b.prv->i;
  }

  assert(!"Unknown type");

  return false;
}

bool operator!=(const Value& a, const Value& b) {
  return !(a == b);
}

Value operator-(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d - b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i - b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    throw type_mismatch("The values must be of the same type for this operation.");
  }

  switch (a.prv->type) {
  case Type::Double:
    return a.prv->d - b.prv->d;
  case Type::Int64:
    return a.prv->i - b.prv->i;
  default:
    break;
  }

  throw type_mismatch("The values must be of type Double or Int64 for this operation.");
}

Value operator*(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d * b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i * b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    throw type_mismatch("The values must be of the same type for this operation.");
  }

  switch (a.prv->type) {
  case Type::Double:
    return a.prv->d * b.prv->d;
  case Type::Int64:
    return a.prv->i * b.prv->i;
  default:
    break;
  }

  throw type_mismatch("The values must be of type Double or Int64 for this operation.");
}

Value operator/(const Value& a, const Value& b) {
  if (a.prv->type == Type::Double && b.prv->type == Type::Int64) {
    return a.prv->d / b.prv->i;
  } else if (a.prv->type == Type::Int64 && b.prv->type == Type::Double) {
    return a.prv->i / b.prv->d;
  }

  if (a.prv->type != b.prv->type) {
    throw type_mismatch("The values must be of the same type for this operation.");
  }

  switch (a.prv->type) {
  case Type::Double:
    return a.prv->d / b.prv->d;
  case Type::Int64:
    return a.prv->i / b.prv->i;
  default:
    break;
  }

  throw type_mismatch("The values must be of type Double or Int64 for this operation.");
}

Value operator%(const Value& a, const Value& b) {
  if (a.prv->type != b.prv->type || a.prv->type != Type::Int64) {
    throw type_mismatch("The values must be of the Int64 type for this operation.");
  }

  return a.prv->i % b.prv->i;
}

#define OP_ASS(_O, _T) \
Value& Value::operator _O(_T b) { \
  return operator _O(Value(b)); \
}

#define HJSON_ASS_IMPL_A(_T) \
OP_ASS(+=, _T) \
OP_ASS(-=, _T) \
OP_ASS(*=, _T) \
OP_ASS(/=, _T)

#define HJSON_ASS_IMPL_B(_T) \
HJSON_ASS_IMPL_A(_T) \
OP_ASS(%=, _T)

HJSON_ASS_IMPL_A(float)
HJSON_ASS_IMPL_A(double)
HJSON_ASS_IMPL_A(long double)
HJSON_ASS_IMPL_B(char)
HJSON_ASS_IMPL_B(unsigned char)
HJSON_ASS_IMPL_B(short)
HJSON_ASS_IMPL_B(unsigned short)
HJSON_ASS_IMPL_B(int)
HJSON_ASS_IMPL_B(unsigned int)
HJSON_ASS_IMPL_B(long)
HJSON_ASS_IMPL_B(unsigned long)
HJSON_ASS_IMPL_B(long long)
HJSON_ASS_IMPL_B(unsigned long long)

Value& Value::operator+=(const char *b) {
  return operator+=(std::string(b));
}

Value& Value::operator+=(const std::string& b) {
  if (prv->type != Type::String) {
    throw type_mismatch("The value must be of type String for this operation.");
  }

  *prv->s += b;

  return *this;
}

Value& Value::operator+=(const Value& b) {
  if (prv->type == Type::Double && b.prv->type == Type::Int64) {
    prv->d += b.prv->i;
  } else if (prv->type == Type::Int64 && b.prv->type == Type::Double) {
    prv->i += static_cast<int64_t>(b.prv->d);
  } else {
    if (prv->type != b.prv->type) {
      throw type_mismatch("The values must be of the same type for this operation.");
    }

    switch (prv->type) {
    case Type::Double:
      prv->d += b.prv->d;
      break;
    case Type::Int64:
      prv->i += b.prv->i;
      break;
    case Type::String:
      *prv->s += *b.prv->s;
      break;
    default:
      throw type_mismatch("The values must be of type Double, Int64 or String for this operation.");
      break;
    }
  }

  return *this;
}

Value& Value::operator-=(const Value& b) {
  operator +=(-b);

  return *this;
}

Value& Value::operator*=(const Value& b) {
  if (prv->type == Type::Double && b.prv->type == Type::Int64) {
    prv->d *= b.prv->i;
  } else if (prv->type == Type::Int64 && b.prv->type == Type::Double) {
    prv->i = static_cast<int64_t>(prv->i * b.prv->d);
  } else {
    if (prv->type != b.prv->type) {
      throw type_mismatch("The values must be of the same type for this operation.");
    }

    switch (prv->type) {
    case Type::Double:
      prv->d *= b.prv->d;
      break;
    case Type::Int64:
      prv->i *= b.prv->i;
      break;
    default:
      throw type_mismatch("The values must be of type Double or Int64 for this operation.");
      break;
    }
  }

  return *this;
}

Value& Value::operator/=(const Value& b) {
  if (prv->type == Type::Double && b.prv->type == Type::Int64) {
    prv->d /= b.prv->i;
  } else if (prv->type == Type::Int64 && b.prv->type == Type::Double) {
    prv->i = static_cast<int64_t>(prv->i / b.prv->d);
  } else {
    if (prv->type != b.prv->type) {
      throw type_mismatch("The values must be of the same type for this operation.");
    }

    switch (prv->type) {
    case Type::Double:
      prv->d /= b.prv->d;
      break;
    case Type::Int64:
      prv->i /= b.prv->i;
      break;
    default:
      throw type_mismatch("The values must be of type Double or Int64 for this operation.");
      break;
    }
  }

  return *this;
}

Value& Value::operator%=(const Value& b) {
  if (prv->type != b.prv->type || prv->type != Type::Int64) {
    throw type_mismatch("The values must be of the Int64 type for this operation.");
  }

  prv->i %= b.prv->i;

  return *this;
}

Value Value::operator+() const {
  switch (prv->type) {
  case Type::Double:
    return prv->d;
  case Type::Int64:
    return prv->i;
  default:
    throw type_mismatch("The value must be of type Double or Int64 for this operation.");
    break;
  }

  return *this;
}

Value Value::operator-() const {
  switch (prv->type) {
  case Type::Double:
    return -prv->d;
  case Type::Int64:
    return -prv->i;
  default:
    throw type_mismatch("The value must be of type Double or Int64 for this operation.");
    break;
  }

  return *this;
}

Value& Value::operator++() {
  switch (prv->type) {
  case Type::Double:
    prv->d++;
    break;
  case Type::Int64:
    prv->i++;
    break;
  default:
    throw type_mismatch("The values must be of type Double or Int64 for this operation.");
    break;
  }

  return *this;
}

Value& Value::operator--() {
  switch (prv->type) {
  case Type::Double:
    prv->d--;
    break;
  case Type::Int64:
    prv->i--;
    break;
  default:
    throw type_mismatch("The values must be of type Double or Int64 for this operation.");
    break;
  }

  return *this;
}

Value Value::operator++(int) {
  Value ret;

  switch (prv->type) {
  case Type::Double:
    ret = prv->d;
    prv->d++;
    break;
  case Type::Int64:
    ret = prv->i;
    prv->i++;
    break;
  default:
    throw type_mismatch("The values must be of type Double or Int64 for this operation.");
    break;
  }

  return ret;
}

Value Value::operator--(int) {
  Value ret;

  switch (prv->type) {
  case Type::Double:
    ret = prv->d;
    prv->d--;
    break;
  case Type::Int64:
    ret = prv->i;
    prv->i--;
    break;
  default:
    throw type_mismatch("The values must be of type Double or Int64 for this operation.");
    break;
  }

  return ret;
}

Value::operator bool() const {
  switch (prv->type)
  {
  case Type::Double:
    return !!prv->d;
  case Type::Int64:
    return !!prv->i;
  case Type::Bool:
    return prv->b;
  default:
    break;
  }

  return !empty();
}

Value::operator float() const {
  return static_cast<float>(operator double());
}

Value::operator double() const {
  switch (prv->type)
  {
  case Type::Double:
    return prv->d;
  case Type::Int64:
    return static_cast<double>(prv->i);
  default:
    break;
  }

  throw type_mismatch("Must be of type Double or Int64 for that operation.");

  return 0.0;
}

Value::operator long double() const {
  return static_cast<long double>(operator double());
}

#define HJSON_CONV_INT_IMPL(_T) \
Value::operator _T() const { \
  return static_cast<_T>(operator long long()); \
}

HJSON_CONV_INT_IMPL(char)
HJSON_CONV_INT_IMPL(unsigned char)
HJSON_CONV_INT_IMPL(short)
HJSON_CONV_INT_IMPL(unsigned short)
HJSON_CONV_INT_IMPL(int)
HJSON_CONV_INT_IMPL(unsigned int)
HJSON_CONV_INT_IMPL(long)
HJSON_CONV_INT_IMPL(unsigned long)
HJSON_CONV_INT_IMPL(unsigned long long)

Value::operator long long() const {
  switch (prv->type)
  {
  case Type::Double:
    return static_cast<long long>(prv->d);
  case Type::Int64:
    return prv->i;
  default:
    break;
  }

  throw type_mismatch("Must be of type Double or Int64 for that operation.");

  return 0;
}

Value::operator const char*() const {
  if (prv->type != Type::String) {
    throw type_mismatch("Must be of type String for that operation.");
  }

  return prv->s->c_str();
}

Value::operator std::string() const {
  if (prv->type != Type::String) {
    throw type_mismatch("Must be of type String for that operation.");
  }

  return *prv->s;
}

bool Value::defined() const {
  return prv->type != Type::Undefined;
}

bool Value::empty() const {
  return (prv->type == Type::Undefined ||
    prv->type == Type::Null ||
    (prv->type == Type::String && prv->s->empty()) ||
    (prv->type == Type::Vector && prv->v->empty()) ||
    (prv->type == Type::Map && prv->m->m.empty()));
}

Type Value::type() const {
  return prv->type;
}

bool Value::is_container() const {
  return prv->type == Type::Vector || prv->type == Type::Map;
}

bool Value::is_numeric() const {
  return prv->type == Type::Double || prv->type == Type::Int64;
}

size_t Value::size() const {
  switch (prv->type)
  {
  case Type::Vector:
    return prv->v->size();
  case Type::Map:
    return prv->m->m.size();
  default:
    break;
  }

  return 0;
}

bool Value::deep_equal(const Value& other) const {
  if (*this == other) {
    return true;
  }

  if (this->type() != other.type() || this->size() != other.size()) {
    return false;
  }

  switch (prv->type)
  {
  case Type::Vector:
    {
      auto itA = this->prv->v->begin();
      auto endA = this->prv->v->end();
      auto itB = other.prv->v->begin();
      while (itA != endA) {
        if (!itA->deep_equal(*itB)) {
          return false;
        }
        ++itA;
        ++itB;
      }
    }
    return true;

  case Type::Map:
    {
      auto itA = this->begin(), endA = this->end(), itB = other.begin();
      while (itA != endA) {
        if (!itA->second.deep_equal(itB->second)) {
          return false;
        }
        ++itA;
        ++itB;
      }
    }
    return true;

  default:
    break;
  }

  return false;
}

Value Value::clone() const {
  switch (prv->type) {
  case Type::Vector:
    {
      Value ret;
      for (int index = 0; index < int(size()); ++index) {
        ret.push_back(operator[](index).clone());
      }
      ret.set_comments(*this);
      return ret;
    }

  case Type::Map:
    {
      Value ret;
      for (int index = 0; index < size(); ++index) {
        ret[key(index)] = operator[](index).clone();
      }
      ret.set_comments(*this);
      return ret;
    }

  default:
    break;
  }

  return *this;
}

void Value::clear() {
  switch (prv->type) {
  case Type::Vector:
    prv->v->clear();
    break;

  case Type::Map:
    prv->m->m.clear();
    prv->m->v.clear();
    break;

  default:
    break;
  }
}

void Value::erase(int index) {
  switch (prv->type)
  {
  case Type::Undefined:
  case Type::Vector:
  case Type::Map:
    if (index < 0 || index >= size()) {
      throw index_out_of_bounds("Index out of bounds.");
    }

    switch (prv->type)
    {
    case Type::Vector:
      {
        prv->v->erase(prv->v->begin() + index);
      }
      break;
    case Type::Map:
      {
        prv->m->m.erase(prv->m->v[index]);
        prv->m->v.erase(prv->m->v.begin() + index);
      }
      break;
    default:
      break;
    }
    break;

  default:
    throw type_mismatch("Must be of type Vector or Map for that operation.");
  }
}

void Value::push_back(const Value& other) {
  if (prv->type == Type::Undefined) {
    prv->~ValueImpl();
    // Recreate the private object using the same memory block.
    new(&(*prv)) ValueImpl(Type::Vector);
  } else if (prv->type != Type::Vector) {
    throw type_mismatch("Must be of type Undefined or Vector for that operation.");
  }

  prv->v->push_back(other);
}

void Value::move(int from, int to) {
  switch (prv->type)
  {
  case Type::Undefined:
  case Type::Vector:
  case Type::Map:
    if (from < 0 || to < 0 || from >= size() || to > size()) {
      throw index_out_of_bounds("Index out of bounds.");
    }

    if (from == to) {
      return;
    }

    switch (prv->type)
    {
    case Type::Vector:
      {
        auto it = prv->v->begin();

        prv->v->insert(it + to, it[from]);
        if (to < from) {
          ++from;
        }
        prv->v->erase(prv->v->begin() + from);
      }
      break;
    case Type::Map:
      {
        auto vec = &prv->m->v;
        auto it = vec->begin();

        vec->insert(it + to, it[from]);
        if (to < from) {
          ++from;
        }
        vec->erase(vec->begin() + from);
      }
      break;
    default:
      break;
    }
    break;

  default:
    throw type_mismatch("Must be of type Vector or Map for that operation.");
  }
}

std::string Value::key(int index) const {
  switch (prv->type)
  {
  case Type::Undefined:
  case Type::Map:
    if (index < 0 || index >= size()) {
      throw index_out_of_bounds("Index out of bounds.");
    }
    return prv->m->v[index];
  default:
    throw type_mismatch("Must be of type Map for that operation.");
  }
}

ValueMap::iterator Value::begin() {
  if (prv->type != Type::Map) {
    // Some C++ compilers might not allow comparing this to another
    // default-constructed iterator.
    return ValueMap::iterator();
  }

  return prv->m->m.begin();
}

ValueMap::iterator Value::end() {
  if (prv->type != Type::Map) {
    // Some C++ compilers might not allow comparing this to another
    // default-constructed iterator.
    return ValueMap::iterator();
  }

  return prv->m->m.end();
}

ValueMap::const_iterator Value::begin() const {
  if (prv->type != Type::Map) {
    // Some C++ compilers might not allow comparing this to another
    // default-constructed iterator.
    return ValueMap::const_iterator();
  }

  return prv->m->m.begin();
}

ValueMap::const_iterator Value::end() const {
  if (prv->type != Type::Map) {
    // Some C++ compilers might not allow comparing this to another
    // default-constructed iterator.
    return ValueMap::const_iterator();
  }

  return prv->m->m.end();
}

size_t Value::erase(const std::string &key) {
  if (prv->type == Type::Undefined) {
    return 0;
  } else if (prv->type != Type::Map) {
    throw type_mismatch("Must be of type Map for that operation.");
  }

  size_t ret = prv->m->m.erase(key);

  if (ret > 0) {
    auto v = &prv->m->v;
    auto it = std::find(v->begin(), v->end(), key);
    if (it == v->end()) {
      assert(!"Value found in map but not in vector");
    } else {
      v->erase(it);
    }
  }

  return ret;
}

size_t Value::erase(const char *key) {
  return erase(std::string(key));
}

double Value::to_double() const {
  switch (prv->type) {
  case Type::Undefined:
  case Type::Null:
    return 0.0;
  case Type::Bool:
    return (prv->b ? 1.0 : 0.0);
  case Type::Double:
    return prv->d;
  case Type::Int64:
    return static_cast<double>(prv->i);
  case Type::String:
    {
      double ret;

#if HJSON_USE_CHARCONV
      const char *pCh = prv->s->c_str();
      const char *pEnd = pCh + prv->s->size();

      auto res = std::from_chars(pCh, pEnd, ret);

      if (res.ptr != pEnd || res.ec == std::errc::result_out_of_range) {
#elif HJSON_USE_STRTOD
      const char *pCh = prv->s->c_str();
      char *endptr;
      errno = 0;

      ret = std::strtod(pCh, &endptr);

      if (errno || endptr - pCh != prv->s->size()) {
#else
      std::stringstream ss(*prv->s);

      // Make sure we expect dot (not comma) as decimal point.
      ss.imbue(std::locale::classic());

      ss >> ret;

      if (!ss.eof() || ss.fail()) {
#endif
        return 0.0;
      }

      return ret;
    }
  default:
    break;
  }

  throw type_mismatch("Illegal type for this operation.");
}

std::int64_t Value::to_int64() const {
  switch (prv->type) {
  case Type::Undefined:
  case Type::Null:
    return 0;
  case Type::Bool:
    return (prv->b ? 1 : 0);
  case Type::Double:
    return static_cast<std::int64_t>(prv->d);
  case Type::Int64:
    return prv->i;
  case Type::String:
    {
      std::int64_t ret;

#if HJSON_USE_CHARCONV
      const char *pCh = prv->s->c_str();
      const char *pEnd = pCh + prv->s->size();

      auto res = std::from_chars(pCh, pEnd, ret);

      if (res.ptr != pEnd || res.ec == std::errc::result_out_of_range) {
#elif HJSON_USE_STRTOD
      const char *pCh = prv->s->c_str();
      char *endptr;
      errno = 0;

      ret = std::strtoll(pCh, &endptr, 0);

      if (errno || endptr - pCh != prv->s->size()) {
#else
      std::stringstream ss(*prv->s);

      // Avoid localization surprises.
      ss.imbue(std::locale::classic());

      ss >> ret;

      if (!ss.eof() || ss.fail()) {
#endif
        // Perhaps the string contains a decimal point or exponential part.
        return static_cast<std::int64_t>(to_double());
      }

      return ret;
    }
  default:
    break;
  }

  throw type_mismatch("Illegal type for this operation.");
}

std::string Value::to_string() const {
  switch (prv->type) {
  case Type::Undefined:
    return "";
  case Type::Null:
    return "null";
  case Type::Bool:
    return (prv->b ? "true" : "false");
  case Type::Double:
    {
#if HJSON_USE_CHARCONV
      std::array<char, 32> buf;

      auto res = std::to_chars(buf.data(), buf.data() + buf.size(), prv->d);

      if (res.ptr - buf.data() >= buf.size() || res.ec != std::errc()) {
        return "";
      }

      // to_chars() does not set a zero termination, which is needed by strchr().
      *res.ptr = '\0';

      // Always output a decimal point.
      if (strchr(buf.data(), '.') == nullptr) {
        if (res.ptr - buf.data() >= buf.size() - 1) {
          return "";
        }
        *(res.ptr++) = '.';
        *(res.ptr++) = '0';
      }

      return std::string(buf.data(), res.ptr);
#elif HJSON_USE_STRTOD
      char buf[32];
      int nChars = snprintf(buf, sizeof(buf), "%.15g", prv->d);

      if (nChars < 0 || nChars >= static_cast<int>(sizeof(buf))) {
        return "";
      }

      // Always output a decimal point.
      if (strchr(buf, '.') == nullptr) {
        if (nChars >= static_cast<int>(sizeof(buf)) - 1) {
          return "";
        }
        buf[nChars++] = '.';
        buf[nChars++] = '0';
      }

      return std::string(buf, nChars);
#else
      std::ostringstream oss;

      // Make sure we use dot (not comma) as decimal point.
      oss.imbue(std::locale::classic());
      oss.precision(15);

      oss << prv->d;

      // Always output a decimal point. Done like this to avoid printing more
      // decimals than needed, which would be the result of using
      // std::ios::showpoint.
      if (oss.str().find_first_of('.', 0) == std::string::npos) {
        oss << ".0";
      }

      return oss.str();
#endif
    }
  case Type::Int64:
    {
#if HJSON_USE_CHARCONV
      std::array<char, 32> buf;

      auto res = std::to_chars(buf.data(), buf.data() + buf.size(), prv->i);

      if (res.ec != std::errc()) {
        return "";
      }

      return std::string(buf.data(), res.ptr);
#elif HJSON_USE_STRTOD
      return std::to_string(prv->i);
#else
      std::ostringstream oss;

      // Avoid localization surprises.
      oss.imbue(std::locale::classic());

      oss << prv->i;

      return oss.str();
#endif
    }
  case Type::String:
    return *prv->s;
  default:
    break;
  }

  throw type_mismatch("Illegal type for this operation.");
}

void Value::set_comment_before(const std::string& str) {
  if (!cm) {
    if (str.empty()) {
      return;
    }
    cm.reset(new Comments());
  }

  cm->m_commentBefore = str;
}

std::string Value::get_comment_before() const {
  if (cm) {
    return cm->m_commentBefore;
  }

  return "";
}

void Value::set_comment_key(const std::string& str) {
  if (!cm) {
    if (str.empty()) {
      return;
    }
    cm.reset(new Comments());
  }

  cm->m_commentKey = str;
}

std::string Value::get_comment_key() const {
  if (cm) {
    return cm->m_commentKey;
  }

  return "";
}

void Value::set_comment_inside(const std::string& str) {
  if (!cm) {
    if (str.empty()) {
      return;
    }
    cm.reset(new Comments());
  }

  cm->m_commentInside = str;
}

std::string Value::get_comment_inside() const {
  if (cm) {
    return cm->m_commentInside;
  }

  return "";
}

void Value::set_comment_after(const std::string& str) {
  if (!cm) {
    if (str.empty()) {
      return;
    }
    cm.reset(new Comments());
  }

  cm->m_commentAfter = str;
}

std::string Value::get_comment_after() const {
  if (cm) {
    return cm->m_commentAfter;
  }

  return "";
}

void Value::set_comments(const Value& other) {
  if (other.cm) {
    if (!cm) {
      cm.reset(new Comments());
    }

    *cm = *other.cm;
  } else {
    clear_comments();
  }
}

void Value::clear_comments() {
  cm.reset();
}

Value& Value::assign_with_comments(const Value& other) {
  // If this object is of type Undefined set_comments() will be called in the
  // assignment operator, no need to call it here.
  if (defined()) {
    set_comments(other);
  }
  return operator=(other);
}

Value& Value::assign_with_comments(Value&& other) {
  // If this object is of type Undefined set_comments() will be called in the
  // assignment operator, no need to call it here.
  if (defined()) {
    cm = other.cm;
  }
  return operator=(std::move(other));
}

MapProxy::MapProxy(std::shared_ptr<ValueImpl> _parent, const std::string &_key,
  Value *_pTarget)
  : Value(_pTarget ? _pTarget->prv : std::make_shared<ValueImpl>(Type::Undefined),
      _pTarget ? _pTarget->cm : 0),
    parentPrv(_parent),
    key(_key),
    pTarget(_pTarget),
    wasAssigned(false)
{
}

MapProxy::MapProxy(Value&& other)
  : Value(std::move(other))
{
}

MapProxy::~MapProxy() {
  if (wasAssigned || !empty()) {
    if (pTarget) {
      // Can have changed due to assignment.
      pTarget->prv = this->prv;
      // In case cm was 0 but now has been created by a call to set_comment_x.
      pTarget->cm = this->cm;
    } else {
      // If the key is new we must add it to the order vector also.
      parentPrv->m->v.push_back(key);

      // We waited until now because we don't want to insert a Value object of
      // type Undefined into the parent map, unless such an object was explicitly
      // assigned (e.g. `val["key"] = Hjson::Value()`).
      // Without this requirement, checking for the existence of an element
      // would create an Undefined element for that key if it didn't already exist
      // (e.g. `if (val["key"] == 1) {` would create an element for "key").
      parentPrv->m->m.emplace(key, Value(this->prv, this->cm));
    }
  }
}

MapProxy& MapProxy::operator =(const MapProxy &other) {
  return operator=(static_cast<Value>(other));
}

MapProxy& MapProxy::operator =(const Value& other) {
  Value::operator=(other);
  wasAssigned = true;
  return *this;
}

MapProxy& MapProxy::operator =(Value&& other) {
  Value::operator=(std::move(other));
  wasAssigned = true;
  return *this;
}

MapProxy& MapProxy::assign_with_comments(const MapProxy& other) {
  return assign_with_comments(static_cast<Value>(other));
}

MapProxy& MapProxy::assign_with_comments(const Value& other) {
  // If this object is of type Undefined set_comments() will be called in the
  // assignment operator, no need to call it here.
  if (defined()) {
    set_comments(other);
  }
  return operator=(other);
}

MapProxy& MapProxy::assign_with_comments(Value&& other) {
  // If this object is of type Undefined set_comments() will be called in the
  // assignment operator, no need to call it here.
  if (defined()) {
    cm = other.cm;
  }
  return operator=(std::move(other));
}

Value Merge(const Value& base, const Value& ext) {
  Value merged;

  if (!ext.defined()) {
    merged = base.clone();
  } else if (base.type() == Type::Map && ext.type() == Type::Map) {
    for (int index = 0; index < ext.size(); ++index) {
      if (base[ext.key(index)].defined()) {
        merged[ext.key(index)] = Merge(base[ext.key(index)], ext[index]);
      } else {
        merged[ext.key(index)] = ext[index].clone();
      }
    }

    for (int index = 0; index < base.size(); ++index) {
      if (!merged[base.key(index)].defined()) {
        merged[base.key(index)] = base[index].clone();
      }
    }

    merged.set_comments(ext);
  } else {
    merged = ext.clone();
  }

  return merged;
}

}


text:
START_ATF_NAMESPACE
    namespace ATL
    {
        #pragma pack(push, 8)
        struct CCritSecLock
        {
            _RTL_CRITICAL_SECTION *m_cs;
            bool m_bLocked;
        };
        #pragma pack(pop)
    }; // end namespace ATL
END_ATF_NAMESPACE


text:
begin
  require "vagrant"
rescue LoadError
  raise "The Vagrant Brightbox plugin must be run within Vagrant."
end

# This is a sanity check to make sure no one is attempting to install
# this into an early Vagrant version.
if Vagrant::VERSION < "1.2.0"
  raise "The Vagrant Brightbox plugin is only compatible with Vagrant 1.2+"
end

module VagrantPlugins
  module Brightbox
    class Plugin < Vagrant.plugin("2")
      name "Brightbox"
      description <<-DESC
      This plugin installs a provider that allows Vagrant to manage
      servers in the Brightbox Cloud
      DESC

      config(:brightbox, :provider) do
        require_relative "config"
        Config
      end

      provider(:brightbox, parallel: true) do
        # Setup logging and i18n
        setup_logging
        setup_i18n

        # Return the provider
        require_relative "provider"
        Provider
      end

      # This initializes the internationalization strings.
      def self.setup_i18n
        I18n.load_path << File.expand_path("locales/en.yml", Brightbox.source_root)
        I18n.reload!
      end

      # This sets up our log level to be whatever VAGRANT_LOG is.
      def self.setup_logging
        require "log4r"

        level = nil
        begin
          level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
        rescue NameError
          # This means that the logging constant wasn't found,
          # which is fine. We just keep `level` as `nil`. But
          # we tell the user.
          level = nil
        end

        # Some constants, such as "true" resolve to booleans, so the
        # above error checking doesn't catch it. This will check to make
        # sure that the log level is an integer, as Log4r requires.
        level = nil if !level.is_a?(Integer)

        # Set the logging level on all "vagrant" namespaced
        # logs as long as we have a valid level.
        if level
          logger = Log4r::Logger.new("vagrant_brightbox")
          logger.outputters = Log4r::Outputter.stderr
          logger.level = level
          logger = nil
        end
      end
    end
  end
end


text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2013.08.22 at 04:46:40 PM EST
//

package au.com.sixtree.mule.modules.xero.xsd;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for ReportCell complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="ReportCell">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="Value" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         <element name="Attributes" type="{}ReportCellAttributes" minOccurs="0"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ReportCell", propOrder = {
    "value",
    "attributes"
})
public class ReportCell {

    @XmlElement(name = "Value", required = true)
    protected String value;
    @XmlElement(name = "Attributes")
    protected ReportCellAttributes attributes;

    /**
     * Gets the value of the value property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getValue() {
        return value;
    }

    /**
     * Sets the value of the value property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setValue(String value) {
        this.value = value;
    }

    /**
     * Gets the value of the attributes property.
     *
     * @return
     *     possible object is
     *     {@link ReportCellAttributes }
     *
     */
    public ReportCellAttributes getAttributes() {
        return attributes;
    }

    /**
     * Sets the value of the attributes property.
     *
     * @param value
     *     allowed object is
     *     {@link ReportCellAttributes }
     *
     */
    public void setAttributes(ReportCellAttributes value) {
        this.attributes = value;
    }

}


text:
package consul

import (
	"context"
	"log"
	"sync"

	"github.com/hashicorp/consul/agent/consul/autopilot"
	"github.com/hashicorp/consul/agent/metadata"
	"github.com/hashicorp/consul/agent/pool"
	"github.com/hashicorp/serf/serf"
)

// StatsFetcher has two functions for autopilot. First, lets us fetch all the
// stats in parallel so we are taking a sample as close to the same time as
// possible, since we are comparing time-sensitive info for the health check.
// Second, it bounds the time so that one slow RPC can't hold up the health
// check loop; as a side effect of how it implements this, it also limits to
// a single in-flight RPC to any given server, so goroutines don't accumulate
// as we run the health check fairly frequently.
type StatsFetcher struct {
	logger       *log.Logger
	pool         *pool.ConnPool
	datacenter   string
	inflight     map[string]struct{}
	inflightLock sync.Mutex
}

// NewStatsFetcher returns a stats fetcher.
func NewStatsFetcher(logger *log.Logger, pool *pool.ConnPool, datacenter string) *StatsFetcher {
	return &StatsFetcher{
		logger:     logger,
		pool:       pool,
		datacenter: datacenter,
		inflight:   make(map[string]struct{}),
	}
}

// fetch does the RPC to fetch the server stats from a single server. We don't
// cancel this when the context is canceled because we only want one in-flight
// RPC to each server, so we let it finish and then clean up the in-flight
// tracking.
func (f *StatsFetcher) fetch(server *metadata.Server, replyCh chan *autopilot.ServerStats) {
	var args struct{}
	var reply autopilot.ServerStats
	err := f.pool.RPC(f.datacenter, server.Addr, server.Version, "Status.RaftStats", server.UseTLS, &args, &reply)
	if err != nil {
		f.logger.Printf("[WARN] consul: error getting server health from %q: %v",
			server.Name, err)
	} else {
		replyCh <- &reply
	}

	f.inflightLock.Lock()
	delete(f.inflight, server.ID)
	f.inflightLock.Unlock()
}

// Fetch will attempt to query all the servers in parallel.
func (f *StatsFetcher) Fetch(ctx context.Context, members []serf.Member) map[string]*autopilot.ServerStats {
	type workItem struct {
		server  *metadata.Server
		replyCh chan *autopilot.ServerStats
	}
	var servers []*metadata.Server
	for _, s := range members {
		if ok, parts := metadata.IsConsulServer(s); ok {
			servers = append(servers, parts)
		}
	}

	// Skip any servers that have inflight requests.
	var work []*workItem
	f.inflightLock.Lock()
	for _, server := range servers {
		if _, ok := f.inflight[server.ID]; ok {
			f.logger.Printf("[WARN] consul: error getting server health from %q: last request still outstanding",
				server.Name)
		} else {
			workItem := &workItem{
				server:  server,
				replyCh: make(chan *autopilot.ServerStats, 1),
			}
			work = append(work, workItem)
			f.inflight[server.ID] = struct{}{}
			go f.fetch(workItem.server, workItem.replyCh)
		}
	}
	f.inflightLock.Unlock()

	// Now wait for the results to come in, or for the context to be
	// canceled.
	replies := make(map[string]*autopilot.ServerStats)
	for _, workItem := range work {
		select {
		case reply := <-workItem.replyCh:
			replies[workItem.server.ID] = reply

		case <-ctx.Done():
			f.logger.Printf("[WARN] consul: error getting server health from %q: %v",
				workItem.server.Name, ctx.Err())
		}
	}
	return replies
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Shopify SDK for Unity: Shopify.UIToolkit.Editor.ProductPickerView Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="search/search.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />

Shopify SDK for Unity

Shopify

UIToolkit

Editor

ProductPickerView

Public Member Functions |
List of all members

Shopify.UIToolkit.Editor.ProductPickerView Class Reference

Inheritance diagram for Shopify.UIToolkit.Editor.ProductPickerView:

  <map id="Shopify.UIToolkit.Editor.ProductPickerView_map" name="Shopify.UIToolkit.Editor.ProductPickerView_map">
<area href="interface_shopify_1_1_u_i_toolkit_1_1_editor_1_1_i_product_picker_view.html" alt="Shopify.UIToolkit.Editor.IProductPickerView" shape="rect" coords="0,0,258,24"/>
  </map>

Public Member Functions

 	ProductPickerView (IProductPickerController controller)

void 	DrawProductLoadingState (SerializedObject serializedObject)

void 	DrawProductLoadingError (SerializedObject serializedObject)

void 	DrawShopHasNoProductsState (SerializedObject serializedObject)

void 	DrawProductPicker (SerializedObject serializedObject, Dictionary< string, string > productNameToGIDMap)

The documentation for this class was generated from the following file:

Assets/Shopify/UIToolkit/Editor/ProductPicker.cs

<address class="footer">

</address>


text:
Lumia Imaging SDK projects
==========================

### Contents
- [1. Quick start](#quickstart)
- [2. Sample projects](#samples)
- [3. Lumia Imaging SDK Extras](#extras)
 - [3.1. Philosophy](#philosophy)
 - [3.2. Managed (C#/.NET)](#managed)
 - [3.2.1 Layer system](#layers)
 - [3.2.2 Image sources/effects](#sources)
 - [3.2.3 Utility code](#utility)
- [4. Reference](#reference)

## 1. Quick start

Quick Start is a sample project accompanying the tutorial that helps to get your first app that utilizes the Lumia Imaging SDK up and running. This sample implements the following basic tasks: picking an image from the camera roll, applying an effect to it, and processing the filtered image to be rendered and saved as a full resolution JPEG.

  Quick Starts

  Quick Start (C#) for Windows 10 and Windows 10 Mobile

  Quick Start (Visual Basic) for Windows 10 and Windows 10 Mobile

  Quick Start for Windows Phone 10 HTML5/JScript

  Quick Start for Windows 8.1 and Windows Phone 8.1

## 2. Sample projects

  Samples

  Edit Showcase
  Edit Showcase is an example app that demonstrates the use of effects on still images. The photo is processed with the predefined effects. In addition, custom controls are implemented for manipulating the effect properties in real time. The processed image can be saved in the JPEG format into the camera roll.

  Video Effect
  Video Effect sample is an example app that demonstrates the capabilities and performance of the Lumia Imaging SDK by allowing the user to preview and apply a number of real-time effects to camera preview. The effects are applied to the stream received from the camera and shown in the viewfinder. The effects can be changed using the buttons in the application bar. This example app supports recording and capturing of videos and photos.

  Lumia Imaging SDK and Win2D Demo
  Lumia Imaging SDK and Win2D Demo is an example app that demonstrates the use of the Lumia Imaging SDK together with the Win2D API.

  Image Sequencer
  Image Sequencer is an example app that demonstrates the use of the Image Aligner and GIF Renderer APIs for creating Cinemagraph-style animations in the animated GIF format. There are also some example image sequences that can be used as a basis for the alignment and animation.

  Custom Effect Sample
  Custom Effect sample demonstrates  how to create Custom Effects to do image manipulation both on the CPU and the GPU.

## 3. Lumia Imaging SDK Extras

This repository contains extra functionality and sample code for the Lumia Imaging SDK.

The code is provided under the MIT license, and can therefore be conveniently used and modified.

Parts contained will typically target the latest release version of the Lumia Imaging SDK, unless otherwise marked.

### 3.1 Philosophy

- The **projects** (.csproj, .vcxproj etc) collect various classes/features, but are mainly for sample and testing purposes.
- This repository should be considered as a *set of individual classes*, not as a library.
- New revisions may not be compatible with old ones.
- Therefore, if you find something useful, it may be easier to *isolate the part you want* instead of taking a dependency on all the projects included.

### 3.2 Managed (C#/.NET)

#### 3.2.1 Layer system
    Managed/Lumia.Imaging.Extras.Layers/

Allows to describe image processing as a list of layers, like the familiar representation found in photo editing apps.

After configuring the layers, an IImageProvider endpoint can be easily retrieved and rendered.

**Features**
- Layers and Adjustment Layers
- Layer styles (blend function, opacity, transparency mask, scaling/translation)
- Tuned for performance and low GC pressure in interactive scenarios.
- Flexible, construction of actual objects can be deferred etc.

#### 3.2.2 Image sources/effects
    Managed/Lumia.Imaging.Extras.ImageProviders/

**NoiseImageSource**
A noise generator image source. Internally uses a ColorImageSource and a NoiseFilter.

**HighpassEffect**
A "highpass" effect, similar to familiar ones in photo editing apps.

**DepthofField**
A set of high-level scenarios showing how to set up a "DoF" effect.

**HslAdjustmentEffect**
Example of an effect that does higher level HSL adjustments, similar to familiar ones in photo editing apps.
Allows adjustments of saturation and lightness around Master, Red, Green, Blue, Cyan, Magenta and Yellow channels.

#### 3.2.3 Utility code
    Managed/Lumia.Imaging.Extras.Utility/

**ImageProviderExtensions**
- **GetBitmapAsync** overloads that help to reuse bitmaps.
- **Rotate** method, making it convenient to rotate an image provider.

**BitmapExtensions**
- **CopyTo**/**ToWriteableBitmap**: Conversions to WriteableBitmap. These help in interactive scenarios, and can be useful for keeping work off the UI thread.

**BufferExtensions**
- **AsBufferTask**: Conversion from Task<IBuffer> to a Lumia Imaging SDK IBufferProvider that can be passed into a BufferProviderImageSource. This can be useful to avoid having to await the task-of-buffer before setting up an image source.

**MaybeTask<T>**
Value type that either holds a result **or** a task-of-result. This helps interactive app scenarios, keeping GC activity in check when dealing with mixed sync/async operations, as otherwise each new Task causes a heap allocation.

### 4. Reference

[Lumia Imaging SDK](http://go.microsoft.com/fwlink/?LinkID=521939)


text:
/* libjpeg-turbo build number */
#define BUILD  ""

/* Compiler's inline keyword */
#undef inline

/* How to obtain function inlining. */
#ifndef INLINE
#if defined(__GNUC__)
#define INLINE  inline __attribute__((always_inline))
#elif defined(_MSC_VER)
#define INLINE  __forceinline
#else
#define INLINE
#endif
#endif

#if !defined(STARBOARD)
/* How to obtain thread-local storage */
#if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
#define THREAD_LOCAL  __declspec(thread)
#else
#define THREAD_LOCAL  __thread
#endif
#endif

/* Define to the full name of this package. */
#define PACKAGE_NAME  "libjpeg-turbo"

/* Version number of package */
#define VERSION  "2.1.4"

/* The size of `size_t', as computed by sizeof. */
#include <stdint.h>
#if __WORDSIZE==64 || defined(_WIN64)
#define SIZEOF_SIZE_T  8
#else
#define SIZEOF_SIZE_T  4
#endif

/* Define if your compiler has __builtin_ctzl() and sizeof(unsigned long) == sizeof(size_t). */
#if defined(__GNUC__)
#define HAVE_BUILTIN_CTZL
#endif

#if !defined(STARBOARD)
/* Define to 1 if you have the <intrin.h> header file. */
#if defined(_MSC_VER)
#define HAVE_INTRIN_H  1
#endif
#endif

#if defined(_MSC_VER) && defined(HAVE_INTRIN_H)
#if (SIZEOF_SIZE_T == 8)
#define HAVEBITSCANFORWARD64
#elif (SIZEOF_SIZE_T == 4)
#define HAVEBITSCANFORWARD
#endif
#endif

#if defined(__has_attribute)
#if __has_attribute(fallthrough)
#define FALLTHROUGH __attribute__((fallthrough));
#else
#define FALLTHROUGH
#endif
#else
#define FALLTHROUGH
#endif


text:
package hu.bme.mit.inf.lookaheadmatcher;

import hu.bme.mit.inf.lookaheadmatcher.impl.LookaheadMatching;

import java.util.HashMap;
import java.util.List;

import org.eclipse.incquery.runtime.matchers.psystem.PQuery;
import org.eclipse.incquery.runtime.matchers.psystem.PVariable;

import com.google.common.collect.Multiset;

public interface IPartialPatternCacher
{
	// Get the match count for a partial matching
	int GetMatchCountFromPartial(PQuery resolvingQuery, HashMap<PVariable, Object> partialMatchingWithNullsAndEverything, List<PVariable> variablesInOrder, boolean forceMakeIndexIfNotIndexed);

	// Get the exact matches for a partial matching (eg. when using this constraint as the next step)
	Multiset<LookaheadMatching> GetMatchingsFromPartial(PQuery resolvingQuery, HashMap<PVariable, Object> partialMatchingWithNullsAndEverything, List<PVariable> variablesInOrder, boolean forceMakeIndexIfNotIndexed);
}


text:
module Barrister
  module Sinatra
    VERSION = "0.0.3"
  end
end


text:
#pragma once
#ifndef OGLPLUS_EXT_DSA_MATRIX_1107121519_HPP
#define OGLPLUS_EXT_DSA_MATRIX_1107121519_HPP

#include <oglplus/fwd.hpp>
#include <oglplus/ext/ARB_compatibility/matrix_mode.hpp>

namespace oglplus {

#if OGLPLUS_DOCUMENTATION_ONLY || GL_EXT_direct_state_access

/// Wrapper for direct-state-access compatibility matrix operations
/**
 *  @glextreq{EXT,direct_state_access}
 */
class DSAMatrixEXT
{
private:
	CompatibilityMatrixMode _mode;
public:
	/// The matrix mode enumeration
	typedef CompatibilityMatrixMode Mode;

	/// Constructs a new compatibility DSA matrix
	DSAMatrixEXT(Mode mode)
	 : _mode(mode)
	{ }

	/// Pushes a matrix on the stack
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixPushEXT}
	 */
	DSAMatrixEXT& Push(void)
	{
		OGLPLUS_GLFUNC(MatrixPushEXT)(GLenum(_mode));
		OGLPLUS_VERIFY_SIMPLE(MatrixPushEXT);
		return *this;
	}

	/// Pops a matrix from the stack
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixPopEXT}
	 */
	DSAMatrixEXT& Pop(void)
	{
		OGLPLUS_GLFUNC(MatrixPopEXT)(GLenum(_mode));
		OGLPLUS_VERIFY_SIMPLE(MatrixPopEXT);
		return *this;
	}

	/// Loads an identity matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixLoadIdentityEXT}
	 */
	DSAMatrixEXT& LoadIdentity(void)
	{
		OGLPLUS_GLFUNC(MatrixLoadIdentityEXT)(GLenum(_mode));
		OGLPLUS_VERIFY_SIMPLE(MatrixLoadIdentityEXT);
		return *this;
	}

	/// Loads the specified @p matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixLoadTransposeEXT}
	 */
	DSAMatrixEXT& Load(const Matrix<GLfloat, 4, 4>& matrix)
	{
		OGLPLUS_GLFUNC(MatrixLoadTransposefEXT)(
			GLenum(_mode),
			Data(matrix)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixLoadTransposefEXT);
		return *this;
	}

	/// Loads the specified @p matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixLoadTransposeEXT}
	 */
	DSAMatrixEXT& Load(const Matrix<GLdouble, 4, 4>& matrix)
	{
		OGLPLUS_GLFUNC(MatrixLoadTransposedEXT)(
			GLenum(_mode),
			Data(matrix)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixLoadTransposedEXT);
		return *this;
	}

	/// Multiplies the current matrix by the specified @p matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixMultTransposeEXT}
	 */
	DSAMatrixEXT& Mult(const Matrix<GLfloat, 4, 4>& matrix)
	{
		OGLPLUS_GLFUNC(MatrixMultTransposefEXT)(
			GLenum(_mode),
			Data(matrix)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixMultTransposefEXT);
		return *this;
	}

	/// Multiplies the current matrix by the specified @p matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixMultTransposeEXT}
	 */
	DSAMatrixEXT& Mult(const Matrix<GLdouble, 4, 4>& matrix)
	{
		OGLPLUS_GLFUNC(MatrixMultTransposedEXT)(
			GLenum(_mode),
			Data(matrix)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixMultTransposedEXT);
		return *this;
	}

	/// Applies rotation by angle around axis <x,y,z> to the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixRotateEXT}
	 */
	DSAMatrixEXT& Rotate(
		Angle<GLfloat> angle,
		const GLfloat x,
		const GLfloat y,
		const GLfloat z
	)
	{
		OGLPLUS_GLFUNC(MatrixRotatefEXT)(
			GLenum(_mode),
			Degrees(angle),
			x, y, z
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixRotatefEXT);
		return *this;
	}

	/// Applies rotation by angle around axis to the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixRotateEXT}
	 */
	DSAMatrixEXT& Rotate(
		Angle<GLfloat> angle,
		const Vector<GLfloat, 3>& axis
	)
	{
		OGLPLUS_GLFUNC(MatrixRotatefEXT)(
			GLenum(_mode),
			Degrees(angle),
			At(axis, 0),
			At(axis, 1),
			At(axis, 2)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixRotatefEXT);
		return *this;
	}

	/// Applies rotation by angle around axis to the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixRotateEXT}
	 */
	DSAMatrixEXT& Rotate(
		Angle<GLdouble> angle,
		const Vector<GLdouble, 3>& axis
	)
	{
		OGLPLUS_GLFUNC(MatrixRotatedEXT)(
			GLenum(_mode),
			Degrees(angle),
			At(axis, 0),
			At(axis, 1),
			At(axis, 2)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixRotatedEXT);
		return *this;
	}

	/// Scales the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixScaleEXT}
	 */
	DSAMatrixEXT& Scale(const GLfloat x, const GLfloat y, const GLfloat z)
	{
		OGLPLUS_GLFUNC(MatrixScalefEXT)(GLenum(_mode), x, y, z);
		OGLPLUS_VERIFY_SIMPLE(MatrixScalefEXT);
		return *this;
	}

	/// Scales the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixScaleEXT}
	 */
	DSAMatrixEXT& Scale(const Vector<GLfloat, 3>& amount)
	{
		OGLPLUS_GLFUNC(MatrixScalefEXT)(
			GLenum(_mode),
			At(amount, 0),
			At(amount, 1),
			At(amount, 2)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixScalefEXT);
		return *this;
	}

	/// Scales the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixScaleEXT}
	 */
	DSAMatrixEXT& Scale(const Vector<GLdouble, 3>& amount)
	{
		OGLPLUS_GLFUNC(MatrixScalefEXT)(
			GLenum(_mode),
			At(amount, 0),
			At(amount, 1),
			At(amount, 2)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixScaledEXT);
		return *this;
	}

	/// Translates the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixTranslateEXT}
	 */
	DSAMatrixEXT& Translate(
		const GLfloat x,
		const GLfloat y,
		const GLfloat z
	)
	{
		OGLPLUS_GLFUNC(MatrixTranslatefEXT)(GLenum(_mode), x, y, z);
		OGLPLUS_VERIFY_SIMPLE(MatrixTranslatefEXT);
		return *this;
	}

	/// Translates the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixTranslateEXT}
	 */
	DSAMatrixEXT& Translate(const Vector<GLfloat, 3>& amount)
	{
		OGLPLUS_GLFUNC(MatrixTranslatefEXT)(
			GLenum(_mode),
			At(amount, 0),
			At(amount, 1),
			At(amount, 2)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixTranslatefEXT);
		return *this;
	}

	/// Translates the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixTranslateEXT}
	 */
	DSAMatrixEXT& Translate(const Vector<GLdouble, 3>& amount)
	{
		OGLPLUS_GLFUNC(MatrixTranslatefEXT)(
			GLenum(_mode),
			At(amount, 0),
			At(amount, 1),
			At(amount, 2)
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixTranslatedEXT);
		return *this;
	}

	/// Makes an ortho-matrix from the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixOrthoEXT}
	 */
	DSAMatrixEXT& Ortho(
		GLdouble left,
		GLdouble right,
		GLdouble bottom,
		GLdouble top,
		GLdouble near_depth,
		GLdouble far_depth
	)
	{
		OGLPLUS_GLFUNC(MatrixOrthoEXT)(
			GLenum(_mode),
			left,
			right,
			bottom,
			top,
			near_depth,
			far_depth
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixOrthoEXT);
		return *this;
	}

	/// Makes a frustum-matrix from the current matrix
	/**
	 *  @glsymbols
	 *  @glfunref{MatrixFrustumEXT}
	 */
	DSAMatrixEXT& Frustum(
		GLdouble left,
		GLdouble right,
		GLdouble bottom,
		GLdouble top,
		GLdouble near_depth,
		GLdouble far_depth
	)
	{
		OGLPLUS_GLFUNC(MatrixFrustumEXT)(
			GLenum(_mode),
			left,
			right,
			bottom,
			top,
			near_depth,
			far_depth
		);
		OGLPLUS_VERIFY_SIMPLE(MatrixFrustumEXT);
		return *this;
	}
};

/// Wrapper for direct-state-access compatibility modelview matrix operations
class DSAModelviewMatrixEXT
 : public DSAMatrixEXT
{
public:
	DSAModelviewMatrixEXT(void)
	 : DSAMatrixEXT(CompatibilityMatrixMode::Modelview)
	{ }
};

/// Wrapper for direct-state-access compatibility projection matrix operations
class DSAProjectionMatrixEXT
 : public DSAMatrixEXT
{
public:
	DSAProjectionMatrixEXT(void)
	 : DSAMatrixEXT(CompatibilityMatrixMode::Projection)
	{ }
};

#endif // GL_EXT_direct_state_access

} // namespace oglplus

#endif // include guard