text:
#ifndef IBM_TAPE_H
#define IBM_TAPE_H

/* tape device id */
#define IBM_3580    1
#define IBM_3590    2
#define IBM_3592    3

/* changer device id */
#define IBM_3581    7
#define IBM_3582    8
#define IBM_3583    9
#define IBM_3584   10
#define BDT_3581   11
#define IBM_3576   12
#define IBM_3573   13
#define IBM_3577   14
#define IBM_3572   15

/*******************************************************************************
* IOCTL Structures                                                             *
*******************************************************************************/
#ifndef unchar
#define unchar unsigned char
#endif

#ifndef boolean
#define boolean unchar
#endif

#ifndef BYTE
#define BYTE unchar
#endif

/*******************************************************************************
* SCSI_PASS_THROUGH pass through function                                      *
*******************************************************************************/

#define SCSI_PASS_THROUGH _IOWR('P',0x01,SCSIPassThrough) /* Pass Through  */

typedef struct _SCSIPassThrough {
	unchar   CDB[12];                           /* Command Data Block    */
	unchar   CommandLength;                     /* Command Length        */
	unchar * Buffer ;                           /* Command Buffer        */
	ulong    BufferLength;                      /* Buffer Length         */
	unchar   DataDirection;                     /* Transfer Direction    */
	ushort   TimeOut;                           /* Time Out Value        */
	unchar   TargetStatus;                      /* Target Status         */
	unchar   MessageStatus;                     /* Msg from host adapter */
	unchar   HostStatus;                        /* Host status           */
	unchar   DriverStatus;                      /* Driver status         */
	unchar   SenseDataValid;                    /* Sense Data Valid      */
	unchar   ASC;                               /* ASC if SenseDataValid */
	unchar   ASCQ;                              /* ASCQ if SenseDataVld  */
	unchar   SenseKey;                          /* SK if SenseDataValid  */
} SCSIPassThrough, *PSCSIPassThrough;

#define SCSI_DATA_OUT  1
#define SCSI_DATA_IN   2

#ifndef SCSI_DATA_NONE
#define SCSI_DATA_NONE 3
#endif

/*******************************************************************************
* SCSI Tape Operations                                                         *
* STOFFL, STREW, STERASE, STWEOF, STFSF, STRSF, STFSR and STRSR perform as     *
* defined in the AIX manuals. For IBM tape products STRETEN is a NOP           *
* since they automatically perform retension on their own.                     *
*                                                                              *
* STTUR issues a SCSI Test Unit Ready to device.                               *
* STLOAD issues a SCSI LOAD command                                            *
* STSEOD issues a space forward to EOD command. After this command the         *
*   tape is positioned to begin writing.                                       *
* STFSSF issues a forward space sequential filemarks. Count is equal to        *
*   the number of contiguous fiemarks to search for.                           *
* STRSSF issues a reverse space sequential filemarks. Count is equal to        *
*   the number of contiguous fiemarks to search for.                           *
* IMPORTANT NOTE:                                                              *
* Any command that causes tape position to reverse. Will cause the close       *
* entry point to not write file-marks. If you must position the tape           *
* after writing data and before closing then you can manually write            *
* file-marks with STWEOF.                                                      *
*******************************************************************************/

#define STIOCTOP    _IOWR('P',0x02, struct stop)          /* tape commands */

struct stop {
	short   st_op;                            /* operations defined below */
	daddr_t st_count;                         /* Counter value            */
};

#define STOFFL  5                      /* rewind and unload tape              */
#define STREW   6                      /* rewind                              */
#define STERASE 7                      /* erase tape, leave at load point     */
#define STRETEN 8                      /* retension tape, leave at load point */
#define STWEOF  10                     /* write an end-of-file record         */
#define STFSF   11                     /* forward space file                  */
#define STRSF   12                     /* reverse space file                  */
#define STFSR   13                     /* forward space record                */
#define STRSR   14                     /* reverse space record                */
#define STINSRT 15                     /* load the tape                       */
#define STEJECT 16                     /* unload the tape                     */

/* additional st_op's */
#define STTUR   30                     /* test unit ready                     */
#define STLOAD  31                     /* load tape                           */
#define STSEOD  32                     /* space to end of data                */
#define STFSSF  33                     /* forward space sequential file marks */
#define STRSSF  34                     /* reverse space sequential file marks */

#define STIOCHGP _IOW('P',0x03, struct stchgp)    /* change drive parameters  */
struct  stchgp  {
	unchar  st_ecc;                              /* reserved              */
	int     st_blksize;                          /* change blocksize      */
};

/*******************************************************************************
* QUERY_DRIVER_VERSION returns the IBMtape driver version                      *
*******************************************************************************/

#define QUERY_DRIVER_VERSION \
	_IOR('P',0x04, struct QueryDriverVersion)  /* version */
struct QueryDriverVersion {
	uint MajorRelease;                            /* Major release number */
	uint MinorRelease;                            /* Minor release number */
	uint IncrementRelease;                        /* Incrs release num    */
};

/*******************************************************************************
* STIOCSETP changes device driver parameters                                   *
*   The structure "stchgp" is used to set the current values.                  *
* STIOCQRYP queries device driver parameters                                   *
*   The structure "stchgp" is filled in with the current values.               *
*******************************************************************************/

#define STIOCSETP _IOW('z',0x30,struct stchgp_s)         /* change parameters */
#define STIOCQRYP _IOR('z',0x31,struct stchgp_s)         /* query  parameters */

struct stchgp_s {
	int blksize;                      /* new block size                   */
	boolean trace;                    /* TRUE = message trace on          */
	uint hkwrd;                       /* trace hook word                  */
	int sync_count;                   /* obsolete - not used              */
	boolean autoload;                 /* on/off autoload feature          */
	boolean buffered_mode;            /* on/off buffered mode             */
	boolean compression;              /* on/off compression               */
	boolean trailer_labels;           /* on/off allow writing after EOM   */
	boolean rewind_immediate;         /* on/off immediate rewinds         */
	boolean bus_domination;           /* obsolete - not used              */
	boolean logging;                  /* enable or disable volume logging */
	boolean write_protect;            /* write_protected media            */
	uint min_blksize;                 /* minimum block size               */
	uint max_blksize;                 /* maximum block size               */
	uint max_scsi_xfer;               /* maximum scsi tranfer len         */
	char volid[16];                   /* volume id                        */
	unchar acf_mode;                  /* automatic cartridge facility mode*/
#define ACF_NONE             0
#define ACF_MANUAL           1
#define ACF_SYSTEM           2
#define ACF_AUTOMATIC        3
#define ACF_ACCUMULATE       4
#define ACF_RANDOM           5
	unchar record_space_mode;                     /* fsr/bsr space mode   */
#define SCSI_SPACE_MODE      1
#define AIX_SPACE_MODE       2
	unchar logical_write_protect;                 /* logical write protect*/
#define NO_PROTECT           0
#define ASSOCIATED_PROTECT   1
#define PERSISTENT_PROTECT   2
#define WORM_PROTECT         3
	unchar capacity_scaling;                      /* capacity scaling     */
#define SCALE_100            0
#define SCALE_75             1
#define SCALE_50             2
#define SCALE_25             3
#define SCALE_VALUE          4
	unchar retain_reservation;       /* retain reservation                */
	unchar alt_pathing;              /* alternate pathing active          */
	boolean emulate_autoloader;      /* emulate autoloader in random mode */
	unchar medium_type;              /* tape medium type                  */
	unchar density_code;             /* tape density code                 */
	boolean disable_sim_logging;     /* disable sim/mim error logging     */
	boolean read_sili_bit;           /* SILI bit setting for read commands*/
	unchar read_past_filemark;       /* fixed block read pass the filemark*/
	boolean disable_auto_drive_dump; /* disable auto drive dump logging   */
	unchar capacity_scaling_value;   /* hex value of capacity scaling     */
	boolean wfm_immediate;           /* buffer write file mark            */
	boolean limit_read_recov;        /* limit read recovery to 5 seconds  */
	boolean limit_write_recov;       /* limit write recovery to 5 seconds */
	boolean data_safe_mode;          /* turn data safe mode on/off        */
	unchar pews[2];                  /* programmable early warn zone size */
	unchar busy_retry;			     /* if set a retry will be tried on busy */
	unchar reserved[12];
};

/*******************************************************************************
* This has no arguments. The tape buffers are flushed to tape.                 *
*******************************************************************************/

#define STIOCSYNC _IO('z',0x37)           /* synchronize buffers with tape */

/*******************************************************************************
* STIOCDM displays a message on the 3490 display.                              *
*   dm_func is a flag that is built by oring the defines below.                *
*******************************************************************************/

#define STIOCDM _IOW('z',0x32,struct stdm_s)               /* display message */
#define MAXMSGLEN     8

struct stdm_s {
	char dm_func;                                      /* function code   */

/*Function Selection*/
#define DMSTATUSMSG 0x00    /* General Status Msg                             */
#define DMDVMSG     0x20    /* Demount/Verify Message                         */
#define DMMIMMED    0x40    /* Mount With Immediate Action indicator          */
#define DMDEMIMMED  0xE0    /* Demount/Mount With Immediate Action            */

/*Message Control*/
#define DMMSG0      0x00                /* display msg 0                      */
#define DMMSG1      0x04                /* display msg 1                      */
#define DMFLASHMSG0 0x08                /* Flash msg 0                        */
#define DMFLASHMSG1 0x0C                /* flash msg 1                        */
#define DMALTERNATE 0x10                /* alternate msg 0 and msg 1          */

	char dm_msg0[MAXMSGLEN];        /* message 1                          */
char dm_msg1[MAXMSGLEN];                /* message 2                          */
};

/*******************************************************************************
* STIOCQRYPOS is used to query the position of the tape device on the tape.    *
*   "block_type" indicates whether a logical position is wanted or             *
*   whether a vendor specific position is wanted. The vendor specific          *
*   position is a composite number that is fed into an STIOCSETPOS command     *
*   to provide a much faster method of positioning. Unless a SETPOS            *
*   operation is going to be used there is not much reason to use              *
*   QP_PHYSICAL.                                                               *
*   "eot" is true if the tape position is after early warning.                 *
*   "curpos" is the position where the next write or read would take place.    *
*   "lbot" is the number of the last block to be actually written from the     *
*   buffer onto the tape. If no blocks have been written to tape, ie, all      *
*   are still in the buffer then lbot=NONE                                     *
*   NOTE: lbot is only valid immediately following a write command. Any        *
*   tape positioning will cause this to become invalid.                        *
* STIOCSETPOS is used to position the tape directly to a particular block.     *
*   Only "block_type" and "curpos" are used. All other fields are undefined    *
*******************************************************************************/

#define STIOCQRYPOS _IOWR('z',0x33,struct stpos_s)     /* query tape position */
#define STIOCSETPOS _IOWR('z',0x34,struct stpos_s)     /* set tape position   */
typedef unsigned int blockid_t;
struct stpos_s {
	char block_type;                  /* format of block id information   */
#define QP_LOGICAL  0                     /* scsi logical blockid format      */
#define QP_PHYSICAL 1                     /* vendor specific blockid format   */
	boolean eot;                      /* leading end of partition         */
	blockid_t curpos;                 /* for qry/set pos                  */
	blockid_t lbot;                   /* last block written to tape       */
#define LBOT_NONE    0xFFFFFFFF           /* no blocks have been written      */
#define LBOT_UNKNOWN 0xFFFFFFFE           /* unable to determine information  */
	uint num_blocks;                  /* number of blocks in buffer       */
	uint num_bytes;                   /* number of bytes in buffer        */
	boolean bot;                      /* beginning of partition           */
	unchar partition_number;          /* current partition number on tape */
	unchar reserved1[2];
	blockid_t tapepos;                /* next block to be transferred     */
	unchar reserved2[48];
};

/*******************************************************************************
* STIOCQRYSENSE returns raw sense data from device.                            *
*******************************************************************************/

#define MAXSENSE        255
#define STIOCQRYSENSE _IOWR('z',0x35,struct stsense_s)   /* get sense data */

struct stsense_s {
	/*INPUT*/
	char sense_type;        /* fresh(new sense) or error(last error) data */

#define FRESH     1             /* initiate a new sense command               */
#define LASTERROR 2             /* return sense from last scsi sense command  */

	/*OUTPUT*/
	unchar sense[MAXSENSE];  /* actual sense data                         */
	int len;                 /* length of valid sense data returned       */
	int residual_count;      /* residual count from last operation        */
	unchar reserved[60];
};

#define MAX_INQ_LEN 255            /* max data xfer for inquiry page ioctl */

/*******************************************************************************
* STIOCINQUIRY returns raw inquiry data from device.                           *
*******************************************************************************/

#define STIOCQRYINQUIRY _IOWR('z',0x36,struct st_inquiry)   /* get inquiry */
struct inq_data_s {
	BYTE b0;
/*macros for accessing fields of byte 0 */
#define PERIPHERAL_QUALIFIER(x)   ((x->b0 & 0xE0)>>5)
#define PERIPHERAL_CONNECTED          0x00
#define PERIPHERAL_NOT_CONNECTED      0x01
#define LUN_NOT_SUPPORTED             0x03
#define PERIPHERAL_DEVICE_TYPE(x) (x->b0 & 0x1F)
#define DIRECT_ACCESS                 0x00
#define SEQUENTIAL_DEVICE             0x01
#define PRINTER_DEVICE                0x02
#define PROCESSOR_DEVICE              0x03
#define CD_ROM_DEVICE                 0x05
#define OPTICAL_MEMORY_DEVICE         0x07
#define MEDIUM_CHANGER_DEVICE         0x08
#define UNKNOWN                       0x1F

	BYTE b1;
/*macros for accessing fields of byte 1 */
#define RMB(x) ((x->b1 & 0x80)>>7)                /*removable media bit  */
#define FIXED     0
#define REMOVABLE 1
#define device_type_qualifier(x) (x->b1 & 0x7F)   /* vendor specific     */

	BYTE b2;
/*macros for accessing fields of byte 2 */
#define ISO_Version(x)  ((x->b2 & 0xC0)>>6)
#define ECMA_Version(x) ((x->b2 & 0x38)>>3)
#define ANSI_Version(x) (x->b2 & 0x07)
#define NONSTANDARD     0
#define SCSI1           1
#define SCSI2           2
#define SCSI3           3

	BYTE b3;
/*macros for accessing fields of byte 3 */
#define AENC(x)    ((x->b3 & 0x80)>>7) /*asynchronous event notification */
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif

#define TrmIOP(x)  ((x->b3 & 0x40)>>6) /* support terminate I/O process?      */
#define Response_Data_Format(x)  (x->b3 & 0x0F)
#define SCSI1INQ      0          /* scsi1 standard inquiry data format        */
#define CCSINQ        1          /* CCS standard inquiry data format          */
#define SCSI2INQ      2          /* scsi2 standard inquiry data format        */

	BYTE additional_length;  /* bytes following this field minus 4        */
	BYTE res5;
	BYTE b6;
#define MChngr(x)    ((x->b6 & 0x08)>>3)

	BYTE b7;
/* macros for accessing fields of byte 7  */
/* the following fields are true or false */
#define RelAdr(x)    ((x->b7 & 0x80)>>7)
#define WBus32(x)    ((x->b7 & 0x40)>>6)
#define WBus16(x)    ((x->b7 & 0x20)>>5)
#define Sync(x)      ((x->b7 & 0x10)>>4)
#define Linked(x)    ((x->b7 & 0x08)>>3)
#define CmdQue(x)    ((x->b7 & 0x02)>>1)
#define SftRe(x)     (x->b7 & 0x01)

	char vendor_identification[8];
	char product_identification[16];
	char product_revision_level[4];
};

struct st_inquiry {
	struct inq_data_s standard;
	BYTE vendor_specific[MAX_INQ_LEN - sizeof(struct inq_data_s)];
};

/*******************************************************************************
* Log sense page ioctl data structure                                          *
*******************************************************************************/

#define LOGSENSEPAGE 1024        /* max data xfer for log sense page ioctl    */

struct log_sense_page {
	unchar page_code;
	unsigned short len;       /* log_page_header size + parameter length  */
	unsigned short parm_pointer;
	char data[LOGSENSEPAGE];
};

struct log_sense10_page {
	unchar page_code;
	unchar subpage_code;
	unchar reserved[2];
	unsigned short len;     /* [IN] specific allocation length for the data */
							/* [OUT] number of valid bytes in data          *
							 * (log_page_header size + parameter length)    */
	unsigned short parm_pointer;
	char data[LOGSENSEPAGE];
};

#define SIOC_LOG_SENSE10_PAGE _IOR('z', 0x51, struct log_sense10_page)

/*******************************************************************************
* Mode sense page ioctl data structure                                         *
*******************************************************************************/

#define MAX_MDSNS_LEN 255       /* max data xfer for mode sense page ioctl */
struct mode_sense_page {
	unchar page_code;
	char data[MAX_MDSNS_LEN];
};

struct mode_sense {
	unchar page_code;
	unchar subpage_code;
	unchar reserved[6];
	unchar cmd_code;
	char data[MAX_MDSNS_LEN];
};

/*******************************************************************************
* Inquiry page ioctl data structure                                            *
*******************************************************************************/

struct inquiry_page {
	unchar page_code;
	char data[MAX_INQ_LEN];
};

/*******************************************************************************
* Report Density Support ioctl data structures and defines                     *
*******************************************************************************/

#define ALL_MEDIA_DENSITY      0
#define CURRENT_MEDIA_DENSITY  1

#define MAX_DENSITY_REPORTS    8

struct density_report {
	unchar  primary_density_code;  /* primary density code                */
	unchar  secondary_density_code;/* secondary densuty code              */
	uint   wrtok : 1,              /* write ok, dvc can write this format */
		dup : 1,               /* zero if density only reported once  */
		deflt : 1,             /* current density is default format   */
		: 5;                   /* reserved                            */
	char   reserved[2];            /* reserved                            */
	uint   bits_per_mm : 24;       /* bits per mm                         */
	ushort media_width;            /* media width in millimeters          */
	ushort tracks;                 /* tracks                              */
	uint   capacity;               /* capacity in megabytes               */
	char   assigning_org[8];       /* assigning organization in ASCII     */
	char   density_name[8];        /* density name in ASCII               */
	char   description[20];        /* description in ASCII                */
};

struct report_density_support {
	unchar  media;           /* report all or current media as defd above */
	ushort number_reports;   /* num of density reports returned in array  */
	struct density_report reports[MAX_DENSITY_REPORTS];
};

/*******************************************************************************
* 3494 Library Device Number ioctl definition                                  *
*******************************************************************************/
#ifndef MTDEVICE
#define MTDEVICE               _IOR('m', 0x45, int)
#endif

#ifndef MTWEOFI /* included in kernel 3.x */
#define MTWEOFI (35)
#endif

/* Define iocinfo devtype field for medium changer devices */
#define DD_MEDIUM_CHANGER       'j'

/* Define extended parameters for openx, ioctlx and readx */
#define SC_NO_RESERVE     0x08          /* Don't reserve on open            */
#define SC_PASSTHRU       0x00010000    /* SC_DIAGNOSTIC w/o root authority */
#define SC_FEL            0x00020000    /* Force Error Logging on           */
#define SC_SERVICE        0x00040000    /* Service aid mode                 */
#define SC_NO_ERRORLOG    0x00080000    /* Disable AIX error logging        */
#define SC_TMCP           0x00100000    /* Tape Management Control Point    */
#define ATAPE_DIAGNOSTIC  SC_PASSTHRU
#define TAPE_READ_REVERSE 0x00010000    /* readx parm for SCSI Read Reverse */

/* 7332 DDS2 ioctls */
#define INIT_ELEMENT            0x07
#define MOVE_MEDIUM_LOAD        0xb4
#define MOVE_MEDIUM_UNLOAD      0xb5
#define READ_ELEMENT_INFO       0xb7
#define READ_ELEMENT_STATUS     0xb8

/* For locate, DDS2_LOCATE is opcode and arg is (uint) block number */
#define DDS2_LOCATE             0x2b

/* For read position, DDS2_READ_POS is opcode and arg is address of (unit)  */
/* to store current block position                                          */
#define DDS2_READ_POS                0x34

/* The load/unload medium ioctls default to the first empty or first full   */
/* slot when the argument value is 0.  In order to explicitely use slot 0   */
/* it is defined to be -1 passed as the argument.                           */
#define LOAD_UNLOAD_SLOT_0  ((ushort)-1)
#define SMCIOC_LOAD_MEDIUM      MOVE_MEDIUM_LOAD
#define SMCIOC_UNLOAD_MEDIUM    MOVE_MEDIUM_UNLOAD
#define STIOC_READ_POSITION     DDS2_READ_POS
#define STIOC_LOCATE            DDS2_LOCATE

#define SIOC_INQUIRY                  _IOR ('C',0x01,struct inquiry_data)
#define SIOC_REQSENSE                 _IOR ('C',0x02,struct request_sense)
#define SMCIOC_ELEMENT_INFO           _IOR ('C',0x03,struct element_info)
#define SMCIOC_MOVE_MEDIUM            _IOW ('C',0x04,struct move_medium)
#define SMCIOC_POS_TO_ELEM            _IOW ('C',0x05,struct pos_to_elem)
#define SMCIOC_INIT_ELEM_STAT         _IO  ('C',0x06)
#define SMCIOC_INVENTORY              _IOW ('C',0x07,struct inventory)
#define SIOC_RESERVE                  _IO  ('C',0x08)
#define SIOC_RELEASE                  _IO  ('C',0x09)
#define SIOC_TEST_UNIT_READY          _IO  ('C',0x0A)
// STIOC_LOG_SENSE no supported
//#define STIOC_LOG_SENSE              _IOR ('C',0x0B,struct log_sense)
#define SIOC_MODE_SENSE               _IOR ('C', 0x0D, struct mode_sense)
#define SIOC_MODE_SENSE_PAGE          _IOR ('C',0x0E,struct mode_sense_page)
#define SMCIOC_PREVENT_MEDIUM_REMOVAL _IO  ('C',0x0F)
#define SMCIOC_ALLOW_MEDIUM_REMOVAL   _IO  ('C',0x10)
#define STIOC_RESET_DRIVE             _IO  ('C',0x14)
#define SMCIOC_EXCHANGE_MEDIUM        _IOW ('C',0x19,struct exchange_medium)
#define SMCIOC_INIT_ELEM_STAT_RANGE   _IOW ('C',0x1C,struct element_range)
#define SIOC_INQUIRY_PAGE             _IOWR('C',0x1E,struct inquiry_page)
#define STIOC_REPORT_DENSITY_SUPPORT  \
	_IOWR('C',0x1F,struct report_density_support)
#define STIOC_PREVENT_MEDIUM_REMOVAL  _IO  ('C',0x20)
#define STIOC_ALLOW_MEDIUM_REMOVAL   _IO  ('C',0x21)
#define SMCIOC_READ_ELEMENT_DEVIDS    \
	_IOR ('C',0x22,struct read_element_devids)
#define SIOC_LOG_SENSE_PAGE           _IOR ('C',0x23,struct log_sense_page)
#define SMCIOC_READ_CARTRIDGE_LOCATION \
	_IOR('C',0x2A,struct read_cartridge_location)

/* failover ioctls for paths */
#define PRIMARY_SCSI_PATH    1
#define ALTERNATE_SCSI_PATH  2
#define MAX_SCSI_PATH       16

/* If no more than 2 paths, use SIOC_QUERY_PATH ioctl for the primary and first
*  alternate path info.  If more than 2 paths are configured, use the
*  SIOC_DEVICE_PATHS ioctl for path info
*/

#define SIOC_QUERY_PATH               _IOR ('C', 0x24,struct scsi_path)
#define SIOC_DEVICE_PATHS             _IOR ('C', 0x25,struct device_paths)
#define SIOC_ENABLE_PATH              _IO ('C', 0x26)
#define SIOC_DISABLE_PATH             _IO ('C', 0x27)

/******************************************************************************/
struct scsi_path {
	char primary_name[30];          /* primary logical device name        */
	char primary_parent[30];        /* primary SCSI parent name, hostname */
	unchar primary_id;              /* primary target address             */
	unchar primary_lun;             /* primary LUN                        */
	unchar primary_bus;             /* primary SCSI bus, "Channel" value  */
	unsigned long long primary_fcp_scsi_id;  /* primary FCP id            */
	unsigned long long primary_fcp_lun_id;   /* primary FCP LUN           */
	unsigned long long primary_fcp_ww_name;  /* primary FCP ww name       */
	unchar primary_enabled;         /* primary path enabled               */
	unchar primary_id_valid;        /* primary id/lun/bus fields valid    */
	unchar primary_fcp_id_valid;    /* primary FCP scsi/lun/id fields     */
	unchar alternate_configured;    /* alternate path configured          */
	char alternate_name[30];        /* alternate logical device name      */
	char alternate_parent[30];      /* alternate SCSI parent name         */
	unchar alternate_id;            /* alternate target address           */
	unchar alternate_lun;           /* alternate logical unit             */
	unchar alternate_bus;           /* alternate SCSI bus                 */
	unsigned long long alternate_fcp_scsi_id; /* alternate FCP SCSI id    */
	unsigned long long alternate_fcp_lun_id;  /* alternate FCP LUN        */
	unsigned long long alternate_fcp_ww_name; /* alternate FCP ww name    */
	unchar alternate_enabled;       /* alternate path enabled             */
	unchar alternate_id_valid;      /* alternate id/lun/bus fields valid  */
	unchar alternate_fcp_id_valid;  /* alternate FCP scsi/lun/id fields   */
	unchar primary_drive_port_valid;/* primary drive port field valid     */
	unchar primary_drive_port;      /* primary drive port number          */
	unchar alternate_drive_port_valid; /* alternate drive port valid      */
	unchar alternate_drive_port;    /* alternate drive port               */
	unchar primary_fenced;          /* primary fenced by disable path ioc */
	unchar alternate_fenced;        /* altern. fenced by disable path ioc */
	unchar primary_host;            /* primary host bus adapter id        */
	unchar alternate_host;          /* alternate host bus adapter id      */
	char reserved[56];
};

struct device_path_t {
	char name[30];                  /* logical device name                */
	char parent[30];                /* logical parent name                */
	unchar id_valid;                /* SCSI id/lun/bus fields valid       */
	unchar id;                      /* SCSI target address of device      */
	unchar lun;                     /* SCSI logical unit of device        */
	unchar bus;                     /* SCSI bus for device                */
	unchar fcp_id_valid;            /* FCP scsi/lun/id fields valid       */
	unsigned long long fcp_scsi_id; /* FCP SCSi id of device              */
	unsigned long long fcp_lun_id;  /* FCP logical unit of device         */
	unsigned long long fcp_ww_name; /* FCP world wide name                */
	unchar enabled;                 /* path enabled                       */
	unchar drive_port_valid;        /* drive port field valid             */
	unchar drive_port;              /* drive port number                  */
	unchar fenced;                  /* path fenced by diable path ioctl   */
	unchar host;                    /* host bus adapter id                */
	char reserved[62];
};

struct device_paths {
	int number_paths;               /* number of paths configured         */
	struct device_path_t path[MAX_SCSI_PATH];
};

/******************************************************************************/
#define INQ_HEADER_LEN (4)
#define VEND_ID_LEN (8)
#define PROD_ID_LEN (16)
#define REV_LEN (4)

struct inquiry_data {
	uint  qual : 3,                 /* peripheral qualifier               */
		type : 5;               /* device type                        */
	uint  rm : 1,                   /* removable medium                   */
		mod : 7;                /* device type modifier               */
	uint  iso : 2,                  /* ISO version                        */
		ecma : 3,               /* EMCA version                       */
		ansi : 3;               /* ANSI version                       */
	uint  aenc : 1,                 /* asynchronous event notification    */
		trmiop : 1,             /* terminate I/O process message      */
		: 2,                    /* reserved                           */
		rdf : 4;                /* response data format               */
	unchar len;                     /* additional length                  */
	unchar resvd1;                  /* reserved                           */
	uint  : 4,                      /* reserved                           */
		mchngr : 1,             /* medium changer mode (SCSI 3 only)  */
		: 3;                    /* reserved                           */
	uint  reladr : 1,               /* relative addressing                */
		wbus32 : 1,             /* 32 bit wide data transfers         */
		wbus16 : 1,             /* 16 bit wide data transfers         */
		sync : 1,               /* synchronous data transfers         */
		linked : 1,             /* linked commands                    */
		: 1,                    /* reserved                           */
		cmdque : 1,             /* command queueing                   */
		sftre : 1;              /* soft reset                         */
	unchar vid[VEND_ID_LEN];        /* vendor ID                          */
	unchar pid[PROD_ID_LEN];        /* product ID                         */
	unchar revision[REV_LEN];       /* product revision level             */
	unchar vendor1[20];             /* vendor specific                    */
	unchar resvd2[40];              /* reserved                           */
	unchar vendor2[31];             /* vendor specific (padded to 127)    */
};

struct request_sense {
	uint valid : 1,                 /* information field is valid         */
		err_code : 7;           /* error code                         */
	unchar segnum;                  /* segment number                     */
	uint fm : 1,                    /* file mark detected                 */
		eom : 1,                /* end of medium                      */
		ili : 1,                /* incorrect length indicator         */
		resvd1 : 1,             /* reserved                           */
		key : 4;                /* sense key                          */
	int info;                       /* information bytes                  */
	unchar addlen;                  /* additional sense length            */
	uint cmdinfo;                   /* command specific information       */
	unchar asc;                     /* additional sense code              */
	unchar ascq;                    /* additional sense code qualifier    */
	unchar fru;                     /* field replaceable unit code        */
	uint sksv : 1,                  /* sense key specific valid           */
		cd : 1,                 /* control/data                       */
		resvd2 : 2,             /* reserved                           */
		bpv : 1,                /* bit pointer valid                  */
		sim : 3;                /* system information message         */
	unchar field[2];                /* field pointer                      */
	unchar vendor[109];             /* vendor specific (padded to 127)    */
};

struct element_info {
	ushort robot_addr;              /* first robot address                */
	ushort robots;                  /* number medium transport elements   */
	ushort slot_addr;               /* first medium storage element addr  */
	ushort slots;                   /* number medium storage elements     */
	ushort ie_addr;                 /* first import/export element addr   */
	ushort ie_stations;             /* number import-export elements      */
	ushort drive_addr;              /* first data transfer element addr   */
	ushort drives;                  /* number data transfer elements      */
};

struct move_medium {
	ushort robot;                   /* robot address                      */
	ushort source;                  /* move from location                 */
	ushort destination;             /* move to location                   */
	char invert;                    /* invert before placement bit        */
};

struct pos_to_elem {
	ushort robot;                   /* robot address                      */
	ushort destination;             /* move to location                   */
	char invert;                    /* invert before placement bit        */
};

struct exchange_medium {
	ushort robot;                   /* robot address                      */
	ushort source;                  /* move from location                 */
	ushort destination1;            /* move to location                   */
	ushort destination2;            /* move to location                   */
	char invert1;                   /* invert before placement into dest1 */
	char invert2;                   /* invert before placement into dest2 */
};

struct element_status {
	ushort address;                 /* element address                    */
	uint   : 2,                     /* reserved                           */
		inenab : 1,             /* media into changer's scope         */
		exenab : 1,             /* media out of changer's scope       */
		access : 1,             /* robot access allowed               */
		except : 1,             /* abnormal element state             */
		impexp : 1,             /* import/export bit                  */
		full : 1;               /* element contains medium            */
	unchar resvd1;                  /* reserved                           */
	unchar asc;                     /* additional sense code              */
	unchar ascq;                    /* additional sense code qualifier    */
	uint   notbus : 1,              /* element not on same bus as robot   */
		: 1,                    /* reserved                           */
		idvalid : 1,            /* element address valid              */
		luvalid : 1,            /* logical unit valid                 */
		: 1,                    /* reserved                           */
		lun : 3;                /* logical unit number                */
	unchar scsi;                    /* scsi bus address                   */
	unchar resvd2;                  /* reserved                           */
	uint   svalid : 1,              /* element address valid              */
		invert : 1,             /* medium inverted                    */
		: 6;                    /* reserved                           */
	ushort source;                  /* source storage element address     */
	unchar volume[36];              /* primary volume tag                 */
	unchar resvd3[4];               /* reserved                           */
};

struct inventory {
	struct element_status *robot_status;  /* MTE pages                    */
	struct element_status *slot_status;   /* SE pages                     */
	struct element_status *ie_status;     /* IE pages                     */
	struct element_status *drive_status;  /* DTE pages                    */
};

struct element_range {
	ushort element_address;         /* starting element address           */
	ushort number_elements;         /* number of elements                 */
};

struct element_devid {
	ushort address;                 /* element address                    */
	uint   : 4,                     /* reserved                           */
		access : 1,             /* robot access allowed               */
		except : 1,             /* abnormal element state             */
		: 1,                    /* reserved                           */
		full : 1;               /* element contains medium            */
	unchar resvd1;                  /* reserved                           */
	unchar asc;                     /* additional sense code              */
	unchar ascq;                    /* additional sense code qualifier    */
	uint   notbus : 1,              /* element not on same bus as robot   */
		: 1,                    /* reserved                           */
		idvalid : 1,            /* element address valid              */
		luvalid : 1,            /* logical unit valid                 */
		: 1,                    /* reserved                           */
		lun : 3;                /* logical unit number                */
	unchar scsi;                    /* scsi bus address                   */
	unchar resvd2;                  /* reserved                           */
	uint   svalid : 1,              /* element address valid              */
		invert : 1,             /* medium inverted                    */
		: 6;                    /* reserved                           */
	ushort source;                  /* source storage element address     */
	uint   : 4,                     /* reserved                           */
		code_set : 4;           /* code set X'2' is all ASCII id      */
	uint   : 4,                     /* reserved                           */
		ident_type : 4;         /* identifier type                    */
	unchar resvd3;                  /* reserved                           */
	unchar ident_len;               /* identifier length                  */
	unchar identifier[36];          /* device identification              */
};

struct read_element_devids {
	ushort element_address;         /* starting element address           */
	ushort number_elements;         /* number of elements                 */
	struct element_devid *drive_devid; /* data transfer element pages     */
};

struct cartridge_location_data {
	ushort address;
	unchar : 4,
		access : 1,
		except : 1,
		: 1,
		full   : 1;
	unchar resvd1;
	unchar asc;
	unchar ascq;
	unchar resvd2[3];
	unchar svalid : 1,
		invert : 1,
		: 6;
	ushort source;
	unchar volume[36];
	unchar : 4,
		code_set   : 4;
	unchar : 4,
		ident_type : 4;
	unchar resvd3;
	unchar ident_len;
	unchar identifier[24];
};

struct read_cartridge_location {
	ushort element_address;               /* starting element address     */
	ushort number_elements;               /* number of elements           */
	struct cartridge_location_data* data; /* storage element pages        */
	char reserved[8];                     /* reserved                     */
};

/*******************************************************************************
* STIOCREADRESERVKEYS is used to show info on existing reservation Keys.
* STIOCREADRESERVAIONS is used to show info on existing reservations.
* STIOCCLEARREGISTRATION is used to clear registration and reservation.
*******************************************************************************/

#define STIOC_READ_RESERVEKEYS \
	_IOR('z',0x38,struct read_keys)        /* query reservation keys      */
#define STIOC_READ_RESERVATIONS \
	_IOR('z',0x39,struct read_reserves)    /* query reservations          */
#define STIOC_REGISTER_KEY \
	_IO('z',0x40)                          /* register a reservation key  */
#define STIOC_REMOVE_REGISTRATION \
	_IO('z',0x41)                          /* remove current host's reg   */
#define STIOC_CLEAR_ALL_REGISTRATIONS \
	_IO('z',0x42)                          /* clear all registration keys */

#define RESERVE_KEY_LENGTH          8          /* each key is 8-byte-long     */

struct read_keys {
    uint  generation;                          /* counter for PR-out requests */
    uint  length;                              /* bytes in the Res. Key list  */
    char* reserve_key_list;                    /* list of reservation keys    */
};

struct reserve_descriptor {
	char key[RESERVE_KEY_LENGTH];          /* reservation key             */
	uint scope_spec_addr;                  /* scope-specific address      */
	BYTE reserved;
	BYTE scope : 4,                        /* persistent res. scope       */
		type : 4;                      /* reservation type            */
	ushort ext_length;                     /* extent length               */
};

struct read_reserves {
	uint            generation;            /* counter for PR-out requests */
	uint            length;                /* bytes in the Res. list      */
	struct reserve_descriptor* reserve_list;  /* list of res. key descs   */
};

/******************************************************************************/

struct density_data_t {
	char density_code;                  /* mode sense header density code */
	char default_density;               /* default write density          */
	char pending_density;               /* pending write density          */
	char reserved[9];
};

#define STIOC_GET_DENSITY              _IOR('C',0x28,struct density_data_t)
#define STIOC_SET_DENSITY              _IOWR('C',0x29,struct density_data_t)

/*******************************************************************************
* GET_ENCRYPITON_STATE is used to query the current drive's encryption status.
* SET_ENCRYPTION_STATE is used to set application-managed encrption state.
* SET_DATA_KEY is used for application to set the encryption key.
*******************************************************************************/

struct encryption_status {
	unchar encryption_capable;
	unchar encryption_method;
#define METHOD_NONE 0
#define METHOD_LIBRARY 1
#define METHOD_SYSTEM 2
#define METHOD_APPLICATION 3
#define METHOD_CUSTOM 4
#define METHOD_UNKNOWN 5
	unchar encryption_state;
#define STATE_OFF 0
#define STATE_ON 1
#define STATE_NA 2
#define STATE_UNKNOWN 3
	unchar reserved[13];
};

#define GET_ENCRYPTION_STATE           _IOR('C',0x30,struct encryption_status)
#define SET_ENCRYPTION_STATE           _IOWR('C',0x31,struct encryption_status)

struct data_key {
	unchar data_key_index[12];
	unchar data_key_index_length;
	unchar reserved1[15];
	unchar data_key[32];
	unchar rserved2[48];
};

#define SET_DATA_KEY	                 _IOWR('C',0x32,struct data_key)

/******************************************************************************/
/* Data Encryption diagnostic ioctl data structure and defines                */
/******************************************************************************/
#define SERVER_PING_DIAG         1
#define BASIC_ENCRYPTION_DIAG    2
#define FULL_ENCRYPTION_DIAG     3

struct encryption_diagnostics {
	int diag_type;           /* diagtype defined above to be invoked      */
	int diag_errno;          /* errno return code for failures or 0       */
	int diag_cc;             /* diag completion code for diag type        */
	unchar reserved[8];
};

#define DATA_ENCRYPTION_DIAGNOSTICS \
	_IOWR('C',0x33,struct encryption_diagnostics)

/******************************************************************************/
/* Partition IOCTLs                                                           */
/******************************************************************************/

#define IDP_PARTITION    (1)
#define SDP_PARTITION    (2)
#define FDP_PARTITION    (3)

#define UNKNOWN_PAR_TYPE (0)
#define WRAP_WISE_PART   (1)
#define LONGITUDE_PART   (2)

#define SIZE_UNIT_BYTES  (0)
#define SIZE_UNIT_KBYTES (3)
#define SIZE_UNIT_MBYTES (6)
#define SIZE_UNIT_GBYTES (9)
#define SIZE_UNIT_TBYTES (12)

#define MAX_PARTITIONS   (255)
#define MAX_SUPPORTED_PARTITIONS (4)

struct query_partition {
	unchar max_partitions;
	unchar active_partition;
	unchar number_of_partitions;
	unchar size_unit;
	ushort size[MAX_PARTITIONS];
	unchar partition_method; /* for 3592-E07 and later */
	char reserved[31];
};

#define DEVICE_CONFIG_MODE_PAGE    (0x10)
#define MEDIUM_PARTITION_MODE_PAGE (0x11)

#define STIOC_QUERY_PARTITION _IOR('z', 0x43, struct query_partition)

struct tape_partition {
	unchar type;
	unchar number_of_partitions;
	unchar size_unit;
	ushort size[MAX_PARTITIONS];
	unchar partition_method; /* for 3592-E07 and later */
	char reserved[31];
};

#define STIOC_CREATE_PARTITION _IOW('z', 0x44, struct tape_partition)

struct set_active_partition {
	unchar partition_number;
	unsigned long long logical_block_id;
	char reserved[32];
};

#define STIOC_SET_ACTIVE_PARTITION _IOW('z', 0x45, struct set_active_partition)

struct allow_data_overwrite {
	unchar partition_number;
	unsigned long long logical_block_id;
	unchar allow_format_overwrite;
	char reserved[32];
};

#define STIOC_ALLOW_DATA_OVERWRITE _IOW('z', 0x46, struct allow_data_overwrite)

/******************************************************************************/
/* Enhanced Position IOCTLs                                                   */
/******************************************************************************/

/* Extended READ_POSITION */

#define RP_SHORT_FORM (0x00)
#define RP_LONG_FORM (0x06)
#define RP_EXTENDED_FORM (0x08)

struct short_data_format {
#if __BYTE_ORDER == __LITTLE_ENDIAN
	unchar bpew : 1;
	unchar perr : 1;
	unchar lolu : 1;
	unchar rsvd : 1;
	unchar bycu : 1;
	unchar locu : 1;
	unchar eop : 1;
	unchar bop : 1;
#elif __BYTE_ORDER == __BIG_ENDIAN
	unchar bop : 1;
	unchar eop : 1;
	unchar locu : 1;
	unchar bycu : 1;
	unchar rsvd : 1;
	unchar lolu : 1;
	unchar perr : 1;
	unchar bpew : 1;
#else
		error
#endif
	unchar active_partition;
	char reserved[2];
	unchar first_logical_obj_position[4];
	unchar last_logical_obj_position[4];
	unchar num_buffer_logical_obj[4];
	unchar num_buffer_bytes[4];
	char reserved1;
};

struct long_data_format {
#if __BYTE_ORDER == __LITTLE_ENDIAN
	unchar bpew : 1;
	unchar rsvd2 : 1;
	unchar lonu : 1;
	unchar mpu : 1;
	unchar rsvd1 : 2;
	unchar eop : 1;
	unchar bop : 1;
#elif __BYTE_ORDER == __BIG_ENDIAN
	unchar bop : 1;
	unchar eop : 1;
	unchar rsvd1 : 2;
	unchar mpu : 1;
	unchar lonu : 1;
	unchar rsvd2 : 1;
	unchar bpew : 1;
#else
		error
#endif
	char reserved[6];
	unchar active_partition;
	unchar logical_obj_number[8];
	unchar logical_file_id[8];
	unchar obsolete[8];
};

struct extended_data_format {
#if __BYTE_ORDER == __LITTLE_ENDIAN
	unchar bpew : 1;
	unchar perr : 1;
	unchar lolu : 1;
	unchar rsvd : 1;
	unchar bycu : 1;
	unchar locu : 1;
	unchar eop : 1;
	unchar bop : 1;
#elif __BYTE_ORDER == __BIG_ENDIAN
	unchar bop : 1;
	unchar eop : 1;
	unchar locu : 1;
	unchar bycu : 1;
	unchar rsvd : 1;
	unchar lolu : 1;
	unchar perr : 1;
	unchar bpew : 1;
#else
		error
#endif
	unchar active_partition;
	unchar additional_length[2];
	unchar num_buffer_logical_obj[4];
	unchar first_logical_obj_position[8];
	unchar last_logical_obj_position[8];
	unchar num_buffer_bytes[8];
	unchar reserved;
};

struct read_tape_position {
	unchar data_format;
	union {
		struct short_data_format rp_short;
		struct long_data_format rp_long;
		struct extended_data_format rp_extended;
	} rp_data;
};

#define STIOC_READ_POSITION_EX _IOWR('z', 0x47, struct read_tape_position)

/* LOCATE 16 */

#define LOGICAL_ID_BLOCK_TYPE (0x00)
#define LOGICAL_ID_FILE_TYPE (0x01)

struct set_tape_position {
	unchar logical_id_type;
	unsigned long long logical_id;
	char reserved[32];
};

#define STIOC_LOCATE_16 _IOW('z', 0x48, struct set_tape_position)

/******************************************************************************/
/* Logical Block Protection IOCTLs                                            */
/******************************************************************************/

#define LBP_DISABLE             (0x00)
#define REED_SOLOMON_CRC        (0x01)

struct logical_block_protection {
	unchar lbp_capable;
	unchar lbp_method;
	unchar lbp_info_length;
	unchar lbp_w;
	unchar lbp_r;
	unchar rbdp;
	unchar reserved[26];
};

#define EXTENDED_INQUIRY_PAGE   (0x86)

#define STIOC_QUERY_BLK_PROTECTION  _IOR('z', 0x49, \
	struct logical_block_protection)
#define STIOC_SET_BLK_PROTECTION _IOW('z', 0x50, \
	struct logical_block_protection)

/******************************************************************************/
/* EOT warning IOCTLs                                                         */
/******************************************************************************/

struct eot_warn {
	unchar warn;
	unchar reserved[7];
};

#define STIOC_QUERY_EOT_WARN _IOR('z', 0x52, struct eot_warn)
#define STIOC_SET_EOT_WARN _IOW('z', 0x53, struct eot_warn)

/******************************************************************************/
/* VERIFY_TAPE_DATA IOCTL                                                     */
/******************************************************************************/

struct verify_data {

#if __BYTE_ORDER == __LITTLE_ENDIAN
	unchar fixed     : 1;
	unchar bytcmp    : 1;
	unchar immed     : 1;
	unchar vbf       : 1;
	unchar vlbpm     : 1;
	unchar vte       : 1;
	unchar reserved1 : 2;
#elif __BYTE_ORDER == __BIG_ENDIAN
	unchar reserved1 : 2;
	unchar vte       : 1;
	unchar vlbpm     : 1;
	unchar vbf       : 1;
	unchar immed     : 1;
	unchar bytcmp    : 1;
	unchar fixed     : 1;
#else
	error
#endif
	unchar verify_length[3];
	unchar reserved2[15];
};

#define STIOC_VERIFY_TAPE_DATA _IOW('z', 0x54, struct verify_data)

/******************************************************************************/
/* New passthrough ioctl data structure and defines                           */
/******************************************************************************/

struct sioc_pass_through {
	unsigned char cmd_length;     /* Input: Length of SCSI command        */
	unsigned char* cdb;           /* Input: SCSI command descriptor block */
	uint buffer_length;           /* Input: Length of data buffer         */
                                      /* Output: bytes actually transferred   */
	unsigned char *buffer;        /* Input/Output: data transfer or NULL  */
	unsigned int data_direction;  /* Input: Data transfer direction       */
	uint timeout;                 /* Input: Timeout in seconds            */
	unsigned char sense_length;   /* Input/Output: sense data bytes       */
	unsigned char* sense;         /* Output: Sense when sense length > 0  */
	int resid;                    /* Output: resid bytes after transfer   */
	int32_t result;               /* Output: result from lower driver     */
	unsigned char msg_status;     /* Output: from SCSI transport layer    */
	unsigned char target_status;  /* Output: target device status         */
	unsigned short driver_status; /* Output: level driver status          */
	unsigned short host_status;   /* Output: host bus adapter status      */

	unsigned char reserved[64];
};

#define SIOC_PASS_THROUGH     _IOWR('C', 0x34, struct sioc_pass_through)

#define MaxScsiPath		16

#endif


text:
<!doctype html>

        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="apple-touch-icon" href="apple-touch-icon.png">

        <link rel="stylesheet" href="css/bootstrap.min.css">

        <link rel="stylesheet" href="css/main.css">

          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            Toggle navigation

          </button>
          Score Keeper

"It was pretty great!" ~Megan

        Loading...

© 2015 Burwell Designs

redpajama_set_name: RedPajamaGithub


text:
package main

import (
	"context"
	"flag"
	"fmt"
	"os"
	"regexp"
	"strings"

	"github.com/kyma-project/test-infra/development/tools/pkg/common"
	"github.com/kyma-project/test-infra/development/tools/pkg/dnscollector"
	log "github.com/sirupsen/logrus"
	"golang.org/x/oauth2/google"
	compute "google.golang.org/api/compute/v1"
	dns "google.golang.org/api/dns/v1"
	"google.golang.org/api/option"
)

const defaultAddressRegexpList = "(remoteenvs-)?gkeint-(pr|commit|rel)-.*,(remoteenvs-)?gke-upgrade-(pr|commit|rel)-.*,(remoteenvs-)?(e2etest),gke-central-(pr|commit|rel)-.*,gke-backup-(pr|commit|rel)-.*,gkecompint-(pr|commit)-.*,apiserver.gke.*"
const minAgeInHours = 1
const minPatternLength = 5

var (
	project               = flag.String("project", "", "project id [required]")
	regions               = flag.String("regions", "", "comma-separted list of GCP regions [required]")
	dnsZone               = flag.String("dnsZone", "", "Name of the DNS Managed Zone [Required]")
	dryRun                = flag.Bool("dryRun", true, "Dry Run enabled, nothing is deleted")
	ageInHours            = flag.Int("ageInHours", 2, "IP Address age in hours. Addresses older than: now()-ageInHours are considered for removal.")
	addressNameRegexpList = flag.String("addressRegexpList", defaultAddressRegexpList, "Address name regexp list. Separate items with commas, spaces are trimmed. Matching addresses are considered for removal.")
)

func main() {
	flag.Parse()

	if *project == "" {
		fmt.Fprint(os.Stderr, "missing -project flag\n\n")
		flag.Usage()
		os.Exit(2)
	}

	if *dnsZone == "" {
		fmt.Fprint(os.Stderr, "missing -dnsZone flag\n\n")
		flag.Usage()
		os.Exit(2)
	}

	regionsList := splitPatterns(*regions)
	for _, region := range regionsList {
		if len(region) == 0 {
			fmt.Fprint(os.Stderr, "invalid region: \"\"\n\n")
			flag.Usage()
			os.Exit(2)
		}
	}

	patterns := splitPatterns(*addressNameRegexpList)
	regexpList := []*regexp.Regexp{}
	for _, pattern := range patterns {
		if len(pattern) < minPatternLength {
			fmt.Fprintf(os.Stderr, "invalid pattern: \"%s\". Value must not be shorter than %d characters.\n\n", pattern, minPatternLength)
			flag.Usage()
			os.Exit(2)
		}
		regexpList = append(regexpList, regexp.MustCompile(pattern))
	}

	if *ageInHours < minAgeInHours {
		fmt.Fprintf(os.Stderr, "invalid ageInHours. Value must not be smaller than %d\n\n", minAgeInHours)
		flag.Usage()
		os.Exit(2)
	}

	common.ShoutFirst("Running with arguments: project: \"%s\", regions: \"%s\", dnsZone: \"%s\", dryRun: %t, ageInHours: %d, addressRegexpList: %s", *project, quoteElems(regionsList), *dnsZone, *dryRun, *ageInHours, quoteElems(patterns))
	ctx := context.Background()

	computeConn, err := google.DefaultClient(ctx, compute.CloudPlatformScope)
	if err != nil {
		log.Fatalf("Could not get authenticated client: %v", err)
	}

	computeSvc, err := compute.NewService(ctx, option.WithHTTPClient(computeConn))
	if err != nil {
		log.Fatalf("Could not initialize gke client for Compute API: %v", err)
	}

	dnsSvc, err := dns.NewService(ctx, option.WithHTTPClient(computeConn))
	if err != nil {
		log.Fatalf("Could not initialize gke client for Compute API: %v", err)
	}

	computeAPI := &dnscollector.ComputeServiceWrapper{Context: ctx, Compute: computeSvc}
	dnsAPI := &dnscollector.DNSServiceWrapper{Context: ctx, DNS: dnsSvc}
	shouldRemoveFunc := dnscollector.DefaultIPAddressRemovalPredicate(regexpList, *ageInHours)

	cleaner := dnscollector.New(computeAPI, dnsAPI, shouldRemoveFunc)
	allSucceeded, err := cleaner.Run(*project, *dnsZone, regionsList, !(*dryRun))

	if err != nil {
		log.Fatalf("IP/DNS collector error: %v", err)
	}

	if !allSucceeded {
		log.Warn("Some operations failed.")
	}

	common.Shout("Finished")
}

func quoteElems(elems []string) string {

	res := "\"" + elems[0] + "\""
	for i := 1; i < len(elems); i++ {
		res = res + ",\"" + elems[i] + "\""
	}

	return "[" + res + "]"
}

func splitPatterns(commaSeparated string) []string {

	res := []string{}
	values := strings.Split(commaSeparated, ",")
	for _, pattern := range values {
		val := strings.Trim(pattern, " ")
		res = append(res, val)
	}

	return res
}


text:
Bullwinkle is an easy to use framework for asynchronous agent and device communication. The Bullwinkle library consists of two classes:

- [Bullwinkle](#bullwinkle) - The core application - used to add/remove handlers, and send messages.
  - [Bullwinkle.send](#bullwinkle_send) - Sends a message to the partner application.
  - [Bullwinkle.on](#bullwinkle_on) - Adds a message listener for the specified messageName.
    - [reply](#bullwinkle_on_reply) - A method passed into .on handlers that is used to reply to the message.
  - [Bullwinkle.remove](#bullwinkle_remove) - Removes a message listener for the specified messageName.
- [Bullwinkle.Package](#bullwinklepackage) - A packaged message with event handlers.
  - [Package.onSuccess](#onsuccesscallback) - Adds a handler that will be invoked if the message is successfully delivered and acknowledged.
  - [Package.onReply](#onreplycallback) - Adds a handler that will be invoked if the message is replied to.
  - [Package.onFail](#onfailcallback) - Adds an onFail handler that will be invoked if the send failed.
    - [retry](#retrytimeout) - A method passed into .onFail handlers that is used to retry sending the message.

Bullwinkle([options])

Calling the Bullwinkle constructor creates a new Bullwiunkle application.  An optional *options* table can be passed into the constructor to override default behaviours:

```squirrel
#require "bullwinkle.class.nut:2.2.0"

bull <- Bullwinkle();
```

**NOTE:** You must `require` and instantiate Bullwinkle in both the agent and device code.

options

A table containing any of the following keys may be passed into the Bullwinkle constructor to modify the default behaviour:

- ```messageTimeout``` - Changes the default timeout required before a message is considered failed.
- ```retryTimeout``` - Changes the default timeout parameter passed to the [retry](#retry) method.
- ```maxRetries``` - Changes the default number of times the [retry](#retry) method will function. After this number the [retry](#retry) method will do nothing.

The default settings are listed below:

```squirrel
{
    "messageTimeout": 10.0,  // If there is no response from a message in 10 seconds, consider it failed
    "retryTimeout": 60.0,    // Calling package.retry() with no parameter will retry in 60 seconds
    "maxRetries": 0          // There is no limit to the number of retries
}
```

send(messageName, [data])

Sends a named message to the partner's Bullwinkle application, and returns a [Bullwinkle.Package](#package). The *data* parameter can be [any serializable Squirrel value](https://electricimp.com/docs/resources/serialisablesquirrel/).

```squirrel
bull.send("setLights", true);   // Turn the lights on
```

The send method returns a [Bullwinkle.Package](#package) object that can be used to attach [onFail](#onfailcallback) and [onReply](#onreplycallback) handlers.

on(messageName, callback)

Adds a message listener (the *callback*) for the specified *messageName*. The callback method takes two parameters: *message* (the message), and *reply* (a method that can be called to reply to the message).

```squirrel
// Get a message, and do something with it
bull.on("setLights", function(message, reply) {
    led.write(message.data);
});
```

reply(data)

The second parameter, *reply*, is a method that can be invoked to reply to the message caught by the .on handler. The reply method takes a parameter - *data* - representing the information we want to pass back to the partner. The *data* parameter can be [any serializable Squirrel value](https://electricimp.com/docs/resources/serialisablesquirrel/).

```squirrel
// Get a message, and respond to it
bull.on("temp", function(message, reply) {
    // Read the temperature and humidity sensor
    local data = tempHumid.read();

    // Reply to the message
    reply(data);
});
```

remove(messageName)

The *remove* method removes a message listener that was added with the [.on](#bullwinkle_on) method.

```squirrel
bull.remove("test");     // Don't listen for 'test' messages anymore.
```

Bullwinkle.Package

A Bullwinkle.Package object represents a message that has been sent to the partner, and has event handlers attached to it. Bullwinkle.Package objects should never be manually constructed (the [Bullwinkle.send](#bullwinkle_send) method returns a Bullwinkle.Package object).

onSuccess(callback)

The onSuccess method adds an event listener (the *callback*) that will execute if the partner *.on* handler receives the message.
The *message* parameter contains the successfully delivered message including a *tries* count and a round-trip *latency* float in seconds.

```squirrel
bull.send("importantMessage")
    .onSuccess(function(message) {
        server.log("Done!");
    })
    .onFail(function(err, message, retry) {
        retry();
    });
```

onReply(callback)

The onReply method adds an event listener (the *callback*) that will execute if the partner *.on* handler replies to the message with the [reply](#bullwinkle_on_reply) method. The callback takes a single parameter, *message*, which contains the message information including a *tries* count and a round-trip *latency* float in seconds.

The following example demonstrates how to get real time sensor information with [Rocky](https://github.com/electricimp/rocky) and Bullwinkle:

```squirrel
// Agent Code
#require "Rocky.class.nut:1.2.0"
#require "Bullwinkle.class.nut:2.2.0"

app <- Rocky();
bull <- Bullwinkle();

app.get("/data", function(context) {
    bull.send("temp").onReply(function(message) {
        context.send(200, message.data);
    });
});
```

```squirrel
// Device Code
#require "Si702x.class.nut:1.0.0"
#require "Bullwinkle.class.nut:2.2.0"

bull <- Bullwinkle();

i2c <- hardware.i2c89;
i2c.configure(CLOCK_SPEED_400_KHZ);
tempHumid <- Si702x(i2c);

bull.on("temp", function(message, reply){
    local result = tempHumid.read();
    reply(result)
});
```

onFail(callback)

The onFail method adds an event listener (the *callback*) that will  execute if the partner application does not have a handler for the specified messageName, or if the partner fails to respond within a specified period of time (the [messageTimeout](#bullwinkle_options)). The callback method requires three parameters: *err*, *message*, and *retry*.

The *err* parameter describes the error, and will either be `Bullwinkle.NO_HANDLER` (in the event the partner application does not have a handler for the specified messageName), or `Bullwinkle.NO_RESPONSE` (in the event the partner application fails to respond in the specified timeout period).

The *message* parameter contains the failed message including a *tries* count and a *latency* float in seconds.

The *retry* parameter is a method that can be invoked to retry sending the message in a specified period of time. Note, this method must be called synchronously if it is to be called at all. If the *retry* method is not called the message will be expired.

```squirrel
bull.send("importantMessage")
    .onFail(function(err, message, retry) {
        // Try sending the message again in 60 seconds
        if (!retry(60)) {
            server.error("No more retry attempts are allowed");
        }
    }).onReply(function(message) {
        server.log("Done!");
    });
```

retry([timeout])

The *retry* method is passed into onFail handler, and can be used to try sending the failed message again after the specified timeout has elapsed. If no timeout is specified, the retry message will use the default [retryTimeout](#bullwinkle_options) setting. If the maximum number of retries have been attempted then this function will return false and no more retries will be attempted, otherwise it will return true. See [onFail](#onfailcallback) for example usage.

## License

Bullwinkle is licensed under the [MIT License](./LICENSE).


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

#include <barrelfish/barrelfish.h>
#include <barrelfish/waitset.h>
#include <barrelfish/nameservice_client.h>
#include <lwip/inet.h>

#include <if/e10k_defs.h>

#include "port_management_support.h"
#include "device_manager_debug.h"

/******************************************************************************
 * Local state
 ******************************************************************************/

/** Connection to e10k management service */
struct e10k_binding *binding = NULL;

/******************************************************************************
 * Operations for filter interface
 ******************************************************************************/

// Callback for bind
static void bind_cb(void *st, errval_t err, struct e10k_binding *b)
{
    assert(err_is_ok(err));

    NDM_DEBUG("Sucessfully connected to management interface\n");

    binding = b;
    e10k_rpc_client_init(binding);
}

/** Open connection to management interface */
static void connect_to_mngif(char *dev_name)
{
    errval_t r;
    iref_t iref;
    const char *suffix = "_e10kmng";
    char name[strlen(dev_name) + strlen(suffix) + 1];

    // Build label for management service
    sprintf(name, "%s%s", dev_name, suffix);

    // Connect to service
    r = nameservice_blocking_lookup(name, &iref);
    assert(err_is_ok(r));

    r = e10k_bind(iref, bind_cb, NULL, get_default_waitset(),
            IDC_BIND_FLAGS_DEFAULT);
    assert(err_is_ok(r));
}

/******************************************************************************
 * Operations for filter interface
 ******************************************************************************/

static void init_filters(char *dev_name, qid_t qid)
{
    NDM_DEBUG("e10_flt: init %s %d\n", dev_name, (int) qid);

    // Check if we are already initialized from another queue
    if (binding != NULL) {
        return;
    }

    connect_to_mngif(dev_name);

    // waiting for connection to succeed.
    NDM_DEBUG("e10k_init_filters: wait connection\n");
    while (binding == NULL) {
        messages_wait_and_handle_next();
    }
}

static void reg_arp_filters(uint64_t id, uint64_t len_rx,
                            uint64_t len_tx)
{
    USER_PANIC("reg_arp_filters() not supported in e10k filters");
}

static errval_t reg_filters(uint16_t port,
                            port_type_t type,
                            bufid_t buffer_id_rx,
                            bufid_t buffer_id_tx,
                            appid_t appid,
                            qid_t qid,
                            uint64_t *id, errval_t *rerr, uint64_t *filter_id)
{
    e10k_port_type_t t;
    assert(binding != NULL);

    NDM_DEBUG("e10k_reg_filters()\n");

    if (type == net_ports_PORT_TCP) {
        t = e10k_PORT_TCP;
    } else {
        t = e10k_PORT_UDP;
    }
    errval_t err;
    err = binding->rpc_tx_vtbl.register_port_filter(binding, buffer_id_rx, buffer_id_tx, qid, t, port, rerr, filter_id);

    return err;
}

static errval_t unreg_filters(uint64_t filter_id, qid_t qid)
{
    assert(binding != NULL);

    NDM_DEBUG("e10k_unreg_filters()\n");
    errval_t err, rerr;
    err = binding->rpc_tx_vtbl.unregister_filter(binding, qid, &rerr);
    assert(err_is_ok(err));

    return rerr;
}

/******************************************************************************
 * Get signature of this service
 ******************************************************************************/

static struct filters_tx_vtbl e10k_filts_mng = {
    .type = "e10k_filters",
    .init_filters = init_filters,
    .reg_arp_filters = reg_arp_filters,
    .reg_filters = reg_filters,
    .unreg_filters = unreg_filters,
};

struct filters_tx_vtbl *get_e10k_filt_mng_sign(void)
{
    return &e10k_filts_mng;
}


text:
export default ( collection, iteratee, accumulator ) => {
  if ( Array.isArray( collection ) || typeof collection === 'object' ) {
    for ( let key in collection ) {
      accumulator = iteratee( accumulator, collection[ key ], key, collection )
    }
  } else {
    return ""
  }

  return accumulator
}


text:
"use strict";
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:lib
Object.defineProperty(exports, "__esModule", { value: true });
exports.es2015_generator = void 0;
const es2015_iterable_1 = require("./es2015.iterable");
const base_config_1 = require("./base-config");
exports.es2015_generator = Object.assign(Object.assign({}, es2015_iterable_1.es2015_iterable), { Generator: base_config_1.TYPE, GeneratorFunction: base_config_1.TYPE, GeneratorFunctionConstructor: base_config_1.TYPE });
//# sourceMappingURL=es2015.generator.js.map


text: <script src="dist/mqemitter.js"></script>


text:
package com.pengyifan.leetcode;

import java.util.HashSet;
import java.util.Set;

/**
 * Given an unsorted array of integers, find the length of the longest
 * consecutive elements sequence.
 *

 * For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements
 * sequence is [1, 2, 3, 4]. Return its length: 4.
 *

 * Your algorithm should run in O(n) complexity.
 */
public class LongestConsecutiveSequence {

  public int longestConsecutive(int[] num) {
    if (num == null || num.length == 0) {
      return 0;
    }
    int maxLength = 0;
    // number, visited
    Set<Integer> set = new HashSet<Integer>();
    for (int i = 0; i < num.length; i++) {
      set.add(num[i]);
    }

    for (int i = 0; i < num.length; i++) {
      int length = 1;
      int n = num[i];
      // right
      while (set.contains(n + 1)) {
        length++;
        n++;
        set.remove(n);
      }
      n = num[i];
      // left
      while (set.contains(n - 1)) {
        length++;
        n--;
        set.remove(n);
      }
      if (maxLength < length) {
        maxLength = length;
      }
    }
    return maxLength;
  }
}


text:
var demande = {};
var itiniraire = [];
var server  = "http://localhost:9999";
$(document).ready(function()
{
  hundleLoginForm();
  getVehiculeType();
  prepareAddressFinder();
  hundleCompareTime();
  hundleCovoitureur();
  hundleValidateRequest();

 $('.date-fr').bootstrapMaterialDatePicker
    ({
        format: 'DD/MM/YYYY HH:mm',
        lang: 'fr',
        weekStart: 1,
        cancelText : 'ANNULER',
        nowButton : true,
        switchOnClick : true,
        minDate : new Date()
    });
    $('.date-fr').val(new Date().toLocaleString());

    $.material.init()
});

 function initSearchForm(){
   getVehiculeType();
   prepareAddressFinder();
 }

function getVehiculeType(){

    //appel du web service recuperation de type vehicule
    $.ajax( {
		    type:'Get',
		    url:server + '/vehicules',
		    dataType: 'json',
		    success:function (responseData, textStatus, errorThrown) {

		    	$.each( responseData, function( index, vehicule ){
		    		$('#vehiculeTypeSelect').append($('<option>', {
			            value: vehicule.maxPassenger,
			            text: vehicule.type
			        }));
		    	});

			    },
	    	error: function (responseData, textStatus, errorThrown) {
	   		    alert('Erruer de recuperation de type de vehicule !');
	    	}

    	})

    }

function prepareAddressFinder(){
	$( "#departureAddressInput,#arrivalAddressInput" ).autocomplete({
	      source: function( request, response ) {
	    	  var url = server + "/address?voie="+request.term;
	        $.ajax({
	          url: url,
	          dataType: "json",
	          data: {
	            q: request.term
	          },
	          success: function( data ) {
	        	var addressList = [];
	        	  $.each(data,function(index,address){
	        		 var value = address.numero + "," + address.voie + "," + address.code_post;
	        		 addressList.push({value : value, lon : address.lon, lat : address.lat});
	        	  });
	            response( addressList );
	          }
	        });
	      },
	      minLength: 5,
	      select: function( event, ui ) {

	        itiniraire.push(ui.item.lon);
	        itiniraire.push(ui.item.lat);

	        toastr.success("lon : " + ui.item.lon +"
" +"lat : " +ui.item.lat  );
	      },
	      open: function() {
	        $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
	      },
	      close: function() {
	        $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
	      }
	    }).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
			  return $( "
" )
			    .append( "" + item.value + "" )
			    .appendTo( ul );
			};
}

function hundleCovoitureur(){
	$("#covoitureurs").change(function(){
			var number = $("#covoitureurs").val();
	var capacity = $("#vehiculeTypeSelect option:selected").val();
	if(capacity < number)
		toastr.warning("Vous avez dépassé la capacité du véhicule");
	});
}

function hundleCompareTime(){
	$('.date-fr').change(function(){

		var depart = $('#departureTime').val().replace('à','');
		var arrivee = $('#arrivalTime').val().replace('à','');;
		if(arrivee < depart){
			toastr.warning("Horaire d'arrivée doit être superieure à l'horaire' de départ")
		}
	});
}

function hundleLoginForm(){

    $('#login-form-link').click(function(e) {
		$("#login-form").delay(100).fadeIn(100);
 		$("#register-form").fadeOut(100);
		$('#register-form-link').removeClass('active');
		$(this).addClass('active');
		e.preventDefault();
	});
	$('#register-form-link').click(function(e) {
		$("#register-form").delay(100).fadeIn(100);
 		$("#login-form").fadeOut(100);
		$('#login-form-link').removeClass('active');
		$(this).addClass('active');
		e.preventDefault();
	});
}

function hundleValidateRequest(){
	 $("#searchBtn").click(function(){

		 demande.max_price = $("#max_price").val();
		 demande.max_passeneger = $("#covoitureurs").val();
		 demande.max_delay = $("#deviation-time").val();
		 demande.dep_lon = itiniraire[0];
		 demande.dep_lat = itiniraire[1];
		 demande.arr_lon = itiniraire[2];
		 demande.arr_lat = itiniraire[3];
		 demande.vehiculeType = $("#vehiculeTypeSelect option:selected").text();
		 //demande.vehiculeType ="Citadine";

		 $("#spinnerLoader").removeClass("hidden");
		 $("#resultSuggestion").addClass("hidden");
		 $("#noSuggestion").addClass("hidden");
		 $("#waitingModal").modal();

		 $.ajax( {
			 	beforeSend: function(xhrObj){
			        xhrObj.setRequestHeader("Content-Type","application/json");
			        xhrObj.setRequestHeader("Accept","application/json");
			    },
			    type:'Post',
			    url:server +"/suggestions",
			    //dataType: 'application/json',
			    data : JSON.stringify(demande),
			    success:function (responseData, textStatus, errorThrown) {
			    	if(responseData.demandeDistance!= undefined)
			    	{
			    	$("#demandePrice").html(demande.max_price);
			    	$("#demandePassenger").html(demande.max_passeneger);
			    	$("#demandeDelay").html(demande.max_delay);

			    	$("#suggestionPrice").html(responseData.max_price);
			    	$("#suggestionPassenger").html(responseData.max_passenger);
			    	$("#suggestionDelay").html(responseData.max_delay);
			    	$("#suggestionVehicule").html(responseData.vehiculeType);
			    	$("#suggestionDistance").html(responseData.demandeDistance +  " Km");
			    	$("#suggestionDuration").html(responseData.demandeDuration + " min");

			    	$("#spinnerLoader").addClass("hidden");
			    	$("#resultSuggestion").removeClass("hidden");

			    	if(parseInt(responseData.max_passenger) <= parseInt(demande.max_passeneger))
			    		$("#suggestionPassenger").addClass("success");
			    	else
			    		$("#suggestionPassenger").addClass("warning");
			    	if(parseInt(responseData.max_price) <= parseInt(demande.max_price))
			    		$("#suggestionPrice").addClass("success");
			    	else
			    		$("#suggestionPrice").addClass("warning");
			    	if(parseInt(responseData.max_delay) <= parseInt(demande.max_delay))
			    		$("#suggestionDelay").addClass("success");
			    	else
			    		$("#suggestionDelay").addClass("warning");
			    }
			    	else{
			    		$("#spinnerLoader").addClass("hidden");
				    	$("#noSuggestion").removeClass("hidden");
			    	}
			    },error: function (responseData, textStatus, errorThrown) {
			    	toastr.warning("Erreur lors du calcul de votre itinéraire !");
		    	}
		 });

		 /*
	 	var url = 'https://router.project-osrm.org/route/v1/driving/' + itiniraire[1] +',' + itiniraire[0] +';' + itiniraire[3] +',' + itiniraire[2] +'?overview=false';
	 	 //var url = 'http://router.project-osrm.org/route/v1/driving/' + itiniraire[0] +',' + itiniraire[1] +';' + itiniraire[2] +',' + itiniraire[3] +'?overview=false';
	 	 //url = 'https://router.project-osrm.org/route/v1/driving/2.4177585,48.8685127;2.470517,48.941244?overview=false';

		 $.ajax( {
			    type:'Get',
			    url:url,
			    dataType: 'json',
			    success:function (responseData, textStatus, errorThrown) {
			    	var distance = Number((responseData.routes[0].distance /1000).toFixed(1));

			    	var minutes = Math.floor( responseData.routes[0].duration / 60);
    				var hours = Math.floor( minutes / 60);          ;

    				var time = minutes;
    				if(hours>0) time = "" + hours +":"+minutes;

					var depart = $('#departureTime').val().replace('à','').split(" ")[1];
					var arrivee = $('#arrivalTime').val().replace('à','').split(" ")[1];
					var minuteDepart = depart.split(":")[1];
					var hourDepart = depart.split(":")[0];

					var minuteArival = arrivee.split(":")[1];
					var hourArival = arrivee.split(":")[0];

					var couldGo = true;
					var diffHour = 0;
					var diffMinutes = 0;
					if(hourArival>=hourDepart)
					{
						diffHour = (60 * parseFloat(hourArival)) - (60 * parseFloat(hourDepart)) ;
						diffMinutes =  parseFloat(minuteArival) - parseFloat(minuteDepart)   + diffHour;
						if(minutes > diffMinutes)
							couldGo = false;
					}else{
						couldGo = false;
					}

					if(!couldGo){
						toastr.warning("La durée de la course demandée ne peut pas être satistfaite")
					}else{

					toastr.info("Distance : " + distance + " km
" + "Durée : " + time+ "min")
					}
			    	},
		    	error: function (responseData, textStatus, errorThrown) {
		   		    alert('Erruer de recuperation du résultat!');
		    	}

			});
		  	*/ ////: end ajax
	 });

}


text:
These are the active contributors of this project that you may contact if there is anything you need help with or if you have suggestions.

- [z3t0](https://github.com/z3t0) : Active Contributor and currently also the main contributor.
  * Email: zetoslab@gmail.com
- [shirriff](https://github.com/shirriff) : An amazing person who worked to create this awesome library and provide unending support
- [AnalysIR](https:/github.com/AnalysIR): Active contributor and is amazing with providing support!
- [Informatic](https://github.com/Informatic) : Active contributor
- [fmeschia](https://github.com/fmeschia) : Active contributor
- [PaulStoffregen](https://github.com/paulstroffregen) : Active contributor
- [crash7](https://github.com/crash7) : Active contributor
- [Neco777](https://github.com/neco777) : Active contributor
- [Lauszus](https://github.com/lauszus) : Active contributor
- [csBlueChip](https://github.com/csbluechip) : Active contributor, who contributed major and vital changes to the code base.
- [Sebazzz](https://github.com/sebazz): Contributor
- [lumbric](https://github.com/lumbric): Contributor
- [ElectricRCAircraftGuy](https://github.com/electricrcaircraftguy): Active Contributor
- [philipphenkel](https://github.com/philipphenkel): Active Contributor
- [MCUdude](https://github.com/MCUdude): Contributor
- [marcmerlin](https://github.com/marcmerlin): Contributor (ESP32 port)
- [bengtmartensson](https://github.com/bengtmartensson): Active Contributor
- [MrBryonMiller](https://github.com/MrBryonMiller): Contributor

Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed.


text:
import $ from 'jquery';
import io from 'socket.io-client';

import handlers from './handlers';

const socket = $('meta[name="socket-url"]').attr('content');
const jwt = $('meta[name="jwt"]').attr('content');

const listener = io.connect(socket, {
  query: `jwt=${jwt}`,
  transports: ['websocket', 'polling'],
});

let hasConnectionError = false;

// FIXME: Make these easier to test
listener.on('connect_error', () => {
  if (!hasConnectionError) {
    $('#socket_offline').show();
  }

  hasConnectionError = true;
});

listener.on('connect', () => {
  $('#socket_offline').hide();
  hasConnectionError = false;
});

listener.on('reconnect', () => {
  $('#socket_offline').hide();
  hasConnectionError = false;
});

export default handlers(listener);


text:
package gr.forth.ics.util;

public class Args {
    private static final String GT = " must be greater than ";
    private static final String GTE = " must be greater or equal to ";
    private static final String LT = " must be less than ";
    private static final String LTE = " must be less or equal to ";

    private static final String EQUALS = " must be equal to ";

    public static void doesNotContainNull(Iterable<?> iterable) {
        notNull(iterable);
        for (Object o : iterable) {
            notNull("Iterable contains null", o);
        }
    }

    public static void isTrue(boolean condition) {
        isTrue("Condition failed", condition);
    }

    public static void isTrue(String msg, boolean condition) {
        if (!condition) {
            throw new RuntimeException(msg);
        }
    }

    public static void notNull(Object o) {
        notNull(null, o);
    }

    public static void notNull(String arg, Object o) {
        if (arg == null) {
            arg = "Argument";
        }
        if (o == null) {
            throw new IllegalArgumentException(arg + " is null");
        }
    }

    public static void notNull(Object... args) {
        notNull(null, args);
    }

    public static void notNull(String message, Object... args) {
        if (message == null) {
            message = "Some argument";
        }
        for (Object o : args) {
            notNull(message, o);
        }
    }

    public static void notEmpty(Iterable<?> iter) {
        notEmpty(null, iter);
    }

    public static void notEmpty(String arg, Iterable<?> iter) {
        if (arg == null) {
            arg = "Iterable";
        }
        notNull(iter);
        if (iter.iterator().hasNext()) return;
        throw new IllegalArgumentException(arg + " is empty");
    }

    public static void hasNoNull(Iterable<?> iter) {
        hasNoNull(null, iter);
    }

    public static void hasNoNull(String arg, Iterable<?> iter) {
        notNull(iter);
        if (arg == null) {
            arg = "Iterable";
        }
        for (Object o : iter) {
            if (o == null) {
                throw new IllegalArgumentException(arg + " contains null");
            }
        }
    }

    public static void equals(int value, int expected) {
        if (value == expected) return;
        throw new IllegalArgumentException(value + EQUALS + expected);
    }

    public static void equals(long value, long expected) {
        if (value == expected) return;
        throw new IllegalArgumentException(value + EQUALS + expected);
    }

    public static void equals(double value, double expected) {
        if (value == expected) return;
        throw new IllegalArgumentException(value + EQUALS + expected);
    }

    public static void equals(float value, float expected) {
        if (value == expected) return;
        throw new IllegalArgumentException(value + EQUALS + expected);
    }

    public static void equals(char value, char expected) {
        if (value == expected) return;
        throw new IllegalArgumentException(value + EQUALS + expected);
    }

    public static void equals(short value, short expected) {
        if (value == expected) return;
        throw new IllegalArgumentException(value + EQUALS + expected);
    }

    public static void equals(byte value, byte expected) {
        if (value == expected) return;
        throw new IllegalArgumentException(value + EQUALS + expected);
    }

    public static void equals(Object value, Object expected) {
        if (value == expected || value.equals(expected)) return;
        throw new IllegalArgumentException(value + EQUALS + expected);
    }

    public static void gt(int value, int from) {
        if (value > from) return;
        throw new IllegalArgumentException(value + GT + from);
    }

    public static void lt(int value, int from) {
        if (value < from) return;
        throw new IllegalArgumentException(value + LT + from);
    }

    public static void gte(int value, int from) {
        if (value >= from) return;
        throw new IllegalArgumentException(value + GTE + from);
    }

    public static void lte(int value, int from) {
        if (value <= from) return;
        throw new IllegalArgumentException(value + LTE + from);
    }

    public static void gt(long value, long from) {
        if (value > from) return;
        throw new IllegalArgumentException(value + GT + from);
    }

    public static void lt(long value, long from) {
        if (value < from) return;
        throw new IllegalArgumentException(value + LT + from);
    }

    public static void gte(long value, long from) {
        if (value >= from) return;
        throw new IllegalArgumentException(value + GTE + from);
    }

    public static void lte(long value, long from) {
        if (value <= from) return;
        throw new IllegalArgumentException(value + LTE + from);
    }

    public static void gt(short value, short from) {
        if (value > from) return;
        throw new IllegalArgumentException(value + GT + from);
    }

    public static void lt(short value, short from) {
        if (value < from) return;
        throw new IllegalArgumentException(value + LT + from);
    }

    public static void gte(short value, short from) {
        if (value >= from) return;
        throw new IllegalArgumentException(value + GTE + from);
    }

    public static void lte(short value, short from) {
        if (value <= from) return;
        throw new IllegalArgumentException(value + LTE + from);
    }

    public static void gt(byte value, byte from) {
        if (value > from) return;
        throw new IllegalArgumentException(value + GT + from);
    }

    public static void lt(byte value, byte from) {
        if (value < from) return;
        throw new IllegalArgumentException(value + LT + from);
    }

    public static void gte(byte value, byte from) {
        if (value >= from) return;
        throw new IllegalArgumentException(value + GTE + from);
    }

    public static void lte(byte value, byte from) {
        if (value <= from) return;
        throw new IllegalArgumentException(value + LTE + from);
    }

    public static void gt(char value, char from) {
        if (value > from) return;
        throw new IllegalArgumentException(value + GT + from);
    }

    public static void lt(char value, char from) {
        if (value < from) return;
        throw new IllegalArgumentException(value + LT + from);
    }

    public static void gte(char value, char from) {
        if (value >= from) return;
        throw new IllegalArgumentException(value + GTE + from);
    }

    public static void lte(char value, char from) {
        if (value <= from) return;
        throw new IllegalArgumentException(value + LTE + from);
    }

    public static void gt(double value, double from) {
        if (value > from) return;
        throw new IllegalArgumentException(value + GT + from);
    }

    public static void lt(double value, double from) {
        if (value < from) return;
        throw new IllegalArgumentException(value + LT + from);
    }

    public static void gte(double value, double from) {
        if (value >= from) return;
        throw new IllegalArgumentException(value + GTE + from);
    }

    public static void lte(double value, double from) {
        if (value <= from) return;
        throw new IllegalArgumentException(value + LTE + from);
    }

    public static void gt(float value, float from) {
        if (value > from) return;
        throw new IllegalArgumentException(value + GT + from);
    }

    public static void lt(float value, float from) {
        if (value < from) return;
        throw new IllegalArgumentException(value + LT + from);
    }

    public static void gte(float value, float from) {
        if (value >= from) return;
        throw new IllegalArgumentException(value + GTE + from);
    }

    public static void lte(float value, float from) {
        if (value <= from) return;
        throw new IllegalArgumentException(value + LTE + from);
    }

    public static <T> void gt(Comparable<T> c1, T c2) {
        if (c1.compareTo(c2) > 0) return;
        throw new IllegalArgumentException(c1 + GT + c2);
    }

    public static <T> void lt(Comparable<T> c1, T c2) {
        if (c1.compareTo(c2) < 0) return;
        throw new IllegalArgumentException(c1 + LT + c2);
    }

    public static <T> void gte(Comparable<T> c1, T c2) {
        if (c1.compareTo(c2) >= 0) return;
        throw new IllegalArgumentException(c1 + GTE + c2);
    }

    public static <T> void lte(Comparable<T> c1, T c2) {
        if (c1.compareTo(c2) <= 0) return;
        throw new IllegalArgumentException(c1 + LTE + c2);
    }

    public static <T> void inRangeII(Comparable<T> value, T from, T to) {
        gte(value, from);
        lte(value, to);
    }

    public static <T> void inRangeEE(Comparable<T> value, T from, T to) {
        gt(value, from);
        lt(value, to);
    }

    public static <T> void inRangeIE(Comparable<T> value, T from, T to) {
        gt(value, from);
        lt(value, to);
    }

    public static <T> void inRangeEI(Comparable<T> value, T from, T to) {
        gt(value, from);
        lte(value, to);
    }

    public static void inRangeII(int value, int from, int to) {
        gte(value, from);
        lte(value, to);
    }

    public static void inRangeEE(int value, int from, int to) {
        gt(value, from);
        lt(value, to);
    }

    public static void inRangeIE(int value, int from, int to) {
        gte(value, from);
        lt(value, to);
    }

    public static void inRangeEI(int value, int from, int to) {
        gt(value, from);
        lte(value, to);
    }

    public static void inRangeII(long value, long from, long to) {
        gte(value, from);
        lte(value, to);
    }

    public static void inRangeEE(long value, long from, long to) {
        gt(value, from);
        lt(value, to);
    }

    public static void inRangeIE(long value, long from, long to) {
        gte(value, from);
        lt(value, to);
    }

    public static void inRangeEI(long value, long from, long to) {
        gt(value, from);
        lte(value, to);
    }

    public static void inRangeII(short value, short from, short to) {
        gte(value, from);
        lte(value, to);
    }

    public static void inRangeEE(short value, short from, short to) {
        gt(value, from);
        lt(value, to);
    }

    public static void inRangeIE(short value, short from, short to) {
        gte(value, from);
        lt(value, to);
    }

    public static void inRangeEI(short value, short from, short to) {
        gt(value, from);
        lte(value, to);
    }

    public static void inRangeII(byte value, byte from, byte to) {
        gte(value, from);
        lte(value, to);
    }

    public static void inRangeEE(byte value, byte from, byte to) {
        gt(value, from);
        lt(value, to);
    }

    public static void inRangeIE(byte value, byte from, byte to) {
        gte(value, from);
        lt(value, to);
    }

    public static void inRangeEI(byte value, byte from, byte to) {
        gt(value, from);
        lte(value, to);
    }

    public static void check(boolean assertion, String messageIfFailed) {
        if (!assertion) {
            throw new RuntimeException(messageIfFailed);
        }
    }
}


text:
<?php

namespace tests;

use roboapp\tree\NestedSetsBehavior;
use roboapp\tree\NestedSetsException;
use tests\models\Tree;
use yii\db\Connection;

/**
 * NestedSetsBehaviorTest
 */
class NestedSetsBehaviorTest extends TreeBehaviorTest
{
    protected $location = __DIR__ . '/data/nested-sets';

    protected $exceptionClass = NestedSetsException::class;

    public function testIsRoot()
    {
        $this->assertTrue($this->findOneTreeModel(1)->isRoot());
        $this->assertFalse($this->findOneTreeModel(16)->isRoot());
    }

    public function testMakeRootExists()
    {
        $this->expectException(NestedSetsException::class);

        $node = $this->findOneTreeModel(10);
        $node->name = 'Updated node 2';
        $node->makeRoot()->save();
    }

    public function testMakeRootOther()
    {
        $this->expectException($this->exceptionClass);

        $node = $this->createTreeModel(['name' => 'Root']);
        $node->makeRoot()->save();
    }

    public function testInsertBeforeNewExceptionWhenTargetIsRoot()
    {
        $this->expectException($this->exceptionClass);

        $node = $this->createTreeModel(['name' => 'New node']);
        $node->insertBefore($this->findOneTreeModel(1))->save();
    }

    public function testInsertAfterNewExceptionWhenTargetIsRoot()
    {
        $this->expectException($this->exceptionClass);

        $node = $this->createTreeModel(['name' => 'New node']);
        $node->insertAfter($this->findOneTreeModel(1))->save();
    }

    public function testDelete()
    {
        $this->findOneTreeModel(9)->delete();
    }

    /**
     * @inheritdoc
     */
    protected function createTreeModel($options = [])
    {
        $model = new Tree($options);
        $model->attachBehavior('nestedSets', NestedSetsBehavior::class);

        return $model;
    }

    /**
     * @param $pk
     * @return Tree
     */
    protected function findOneTreeModel($pk)
    {
        $model = forward_static_call([$this->createTreeModel(), 'findOne'], $pk);
        if ($model) {
            $model->attachBehavior('nestedSets', NestedSetsBehavior::class);
        }

        return $model;
    }

    /**
     * @inheritdoc
     */
    public static function setUpBeforeClass()
    {
        try {
            \Yii::$app->set('db', [
                'class' => Connection::className(),
                'dsn' => 'sqlite::memory:',
            ]);

            \Yii::$app->getDb()->open();
            $lines = explode(';', file_get_contents(__DIR__ . '/migrations/nested-sqlite.sql'));

            foreach ($lines as $line) {
                if (trim($line) !== '') {
                    \Yii::$app->getDb()->pdo->exec($line);
                }
            }
        } catch (\Exception $e) {
            \Yii::$app->clear('db');
        }
    }
}


text:
'use strict';

require('../support/test-helper');

var assert = require('assert');
var errorMiddleware = require('../../lib/api/middlewares/error-middleware');

describe('error-middleware', function () {
    it('different formats for postgis plugin error returns 400 as status code', function () {
        var expectedStatusCode = 400;
        assert.strictEqual(
            errorMiddleware.findStatusCode('Postgis Plugin: ERROR:  column "missing" does not exist\n'),
            expectedStatusCode,
            'Error status code for single line does not match'
        );

        assert.strictEqual(
            errorMiddleware.findStatusCode('Postgis Plugin: PSQL error:\nERROR:  column "missing" does not exist\n'),
            expectedStatusCode,
            'Error status code for multiline/PSQL does not match'
        );
    });
});