text
stringlengths 2
99.9k
| meta
dict |
---|---|
//
// main.m
// EMAccordionTableViewController
//
// Created by Ennio Masi on 10/01/14.
// Copyright (c) 2014 EM. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
| {
"pile_set_name": "Github"
} |
# This is a simple smoke test
# of the file_line resource type.
# ! alert
# ? question
file { '/tmp/dansfile':
ensure => file,
}
-> file_line { 'dans_line':
line => 'dan is awesome',
path => '/tmp/dansfile',
}
| {
"pile_set_name": "Github"
} |
require 'test_helper'
require 'metriks/timer'
class TimerTest < Test::Unit::TestCase
def setup
@timer = Metriks::Timer.new
end
def teardown
@timer.stop
end
def test_timer
3.times do
@timer.time do
sleep 0.1
end
end
assert_in_delta 0.1, @timer.mean, 0.01
assert_in_delta 0.1, @timer.snapshot.median, 0.01
end
def test_timer_without_block
t = @timer.time
sleep 0.1
t.stop
assert_in_delta 0.1, @timer.mean, 0.01
end
end | {
"pile_set_name": "Github"
} |
#include "ByteCodeRunner.h"
#include "RunnerMacros.h"
@interface TimerCallbackObject : NSObject {
@private
ByteCodeRunner * Runner;
}
- (id) initWithRunner: (ByteCodeRunner*) rnr;
- (void) fire: (NSNumber *) root;
@end
class iosTimerSupport : public NativeMethodHost
{
public:
iosTimerSupport(ByteCodeRunner *Runner);
~iosTimerSupport();
protected:
NativeFunction *MakeNativeFunction(const char *name, int num_args);
void OnRunnerReset(bool inDestructor);
private:
ByteCodeRunner* Runner;
TimerCallbackObject * CallbackObject;
DECLARE_NATIVE_METHOD(Timer);
};
| {
"pile_set_name": "Github"
} |
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/tips.css">
</head>
<body>
<p>You can easily open an external file for editing, if you just drag it from the Explorer or Finder to the editor.</p>
<p class="image"><img src="images/dragToOpen.png"></p>
</body>
</html>
| {
"pile_set_name": "Github"
} |
/******************************************************************************
**
** FILE NAME : ifxmips_async_aes.c
** PROJECT : IFX UEIP
** MODULES : DEU Module
**
** DATE : October 11, 2010
** AUTHOR : Mohammad Firdaus
** DESCRIPTION : Data Encryption Unit Driver for AES Algorithm
** COPYRIGHT : Copyright (c) 2010
** Infineon Technologies AG
** Am Campeon 1-12, 85579 Neubiberg, Germany
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** HISTORY
** $Date $Author $Comment
** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
** 11, Oct 2010 Mohammad Firdaus Kernel Port incl. Async. Ablkcipher mode
** 21,March 2011 Mohammad Firdaus Changes for Kernel 2.6.32 and IPSec integration
*******************************************************************************/
/*!
\defgroup IFX_DEU IFX_DEU_DRIVERS
\ingroup API
\brief ifx DEU driver module
*/
/*!
\file ifxmips_async_aes.c
\ingroup IFX_DEU
\brief AES Encryption Driver main file
*/
/*!
\defgroup IFX_AES_FUNCTIONS IFX_AES_FUNCTIONS
\ingroup IFX_DEU
\brief IFX AES driver Functions
*/
#include <linux/wait.h>
#include <linux/crypto.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <crypto/ctr.h>
#include <crypto/aes.h>
#include <crypto/algapi.h>
#include <crypto/scatterwalk.h>
#include <asm/ifx/ifx_regs.h>
#include <asm/ifx/ifx_types.h>
#include <asm/ifx/common_routines.h>
#include <asm/ifx/irq.h>
#include <asm/ifx/ifx_pmu.h>
#include <asm/ifx/ifx_gpio.h>
#include <asm/kmap_types.h>
#include "ifxmips_deu.h"
#if defined(CONFIG_DANUBE)
#include "ifxmips_deu_danube.h"
extern int ifx_danube_pre_1_4;
#elif defined(CONFIG_AR9)
#include "ifxmips_deu_ar9.h"
#elif defined(CONFIG_VR9) || defined(CONFIG_AR10)
#include "ifxmips_deu_vr9.h"
#else
#error "Unkown platform"
#endif
/* DMA related header and variables */
spinlock_t aes_lock;
#define CRTCL_SECT_INIT spin_lock_init(&aes_lock)
#define CRTCL_SECT_START spin_lock_irqsave(&aes_lock, flag)
#define CRTCL_SECT_END spin_unlock_irqrestore(&aes_lock, flag)
/* Definition of constants */
//#define AES_START IFX_AES_CON
#define AES_MIN_KEY_SIZE 16
#define AES_MAX_KEY_SIZE 32
#define AES_BLOCK_SIZE 16
#define CTR_RFC3686_NONCE_SIZE 4
#define CTR_RFC3686_IV_SIZE 8
#define CTR_RFC3686_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE)
#ifdef CRYPTO_DEBUG
extern char debug_level;
#define DPRINTF(level, format, args...) if (level < debug_level) printk(KERN_INFO "[%s %s %d]: " format, __FILE__, __func__, __LINE__, ##args);
#else
#define DPRINTF(level, format, args...)
#endif /* CRYPTO_DEBUG */
static int disable_multiblock = 0;
module_param(disable_multiblock, int, 0);
static int disable_deudma = 1;
/* Function decleration */
int aes_chip_init(void);
u32 endian_swap(u32 input);
u32 input_swap(u32 input);
u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
int aes_memory_allocate(int value);
int des_memory_allocate(int value);
void memory_release(u32 *addr);
struct aes_ctx {
int key_length;
u32 buf[AES_MAX_KEY_SIZE];
u8 nonce[CTR_RFC3686_NONCE_SIZE];
};
struct aes_container {
u8 *iv;
u8 *src_buf;
u8 *dst_buf;
int mode;
int encdec;
int complete;
int flag;
u32 bytes_processed;
u32 nbytes;
struct ablkcipher_request arequest;
};
aes_priv_t *aes_queue;
extern deu_drv_priv_t deu_dma_priv;
void hexdump(unsigned char *buf, unsigned int len)
{
print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
16, 1,
buf, len, false);
}
/*! \fn void lq_deu_aes_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg, u8 *iv_arg,
size_t nbytes, int encdec, int mode)
* \ingroup IFX_AES_FUNCTIONS
* \brief main interface to AES hardware
* \param ctx_arg crypto algo context
* \param out_arg output bytestream
* \param in_arg input bytestream
* \param iv_arg initialization vector
* \param nbytes length of bytestream
* \param encdec 1 for encrypt; 0 for decrypt
* \param mode operation mode such as ebc, cbc, ctr
*
*/
static int lq_deu_aes_core (void *ctx_arg, u8 *out_arg, const u8 *in_arg,
u8 *iv_arg, size_t nbytes, int encdec, int mode)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
volatile struct aes_t *aes = (volatile struct aes_t *) AES_START;
struct aes_ctx *ctx = (struct aes_ctx *)ctx_arg;
u32 *in_key = ctx->buf;
unsigned long flag;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
int key_len = ctx->key_length;
volatile struct deu_dma_t *dma = (struct deu_dma_t *) IFX_DEU_DMA_CON;
struct dma_device_info *dma_device = ifx_deu[0].dma_device;
deu_drv_priv_t *deu_priv = (deu_drv_priv_t *)dma_device->priv;
int wlen = 0;
//u32 *outcopy = NULL;
u32 *dword_mem_aligned_in = NULL;
CRTCL_SECT_START;
/* 128, 192 or 256 bit key length */
aes->controlr.K = key_len / 8 - 2;
if (key_len == 128 / 8) {
aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
}
else if (key_len == 192 / 8) {
aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
}
else if (key_len == 256 / 8) {
aes->K7R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 0));
aes->K6R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 1));
aes->K5R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 2));
aes->K4R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 3));
aes->K3R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 4));
aes->K2R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 5));
aes->K1R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 6));
aes->K0R = DEU_ENDIAN_SWAP(*((u32 *) in_key + 7));
}
else {
printk (KERN_ERR "[%s %s %d]: Invalid key_len : %d\n", __FILE__, __func__, __LINE__, key_len);
CRTCL_SECT_END;
return -EINVAL;
}
/* let HW pre-process DEcryption key in any case (even if
ENcryption is used). Key Valid (KV) bit is then only
checked in decryption routine! */
aes->controlr.PNK = 1;
while (aes->controlr.BUS) {
// this will not take long
}
AES_DMA_MISC_CONFIG();
aes->controlr.E_D = !encdec; //encryption
aes->controlr.O = mode; //0 ECB 1 CBC 2 OFB 3 CFB 4 CTR
//aes->controlr.F = 128; //default; only for CFB and OFB modes; change only for customer-specific apps
if (mode > 0) {
aes->IV3R = DEU_ENDIAN_SWAP(*(u32 *) iv_arg);
aes->IV2R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
aes->IV1R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
aes->IV0R = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
};
/* Prepare Rx buf length used in dma psuedo interrupt */
deu_priv->deu_rx_buf = (u32 *)out_arg;
deu_priv->deu_rx_len = nbytes;
/* memory alignment issue */
dword_mem_aligned_in = (u32 *) DEU_DWORD_REORDERING(in_arg, aes_buff_in, BUFFER_IN, nbytes);
dma->controlr.ALGO = 1; //AES
dma->controlr.BS = 0;
aes->controlr.DAU = 0;
dma->controlr.EN = 1;
while (aes->controlr.BUS) {
// wait for AES to be ready
};
deu_priv->outcopy = (u32 *) DEU_DWORD_REORDERING(out_arg, aes_buff_out, BUFFER_OUT, nbytes);
deu_priv->event_src = AES_ASYNC_EVENT;
wlen = dma_device_write (dma_device, (u8 *)dword_mem_aligned_in, nbytes, NULL);
if (wlen != nbytes) {
dma->controlr.EN = 0;
CRTCL_SECT_END;
printk (KERN_ERR "[%s %s %d]: dma_device_write fail!\n", __FILE__, __func__, __LINE__);
return -EINVAL;
}
// WAIT_AES_DMA_READY();
CRTCL_SECT_END;
if (mode > 0) {
*((u32 *) iv_arg) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg));
*((u32 *) iv_arg + 1) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 1));
*((u32 *) iv_arg + 2) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 2));
*((u32 *) iv_arg + 3) = DEU_ENDIAN_SWAP(*((u32 *) iv_arg + 3));
}
return -EINPROGRESS;
}
/* \fn static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
* \ingroup IFX_AES_FUNCTIONS
* \brief Counts and return the number of scatterlists
* \param *sl Function pointer to the scatterlist
* \param total_bytes The total number of bytes that needs to be encrypted/decrypted
* \return The number of scatterlists
*/
static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
{
int i = 0;
do {
total_bytes -= sl[i].length;
i++;
} while (total_bytes > 0);
return i;
}
/* \fn void lq_sg_init(struct scatterlist *src,
* struct scatterlist *dst)
* \ingroup IFX_AES_FUNCTIONS
* \brief Maps the scatterlists into a source/destination page.
* \param *src Pointer to the source scatterlist
* \param *dst Pointer to the destination scatterlist
*/
static void lq_sg_init(struct aes_container *aes_con,struct scatterlist *src,
struct scatterlist *dst)
{
struct page *dst_page, *src_page;
src_page = sg_virt(src);
aes_con->src_buf = (char *) src_page;
dst_page = sg_virt(dst);
aes_con->dst_buf = (char *) dst_page;
}
/* \fn static void lq_sg_complete(struct aes_container *aes_con)
* \ingroup IFX_AES_FUNCTIONS
* \brief Free the used up memory after encryt/decrypt.
*/
static void lq_sg_complete(struct aes_container *aes_con)
{
unsigned long queue_flag;
spin_lock_irqsave(&aes_queue->lock, queue_flag);
kfree(aes_con);
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
}
/* \fn static inline struct aes_container *aes_container_cast (
* struct scatterlist *dst)
* \ingroup IFX_AES_FUNCTIONS
* \brief Locate the structure aes_container in memory.
* \param *areq Pointer to memory location where ablkcipher_request is located
* \return *aes_cointainer The function pointer to aes_container
*/
static inline struct aes_container *aes_container_cast (
struct ablkcipher_request *areq)
{
return container_of(areq, struct aes_container, arequest);
}
/* \fn static int process_next_packet(struct aes_container *aes_con, struct ablkcipher_request *areq,
* \ int state)
* \ingroup IFX_AES_FUNCTIONS
* \brief Process next packet to be encrypt/decrypt
* \param *aes_con AES container structure
* \param *areq Pointer to memory location where ablkcipher_request is located
* \param state The state of the current packet (part of scatterlist or new packet)
* \return -EINVAL: error, -EINPROGRESS: Crypto still running, 1: no more scatterlist
*/
static int process_next_packet(struct aes_container *aes_con, struct ablkcipher_request *areq,
int state)
{
u8 *iv;
int mode, dir, err = -EINVAL;
unsigned long queue_flag;
u32 inc, nbytes, remain, chunk_size;
struct scatterlist *src = NULL;
struct scatterlist *dst = NULL;
struct crypto_ablkcipher *cipher;
struct aes_ctx *ctx;
spin_lock_irqsave(&aes_queue->lock, queue_flag);
dir = aes_con->encdec;
mode = aes_con->mode;
iv = aes_con->iv;
if (state & PROCESS_SCATTER) {
src = scatterwalk_sg_next(areq->src);
dst = scatterwalk_sg_next(areq->dst);
if (!src || !dst) {
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
return 1;
}
}
else if (state & PROCESS_NEW_PACKET) {
src = areq->src;
dst = areq->dst;
}
remain = aes_con->bytes_processed;
chunk_size = src->length;
if (remain > DEU_MAX_PACKET_SIZE)
inc = DEU_MAX_PACKET_SIZE;
else if (remain > chunk_size)
inc = chunk_size;
else
inc = remain;
remain -= inc;
aes_con->nbytes = inc;
if (state & PROCESS_SCATTER) {
aes_con->src_buf += aes_con->nbytes;
aes_con->dst_buf += aes_con->nbytes;
}
lq_sg_init(aes_con, src, dst);
nbytes = aes_con->nbytes;
//printk("debug - Line: %d, func: %s, reqsize: %d, scattersize: %d\n",
// __LINE__, __func__, nbytes, chunk_size);
cipher = crypto_ablkcipher_reqtfm(areq);
ctx = crypto_ablkcipher_ctx(cipher);
if (aes_queue->hw_status == AES_IDLE)
aes_queue->hw_status = AES_STARTED;
aes_con->bytes_processed -= aes_con->nbytes;
err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
if (err == -EBUSY) {
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
printk("Failed to enqueue request, ln: %d, err: %d\n",
__LINE__, err);
return -EINVAL;
}
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
err = lq_deu_aes_core(ctx, aes_con->dst_buf, aes_con->src_buf, iv, nbytes, dir, mode);
return err;
}
/* \fn static void process_queue (unsigned long data)
* \ingroup IFX_AES_FUNCTIONS
* \brief tasklet to signal the dequeuing of the next packet to be processed
* \param unsigned long data Not used
* \return void
*/
static void process_queue(unsigned long data)
{
DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
deu_dma_priv.aes_event_flags);
}
/* \fn static int aes_crypto_thread (void *data)
* \ingroup IFX_AES_FUNCTIONS
* \brief AES thread that handles crypto requests from upper layer & DMA
* \param *data Not used
* \return -EINVAL: DEU failure, -EBUSY: DEU HW busy, 0: exit thread
*/
static int aes_crypto_thread (void *data)
{
struct aes_container *aes_con = NULL;
struct ablkcipher_request *areq = NULL;
int err;
unsigned long queue_flag;
daemonize("lq_aes_thread");
printk("AES Queue Manager Starting\n");
while (1)
{
DEU_WAIT_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
deu_dma_priv.aes_event_flags);
spin_lock_irqsave(&aes_queue->lock, queue_flag);
/* wait to prevent starting a crypto session before
* exiting the dma interrupt thread.
*/
if (aes_queue->hw_status == AES_STARTED) {
areq = ablkcipher_dequeue_request(&aes_queue->list);
aes_con = aes_container_cast(areq);
aes_queue->hw_status = AES_BUSY;
}
else if (aes_queue->hw_status == AES_IDLE) {
areq = ablkcipher_dequeue_request(&aes_queue->list);
aes_con = aes_container_cast(areq);
aes_queue->hw_status = AES_STARTED;
}
else if (aes_queue->hw_status == AES_BUSY) {
areq = ablkcipher_dequeue_request(&aes_queue->list);
aes_con = aes_container_cast(areq);
}
else if (aes_queue->hw_status == AES_COMPLETED) {
lq_sg_complete(aes_con);
aes_queue->hw_status = AES_IDLE;
areq->base.complete(&areq->base, 0);
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
return 0;
}
//printk("debug ln: %d, bytes proc: %d\n", __LINE__, aes_con->bytes_processed);
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
if (!aes_con) {
printk("AES_CON return null\n");
goto aes_done;
}
if (aes_con->bytes_processed == 0) {
goto aes_done;
}
/* Process new packet or the next packet in a scatterlist */
if (aes_con->flag & PROCESS_NEW_PACKET) {
aes_con->flag = PROCESS_SCATTER;
err = process_next_packet(aes_con, areq, PROCESS_NEW_PACKET);
}
else
err = process_next_packet(aes_con, areq, PROCESS_SCATTER);
if (err == -EINVAL) {
areq->base.complete(&areq->base, err);
lq_sg_complete(aes_con);
printk("src/dst returned -EINVAL in func: %s\n", __func__);
}
else if (err > 0) {
printk("src/dst returned zero in func: %s\n", __func__);
goto aes_done;
}
continue;
aes_done:
//printk("debug line - %d, func: %s, qlen: %d\n", __LINE__, __func__, aes_queue->list.qlen);
areq->base.complete(&areq->base, 0);
lq_sg_complete(aes_con);
spin_lock_irqsave(&aes_queue->lock, queue_flag);
if (aes_queue->list.qlen > 0) {
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
tasklet_schedule(&aes_queue->aes_task);
}
else {
aes_queue->hw_status = AES_IDLE;
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
}
} //while(1)
return 0;
}
/* \fn static int lq_aes_queue_mgr(struct aes_ctx *ctx, struct ablkcipher_request *areq,
u8 *iv, int dir, int mode)
* \ingroup IFX_AES_FUNCTIONS
* \brief starts the process of queuing DEU requests
* \param *ctx crypto algo contax
* \param *areq Pointer to the balkcipher requests
* \param *iv Pointer to intput vector location
* \param dir Encrypt/Decrypt
* \mode The mode AES algo is running
* \return 0 if success
*/
static int lq_aes_queue_mgr(struct aes_ctx *ctx, struct ablkcipher_request *areq,
u8 *iv, int dir, int mode)
{
int err = -EINVAL;
unsigned long queue_flag;
struct scatterlist *src = areq->src;
struct scatterlist *dst = areq->dst;
struct aes_container *aes_con = NULL;
u32 remain, inc, nbytes = areq->nbytes;
u32 chunk_bytes = src->length;
aes_con = (struct aes_container *)kmalloc(sizeof(struct aes_container),
GFP_KERNEL);
if (!(aes_con)) {
printk("Cannot allocate memory for AES container, fn %s, ln %d\n",
__func__, __LINE__);
return -ENOMEM;
}
/* AES encrypt/decrypt mode */
if (mode == 5) {
nbytes = AES_BLOCK_SIZE;
chunk_bytes = AES_BLOCK_SIZE;
mode = 0;
}
aes_con->bytes_processed = nbytes;
aes_con->arequest = *(areq);
remain = nbytes;
//printk("debug - Line: %d, func: %s, reqsize: %d, scattersize: %d\n",
// __LINE__, __func__, nbytes, chunk_bytes);
if (remain > DEU_MAX_PACKET_SIZE)
inc = DEU_MAX_PACKET_SIZE;
else if (remain > chunk_bytes)
inc = chunk_bytes;
else
inc = remain;
remain -= inc;
lq_sg_init(aes_con, src, dst);
if (remain <= 0)
aes_con->complete = 1;
else
aes_con->complete = 0;
aes_con->nbytes = inc;
aes_con->iv = iv;
aes_con->mode = mode;
aes_con->encdec = dir;
spin_lock_irqsave(&aes_queue->lock, queue_flag);
if (aes_queue->hw_status == AES_STARTED || aes_queue->hw_status == AES_BUSY ||
aes_queue->list.qlen > 0) {
aes_con->flag = PROCESS_NEW_PACKET;
err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
/* max queue length reached */
if (err == -EBUSY) {
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
printk("Unable to enqueue request ln: %d, err: %d\n", __LINE__, err);
return err;
}
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
return -EINPROGRESS;
}
else if (aes_queue->hw_status == AES_IDLE)
aes_queue->hw_status = AES_STARTED;
aes_con->flag = PROCESS_SCATTER;
aes_con->bytes_processed -= aes_con->nbytes;
/* or enqueue the whole structure so as to get back the info
* at the moment that it's queued. nbytes might be different */
err = ablkcipher_enqueue_request(&aes_queue->list, &aes_con->arequest);
if (err == -EBUSY) {
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
printk("Unable to enqueue request ln: %d, err: %d\n", __LINE__, err);
return err;
}
spin_unlock_irqrestore(&aes_queue->lock, queue_flag);
return lq_deu_aes_core(ctx, aes_con->dst_buf, aes_con->src_buf, iv, inc, dir, mode);
}
/* \fn static int aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
* unsigned int keylen)
* \ingroup IFX_AES_FUNCTIONS
* \brief Sets AES key
* \param *tfm Pointer to the ablkcipher transform
* \param *in_key Pointer to input keys
* \param key_len Length of the AES keys
* \return 0 is success, -EINVAL if bad key length
*/
static int aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
unsigned int keylen)
{
struct aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
unsigned long *flags = (unsigned long *) &tfm->base.crt_flags;
DPRINTF(2, "set_key in %s\n", __FILE__);
if (keylen != 16 && keylen != 24 && keylen != 32) {
*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
return -EINVAL;
}
ctx->key_length = keylen;
DPRINTF(0, "ctx @%p, keylen %d, ctx->key_length %d\n", ctx, keylen, ctx->key_length);
memcpy ((u8 *) (ctx->buf), in_key, keylen);
return 0;
}
/* \fn static int aes_generic_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
* unsigned int keylen)
* \ingroup IFX_AES_FUNCTIONS
* \brief Sets AES key
* \param *tfm Pointer to the ablkcipher transform
* \param *key Pointer to input keys
* \param keylen Length of AES keys
* \return 0 is success, -EINVAL if bad key length
*/
static int aes_generic_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
unsigned int keylen)
{
return aes_setkey(tfm, key, keylen);
}
/* \fn static int rfc3686_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *in_key,
* unsigned int keylen)
* \ingroup IFX_AES_FUNCTIONS
* \brief Sets AES key
* \param *tfm Pointer to the ablkcipher transform
* \param *in_key Pointer to input keys
* \param key_len Length of the AES keys
* \return 0 is success, -EINVAL if bad key length
*/
static int rfc3686_aes_setkey(struct crypto_ablkcipher *tfm,
const u8 *in_key, unsigned int keylen)
{
struct aes_ctx *ctx = crypto_ablkcipher_ctx(tfm);
unsigned long *flags = (unsigned long *)&tfm->base.crt_flags;
DPRINTF(2, "ctr_rfc3686_aes_set_key in %s\n", __FILE__);
memcpy(ctx->nonce, in_key + (keylen - CTR_RFC3686_NONCE_SIZE),
CTR_RFC3686_NONCE_SIZE);
keylen -= CTR_RFC3686_NONCE_SIZE; // remove 4 bytes of nonce
if (keylen != 16 && keylen != 24 && keylen != 32) {
*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
return -EINVAL;
}
ctx->key_length = keylen;
memcpy ((u8 *) (ctx->buf), in_key, keylen);
return 0;
}
/* \fn static int aes_encrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Encrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int aes_encrypt (struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_ENCRYPT, 5);
}
/* \fn static int aes_decrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Decrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int aes_decrypt (struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, NULL, CRYPTO_DIR_DECRYPT, 5);
}
/* \fn static int ecb_aes_decrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Encrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int ecb_aes_encrypt (struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 0);
}
/* \fn static int ecb_aes_decrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Decrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int ecb_aes_decrypt(struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 0);
}
/* \fn static int cbc_aes_encrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Encrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int cbc_aes_encrypt (struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 1);
}
/* \fn static int cbc_aes_decrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Decrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int cbc_aes_decrypt(struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 1);
}
#if 0
static int ofb_aes_encrypt (struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 2);
}
static int ofb_aes_decrypt(struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 2);
}
static int cfb_aes_encrypt (struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 3);
}
static int cfb_aes_decrypt(struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 3);
}
#endif
/* \fn static int ctr_aes_encrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Encrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int ctr_aes_encrypt (struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 4);
}
/* \fn static int ctr_aes_decrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Decrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int ctr_aes_decrypt(struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
return lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 4);
}
/* \fn static int rfc3686_aes_encrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Encrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int rfc3686_aes_encrypt(struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
int ret;
u8 *info = areq->info;
u8 rfc3686_iv[16];
memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, info, CTR_RFC3686_IV_SIZE);
/* initialize counter portion of counter block */
*(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
cpu_to_be32(1);
areq->info = rfc3686_iv;
ret = lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_ENCRYPT, 4);
areq->info = info;
return ret;
}
/* \fn static int rfc3686_aes_decrypt(struct ablkcipher_request *areq)
* \ingroup IFX_AES_FUNCTIONS
* \brief Decrypt function for AES algo
* \param *areq Pointer to ablkcipher request in memory
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
static int rfc3686_aes_decrypt(struct ablkcipher_request *areq)
{
struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq);
struct aes_ctx *ctx = crypto_ablkcipher_ctx(cipher);
int ret;
u8 *info = areq->info;
u8 rfc3686_iv[16];
/* set up counter block */
memcpy(rfc3686_iv, ctx->nonce, CTR_RFC3686_NONCE_SIZE);
memcpy(rfc3686_iv + CTR_RFC3686_NONCE_SIZE, info, CTR_RFC3686_IV_SIZE);
/* initialize counter portion of counter block */
*(__be32 *)(rfc3686_iv + CTR_RFC3686_NONCE_SIZE + CTR_RFC3686_IV_SIZE) =
cpu_to_be32(1);
areq->info = rfc3686_iv;
ret = lq_aes_queue_mgr(ctx, areq, areq->info, CRYPTO_DIR_DECRYPT, 4);
areq->info = info;
return ret;
}
struct lq_aes_alg {
struct crypto_alg alg;
};
/* AES supported algo array */
static struct lq_aes_alg aes_drivers_alg[] = {
{
.alg = {
.cra_name = "aes",
.cra_driver_name = "ifxdeu-aes",
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
.cra_blocksize = AES_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct aes_ctx),
.cra_type = &crypto_ablkcipher_type,
.cra_priority = 300,
.cra_module = THIS_MODULE,
.cra_ablkcipher = {
.setkey = aes_setkey,
.encrypt = aes_encrypt,
.decrypt = aes_decrypt,
.geniv = "eseqiv",
.min_keysize = AES_MIN_KEY_SIZE,
.max_keysize = AES_MAX_KEY_SIZE,
.ivsize = AES_BLOCK_SIZE,
}
}
},{
.alg = {
.cra_name = "ecb(aes)",
.cra_driver_name = "ifxdeu-ecb(aes)",
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
.cra_blocksize = AES_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct aes_ctx),
.cra_type = &crypto_ablkcipher_type,
.cra_priority = 400,
.cra_module = THIS_MODULE,
.cra_ablkcipher = {
.setkey = aes_generic_setkey,
.encrypt = ecb_aes_encrypt,
.decrypt = ecb_aes_decrypt,
.geniv = "eseqiv",
.min_keysize = AES_MIN_KEY_SIZE,
.max_keysize = AES_MAX_KEY_SIZE,
.ivsize = AES_BLOCK_SIZE,
}
}
},{
.alg = {
.cra_name = "cbc(aes)",
.cra_driver_name = "ifxdeu-cbc(aes)",
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
.cra_blocksize = AES_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct aes_ctx),
.cra_type = &crypto_ablkcipher_type,
.cra_priority = 400,
.cra_module = THIS_MODULE,
.cra_ablkcipher = {
.setkey = aes_generic_setkey,
.encrypt = cbc_aes_encrypt,
.decrypt = cbc_aes_decrypt,
.geniv = "eseqiv",
.min_keysize = AES_MIN_KEY_SIZE,
.max_keysize = AES_MAX_KEY_SIZE,
.ivsize = AES_BLOCK_SIZE,
}
}
},{
.alg = {
.cra_name = "ctr(aes)",
.cra_driver_name = "ifxdeu-ctr(aes)",
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
.cra_blocksize = AES_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct aes_ctx),
.cra_type = &crypto_ablkcipher_type,
.cra_priority = 400,
.cra_module = THIS_MODULE,
.cra_ablkcipher = {
.setkey = aes_generic_setkey,
.encrypt = ctr_aes_encrypt,
.decrypt = ctr_aes_decrypt,
.geniv = "eseqiv",
.min_keysize = AES_MIN_KEY_SIZE,
.max_keysize = AES_MAX_KEY_SIZE,
.ivsize = AES_BLOCK_SIZE,
}
}
},{
.alg = {
.cra_name = "rfc3686(ctr(aes))",
.cra_driver_name = "ifxdeu-rfc3686(ctr(aes))",
.cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC,
.cra_blocksize = AES_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct aes_ctx),
.cra_type = &crypto_ablkcipher_type,
.cra_priority = 400,
.cra_module = THIS_MODULE,
.cra_ablkcipher = {
.setkey = rfc3686_aes_setkey,
.encrypt = rfc3686_aes_encrypt,
.decrypt = rfc3686_aes_decrypt,
.geniv = "eseqiv",
.min_keysize = AES_MIN_KEY_SIZE,
.max_keysize = CTR_RFC3686_MAX_KEY_SIZE,
//.max_keysize = AES_MAX_KEY_SIZE,
//.ivsize = CTR_RFC3686_IV_SIZE,
.ivsize = AES_BLOCK_SIZE, // else cannot reg
}
}
}
};
/* \fn int __init lqdeu_async_aes_init (void)
* \ingroup IFX_AES_FUNCTIONS
* \brief Initializes the Async. AES driver
* \return 0 is success, -EINPROGRESS if encryting, EINVAL if failure
*/
int __init lqdeu_async_aes_init (void)
{
int i, j, ret = -EINVAL;
#define IFX_DEU_DRV_VERSION "2.0.0"
printk(KERN_INFO "Lantiq Technologies DEU Driver version %s\n", IFX_DEU_DRV_VERSION);
for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++) {
ret = crypto_register_alg(&aes_drivers_alg[i].alg);
printk("driver: %s\n", aes_drivers_alg[i].alg.cra_name);
if (ret)
goto aes_err;
}
aes_chip_init();
CRTCL_SECT_INIT;
printk (KERN_NOTICE "Lantiq DEU AES initialized %s %s.\n",
disable_multiblock ? "" : " (multiblock)", disable_deudma ? "" : " (DMA)");
return ret;
aes_err:
for (j = 0; j < i; j++)
crypto_unregister_alg(&aes_drivers_alg[j].alg);
printk(KERN_ERR "Lantiq %s driver initialization failed!\n", (char *)&aes_drivers_alg[i].alg.cra_driver_name);
return ret;
ctr_rfc3686_aes_err:
for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++) {
if (!strcmp((char *)&aes_drivers_alg[i].alg.cra_name, "rfc3686(ctr(aes))"))
crypto_unregister_alg(&aes_drivers_alg[j].alg);
}
printk (KERN_ERR "Lantiq ctr_rfc3686_aes initialization failed!\n");
return ret;
}
/*! \fn void __exit ifxdeu_fini_aes (void)
* \ingroup IFX_AES_FUNCTIONS
* \brief unregister aes driver
*/
void __exit lqdeu_fini_async_aes (void)
{
int i;
for (i = 0; i < ARRAY_SIZE(aes_drivers_alg); i++)
crypto_unregister_alg(&aes_drivers_alg[i].alg);
aes_queue->hw_status = AES_COMPLETED;
DEU_WAKEUP_EVENT(deu_dma_priv.deu_thread_wait, AES_ASYNC_EVENT,
deu_dma_priv.aes_event_flags);
kfree(aes_queue);
}
| {
"pile_set_name": "Github"
} |
function($mpt){
var anns = this.meta.$mod$ans$;
if (typeof(anns) === 'function') {
anns = anns();
this.meta.$mod$ans$=anns;
}
if (anns) for (var i=0; i < anns.length; i++) {
if (is$(anns[i],$mpt.Annotation$annotated))return true;
}
return false;
}
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<array>
<string>foreground</string>
<string>glyphs</string>
</array>
<array>
<string>background</string>
<string>glyphs.background</string>
</array>
</array>
</plist>
| {
"pile_set_name": "Github"
} |
require 'rmagick'
hat = Magick::Image.read('images/Flower_Hat.jpg').first
hat.resize!(0.25)
# Construct a pattern using the hat image
gc = Magick::Draw.new
gc.pattern('hat', 0, 0, hat.columns, hat.rows) do
gc.composite(0, 0, 0, 0, hat)
end
# Set the fill to the hat "pattern." Draw an ellipse
gc.fill('hat')
gc.ellipse(150, 75, 140, 70, 0, 360)
# Create a canvas to draw on
img = Magick::Image.new(300, 150, Magick::HatchFill.new('white', 'lightcyan2', 8))
# Draw the ellipse using the fill
gc.draw(img)
img.border!(1, 1, 'lightcyan2')
img.write('pattern2.gif')
exit
| {
"pile_set_name": "Github"
} |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_79) on Wed May 03 07:08:46 PDT 2017 -->
<title>MemoryCache.ResourceRemovedListener (glide 3.8.0 API)</title>
<meta name="date" content="2017-05-03">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="MemoryCache.ResourceRemovedListener (glide 3.8.0 API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../com/bumptech/glide/load/engine/cache/MemoryCache.html" title="interface in com.bumptech.glide.load.engine.cache"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../../com/bumptech/glide/load/engine/cache/MemoryCacheAdapter.html" title="class in com.bumptech.glide.load.engine.cache"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?com/bumptech/glide/load/engine/cache/MemoryCache.ResourceRemovedListener.html" target="_top">Frames</a></li>
<li><a href="MemoryCache.ResourceRemovedListener.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">com.bumptech.glide.load.engine.cache</div>
<h2 title="Interface MemoryCache.ResourceRemovedListener" class="title">Interface MemoryCache.ResourceRemovedListener</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../../../../../com/bumptech/glide/load/engine/Engine.html" title="class in com.bumptech.glide.load.engine">Engine</a></dd>
</dl>
<dl>
<dt>Enclosing interface:</dt>
<dd><a href="../../../../../../com/bumptech/glide/load/engine/cache/MemoryCache.html" title="interface in com.bumptech.glide.load.engine.cache">MemoryCache</a></dd>
</dl>
<hr>
<br>
<pre>public static interface <span class="strong">MemoryCache.ResourceRemovedListener</span></pre>
<div class="block">An interface that will be called whenever a bitmap is removed from the cache.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../../../com/bumptech/glide/load/engine/cache/MemoryCache.ResourceRemovedListener.html#onResourceRemoved(com.bumptech.glide.load.engine.Resource)">onResourceRemoved</a></strong>(<a href="../../../../../../com/bumptech/glide/load/engine/Resource.html" title="interface in com.bumptech.glide.load.engine">Resource</a><?> removed)</code> </td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="onResourceRemoved(com.bumptech.glide.load.engine.Resource)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>onResourceRemoved</h4>
<pre>void onResourceRemoved(<a href="../../../../../../com/bumptech/glide/load/engine/Resource.html" title="interface in com.bumptech.glide.load.engine">Resource</a><?> removed)</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../com/bumptech/glide/load/engine/cache/MemoryCache.html" title="interface in com.bumptech.glide.load.engine.cache"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../../../com/bumptech/glide/load/engine/cache/MemoryCacheAdapter.html" title="class in com.bumptech.glide.load.engine.cache"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../index.html?com/bumptech/glide/load/engine/cache/MemoryCache.ResourceRemovedListener.html" target="_top">Frames</a></li>
<li><a href="MemoryCache.ResourceRemovedListener.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| {
"pile_set_name": "Github"
} |
<?php
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\Block\DatabaseBlockStore;
use MediaWiki\Block\Restriction\NamespaceRestriction;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\MediaWikiServices;
use Psr\Log\NullLogger;
/**
* Integration tests for DatabaseBlockStore.
*
* @author DannyS712
* @group Blocking
* @group Database
* @covers \MediaWiki\Block\DatabaseBlockStore
*/
class DatabaseBlockStoreTest extends MediaWikiIntegrationTestCase {
/** @var User */
private $sysop;
/** @var integer */
private $expiredBlockId = 11111;
/** @var integer */
private $unexpiredBlockId = 22222;
/** @var integer */
private $autoblockId = 33333;
/**
* @param array $options
* - config: Override the ServiceOptions config
* - constructorArgs: Override the constructor arguments
* @return DatabaseBlockStore
*/
private function getStore( array $options = [] ) : DatabaseBlockStore {
$overrideConfig = $options['config'] ?? [];
$overrideConstructorArgs = $options['constructorArgs'] ?? [];
$defaultConfig = [
'PutIPinRC' => true,
'BlockDisablesLogin' => false,
];
$config = array_merge( $defaultConfig, $overrideConfig );
// This ensures continuation after hooks
$hookContainer = $this->createMock( HookContainer::class );
$hookContainer->method( 'run' )
->willReturn( true );
// Most tests need read only to be false
$readOnlyMode = $this->createMock( ReadOnlyMode::class );
$readOnlyMode->method( 'isReadOnly' )
->willReturn( false );
$services = MediaWikiServices::getInstance();
$defaultConstructorArgs = [
'serviceOptions' => new ServiceOptions(
DatabaseBlockStore::CONSTRUCTOR_OPTIONS,
$config
),
'logger' => new NullLogger(),
'actorMigration' => $services->getActorMigration(),
'blockRestrictionStore' => $services->getBlockRestrictionStore(),
'commentStore' => $services->getCommentStore(),
'hookContainer' => $hookContainer,
'loadBalancer' => $services->getDBLoadBalancer(),
'readOnlyMode' => $readOnlyMode,
];
$constructorArgs = array_merge( $defaultConstructorArgs, $overrideConstructorArgs );
return new DatabaseBlockStore( ...array_values( $constructorArgs ) );
}
/**
* @param array $options
* - target: The intended target, an unblocked user by default
* - autoblock: Whether this block is autoblocking
* @return DatabaseBlock
*/
private function getBlock( array $options = [] ) : DatabaseBlock {
$target = $options['target'] ?? $this->getTestUser()->getUser();
$autoblock = $options['autoblock'] ?? false;
return new DatabaseBlock( [
'by' => $this->sysop->getId(),
'address' => $target,
'enableAutoblock' => $autoblock,
] );
}
/**
* Check that an autoblock corresponds to a parent block. The following are not
* required to be equal, so are not tested:
* - target
* - type
* - expiry
* - autoblocking
*
* @param DatabaseBlock $block
* @param DatabaseBlock $autoblock
*/
private function assertAutoblockEqualsBlock(
DatabaseBlock $block,
DatabaseBlock $autoblock
) {
$this->assertSame( $autoblock->getParentBlockId(), $block->getId() );
$this->assertSame( $autoblock->isHardblock(), $block->isHardblock() );
$this->assertSame( $autoblock->isCreateAccountBlocked(), $block->isCreateAccountBlocked() );
$this->assertSame( $autoblock->getHideName(), $block->getHideName() );
$this->assertSame( $autoblock->isEmailBlocked(), $block->isEmailBlocked() );
$this->assertSame( $autoblock->isUsertalkEditAllowed(), $block->isUsertalkEditAllowed() );
$this->assertSame( $autoblock->isSitewide(), $block->isSitewide() );
$restrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
$this->assertTrue(
$restrictionStore->equals(
$autoblock->getRestrictions(),
$block->getRestrictions()
)
);
}
/**
* @dataProvider provideInsertBlockSuccess
*/
public function testInsertBlockSuccess( $options ) {
$block = $this->getBlock( $options['block'] ?? [] );
$block->setRestrictions( [
new NamespaceRestriction( 0, NS_MAIN ),
] );
$store = $this->getStore( $options['store'] ?? [] );
$result = $store->insertBlock( $block );
$this->assertIsArray( $result );
$this->assertArrayHasKey( 'id', $result );
$this->assertArrayHasKey( 'autoIds', $result );
$this->assertSame( 0, count( $result['autoIds'] ) );
$retrievedBlock = DatabaseBlock::newFromId( $result['id'] );
$this->assertTrue( $block->equals( $retrievedBlock ) );
}
public function provideInsertBlockSuccess() {
return [
'No conflicting block, not autoblocking' => [
'block' => [
'autoblock' => false,
],
],
'No conflicting block, autoblocking but IP not in recent changes' => [
[
'block' => [
'autoblock' => true,
],
'store' => [
'constructorArgs' => [
'PutIPinRC' => false,
],
],
],
],
'No conflicting block, autoblocking but no recent edits' => [
'block' => [
'autoblock' => true,
],
],
'Conflicting block, expired' => [
'block' => [
// Blocked with expired block in addDBData
'target' => '1.1.1.1',
],
],
];
}
public function testInsertBlockConflict() {
$block = $this->getBlock( [ 'target' => $this->sysop ] );
$store = $this->getStore();
$result = $store->insertBlock( $block );
$this->assertFalse( $result );
$this->assertNull( $block->getId() );
}
/**
* @dataProvider provideInsertBlockLogout
*/
public function testInsertBlockLogout( $options, $expectTokenEqual ) {
$block = $this->getBlock();
$targetToken = $block->getTarget()->getToken();
$store = $this->getStore( $options );
$result = $store->insertBlock( $block );
$this->assertSame(
$expectTokenEqual,
$targetToken === $block->getTarget()->getToken()
);
}
public function provideInsertBlockLogout() {
return [
'Blocked user can log in' => [
[
'config' => [
'BlockDisablesLogin' => false,
],
],
true,
],
'Blocked user cannot log in' => [
[
'config' => [
'BlockDisablesLogin' => true,
],
],
false,
],
];
}
public function testInsertBlockAutoblock() {
// This is quicker than adding a recent change for an unblocked user.
// See addDBDataOnce documentation for more details.
$target = $this->sysop;
$this->db->delete(
'ipblocks',
[ 'ipb_address' => $target->getName() ]
);
$block = $this->getBlock( [
'autoblock' => true,
'target' => $target,
] );
$store = $this->getStore();
$result = $store->insertBlock( $block );
$this->assertIsArray( $result );
$this->assertArrayHasKey( 'autoIds', $result );
$this->assertCount( 1, $result['autoIds'] );
$retrievedBlock = DatabaseBlock::newFromId( $result['autoIds'][0] );
$this->assertSame( $block->getId(), $retrievedBlock->getParentBlockId() );
$this->assertAutoblockEqualsBlock( $block, $retrievedBlock );
}
public function testInsertBlockError() {
$block = $this->createMock( DatabaseBlock::class );
$this->expectException( MWException::class );
$this->expectExceptionMessage( 'insert' );
$store = $this->getStore();
$store->insertBlock( $block );
}
public function testUpdateBlock() {
$existingBlock = DatabaseBlock::newFromTarget( $this->sysop );
$existingBlock->isUsertalkEditAllowed( true );
$store = $this->getStore();
$result = $store->updateBlock( $existingBlock );
$updatedBlock = DatabaseBlock::newFromId( $result['id'] );
$autoblock = DatabaseBlock::newFromId( $result['autoIds'][0] );
$this->assertTrue( $updatedBlock->equals( $existingBlock ) );
$this->assertAutoblockEqualsBlock( $existingBlock, $autoblock );
}
public function testUpdateBlockAddOrRemoveAutoblock() {
// Existing block is autoblocking to begin with
$existingBlock = DatabaseBlock::newFromTarget( $this->sysop );
$existingBlock->isAutoblocking( false );
$store = $this->getStore();
$result = $store->updateBlock( $existingBlock );
$updatedBlock = DatabaseBlock::newFromId( $result['id'] );
$this->assertTrue( $updatedBlock->equals( $existingBlock ) );
$this->assertCount( 0, $result['autoIds'] );
// Test adding an autoblock in the same test run, since we need the
// target to be the sysop (see addDBDataOnce documentation), and the
// sysop is blocked with an autoblock between test runs.
$existingBlock->isAutoblocking( true );
$result = $store->updateBlock( $existingBlock );
$updatedBlock = DatabaseBlock::newFromId( $result['id'] );
$autoblock = DatabaseBlock::newFromId( $result['autoIds'][0] );
$this->assertTrue( $updatedBlock->equals( $existingBlock ) );
$this->assertAutoblockEqualsBlock( $existingBlock, $autoblock );
}
/**
* @dataProvider provideUpdateBlockRestrictions
*/
public function testUpdateBlockRestrictions( $expectedCount ) {
$existingBlock = DatabaseBlock::newFromTarget( $this->sysop );
$restrictions = [];
for ( $ns = 0; $ns < $expectedCount; $ns++ ) {
$restrictions[] = new NamespaceRestriction( $existingBlock->getId(), $ns );
}
$existingBlock->setRestrictions( $restrictions );
$store = $this->getStore();
$result = $store->updateBlock( $existingBlock );
$retrievedBlock = DatabaseBlock::newFromId( $result['id'] );
$this->assertCount(
$expectedCount,
$retrievedBlock->getRestrictions()
);
}
public function provideUpdateBlockRestrictions() {
return [
'Restrictions deleted if removed' => [ 0 ],
'Restrictions changed if updated' => [ 2 ],
];
}
public function testDeleteBlockSuccess() {
$target = $this->sysop;
$block = DatabaseBlock::newFromTarget( $target );
$store = $this->getStore();
$this->assertTrue( $store->deleteBlock( $block ) );
$this->assertNull( DatabaseBlock::newFromTarget( $target ) );
}
public function testDeleteBlockFailureReadOnly() {
$target = $this->sysop;
$block = DatabaseBlock::newFromTarget( $target );
$readOnlyMode = $this->createMock( ReadOnlyMode::class );
$readOnlyMode->method( 'isReadOnly' )
->willReturn( true );
$store = $this->getStore( [
'constructorArgs' => [
'readOnlyMode' => $readOnlyMode
],
] );
$this->assertFalse( $store->deleteBlock( $block ) );
$this->assertTrue( (bool)DatabaseBlock::newFromTarget( $target ) );
}
public function testDeleteBlockFailureNoBlockId() {
$block = $this->createMock( DatabaseBlock::class );
$block->method( 'getId' )
->willReturn( null );
$this->expectException( MWException::class );
$this->expectExceptionMessage( 'delete' );
$store = $this->getStore();
$store->deleteBlock( $block );
}
/**
* Check whether expired blocks and restrictions were removed from the database.
*
* @param int $blockId
* @param bool $expected Whether to expect to find any rows
*/
private function assertPurgeWorked( int $blockId, bool $expected ) : void {
$blockRows = (bool)$this->db->select(
'ipblocks',
'ipb_id',
[ 'ipb_id' => $blockId ]
)->numRows();
$blockRestrictionsRows = (bool)$this->db->select(
'ipblocks_restrictions',
'ir_ipb_id',
[ 'ir_ipb_id' => $blockId ]
)->numRows();
$this->assertSame( $expected, $blockRows );
$this->assertSame( $expected, $blockRestrictionsRows );
}
public function testPurgeExpiredBlocksSuccess() {
$store = $this->getStore();
$store->purgeExpiredBlocks();
$this->assertPurgeWorked( $this->expiredBlockId, false );
$this->assertPurgeWorked( $this->unexpiredBlockId, true );
}
public function testPurgeExpiredBlocksFailureReadOnly() {
$readOnlyMode = $this->createMock( ReadOnlyMode::class );
$readOnlyMode->method( 'isReadOnly' )
->willReturn( true );
$store = $this->getStore( [
'constructorArgs' => [
'readOnlyMode' => $readOnlyMode,
],
] );
$store->purgeExpiredBlocks();
$this->assertPurgeWorked( $this->expiredBlockId, true );
}
/**
* In order to autoblock a user, they must have a recent change.
*
* Make a recent change for the test sysop. This user persists between test runs,
* so will always have this recent change.
*
* Regular test users don't persist between test runs, because the TestUserRegistry
* is cleared between runs. If we tested autoblocking on a regular test user, we
* would need to make a recent change for each test, which is slow.
*
* Instead we always test autoblocks on the test sysop.
*/
public function addDBDataOnce() {
$this->editPage(
'UTPage', // Added in addCoreDBData
'an edit',
'a summary',
NS_MAIN,
$this->getTestSysop()->getUser()
);
}
/**
* Three blocks are added:
* - an expired block with restrictions, against an IP
* - a current block with restrictions, against a user with recent changes
* - a current autoblock from the current block above
*/
public function addDBData() {
$this->sysop = $this->getTestSysop()->getUser();
// Get a comment ID. One was added in addCoreDBData.
$commentId = $this->db->select(
'comment',
'comment_id'
)->fetchObject()->comment_id;
$commonBlockData = [
'ipb_user' => 0,
'ipb_by_actor' => $this->sysop->getActorId(),
'ipb_reason_id' => $commentId,
'ipb_timestamp' => $this->db->timestamp( '20000101000000' ),
'ipb_auto' => 0,
'ipb_anon_only' => 0,
'ipb_create_account' => 0,
'ipb_enable_autoblock' => 0,
'ipb_expiry' => $this->db->getInfinity(),
'ipb_range_start' => '',
'ipb_range_end' => '',
'ipb_deleted' => 0,
'ipb_block_email' => 0,
'ipb_allow_usertalk' => 0,
'ipb_parent_block_id' => 0,
'ipb_sitewide' => 0,
];
$blockData = [
[
'ipb_id' => $this->expiredBlockId,
'ipb_address' => '1.1.1.1',
'ipb_expiry' => $this->db->timestamp( '20010101000000' ),
],
[
'ipb_id' => $this->unexpiredBlockId,
'ipb_address' => $this->sysop,
'ipb_user' => $this->sysop->getId(),
'ipb_enable_autoblock' => 1,
],
[
'ipb_id' => $this->autoblockId,
'ipb_address' => '2.2.2.2',
'ipb_parent_block_id' => $this->unexpiredBlockId,
],
];
$restrictionData = [
[
'ir_ipb_id' => $this->expiredBlockId,
'ir_type' => 1,
'ir_value' => 1,
],
[
'ir_ipb_id' => $this->unexpiredBlockId,
'ir_type' => 2,
'ir_value' => 2,
],
[
'ir_ipb_id' => $this->autoblockId,
'ir_type' => 2,
'ir_value' => 2,
],
];
foreach ( $blockData as $row ) {
$this->db->insert( 'ipblocks', $row + $commonBlockData );
}
foreach ( $restrictionData as $row ) {
$this->db->insert( 'ipblocks_restrictions', $row );
}
$this->tablesUsed[] = 'ipblocks';
$this->tablesUsed[] = 'ipblocks_restrictions';
}
}
| {
"pile_set_name": "Github"
} |
package registry
import (
"errors"
"fmt"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/watch"
kapi "k8s.io/kubernetes/pkg/api"
kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"github.com/golang/glog"
deployapi "github.com/openshift/origin/pkg/apps/apis/apps"
deployutil "github.com/openshift/origin/pkg/apps/util"
)
var (
// ErrUnknownDeploymentPhase is returned for WaitForRunningDeployment if an unknown phase is returned.
ErrUnknownDeploymentPhase = errors.New("unknown deployment phase")
ErrTooOldResourceVersion = errors.New("too old resource version")
)
// WaitForRunningDeployment waits until the specified deployment is no longer New or Pending. Returns true if
// the deployment became running, complete, or failed within timeout, false if it did not, and an error if any
// other error state occurred. The last observed deployment state is returned.
func WaitForRunningDeployment(rn kcoreclient.ReplicationControllersGetter, observed *kapi.ReplicationController, timeout time.Duration) (*kapi.ReplicationController, bool, error) {
fieldSelector := fields.Set{"metadata.name": observed.Name}.AsSelector()
options := metav1.ListOptions{FieldSelector: fieldSelector.String(), ResourceVersion: observed.ResourceVersion}
w, err := rn.ReplicationControllers(observed.Namespace).Watch(options)
if err != nil {
return observed, false, err
}
defer w.Stop()
if _, err := watch.Until(timeout, w, func(e watch.Event) (bool, error) {
if e.Type == watch.Error {
// When we send too old resource version in observed replication controller to
// watcher, restart the watch with latest available controller.
switch t := e.Object.(type) {
case *metav1.Status:
if t.Reason == metav1.StatusReasonGone {
glog.V(5).Infof("encountered error while watching for replication controller: %v (retrying)", t)
return false, ErrTooOldResourceVersion
}
}
return false, fmt.Errorf("encountered error while watching for replication controller: %v", e.Object)
}
obj, isController := e.Object.(*kapi.ReplicationController)
if !isController {
return false, fmt.Errorf("received unknown object while watching for deployments: %v", obj)
}
observed = obj
switch deployutil.DeploymentStatusFor(observed) {
case deployapi.DeploymentStatusRunning, deployapi.DeploymentStatusFailed, deployapi.DeploymentStatusComplete:
return true, nil
case deployapi.DeploymentStatusNew, deployapi.DeploymentStatusPending:
return false, nil
default:
return false, ErrUnknownDeploymentPhase
}
}); err != nil {
if err == ErrTooOldResourceVersion {
latestRC, err := rn.ReplicationControllers(observed.Namespace).Get(observed.Name, metav1.GetOptions{})
if err != nil {
return observed, false, err
}
return WaitForRunningDeployment(rn, latestRC, timeout)
}
return observed, false, err
}
return observed, true, nil
}
| {
"pile_set_name": "Github"
} |
---
openshift_gcp_project: ''
openshift_gcp_prefix: ''
openshift_gcp_network_name: "{{ openshift_gcp_prefix }}network"
openshift_gcp_multizone: False
| {
"pile_set_name": "Github"
} |
% instance = 10, name = bbob_f001_i21_d40__bbob_f006_i22_d40
% function eval_number | 2 objectives
1 1.300570470813759e+05 1.768573899060141e+08
4 1.178072939445730e+05 1.952959468816856e+08
12 1.175379415255915e+05 2.263008796289749e+08
24 1.327177823981511e+05 1.662908535201634e+08
26 9.048792727954550e+04 1.849616660901090e+08
27 1.443932455449268e+05 9.335551173994991e+07
60 9.403576877850827e+04 1.084299201490567e+08
78 7.956210930569618e+04 1.499706464489916e+08
% evaluations = 80 | {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: 8caca8a5b8fc29241857185d3e2fbaa6
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
{"text": ["$", "cost", "looking", "for", "the", "next", "$", "ati", "$", "utx", "$", "do", "must", "have", "URL"], "created_at": "Sat May 31 09:24:59 +0000 2014", "user_id_str": "2535221254"}
| {
"pile_set_name": "Github"
} |
{
"multi":null,
"text":"@张杰 @林俊杰 @文章同學 ,这分明是一个缠绵悱恻,纠葛凄美的爱情故事啊,你爱我,我爱他,他爱你,你们这样真的好吗[偷笑]",
"user":{
"verified":false,
"description":true,
"gender":"f",
"messages":17993,
"followers":8522,
"location":"其他",
"time":1265870716,
"friends":374,
"verified_type":220
},
"has_url":false,
"comments":26,
"pics":3,
"source":"iPhone客户端",
"likes":8,
"time":1387122515,
"reposts":228
} | {
"pile_set_name": "Github"
} |
package packngo
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)
const (
libraryVersion = "0.1.0"
baseURL = "https://api.packet.net/"
userAgent = "packngo/" + libraryVersion
mediaType = "application/json"
headerRateLimit = "X-RateLimit-Limit"
headerRateRemaining = "X-RateLimit-Remaining"
headerRateReset = "X-RateLimit-Reset"
)
// ListOptions specifies optional global API parameters
type ListOptions struct {
// for paginated result sets, page of results to retrieve
Page int `url:"page,omitempty"`
// for paginated result sets, the number of results to return per page
PerPage int `url:"per_page,omitempty"`
// specify which resources you want to return as collections instead of references
Includes string
}
// Response is the http response from api calls
type Response struct {
*http.Response
Rate
}
// Href is an API link
type Href struct {
Href string `json:"href"`
}
func (r *Response) populateRate() {
// parse the rate limit headers and populate Response.Rate
if limit := r.Header.Get(headerRateLimit); limit != "" {
r.Rate.RequestLimit, _ = strconv.Atoi(limit)
}
if remaining := r.Header.Get(headerRateRemaining); remaining != "" {
r.Rate.RequestsRemaining, _ = strconv.Atoi(remaining)
}
if reset := r.Header.Get(headerRateReset); reset != "" {
if v, _ := strconv.ParseInt(reset, 10, 64); v != 0 {
r.Rate.Reset = Timestamp{time.Unix(v, 0)}
}
}
}
// ErrorResponse is the http response used on errrors
type ErrorResponse struct {
Response *http.Response
Errors []string `json:"errors"`
SingleError string `json:"error"`
}
func (r *ErrorResponse) Error() string {
return fmt.Sprintf("%v %v: %d %v %v",
r.Response.Request.Method, r.Response.Request.URL, r.Response.StatusCode, strings.Join(r.Errors, ", "), r.SingleError)
}
// Client is the base API Client
type Client struct {
client *http.Client
BaseURL *url.URL
UserAgent string
ConsumerToken string
APIKey string
RateLimit Rate
// Packet Api Objects
Plans PlanService
Users UserService
Emails EmailService
SSHKeys SSHKeyService
Devices DeviceService
Projects ProjectService
Facilities FacilityService
OperatingSystems OSService
DeviceIPs DeviceIPService
ProjectIPs ProjectIPService
Volumes VolumeService
VolumeAttachments VolumeAttachmentService
SpotMarket SpotMarketService
}
// NewRequest inits a new http request with the proper headers
func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error) {
// relative path to append to the endpoint url, no leading slash please
rel, err := url.Parse(path)
if err != nil {
return nil, err
}
u := c.BaseURL.ResolveReference(rel)
// json encode the request body, if any
buf := new(bytes.Buffer)
if body != nil {
err := json.NewEncoder(buf).Encode(body)
if err != nil {
return nil, err
}
}
req, err := http.NewRequest(method, u.String(), buf)
if err != nil {
return nil, err
}
req.Close = true
req.Header.Add("X-Auth-Token", c.APIKey)
req.Header.Add("X-Consumer-Token", c.ConsumerToken)
req.Header.Add("Content-Type", mediaType)
req.Header.Add("Accept", mediaType)
req.Header.Add("User-Agent", userAgent)
return req, nil
}
// Do executes the http request
func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {
resp, err := c.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
response := Response{Response: resp}
response.populateRate()
c.RateLimit = response.Rate
err = checkResponse(resp)
// if the response is an error, return the ErrorResponse
if err != nil {
return &response, err
}
if v != nil {
// if v implements the io.Writer interface, return the raw response
if w, ok := v.(io.Writer); ok {
io.Copy(w, resp.Body)
} else {
err = json.NewDecoder(resp.Body).Decode(v)
if err != nil {
return &response, err
}
}
}
return &response, err
}
// DoRequest is a convenience method, it calls NewRequest follwed by Do
func (c *Client) DoRequest(method, path string, body, v interface{}) (*Response, error) {
req, err := c.NewRequest(method, path, body)
if err != nil {
return nil, err
}
return c.Do(req, v)
}
// NewClient initializes and returns a Client, use this to get an API Client to operate on
// N.B.: Packet's API certificate requires Go 1.5+ to successfully parse. If you are using
// an older version of Go, pass in a custom http.Client with a custom TLS configuration
// that sets "InsecureSkipVerify" to "true"
func NewClient(consumerToken string, apiKey string, httpClient *http.Client) *Client {
client, _ := NewClientWithBaseURL(consumerToken, apiKey, httpClient, baseURL)
return client
}
// NewClientWithBaseURL returns a Client pointing to nonstandard API URL, e.g.
// for mocking the remote API
func NewClientWithBaseURL(consumerToken string, apiKey string, httpClient *http.Client, apiBaseURL string) (*Client, error) {
if httpClient == nil {
// Don't fall back on http.DefaultClient as it's not nice to adjust state
// implicitly. If the client wants to use http.DefaultClient, they can
// pass it in explicitly.
httpClient = &http.Client{}
}
u, err := url.Parse(apiBaseURL)
if err != nil {
return nil, err
}
c := &Client{client: httpClient, BaseURL: u, UserAgent: userAgent, ConsumerToken: consumerToken, APIKey: apiKey}
c.Plans = &PlanServiceOp{client: c}
c.Users = &UserServiceOp{client: c}
c.Emails = &EmailServiceOp{client: c}
c.SSHKeys = &SSHKeyServiceOp{client: c}
c.Devices = &DeviceServiceOp{client: c}
c.Projects = &ProjectServiceOp{client: c}
c.Facilities = &FacilityServiceOp{client: c}
c.OperatingSystems = &OSServiceOp{client: c}
c.DeviceIPs = &DeviceIPServiceOp{client: c}
c.ProjectIPs = &ProjectIPServiceOp{client: c}
c.Volumes = &VolumeServiceOp{client: c}
c.VolumeAttachments = &VolumeAttachmentServiceOp{client: c}
c.SpotMarket = &SpotMarketServiceOp{client: c}
return c, nil
}
func checkResponse(r *http.Response) error {
// return if http status code is within 200 range
if c := r.StatusCode; c >= 200 && c <= 299 {
// response is good, return
return nil
}
errorResponse := &ErrorResponse{Response: r}
data, err := ioutil.ReadAll(r.Body)
// if the response has a body, populate the message in errorResponse
if err == nil && len(data) > 0 {
json.Unmarshal(data, errorResponse)
}
return errorResponse
}
| {
"pile_set_name": "Github"
} |
POM_ARTIFACT_ID=apollo-rx3-support
POM_NAME=Apollo GraphQL Rx3 Support
POM_DESCRIPTION=Apollo GraphQL RxJava3 bindings
POM_PACKAGING=jar
| {
"pile_set_name": "Github"
} |
<?php
namespace Illuminate\Filesystem;
use Illuminate\Support\ServiceProvider;
class FilesystemServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->registerNativeFilesystem();
$this->registerFlysystem();
}
/**
* Register the native filesystem implementation.
*
* @return void
*/
protected function registerNativeFilesystem()
{
$this->app->singleton('files', function () {
return new Filesystem;
});
}
/**
* Register the driver based filesystem.
*
* @return void
*/
protected function registerFlysystem()
{
$this->registerManager();
$this->app->singleton('filesystem.disk', function () {
return $this->app['filesystem']->disk($this->getDefaultDriver());
});
$this->app->singleton('filesystem.cloud', function () {
return $this->app['filesystem']->disk($this->getCloudDriver());
});
}
/**
* Register the filesystem manager.
*
* @return void
*/
protected function registerManager()
{
$this->app->singleton('filesystem', function () {
return new FilesystemManager($this->app);
});
}
/**
* Get the default file driver.
*
* @return string
*/
protected function getDefaultDriver()
{
return $this->app['config']['filesystems.default'];
}
/**
* Get the default cloud based file driver.
*
* @return string
*/
protected function getCloudDriver()
{
return $this->app['config']['filesystems.cloud'];
}
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html >
<html>
<head>
<title>Weekday - org.saddle.time.Weekday</title>
<meta name="description" content="Weekday - org.saddle.time.Weekday" />
<meta name="keywords" content="Weekday org.saddle.time.Weekday" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="../../../lib/template.css" media="screen" type="text/css" rel="stylesheet" />
<link href="../../../lib/diagrams.css" media="screen" type="text/css" rel="stylesheet" id="diagrams-css" />
<script type="text/javascript" src="../../../lib/jquery.js" id="jquery-js"></script>
<script type="text/javascript" src="../../../lib/jquery-ui.js"></script>
<script type="text/javascript" src="../../../lib/template.js"></script>
<script type="text/javascript" src="../../../lib/tools.tooltip.js"></script>
<script type="text/javascript">
if(top === self) {
var url = '../../../index.html';
var hash = 'org.saddle.time.Weekday$';
var anchor = window.location.hash;
var anchor_opt = '';
if (anchor.length >= 1)
anchor_opt = '@' + anchor.substring(1);
window.location.href = url + '#' + hash + anchor_opt;
}
</script>
</head>
<body class="value">
<div id="definition">
<a href="Weekday.html" title="See companion trait"><img src="../../../lib/object_to_trait_big.png" /></a>
<p id="owner"><a href="../../package.html" class="extype" name="org">org</a>.<a href="../package.html" class="extype" name="org.saddle">saddle</a>.<a href="package.html" class="extype" name="org.saddle.time">time</a></p>
<h1><a href="Weekday.html" title="See companion trait">Weekday</a></h1><h3><span class="morelinks"><div>
Related Docs:
<a href="Weekday.html" title="See companion trait">trait Weekday</a>
| <a href="package.html" class="extype" name="org.saddle.time">package time</a>
</div></span></h3><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
</div>
<h4 id="signature" class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">object</span>
</span>
<span class="symbol">
<span class="name">Weekday</span>
</span>
</h4>
<div id="comment" class="fullcommenttop"><div class="toggleContainer block">
<span class="toggle">Linear Supertypes</span>
<div class="superTypes hiddenContent"><span class="extype" name="scala.AnyRef">AnyRef</span>, <span class="extype" name="scala.Any">Any</span></div>
</div></div>
<div id="mbrsel">
<div id="textfilter"><span class="pre"></span><span class="input"><input id="mbrsel-input" type="text" accesskey="/" /></span><span class="post"></span></div>
<div id="order">
<span class="filtertype">Ordering</span>
<ol>
<li class="alpha in"><span>Alphabetic</span></li>
<li class="inherit out"><span>By inheritance</span></li>
</ol>
</div>
<div id="ancestors">
<span class="filtertype">Inherited<br />
</span>
<ol id="linearization">
<li class="in" name="org.saddle.time.Weekday"><span>Weekday</span></li><li class="in" name="scala.AnyRef"><span>AnyRef</span></li><li class="in" name="scala.Any"><span>Any</span></li>
</ol>
</div><div id="ancestors">
<span class="filtertype"></span>
<ol>
<li class="hideall out"><span>Hide All</span></li>
<li class="showall in"><span>Show all</span></li>
</ol>
<a href="http://docs.scala-lang.org/overviews/scaladoc/usage.html#members" target="_blank">Learn more about member selection</a>
</div>
<div id="visbl">
<span class="filtertype">Visibility</span>
<ol><li class="public in"><span>Public</span></li><li class="all out"><span>All</span></li></ol>
</div>
</div>
<div id="template">
<div id="allMembers">
<div id="values" class="values members">
<h3>Value Members</h3>
<ol><li name="scala.AnyRef#!=" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="!=(x$1:Any):Boolean"></a>
<a id="!=(Any):Boolean"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span title="gt4s: $bang$eq" class="name">!=</span><span class="params">(<span name="arg0">arg0: <span class="extype" name="scala.Any">Any</span></span>)</span><span class="result">: <span class="extype" name="scala.Boolean">Boolean</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@!=(x$1:Any):Boolean" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef → Any</dd></dl></div>
</li><li name="scala.AnyRef###" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="##():Int"></a>
<a id="##():Int"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span title="gt4s: $hash$hash" class="name">##</span><span class="params">()</span><span class="result">: <span class="extype" name="scala.Int">Int</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@##():Int" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef → Any</dd></dl></div>
</li><li name="scala.AnyRef#==" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="==(x$1:Any):Boolean"></a>
<a id="==(Any):Boolean"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span title="gt4s: $eq$eq" class="name">==</span><span class="params">(<span name="arg0">arg0: <span class="extype" name="scala.Any">Any</span></span>)</span><span class="result">: <span class="extype" name="scala.Boolean">Boolean</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@==(x$1:Any):Boolean" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef → Any</dd></dl></div>
</li><li name="scala.Any#asInstanceOf" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="asInstanceOf[T0]:T0"></a>
<a id="asInstanceOf[T0]:T0"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">asInstanceOf</span><span class="tparams">[<span name="T0">T0</span>]</span><span class="result">: <span class="extype" name="scala.Any.asInstanceOf.T0">T0</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@asInstanceOf[T0]:T0" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>Any</dd></dl></div>
</li><li name="scala.AnyRef#clone" visbl="prt" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="clone():Object"></a>
<a id="clone():AnyRef"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">clone</span><span class="params">()</span><span class="result">: <span class="extype" name="scala.AnyRef">AnyRef</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@clone():Object" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Attributes</dt><dd>protected[<a href="../../../java$lang.html" class="extype" name="java.lang">java.lang</a>] </dd><dt>Definition Classes</dt><dd>AnyRef</dd><dt>Annotations</dt><dd>
<span class="name">@throws</span><span class="args">(<span>
<span class="defval" name="classOf[java.lang.CloneNotSupportedException]">...</span>
</span>)</span>
</dd></dl></div>
</li><li name="scala.AnyRef#eq" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="eq(x$1:AnyRef):Boolean"></a>
<a id="eq(AnyRef):Boolean"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">eq</span><span class="params">(<span name="arg0">arg0: <span class="extype" name="scala.AnyRef">AnyRef</span></span>)</span><span class="result">: <span class="extype" name="scala.Boolean">Boolean</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@eq(x$1:AnyRef):Boolean" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd></dl></div>
</li><li name="scala.AnyRef#equals" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="equals(x$1:Any):Boolean"></a>
<a id="equals(Any):Boolean"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">equals</span><span class="params">(<span name="arg0">arg0: <span class="extype" name="scala.Any">Any</span></span>)</span><span class="result">: <span class="extype" name="scala.Boolean">Boolean</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@equals(x$1:Any):Boolean" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef → Any</dd></dl></div>
</li><li name="scala.AnyRef#finalize" visbl="prt" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="finalize():Unit"></a>
<a id="finalize():Unit"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">finalize</span><span class="params">()</span><span class="result">: <span class="extype" name="scala.Unit">Unit</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@finalize():Unit" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Attributes</dt><dd>protected[<a href="../../../java$lang.html" class="extype" name="java.lang">java.lang</a>] </dd><dt>Definition Classes</dt><dd>AnyRef</dd><dt>Annotations</dt><dd>
<span class="name">@throws</span><span class="args">(<span>
<span class="symbol">classOf[java.lang.Throwable]</span>
</span>)</span>
</dd></dl></div>
</li><li name="scala.AnyRef#getClass" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="getClass():Class[_]"></a>
<a id="getClass():Class[_]"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">getClass</span><span class="params">()</span><span class="result">: <span class="extype" name="java.lang.Class">Class</span>[_]</span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@getClass():Class[_]" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef → Any</dd></dl></div>
</li><li name="scala.AnyRef#hashCode" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="hashCode():Int"></a>
<a id="hashCode():Int"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">hashCode</span><span class="params">()</span><span class="result">: <span class="extype" name="scala.Int">Int</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@hashCode():Int" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef → Any</dd></dl></div>
</li><li name="scala.Any#isInstanceOf" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="isInstanceOf[T0]:Boolean"></a>
<a id="isInstanceOf[T0]:Boolean"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">isInstanceOf</span><span class="tparams">[<span name="T0">T0</span>]</span><span class="result">: <span class="extype" name="scala.Boolean">Boolean</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@isInstanceOf[T0]:Boolean" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>Any</dd></dl></div>
</li><li name="scala.AnyRef#ne" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="ne(x$1:AnyRef):Boolean"></a>
<a id="ne(AnyRef):Boolean"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">ne</span><span class="params">(<span name="arg0">arg0: <span class="extype" name="scala.AnyRef">AnyRef</span></span>)</span><span class="result">: <span class="extype" name="scala.Boolean">Boolean</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@ne(x$1:AnyRef):Boolean" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd></dl></div>
</li><li name="scala.AnyRef#notify" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="notify():Unit"></a>
<a id="notify():Unit"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">notify</span><span class="params">()</span><span class="result">: <span class="extype" name="scala.Unit">Unit</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@notify():Unit" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd></dl></div>
</li><li name="scala.AnyRef#notifyAll" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="notifyAll():Unit"></a>
<a id="notifyAll():Unit"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">notifyAll</span><span class="params">()</span><span class="result">: <span class="extype" name="scala.Unit">Unit</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@notifyAll():Unit" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd></dl></div>
</li><li name="scala.AnyRef#synchronized" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="synchronized[T0](x$1:=>T0):T0"></a>
<a id="synchronized[T0](⇒T0):T0"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">synchronized</span><span class="tparams">[<span name="T0">T0</span>]</span><span class="params">(<span name="arg0">arg0: ⇒ <span class="extype" name="java.lang.AnyRef.synchronized.T0">T0</span></span>)</span><span class="result">: <span class="extype" name="java.lang.AnyRef.synchronized.T0">T0</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@synchronized[T0](x$1:=>T0):T0" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd></dl></div>
</li><li name="scala.AnyRef#toString" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="toString():String"></a>
<a id="toString():String"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier"></span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">toString</span><span class="params">()</span><span class="result">: <span class="extype" name="java.lang.String">String</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@toString():String" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef → Any</dd></dl></div>
</li><li name="org.saddle.time.Weekday#w2wn" visbl="pub" data-isabs="false" fullComment="no" group="Ungrouped">
<a id="w2wn(w:org.saddle.time.Weekday):org.saddle.time.WeekdayNum"></a>
<a id="w2wn(Weekday):WeekdayNum"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">implicit </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">w2wn</span><span class="params">(<span name="w">w: <a href="Weekday.html" class="extype" name="org.saddle.time.Weekday">Weekday</a></span>)</span><span class="result">: <a href="WeekdayNum.html" class="extype" name="org.saddle.time.WeekdayNum">WeekdayNum</a></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@w2wn(w:org.saddle.time.Weekday):org.saddle.time.WeekdayNum" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<p class="shortcomment cmt">Allow for implicit Weekday => WeekdayNum conversion: e.g., MO => MO(0)
</p>
</li><li name="scala.AnyRef#wait" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="wait():Unit"></a>
<a id="wait():Unit"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">wait</span><span class="params">()</span><span class="result">: <span class="extype" name="scala.Unit">Unit</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@wait():Unit" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd><dt>Annotations</dt><dd>
<span class="name">@throws</span><span class="args">(<span>
<span class="defval" name="classOf[java.lang.InterruptedException]">...</span>
</span>)</span>
</dd></dl></div>
</li><li name="scala.AnyRef#wait" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="wait(x$1:Long,x$2:Int):Unit"></a>
<a id="wait(Long,Int):Unit"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">wait</span><span class="params">(<span name="arg0">arg0: <span class="extype" name="scala.Long">Long</span></span>, <span name="arg1">arg1: <span class="extype" name="scala.Int">Int</span></span>)</span><span class="result">: <span class="extype" name="scala.Unit">Unit</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@wait(x$1:Long,x$2:Int):Unit" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd><dt>Annotations</dt><dd>
<span class="name">@throws</span><span class="args">(<span>
<span class="defval" name="classOf[java.lang.InterruptedException]">...</span>
</span>)</span>
</dd></dl></div>
</li><li name="scala.AnyRef#wait" visbl="pub" data-isabs="false" fullComment="yes" group="Ungrouped">
<a id="wait(x$1:Long):Unit"></a>
<a id="wait(Long):Unit"></a>
<h4 class="signature">
<span class="modifier_kind">
<span class="modifier">final </span>
<span class="kind">def</span>
</span>
<span class="symbol">
<span class="name">wait</span><span class="params">(<span name="arg0">arg0: <span class="extype" name="scala.Long">Long</span></span>)</span><span class="result">: <span class="extype" name="scala.Unit">Unit</span></span>
</span>
</h4><span class="permalink">
<a href="../../../index.html#org.saddle.time.Weekday$@wait(x$1:Long):Unit" title="Permalink" target="_top">
<img src="../../../lib/permalink.png" />
</a>
</span>
<div class="fullcomment"><dl class="attributes block"> <dt>Definition Classes</dt><dd>AnyRef</dd><dt>Annotations</dt><dd>
<span class="name">@throws</span><span class="args">(<span>
<span class="defval" name="classOf[java.lang.InterruptedException]">...</span>
</span>)</span>
</dd></dl></div>
</li></ol>
</div>
</div>
<div id="inheritedMembers">
<div class="parent" name="scala.AnyRef">
<h3>Inherited from <span class="extype" name="scala.AnyRef">AnyRef</span></h3>
</div><div class="parent" name="scala.Any">
<h3>Inherited from <span class="extype" name="scala.Any">Any</span></h3>
</div>
</div>
<div id="groupedMembers">
<div class="group" name="Ungrouped">
<h3>Ungrouped</h3>
</div>
</div>
</div>
<div id="tooltip"></div>
<div id="footer"> </div>
</body>
</html> | {
"pile_set_name": "Github"
} |
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
add_definitions(-D__WINESRC__)
spec2def(rasapi32.dll rasapi32.spec ADD_IMPORTLIB)
list(APPEND SOURCE
rasapi.c
${CMAKE_CURRENT_BINARY_DIR}/rasapi32_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/rasapi32.def)
add_library(rasapi32 SHARED ${SOURCE})
set_module_type(rasapi32 win32dll)
target_link_libraries(rasapi32 wine)
add_importlibs(rasapi32 msvcrt kernel32 ntdll)
add_cd_file(TARGET rasapi32 DESTINATION reactos/system32 FOR all)
| {
"pile_set_name": "Github"
} |
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
source /root/func.sh
source /opt/cloud/bin/vpc_func.sh
vpnoutmark="0x525"
vpninmark="0x524"
lock="biglock"
locked=$(getLockFile $lock)
if [ "$locked" != "1" ]
then
exit 1
fi
usage() {
printf "Usage: %s -[c|g|r|n|d] [-l <public gateway>] [-v <vpc cidr>] \n" $(basename $0) >&2
}
create_usage_rules () {
iptables-save|grep "NETWORK_STATS_$ethDev" > /dev/null
if [ $? -gt 0 ]
then
iptables -N NETWORK_STATS_$ethDev > /dev/null;
iptables -I FORWARD -j NETWORK_STATS_$ethDev > /dev/null;
iptables -A NETWORK_STATS_$ethDev -o $ethDev -s $vcidr > /dev/null;
iptables -A NETWORK_STATS_$ethDev -i $ethDev -d $vcidr > /dev/null;
fi
return $?
}
create_vpn_usage_rules () {
iptables-save|grep "VPN_STATS_$ethDev" > /dev/null
if [ $? -gt 0 ]
then
iptables -t mangle -N VPN_STATS_$ethDev > /dev/null;
iptables -t mangle -I FORWARD -j VPN_STATS_$ethDev > /dev/null;
iptables -t mangle -A VPN_STATS_$ethDev -o $ethDev -m mark --mark $vpnoutmark > /dev/null;
iptables -t mangle -A VPN_STATS_$ethDev -i $ethDev -m mark --mark $vpninmark > /dev/null;
fi
return $?
}
remove_usage_rules () {
return 0
}
get_usage () {
iptables -L NETWORK_STATS_$ethDev -n -v -x 2> /dev/null | awk '$1 ~ /^[0-9]+$/ { printf "%s:", $2}'; > /dev/null
return 0
}
get_vpn_usage () {
iptables -t mangle -L VPN_STATS_$ethDev -n -v -x | awk '$1 ~ /^[0-9]+$/ { printf "%s:", $2}'; > /dev/null
if [ $? -gt 0 ]
then
printf $?
return 1
fi
}
reset_usage () {
iptables -Z NETWORK_STATS_$ethDev > /dev/null
if [ $? -gt 0 -a $? -ne 2 ]
then
return 1
fi
}
#set -x
cflag=
gflag=
rflag=
lflag=
vflag=
nflag=
dflag=
while getopts 'cgndrl:v:' OPTION
do
case $OPTION in
c) cflag=1
;;
g) gflag=1
;;
r) rflag=1
;;
l) lflag=1
publicIp="$OPTARG"
;;
v) vflag=1
vcidr="$OPTARG"
;;
n) nflag=1
;;
d) dflag=1
;;
i) #Do nothing, since it's parameter for host script
;;
?) usage
unlock_exit 2 $lock $locked
;;
esac
done
ethDev=$(getEthByIp $publicIp)
if [ "$cflag" == "1" ]
then
if [ "$ethDev" != "" ]
then
create_usage_rules
create_vpn_usage_rules
unlock_exit 0 $lock $locked
fi
fi
if [ "$gflag" == "1" ]
then
get_usage
unlock_exit $? $lock $locked
fi
if [ "$nflag" == "1" ]
then
#get_vpn_usage
unlock_exit $? $lock $locked
fi
if [ "$dflag" == "1" ]
then
#remove_usage_rules
unlock_exit 0 $lock $locked
fi
if [ "$rflag" == "1" ]
then
reset_usage
unlock_exit $? $lock $locked
fi
unlock_exit 0 $lock $locked
| {
"pile_set_name": "Github"
} |
/*
* Sending VK_PAUSE to the console window almost works as a mechanism for
* pausing it, but it doesn't because the console could turn off the
* ENABLE_LINE_INPUT console mode flag.
*/
#define _WIN32_WINNT 0x0501
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
CALLBACK DWORD pausingThread(LPVOID dummy)
{
if (1) {
Sleep(1000);
HWND hwnd = GetConsoleWindow();
SendMessage(hwnd, WM_KEYDOWN, VK_PAUSE, 1);
Sleep(1000);
SendMessage(hwnd, WM_KEYDOWN, VK_ESCAPE, 1);
}
if (0) {
INPUT_RECORD ir;
memset(&ir, 0, sizeof(ir));
ir.EventType = KEY_EVENT;
ir.Event.KeyEvent.bKeyDown = TRUE;
ir.Event.KeyEvent.wVirtualKeyCode = VK_PAUSE;
ir.Event.KeyEvent.wRepeatCount = 1;
}
return 0;
}
int main()
{
HANDLE hin = GetStdHandle(STD_INPUT_HANDLE);
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
COORD c = { 0, 0 };
DWORD mode;
GetConsoleMode(hin, &mode);
SetConsoleMode(hin, mode &
~(ENABLE_LINE_INPUT));
CreateThread(NULL, 0,
pausingThread, NULL,
0, NULL);
int i = 0;
while (true) {
Sleep(100);
printf("%d\n", ++i);
}
return 0;
}
| {
"pile_set_name": "Github"
} |
---
output:
pdf_document:
citation_package: natbib
keep_tex: true
fig_caption: true
latex_engine: pdflatex
template: ../svm-latex-ms.tex
bibliography: master.bib
header-includes:
- \usepackage{hyperref}
biblio-style: apsr
title: "A Pandoc Markdown Article Starter and Template"
thanks: "Replication files are available on the author's Github account (http://github.com/svmiller). **Current version**: `r format(Sys.time(), '%B %d, %Y')`; **Corresponding author**: [email protected]."
author:
- name: Steven V. Miller
affiliation: Clemson University
abstract: "This document provides an introduction to R Markdown, argues for its benefits, and presents a sample manuscript template intended for an academic audience. I include basic syntax to R Markdown and a minimal working example of how the analysis itself can be conducted within R with the `knitr` package."
keywords: "pandoc, r markdown, knitr"
date: "`r format(Sys.time(), '%B %d, %Y')`"
geometry: margin=1in
fontfamily: mathpazo
fontsize: 11pt
# spacing: double
endnote: no
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(cache=TRUE,
message=FALSE, warning=FALSE,
fig.path='figs/',
cache.path = '_cache/',
fig.process = function(x) {
x2 = sub('-\\d+([.][a-z]+)$', '\\1', x)
if (file.rename(x, x2)) x2 else x
})
```
# Introduction
Academic workflow, certainly in political science, is at a crossroads. The *American Journal of Political Science* (*AJPS*) announced a (my words) ["show your work" initiative](http://ajps.org/2015/03/26/the-ajps-replication-policy-innovations-and-revisions/) in which authors who are tentatively accepted for publication at the journal must hand over the raw code and data that produced the results shown in the manuscript. The editorial team at *AJPS* then reproduces the code from the manuscript. Pending successful replication, the manuscript moves toward publication. The *AJPS* might be at the fore of this movement, and it could be the most aggressive among political science journals, but other journals in our field have signed the joint [Data Access & Research Transparency](http://www.dartstatement.org/) (DART) initiative. This, at a bare minimum, requires uploading code from quantitatively-oriented published articles to in-house directories hosted by the journal or to services like [Dataverse](http://dataverse.org/).
There are workflow implications to the Lacour controversy as well. Political science, for the foreseeable future, will struggle with the extent of [the data fraud perpetrated by Michael Lacour](http://stanford.edu/~dbroock/broockman_kalla_aronow_lg_irregularities.pdf) in an article co-authored with Donald P. Green in *Science*, the general scientific journal of record in the United States. A failure to reproduce LaCour's results with different samples uncovered a comprehensive effort by LaCour to "fake" data that provided results to what we felt or believed to be true [(i.e. "truthiness")](http://chronicle.com/article/LAffaire-LaCour/230905/). However, [fake data can have real consequences](http://kieranhealy.org/blog/archives/2015/05/20/fake-science-real-consequences/) for both the researcher and those who want to learn from it and use it for various purposes. Even research done honestly may suffer the same fate if researchers are not diligent in their workflow.
These recent events underscore the DART push and cast a shadow over our workflow. However, good workflow has always been an issue in our discipline. Cloud storage services like [Dropbox](http://www.dropbox.com) are still relatively new among political scientists. Without cloud storage, previous workflow left open the possibility that work between a home computer and an office computer was lost as a function of a corrupted thumb drive, an overheated power supply, or, among other things, the wave of viruses that [would particularly affect Microsoft users every summer](http://money.cnn.com/2003/11/05/technology/microsoftbounty/). Social sciences, [unlike engineering](http://kieranhealy.org/blog/archives/2014/01/23/plain-text/), have traditionally relied on software like Microsoft Word for manuscript preparation though any word processor reduces workflow to a series of clicks and strokes on a keyboard. This is [a terrible way to track changes](http://www.nytimes.com/2013/04/19/opinion/krugman-the-excel-depression.html) or maintain version control. The addition of collaborators only compounds all the aforementioned issues. The proverbial left hand may not know what the right hand is doing.
I think there is reason for optimism. We only struggle with it now because we have tools like [R Markdown](http://rmarkdown.rstudio.com/) and [Pandoc](http://pandoc.org/), more generally, that make significant strides in workflow. LaTeX resolved earlier issues of corrupted binary files by reducing documents to raw markup that was little more than raw text and revisions that could be easily kept as ["commented" text](http://tex.stackexchange.com/questions/11177/how-to-write-hidden-notes-in-a-latex-file). However, for all its benefits (including pretty PDFs), [LaTeX is *ugly* code](http://www-rohan.sdsu.edu/~aty/bibliog/latex/gripe.html) and does not provide means of seamlessly working with the actual data analysis itself. R Markdown both eliminates markup and allows the author and her collaborators to write and reproduce the manuscript in one fell swoop.
# Getting Started with YAML
The lion's share of a R Markdown document will be raw text, though the front matter may be the most important part of the document. R Markdown uses [YAML](http://www.yaml.org/) for its metadata and the fields differ from [what an author would use for a Beamer presentation](http://svmiller.com/blog/2015/02/moving-from-beamer-to-r-markdown/). I provide a sample YAML metadata largely taken from this exact document and explain it below.
```{r eval=FALSE}
---
output:
pdf_document:
citation_package: natbib
keep_tex: true
fig_caption: true
latex_engine: pdflatex
template: ~/Dropbox/miscelanea/svm-r-markdown-templates/svm-latex-ms.tex
title: "A Pandoc Markdown Article Starter and Template"
thanks: "Replication files are available on the author's Github account..."
author:
- name: Steven V. Miller
affiliation: Clemson University
- name: Mary Margaret Albright
affiliation: Pendelton State University
- name: Rembrandt Q. Einstein
affiliation: Springfield University
abstract: "This document provides an introduction to R Markdown, argues for its..."
keywords: "pandoc, r markdown, knitr"
date: "`r format(Sys.time(), '%B %d, %Y')`"
geometry: margin=1in
fontfamily: mathpazo
fontsize: 11pt
# spacing: double
bibliography: "`r paste0(Sys.getenv('HOME'),'/Dropbox/master.bib')`"
biblio-style: apsr
---
```
`output:` will tell R Markdown we want a PDF document rendered with LaTeX. Since we are adding a fair bit of custom options to this call, we specify `pdf_document:` on the next line (with, importantly, a two-space indent). We specify additional output-level options underneath it, each are indented with four spaces. `citation_package: natbib` tells R Markdown to use `natbib` to handle bibliographic citations.[^natbib] Thereafter, the next line (`keep_tex: true`) tells R Markdown to render a raw `.tex` file along with the PDF document. This is useful for both debugging and the publication stage, when the editorial team will ask for the raw `.tex` so that they could render it and later provide page proofs. The next line `fig_caption: true` tells R Markdown to make sure that whatever images are included in the document are treated as figures in which our caption in brackets in a Markdown call is treated as the caption in the figure. The next line (`latex_engine: pdflatex`) tells R Markdown to use pdflatex and not some other option like `lualatex`. For my template, I'm pretty sure this is mandatory.[^pdflatex]
[^natbib]: R Markdown can use Pandoc's native bibliography management system or even `biblatex`, but I've found that it chokes with some of the more advanced stuff I've done with my .bib file over the years. For example, I've been diligent about special characters (e.g. umlauts and acute accents) in author names in my .bib file, but Pandoc's native citation system will choke on these characters in a .bib file. I effectively need `natbib` for my own projects.
[^pdflatex]: The main reason I still use `pdflatex` (and most readers probably do as well) is because of LaTeX fonts. [Unlike others](http://www-rohan.sdsu.edu/~aty/bibliog/latex/gripe.html), I find standard LaTeX fonts to be appealing.
The next line (`template: ...`) tells R Markdown to use my custom LaTeX template.[^path] While I will own any errors in the code, I confess to "Frankensteining" this template from [the default LaTeX template](https://github.com/jgm/pandoc-templates) from Pandoc, [Kieran Healy's LaTeX template](https://github.com/kjhealy/pandoc-templates/tree/master/templates), and liberally using raw TeX from the [Association for Computing Machinery's (ACM) LaTeX template](https://www.acm.org/publications/article-templates/acm-latex-style-guide). I rather like that template since it resembles standard manuscripts when they are published in some of our more prominent journals. I will continue with a description of the YAML metadata in the next paragraph, though invite the curious reader to scroll to the end of the accompanying post to see the PDF this template produces.
[^path]: Notice that the path is relative. The user can, if she wishes, install this in the default Pandoc directory. I don't think this is necessary. Just be mindful of wherever the template is placed. Importantly, `~` is used in R to find the home directory (not necessarily the working directory). It is equivalent to saying `/home/steve` in Linux, or `/Users/steve` on a Mac, in my case.
The next fields get to the heart of the document itself. `title:` is, intuitively, the title of the manuscript. Do note that fields like `title:` do not have to be in quotation marks, but must be in quotation marks if the title of the document includes a colon. That said, the only reason to use a colon in an article title is if it is followed by a subtitle, hence the optional field (`subtitle:`). Notice I "comment out" the subtitle in the above example with a pound sign since this particular document does not have a subtitle. If `thanks:` is included and has an accompanying entry, the ensuing title of the document gets an asterisk and a footnote. This field is typically used to advise readers that the document is a working paper or is forthcoming in a journal.
The next field (`author:`) is a divergence from standard YAML, but I think it is useful. I will also confess to pilfering this idea from Kieran Healy's template. Typically, multiple authors for a given document are separated by an `\and` in this field. However, standard LaTeX then creates a tabular field separating multiple authors that is somewhat restrictive and not easy to override. As a result, I use this setup (again, taken from Kieran Healy) to sidestep the restrictive rendering of authors in the standard `\maketitle` tag. After `author:`, enter `- name:` (no space before the dash) and fill in the field with the first author. On the next line, enter two spaces, followed by `affiliation:` and the institute or university affiliation of the first author.
Do notice this can be repeated for however many co-authors there are to a manuscript. The rendered PDF will enter each co-author in a new line in a manner similar to journals like *American Journal of Political Science*, *American Political Science Review*, or *Journal of Politics*.
The next two fields pertain to the frontmatter of a manuscript. They should also be intuitive for the reader. `abstract` should contain the abstract and `keywords` should contain some keywords that describe the research project. Both fields are optional, though are practically mandatory. Every manuscript requires an abstract and some journals---especially those published by Sage---request them with submitted manuscripts. My template also includes these keywords in the PDF's metadata.
`date` comes standard with R Markdown and you can use it to enter the date of the most recent compile. I typically include the date of the last compile for a working paper in the `thanks:` field, so this field currently does not do anything in my Markdown-LaTeX manuscript template. I include it in my YAML as a legacy, basically.
The next items are optional and cosmetic. `geometry:` is a standard option in LaTeX. I set the margins at one inch, and you probably should too. `fontfamily:` is optional, but I use it to specify the Palatino font. The default option is Computer Modern Roman. `fontsize:` sets, intuitively, the font size. The default is 10-point, but I prefer 11-point. `spacing:` is an optional field. If it is set as "double", the ensuing document is double-spaced. "single" is the only other valid entry for this field, though not including the entry in the YAML metadata amounts to singlespacing the document by default. Notice I have this "commented out" in the example code.
The final two options pertain to the bibliography. `bibliography:` specifies the location of the .bib file, so the author could make citations in the manuscript. `biblio-style` specifies the type of bibliography to use. You'll typically set this as APSR. You could also specify the relative path of [my *Journal of Peace Research* .bst file](http://svmiller.com/miscellany/journal-of-peace-research-bst-file/) if you are submitting to that journal.
# Getting Started with Markdown Syntax
There are a lot of cheatsheets and reference guides for Markdown (e.g. [Adam Prichard](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet), [Assemble](http://assemble.io/docs/Cheatsheet-Markdown.html), [Rstudio](https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf), [Rstudio again](https://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf), [Scott Boms](http://scottboms.com/downloads/documentation/markdown_cheatsheet.pdf), [Daring Fireball](https://daringfireball.net/projects/markdown/syntax), among, I'm sure, several others). I encourage the reader to look at those, though I will retread these references here with a minimal working example below.
```markdown
# Introduction
**Lorem ipsum** dolor *sit amet*.
- Single asterisks italicize text *like this*.
- Double asterisks embolden text **like this**.
Start a new paragraph with a blank line separating paragraphs.
- This will start an unordered list environment, and this will be the first item.
- This will be a second item.
- A third item.
- Four spaces and a dash create a sublist and this item in it.
- The fourth item.
1. This starts a numerical list.
2. This is no. 2 in the numerical list.
# This Starts A New Section
## This is a Subsection
### This is a Subsubsection
#### This starts a Paragraph Block.
> This will create a block quote, if you want one.
Want a table? This will create one.
Table Header | Second Header
------------- | -------------
Table Cell | Cell 2
Cell 3 | Cell 4
Note that the separators *do not* have to be aligned.
Want an image? This will do it.

`fig_caption: yes` will provide a caption. Put that in the YAML metadata.
Almost forgot about creating a footnote.[^1] This will do it again.[^2]
[^1]: The first footnote
[^2]: The second footnote
Want to cite something?
- Find your biblatexkey in your bib file.
- Put an @ before it, like @smith1984, or whatever it is.
- @smith1984 creates an in-text citation (e.g. Smith (1984) says...)
- [@smith1984] creates a parenthetical citation (Smith, 1984)
That'll also automatically create a reference list at the end of the document.
[In-text link to Google](http://google.com) as well.
```
That's honestly it. Markdown takes the chore of markup from your manuscript (hence: "Markdown").
On that note, you could easily pass most LaTeX code through Markdown if you're writing a LaTeX document. However, you don't need to do this (unless you're using the math environment) and probably shouldn't anyway if you intend to share your document in HTML as well.
# Using R Markdown with Knitr
Perhaps the greatest intrigue of R Markdown comes with the [`knitr` package](http://yihui.name/knitr/) provided by @xie2013ddrk. In other words, the author can, if she chooses, do the analysis in the Markdown document itself and compile/execute it in R.
Take, for example, this simple exercise using the `voteincome` data from the `Zelig` package. Suppose I want to explain the decision to vote using data from this package. I load in the data, clean the data, run the analyses, and present the results as a coefficient plot.
Here's what this code looks like. All I did was create a code display, which starts with three *backticks* (i.e. those ticks next to the number 1 key on your keyboard) and ends with three backticks on another line. On the first line of backticks (i.e. to start the code display) enter `{r, eval=FALSE, tidy=TRUE}`. The `eval=FALSE` option just displays the R code (and does not run it), `tidy=TRUE` wraps long code so it does not run off the page.
Within that code display, I enter my R code like this.
```{r, eval=FALSE, tidy = TRUE}
library(stevemisc)
data(uniondensity)
M1 <- lm(union ~ left + size + concen, data=uniondensity)
library(arm)
coefplot(M1)
```
The implications for workflow are faily substantial. Authors can rather quickly display the code they used to run the analyses in the document itself (likely in the appendix). As such, there's little guesswork for reviewers and editors in understanding what the author did in the analyses reported in the manuscript.
It doesn't end there. In fact, here's what happens when `eval=FALSE` is omitted or changed to `eval=TRUE`. Now, the code runs within R. Observe.
```{r, eval=TRUE, tidy = TRUE, cache=FALSE, fig.cap="A Coefficient Plot", message=F, warning=F}
library(stevemisc)
data(uniondensity)
M1 <- lm(union ~ left + size + concen, data=uniondensity)
library(arm)
coefplot(M1)
```
To get `knitr` to present the results of a table, add `results="asis"` to the brackets to start the R code chunk. The ensuing output will look like this (though the table may come on the next page).
```{r, eval=TRUE, tidy = TRUE, size="small", cache=FALSE, results="asis", message=F, warning=F}
library(stevemisc)
data(uniondensity)
library(stargazer)
M1 <- lm(union ~ left + size + concen, data=uniondensity)
stargazer(M1, title="A Handsome Table", header=FALSE)
```
Adding `echo="FALSE"` inside the brackets to start the R chunk will omit the presentation of the R commands. It will just present the table. This provides substantial opportunity for authors in doing their analyses. Now, the analysis and presentation in the form of a polished manuscript can be effectively simultaneous.[^4]
[^4]: I'm not sure if I'm ready to commit to this myself since my workflow is still largely derived from [Rob J. Hyndman's example](http://robjhyndman.com/hyndsight/workflow-in-r/). However, *knitr* has endless potential, especially when analyses can stored in cache, saved as chunks, or loaded in the preamble of a document to reference later in the manuscript.
<!--
# References
\setlength{\parindent}{-0.2in}
\setlength{\leftskip}{0.2in}
\setlength{\parskip}{8pt}
\vspace*{-0.2in}
\noindent
-->
| {
"pile_set_name": "Github"
} |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package scrypt implements the scrypt key derivation function as defined in
// Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard
// Functions" (https://www.tarsnap.com/scrypt/scrypt.pdf).
package scrypt // import "golang.org/x/crypto/scrypt"
import (
"crypto/sha256"
"errors"
"golang.org/x/crypto/pbkdf2"
)
const maxInt = int(^uint(0) >> 1)
// blockCopy copies n numbers from src into dst.
func blockCopy(dst, src []uint32, n int) {
copy(dst, src[:n])
}
// blockXOR XORs numbers from dst with n numbers from src.
func blockXOR(dst, src []uint32, n int) {
for i, v := range src[:n] {
dst[i] ^= v
}
}
// salsaXOR applies Salsa20/8 to the XOR of 16 numbers from tmp and in,
// and puts the result into both both tmp and out.
func salsaXOR(tmp *[16]uint32, in, out []uint32) {
w0 := tmp[0] ^ in[0]
w1 := tmp[1] ^ in[1]
w2 := tmp[2] ^ in[2]
w3 := tmp[3] ^ in[3]
w4 := tmp[4] ^ in[4]
w5 := tmp[5] ^ in[5]
w6 := tmp[6] ^ in[6]
w7 := tmp[7] ^ in[7]
w8 := tmp[8] ^ in[8]
w9 := tmp[9] ^ in[9]
w10 := tmp[10] ^ in[10]
w11 := tmp[11] ^ in[11]
w12 := tmp[12] ^ in[12]
w13 := tmp[13] ^ in[13]
w14 := tmp[14] ^ in[14]
w15 := tmp[15] ^ in[15]
x0, x1, x2, x3, x4, x5, x6, x7, x8 := w0, w1, w2, w3, w4, w5, w6, w7, w8
x9, x10, x11, x12, x13, x14, x15 := w9, w10, w11, w12, w13, w14, w15
for i := 0; i < 8; i += 2 {
u := x0 + x12
x4 ^= u<<7 | u>>(32-7)
u = x4 + x0
x8 ^= u<<9 | u>>(32-9)
u = x8 + x4
x12 ^= u<<13 | u>>(32-13)
u = x12 + x8
x0 ^= u<<18 | u>>(32-18)
u = x5 + x1
x9 ^= u<<7 | u>>(32-7)
u = x9 + x5
x13 ^= u<<9 | u>>(32-9)
u = x13 + x9
x1 ^= u<<13 | u>>(32-13)
u = x1 + x13
x5 ^= u<<18 | u>>(32-18)
u = x10 + x6
x14 ^= u<<7 | u>>(32-7)
u = x14 + x10
x2 ^= u<<9 | u>>(32-9)
u = x2 + x14
x6 ^= u<<13 | u>>(32-13)
u = x6 + x2
x10 ^= u<<18 | u>>(32-18)
u = x15 + x11
x3 ^= u<<7 | u>>(32-7)
u = x3 + x15
x7 ^= u<<9 | u>>(32-9)
u = x7 + x3
x11 ^= u<<13 | u>>(32-13)
u = x11 + x7
x15 ^= u<<18 | u>>(32-18)
u = x0 + x3
x1 ^= u<<7 | u>>(32-7)
u = x1 + x0
x2 ^= u<<9 | u>>(32-9)
u = x2 + x1
x3 ^= u<<13 | u>>(32-13)
u = x3 + x2
x0 ^= u<<18 | u>>(32-18)
u = x5 + x4
x6 ^= u<<7 | u>>(32-7)
u = x6 + x5
x7 ^= u<<9 | u>>(32-9)
u = x7 + x6
x4 ^= u<<13 | u>>(32-13)
u = x4 + x7
x5 ^= u<<18 | u>>(32-18)
u = x10 + x9
x11 ^= u<<7 | u>>(32-7)
u = x11 + x10
x8 ^= u<<9 | u>>(32-9)
u = x8 + x11
x9 ^= u<<13 | u>>(32-13)
u = x9 + x8
x10 ^= u<<18 | u>>(32-18)
u = x15 + x14
x12 ^= u<<7 | u>>(32-7)
u = x12 + x15
x13 ^= u<<9 | u>>(32-9)
u = x13 + x12
x14 ^= u<<13 | u>>(32-13)
u = x14 + x13
x15 ^= u<<18 | u>>(32-18)
}
x0 += w0
x1 += w1
x2 += w2
x3 += w3
x4 += w4
x5 += w5
x6 += w6
x7 += w7
x8 += w8
x9 += w9
x10 += w10
x11 += w11
x12 += w12
x13 += w13
x14 += w14
x15 += w15
out[0], tmp[0] = x0, x0
out[1], tmp[1] = x1, x1
out[2], tmp[2] = x2, x2
out[3], tmp[3] = x3, x3
out[4], tmp[4] = x4, x4
out[5], tmp[5] = x5, x5
out[6], tmp[6] = x6, x6
out[7], tmp[7] = x7, x7
out[8], tmp[8] = x8, x8
out[9], tmp[9] = x9, x9
out[10], tmp[10] = x10, x10
out[11], tmp[11] = x11, x11
out[12], tmp[12] = x12, x12
out[13], tmp[13] = x13, x13
out[14], tmp[14] = x14, x14
out[15], tmp[15] = x15, x15
}
func blockMix(tmp *[16]uint32, in, out []uint32, r int) {
blockCopy(tmp[:], in[(2*r-1)*16:], 16)
for i := 0; i < 2*r; i += 2 {
salsaXOR(tmp, in[i*16:], out[i*8:])
salsaXOR(tmp, in[i*16+16:], out[i*8+r*16:])
}
}
func integer(b []uint32, r int) uint64 {
j := (2*r - 1) * 16
return uint64(b[j]) | uint64(b[j+1])<<32
}
func smix(b []byte, r, N int, v, xy []uint32) {
var tmp [16]uint32
x := xy
y := xy[32*r:]
j := 0
for i := 0; i < 32*r; i++ {
x[i] = uint32(b[j]) | uint32(b[j+1])<<8 | uint32(b[j+2])<<16 | uint32(b[j+3])<<24
j += 4
}
for i := 0; i < N; i += 2 {
blockCopy(v[i*(32*r):], x, 32*r)
blockMix(&tmp, x, y, r)
blockCopy(v[(i+1)*(32*r):], y, 32*r)
blockMix(&tmp, y, x, r)
}
for i := 0; i < N; i += 2 {
j := int(integer(x, r) & uint64(N-1))
blockXOR(x, v[j*(32*r):], 32*r)
blockMix(&tmp, x, y, r)
j = int(integer(y, r) & uint64(N-1))
blockXOR(y, v[j*(32*r):], 32*r)
blockMix(&tmp, y, x, r)
}
j = 0
for _, v := range x[:32*r] {
b[j+0] = byte(v >> 0)
b[j+1] = byte(v >> 8)
b[j+2] = byte(v >> 16)
b[j+3] = byte(v >> 24)
j += 4
}
}
// Key derives a key from the password, salt, and cost parameters, returning
// a byte slice of length keyLen that can be used as cryptographic key.
//
// N is a CPU/memory cost parameter, which must be a power of two greater than 1.
// r and p must satisfy r * p < 2³⁰. If the parameters do not satisfy the
// limits, the function returns a nil byte slice and an error.
//
// For example, you can get a derived key for e.g. AES-256 (which needs a
// 32-byte key) by doing:
//
// dk, err := scrypt.Key([]byte("some password"), salt, 16384, 8, 1, 32)
//
// The recommended parameters for interactive logins as of 2017 are N=32768, r=8
// and p=1. The parameters N, r, and p should be increased as memory latency and
// CPU parallelism increases; consider setting N to the highest power of 2 you
// can derive within 100 milliseconds. Remember to get a good random salt.
func Key(password, salt []byte, N, r, p, keyLen int) ([]byte, error) {
if N <= 1 || N&(N-1) != 0 {
return nil, errors.New("scrypt: N must be > 1 and a power of 2")
}
if uint64(r)*uint64(p) >= 1<<30 || r > maxInt/128/p || r > maxInt/256 || N > maxInt/128/r {
return nil, errors.New("scrypt: parameters are too large")
}
xy := make([]uint32, 64*r)
v := make([]uint32, 32*N*r)
b := pbkdf2.Key(password, salt, 1, p*128*r, sha256.New)
for i := 0; i < p; i++ {
smix(b[i*128*r:], r, N, v, xy)
}
return pbkdf2.Key(password, b, 1, keyLen, sha256.New), nil
}
| {
"pile_set_name": "Github"
} |
#include "iwstw.h"
#include "iwth.h"
#include "iwlog.h"
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
struct _TASK {
iwstw_task_f fn;
void *arg;
struct _TASK *next;
};
struct _IWSTW {
struct _TASK *head;
struct _TASK *tail;
pthread_mutex_t mtx;
pthread_barrier_t brr;
pthread_cond_t cond;
pthread_t thr;
int cnt;
int queue_limit;
volatile bool shutdown;
};
void *worker_fn(void *op) {
struct _IWSTW *stw = op;
assert(stw);
pthread_barrier_wait(&stw->brr);
while (true) {
void *arg;
iwstw_task_f fn = 0;
pthread_mutex_lock(&stw->mtx);
if (stw->head) {
struct _TASK *h = stw->head;
fn = h->fn;
arg = h->arg;
stw->head = h->next;
if (stw->tail == h) {
stw->tail = stw->head;
}
--stw->cnt;
free(h);
}
pthread_mutex_unlock(&stw->mtx);
if (fn) {
fn(arg);
}
pthread_mutex_lock(&stw->mtx);
if (stw->head) {
pthread_mutex_unlock(&stw->mtx);
continue;
} else if (stw->shutdown) {
pthread_mutex_unlock(&stw->mtx);
break;
}
pthread_cond_wait(&stw->cond, &stw->mtx);
pthread_mutex_unlock(&stw->mtx);
}
return 0;
}
void iwstw_shutdown(IWSTW *stwp, bool wait_for_all) {
if (!stwp || !*stwp) {
return;
}
IWSTW stw = *stwp;
pthread_mutex_lock(&stw->mtx);
if (stw->shutdown) {
pthread_mutex_unlock(&stw->mtx);
return;
}
if (!wait_for_all) {
struct _TASK *t = stw->head;
while (t) {
struct _TASK *o = t;
t = t->next;
free(o);
}
stw->head = 0;
stw->tail = 0;
stw->cnt = 0;
}
stw->shutdown = true;
pthread_cond_broadcast(&stw->cond);
pthread_mutex_unlock(&stw->mtx);
int rci = pthread_join(stw->thr, 0);
if (rci) {
iwrc rc = iwrc_set_errno(IW_ERROR_THREADING_ERRNO, rci);
iwlog_ecode_error3(rc);
}
pthread_barrier_destroy(&stw->brr);
pthread_cond_destroy(&stw->cond);
pthread_mutex_destroy(&stw->mtx);
free(stw);
*stwp = 0;
}
iwrc iwstw_schedule(IWSTW stw, iwstw_task_f fn, void *arg) {
if (!stw || !fn) {
return IW_ERROR_INVALID_ARGS;
}
iwrc rc = 0;
struct _TASK *task = malloc(sizeof(*task));
if (!task) {
return iwrc_set_errno(IW_ERROR_ALLOC, errno);
}
*task = (struct _TASK) {
.fn = fn,
.arg = arg
};
int rci = pthread_mutex_lock(&stw->mtx);
if (rci) {
rc = iwrc_set_errno(IW_ERROR_THREADING_ERRNO, errno);
goto finish;
}
if (stw->shutdown) {
rc = IW_ERROR_INVALID_STATE;
pthread_mutex_unlock(&stw->mtx);
goto finish;
}
if (stw->queue_limit && stw->cnt + 1 > stw->queue_limit) {
rc = IW_ERROR_OVERFLOW;
pthread_mutex_unlock(&stw->mtx);
goto finish;
}
if (stw->tail) {
stw->tail->next = task;
stw->tail = task;
} else {
stw->head = task;
stw->tail = task;
}
++stw->cnt;
pthread_cond_broadcast(&stw->cond);
pthread_mutex_unlock(&stw->mtx);
finish:
if (rc) {
free(task);
}
return rc;
}
iwrc iwstw_start(int queue_limit, IWSTW *stwp_out) {
struct _IWSTW *stw = malloc(sizeof(*stw));
if (!stw) {
*stwp_out = 0;
return iwrc_set_errno(IW_ERROR_ALLOC, errno);
}
int rci;
iwrc rc = 0;
*stw = (struct _IWSTW) {
.queue_limit = queue_limit,
.mtx = PTHREAD_MUTEX_INITIALIZER,
.cond = PTHREAD_COND_INITIALIZER
};
rci = pthread_barrier_init(&stw->brr, 0, 2);
if (rci) {
rc = iwrc_set_errno(IW_ERROR_THREADING_ERRNO, errno);
goto finish;
}
rci = pthread_create(&stw->thr, 0, worker_fn, stw);
if (rci) {
rc = iwrc_set_errno(IW_ERROR_THREADING_ERRNO, errno);
pthread_barrier_destroy(&stw->brr);
goto finish;
}
pthread_barrier_wait(&stw->brr);
finish:
if (rc) {
*stwp_out = 0;
free(stw);
} else {
*stwp_out = stw;
}
return 0;
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.ssl;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.function.BiFunction;
import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLProtocolException;
import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import jdk.internal.misc.JavaNetInetAddressAccess;
import jdk.internal.misc.SharedSecrets;
/**
* Implementation of an SSL socket.
* <P>
* This is a normal connection type socket, implementing SSL over some lower
* level socket, such as TCP. Because it is layered over some lower level
* socket, it MUST override all default socket methods.
* <P>
* This API offers a non-traditional option for establishing SSL
* connections. You may first establish the connection directly, then pass
* that connection to the SSL socket constructor with a flag saying which
* role should be taken in the handshake protocol. (The two ends of the
* connection must not choose the same role!) This allows setup of SSL
* proxying or tunneling, and also allows the kind of "role reversal"
* that is required for most FTP data transfers.
*
* @see javax.net.ssl.SSLSocket
* @see SSLServerSocket
*
* @author David Brownell
*/
public final class SSLSocketImpl
extends BaseSSLSocketImpl implements SSLTransport {
final SSLContextImpl sslContext;
final TransportContext conContext;
private final AppInputStream appInput = new AppInputStream();
private final AppOutputStream appOutput = new AppOutputStream();
private String peerHost;
private boolean autoClose;
private boolean isConnected = false;
private volatile boolean tlsIsClosed = false;
/*
* Is the local name service trustworthy?
*
* If the local name service is not trustworthy, reverse host name
* resolution should not be performed for endpoint identification.
*/
private static final boolean trustNameService =
Utilities.getBooleanProperty("jdk.tls.trustNameService", false);
/**
* Package-private constructor used to instantiate an unconnected
* socket.
*
* This instance is meant to set handshake state to use "client mode".
*/
SSLSocketImpl(SSLContextImpl sslContext) {
super();
this.sslContext = sslContext;
HandshakeHash handshakeHash = new HandshakeHash();
this.conContext = new TransportContext(sslContext, this,
new SSLSocketInputRecord(handshakeHash),
new SSLSocketOutputRecord(handshakeHash), true);
}
/**
* Package-private constructor used to instantiate a server socket.
*
* This instance is meant to set handshake state to use "server mode".
*/
SSLSocketImpl(SSLContextImpl sslContext, SSLConfiguration sslConfig) {
super();
this.sslContext = sslContext;
HandshakeHash handshakeHash = new HandshakeHash();
this.conContext = new TransportContext(sslContext, this, sslConfig,
new SSLSocketInputRecord(handshakeHash),
new SSLSocketOutputRecord(handshakeHash));
}
/**
* Constructs an SSL connection to a named host at a specified
* port, using the authentication context provided.
*
* This endpoint acts as the client, and may rejoin an existing SSL session
* if appropriate.
*/
SSLSocketImpl(SSLContextImpl sslContext, String peerHost,
int peerPort) throws IOException, UnknownHostException {
super();
this.sslContext = sslContext;
HandshakeHash handshakeHash = new HandshakeHash();
this.conContext = new TransportContext(sslContext, this,
new SSLSocketInputRecord(handshakeHash),
new SSLSocketOutputRecord(handshakeHash), true);
this.peerHost = peerHost;
SocketAddress socketAddress =
peerHost != null ? new InetSocketAddress(peerHost, peerPort) :
new InetSocketAddress(InetAddress.getByName(null), peerPort);
connect(socketAddress, 0);
}
/**
* Constructs an SSL connection to a server at a specified
* address, and TCP port, using the authentication context
* provided.
*
* This endpoint acts as the client, and may rejoin an existing SSL
* session if appropriate.
*/
SSLSocketImpl(SSLContextImpl sslContext,
InetAddress address, int peerPort) throws IOException {
super();
this.sslContext = sslContext;
HandshakeHash handshakeHash = new HandshakeHash();
this.conContext = new TransportContext(sslContext, this,
new SSLSocketInputRecord(handshakeHash),
new SSLSocketOutputRecord(handshakeHash), true);
SocketAddress socketAddress = new InetSocketAddress(address, peerPort);
connect(socketAddress, 0);
}
/**
* Constructs an SSL connection to a named host at a specified
* port, using the authentication context provided.
*
* This endpoint acts as the client, and may rejoin an existing SSL
* session if appropriate.
*/
SSLSocketImpl(SSLContextImpl sslContext,
String peerHost, int peerPort, InetAddress localAddr,
int localPort) throws IOException, UnknownHostException {
super();
this.sslContext = sslContext;
HandshakeHash handshakeHash = new HandshakeHash();
this.conContext = new TransportContext(sslContext, this,
new SSLSocketInputRecord(handshakeHash),
new SSLSocketOutputRecord(handshakeHash), true);
this.peerHost = peerHost;
bind(new InetSocketAddress(localAddr, localPort));
SocketAddress socketAddress =
peerHost != null ? new InetSocketAddress(peerHost, peerPort) :
new InetSocketAddress(InetAddress.getByName(null), peerPort);
connect(socketAddress, 0);
}
/**
* Constructs an SSL connection to a server at a specified
* address, and TCP port, using the authentication context
* provided.
*
* This endpoint acts as the client, and may rejoin an existing SSL
* session if appropriate.
*/
SSLSocketImpl(SSLContextImpl sslContext,
InetAddress peerAddr, int peerPort,
InetAddress localAddr, int localPort) throws IOException {
super();
this.sslContext = sslContext;
HandshakeHash handshakeHash = new HandshakeHash();
this.conContext = new TransportContext(sslContext, this,
new SSLSocketInputRecord(handshakeHash),
new SSLSocketOutputRecord(handshakeHash), true);
bind(new InetSocketAddress(localAddr, localPort));
SocketAddress socketAddress = new InetSocketAddress(peerAddr, peerPort);
connect(socketAddress, 0);
}
/**
* Creates a server mode {@link Socket} layered over an
* existing connected socket, and is able to read data which has
* already been consumed/removed from the {@link Socket}'s
* underlying {@link InputStream}.
*/
SSLSocketImpl(SSLContextImpl sslContext, Socket sock,
InputStream consumed, boolean autoClose) throws IOException {
super(sock, consumed);
// We always layer over a connected socket
if (!sock.isConnected()) {
throw new SocketException("Underlying socket is not connected");
}
this.sslContext = sslContext;
HandshakeHash handshakeHash = new HandshakeHash();
this.conContext = new TransportContext(sslContext, this,
new SSLSocketInputRecord(handshakeHash),
new SSLSocketOutputRecord(handshakeHash), false);
this.autoClose = autoClose;
doneConnect();
}
/**
* Layer SSL traffic over an existing connection, rather than
* creating a new connection.
*
* The existing connection may be used only for SSL traffic (using this
* SSLSocket) until the SSLSocket.close() call returns. However, if a
* protocol error is detected, that existing connection is automatically
* closed.
* <p>
* This particular constructor always uses the socket in the
* role of an SSL client. It may be useful in cases which start
* using SSL after some initial data transfers, for example in some
* SSL tunneling applications or as part of some kinds of application
* protocols which negotiate use of a SSL based security.
*/
SSLSocketImpl(SSLContextImpl sslContext, Socket sock,
String peerHost, int port, boolean autoClose) throws IOException {
super(sock);
// We always layer over a connected socket
if (!sock.isConnected()) {
throw new SocketException("Underlying socket is not connected");
}
this.sslContext = sslContext;
HandshakeHash handshakeHash = new HandshakeHash();
this.conContext = new TransportContext(sslContext, this,
new SSLSocketInputRecord(handshakeHash),
new SSLSocketOutputRecord(handshakeHash), true);
this.peerHost = peerHost;
this.autoClose = autoClose;
doneConnect();
}
@Override
public void connect(SocketAddress endpoint,
int timeout) throws IOException {
if (isLayered()) {
throw new SocketException("Already connected");
}
if (!(endpoint instanceof InetSocketAddress)) {
throw new SocketException(
"Cannot handle non-Inet socket addresses.");
}
super.connect(endpoint, timeout);
doneConnect();
}
@Override
public String[] getSupportedCipherSuites() {
return CipherSuite.namesOf(sslContext.getSupportedCipherSuites());
}
@Override
public synchronized String[] getEnabledCipherSuites() {
return CipherSuite.namesOf(conContext.sslConfig.enabledCipherSuites);
}
@Override
public synchronized void setEnabledCipherSuites(String[] suites) {
conContext.sslConfig.enabledCipherSuites =
CipherSuite.validValuesOf(suites);
}
@Override
public String[] getSupportedProtocols() {
return ProtocolVersion.toStringArray(
sslContext.getSupportedProtocolVersions());
}
@Override
public synchronized String[] getEnabledProtocols() {
return ProtocolVersion.toStringArray(
conContext.sslConfig.enabledProtocols);
}
@Override
public synchronized void setEnabledProtocols(String[] protocols) {
if (protocols == null) {
throw new IllegalArgumentException("Protocols cannot be null");
}
conContext.sslConfig.enabledProtocols =
ProtocolVersion.namesOf(protocols);
}
@Override
public SSLSession getSession() {
try {
// start handshaking, if failed, the connection will be closed.
ensureNegotiated();
} catch (IOException ioe) {
if (SSLLogger.isOn && SSLLogger.isOn("handshake")) {
SSLLogger.severe("handshake failed", ioe);
}
return SSLSessionImpl.nullSession;
}
return conContext.conSession;
}
@Override
public synchronized SSLSession getHandshakeSession() {
if (conContext.handshakeContext != null) {
synchronized (this) {
if (conContext.handshakeContext != null) {
return conContext.handshakeContext.handshakeSession;
}
}
}
return null;
}
@Override
public synchronized void addHandshakeCompletedListener(
HandshakeCompletedListener listener) {
if (listener == null) {
throw new IllegalArgumentException("listener is null");
}
conContext.sslConfig.addHandshakeCompletedListener(listener);
}
@Override
public synchronized void removeHandshakeCompletedListener(
HandshakeCompletedListener listener) {
if (listener == null) {
throw new IllegalArgumentException("listener is null");
}
conContext.sslConfig.removeHandshakeCompletedListener(listener);
}
@Override
public void startHandshake() throws IOException {
if (!isConnected) {
throw new SocketException("Socket is not connected");
}
if (conContext.isBroken || conContext.isInboundClosed() ||
conContext.isOutboundClosed()) {
throw new SocketException("Socket has been closed or broken");
}
synchronized (conContext) { // handshake lock
// double check the context status
if (conContext.isBroken || conContext.isInboundClosed() ||
conContext.isOutboundClosed()) {
throw new SocketException("Socket has been closed or broken");
}
try {
conContext.kickstart();
// All initial handshaking goes through this operation until we
// have a valid SSL connection.
//
// Handle handshake messages only, need no application data.
if (!conContext.isNegotiated) {
readHandshakeRecord();
}
} catch (IOException ioe) {
conContext.fatal(Alert.HANDSHAKE_FAILURE,
"Couldn't kickstart handshaking", ioe);
} catch (Exception oe) { // including RuntimeException
handleException(oe);
}
}
}
@Override
public synchronized void setUseClientMode(boolean mode) {
conContext.setUseClientMode(mode);
}
@Override
public synchronized boolean getUseClientMode() {
return conContext.sslConfig.isClientMode;
}
@Override
public synchronized void setNeedClientAuth(boolean need) {
conContext.sslConfig.clientAuthType =
(need ? ClientAuthType.CLIENT_AUTH_REQUIRED :
ClientAuthType.CLIENT_AUTH_NONE);
}
@Override
public synchronized boolean getNeedClientAuth() {
return (conContext.sslConfig.clientAuthType ==
ClientAuthType.CLIENT_AUTH_REQUIRED);
}
@Override
public synchronized void setWantClientAuth(boolean want) {
conContext.sslConfig.clientAuthType =
(want ? ClientAuthType.CLIENT_AUTH_REQUESTED :
ClientAuthType.CLIENT_AUTH_NONE);
}
@Override
public synchronized boolean getWantClientAuth() {
return (conContext.sslConfig.clientAuthType ==
ClientAuthType.CLIENT_AUTH_REQUESTED);
}
@Override
public synchronized void setEnableSessionCreation(boolean flag) {
conContext.sslConfig.enableSessionCreation = flag;
}
@Override
public synchronized boolean getEnableSessionCreation() {
return conContext.sslConfig.enableSessionCreation;
}
@Override
public boolean isClosed() {
return tlsIsClosed;
}
// Please don't synchronized this method. Otherwise, the read and close
// locks may be deadlocked.
@Override
public void close() throws IOException {
if (tlsIsClosed) {
return;
}
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.fine("duplex close of SSLSocket");
}
try {
// shutdown output bound, which may have been closed previously.
if (!isOutputShutdown()) {
duplexCloseOutput();
}
// shutdown input bound, which may have been closed previously.
if (!isInputShutdown()) {
duplexCloseInput();
}
if (!isClosed()) {
// close the connection directly
closeSocket(false);
}
} catch (IOException ioe) {
// ignore the exception
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.warning("SSLSocket duplex close failed", ioe);
}
} finally {
tlsIsClosed = true;
}
}
/**
* Duplex close, start from closing outbound.
*
* For TLS 1.2 [RFC 5246], unless some other fatal alert has been
* transmitted, each party is required to send a close_notify alert
* before closing the write side of the connection. The other party
* MUST respond with a close_notify alert of its own and close down
* the connection immediately, discarding any pending writes. It is
* not required for the initiator of the close to wait for the responding
* close_notify alert before closing the read side of the connection.
*
* For TLS 1.3, Each party MUST send a close_notify alert before
* closing its write side of the connection, unless it has already sent
* some error alert. This does not have any effect on its read side of
* the connection. Both parties need not wait to receive a close_notify
* alert before closing their read side of the connection, though doing
* so would introduce the possibility of truncation.
*
* In order to support user initiated duplex-close for TLS 1.3 connections,
* the user_canceled alert is used together with the close_notify alert.
*/
private void duplexCloseOutput() throws IOException {
boolean useUserCanceled = false;
boolean hasCloseReceipt = false;
if (conContext.isNegotiated) {
if (!conContext.protocolVersion.useTLS13PlusSpec()) {
hasCloseReceipt = true;
} else {
// Use a user_canceled alert for TLS 1.3 duplex close.
useUserCanceled = true;
}
} else if (conContext.handshakeContext != null) { // initial handshake
// Use user_canceled alert regardless the protocol versions.
useUserCanceled = true;
// The protocol version may have been negotiated.
ProtocolVersion pv = conContext.handshakeContext.negotiatedProtocol;
if (pv == null || (!pv.useTLS13PlusSpec())) {
hasCloseReceipt = true;
}
}
// Need a lock here so that the user_canceled alert and the
// close_notify alert can be delivered together.
try {
synchronized (conContext.outputRecord) {
// send a user_canceled alert if needed.
if (useUserCanceled) {
conContext.warning(Alert.USER_CANCELED);
}
// send a close_notify alert
conContext.warning(Alert.CLOSE_NOTIFY);
}
} finally {
if (!conContext.isOutboundClosed()) {
conContext.outputRecord.close();
}
if ((autoClose || !isLayered()) && !super.isOutputShutdown()) {
super.shutdownOutput();
}
}
if (!isInputShutdown()) {
bruteForceCloseInput(hasCloseReceipt);
}
}
/**
* Duplex close, start from closing inbound.
*
* This method should only be called when the outbound has been closed,
* but the inbound is still open.
*/
private void duplexCloseInput() throws IOException {
boolean hasCloseReceipt = false;
if (conContext.isNegotiated &&
!conContext.protocolVersion.useTLS13PlusSpec()) {
hasCloseReceipt = true;
} // No close receipt if handshake has no completed.
bruteForceCloseInput(hasCloseReceipt);
}
/**
* Brute force close the input bound.
*
* This method should only be called when the outbound has been closed,
* but the inbound is still open.
*/
private void bruteForceCloseInput(
boolean hasCloseReceipt) throws IOException {
if (hasCloseReceipt) {
// It is not required for the initiator of the close to wait for
// the responding close_notify alert before closing the read side
// of the connection. However, if the application protocol using
// TLS provides that any data may be carried over the underlying
// transport after the TLS connection is closed, the TLS
// implementation MUST receive a "close_notify" alert before
// indicating end-of-data to the application-layer.
try {
this.shutdown();
} finally {
if (!isInputShutdown()) {
shutdownInput(false);
}
}
} else {
if (!conContext.isInboundClosed()) {
conContext.inputRecord.close();
}
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
super.shutdownInput();
}
}
}
// Please don't synchronized this method. Otherwise, the read and close
// locks may be deadlocked.
@Override
public void shutdownInput() throws IOException {
shutdownInput(true);
}
// It is not required to check the close_notify receipt unless an
// application call shutdownInput() explicitly.
private void shutdownInput(
boolean checkCloseNotify) throws IOException {
if (isInputShutdown()) {
return;
}
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.fine("close inbound of SSLSocket");
}
// Is it ready to close inbound?
//
// No need to throw exception if the initial handshake is not started.
if (checkCloseNotify && !conContext.isInputCloseNotified &&
(conContext.isNegotiated || conContext.handshakeContext != null)) {
conContext.fatal(Alert.INTERNAL_ERROR,
"closing inbound before receiving peer's close_notify");
}
conContext.closeInbound();
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
super.shutdownInput();
}
}
@Override
public boolean isInputShutdown() {
return conContext.isInboundClosed() &&
((autoClose || !isLayered()) ? super.isInputShutdown(): true);
}
// Please don't synchronized this method. Otherwise, the read and close
// locks may be deadlocked.
@Override
public void shutdownOutput() throws IOException {
if (isOutputShutdown()) {
return;
}
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.fine("close outbound of SSLSocket");
}
conContext.closeOutbound();
if ((autoClose || !isLayered()) && !super.isOutputShutdown()) {
super.shutdownOutput();
}
}
@Override
public boolean isOutputShutdown() {
return conContext.isOutboundClosed() &&
((autoClose || !isLayered()) ? super.isOutputShutdown(): true);
}
@Override
public synchronized InputStream getInputStream() throws IOException {
if (isClosed()) {
throw new SocketException("Socket is closed");
}
if (!isConnected) {
throw new SocketException("Socket is not connected");
}
if (conContext.isInboundClosed() || isInputShutdown()) {
throw new SocketException("Socket input is already shutdown");
}
return appInput;
}
private void ensureNegotiated() throws IOException {
if (conContext.isNegotiated || conContext.isBroken ||
conContext.isInboundClosed() || conContext.isOutboundClosed()) {
return;
}
synchronized (conContext) { // handshake lock
// double check the context status
if (conContext.isNegotiated || conContext.isBroken ||
conContext.isInboundClosed() ||
conContext.isOutboundClosed()) {
return;
}
startHandshake();
}
}
/**
* InputStream for application data as returned by
* SSLSocket.getInputStream().
*/
private class AppInputStream extends InputStream {
// One element array used to implement the single byte read() method
private final byte[] oneByte = new byte[1];
// the temporary buffer used to read network
private ByteBuffer buffer;
// Is application data available in the stream?
private volatile boolean appDataIsAvailable;
AppInputStream() {
this.appDataIsAvailable = false;
this.buffer = ByteBuffer.allocate(4096);
}
/**
* Return the minimum number of bytes that can be read
* without blocking.
*/
@Override
public int available() throws IOException {
// Currently not synchronized.
if ((!appDataIsAvailable) || checkEOF()) {
return 0;
}
return buffer.remaining();
}
/**
* Read a single byte, returning -1 on non-fault EOF status.
*/
@Override
public int read() throws IOException {
int n = read(oneByte, 0, 1);
if (n <= 0) { // EOF
return -1;
}
return oneByte[0] & 0xFF;
}
/**
* Reads up to {@code len} bytes of data from the input stream
* into an array of bytes.
*
* An attempt is made to read as many as {@code len} bytes, but a
* smaller number may be read. The number of bytes actually read
* is returned as an integer.
*
* If the layer above needs more data, it asks for more, so we
* are responsible only for blocking to fill at most one buffer,
* and returning "-1" on non-fault EOF status.
*/
@Override
public int read(byte[] b, int off, int len)
throws IOException {
if (b == null) {
throw new NullPointerException("the target buffer is null");
} else if (off < 0 || len < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException(
"buffer length: " + b.length + ", offset; " + off +
", bytes to read:" + len);
} else if (len == 0) {
return 0;
}
if (checkEOF()) {
return -1;
}
// start handshaking if the connection has not been negotiated.
if (!conContext.isNegotiated && !conContext.isBroken &&
!conContext.isInboundClosed() &&
!conContext.isOutboundClosed()) {
ensureNegotiated();
}
// Check if the Socket is invalid (error or closed).
if (!conContext.isNegotiated ||
conContext.isBroken || conContext.isInboundClosed()) {
throw new SocketException("Connection or inbound has closed");
}
// Read the available bytes at first.
//
// Note that the receiving and processing of post-handshake message
// are also synchronized with the read lock.
synchronized (this) {
int remains = available();
if (remains > 0) {
int howmany = Math.min(remains, len);
buffer.get(b, off, howmany);
return howmany;
}
appDataIsAvailable = false;
try {
ByteBuffer bb = readApplicationRecord(buffer);
if (bb == null) { // EOF
return -1;
} else {
// The buffer may be reallocated for bigger capacity.
buffer = bb;
}
bb.flip();
int volume = Math.min(len, bb.remaining());
buffer.get(b, off, volume);
appDataIsAvailable = true;
return volume;
} catch (Exception e) { // including RuntimeException
// shutdown and rethrow (wrapped) exception as appropriate
handleException(e);
// dummy for compiler
return -1;
}
}
}
/**
* Skip n bytes.
*
* This implementation is somewhat less efficient than possible, but
* not badly so (redundant copy). We reuse the read() code to keep
* things simpler. Note that SKIP_ARRAY is static and may garbled by
* concurrent use, but we are not interested in the data anyway.
*/
@Override
public synchronized long skip(long n) throws IOException {
// dummy array used to implement skip()
byte[] skipArray = new byte[256];
long skipped = 0;
while (n > 0) {
int len = (int)Math.min(n, skipArray.length);
int r = read(skipArray, 0, len);
if (r <= 0) {
break;
}
n -= r;
skipped += r;
}
return skipped;
}
@Override
public void close() throws IOException {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.finest("Closing input stream");
}
try {
shutdownInput(false);
} catch (IOException ioe) {
// ignore the exception
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.warning("input stream close failed", ioe);
}
}
}
/**
* Return whether we have reached end-of-file.
*
* If the socket is not connected, has been shutdown because of an error
* or has been closed, throw an Exception.
*/
private boolean checkEOF() throws IOException {
if (conContext.isInboundClosed()) {
return true;
} else if (conContext.isInputCloseNotified || conContext.isBroken) {
if (conContext.closeReason == null) {
return true;
} else {
throw new SSLException(
"Connection has closed: " + conContext.closeReason,
conContext.closeReason);
}
}
return false;
}
}
@Override
public synchronized OutputStream getOutputStream() throws IOException {
if (isClosed()) {
throw new SocketException("Socket is closed");
}
if (!isConnected) {
throw new SocketException("Socket is not connected");
}
if (conContext.isOutboundDone() || isOutputShutdown()) {
throw new SocketException("Socket output is already shutdown");
}
return appOutput;
}
/**
* OutputStream for application data as returned by
* SSLSocket.getOutputStream().
*/
private class AppOutputStream extends OutputStream {
// One element array used to implement the write(byte) method
private final byte[] oneByte = new byte[1];
@Override
public void write(int i) throws IOException {
oneByte[0] = (byte)i;
write(oneByte, 0, 1);
}
@Override
public void write(byte[] b,
int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException("the source buffer is null");
} else if (off < 0 || len < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException(
"buffer length: " + b.length + ", offset; " + off +
", bytes to read:" + len);
} else if (len == 0) {
//
// Don't bother to really write empty records. We went this
// far to drive the handshake machinery, for correctness; not
// writing empty records improves performance by cutting CPU
// time and network resource usage. However, some protocol
// implementations are fragile and don't like to see empty
// records, so this also increases robustness.
//
return;
}
// Start handshaking if the connection has not been negotiated.
if (!conContext.isNegotiated && !conContext.isBroken &&
!conContext.isInboundClosed() &&
!conContext.isOutboundClosed()) {
ensureNegotiated();
}
// Check if the Socket is invalid (error or closed).
if (!conContext.isNegotiated ||
conContext.isBroken || conContext.isOutboundClosed()) {
throw new SocketException("Connection or outbound has closed");
}
//
// Delegate the writing to the underlying socket.
try {
conContext.outputRecord.deliver(b, off, len);
} catch (SSLHandshakeException she) {
// may be record sequence number overflow
conContext.fatal(Alert.HANDSHAKE_FAILURE, she);
} catch (IOException e) {
conContext.fatal(Alert.UNEXPECTED_MESSAGE, e);
}
// Is the sequence number is nearly overflow, or has the key usage
// limit been reached?
if (conContext.outputRecord.seqNumIsHuge() ||
conContext.outputRecord.writeCipher.atKeyLimit()) {
tryKeyUpdate();
}
}
@Override
public void close() throws IOException {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.finest("Closing output stream");
}
try {
shutdownOutput();
} catch (IOException ioe) {
// ignore the exception
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.warning("output stream close failed", ioe);
}
}
}
}
@Override
public synchronized SSLParameters getSSLParameters() {
return conContext.sslConfig.getSSLParameters();
}
@Override
public synchronized void setSSLParameters(SSLParameters params) {
conContext.sslConfig.setSSLParameters(params);
if (conContext.sslConfig.maximumPacketSize != 0) {
conContext.outputRecord.changePacketSize(
conContext.sslConfig.maximumPacketSize);
}
}
@Override
public synchronized String getApplicationProtocol() {
return conContext.applicationProtocol;
}
@Override
public synchronized String getHandshakeApplicationProtocol() {
if (conContext.handshakeContext != null) {
return conContext.handshakeContext.applicationProtocol;
}
return null;
}
@Override
public synchronized void setHandshakeApplicationProtocolSelector(
BiFunction<SSLSocket, List<String>, String> selector) {
conContext.sslConfig.socketAPSelector = selector;
}
@Override
public synchronized BiFunction<SSLSocket, List<String>, String>
getHandshakeApplicationProtocolSelector() {
return conContext.sslConfig.socketAPSelector;
}
/**
* Read the initial handshake records.
*/
private int readHandshakeRecord() throws IOException {
while (!conContext.isInboundClosed()) {
try {
Plaintext plainText = decode(null);
if ((plainText.contentType == ContentType.HANDSHAKE.id) &&
conContext.isNegotiated) {
return 0;
}
} catch (SSLException ssle) {
throw ssle;
} catch (IOException ioe) {
if (!(ioe instanceof SSLException)) {
throw new SSLException("readHandshakeRecord", ioe);
} else {
throw ioe;
}
}
}
return -1;
}
/**
* Read application data record. Used by AppInputStream only, but defined
* here so as to use the socket level synchronization.
*
* Note that the connection guarantees that handshake, alert, and change
* cipher spec data streams are handled as they arrive, so we never see
* them here.
*
* Note: Please be careful about the synchronization, and don't use this
* method other than in the AppInputStream class!
*/
private ByteBuffer readApplicationRecord(
ByteBuffer buffer) throws IOException {
while (!conContext.isInboundClosed()) {
/*
* clean the buffer and check if it is too small, e.g. because
* the AppInputStream did not have the chance to see the
* current packet length but rather something like that of the
* handshake before. In that case we return 0 at this point to
* give the caller the chance to adjust the buffer.
*/
buffer.clear();
int inLen = conContext.inputRecord.bytesInCompletePacket();
if (inLen < 0) { // EOF
handleEOF(null);
// if no exception thrown
return null;
}
// Is this packet bigger than SSL/TLS normally allows?
if (inLen > SSLRecord.maxLargeRecordSize) {
throw new SSLProtocolException(
"Illegal packet size: " + inLen);
}
if (inLen > buffer.remaining()) {
buffer = ByteBuffer.allocate(inLen);
}
try {
Plaintext plainText;
synchronized (this) {
plainText = decode(buffer);
}
if (plainText.contentType == ContentType.APPLICATION_DATA.id &&
buffer.position() > 0) {
return buffer;
}
} catch (SSLException ssle) {
throw ssle;
} catch (IOException ioe) {
if (!(ioe instanceof SSLException)) {
throw new SSLException("readApplicationRecord", ioe);
} else {
throw ioe;
}
}
}
//
// couldn't read, due to some kind of error
//
return null;
}
private Plaintext decode(ByteBuffer destination) throws IOException {
Plaintext plainText;
try {
if (destination == null) {
plainText = SSLTransport.decode(conContext,
null, 0, 0, null, 0, 0);
} else {
plainText = SSLTransport.decode(conContext,
null, 0, 0, new ByteBuffer[]{destination}, 0, 1);
}
} catch (EOFException eofe) {
// EOFException is special as it is related to close_notify.
plainText = handleEOF(eofe);
}
// Is the sequence number is nearly overflow?
if (plainText != Plaintext.PLAINTEXT_NULL &&
(conContext.inputRecord.seqNumIsHuge() ||
conContext.inputRecord.readCipher.atKeyLimit())) {
tryKeyUpdate();
}
return plainText;
}
/**
* Try key update for sequence number wrap or key usage limit.
*
* Note that in order to maintain the handshake status properly, we check
* the sequence number and key usage limit after the last record
* reading/writing process.
*
* As we request renegotiation or close the connection for wrapped sequence
* number when there is enough sequence number space left to handle a few
* more records, so the sequence number of the last record cannot be
* wrapped.
*/
private void tryKeyUpdate() throws IOException {
// Don't bother to kickstart if handshaking is in progress, or if the
// connection is not duplex-open.
if ((conContext.handshakeContext == null) &&
!conContext.isOutboundClosed() &&
!conContext.isInboundClosed() &&
!conContext.isBroken) {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.finest("trigger key update");
}
startHandshake();
}
}
/**
* Initialize the handshaker and socket streams.
*
* Called by connect, the layered constructor, and SSLServerSocket.
*/
synchronized void doneConnect() throws IOException {
// In server mode, it is not necessary to set host and serverNames.
// Otherwise, would require a reverse DNS lookup to get the hostname.
if ((peerHost == null) || (peerHost.length() == 0)) {
boolean useNameService =
trustNameService && conContext.sslConfig.isClientMode;
useImplicitHost(useNameService);
} else {
conContext.sslConfig.serverNames =
Utilities.addToSNIServerNameList(
conContext.sslConfig.serverNames, peerHost);
}
InputStream sockInput = super.getInputStream();
conContext.inputRecord.setReceiverStream(sockInput);
OutputStream sockOutput = super.getOutputStream();
conContext.inputRecord.setDeliverStream(sockOutput);
conContext.outputRecord.setDeliverStream(sockOutput);
this.isConnected = true;
}
private void useImplicitHost(boolean useNameService) {
// Note: If the local name service is not trustworthy, reverse
// host name resolution should not be performed for endpoint
// identification. Use the application original specified
// hostname or IP address instead.
// Get the original hostname via jdk.internal.misc.SharedSecrets
InetAddress inetAddress = getInetAddress();
if (inetAddress == null) { // not connected
return;
}
JavaNetInetAddressAccess jna =
SharedSecrets.getJavaNetInetAddressAccess();
String originalHostname = jna.getOriginalHostName(inetAddress);
if ((originalHostname != null) &&
(originalHostname.length() != 0)) {
this.peerHost = originalHostname;
if (conContext.sslConfig.serverNames.isEmpty() &&
!conContext.sslConfig.noSniExtension) {
conContext.sslConfig.serverNames =
Utilities.addToSNIServerNameList(
conContext.sslConfig.serverNames, peerHost);
}
return;
}
// No explicitly specified hostname, no server name indication.
if (!useNameService) {
// The local name service is not trustworthy, use IP address.
this.peerHost = inetAddress.getHostAddress();
} else {
// Use the underlying reverse host name resolution service.
this.peerHost = getInetAddress().getHostName();
}
}
// ONLY used by HttpsClient to setup the URI specified hostname
//
// Please NOTE that this method MUST be called before calling to
// SSLSocket.setSSLParameters(). Otherwise, the {@code host} parameter
// may override SNIHostName in the customized server name indication.
public synchronized void setHost(String host) {
this.peerHost = host;
this.conContext.sslConfig.serverNames =
Utilities.addToSNIServerNameList(
conContext.sslConfig.serverNames, host);
}
/**
* Handle an exception.
*
* This method is called by top level exception handlers (in read(),
* write()) to make sure we always shutdown the connection correctly
* and do not pass runtime exception to the application.
*
* This method never returns normally, it always throws an IOException.
*/
private void handleException(Exception cause) throws IOException {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.warning("handling exception", cause);
}
// Don't close the Socket in case of timeouts or interrupts.
if (cause instanceof InterruptedIOException) {
throw (IOException)cause;
}
// need to perform error shutdown
boolean isSSLException = (cause instanceof SSLException);
Alert alert;
if (isSSLException) {
if (cause instanceof SSLHandshakeException) {
alert = Alert.HANDSHAKE_FAILURE;
} else {
alert = Alert.UNEXPECTED_MESSAGE;
}
} else {
if (cause instanceof IOException) {
alert = Alert.UNEXPECTED_MESSAGE;
} else {
// RuntimeException
alert = Alert.INTERNAL_ERROR;
}
}
conContext.fatal(alert, cause);
}
private Plaintext handleEOF(EOFException eofe) throws IOException {
if (requireCloseNotify || conContext.handshakeContext != null) {
SSLException ssle;
if (conContext.handshakeContext != null) {
ssle = new SSLHandshakeException(
"Remote host terminated the handshake");
} else {
ssle = new SSLProtocolException(
"Remote host terminated the connection");
}
if (eofe != null) {
ssle.initCause(eofe);
}
throw ssle;
} else {
// treat as if we had received a close_notify
conContext.isInputCloseNotified = true;
shutdownInput();
return Plaintext.PLAINTEXT_NULL;
}
}
@Override
public String getPeerHost() {
return peerHost;
}
@Override
public int getPeerPort() {
return getPort();
}
@Override
public boolean useDelegatedTask() {
return false;
}
@Override
public void shutdown() throws IOException {
if (!isClosed()) {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.fine("close the underlying socket");
}
try {
if (conContext.isInputCloseNotified) {
// Close the connection, no wait for more peer response.
closeSocket(false);
} else {
// Close the connection, may wait for peer close_notify.
closeSocket(true);
}
} finally {
tlsIsClosed = true;
}
}
}
private void closeSocket(boolean selfInitiated) throws IOException {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.fine("close the SSL connection " +
(selfInitiated ? "(initiative)" : "(passive)"));
}
if (autoClose || !isLayered()) {
super.close();
} else if (selfInitiated) {
if (!conContext.isInboundClosed() && !isInputShutdown()) {
// wait for close_notify alert to clear input stream.
waitForClose();
}
}
}
/**
* Wait for close_notify alert for a graceful closure.
*
* [RFC 5246] If the application protocol using TLS provides that any
* data may be carried over the underlying transport after the TLS
* connection is closed, the TLS implementation must receive the responding
* close_notify alert before indicating to the application layer that
* the TLS connection has ended. If the application protocol will not
* transfer any additional data, but will only close the underlying
* transport connection, then the implementation MAY choose to close the
* transport without waiting for the responding close_notify.
*/
private void waitForClose() throws IOException {
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.fine("wait for close_notify or alert");
}
while (!conContext.isInboundClosed()) {
try {
Plaintext plainText = decode(null);
// discard and continue
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
SSLLogger.finest(
"discard plaintext while waiting for close", plainText);
}
} catch (Exception e) { // including RuntimeException
handleException(e);
}
}
}
}
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
>
<LinearLayout
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:orientation="vertical"
>
<TextView
android:id="@+id/cancel_item_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
/>
<TextView
android:id="@+id/cancel_item_summary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
/>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
| {
"pile_set_name": "Github"
} |
:doctype: book
:idprefix:
:idseparator: -
:toc: left
:toclevels: 4
:tabsize: 4
:numbered:
:sectanchors:
:sectnums:
:icons: font
:hide-uri-scheme:
:docinfo: shared,private
:sc-ext: java
:project-full-name: Spring Cloud Vault
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2002 Michael Niedermayer <[email protected]>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* simple arithmetic expression evaluator
*/
#ifndef AVUTIL_EVAL_H
#define AVUTIL_EVAL_H
#include "avutil.h"
typedef struct AVExpr AVExpr;
/**
* Parse and evaluate an expression.
* Note, this is significantly slower than av_expr_eval().
*
* @param res a pointer to a double where is put the result value of
* the expression, or NAN in case of error
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
* @param const_values a zero terminated array of values for the identifiers from const_names
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
* @param log_ctx parent logging context
* @return >= 0 in case of success, a negative value corresponding to an
* AVERROR code otherwise
*/
int av_expr_parse_and_eval(double *res, const char *s,
const char * const *const_names, const double *const_values,
const char * const *func1_names, double (* const *funcs1)(void *, double),
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
void *opaque, int log_offset, void *log_ctx);
/**
* Parse an expression.
*
* @param expr a pointer where is put an AVExpr containing the parsed
* value in case of successful parsing, or NULL otherwise.
* The pointed to AVExpr must be freed with av_expr_free() by the user
* when it is not needed anymore.
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
* @param log_ctx parent logging context
* @return >= 0 in case of success, a negative value corresponding to an
* AVERROR code otherwise
*/
int av_expr_parse(AVExpr **expr, const char *s,
const char * const *const_names,
const char * const *func1_names, double (* const *funcs1)(void *, double),
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
int log_offset, void *log_ctx);
/**
* Evaluate a previously parsed expression.
*
* @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
* @return the value of the expression
*/
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
/**
* Free a parsed expression previously created with av_expr_parse().
*/
void av_expr_free(AVExpr *e);
/**
* Parse the string in numstr and return its value as a double. If
* the string is empty, contains only whitespaces, or does not contain
* an initial substring that has the expected syntax for a
* floating-point number, no conversion is performed. In this case,
* returns a value of zero and the value returned in tail is the value
* of numstr.
*
* @param numstr a string representing a number, may contain one of
* the International System number postfixes, for example 'K', 'M',
* 'G'. If 'i' is appended after the postfix, powers of 2 are used
* instead of powers of 10. The 'B' postfix multiplies the value for
* 8, and can be appended after another postfix or used alone. This
* allows using for example 'KB', 'MiB', 'G' and 'B' as postfix.
* @param tail if non-NULL puts here the pointer to the char next
* after the last parsed character
*/
double av_strtod(const char *numstr, char **tail);
#endif /* AVUTIL_EVAL_H */
| {
"pile_set_name": "Github"
} |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import find_mxnet
import mxnet as mx
import logging
import argparse
import train_model
import time
# don't use -n and -s, which are resevered for the distributed training
parser = argparse.ArgumentParser(description='train an image classifer on Kaggle Data Science Bowl 1')
parser.add_argument('--network', type=str, default='dsb',
help = 'the cnn to use')
parser.add_argument('--data-dir', type=str, default="data48/",
help='the input data directory')
parser.add_argument('--save-model-prefix', type=str,default= "./models/sample_net",
help='the prefix of the model to load/save')
parser.add_argument('--lr', type=float, default=.01,
help='the initial learning rate')
parser.add_argument('--lr-factor', type=float, default=1,
help='times the lr with a factor for every lr-factor-epoch epoch')
parser.add_argument('--lr-factor-epoch', type=float, default=15,
help='the number of epoch to factor the lr, could be .5')
parser.add_argument('--clip-gradient', type=float, default=5.,
help='clip min/max gradient to prevent extreme value')
parser.add_argument('--num-epochs', type=int, default=100,
help='the number of training epochs')
parser.add_argument('--load-epoch', type=int,
help="load the model on an epoch using the model-prefix")
parser.add_argument('--batch-size', type=int, default=64,
help='the batch size')
parser.add_argument('--gpus', type=str,
help='the gpus will be used, e.g "0,1,2,3"')
parser.add_argument('--kv-store', type=str, default='local',
help='the kvstore type')
parser.add_argument('--num-examples', type=int, default=20000,
help='the number of training examples')
parser.add_argument('--num-classes', type=int, default=121,
help='the number of classes')
parser.add_argument('--log-file', type=str,
help='the name of log file')
parser.add_argument('--log-dir', type=str, default="/tmp/",
help='directory of the log file')
args = parser.parse_args()
# network
import importlib
net = importlib.import_module('symbol_' + args.network).get_symbol(args.num_classes)
# data
def get_iterator(args, kv):
data_shape = (3, 36, 36)
# train data iterator
train = mx.io.ImageRecordIter(
path_imgrec = args.data_dir + "tr.rec",
mean_r = 128,
mean_g = 128,
mean_b = 128,
scale = 0.0078125,
max_aspect_ratio = 0.35,
data_shape = data_shape,
batch_size = args.batch_size,
rand_crop = True,
rand_mirror = True,
)
# validate data iterator
val = mx.io.ImageRecordIter(
path_imgrec = args.data_dir + "va.rec",
mean_r = 128,
mean_b = 128,
mean_g = 128,
scale = 0.0078125,
rand_crop = False,
rand_mirror = False,
data_shape = data_shape,
batch_size = args.batch_size)
return (train, val)
# train
tic=time.time()
train_model.fit(args, net, get_iterator)
print "time elapsed to train model", time.time()-tic
| {
"pile_set_name": "Github"
} |
<?php
/**
* Validates https (Secure HTTP) according to http scheme.
*/
class HTMLPurifier_URIScheme_https extends HTMLPurifier_URIScheme_http {
public $default_port = 443;
}
// vim: et sw=4 sts=4
| {
"pile_set_name": "Github"
} |
# To convert DocBook XML to PDF
xmlto pdf mydoc.xml
# To convert DocBook XML to HTML
xmlto -o html-dir html mydoc.xml
# To convert DocBook XML to single HTML file
xmlto html-nochunks mydoc.xml
# To modify output with XSL override
xmlto -m ulink.xsl pdf mydoc.xml
# To use non-default xsl
xmlto -x mystylesheet.xsl pdf mydoc.xml
| {
"pile_set_name": "Github"
} |
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OfficeOpenXml;
namespace EPPlusTest
{
[TestClass]
public class ExcelRangeBaseTests : TestBase
{
[TestMethod]
public void CopyCopiesCommentsFromSingleCellRanges()
{
InitBase();
var pck = new ExcelPackage();
var ws1 = pck.Workbook.Worksheets.Add("CommentCopying");
var sourceExcelRange = ws1.Cells[3, 3];
Assert.IsNull(sourceExcelRange.Comment);
sourceExcelRange.AddComment("Testing comment 1", "test1");
Assert.AreEqual("test1", sourceExcelRange.Comment.Author);
Assert.AreEqual("Testing comment 1", sourceExcelRange.Comment.Text);
var destinationExcelRange = ws1.Cells[5, 5];
Assert.IsNull(destinationExcelRange.Comment);
sourceExcelRange.Copy(destinationExcelRange);
// Assert the original comment is intact.
Assert.AreEqual("test1", sourceExcelRange.Comment.Author);
Assert.AreEqual("Testing comment 1", sourceExcelRange.Comment.Text);
// Assert the comment was copied.
Assert.AreEqual("test1", destinationExcelRange.Comment.Author);
Assert.AreEqual("Testing comment 1", destinationExcelRange.Comment.Text);
}
[TestMethod]
public void CopyCopiesCommentsFromMultiCellRanges()
{
InitBase();
var pck = new ExcelPackage();
var ws1 = pck.Workbook.Worksheets.Add("CommentCopying");
var sourceExcelRangeC3 = ws1.Cells[3, 3];
var sourceExcelRangeD3 = ws1.Cells[3, 4];
var sourceExcelRangeE3 = ws1.Cells[3, 5];
Assert.IsNull(sourceExcelRangeC3.Comment);
Assert.IsNull(sourceExcelRangeD3.Comment);
Assert.IsNull(sourceExcelRangeE3.Comment);
sourceExcelRangeC3.AddComment("Testing comment 1", "test1");
sourceExcelRangeD3.AddComment("Testing comment 2", "test1");
sourceExcelRangeE3.AddComment("Testing comment 3", "test1");
Assert.AreEqual("test1", sourceExcelRangeC3.Comment.Author);
Assert.AreEqual("Testing comment 1", sourceExcelRangeC3.Comment.Text);
Assert.AreEqual("test1", sourceExcelRangeD3.Comment.Author);
Assert.AreEqual("Testing comment 2", sourceExcelRangeD3.Comment.Text);
Assert.AreEqual("test1", sourceExcelRangeE3.Comment.Author);
Assert.AreEqual("Testing comment 3", sourceExcelRangeE3.Comment.Text);
// Copy the full row to capture each cell at once.
Assert.IsNull(ws1.Cells[5, 3].Comment);
Assert.IsNull(ws1.Cells[5, 4].Comment);
Assert.IsNull(ws1.Cells[5, 5].Comment);
ws1.Cells["3:3"].Copy(ws1.Cells["5:5"]);
// Assert the original comments are intact.
Assert.AreEqual("test1", sourceExcelRangeC3.Comment.Author);
Assert.AreEqual("Testing comment 1", sourceExcelRangeC3.Comment.Text);
Assert.AreEqual("test1", sourceExcelRangeD3.Comment.Author);
Assert.AreEqual("Testing comment 2", sourceExcelRangeD3.Comment.Text);
Assert.AreEqual("test1", sourceExcelRangeE3.Comment.Author);
Assert.AreEqual("Testing comment 3", sourceExcelRangeE3.Comment.Text);
// Assert the comments were copied.
var destinationExcelRangeC5 = ws1.Cells[5, 3];
var destinationExcelRangeD5 = ws1.Cells[5, 4];
var destinationExcelRangeE5 = ws1.Cells[5, 5];
Assert.AreEqual("test1", destinationExcelRangeC5.Comment.Author);
Assert.AreEqual("Testing comment 1", destinationExcelRangeC5.Comment.Text);
Assert.AreEqual("test1", destinationExcelRangeD5.Comment.Author);
Assert.AreEqual("Testing comment 2", destinationExcelRangeD5.Comment.Text);
Assert.AreEqual("test1", destinationExcelRangeE5.Comment.Author);
Assert.AreEqual("Testing comment 3", destinationExcelRangeE5.Comment.Text);
}
[TestMethod]
public void SettingAddressHandlesMultiAddresses()
{
using (ExcelPackage package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
var name = package.Workbook.Names.Add("Test", worksheet.Cells[3, 3]);
name.Address = "Sheet1!C3";
name.Address = "Sheet1!D3";
Assert.IsNull(name.Addresses);
name.Address = "C3:D3,E3:F3";
Assert.IsNotNull(name.Addresses);
name.Address = "Sheet1!C3";
Assert.IsNull(name.Addresses);
}
}
}
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <[email protected]>
*
*/
#ifndef __LWIP_TCP_IMPL_H__
#define __LWIP_TCP_IMPL_H__
#include "lwip/opt.h"
#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */
#include "lwip/tcp.h"
#include "lwip/mem.h"
#include "lwip/pbuf.h"
#include "lwip/ip.h"
#include "lwip/icmp.h"
#include "lwip/err.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Functions for interfacing with TCP: */
/* Lower layer interface to TCP: */
void tcp_init (void); /* Initialize this module. */
void tcp_tmr (void); /* Must be called every
TCP_TMR_INTERVAL
ms. (Typically 250 ms). */
/* It is also possible to call these two functions at the right
intervals (instead of calling tcp_tmr()). */
void tcp_slowtmr (void);
void tcp_fasttmr (void);
/* Only used by IP to pass a TCP segment to TCP: */
void tcp_input (struct pbuf *p, struct netif *inp);
/* Used within the TCP code only: */
struct tcp_pcb * tcp_alloc (u8_t prio);
void tcp_abandon (struct tcp_pcb *pcb, int reset);
err_t tcp_send_empty_ack(struct tcp_pcb *pcb);
void tcp_rexmit (struct tcp_pcb *pcb);
void tcp_rexmit_rto (struct tcp_pcb *pcb);
void tcp_rexmit_fast (struct tcp_pcb *pcb);
u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb);
err_t tcp_process_refused_data(struct tcp_pcb *pcb);
/**
* This is the Nagle algorithm: try to combine user data to send as few TCP
* segments as possible. Only send if
* - no previously transmitted data on the connection remains unacknowledged or
* - the TF_NODELAY flag is set (nagle algorithm turned off for this pcb) or
* - the only unsent segment is at least pcb->mss bytes long (or there is more
* than one unsent segment - with lwIP, this can happen although unsent->len < mss)
* - or if we are in fast-retransmit (TF_INFR)
*/
#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \
((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \
(((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \
((tpcb)->unsent->len >= (tpcb)->mss))) || \
((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \
) ? 1 : 0)
#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK)
#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0)
#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0)
#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0)
#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0)
/* is b<=a<=c? */
#if 0 /* see bug #10548 */
#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b))
#endif
#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c))
#define TCP_FIN 0x01U
#define TCP_SYN 0x02U
#define TCP_RST 0x04U
#define TCP_PSH 0x08U
#define TCP_ACK 0x10U
#define TCP_URG 0x20U
#define TCP_ECE 0x40U
#define TCP_CWR 0x80U
#define TCP_FLAGS 0x3fU
/* Length of the TCP header, excluding options. */
#define TCP_HLEN 20
#ifndef TCP_TMR_INTERVAL
#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */
#endif /* TCP_TMR_INTERVAL */
#ifndef TCP_FAST_INTERVAL
#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */
#endif /* TCP_FAST_INTERVAL */
#ifndef TCP_SLOW_INTERVAL
#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */
#endif /* TCP_SLOW_INTERVAL */
#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */
#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */
#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */
#ifndef TCP_MSL
#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */
#endif
/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */
#ifndef TCP_KEEPIDLE_DEFAULT
#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */
#endif
#ifndef TCP_KEEPINTVL_DEFAULT
#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */
#endif
#ifndef TCP_KEEPCNT_DEFAULT
#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */
#endif
#define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */
/* Fields are (of course) in network byte order.
* Some fields are converted to host byte order in tcp_input().
*/
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h"
#endif
PACK_STRUCT_BEGIN
struct tcp_hdr {
PACK_STRUCT_FIELD(u16_t src);
PACK_STRUCT_FIELD(u16_t dest);
PACK_STRUCT_FIELD(u32_t seqno);
PACK_STRUCT_FIELD(u32_t ackno);
PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags);
PACK_STRUCT_FIELD(u16_t wnd);
PACK_STRUCT_FIELD(u16_t chksum);
PACK_STRUCT_FIELD(u16_t urgp);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h"
#endif
#define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12)
#define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS)
#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr))
#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS((u16_t)(~(u16_t)(TCP_FLAGS)))) | htons(flags))
#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags))
#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags))
#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (TCPH_FLAGS(phdr) & ~(flags)) )
#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0))
/** Flags used on input processing, not on pcb->flags
*/
#define TF_RESET (u8_t)0x08U /* Connection was reset. */
#define TF_CLOSED (u8_t)0x10U /* Connection was sucessfully closed. */
#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */
#if LWIP_EVENT_API
#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_ACCEPT, NULL, 0, err)
#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_SENT, NULL, space, ERR_OK)
#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_RECV, (p), 0, (err))
#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_RECV, NULL, 0, ERR_OK)
#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_CONNECTED, NULL, 0, (err))
#define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
LWIP_EVENT_POLL, NULL, 0, ERR_OK)
#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \
LWIP_EVENT_ERR, NULL, 0, (err))
#else /* LWIP_EVENT_API */
#define TCP_EVENT_ACCEPT(pcb,err,ret) \
do { \
if((pcb)->accept != NULL) \
(ret) = (pcb)->accept((pcb)->callback_arg,(pcb),(err)); \
else (ret) = ERR_ARG; \
} while (0)
#define TCP_EVENT_SENT(pcb,space,ret) \
do { \
if((pcb)->sent != NULL) \
(ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \
else (ret) = ERR_OK; \
} while (0)
#define TCP_EVENT_RECV(pcb,p,err,ret) \
do { \
if((pcb)->recv != NULL) { \
(ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\
} else { \
(ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \
} \
} while (0)
#define TCP_EVENT_CLOSED(pcb,ret) \
do { \
if(((pcb)->recv != NULL)) { \
(ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\
} else { \
(ret) = ERR_OK; \
} \
} while (0)
#define TCP_EVENT_CONNECTED(pcb,err,ret) \
do { \
if((pcb)->connected != NULL) \
(ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \
else (ret) = ERR_OK; \
} while (0)
#define TCP_EVENT_POLL(pcb,ret) \
do { \
if((pcb)->poll != NULL) \
(ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \
else (ret) = ERR_OK; \
} while (0)
#define TCP_EVENT_ERR(errf,arg,err) \
do { \
if((errf) != NULL) \
(errf)((arg),(err)); \
} while (0)
#endif /* LWIP_EVENT_API */
/** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */
#if TCP_OVERSIZE && defined(LWIP_DEBUG)
#define TCP_OVERSIZE_DBGCHECK 1
#else
#define TCP_OVERSIZE_DBGCHECK 0
#endif
/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */
#define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP)
/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */
struct tcp_seg {
struct tcp_seg *next; /* used when putting segements on a queue */
struct pbuf *p; /* buffer containing data + TCP header */
u16_t len; /* the TCP length of this segment */
#if TCP_OVERSIZE_DBGCHECK
u16_t oversize_left; /* Extra bytes available at the end of the last
pbuf in unsent (used for asserting vs.
tcp_pcb.unsent_oversized only) */
#endif /* TCP_OVERSIZE_DBGCHECK */
#if TCP_CHECKSUM_ON_COPY
u16_t chksum;
u8_t chksum_swapped;
#endif /* TCP_CHECKSUM_ON_COPY */
u8_t flags;
#define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */
#define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */
#define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is
checksummed into 'chksum' */
struct tcp_hdr *tcphdr; /* the TCP header */
};
#define LWIP_TCP_OPT_LENGTH(flags) \
(flags & TF_SEG_OPTS_MSS ? 4 : 0) + \
(flags & TF_SEG_OPTS_TS ? 12 : 0)
/** This returns a TCP header option for MSS in an u32_t */
#define TCP_BUILD_MSS_OPTION(mss) htonl(0x02040000 | ((mss) & 0xFFFF))
/* Global variables: */
extern struct tcp_pcb *tcp_input_pcb;
extern u32_t tcp_ticks;
extern u8_t tcp_active_pcbs_changed;
/* The TCP PCB lists. */
union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */
struct tcp_pcb_listen *listen_pcbs;
struct tcp_pcb *pcbs;
};
extern struct tcp_pcb *tcp_bound_pcbs;
extern union tcp_listen_pcbs_t tcp_listen_pcbs;
extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
state in which they accept or send
data. */
extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
/* Axioms about the above lists:
1) Every TCP PCB that is not CLOSED is in one of the lists.
2) A PCB is only in one of the lists.
3) All PCBs in the tcp_listen_pcbs list is in LISTEN state.
4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state.
*/
/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB
with a PCB list or removes a PCB from a list, respectively. */
#ifndef TCP_DEBUG_PCB_LISTS
#define TCP_DEBUG_PCB_LISTS 0
#endif
#if TCP_DEBUG_PCB_LISTS
#define TCP_REG(pcbs, npcb) do {\
LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \
for(tcp_tmp_pcb = *(pcbs); \
tcp_tmp_pcb != NULL; \
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \
} \
LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \
(npcb)->next = *(pcbs); \
LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \
*(pcbs) = (npcb); \
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
tcp_timer_needed(); \
} while(0)
#define TCP_RMV(pcbs, npcb) do { \
LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \
if(*(pcbs) == (npcb)) { \
*(pcbs) = (*pcbs)->next; \
} else for(tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
if(tcp_tmp_pcb->next == (npcb)) { \
tcp_tmp_pcb->next = (npcb)->next; \
break; \
} \
} \
(npcb)->next = NULL; \
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \
} while(0)
#else /* LWIP_DEBUG */
#define TCP_REG(pcbs, npcb) \
do { \
(npcb)->next = *pcbs; \
*(pcbs) = (npcb); \
tcp_timer_needed(); \
} while (0)
#define TCP_RMV(pcbs, npcb) \
do { \
if(*(pcbs) == (npcb)) { \
(*(pcbs)) = (*pcbs)->next; \
} \
else { \
for(tcp_tmp_pcb = *pcbs; \
tcp_tmp_pcb != NULL; \
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
if(tcp_tmp_pcb->next == (npcb)) { \
tcp_tmp_pcb->next = (npcb)->next; \
break; \
} \
} \
} \
(npcb)->next = NULL; \
} while(0)
#endif /* LWIP_DEBUG */
#define TCP_REG_ACTIVE(npcb) \
do { \
TCP_REG(&tcp_active_pcbs, npcb); \
tcp_active_pcbs_changed = 1; \
} while (0)
#define TCP_RMV_ACTIVE(npcb) \
do { \
TCP_RMV(&tcp_active_pcbs, npcb); \
tcp_active_pcbs_changed = 1; \
} while (0)
#define TCP_PCB_REMOVE_ACTIVE(pcb) \
do { \
tcp_pcb_remove(&tcp_active_pcbs, pcb); \
tcp_active_pcbs_changed = 1; \
} while (0)
/* Internal functions: */
struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb);
void tcp_pcb_purge(struct tcp_pcb *pcb);
void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb);
void tcp_segs_free(struct tcp_seg *seg);
void tcp_seg_free(struct tcp_seg *seg);
struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);
#define tcp_ack(pcb) \
do { \
if((pcb)->flags & TF_ACK_DELAY) { \
(pcb)->flags &= ~TF_ACK_DELAY; \
(pcb)->flags |= TF_ACK_NOW; \
} \
else { \
(pcb)->flags |= TF_ACK_DELAY; \
} \
} while (0)
#define tcp_ack_now(pcb) \
do { \
(pcb)->flags |= TF_ACK_NOW; \
} while (0)
err_t tcp_send_fin(struct tcp_pcb *pcb);
err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags);
void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
void tcp_rst(u32_t seqno, u32_t ackno,
ip_addr_t *local_ip, ip_addr_t *remote_ip,
u16_t local_port, u16_t remote_port);
u32_t tcp_next_iss(void);
void tcp_keepalive(struct tcp_pcb *pcb);
void tcp_zero_window_probe(struct tcp_pcb *pcb);
#if TCP_CALCULATE_EFF_SEND_MSS
u16_t tcp_eff_send_mss(u16_t sendmss, ip_addr_t *addr);
#endif /* TCP_CALCULATE_EFF_SEND_MSS */
#if LWIP_CALLBACK_API
err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err);
#endif /* LWIP_CALLBACK_API */
#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG
void tcp_debug_print(struct tcp_hdr *tcphdr);
void tcp_debug_print_flags(u8_t flags);
void tcp_debug_print_state(enum tcp_state s);
void tcp_debug_print_pcbs(void);
s16_t tcp_pcbs_sane(void);
#else
# define tcp_debug_print(tcphdr)
# define tcp_debug_print_flags(flags)
# define tcp_debug_print_state(s)
# define tcp_debug_print_pcbs()
# define tcp_pcbs_sane() 1
#endif /* TCP_DEBUG */
/** External function (implemented in timers.c), called when TCP detects
* that a timer is needed (i.e. active- or time-wait-pcb found). */
void tcp_timer_needed(void);
#ifdef __cplusplus
}
#endif
#endif /* LWIP_TCP */
#endif /* __LWIP_TCP_H__ */
| {
"pile_set_name": "Github"
} |
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
<vType id="DEFAULT_VEHTYPE" sigma="0"/>
<vehicle id="0" depart="0">
<route edges="beg middle end rend"/>
<route edges="beg middle end rend"/>
</vehicle>
</routes>
| {
"pile_set_name": "Github"
} |
version https://git-lfs.github.com/spec/v1
oid sha256:26fe5796c5161417f976204f360377d3dca9f8cd310823652b10cf245c5d13b6
size 8621
| {
"pile_set_name": "Github"
} |
/******************************************************************************
* xen-compat.h
*
* Guest OS interface to Xen. Compatibility layer.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Copyright (c) 2006, Christian Limpach
*/
#ifndef __XEN_PUBLIC_XEN_COMPAT_H__
#define __XEN_PUBLIC_XEN_COMPAT_H__
FILE_LICENCE ( MIT );
#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040400
#if defined(__XEN__) || defined(__XEN_TOOLS__)
/* Xen is built with matching headers and implements the latest interface. */
#define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__
#elif !defined(__XEN_INTERFACE_VERSION__)
/* Guests which do not specify a version get the legacy interface. */
#define __XEN_INTERFACE_VERSION__ 0x00000000
#endif
#if __XEN_INTERFACE_VERSION__ > __XEN_LATEST_INTERFACE_VERSION__
#error "These header files do not support the requested interface version."
#endif
#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */
| {
"pile_set_name": "Github"
} |
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id></id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>plugin.json</include>
<include>plugin_job_template.json</include>
</includes>
<outputDirectory>plugin/reader/streamreader</outputDirectory>
</fileSet>
<fileSet>
<directory>target/</directory>
<includes>
<include>streamreader-0.0.1-SNAPSHOT.jar</include>
</includes>
<outputDirectory>plugin/reader/streamreader</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>plugin/reader/streamreader/libs</outputDirectory>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
| {
"pile_set_name": "Github"
} |
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// test operator new replacement
#include <new>
#include <cstddef>
#include <cstdlib>
#include <cassert>
#include <limits>
int new_called = 0;
void* operator new(std::size_t s) throw(std::bad_alloc)
{
++new_called;
return std::malloc(s);
}
void operator delete(void* p) throw()
{
--new_called;
std::free(p);
}
bool A_constructed = false;
struct A
{
A() {A_constructed = true;}
~A() {A_constructed = false;}
};
int main()
{
A* ap = new A;
assert(ap);
assert(A_constructed);
assert(new_called);
delete ap;
assert(!A_constructed);
assert(!new_called);
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_31) on Sun Jan 06 11:49:16 CST 2013 -->
<TITLE>
Uses of Interface com.intel.cosbench.controller.service.StageCallable
</TITLE>
<META NAME="date" CONTENT="2013-01-06">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Interface com.intel.cosbench.controller.service.StageCallable";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../com/intel/cosbench/controller/service/StageCallable.html" title="interface in com.intel.cosbench.controller.service"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV
NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../index.html?com/intel/cosbench/controller/service/\class-useStageCallable.html" target="_top"><B>FRAMES</B></A>
<A HREF="StageCallable.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<CENTER>
<H2>
<B>Uses of Interface<br>com.intel.cosbench.controller.service.StageCallable</B></H2>
</CENTER>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
Packages that use <A HREF="../../../../../../com/intel/cosbench/controller/service/StageCallable.html" title="interface in com.intel.cosbench.controller.service">StageCallable</A></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><A HREF="#com.intel.cosbench.controller.service"><B>com.intel.cosbench.controller.service</B></A></TD>
<TD> </TD>
</TR>
</TABLE>
<P>
<A NAME="com.intel.cosbench.controller.service"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
Uses of <A HREF="../../../../../../com/intel/cosbench/controller/service/StageCallable.html" title="interface in com.intel.cosbench.controller.service">StageCallable</A> in <A HREF="../../../../../../com/intel/cosbench/controller/service/package-summary.html">com.intel.cosbench.controller.service</A></FONT></TH>
</TR>
</TABLE>
<P>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left" COLSPAN="2">Classes in <A HREF="../../../../../../com/intel/cosbench/controller/service/package-summary.html">com.intel.cosbench.controller.service</A> that implement <A HREF="../../../../../../com/intel/cosbench/controller/service/StageCallable.html" title="interface in com.intel.cosbench.controller.service">StageCallable</A></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE> class</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../../../com/intel/cosbench/controller/service/StageChecker.html" title="class in com.intel.cosbench.controller.service">StageChecker</A></B></CODE>
<BR>
This class encapsulates operations to check stage status.</TD>
</TR>
</TABLE>
<P>
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../com/intel/cosbench/controller/service/StageCallable.html" title="interface in com.intel.cosbench.controller.service"><FONT CLASS="NavBarFont1"><B>Class</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Use</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
PREV
NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../../../index.html?com/intel/cosbench/controller/service/\class-useStageCallable.html" target="_top"><B>FRAMES</B></A>
<A HREF="StageCallable.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
</BODY>
</HTML>
| {
"pile_set_name": "Github"
} |
import * as React from 'react';
import { LoadingOutlined } from '@ant-design/icons';
import { Steps, Button, message } from 'antd';
// TODO
// import Prompt from 'umi/prompt';
import { ICreateProgress } from '@/enums';
import ProjectContext from '@/layouts/ProjectContext';
import Terminal, { TerminalType } from '@/components/Terminal';
import debug from '@/debug';
import LoadingPage from '@/components/Loading';
import { listenCreateProject, setCurrentProject, createProject } from '@/services/project';
import { handleBack } from '@/utils';
import styles from './index.less';
import { IProjectProps } from '../index';
const { useContext, useEffect, useState } = React;
const { Step } = Steps;
const ProgressStage: React.FC<IProjectProps> = props => {
const _log = debug.extend('ProgressStage');
_log('ProgressStage props', props);
let terminal: TerminalType;
const { currentData, projectList } = props;
const { formatMessage, locale } = useContext(ProjectContext);
const [retryLoading, setRetryLoading] = useState<boolean>(false);
const key = currentData?.key || '';
const progress: ICreateProgress = projectList?.projectsByKey?.[key]?.creatingProgress || {};
_log('progress', progress);
useEffect(() => {
if (progress.success && key) {
(async () => {
await setCurrentProject({ key });
await handleBack(true, '/dashboard');
// for flash dashboard
document.getElementById('root').innerHTML = '';
ReactDOM.render(React.createElement(<LoadingPage />, {}), document.getElementById('root'));
})();
}
if (progress.failure) {
const { code: errorCode, message: errorMsg, path: errorPath } = progress.failure;
let msg = '';
if (progress.failure.code === 'EACCES') {
msg = formatMessage(
{
id: 'org.umi.ui.global.project.create.steps.EACCES',
},
{
path: errorPath,
code: errorCode,
},
);
} else {
msg = errorMsg;
}
if (terminal) {
terminal.write(msg.replace(/\n/g, '\r\n'));
}
}
const unsubscribe = listenCreateProject({
onMessage: data => {
_log('listen createProject', data);
if (data.install && terminal) {
terminal.write(data.install.replace(/\n/g, '\r\n'));
}
},
});
return () => {
if (unsubscribe) {
unsubscribe();
}
};
}, [progress.success, progress.failure]);
const getStepStatus = (): 'error' | 'finish' => {
if (progress.success) {
return 'finish';
}
if (progress.failure && !retryLoading) {
return 'error';
}
};
const getTitle = () => {
if (progress.success) {
return <p>{formatMessage({ id: 'org.umi.ui.global.progress.create.success' })}</p>;
}
if (progress.failure) {
return formatMessage({ id: 'org.umi.ui.global.progress.create.failure' });
}
return formatMessage({ id: 'org.umi.ui.global.progress.create.loading' });
};
const steps = progress.steps ? progress.steps[locale] : [];
const progressSteps = Array.isArray(steps)
? steps.concat([formatMessage({ id: 'org.umi.ui.global.progress.create.success' })])
: [];
const handleRetry = async () => {
setRetryLoading(true);
try {
const data = await createProject({
key,
retryFrom: progress.step,
});
_log('handleRetry', data);
} catch (e) {
message.error(
e && e.message
? e.message
: formatMessage({ id: 'org.umi.ui.global.progress.retry.failure' }),
);
} finally {
setRetryLoading(false);
}
};
const status = getStepStatus();
_log('status', status);
_log('progressSteps', progressSteps);
return (
<>
{/* <Prompt
when
message={() => {
return window.confirm('confirm to leave the project creating?');
}}
/> */}
<div className={styles['project-progress']}>
<h3>{getTitle()}</h3>
{progress && (
<Steps
current={progress.success ? progressSteps.length - 1 : progress.step}
status={status}
labelPlacement="vertical"
>
{progressSteps.map((step, i) => (
<Step
key={i.toString()}
title={step}
icon={progress.stepStatus === 1 && progress.step === i && <LoadingOutlined />}
/>
))}
</Steps>
)}
{/* {progress.success ? <div>创建成功</div> : null} */}
<div style={{ marginTop: 16 }}>
<Terminal
terminalClassName={styles.terminal}
onInit={ins => {
terminal = ins;
}}
/>
</div>
{progress.failure && (
<div className={styles['project-progress-fail']}>
<Button loading={retryLoading} type="primary" onClick={handleRetry}>
{formatMessage({ id: 'org.umi.ui.global.progress.retry' })}
</Button>
</div>
)}
</div>
</>
);
};
export default ProgressStage;
| {
"pile_set_name": "Github"
} |
.pagination {
zoom: 1;
}
.pagination table {
float: left;
height: 30px;
}
.pagination td {
border: 0;
}
.pagination-btn-separator {
float: left;
height: 24px;
border-left: 1px solid #444;
border-right: 1px solid #777;
margin: 3px 1px;
}
.pagination .pagination-num {
border-width: 1px;
border-style: solid;
margin: 0 2px;
padding: 2px;
width: 2em;
height: auto;
}
.pagination-page-list {
margin: 0px 6px;
padding: 1px 2px;
width: auto;
height: auto;
border-width: 1px;
border-style: solid;
}
.pagination-info {
float: right;
margin: 0 6px 0 0;
padding: 0;
height: 30px;
line-height: 30px;
font-size: 12px;
}
.pagination span {
font-size: 12px;
}
.pagination-link .l-btn-text {
width: 24px;
text-align: center;
margin: 0;
}
.pagination-first {
background: url('images/pagination_icons.png') no-repeat 0 center;
}
.pagination-prev {
background: url('images/pagination_icons.png') no-repeat -16px center;
}
.pagination-next {
background: url('images/pagination_icons.png') no-repeat -32px center;
}
.pagination-last {
background: url('images/pagination_icons.png') no-repeat -48px center;
}
.pagination-load {
background: url('images/pagination_icons.png') no-repeat -64px center;
}
.pagination-loading {
background: url('images/loading.gif') no-repeat center center;
}
.pagination-page-list,
.pagination .pagination-num {
border-color: #000;
}
| {
"pile_set_name": "Github"
} |

[](https://travis-ci.org/caolan/async)
[](https://www.npmjs.com/package/async)
[](https://coveralls.io/r/caolan/async?branch=master)
[](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser.
For Documentation, visit <http://caolan.github.io/async/>
*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
| {
"pile_set_name": "Github"
} |
angular.module('healthyGulpAngularApp', ['ui.router'])
.config(['$stateProvider', '$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
templateUrl: 'components/home.html'
});
}]); | {
"pile_set_name": "Github"
} |
function X = myOMP(Y, D, L)
%% =================== Info =========================
% Author: Tiep Vu [email protected]
% Date created: 8/27/2015 9:09:35 AM
% Description: Solve the l0 problem using OMP. This is actuaaly
% a wrapper of mexOMP in SPAMS toolbox
%% =========================================================
% param.L = L; % not more than 10 non-zeros coefficients
% param.eps = 0.001; % squared norm of the residual should be less than 0.1
% param.numThreads = 1; % number of processors/cores to use; the default choice is -1
% Y = normc(Y);
% X = mexOMP(Y, D, param);
X = omp(D'*Y, D'*D, L);
end
| {
"pile_set_name": "Github"
} |
mkdir /v2c/disk
guestfish -a /input/input -m /dev/sda1:/ copy-out / /v2c/disk
| {
"pile_set_name": "Github"
} |
import { Action } from '@ngrx/store';
import { IUserData } from './models';
import { tracklistIdForUserLikes, tracklistIdForUserTracks } from './utils';
export class UserActions {
static FETCH_USER_FAILED = 'FETCH_USER_FAILED';
static FETCH_USER_FULFILLED = 'FETCH_USER_FULFILLED';
static LOAD_USER = 'LOAD_USER';
static LOAD_USER_LIKES = 'LOAD_USER_LIKES';
static LOAD_USER_TRACKS = 'LOAD_USER_TRACKS';
fetchUserFailed(error: any): Action {
return {
type: UserActions.FETCH_USER_FAILED,
payload: error
};
}
fetchUserFulfilled(user: IUserData): Action {
return {
type: UserActions.FETCH_USER_FULFILLED,
payload: {
user
}
};
}
loadUser(userId: any): Action {
return {
type: UserActions.LOAD_USER,
payload: {
userId: parseInt(userId, 10)
}
};
}
loadUserLikes(userId: any): Action {
return {
type: UserActions.LOAD_USER_LIKES,
payload: {
tracklistId: tracklistIdForUserLikes(userId),
userId: parseInt(userId, 10)
}
};
}
loadUserTracks(userId: any): Action {
return {
type: UserActions.LOAD_USER_TRACKS,
payload: {
tracklistId: tracklistIdForUserTracks(userId),
userId: parseInt(userId, 10)
}
};
}
}
| {
"pile_set_name": "Github"
} |
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include <QObject>
class ctkPluginContext;
class QmitkPreferencesDialog;
/** This class is a "hack" due to the currently missing command framework. It is a direct clone of QmitkExtWorkbenchWindowAdvisorHack.*/
class QmitkFlowApplicationWorkbenchWindowAdvisorHack : public QObject
{
Q_OBJECT
public slots:
void onUndo();
void onRedo();
void onImageNavigator();
void onEditPreferences();
void onQuit();
void onResetPerspective();
void onClosePerspective();
void onIntro();
/**
* @brief This slot is called if the user klicks the menu item "help->context help" or presses F1.
* The help page is shown in a workbench editor.
*/
void onHelp();
void onHelpOpenHelpPerspective();
/**
* @brief This slot is called if the user clicks in help menu the about button
*/
void onAbout();
public:
QmitkFlowApplicationWorkbenchWindowAdvisorHack();
~QmitkFlowApplicationWorkbenchWindowAdvisorHack() override;
static QmitkFlowApplicationWorkbenchWindowAdvisorHack* undohack;
};
| {
"pile_set_name": "Github"
} |
/*****************************************************************************
* | File : EPD_2in13_V2.c
* | Author : Waveshare team
* | Function : 2.13inch e-paper V2
* | Info :
*----------------
* | This version: V3.0
* | Date : 2019-06-13
* | Info :
* -----------------------------------------------------------------------------
* V3.0(2019-06-13):
* 1.Change name:
* EPD_Reset() => EPD_2IN13_V2_Reset()
* EPD_SendCommand() => EPD_2IN13_V2_SendCommand()
* EPD_SendData() => EPD_2IN13_V2_SendData()
* EPD_WaitUntilIdle() => EPD_2IN13_V2_ReadBusy()
* EPD_Init() => EPD_2IN13_V2_Init()
* EPD_Clear() => EPD_2IN13_V2_Clear()
* EPD_Display() => EPD_2IN13_V2_Display()
* EPD_Sleep() => EPD_2IN13_V2_Sleep()
* 2.add:
* EPD_2IN13_V2_DisplayPartBaseImage()
* -----------------------------------------------------------------------------
* V2.0(2018-11-14):
* 1.Remove:ImageBuff[EPD_HEIGHT * EPD_WIDTH / 8]
* 2.Change:EPD_2IN13_V2_Display(UBYTE *Image)
* Need to pass parameters: pointer to cached data
* 3.Change:
* EPD_RST -> EPD_RST_PIN
* EPD_DC -> EPD_DC_PIN
* EPD_CS -> EPD_CS_PIN
* EPD_BUSY -> EPD_BUSY_PIN
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "EPD_2in13_V2.h"
#include "Debug.h"
const unsigned char EPD_2IN13_V2_lut_full_update[]= {
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7
0x80,0x60,0x40,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7
0x10,0x60,0x20,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7
0x03,0x03,0x00,0x00,0x02, // TP0 A~D RP0
0x09,0x09,0x00,0x00,0x02, // TP1 A~D RP1
0x03,0x03,0x00,0x00,0x02, // TP2 A~D RP2
0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3
0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4
0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5
0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6
0x15,0x41,0xA8,0x32,0x30,0x0A,
};
const unsigned char EPD_2IN13_V2_lut_partial_update[]= { //20 bytes
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT0: BB: VS 0 ~7
0x80,0x00,0x00,0x00,0x00,0x00,0x00, //LUT1: BW: VS 0 ~7
0x40,0x00,0x00,0x00,0x00,0x00,0x00, //LUT2: WB: VS 0 ~7
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT3: WW: VS 0 ~7
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //LUT4: VCOM: VS 0 ~7
0x0A,0x00,0x00,0x00,0x00, // TP0 A~D RP0
0x00,0x00,0x00,0x00,0x00, // TP1 A~D RP1
0x00,0x00,0x00,0x00,0x00, // TP2 A~D RP2
0x00,0x00,0x00,0x00,0x00, // TP3 A~D RP3
0x00,0x00,0x00,0x00,0x00, // TP4 A~D RP4
0x00,0x00,0x00,0x00,0x00, // TP5 A~D RP5
0x00,0x00,0x00,0x00,0x00, // TP6 A~D RP6
0x15,0x41,0xA8,0x32,0x30,0x0A,
};
/******************************************************************************
function : Software reset
parameter:
******************************************************************************/
static void EPD_2IN13_V2_Reset(void)
{
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
DEV_Digital_Write(EPD_RST_PIN, 0);
DEV_Delay_ms(10);
DEV_Digital_Write(EPD_RST_PIN, 1);
DEV_Delay_ms(200);
}
/******************************************************************************
function : send command
parameter:
Reg : Command register
******************************************************************************/
static void EPD_2IN13_V2_SendCommand(UBYTE Reg)
{
DEV_Digital_Write(EPD_DC_PIN, 0);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Reg);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : send data
parameter:
Data : Write data
******************************************************************************/
static void EPD_2IN13_V2_SendData(UBYTE Data)
{
DEV_Digital_Write(EPD_DC_PIN, 1);
DEV_Digital_Write(EPD_CS_PIN, 0);
DEV_SPI_WriteByte(Data);
DEV_Digital_Write(EPD_CS_PIN, 1);
}
/******************************************************************************
function : Wait until the busy_pin goes LOW
parameter:
******************************************************************************/
void EPD_2IN13_V2_ReadBusy(void)
{
Debug("e-Paper busy\r\n");
while(DEV_Digital_Read(EPD_BUSY_PIN) == 1) { //LOW: idle, HIGH: busy
DEV_Delay_ms(100);
}
Debug("e-Paper busy release\r\n");
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN13_V2_TurnOnDisplay(void)
{
EPD_2IN13_V2_SendCommand(0x22);
EPD_2IN13_V2_SendData(0xC7);
EPD_2IN13_V2_SendCommand(0x20);
EPD_2IN13_V2_ReadBusy();
}
/******************************************************************************
function : Turn On Display
parameter:
******************************************************************************/
static void EPD_2IN13_V2_TurnOnDisplayPart(void)
{
EPD_2IN13_V2_SendCommand(0x22);
EPD_2IN13_V2_SendData(0x0C);
EPD_2IN13_V2_SendCommand(0x20);
EPD_2IN13_V2_ReadBusy();
}
/******************************************************************************
function : Initialize the e-Paper register
parameter:
******************************************************************************/
void EPD_2IN13_V2_Init(UBYTE Mode)
{
UBYTE count;
EPD_2IN13_V2_Reset();
if(Mode == EPD_2IN13_V2_FULL) {
EPD_2IN13_V2_ReadBusy();
EPD_2IN13_V2_SendCommand(0x12); // soft reset
EPD_2IN13_V2_ReadBusy();
EPD_2IN13_V2_SendCommand(0x74); //set analog block control
EPD_2IN13_V2_SendData(0x54);
EPD_2IN13_V2_SendCommand(0x7E); //set digital block control
EPD_2IN13_V2_SendData(0x3B);
EPD_2IN13_V2_SendCommand(0x01); //Driver output control
EPD_2IN13_V2_SendData(0xF9);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendCommand(0x11); //data entry mode
EPD_2IN13_V2_SendData(0x01);
EPD_2IN13_V2_SendCommand(0x44); //set Ram-X address start/end position
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x0F); //0x0C-->(15+1)*8=128
EPD_2IN13_V2_SendCommand(0x45); //set Ram-Y address start/end position
EPD_2IN13_V2_SendData(0xF9); //0xF9-->(249+1)=250
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendCommand(0x3C); //BorderWavefrom
EPD_2IN13_V2_SendData(0x03);
EPD_2IN13_V2_SendCommand(0x2C); //VCOM Voltage
EPD_2IN13_V2_SendData(0x55); //
EPD_2IN13_V2_SendCommand(0x03);
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[70]);
EPD_2IN13_V2_SendCommand(0x04); //
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[71]);
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[72]);
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[73]);
EPD_2IN13_V2_SendCommand(0x3A); //Dummy Line
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[74]);
EPD_2IN13_V2_SendCommand(0x3B); //Gate time
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[75]);
EPD_2IN13_V2_SendCommand(0x32);
for(count = 0; count < 70; count++) {
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_full_update[count]);
}
EPD_2IN13_V2_SendCommand(0x4E); // set RAM x address count to 0;
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendCommand(0x4F); // set RAM y address count to 0X127;
EPD_2IN13_V2_SendData(0xF9);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_ReadBusy();
} else if(Mode == EPD_2IN13_V2_PART) {
EPD_2IN13_V2_SendCommand(0x2C); //VCOM Voltage
EPD_2IN13_V2_SendData(0x26);
EPD_2IN13_V2_ReadBusy();
EPD_2IN13_V2_SendCommand(0x32);
for(count = 0; count < 70; count++) {
EPD_2IN13_V2_SendData(EPD_2IN13_V2_lut_partial_update[count]);
}
EPD_2IN13_V2_SendCommand(0x37);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x40);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendData(0x00);
EPD_2IN13_V2_SendCommand(0x22);
EPD_2IN13_V2_SendData(0xC0);
EPD_2IN13_V2_SendCommand(0x20);
EPD_2IN13_V2_ReadBusy();
EPD_2IN13_V2_SendCommand(0x3C); //BorderWavefrom
EPD_2IN13_V2_SendData(0x01);
} else {
Debug("error, the Mode is EPD_2IN13_FULL or EPD_2IN13_PART");
}
}
/******************************************************************************
function : Clear screen
parameter:
******************************************************************************/
void EPD_2IN13_V2_Clear(void)
{
UWORD Width, Height;
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
Height = EPD_2IN13_V2_HEIGHT;
EPD_2IN13_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13_V2_SendData(0XFF);
}
}
EPD_2IN13_V2_TurnOnDisplay();
}
/******************************************************************************
function : Sends the image buffer in RAM to e-Paper and displays
parameter:
******************************************************************************/
void EPD_2IN13_V2_Display(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
Height = EPD_2IN13_V2_HEIGHT;
EPD_2IN13_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13_V2_SendData(Image[i + j * Width]);
}
}
EPD_2IN13_V2_TurnOnDisplay();
}
/******************************************************************************
function : The image of the previous frame must be uploaded, otherwise the
first few seconds will display an exception.
parameter:
******************************************************************************/
void EPD_2IN13_V2_DisplayPartBaseImage(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
Height = EPD_2IN13_V2_HEIGHT;
UDOUBLE Addr = 0;
EPD_2IN13_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
Addr = i + j * Width;
EPD_2IN13_V2_SendData(Image[Addr]);
}
}
EPD_2IN13_V2_SendCommand(0x26);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
Addr = i + j * Width;
EPD_2IN13_V2_SendData(Image[Addr]);
}
}
EPD_2IN13_V2_TurnOnDisplay();
}
void EPD_2IN13_V2_DisplayPart(UBYTE *Image)
{
UWORD Width, Height;
Width = (EPD_2IN13_V2_WIDTH % 8 == 0)? (EPD_2IN13_V2_WIDTH / 8 ): (EPD_2IN13_V2_WIDTH / 8 + 1);
Height = EPD_2IN13_V2_HEIGHT;
EPD_2IN13_V2_SendCommand(0x24);
for (UWORD j = 0; j < Height; j++) {
for (UWORD i = 0; i < Width; i++) {
EPD_2IN13_V2_SendData(Image[i + j * Width]);
}
}
EPD_2IN13_V2_TurnOnDisplayPart();
}
/******************************************************************************
function : Enter sleep mode
parameter:
******************************************************************************/
void EPD_2IN13_V2_Sleep(void)
{
EPD_2IN13_V2_SendCommand(0x22); //POWER OFF
EPD_2IN13_V2_SendData(0xC3);
EPD_2IN13_V2_SendCommand(0x20);
EPD_2IN13_V2_SendCommand(0x10); //enter deep sleep
EPD_2IN13_V2_SendData(0x01);
DEV_Delay_ms(100);
}
| {
"pile_set_name": "Github"
} |
/*
* FreeRTOS Kernel V10.2.0
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/
/*
* This is the list implementation used by the scheduler. While it is tailored
* heavily for the schedulers needs, it is also available for use by
* application code.
*
* list_ts can only store pointers to list_item_ts. Each ListItem_t contains a
* numeric value (xItemValue). Most of the time the lists are sorted in
* descending item value order.
*
* Lists are created already containing one list item. The value of this
* item is the maximum possible that can be stored, it is therefore always at
* the end of the list and acts as a marker. The list member pxHead always
* points to this marker - even though it is at the tail of the list. This
* is because the tail contains a wrap back pointer to the true head of
* the list.
*
* In addition to it's value, each list item contains a pointer to the next
* item in the list (pxNext), a pointer to the list it is in (pxContainer)
* and a pointer to back to the object that contains it. These later two
* pointers are included for efficiency of list manipulation. There is
* effectively a two way link between the object containing the list item and
* the list item itself.
*
*
* \page ListIntroduction List Implementation
* \ingroup FreeRTOSIntro
*/
#ifndef INC_FREERTOS_H
#error FreeRTOS.h must be included before list.h
#endif
#ifndef LIST_H
#define LIST_H
/*
* The list structure members are modified from within interrupts, and therefore
* by rights should be declared volatile. However, they are only modified in a
* functionally atomic way (within critical sections of with the scheduler
* suspended) and are either passed by reference into a function or indexed via
* a volatile variable. Therefore, in all use cases tested so far, the volatile
* qualifier can be omitted in order to provide a moderate performance
* improvement without adversely affecting functional behaviour. The assembly
* instructions generated by the IAR, ARM and GCC compilers when the respective
* compiler's options were set for maximum optimisation has been inspected and
* deemed to be as intended. That said, as compiler technology advances, and
* especially if aggressive cross module optimisation is used (a use case that
* has not been exercised to any great extend) then it is feasible that the
* volatile qualifier will be needed for correct optimisation. It is expected
* that a compiler removing essential code because, without the volatile
* qualifier on the list structure members and with aggressive cross module
* optimisation, the compiler deemed the code unnecessary will result in
* complete and obvious failure of the scheduler. If this is ever experienced
* then the volatile qualifier can be inserted in the relevant places within the
* list structures by simply defining configLIST_VOLATILE to volatile in
* FreeRTOSConfig.h (as per the example at the bottom of this comment block).
* If configLIST_VOLATILE is not defined then the preprocessor directives below
* will simply #define configLIST_VOLATILE away completely.
*
* To use volatile list structure members then add the following line to
* FreeRTOSConfig.h (without the quotes):
* "#define configLIST_VOLATILE volatile"
*/
#ifndef configLIST_VOLATILE
#define configLIST_VOLATILE
#endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */
#ifdef __cplusplus
extern "C" {
#endif
/* Macros that can be used to place known values within the list structures,
then check that the known values do not get corrupted during the execution of
the application. These may catch the list data structures being overwritten in
memory. They will not catch data errors caused by incorrect configuration or
use of FreeRTOS.*/
#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 )
/* Define the macros to do nothing. */
#define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE
#define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE
#define listFIRST_LIST_INTEGRITY_CHECK_VALUE
#define listSECOND_LIST_INTEGRITY_CHECK_VALUE
#define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )
#define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )
#define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList )
#define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList )
#define listTEST_LIST_ITEM_INTEGRITY( pxItem )
#define listTEST_LIST_INTEGRITY( pxList )
#else
/* Define macros that add new members into the list structures. */
#define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1;
#define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2;
#define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1;
#define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2;
/* Define macros that set the new structure members to known values. */
#define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE
#define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE
#define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE
#define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE
/* Define macros that will assert if one of the structure members does not
contain its expected value. */
#define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )
#define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )
#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */
/*
* Definition of the only type of object that a list can contain.
*/
struct xLIST;
struct xLIST_ITEM
{
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */
struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */
void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */
listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
};
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */
struct xMINI_LIST_ITEM
{
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
configLIST_VOLATILE TickType_t xItemValue;
struct xLIST_ITEM * configLIST_VOLATILE pxNext;
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious;
};
typedef struct xMINI_LIST_ITEM MiniListItem_t;
/*
* Definition of the type of queue used by the scheduler.
*/
typedef struct xLIST
{
listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
volatile UBaseType_t uxNumberOfItems;
ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */
MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
} List_t;
/*
* Access macro to set the owner of a list item. The owner of a list item
* is the object (usually a TCB) that contains the list item.
*
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
* \ingroup LinkedList
*/
#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) )
/*
* Access macro to get the owner of a list item. The owner of a list item
* is the object (usually a TCB) that contains the list item.
*
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
* \ingroup LinkedList
*/
#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner )
/*
* Access macro to set the value of the list item. In most cases the value is
* used to sort the list in descending order.
*
* \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) )
/*
* Access macro to retrieve the value of the list item. The value can
* represent anything - for example the priority of a task, or the time at
* which a task should be unblocked.
*
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue )
/*
* Access macro to retrieve the value of the list item at the head of a given
* list.
*
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue )
/*
* Return the list item at the head of the list.
*
* \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY
* \ingroup LinkedList
*/
#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext )
/*
* Return the list item at the head of the list.
*
* \page listGET_NEXT listGET_NEXT
* \ingroup LinkedList
*/
#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext )
/*
* Return the list item that marks the end of the list
*
* \page listGET_END_MARKER listGET_END_MARKER
* \ingroup LinkedList
*/
#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) )
/*
* Access macro to determine if a list contains any items. The macro will
* only have the value true if the list is empty.
*
* \page listLIST_IS_EMPTY listLIST_IS_EMPTY
* \ingroup LinkedList
*/
#define listLIST_IS_EMPTY( pxList ) ( ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) ? pdTRUE : pdFALSE )
/*
* Access macro to return the number of items in the list.
*/
#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems )
/*
* Access function to obtain the owner of the next entry in a list.
*
* The list member pxIndex is used to walk through a list. Calling
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list
* and returns that entry's pxOwner parameter. Using multiple calls to this
* function it is therefore possible to move through every item contained in
* a list.
*
* The pxOwner parameter of a list item is a pointer to the object that owns
* the list item. In the scheduler this is normally a task control block.
* The pxOwner parameter effectively creates a two way link between the list
* item and its owner.
*
* @param pxTCB pxTCB is set to the address of the owner of the next list item.
* @param pxList The list from which the next item owner is to be returned.
*
* \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY
* \ingroup LinkedList
*/
#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \
{ \
List_t * const pxConstList = ( pxList ); \
/* Increment the index to the next item and return the item, ensuring */ \
/* we don't return the marker used at the end of the list. */ \
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \
{ \
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
} \
( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \
}
/*
* Access function to obtain the owner of the first entry in a list. Lists
* are normally sorted in ascending item value order.
*
* This function returns the pxOwner member of the first item in the list.
* The pxOwner parameter of a list item is a pointer to the object that owns
* the list item. In the scheduler this is normally a task control block.
* The pxOwner parameter effectively creates a two way link between the list
* item and its owner.
*
* @param pxList The list from which the owner of the head item is to be
* returned.
*
* \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY
* \ingroup LinkedList
*/
#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner )
/*
* Check to see if a list item is within a list. The list item maintains a
* "container" pointer that points to the list it is in. All this macro does
* is check to see if the container and the list match.
*
* @param pxList The list we want to know if the list item is within.
* @param pxListItem The list item we want to know if is in the list.
* @return pdTRUE if the list item is in the list, otherwise pdFALSE.
*/
#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) )
/*
* Return the list a list item is contained within (referenced from).
*
* @param pxListItem The list item being queried.
* @return A pointer to the List_t object that references the pxListItem
*/
#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pxContainer )
/*
* This provides a crude means of knowing if a list has been initialised, as
* pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise()
* function.
*/
#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY )
/*
* Must be called before a list is used! This initialises all the members
* of the list structure and inserts the xListEnd item into the list as a
* marker to the back of the list.
*
* @param pxList Pointer to the list being initialised.
*
* \page vListInitialise vListInitialise
* \ingroup LinkedList
*/
void vListInitialise( List_t * const pxList ) PRIVILEGED_FUNCTION;
/*
* Must be called before a list item is used. This sets the list container to
* null so the item does not think that it is already contained in a list.
*
* @param pxItem Pointer to the list item being initialised.
*
* \page vListInitialiseItem vListInitialiseItem
* \ingroup LinkedList
*/
void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION;
/*
* Insert a list item into a list. The item will be inserted into the list in
* a position determined by its item value (descending item value order).
*
* @param pxList The list into which the item is to be inserted.
*
* @param pxNewListItem The item that is to be placed in the list.
*
* \page vListInsert vListInsert
* \ingroup LinkedList
*/
void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION;
/*
* Insert a list item into a list. The item will be inserted in a position
* such that it will be the last item within the list returned by multiple
* calls to listGET_OWNER_OF_NEXT_ENTRY.
*
* The list member pxIndex is used to walk through a list. Calling
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list.
* Placing an item in a list using vListInsertEnd effectively places the item
* in the list position pointed to by pxIndex. This means that every other
* item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before
* the pxIndex parameter again points to the item being inserted.
*
* @param pxList The list into which the item is to be inserted.
*
* @param pxNewListItem The list item to be inserted into the list.
*
* \page vListInsertEnd vListInsertEnd
* \ingroup LinkedList
*/
void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION;
/*
* Remove an item from a list. The list item has a pointer to the list that
* it is in, so only the list item need be passed into the function.
*
* @param uxListRemove The item to be removed. The item will remove itself from
* the list pointed to by it's pxContainer parameter.
*
* @return The number of items that remain in the list after the list item has
* been removed.
*
* \page uxListRemove uxListRemove
* \ingroup LinkedList
*/
UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION;
#ifdef __cplusplus
}
#endif
#endif
| {
"pile_set_name": "Github"
} |
namespace Pulsar4X.ECSLib
{
public class PassiveThermalSensorAtbDB : BaseDataBlob
{
public int ThermalSensitivity { get; internal set; }
public override object Clone()
{
return new PassiveThermalSensorAtbDB { ThermalSensitivity = ThermalSensitivity, OwningEntity = OwningEntity };
}
}
} | {
"pile_set_name": "Github"
} |
function [f,x,u]=ksdensityw(y,w,varargin)
%KSDENSITY Compute density estimate
% [F,XI]=KSDENSITY(X) computes a probability density estimate of the sample
% in the vector X. F is the vector of density values evaluated at the
% points in XI. The estimate is based on a normal kernel function, using a
% window parameter (bandwidth) that is a function of the number of points
% in X. The density is evaluated at 100 equally-spaced points covering
% the range of the data in X.
%
% F=KSDENSITY(X,XI) specifies the vector XI of values where the density
% estimate is to be evaluated.
%
% [F,XI,U]=KSDENSITY(...) also returns the bandwidth of the kernel smoothing
% window.
%
% DWH: w are the weights for y (w = 1/n for ksdenstiy)
%
% [...]=KSDENSITY(...,'PARAM1',val1,'PARAM2',val2,...) specifies parameter
% name/value pairs to control the density estimation. Valid parameters
% are the following:
%
% Parameter Value
% 'kernel' The type of kernel smoother to use, chosen from among
% 'normal' (default), 'box', 'triangle', and
% 'epanechinikov'.
% 'npoints' The number of equally-spaced points in XI.
% 'width' The bandwidth of the kernel smoothing window. The default
% is optimal for estimating normal densities, but you
% may want to choose a smaller value to reveal features
% such as multiple modes.
%
% In place of the kernel functions listed above, you can specify another
% function by using @ (such as @normpdf) or quotes (such as 'normpdf').
% The function must take a single argument that is an array of distances
% between data values and places where the density is evaluated, and
% return an array of the same size containing corresponding values of
% the kernel function.
%
% Example:
% x = [randn(30,1); 5+randn(30,1)];
% [f,xi] = ksdensity(x);
% plot(xi,f);
% This example generates a mixture of two normal distributions, and
% plots the estimated density.
%
% See also HIST, @.
% Reference:
% A.W. Bowman and A. Azzalini (1997), "Applied Smoothing
% Techniques for Data Analysis," Oxford University Press.
% Copyright 1993-2002 The MathWorks, Inc.
% $Revision: 1.7 $ $Date: 2002/03/21 20:36:29 $
% Get y vector and its dimensions
if (prod(size(y)) > length(y)), error('X must be a vector'); end
y = y(:);
y(isnan(y)) = [];
n = length(y);
ymin = min(y);
ymax = max(y);
% Maybe x was specified, or maybe not
if ~isempty(varargin)
if ~ischar(varargin{1})
x = varargin{1};
varargin(1) = [];
end
end
% Process additional name/value pair arguments
okargs = {'width' 'npoints' 'kernel'};
defaults = {[] [] 'normal'};
[emsg,u,m,kernel] = statgetargs(okargs, defaults, varargin{:});
error(emsg);
% Default window parameter is optimal for normal distribution
if (isempty(u)),
med = median(y);
sig = median(abs(y-med)) / 0.6745;
if sig<=0, sig = ymax-ymin; end
if sig>0
u = sig * (4/(3*n))^(1/5);
else
u = 1;
end
end
% Check other arguments or get defaults.
if ~exist('x','var')
if isempty(m), m=100; end
x = linspace(ymin-2*u, ymax+2*u, m);
elseif (prod(size(x)) > length(x))
error('XI must be a vector');
end
xsize = size(x);
x = x(:);
m = length(x);
okkernels = {'normal' 'epanechinikov' 'box' 'triangle'};
if isempty(kernel)
kernel = okkernels{1};
elseif ~(isa(kernel,'function_handle') | isa(kernel,'inline'))
if ~ischar(kernel)
error('Smoothing kernel must be a function.');
end
knum = strmatch(lower(kernel), okkernels);
if (length(knum) == 1)
kernel = okkernels{knum};
end
end
blocksize = 1e6;
if n*m<=blocksize
% Compute kernel density estimate in one operation
z = (repmat(x',n,1)-repmat(y,1,m))/u;
w2 = repmat(w, 1, m);
f = sum(feval(kernel, z).*w2,1);
else
% For large vectors, process blocks of elements as a group
M = max(1,ceil(blocksize/n));
mrem = rem(m,M);
if mrem==0, mrem = min(M,m); end
x = x';
f = zeros(1,m);
ii = 1:mrem;
z = (repmat(x(ii),n,1)-repmat(y,1,mrem))/u;
w2 = repmat(w, 1, mrem);
f(ii) = sum(feval(kernel, z).*w2,1);
z = zeros(n,M);
w2 = zeros(n,M);
for j=mrem+1:M:m
ii = j:j+M-1;
z(:) = (repmat(x(ii),n,1)-repmat(y,1,M))/u;
w2(:) = repmat(w, 1, M);
f(ii) = sum(feval(kernel, z).*w2,1);
end
end
f = reshape(f./u, xsize);
% -----------------------------
% The following are functions that define smoothing kernels k(z).
% Each function takes a single input Z and returns the value of
% the smoothing kernel. These sample kernels are designed to
% produce outputs that are somewhat comparable (differences due
% to shape rather than scale), so they are all probability
% density functions with unit variance.
%
% The density estimate has the form
% f(x;k,h) = mean over i=1:n of k((x-y(i))/h) / h
function f = normal(z)
%NORMAL Normal density kernel.
%f = normpdf(z);
f = exp(-0.5 * z .^2) ./ sqrt(2*pi);
function f = epanechinikov(z)
%EPANECHINIKOV Epanechinikov's asymptotically optimal kernel.
a = sqrt(5);
z = max(-a, min(z,a));
f = .75 * (1 - .2*z.^2) / a;
function f = box(z)
%BOX Box-shaped kernel
a = sqrt(3);
f = (abs(z)<=a) ./ (2 * a);
function f = triangle(z)
%TRIANGLE Triangular kernel.
a = sqrt(6);
z = abs(z);
f = (z<=a) .* (1 - z/a) / a; | {
"pile_set_name": "Github"
} |
//======== (C) Copyright 2002 Charles G. Cleveland All rights reserved. =========
//
// The copyright to the contents herein is the property of Charles G. Cleveland.
// The contents may be used and/or copied only with the written permission of
// Charles G. Cleveland, or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose:
//
// $Workfile: AvHTechNode.cpp $
// $Date: 2002/09/23 22:36:08 $
//
//===============================================================================
#include "mod/AvHTechNode.h"
//for use in operator==
#define CHECK_EQUAL(x) (this->x == other.x)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// AvHTechNode
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AvHTechNode::AvHTechNode(const AvHMessageID id) : mMessageID(id), mCost(-1), mBuildTime(-1), mResearchable(true),
mResearched(false), mAllowMultiples(false), mTechID(TECH_NULL), mPrereqID1(TECH_NULL), mPrereqID2(TECH_NULL)
{}
AvHTechNode::AvHTechNode(const AvHTechNode& other) : mMessageID(other.mMessageID), mTechID(other.mTechID),
mCost(other.mCost), mPrereqID1(other.mPrereqID1), mPrereqID2(other.mPrereqID2), mBuildTime(other.mBuildTime),
mResearchable(other.mResearchable), mResearched(other.mResearched), mAllowMultiples(other.mAllowMultiples)
{}
AvHTechNode::AvHTechNode(AvHMessageID inMessageID, AvHTechID inID, AvHTechID inPrereq1, AvHTechID inPrereq2, int inCost, int inBuildTime, bool inResearched) :
mMessageID(inMessageID), mTechID(inID), mPrereqID1(inPrereq1), mPrereqID2(inPrereq2), mCost(inCost),
mBuildTime(inBuildTime), mResearchable(true), mResearched(inResearched), mAllowMultiples(false)
{}
AvHTechNode::~AvHTechNode(void) {}
AvHTechNode* AvHTechNode::clone(void) const { return new AvHTechNode(*this); }
void AvHTechNode::swap(AvHTechNode& other)
{
AvHTechID tempTech = mTechID; mTechID = other.mTechID; other.mTechID = tempTech;
tempTech = mPrereqID1; mPrereqID1 = other.mPrereqID1; other.mPrereqID1 = tempTech;
tempTech = mPrereqID2; mPrereqID2 = other.mPrereqID2; other.mPrereqID2 = tempTech;
int temp = mCost; mCost = other.mCost; other.mCost = temp;
temp = mBuildTime; mBuildTime = other.mBuildTime; other.mBuildTime = temp;
bool btemp = mResearchable; mResearchable = other.mResearchable; other.mResearchable = btemp;
btemp = mResearched; mResearched = other.mResearched; other.mResearched = btemp;
btemp = mAllowMultiples; mAllowMultiples = other.mAllowMultiples; other.mAllowMultiples = btemp;
}
AvHMessageID AvHTechNode::getMessageID(void) const { return mMessageID; }
AvHTechID AvHTechNode::getTechID(void) const { return mTechID; }
AvHTechID AvHTechNode::getPrereqTechID1(void) const { return mPrereqID1; }
AvHTechID AvHTechNode::getPrereqTechID2(void) const { return mPrereqID2; }
int AvHTechNode::getBuildTime(void) const { return mBuildTime; }
int AvHTechNode::getCost(void) const { return mCost; }
bool AvHTechNode::getIsResearchable(void) const { return mResearchable; }
bool AvHTechNode::getIsResearched(void) const { return mResearched; }
bool AvHTechNode::getAllowMultiples(void) const { return mAllowMultiples; }
void AvHTechNode::setTechID(const AvHTechID inTechID) { mTechID = inTechID; }
void AvHTechNode::setPrereqTechID1(const AvHTechID inTechID) { mPrereqID1 = inTechID; }
void AvHTechNode::setPrereqTechID2(const AvHTechID inTechID) { mPrereqID2 = inTechID; }
void AvHTechNode::setBuildTime(const int inBuildTime) { mBuildTime = inBuildTime; }
void AvHTechNode::setCost(const int inCost) { mCost = inCost; }
void AvHTechNode::setResearchable(bool inState) { mResearchable = inState; }
void AvHTechNode::setResearchState(bool inState)
{
mResearched = inState;
if(!mAllowMultiples)
{ mResearchable = !mResearched; }
}
bool AvHTechNode::operator==(const AvHTechNode& other) const
{
bool theIsEqual = CHECK_EQUAL(mMessageID) && CHECK_EQUAL(mTechID) && CHECK_EQUAL(mPrereqID1)
&& CHECK_EQUAL(mPrereqID2) && CHECK_EQUAL(mCost) && CHECK_EQUAL(mBuildTime)
&& CHECK_EQUAL(mResearchable) && CHECK_EQUAL(mResearched) && CHECK_EQUAL(mAllowMultiples);
return theIsEqual;
}
bool AvHTechNode::operator!=(const AvHTechNode& other) const
{
return !this->operator==(other);
}
AvHTechNode& AvHTechNode::operator=(const AvHTechNode& inTechNode)
{
AvHTechNode node(inTechNode);
swap(node);
return *this;
}
void AvHTechNode::setAllowMultiples(const bool inAllow){ mAllowMultiples = inAllow; }
| {
"pile_set_name": "Github"
} |
package test.websocket.text;
import hxy.server.socket.anno.Socket;
import hxy.server.socket.engine.SocketMsgHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpRequest;
/**
* @Description
* @Author xinyu.huang
* @Time 2020/4/8 21:32
*/
@Socket
public class SimpleSocketMsgHandler implements SocketMsgHandler<String> {
@Override
public void onConnect(ChannelHandlerContext ctx, HttpRequest req) {
System.out.println(ctx.channel().toString());
}
@Override
public void onMessage(ChannelHandlerContext ctx, String msg) {
System.out.println("收到消息=" + msg);
ctx.writeAndFlush(msg);
}
@Override
public void disConnect(ChannelHandlerContext ctx) {
System.out.println("断开连接=" + ctx.channel().toString());
}
}
| {
"pile_set_name": "Github"
} |
//>>built
define("dojox/grid/enhanced/plugins/DnD", [
"dojo/_base/kernel",
"dojo/_base/declare",
"dojo/_base/connect",
"dojo/_base/array",
"dojo/_base/lang",
"dojo/_base/html",
"dojo/_base/json",
"dojo/_base/window",
"dojo/query",
"dojo/keys",
"dojo/dnd/Source",
"dojo/dnd/Avatar",
"../_Plugin",
"../../EnhancedGrid",
"./Selector",
"./Rearrange",
"dojo/dnd/Manager"
], function(dojo, declare, connect, array, lang, html, json, win, query, keys, Source, Avatar, _Plugin, EnhancedGrid){
var _devideToArrays = function(a){
a.sort(function(v1, v2){
return v1 - v2;
});
var arr = [[a[0]]];
for(var i = 1, j = 0; i < a.length; ++i){
if(a[i] == a[i-1] + 1){
arr[j].push(a[i]);
}else{
arr[++j] = [a[i]];
}
}
return arr;
},
_joinToArray = function(arrays){
var a = arrays[0];
for(var i = 1; i < arrays.length; ++i){
a = a.concat(arrays[i]);
}
return a;
};
var GridDnDElement = declare("dojox.grid.enhanced.plugins.GridDnDElement", null, {
constructor: function(dndPlugin){
this.plugin = dndPlugin;
this.node = html.create("div");
this._items = {};
},
destroy: function(){
this.plugin = null;
html.destroy(this.node);
this.node = null;
this._items = null;
},
createDnDNodes: function(dndRegion){
this.destroyDnDNodes();
var acceptType = ["grid/" + dndRegion.type + "s"];
var itemNodeIdBase = this.plugin.grid.id + "_dndItem";
array.forEach(dndRegion.selected, function(range, i){
var id = itemNodeIdBase + i;
this._items[id] = {
"type": acceptType,
"data": range,
"dndPlugin": this.plugin
};
this.node.appendChild(html.create("div", {
"id": id
}));
}, this);
},
getDnDNodes: function(){
return array.map(this.node.childNodes, function(node){
return node;
});
},
destroyDnDNodes: function(){
html.empty(this.node);
this._items = {};
},
getItem: function(nodeId){
return this._items[nodeId];
}
});
var GridDnDSource = declare("dojox.grid.enhanced.plugins.GridDnDSource", Source,{
accept: ["grid/cells", "grid/rows", "grid/cols"],
constructor: function(node, param){
this.grid = param.grid;
this.dndElem = param.dndElem;
this.dndPlugin = param.dnd;
this.sourcePlugin = null;
},
destroy: function(){
this.inherited(arguments);
this.grid = null;
this.dndElem = null;
this.dndPlugin = null;
this.sourcePlugin = null;
},
getItem: function(nodeId){
return this.dndElem.getItem(nodeId);
},
checkAcceptance: function(source, nodes){
if(this != source && nodes[0]){
var item = source.getItem(nodes[0].id);
if(item.dndPlugin){
var type = item.type;
for(var j = 0; j < type.length; ++j){
if(type[j] in this.accept){
if(this.dndPlugin._canAccept(item.dndPlugin)){
this.sourcePlugin = item.dndPlugin;
}else{
return false;
}
break;
}
}
}else if("grid/rows" in this.accept){
var rows = [];
array.forEach(nodes, function(node){
var item = source.getItem(node.id);
if(item.data && array.indexOf(item.type, "grid/rows") >= 0){
var rowData = item.data;
if(typeof item.data == "string"){
rowData = json.fromJson(item.data);
}
if(rowData){
rows.push(rowData);
}
}
});
if(rows.length){
this.sourcePlugin = {
_dndRegion: {
type: "row",
selected: [rows]
}
};
}else{
return false;
}
}
}
return this.inherited(arguments);
},
onDraggingOver: function(){
this.dndPlugin.onDraggingOver(this.sourcePlugin);
},
onDraggingOut: function(){
this.dndPlugin.onDraggingOut(this.sourcePlugin);
},
onDndDrop: function(source, nodes, copy, target){
//this.inherited(arguments);
this.onDndCancel();
if(this != source && this == target){
this.dndPlugin.onDragIn(this.sourcePlugin, copy);
}
}
});
var GridDnDAvatar = declare("dojox.grid.enhanced.plugins.GridDnDAvatar", Avatar, {
construct: function(){
// summary:
// constructor function;
// it is separate so it can be (dynamically) overwritten in case of need
this._itemType = this.manager._dndPlugin._dndRegion.type;
this._itemCount = this._getItemCount();
this.isA11y = html.hasClass(win.body(), "dijit_a11y");
var a = html.create("table", {
"border": "0",
"cellspacing": "0",
"class": "dojoxGridDndAvatar",
"style": {
position: "absolute",
zIndex: "1999",
margin: "0px"
}
}),
source = this.manager.source,
b = html.create("tbody", null, a),
tr = html.create("tr", null, b),
td = html.create("td", {
"class": "dojoxGridDnDIcon"
}, tr);
if(this.isA11y){
html.create("span", {
"id" : "a11yIcon",
"innerHTML" : this.manager.copy ? '+' : "<"
}, td);
}
td = html.create("td", {
"class" : "dojoxGridDnDItemIcon " + this._getGridDnDIconClass()
}, tr);
td = html.create("td", null, tr);
html.create("span", {
"class": "dojoxGridDnDItemCount",
"innerHTML": source.generateText ? this._generateText() : ""
}, td);
// we have to set the opacity on IE only after the node is live
html.style(tr, {
"opacity": 0.9
});
this.node = a;
},
_getItemCount: function(){
var selected = this.manager._dndPlugin._dndRegion.selected,
count = 0;
switch(this._itemType){
case "cell":
selected = selected[0];
var cells = this.manager._dndPlugin.grid.layout.cells,
colCount = selected.max.col - selected.min.col + 1,
rowCount = selected.max.row - selected.min.row + 1;
if(colCount > 1){
for(var i = selected.min.col; i <= selected.max.col; ++i){
if(cells[i].hidden){
--colCount;
}
}
}
count = colCount * rowCount;
break;
case "row":
case "col":
count = _joinToArray(selected).length;
}
return count;
},
_getGridDnDIconClass: function(){
return {
"row": ["dojoxGridDnDIconRowSingle", "dojoxGridDnDIconRowMulti"],
"col": ["dojoxGridDnDIconColSingle", "dojoxGridDnDIconColMulti"],
"cell": ["dojoxGridDnDIconCellSingle", "dojoxGridDnDIconCellMulti"]
}[this._itemType][this._itemCount == 1 ? 0 : 1];
},
_generateText: function(){
// summary:
// generates a proper text to reflect copying or moving of items
return "(" + this._itemCount + ")";
}
});
var DnD = declare("dojox.grid.enhanced.plugins.DnD", _Plugin, {
// summary:
// Provide drag and drop for grid columns/rows/cells within grid and out of grid.
// The store of grid must implement dojo.data.api.Write.
// DnD selected columns:
// Support moving within grid, moving/copying out of grid to a non-grid DnD target.
// DnD selected rows:
// Support moving within grid, moving/copying out of grid to any DnD target.
// DnD selected cells (in rectangle shape only):
// Support moving/copying within grid, moving/copying out of grid to any DnD target.
//
// name: String,
// plugin name;
name: "dnd",
_targetAnchorBorderWidth: 2,
_copyOnly: false,
_config: {
"row":{
"within":true,
"in":true,
"out":true
},
"col":{
"within":true,
"in":true,
"out":true
},
"cell":{
"within":true,
"in":true,
"out":true
}
},
constructor: function(grid, args){
this.grid = grid;
this._config = lang.clone(this._config);
args = lang.isObject(args) ? args : {};
this.setupConfig(args.dndConfig);
this._copyOnly = !!args.copyOnly;
//Get the plugins we are dependent on.
this._mixinGrid();
this.selector = grid.pluginMgr.getPlugin("selector");
this.rearranger = grid.pluginMgr.getPlugin("rearrange");
//TODO: waiting for a better plugin framework to pass args to dependent plugins.
this.rearranger.setArgs(args);
//Initialized the components we need.
this._clear();
this._elem = new GridDnDElement(this);
this._source = new GridDnDSource(this._elem.node, {
"grid": grid,
"dndElem": this._elem,
"dnd": this
});
this._container = query(".dojoxGridMasterView", this.grid.domNode)[0];
this._initEvents();
},
destroy: function(){
this.inherited(arguments);
this._clear();
this._source.destroy();
this._elem.destroy();
this._container = null;
this.grid = null;
this.selector = null;
this.rearranger = null;
this._config = null;
},
_mixinGrid: function(){
// summary:
// Provide APIs for grid.
this.grid.setupDnDConfig = lang.hitch(this, "setupConfig");
this.grid.dndCopyOnly = lang.hitch(this, "copyOnly");
},
setupConfig: function(config){
// summary:
// Configure which DnD functionalities are needed.
// Combination of any item from type set ("row", "col", "cell")
// and any item from mode set("within", "in", "out") is configurable.
//
// "row", "col", "cell" are straitforward, while the other 3 are explained below:
// "within": DnD within grid, that is, column/row reordering and cell moving/copying.
// "in": Whether allowed to accept rows/cells (currently not support columns) from another grid.
// "out": Whether allowed to drag out of grid, to another grid or even to any other DnD target.
//
// If not provided in the config, will use the default.
// When declared together, Mode set has higher priority than type set.
// config: Object
// DnD configuration object.
// See the examples below.
// example:
// The following code disables row DnD within grid,
// but still can drag rows out of grid or drag rows from other gird.
// | setUpConfig({
// | "row": {
// | "within": false
// | }
// | });
//
// The opposite way is also okay:
// | setUpConfig({
// | "within": {
// | "row": false
// | }
// | });
//
// And if you'd like to disable/enable a whole set, here's a shortcut:
// | setUpConfig({
// | "cell", true,
// | "out": false
// | });
//
// Because mode has higher priority than type, the following will disable row dnd within grid:
// | setUpConfig({
// | "within", {
// | "row": false;
// | },
// | "row", {
// | "within": true
// | }
// | });
if(config && lang.isObject(config)){
var firstLevel = ["row", "col", "cell"],
secondLevel = ["within", "in", "out"],
cfg = this._config;
array.forEach(firstLevel, function(type){
if(type in config){
var t = config[type];
if(t && lang.isObject(t)){
array.forEach(secondLevel, function(mode){
if(mode in t){
cfg[type][mode] = !!t[mode];
}
});
}else{
array.forEach(secondLevel, function(mode){
cfg[type][mode] = !!t;
});
}
}
});
array.forEach(secondLevel, function(mode){
if(mode in config){
var m = config[mode];
if(m && lang.isObject(m)){
array.forEach(firstLevel, function(type){
if(type in m){
cfg[type][mode] = !!m[type];
}
});
}else{
array.forEach(firstLevel, function(type){
cfg[type][mode] = !!m;
});
}
}
});
}
},
copyOnly: function(isCopyOnly){
// summary:
// Setter/getter of this._copyOnly.
if(typeof isCopyOnly != "undefined"){
this._copyOnly = !!isCopyOnly;
}
return this._copyOnly;
},
_isOutOfGrid: function(evt){
var gridPos = html.position(this.grid.domNode), x = evt.clientX, y = evt.clientY;
return y < gridPos.y || y > gridPos.y + gridPos.h ||
x < gridPos.x || x > gridPos.x + gridPos.w;
},
_onMouseMove: function(evt){
if(this._dndRegion && !this._dnding && !this._externalDnd){
this._dnding = true;
this._startDnd(evt);
}else{
if(this._isMouseDown && !this._dndRegion){
delete this._isMouseDown;
this._oldCursor = html.style(win.body(), "cursor");
html.style(win.body(), "cursor", "not-allowed");
}
//TODO: should implement as mouseenter/mouseleave
//But we have an avatar under mouse when dnd, and this will cause a lot of mouseenter in FF.
var isOut = this._isOutOfGrid(evt);
if(!this._alreadyOut && isOut){
this._alreadyOut = true;
if(this._dnding){
this._destroyDnDUI(true, false);
}
this._moveEvent = evt;
this._source.onOutEvent();
}else if(this._alreadyOut && !isOut){
this._alreadyOut = false;
if(this._dnding){
this._createDnDUI(evt, true);
}
this._moveEvent = evt;
this._source.onOverEvent();
}
}
},
_onMouseUp: function(){
if(!this._extDnding && !this._isSource){
var isInner = this._dnding && !this._alreadyOut;
if(isInner && this._config[this._dndRegion.type]["within"]){
this._rearrange();
}
this._endDnd(isInner);
}
html.style(win.body(), "cursor", this._oldCursor || "");
delete this._isMouseDown;
},
_initEvents: function(){
var g = this.grid, s = this.selector;
this.connect(win.doc, "onmousemove", "_onMouseMove");
this.connect(win.doc, "onmouseup", "_onMouseUp");
this.connect(g, "onCellMouseOver", function(evt){
if(!this._dnding && !s.isSelecting() && !evt.ctrlKey){
this._dndReady = s.isSelected("cell", evt.rowIndex, evt.cell.index);
s.selectEnabled(!this._dndReady);
}
});
this.connect(g, "onHeaderCellMouseOver", function(evt){
if(this._dndReady){
s.selectEnabled(true);
}
});
this.connect(g, "onRowMouseOver", function(evt){
if(this._dndReady && !evt.cell){
s.selectEnabled(true);
}
});
this.connect(g, "onCellMouseDown", function(evt){
if(!evt.ctrlKey && this._dndReady){
this._dndRegion = this._getDnDRegion(evt.rowIndex, evt.cell.index);
this._isMouseDown = true;
}
});
this.connect(g, "onCellMouseUp", function(evt){
if(!this._dndReady && !s.isSelecting() && evt.cell){
this._dndReady = s.isSelected("cell", evt.rowIndex, evt.cell.index);
s.selectEnabled(!this._dndReady);
}
});
this.connect(g, "onCellClick", function(evt){
if(this._dndReady && !evt.ctrlKey && !evt.shiftKey){
s.select("cell", evt.rowIndex, evt.cell.index);
}
});
this.connect(g, "onEndAutoScroll", function(isVertical, isForward, view, target, evt){
if(this._dnding){
this._markTargetAnchor(evt);
}
});
this.connect(win.doc, "onkeydown", function(evt){
if(evt.keyCode == keys.ESCAPE){
this._endDnd(false);
}else if(evt.keyCode == keys.CTRL){
s.selectEnabled(true);
this._isCopy = true;
}
});
this.connect(win.doc, "onkeyup", function(evt){
if(evt.keyCode == keys.CTRL){
s.selectEnabled(!this._dndReady);
this._isCopy = false;
}
});
},
_clear: function(){
this._dndRegion = null;
this._target = null;
this._moveEvent = null;
this._targetAnchor = {};
this._dnding = false;
this._externalDnd = false;
this._isSource = false;
this._alreadyOut = false;
this._extDnding = false;
},
_getDnDRegion: function(rowIndex, colIndex){
var s = this.selector,
selected = s._selected,
flag = (!!selected.cell.length) | (!!selected.row.length << 1) | (!!selected.col.length << 2),
type;
switch(flag){
case 1:
type = "cell";
if(!this._config[type]["within"] && !this._config[type]["out"]){
return null;
}
var cells = this.grid.layout.cells,
getCount = function(range){
var hiddenColCnt = 0;
for(var i = range.min.col; i <= range.max.col; ++i){
if(cells[i].hidden){
++hiddenColCnt;
}
}
return (range.max.row - range.min.row + 1) * (range.max.col - range.min.col + 1 - hiddenColCnt);
},
inRange = function(item, range){
return item.row >= range.min.row && item.row <= range.max.row &&
item.col >= range.min.col && item.col <= range.max.col;
},
range = {
max: {
row: -1,
col: -1
},
min: {
row: Infinity,
col: Infinity
}
};
array.forEach(selected[type], function(item){
if(item.row < range.min.row){
range.min.row = item.row;
}
if(item.row > range.max.row){
range.max.row = item.row;
}
if(item.col < range.min.col){
range.min.col = item.col;
}
if(item.col > range.max.col){
range.max.col = item.col;
}
});
if(array.some(selected[type], function(item){
return item.row == rowIndex && item.col == colIndex;
})){
if(getCount(range) == selected[type].length && array.every(selected[type], function(item){
return inRange(item, range);
})){
return {
"type": type,
"selected": [range],
"handle": {
"row": rowIndex,
"col": colIndex
}
};
}
}
return null;
case 2: case 4:
type = flag == 2 ? "row" : "col";
if(!this._config[type]["within"] && !this._config[type]["out"]){
return null;
}
var res = s.getSelected(type);
if(res.length){
return {
"type": type,
"selected": _devideToArrays(res),
"handle": flag == 2 ? rowIndex : colIndex
};
}
return null;
}
return null;
},
_startDnd: function(evt){
this._createDnDUI(evt);
},
_endDnd: function(destroySource){
this._destroyDnDUI(false, destroySource);
this._clear();
},
_createDnDUI: function(evt, isMovingIn){
//By default the master view of grid do not have height, because the children in it are all positioned absolutely.
//But we need it to contain avatars.
var viewPos = html.position(this.grid.views.views[0].domNode);
html.style(this._container, "height", viewPos.h + "px");
try{
//If moving in from out side, dnd source is already created.
if(!isMovingIn){
this._createSource(evt);
}
this._createMoveable(evt);
this._oldCursor = html.style(win.body(), "cursor");
html.style(win.body(), "cursor", "default");
}catch(e){
console.warn("DnD._createDnDUI() error:", e);
}
},
_destroyDnDUI: function(isMovingOut, destroySource){
try{
if(destroySource){
this._destroySource();
}
this._unmarkTargetAnchor();
if(!isMovingOut){
this._destroyMoveable();
}
html.style(win.body(), "cursor", this._oldCursor);
}catch(e){
console.warn("DnD._destroyDnDUI() error:", this.grid.id, e);
}
},
_createSource: function(evt){
this._elem.createDnDNodes(this._dndRegion);
var m = dojo.dnd.manager();
var oldMakeAvatar = m.makeAvatar;
m._dndPlugin = this;
m.makeAvatar = function(){
var avatar = new GridDnDAvatar(m);
delete m._dndPlugin;
return avatar;
};
m.startDrag(this._source, this._elem.getDnDNodes(), evt.ctrlKey);
m.makeAvatar = oldMakeAvatar;
m.onMouseMove(evt);
},
_destroySource: function(){
connect.publish("/dnd/cancel");
},
_createMoveable: function(evt){
if(!this._markTagetAnchorHandler){
this._markTagetAnchorHandler = this.connect(win.doc, "onmousemove", "_markTargetAnchor");
}
},
_destroyMoveable: function(){
this.disconnect(this._markTagetAnchorHandler);
delete this._markTagetAnchorHandler;
},
_calcColTargetAnchorPos: function(evt, containerPos){
// summary:
// Calculate the position of the column DnD avatar
var i, headPos, left, target, ex = evt.clientX,
cells = this.grid.layout.cells,
ltr = html._isBodyLtr(),
headers = this._getVisibleHeaders();
for(i = 0; i < headers.length; ++i){
headPos = html.position(headers[i].node);
if(ltr ? ((i === 0 || ex >= headPos.x) && ex < headPos.x + headPos.w) :
((i === 0 || ex < headPos.x + headPos.w) && ex >= headPos.x)){
left = headPos.x + (ltr ? 0 : headPos.w);
break;
}else if(ltr ? (i === headers.length - 1 && ex >= headPos.x + headPos.w) :
(i === headers.length - 1 && ex < headPos.x)){
++i;
left = headPos.x + (ltr ? headPos.w : 0);
break;
}
}
if(i < headers.length){
target = headers[i].cell.index;
if(this.selector.isSelected("col", target) && this.selector.isSelected("col", target - 1)){
var ranges = this._dndRegion.selected;
for(i = 0; i < ranges.length; ++i){
if(array.indexOf(ranges[i], target) >= 0){
target = ranges[i][0];
headPos = html.position(cells[target].getHeaderNode());
left = headPos.x + (ltr ? 0 : headPos.w);
break;
}
}
}
}else{
target = cells.length;
}
this._target = target;
return left - containerPos.x;
},
_calcRowTargetAnchorPos: function(evt, containerPos){
// summary:
// Calculate the position of the row DnD avatar
var g = this.grid, top, i = 0,
cells = g.layout.cells;
while(cells[i].hidden){ ++i; }
var cell = g.layout.cells[i],
rowIndex = g.scroller.firstVisibleRow,
cellNode = cell.getNode(rowIndex);
if(!cellNode){
//if the target grid is empty, set to -1
//which will be processed in Rearrange
this._target = -1;
return 0; //position of the insert bar
}
var nodePos = html.position(cellNode);
while(nodePos.y + nodePos.h < evt.clientY){
if(++rowIndex >= g.rowCount){
break;
}
nodePos = html.position(cell.getNode(rowIndex));
}
if(rowIndex < g.rowCount){
if(this.selector.isSelected("row", rowIndex) && this.selector.isSelected("row", rowIndex - 1)){
var ranges = this._dndRegion.selected;
for(i = 0; i < ranges.length; ++i){
if(array.indexOf(ranges[i], rowIndex) >= 0){
rowIndex = ranges[i][0];
nodePos = html.position(cell.getNode(rowIndex));
break;
}
}
}
top = nodePos.y;
}else{
top = nodePos.y + nodePos.h;
}
this._target = rowIndex;
return top - containerPos.y;
},
_calcCellTargetAnchorPos: function(evt, containerPos, targetAnchor){
// summary:
// Calculate the position of the cell DnD avatar
var s = this._dndRegion.selected[0],
origin = this._dndRegion.handle,
g = this.grid, ltr = html._isBodyLtr(),
cells = g.layout.cells, headPos,
minPos, maxPos, headers,
height, width, left, top,
minCol, maxCol, i,
preSpan = origin.col - s.min.col,
postSpan = s.max.col - origin.col,
leftTopDiv, rightBottomDiv;
if(!targetAnchor.childNodes.length){
leftTopDiv = html.create("div", {
"class": "dojoxGridCellBorderLeftTopDIV"
}, targetAnchor);
rightBottomDiv = html.create("div", {
"class": "dojoxGridCellBorderRightBottomDIV"
}, targetAnchor);
}else{
leftTopDiv = query(".dojoxGridCellBorderLeftTopDIV", targetAnchor)[0];
rightBottomDiv = query(".dojoxGridCellBorderRightBottomDIV", targetAnchor)[0];
}
for(i = s.min.col + 1; i < origin.col; ++i){
if(cells[i].hidden){
--preSpan;
}
}
for(i = origin.col + 1; i < s.max.col; ++i){
if(cells[i].hidden){
--postSpan;
}
}
headers = this._getVisibleHeaders();
//calc width
for(i = preSpan; i < headers.length - postSpan; ++i){
headPos = html.position(headers[i].node);
if((evt.clientX >= headPos.x && evt.clientX < headPos.x + headPos.w) || //within in this column
//prior to this column, but within range
(i == preSpan && (ltr ? evt.clientX < headPos.x : evt.clientX >= headPos.x + headPos.w)) ||
//post to this column, but within range
(i == headers.length - postSpan - 1 && (ltr ? evt.clientX >= headPos.x + headPos.w : evt < headPos.x))){
minCol = headers[i - preSpan];
maxCol = headers[i + postSpan];
minPos = html.position(minCol.node);
maxPos = html.position(maxCol.node);
minCol = minCol.cell.index;
maxCol = maxCol.cell.index;
left = ltr ? minPos.x : maxPos.x;
width = ltr ? (maxPos.x + maxPos.w - minPos.x) : (minPos.x + minPos.w - maxPos.x);
break;
}
}
//calc height
i = 0;
while(cells[i].hidden){ ++i; }
var cell = cells[i],
rowIndex = g.scroller.firstVisibleRow,
nodePos = html.position(cell.getNode(rowIndex));
while(nodePos.y + nodePos.h < evt.clientY){
if(++rowIndex < g.rowCount){
nodePos = html.position(cell.getNode(rowIndex));
}else{
break;
}
}
var minRow = rowIndex >= origin.row - s.min.row ? rowIndex - origin.row + s.min.row : 0;
var maxRow = minRow + s.max.row - s.min.row;
if(maxRow >= g.rowCount){
maxRow = g.rowCount - 1;
minRow = maxRow - s.max.row + s.min.row;
}
minPos = html.position(cell.getNode(minRow));
maxPos = html.position(cell.getNode(maxRow));
top = minPos.y;
height = maxPos.y + maxPos.h - minPos.y;
this._target = {
"min":{
"row": minRow,
"col": minCol
},
"max":{
"row": maxRow,
"col": maxCol
}
};
var anchorBorderSize = (html.marginBox(leftTopDiv).w - html.contentBox(leftTopDiv).w) / 2;
var leftTopCellPos = html.position(cells[minCol].getNode(minRow));
html.style(leftTopDiv, {
"width": (leftTopCellPos.w - anchorBorderSize) + "px",
"height": (leftTopCellPos.h - anchorBorderSize) + "px"
});
var rightBottomCellPos = html.position(cells[maxCol].getNode(maxRow));
html.style(rightBottomDiv, {
"width": (rightBottomCellPos.w - anchorBorderSize) + "px",
"height": (rightBottomCellPos.h - anchorBorderSize) + "px"
});
return {
h: height,
w: width,
l: left - containerPos.x,
t: top - containerPos.y
};
},
_markTargetAnchor: function(evt){
try{
var t = this._dndRegion.type;
if(this._alreadyOut || (this._dnding && !this._config[t]["within"]) || (this._extDnding && !this._config[t]["in"])){
return;
}
var height, width, left, top,
targetAnchor = this._targetAnchor[t],
pos = html.position(this._container);
if(!targetAnchor){
targetAnchor = this._targetAnchor[t] = html.create("div", {
"class": (t == "cell") ? "dojoxGridCellBorderDIV" : "dojoxGridBorderDIV"
});
html.style(targetAnchor, "display", "none");
this._container.appendChild(targetAnchor);
}
switch(t){
case "col":
height = pos.h;
width = this._targetAnchorBorderWidth;
left = this._calcColTargetAnchorPos(evt, pos);
top = 0;
break;
case "row":
height = this._targetAnchorBorderWidth;
width = pos.w;
left = 0;
top = this._calcRowTargetAnchorPos(evt, pos);
break;
case "cell":
var cellPos = this._calcCellTargetAnchorPos(evt, pos, targetAnchor);
height = cellPos.h;
width = cellPos.w;
left = cellPos.l;
top = cellPos.t;
}
if(typeof height == "number" && typeof width == "number" && typeof left == "number" && typeof top == "number"){
html.style(targetAnchor, {
"height": height + "px",
"width": width + "px",
"left": left + "px",
"top": top + "px"
});
html.style(targetAnchor, "display", "");
}else{
this._target = null;
}
}catch(e){
console.warn("DnD._markTargetAnchor() error:",e);
}
},
_unmarkTargetAnchor: function(){
if(this._dndRegion){
var targetAnchor = this._targetAnchor[this._dndRegion.type];
if(targetAnchor){
html.style(this._targetAnchor[this._dndRegion.type], "display", "none");
}
}
},
_getVisibleHeaders: function(){
return array.map(array.filter(this.grid.layout.cells, function(cell){
return !cell.hidden;
}), function(cell){
return {
"node": cell.getHeaderNode(),
"cell": cell
};
});
},
_rearrange: function(){
if(this._target === null){
return;
}
var t = this._dndRegion.type;
var ranges = this._dndRegion.selected;
if(t === "cell"){
this.rearranger[(this._isCopy || this._copyOnly) ? "copyCells" : "moveCells"](ranges[0], this._target === -1 ? null : this._target);
}else{
this.rearranger[t == "col" ? "moveColumns" : "moveRows"](_joinToArray(ranges), this._target === -1 ? null: this._target);
}
this._target = null;
},
onDraggingOver: function(sourcePlugin){
if(!this._dnding && sourcePlugin){
sourcePlugin._isSource = true;
this._extDnding = true;
if(!this._externalDnd){
this._externalDnd = true;
this._dndRegion = this._mapRegion(sourcePlugin.grid, sourcePlugin._dndRegion);
}
this._createDnDUI(this._moveEvent,true);
this.grid.pluginMgr.getPlugin("autoScroll").readyForAutoScroll = true;
}
},
_mapRegion: function(srcGrid, dndRegion){
if(dndRegion.type === "cell"){
var srcRange = dndRegion.selected[0];
var cells = this.grid.layout.cells;
var srcCells = srcGrid.layout.cells;
var c, cnt = 0;
for(c = srcRange.min.col; c <= srcRange.max.col; ++c){
if(!srcCells[c].hidden){
++cnt;
}
}
for(c = 0; cnt > 0; ++c){
if(!cells[c].hidden){
--cnt;
}
}
var region = lang.clone(dndRegion);
region.selected[0].min.col = 0;
region.selected[0].max.col = c - 1;
for(c = srcRange.min.col; c <= dndRegion.handle.col; ++c){
if(!srcCells[c].hidden){
++cnt;
}
}
for(c = 0; cnt > 0; ++c){
if(!cells[c].hidden){
--cnt;
}
}
region.handle.col = c;
}
return dndRegion;
},
onDraggingOut: function(sourcePlugin){
if(this._externalDnd){
this._extDnding = false;
this._destroyDnDUI(true, false);
if(sourcePlugin){
sourcePlugin._isSource = false;
}
}
},
onDragIn: function(sourcePlugin, isCopy){
var success = false;
if(this._target !== null){
var type = sourcePlugin._dndRegion.type;
var ranges = sourcePlugin._dndRegion.selected;
switch(type){
case "cell":
this.rearranger.changeCells(sourcePlugin.grid, ranges[0], this._target);
break;
case "row":
var range = _joinToArray(ranges);
this.rearranger.insertRows(sourcePlugin.grid, range, this._target);
break;
}
success = true;
}
this._endDnd(true);
if(sourcePlugin.onDragOut){
sourcePlugin.onDragOut(success && !isCopy);
}
},
onDragOut: function(isMove){
if(isMove && !this._copyOnly){
var type = this._dndRegion.type;
var ranges = this._dndRegion.selected;
switch(type){
case "cell":
this.rearranger.clearCells(ranges[0]);
break;
case "row":
this.rearranger.removeRows(_joinToArray(ranges));
break;
}
}
this._endDnd(true);
},
_canAccept: function(sourcePlugin){
if(!sourcePlugin){
return false;
}
var srcRegion = sourcePlugin._dndRegion;
var type = srcRegion.type;
if(!this._config[type]["in"] || !sourcePlugin._config[type]["out"]){
return false;
}
var g = this.grid;
var ranges = srcRegion.selected;
var colCnt = array.filter(g.layout.cells, function(cell){
return !cell.hidden;
}).length;
var rowCnt = g.rowCount;
var res = true;
switch(type){
case "cell":
ranges = ranges[0];
res = g.store.getFeatures()["dojo.data.api.Write"] &&
(ranges.max.row - ranges.min.row) <= rowCnt &&
array.filter(sourcePlugin.grid.layout.cells, function(cell){
return cell.index >= ranges.min.col && cell.index <= ranges.max.col && !cell.hidden;
}).length <= colCnt;
//intentional drop through - don't break
case "row":
if(sourcePlugin._allDnDItemsLoaded()){
return res;
}
}
return false;
},
_allDnDItemsLoaded: function(){
if(this._dndRegion){
var type = this._dndRegion.type,
ranges = this._dndRegion.selected,
rows = [];
switch(type){
case "cell":
for(var i = ranges[0].min.row, max = ranges[0].max.row; i <= max; ++i){
rows.push(i);
}
break;
case "row":
rows = _joinToArray(ranges);
break;
default:
return false;
}
var cache = this.grid._by_idx;
return array.every(rows, function(rowIndex){
return !!cache[rowIndex];
});
}
return false;
}
});
EnhancedGrid.registerPlugin(DnD/*name:'dnd'*/, {
"dependency": ["selector", "rearrange"]
});
return DnD;
});
| {
"pile_set_name": "Github"
} |
var getLength = require('./getLength'),
isLength = require('./isLength'),
toObject = require('./toObject');
/**
* Creates a `baseEach` or `baseEachRight` function.
*
* @private
* @param {Function} eachFunc The function to iterate over a collection.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new base function.
*/
function createBaseEach(eachFunc, fromRight) {
return function(collection, iteratee) {
var length = collection ? getLength(collection) : 0;
if (!isLength(length)) {
return eachFunc(collection, iteratee);
}
var index = fromRight ? length : -1,
iterable = toObject(collection);
while ((fromRight ? index-- : ++index < length)) {
if (iteratee(iterable[index], index, iterable) === false) {
break;
}
}
return collection;
};
}
module.exports = createBaseEach;
| {
"pile_set_name": "Github"
} |
// SPDX-License-Identifier: GPL-2.0
#include "levenshtein.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
/*
* This function implements the Damerau-Levenshtein algorithm to
* calculate a distance between strings.
*
* Basically, it says how many letters need to be swapped, substituted,
* deleted from, or added to string1, at least, to get string2.
*
* The idea is to build a distance matrix for the substrings of both
* strings. To avoid a large space complexity, only the last three rows
* are kept in memory (if swaps had the same or higher cost as one deletion
* plus one insertion, only two rows would be needed).
*
* At any stage, "i + 1" denotes the length of the current substring of
* string1 that the distance is calculated for.
*
* row2 holds the current row, row1 the previous row (i.e. for the substring
* of string1 of length "i"), and row0 the row before that.
*
* In other words, at the start of the big loop, row2[j + 1] contains the
* Damerau-Levenshtein distance between the substring of string1 of length
* "i" and the substring of string2 of length "j + 1".
*
* All the big loop does is determine the partial minimum-cost paths.
*
* It does so by calculating the costs of the path ending in characters
* i (in string1) and j (in string2), respectively, given that the last
* operation is a substition, a swap, a deletion, or an insertion.
*
* This implementation allows the costs to be weighted:
*
* - w (as in "sWap")
* - s (as in "Substitution")
* - a (for insertion, AKA "Add")
* - d (as in "Deletion")
*
* Note that this algorithm calculates a distance _iff_ d == a.
*/
int levenshtein(const char *string1, const char *string2,
int w, int s, int a, int d)
{
int len1 = strlen(string1), len2 = strlen(string2);
int *row0 = malloc(sizeof(int) * (len2 + 1));
int *row1 = malloc(sizeof(int) * (len2 + 1));
int *row2 = malloc(sizeof(int) * (len2 + 1));
int i, j;
for (j = 0; j <= len2; j++)
row1[j] = j * a;
for (i = 0; i < len1; i++) {
int *dummy;
row2[0] = (i + 1) * d;
for (j = 0; j < len2; j++) {
/* substitution */
row2[j + 1] = row1[j] + s * (string1[i] != string2[j]);
/* swap */
if (i > 0 && j > 0 && string1[i - 1] == string2[j] &&
string1[i] == string2[j - 1] &&
row2[j + 1] > row0[j - 1] + w)
row2[j + 1] = row0[j - 1] + w;
/* deletion */
if (row2[j + 1] > row1[j + 1] + d)
row2[j + 1] = row1[j + 1] + d;
/* insertion */
if (row2[j + 1] > row2[j] + a)
row2[j + 1] = row2[j] + a;
}
dummy = row0;
row0 = row1;
row1 = row2;
row2 = dummy;
}
i = row1[len2];
free(row0);
free(row1);
free(row2);
return i;
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<title>Uses of Class javax.sound.sampled.CompoundControl.Type (Java SE 12 & JDK 12 )</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../../jquery/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../../../../jquery/jquery-migrate-3.0.1.js"></script>
<script type="text/javascript" src="../../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class javax.sound.sampled.CompoundControl.Type (Java SE 12 & JDK 12 )";
}
}
catch(err) {
}
//-->
var pathtoroot = "../../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="../../../../module-summary.html">Module</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../CompoundControl.Type.html" title="class in javax.sound.sampled">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 12 & JDK 12</strong> </div></div>
</div>
<div class="subNav">
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding"> </div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<main role="main">
<div class="header">
<h2 title="Uses of Class javax.sound.sampled.CompoundControl.Type" class="title">Uses of Class<br>javax.sound.sampled.CompoundControl.Type</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<div class="useSummary">
<table>
<caption><span>Packages that use <a href="../CompoundControl.Type.html" title="class in javax.sound.sampled">CompoundControl.Type</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<th class="colFirst" scope="row"><a href="#javax.sound.sampled">javax.sound.sampled</a></th>
<td class="colLast">
<div class="block">Provides interfaces and classes for capture, processing, and playback of
sampled audio data.</div>
</td>
</tr>
</tbody>
</table>
</div>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList">
<section role="region"><a id="javax.sound.sampled">
<!-- -->
</a>
<h3>Uses of <a href="../CompoundControl.Type.html" title="class in javax.sound.sampled">CompoundControl.Type</a> in <a href="../package-summary.html">javax.sound.sampled</a></h3>
<div class="useSummary">
<table>
<caption><span>Constructors in <a href="../package-summary.html">javax.sound.sampled</a> with parameters of type <a href="../CompoundControl.Type.html" title="class in javax.sound.sampled">CompoundControl.Type</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../CompoundControl.html#%3Cinit%3E(javax.sound.sampled.CompoundControl.Type,javax.sound.sampled.Control%5B%5D)">CompoundControl</a></span>​(<a href="../CompoundControl.Type.html" title="class in javax.sound.sampled">CompoundControl.Type</a> type,
<a href="../Control.html" title="class in javax.sound.sampled">Control</a>[] memberControls)</code></th>
<td class="colLast">
<div class="block">Constructs a new compound control object with the given parameters.</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</li>
</ul>
</li>
</ul>
</div>
</main>
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="../../../../module-summary.html">Module</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../CompoundControl.Type.html" title="class in javax.sound.sampled">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 12 & JDK 12</strong> </div></div>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small><a href="https://bugreport.java.com/bugreport/">Report a bug or suggest an enhancement</a><br> For further API reference and developer documentation see the <a href="https://docs.oracle.com/pls/topic/lookup?ctx=javase12.0.2&id=homepage" target="_blank">Java SE Documentation</a>, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.<br> Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.<br> <a href="../../../../../../legal/copyright.html">Copyright</a> © 1993, 2019, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.<br>All rights reserved. Use is subject to <a href="https://www.oracle.com/technetwork/java/javase/terms/license/java12.0.2speclicense.html">license terms</a> and the <a href="https://www.oracle.com/technetwork/java/redist-137594.html">documentation redistribution policy</a>. <!-- Version 12.0.2+10 --></small></p>
</footer>
</body>
</html>
| {
"pile_set_name": "Github"
} |
/*
* CaptureTheFlagFlagTest.java
*/
package games.stendhal.server.entity.item;
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.junit.Test;
import games.stendhal.server.entity.DressedEntity;
import games.stendhal.server.entity.Outfit;
import games.stendhal.server.entity.RPEntity;
import games.stendhal.server.entity.player.Player;
import games.stendhal.server.maps.MockStendlRPWorld;
import marauroa.common.Log4J;
import marauroa.common.game.SlotOwner;
import utilities.PlayerTestHelper;
import utilities.RPClass.ItemTestHelper;
public class CaptureTheFlagFlagTest {
/**
* TODO: move this in to test utils
*/
class TestEntity extends DressedEntity {
public String name;
public TestEntity(String name) {
this.name = name;
this.setOutfit(Outfit.getRandomOutfit());
}
public TestEntity() {
this("NoName");
}
@Override
public void dropItemsOn(Corpse corpse) {}
@Override
public void logic() {}
}
/*
* XXX hack, until i can figure out how to have item.getContainerOwner()
* work normally (need slots, ...)
*
*/
class CheatingOwnerCaptureTheFlagFlag extends CaptureTheFlagFlag {
RPEntity owner = null;
@Override
public boolean onEquipped(RPEntity equipper, String slot) {
boolean result = super.onEquipped(equipper, slot);
if (!result) {
return result;
}
this.owner = equipper;
return result;
}
@Override
public SlotOwner getContainerOwner() {
return owner;
}
}
@BeforeClass
public static void setUpBeforeClass() throws Exception {
Log4J.init();
MockStendlRPWorld.get();
ItemTestHelper.generateRPClasses();
}
@Test
public void testOnEquipped() {
Player player = PlayerTestHelper.createPlayer("player1");
// CaptureTheFlagFlag flag = new CaptureTheFlagFlag();
CaptureTheFlagFlag flag = new CheatingOwnerCaptureTheFlagFlag();
boolean result;
// note: not taking the complete, correct, path through code to put the item in player's equipment
// DestinationObject does a lot of work to find slot in container, ...
// - flag/item cannot check that they are really owned by the owner, ...
//
// also note that we are not able to test that flag cannot be put in
// bag. change occurs when flag is equipped *anywhere*.
// in the game, there are restrictions - can only equip to hands
//
int origDetail = player.getOutfit().getLayer("detail");
assertEquals(origDetail, (int) player.getOutfit().getLayer("detail"));
result = flag.onEquipped(player, "lhand");
assertEquals(true, result);
// confirm change to outfit
assertEquals(flag.getDetailValue(), (int)player.getOutfit().getLayer("detail"));
assertEquals(flag.getColorValue(), player.get("outfit_colors", "detail"));
}
@Test
public void testOnUnequipped() {
Player player = PlayerTestHelper.createPlayer("player1");
// CaptureTheFlagFlag flag = new CaptureTheFlagFlag();
CaptureTheFlagFlag flag = new CheatingOwnerCaptureTheFlagFlag();
String slot = "lhand";
boolean result;
// note: not taking the complete, correct, path through code to put the item in player's equipment
// DestinationObject does a lot of work to find slot in container, ...
// - flag/item cannot check that they are really owned by the owner, ...
//
// also note that we are not able to test that flag cannot be put in
// bag. change occurs when flag is equipped *anywhere*.
// in the game, there are restrictions - can only equip to hands
//
int origDetail = player.getOutfit().getLayer("detail");
// System.out.println(" slot: " + player.getSlot(slot));
// RPSlot rpslot = ((EntitySlot) player.getSlot(slot)).getWriteableSlot();
// unequipping from a player that never owned the item should
// not cause problems
result = flag.onUnequipped();
assertEquals(false, result);
result = flag.onEquipped(player, slot);
assertEquals(true, result);
// confirm change to outfit
assertEquals(flag.getDetailValue(), (int)player.getOutfit().getLayer("detail"));
assertEquals(flag.getColorValue(), player.get("outfit_colors", "detail"));
// flag.removeFromWorld();
flag.onUnequipped();
// flag.onUnequipped(player, slot, true);
// XXX this is failing, because flag.getContainerOwner()
// is returning null - we did not
// properly transfer to container
// confirm back to original value
assertEquals(origDetail, (int) player.getOutfit().getLayer("detail"));
}
/**
* a little bit bigger than a unit test, but this is what's
* important to test ...
*/
@Test
public void test_transferBetweenPlayers() {
Player player1 = PlayerTestHelper.createPlayer("player1");
Player player2 = PlayerTestHelper.createPlayer("player2");
// CaptureTheFlagFlag flag = new CaptureTheFlagFlag();
CaptureTheFlagFlag flag = new CheatingOwnerCaptureTheFlagFlag();
String slot = "lhand";
boolean result;
// note: not taking the complete, correct, path through code to put the item in player's equipment
// DestinationObject does a lot of work to find slot in container, ...
// - flag/item cannot check that they are really owned by the owner, ...
//
// also note that we are not able to test that flag cannot be put in
// bag. change occurs when flag is equipped *anywhere*.
// in the game, there are restrictions - can only equip to hands
//
int origDetail = player1.getOutfit().getLayer("detail");
result = flag.onEquipped(player1, slot);
assertEquals(true, result);
// confirm change to outfit
assertEquals(flag.getDetailValue(), (int)player1.getOutfit().getLayer("detail"));
assertEquals(flag.getColorValue(), player1.get("outfit_colors", "detail"));
// flag.removeFromWorld();
flag.onUnequipped();
// confirm player1 back to original value
assertEquals(origDetail, (int) player1.getOutfit().getLayer("detail"));
// TODO: confirm player2 outfit changed
// TODO: confirm player2 outfit back to default
result = flag.onEquipped(player2, slot);
assertEquals(true, result);
// confirm change to outfit
assertEquals(flag.getDetailValue(), (int)player2.getOutfit().getLayer("detail"));
assertEquals(flag.getColorValue(), player2.get("outfit_colors", "detail"));
// flag.removeFromWorld();
flag.onUnequipped();
// confirm player2 back to original value
assertEquals(origDetail, (int) player2.getOutfit().getLayer("detail"));
}
}
| {
"pile_set_name": "Github"
} |
using System.Web.Mvc;
using NUnit.Framework;
using Roadkill.Core;
using Roadkill.Core.Configuration;
using Roadkill.Core.Extensions;
using Roadkill.Core.Mvc.Controllers;
using Roadkill.Core.Services;
using Roadkill.Tests.Unit.StubsAndMocks;
using Roadkill.Tests.Unit.StubsAndMocks.Mvc;
namespace Roadkill.Tests.Unit.Extensions
{
[TestFixture]
[Category("Unit")]
public class UrlHelperExtensionsTests
{
// Objects for the UrlHelper
private MocksAndStubsContainer _container;
private ApplicationSettings _applicationSettings;
private IUserContext _context;
private PageRepositoryMock _pageRepository;
private UserServiceMock _userService;
private PageService _pageService;
private PageHistoryService _historyService;
private SettingsService _settingsService;
private SiteSettings _siteSettings;
private PluginFactoryMock _pluginFactory;
private WikiController _wikiController;
private UrlHelper _urlHelper;
[SetUp]
public void Setup()
{
// WikiController setup (use WikiController as it's the one typically used by views)
_container = new MocksAndStubsContainer();
_applicationSettings = _container.ApplicationSettings;
_context = _container.UserContext;
_pageRepository = _container.PageRepository;
_pluginFactory = _container.PluginFactory;
_settingsService = _container.SettingsService;
_siteSettings = _settingsService.GetSiteSettings();
_siteSettings.Theme = "Mediawiki";
_userService = _container.UserService;
_historyService = _container.HistoryService;
_pageService = _container.PageService;
_wikiController = new WikiController(_applicationSettings, _userService, _pageService, _context, _settingsService);
_wikiController.SetFakeControllerContext("~/wiki/index/1");
_urlHelper = _wikiController.Url;
}
[Test]
public void themecontent_should_return_expected_html()
{
// Arrange
string expectedHtml = "/Themes/Mediawiki/mythemefile.png";
// Act
string actualHtml = _urlHelper.ThemeContent("mythemefile.png", _siteSettings);
// Assert
Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
}
[Test]
public void csslink_should_return_expected_html()
{
// Arrange
string expectedHtml = @"<link href=""/Assets/CSS/roadkill.css?version={AppVersion}"" rel=""stylesheet"" type=""text/css"" />";
expectedHtml = expectedHtml.Replace("{AppVersion}", ApplicationSettings.ProductVersion);
// Act
string actualHtml = _urlHelper.CssLink("roadkill.css").ToHtmlString();
// Assert
Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
}
[Test]
public void scriptlink_should_return_expected_html()
{
// Arrange
string expectedHtml = @"<script type=""text/javascript"" language=""javascript"" src=""/Assets/Scripts/roadkill.js?version={AppVersion}""></script>";
expectedHtml = expectedHtml.Replace("{AppVersion}", ApplicationSettings.ProductVersion);
// Act
string actualHtml = _urlHelper.ScriptLink("roadkill.js").ToHtmlString();
// Assert
Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
}
[Test]
public void installerscriptlink_should_expected_html()
{
// Arrange
string expectedHtml = @"<script type=""text/javascript"" language=""javascript"" src=""/Assets/Scripts/roadkill/installer/step1.js?version={AppVersion}""></script>";
expectedHtml = expectedHtml.Replace("{AppVersion}", ApplicationSettings.ProductVersion);
// Act
string actualHtml = _urlHelper.InstallerScriptLink("step1.js").ToHtmlString();
// Assert
Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
}
[Test]
public void bootstrapcss_should_return_expected_html()
{
// Arrange
string expectedHtml = @"<link href=""/Assets/bootstrap/css/bootstrap.min.css?version={AppVersion}"" rel=""stylesheet"" type=""text/css"" />";
expectedHtml = expectedHtml.Replace("{AppVersion}", ApplicationSettings.ProductVersion);
// Act
string actualHtml = _urlHelper.BootstrapCSS().ToHtmlString();
// Assert
Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
}
[Test]
public void bootstrapjs_should_return_expected_html()
{
// Arrange
string expectedHtml = @"<script type=""text/javascript"" language=""javascript"" src=""/Assets/bootstrap/js/bootstrap.min.js?version={AppVersion}""></script>";
expectedHtml += "\n" +@"<script type=""text/javascript"" language=""javascript"" src=""/Assets/bootstrap/js/respond.min.js?version={AppVersion}""></script>";
expectedHtml = expectedHtml.Replace("{AppVersion}", ApplicationSettings.ProductVersion);
// Act
string actualHtml = _urlHelper.BootstrapJS().ToHtmlString();
// Assert
Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
}
}
}
| {
"pile_set_name": "Github"
} |
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build darwin linux windows
package asset
import "io"
// Open opens a named asset.
//
// Errors are of type *os.PathError.
//
// This must not be called from init when used in android apps.
func Open(name string) (File, error) {
return openAsset(name)
}
// File is an open asset.
type File interface {
io.ReadSeeker
io.Closer
}
| {
"pile_set_name": "Github"
} |
/*
@author Roberto G. Valenti <[email protected]>
@section LICENSE
Copyright (c) 2015, City University of New York
CCNY Robotics Lab <http://robotics.ccny.cuny.edu>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the City College of New York nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL the CCNY ROBOTICS LAB BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "imu_complementary_filter/complementary_filter_ros.h"
#include <std_msgs/Float64.h>
#include <std_msgs/Bool.h>
namespace imu_tools {
ComplementaryFilterROS::ComplementaryFilterROS(
const ros::NodeHandle& nh,
const ros::NodeHandle& nh_private):
nh_(nh),
nh_private_(nh_private),
initialized_filter_(false)
{
ROS_INFO("Starting ComplementaryFilterROS");
initializeParams();
int queue_size = 5;
// Register publishers:
imu_publisher_ = nh_.advertise<sensor_msgs::Imu>(ros::names::resolve("imu") + "/data", queue_size);
if (publish_debug_topics_)
{
rpy_publisher_ = nh_.advertise<geometry_msgs::Vector3Stamped>(
ros::names::resolve("imu") + "/rpy/filtered", queue_size);
if (filter_.getDoBiasEstimation())
{
state_publisher_ = nh_.advertise<std_msgs::Bool>(
ros::names::resolve("imu") + "/steady_state", queue_size);
}
}
// Register IMU raw data subscriber.
imu_subscriber_.reset(new ImuSubscriber(nh_, ros::names::resolve("imu") + "/data_raw", queue_size));
// Register magnetic data subscriber.
if (use_mag_)
{
mag_subscriber_.reset(new MagSubscriber(nh_, ros::names::resolve("imu") + "/mag", queue_size));
sync_.reset(new Synchronizer(
SyncPolicy(queue_size), *imu_subscriber_, *mag_subscriber_));
sync_->registerCallback(
boost::bind(&ComplementaryFilterROS::imuMagCallback, this, _1, _2));
}
else
{
imu_subscriber_->registerCallback(
&ComplementaryFilterROS::imuCallback, this);
}
}
ComplementaryFilterROS::~ComplementaryFilterROS()
{
ROS_INFO("Destroying ComplementaryFilterROS");
}
void ComplementaryFilterROS::initializeParams()
{
double gain_acc;
double gain_mag;
bool do_bias_estimation;
double bias_alpha;
bool do_adaptive_gain;
if (!nh_private_.getParam ("fixed_frame", fixed_frame_))
fixed_frame_ = "odom";
if (!nh_private_.getParam ("use_mag", use_mag_))
use_mag_ = false;
if (!nh_private_.getParam ("publish_tf", publish_tf_))
publish_tf_ = false;
if (!nh_private_.getParam ("reverse_tf", reverse_tf_))
reverse_tf_ = false;
if (!nh_private_.getParam ("constant_dt", constant_dt_))
constant_dt_ = 0.0;
if (!nh_private_.getParam ("publish_debug_topics", publish_debug_topics_))
publish_debug_topics_ = false;
if (!nh_private_.getParam ("gain_acc", gain_acc))
gain_acc = 0.01;
if (!nh_private_.getParam ("gain_mag", gain_mag))
gain_mag = 0.01;
if (!nh_private_.getParam ("do_bias_estimation", do_bias_estimation))
do_bias_estimation = true;
if (!nh_private_.getParam ("bias_alpha", bias_alpha))
bias_alpha = 0.01;
if (!nh_private_.getParam ("do_adaptive_gain", do_adaptive_gain))
do_adaptive_gain = true;
filter_.setDoBiasEstimation(do_bias_estimation);
filter_.setDoAdaptiveGain(do_adaptive_gain);
if(!filter_.setGainAcc(gain_acc))
ROS_WARN("Invalid gain_acc passed to ComplementaryFilter.");
if (use_mag_)
{
if(!filter_.setGainMag(gain_mag))
ROS_WARN("Invalid gain_mag passed to ComplementaryFilter.");
}
if (do_bias_estimation)
{
if(!filter_.setBiasAlpha(bias_alpha))
ROS_WARN("Invalid bias_alpha passed to ComplementaryFilter.");
}
// check for illegal constant_dt values
if (constant_dt_ < 0.0)
{
// if constant_dt_ is 0.0 (default), use IMU timestamp to determine dt
// otherwise, it will be constant
ROS_WARN("constant_dt parameter is %f, must be >= 0.0. Setting to 0.0", constant_dt_);
constant_dt_ = 0.0;
}
}
void ComplementaryFilterROS::imuCallback(const ImuMsg::ConstPtr& imu_msg_raw)
{
const geometry_msgs::Vector3& a = imu_msg_raw->linear_acceleration;
const geometry_msgs::Vector3& w = imu_msg_raw->angular_velocity;
const ros::Time& time = imu_msg_raw->header.stamp;
// Initialize.
if (!initialized_filter_)
{
time_prev_ = time;
initialized_filter_ = true;
return;
}
// determine dt: either constant, or from IMU timestamp
double dt;
if (constant_dt_ > 0.0)
dt = constant_dt_;
else
dt = (time - time_prev_).toSec();
time_prev_ = time;
// Update the filter.
filter_.update(a.x, a.y, a.z, w.x, w.y, w.z, dt);
// Publish state.
publish(imu_msg_raw);
}
void ComplementaryFilterROS::imuMagCallback(const ImuMsg::ConstPtr& imu_msg_raw,
const MagMsg::ConstPtr& mag_msg)
{
const geometry_msgs::Vector3& a = imu_msg_raw->linear_acceleration;
const geometry_msgs::Vector3& w = imu_msg_raw->angular_velocity;
const geometry_msgs::Vector3& m = mag_msg->magnetic_field;
const ros::Time& time = imu_msg_raw->header.stamp;
// Initialize.
if (!initialized_filter_)
{
time_prev_ = time;
initialized_filter_ = true;
return;
}
// Calculate dt.
double dt = (time - time_prev_).toSec();
time_prev_ = time;
//ros::Time t_in, t_out;
//t_in = ros::Time::now();
// Update the filter.
if (isnan(m.x) || isnan(m.y) || isnan(m.z))
filter_.update(a.x, a.y, a.z, w.x, w.y, w.z, dt);
else
filter_.update(a.x, a.y, a.z, w.x, w.y, w.z, m.x, m.y, m.z, dt);
//t_out = ros::Time::now();
//float dt_tot = (t_out - t_in).toSec() * 1000.0; // In msec.
//printf("%.6f\n", dt_tot);
// Publish state.
publish(imu_msg_raw);
}
tf::Quaternion ComplementaryFilterROS::hamiltonToTFQuaternion(
double q0, double q1, double q2, double q3) const
{
// ROS uses the Hamilton quaternion convention (q0 is the scalar). However,
// the ROS quaternion is in the form [x, y, z, w], with w as the scalar.
return tf::Quaternion(q1, q2, q3, q0);
}
void ComplementaryFilterROS::publish(
const sensor_msgs::Imu::ConstPtr& imu_msg_raw)
{
// Get the orientation:
double q0, q1, q2, q3;
filter_.getOrientation(q0, q1, q2, q3);
tf::Quaternion q = hamiltonToTFQuaternion(q0, q1, q2, q3);
// Create and publish fitlered IMU message.
boost::shared_ptr<sensor_msgs::Imu> imu_msg =
boost::make_shared<sensor_msgs::Imu>(*imu_msg_raw);
tf::quaternionTFToMsg(q, imu_msg->orientation);
// Account for biases.
if (filter_.getDoBiasEstimation())
{
imu_msg->angular_velocity.x -= filter_.getAngularVelocityBiasX();
imu_msg->angular_velocity.y -= filter_.getAngularVelocityBiasY();
imu_msg->angular_velocity.z -= filter_.getAngularVelocityBiasZ();
}
imu_publisher_.publish(imu_msg);
if (publish_debug_topics_)
{
// Create and publish roll, pitch, yaw angles
geometry_msgs::Vector3Stamped rpy;
rpy.header = imu_msg_raw->header;
tf::Matrix3x3 M;
M.setRotation(q);
M.getRPY(rpy.vector.x, rpy.vector.y, rpy.vector.z);
rpy_publisher_.publish(rpy);
// Publish whether we are in the steady state, when doing bias estimation
if (filter_.getDoBiasEstimation())
{
std_msgs::Bool state_msg;
state_msg.data = filter_.getSteadyState();
state_publisher_.publish(state_msg);
}
}
if (publish_tf_)
{
// Create and publish the ROS tf.
tf::Transform transform;
transform.setOrigin(tf::Vector3(0.0, 0.0, 0.0));
transform.setRotation(q);
if (reverse_tf_)
{
tf_broadcaster_.sendTransform(
tf::StampedTransform(transform.inverse(),
imu_msg_raw->header.stamp,
imu_msg_raw->header.frame_id,
fixed_frame_));
}
else
{
tf_broadcaster_.sendTransform(
tf::StampedTransform(transform,
imu_msg_raw->header.stamp,
fixed_frame_,
imu_msg_raw->header.frame_id));
}
}
}
} // namespace imu_tools
| {
"pile_set_name": "Github"
} |
+++
title = "Software Engineering"
author = ["Derrick Chua", "Jethro Kuan"]
lastmod = 2020-07-17T00:57:54+08:00
draft = false
+++
## Object-Oriented Programming {#object-oriented-programming}
- Every object has both _state_ (data) and _behaviour_ (operations on
data).
- Every object has an _interface_ and an _implementation_.
- Interface are for other objects to interact with.
- Implementations support the interface, and may not be accessible
to other objects.
### Basic UML Notation {#basic-uml-notation}
The class is denoted with 3 parts: The class name, its attributes, and
its methods.
{{< figure src="/ox-hugo/class_uml.png" >}}
Instances of a class are denoted with 3 parts: its name (and class),
and its attribute values.
{{< figure src="/ox-hugo/instance_uml.png" >}}
Class-level attributes and variables are denoted by <span class="underline">underlines</span>. In
the class diagram below, `totalStudents` and `getTotalStudents` are
class-level.\_
{{< figure src="/ox-hugo/class_level_uml.png" >}}
UML Notation for enumerations:
{{< figure src="/ox-hugo/enumeration_uml.png" >}}
### Associations {#associations}
- A solid line indicates an association between 2 objects.
- The concept of _Navigability_ refers to whether the association
knows about the other class. Arrow heads are used to indicate the
navigability of the association.
{{< figure src="/ox-hugo/navigability_uml.png" >}}
- Multiplicity is denoted on each end of the association.
{{< figure src="/ox-hugo/multiplicity_uml.png" >}}
- Dependencies are weaker associations where interactions between
objects do not result in a long-term relationship. A dashed arrow
is used to show dependencies.
{{< figure src="/ox-hugo/dependencies_uml.png" >}}
- Composition represents a strong whole-part relationship. When the
whole is destroyed, parts are destroyed too. There cannot be
cyclical links in composition.
{{< figure src="/ox-hugo/composition_uml.png" >}}
- Aggregation represents a container-contained relationship.
{{< figure src="/ox-hugo/aggregation_uml.png" >}}
- An association class represents additional information about an
association. It is a normal class but plays a special role from a
design point of view.
{{< figure src="/ox-hugo/association_class_uml.png" >}}
### Inheritance {#inheritance}
Inheritance allows you to define a new class based on an existing
class. This helps group common parts among classes. This is denoted by
an arrow.
{{< figure src="/ox-hugo/inheritance_uml.png" >}}
### Interfaces {#interfaces}
An _interface_ is a behaviour specification. If a class implements the
interface, it is able to support the behaviours specified by the
interface. A class implementing an interface results in an is-a
relationship. In the example below, `AcademicStaff` is a
`SalariedStaff`.
{{< figure src="/ox-hugo/interface_uml.png" >}}
An abstract method is the method interface without the implementation.
It is denoted with the `{abstract}` annotation in the UML diagram.
{{< figure src="/ox-hugo/abstract_uml.png" >}}
### Polymorphism {#polymorphism}
_Polymorphism_ is the ability of different objects to respond, each
it its own way, to identical messages. The mechanisms that enable
polymorphism are:
Substitutability
: write code that expects parent class, yet use
that code with objects of child classes.
Overriding
: Operations in the super class need to be overridden in
each of the subclasses.
Dynamic binding
: Calls to overridden methods are bound to the
implementation of the actual object's class dynamically during
runtime.
## Modelling Behaviour {#modelling-behaviour}
### Activity Diagrams {#activity-diagrams}
Actions
: Rectangles with rounded edges (Steps)
Control flows
: Lines with arrowheads (Flow of control from one
action to another)
Alternate paths
: Diamond shapes - Branch or merge nodes - Each control flow leaving branch node has guard condition - Only 1 alernative path can be taken at any time.
Parallel paths
: bar - Forks and join - Indicate start and end of concurrent flows of control
Part of Activity
: rakes - Indicate that part of activity is given as separate diagram - In actions
Actor partitions
: swimlanes - Partition activity diagram to show who is doing which action (Who
label at the top, as columns)
{{< figure src="/ox-hugo/activity_branch_uml.png" >}}
{{< figure src="/ox-hugo/activity_fork_join_uml.png" >}}
### Sequence Diagrams {#sequence-diagrams}
Method calls
: Solid arrows
Method returns
: Dotted arrows (optional)
Loops
: labeled boxes
Activation bar (optional) - Method is running and in charge of execution - Constructor is active - Dotted lines after activation bar shows a lifeline, i.e. it is
still alive
Deletion
: Use a X at end of lifeline of an object
Self Invocation
: Draw a second bar within the activation bar for
inner method and an arrow to show self invocation
Alternative paths
: `Alt` frames (boxes) with dotted horizontal
lines to separate alternative paths
Optional paths
: `Opt` frames
Reference frames
: frames - `ref` frame to omit details/ Show frame in another sequence
diagram - `sd` frame to show details
Parallel paths
: For multi-threading, as multiple things are being
done at the same time
Note:
- No underlined object names (e.g. :Object)
{{< figure src="/ox-hugo/sequence_uml.png" >}}
## Software Requirements {#software-requirements}
Requirements come from _stakeholders_: parties that are directly
affected by the software project.
functional requirements
: specify what the system should do - data requirements: availability etc.
non-functional requirements
: specify the constraints under which
system is developed - business and domain rules: the size of the group cannot be more
than 5 - constraints: should be backwards compatible - technical requirements: should work on 32/64-bit environments
Good requirements are: unambiguous, testable, clear, correct,
understandable, feasible, independent, atomic, necessary,
implementation-free
User stories follow the format: `As a _, I can _ so that _`. They
occur on different levels, high-level stories are called epics.
## Design {#design}
Software design has 2 main aspects:
1. product/external design: designing the external behaviour of the
product to meet the user requirements.
2. implementation/internal design: designing how the product will be
implemented to meet the required external behaviour.
3. technique for dealing with complexity, establishes a
level of complexity we are interested in, and
suppressing more complex details below that level.
### Coupling {#coupling}
Coupling is the **measure of the degree of dependence** between
components. Highly coupled components are:
- **harder to maintain**: change in one module can cause changes to other modules
- **harder to integrate**: multiple components have to be integrated at
the same time
- **harder to test**: dependence on other modules
Coupling comes in various forms:
Content Coupling
: one module modifies or relies on the internal
workings of another module.
Common/Global Coupling
: two modules share the same global data
Control Coupling
: one module controls the flow of the other
Data Coupling
: one module sharing data with another module (e.g.
passing params)
External Coupling
: two modules share an externally imposed convention
Subclass Coupling
: a class inherits from another class
Temporal Coupling
: two actions are bundled together because they
happen to occur at the same time
### Cohesion {#cohesion}
Cohesion is a **measure of how strongly-related and focused the
various responsibilities of a component are**. Low cohesion can:
- impede the understandability of modules
- lower maintainability because a module can be modified due to
unrelated causes
- lowers reusability because they do not represent logical units of
functionality
Cohesion can be present in many forms:
- Code related to the same concept are kept together
- Code invoked close together in time are kept together
- Code manipulating the same data structure are kept together
## Software Architecture {#software-architecture}
Software architecture shows the **overall organization of the system
and can be viewed as a very high-level design**.
### Architectural Styles {#architectural-styles}
1. n-tier
- n layer
- Higher layer communicates to lower tier
- Must be independent
2. Client-server
- At least one client component and one server component
- Commonly used in distributed apps
3. Event-driven Style
- Detect events from emitters and communicating to event consumers
4. Transaction processing style
- Divides workload down to a number of transactions which are given
to a dispatcher which controls the execution for each transaction
5. Service-oriented architecture (SOA)
- Combining functionalities packaged by programmatically accessible
services
- e.g. Creating an SOA app that uses Amazon web services
6. Pipes and Filters pattern
- Break down processing tasks by modules (streams) into separate
components(filters), each into 1 task
- Combine them into a pipeline by standardising format of data each
component sends and receives
- Bottleneck - Slowest filter
- Components can be run independently
- Used when processing steps by an application have different
scalability requirements
7. Broker pattern
- Broker component coordinates communication, such as forwarding
requests, as well as for transmitting results and exceptions
- Used to structure distributed software systems with decoupled
components interacting by remote service invocations
8. Peer-to-peer
- Partitions workload between peers (both 'client' and 'server' to
other nodes)
9. Message-driven processing
- Client sends service requests in specially-formatted messages to
request brokers(programs)
- Request brokers maintain queues of requests (and maybe replies) to
screen their details
## Software Design Patterns {#software-design-patterns}
Software Design Patterns are **elegant reusable solutions to commonly
recurring problems within a given context in software design**.
Design patterns are specified with: context, problem, solution,
anti-patterns, consequences and other useful information.
### Singleton {#singleton}
- **Context**: certain classes should have no more than 1 instance.
- **Problem**: a normal class can be instantiated multiple times by
invoking the constructor
- **Solution**: make the constructor of the singleton class `private`,
provide a public class-level method to access the single instance.
- Pros:
- Easy to apply
- Effective with minimal work
- Access singleton from anywhere
- Cons:
- Global variable, increases coupling
- Hard to test as they cannot be replaced with stubs
- Singletons carry data from one test to another
### Abstraction Occurrence {#abstraction-occurrence}
- **Context**: Group of similar entities that appear to be occurrences
of the same thing, sharing a lot of common information, but differ
in many ways.
- **Problem**: representing objects as a single class would result in
duplication of data, leading to inconsistencies in data.
- **Solution**: Let a copy of the entity be represented by multiple
objects, separating the common and unique information into 2
classes.
### Facade Pattern {#facade-pattern}
- **Context**: Components need access to functionality deep inside other
components
- **Problem**: Access to component should be allowed without exposing
internal details
- **Solution**: Create a Facade class that sits between the component
internals and users of the component that access the component
happens through the facade class.
{{< figure src="/ox-hugo/facade.png" >}}
### Command Pattern {#command-pattern}
- **Context**: A system is required to execute a number of commands,s
each doing a different task.
- **Problem**: Prefer to have code executing command to not have to know
each command type
- **Solution**: Have a general `Command` object that can be passed
around, stored and executed without knowing the type of command.
### MVC Pattern {#mvc-pattern}
- **Context**: applications support storage/retrieval of information,
display, and updating stored information
- **Problem**: want to reduce coupling between interlinked nature of the
above features
- **Solution**: _View_ displays data, interacts with the user.
_Controller_ detects UI events, and updates the model/view when
necessary. _Model_ stores and maintains the data, updates the views
if necessary.
### Observer Pattern {#observer-pattern}
- **Context**: An object is interested in getting notified when a change
happens to another object
- **Problem**: the observed object does not want to be coupled to
objects that are 'observing' it
- **Solution**: Force the communication through an interface know to
both parties.
{{< figure src="/ox-hugo/observer.png" >}}
## Implementation {#implementation}
Debugging
: process of discovering defects in the program. - inserting temporary print statements incur extra effort, manually
tracing through code is difficult and time consuming. We should
use a debugger tool, which allows pausing and stepping through
execution of the code.
### Code Quality {#code-quality}
There are various dimensions of code quality, including **run-time
efficiency, security, and robustness**. The most important perhaps is
**readability**.
Some basic guidelines:
1. Avoid long methods
2. Avoid deep nesting
3. Avoid complicated expressions
4. Avoid Magic numbers
5. Make the code obvious, e.g. by using explicity type conversion
6. Structure code logically
7. Do not trip up the reader, with things like unused parameters in
the method signature
8. Practice KISSing
9. Avoid premature optimizations
10. Make the happy path prominent
11. SLAP (Single level of abstraction per method) hard
12. Make the happy path prominent
It is also good to follow a **coding standard**.
Comments should explain the what and why, and not the how. Write
comments minimally but sufficiently, not repeating the obvious and
writing with the reader in mind.
### Refactoring {#refactoring}
Refactoring **improves a program's internal structure in small steps without
modifying its external behaviour.** It is not rewriting, and not bug-fixing.
Common refactors include:
- Consolidate duplicate conditional fragments
- extract method
### Error Handling {#error-handling}
Exceptions are events that occur during the execution of a program,
that **disrupt the normal flow of the program's instructions**.
Exception objects encapsulate the unusual situation so that another
piece of code can catch it and deal with it. Exception objects
propagate up the method call hierarchy until it is dealt with.
### Assertions {#assertions}
Assertions are used to define assumptions about the program state so
that the runtime can verify them. If the runtime detects an assertion
failure, it typically takes some drastic action, such as terminating
the program. Assertions can be disabled without modifying the code.
### Logging {#logging}
Logging is **The deliberate recording of certain information during
program execution for future reference**, and is useful for
troubleshooting problems. Most languages come with a logging
mechanism, and the logger has different levels: SEVERE,
INFO, WARNING etc.
<!--list-separator-->
- Build automation
1. Gradle
- Automates tasks such as:
- Running tests
- Manage library dependencies
- Analyse code for style compliance
- Gradle configuration is defined in build script build.gradle
- Gradle commands are run in gradlew (wrapper) which runs the
following commands by default:
- clean
- headless
- allTests
- coverage
- Dependencies are updated automatically by other relevant Gradle
tasks
<!--list-separator-->
- Continuous Integration (CI)
1. Integration, building and testing happens automatically after code
change
2. Travis CI
3. Continuous Deployment (CD) - Changes are integreated, and deployed to
end-users at the same time (e.g. Travis)
### Defensive Programming {#defensive-programming}
- Leave no room for things to go wrong
- Enforce compulsory associations(perform checks for null)
- Enforce 1-to-1 associations (Initialise an association as a new
object first, before assignment)
- Enforce referential integrity (Inconsistency in object references)
(invoke the peer method when one is called)
### Design-by-Contract {#design-by-contract}
DbC is an \*approach for designing software that requires defining
formal, precise and verifiable interface specifications for software
components\*.
- Meet interface specifications for different components
(preconditions must be met) to fulfil contract
### Integration Approaches {#integration-approaches}
1. Late and one-time
- Wait till all components are completed and integrate all finished
components near end of project
- Not recommended due to possible component incompatabilities, which
can lead to delivery delays
2. Early and frequent
- Integrate early and evolve each part in parallel, in small steps,
re-integrating frequently
3. Big-Bang vs Incremental Integration
- Big-bang can lead to many problems at the same time
4. Top-Down vs Bottom-Up
- Top-Down require stubs
- Bottom-up require drivers
- Sandwich for both to 'meet' in the middle
### Reuse {#reuse}
By reusing tried and tested components, the robustness of a new
software system can be enhanced while reducing the manpower and time
requirement. There are costs associated with reuse.
### APIs {#apis}
An Application Programming Interface (API) specifies the interface
through which other programs can interact with a software component.
### Libraries and Frameworks {#libraries-and-frameworks}
A library is a collection of modular code that is general and can be
used by other programs. A software framework is a reusable
implementation of a software providing generic functionality that can
be selectively customized to produce a specific application. Libraries
are meant to be used 'as is' while frameworks are meant to be
customized/extended. Your code calls the library code while the
framework code calls your code.
### Platforms {#platforms}
A platform provides a runtime environment for applications. A
platform is often bundled with libraries, tools and frameworks.
## Quality Assurance {#quality-assurance}
QA ensures that the software being built has the required levels of
quality. This is achieved through:
code reviews
: the systematic examination of code with the
intention of finding where the code can be improved
static analysis
: analysis of the code without actually executing
the code (e.g. Linters)
formal verification
: mathematical techniques, used to prove the
correctness of a program. it can only be used to prove the
absence of errors, but only proves compliance with the
specification, and not the actual utility of the software.
### Testing {#testing}
When testing, we execute a set of test cases, containing the **input**
and the **expected behaviour**. Test cases can be determined based on
the specification.
<!--list-separator-->
- Unit Testing
- testing individual units to ensure each piece works correctly. In
OOP, this includes writing one or more unit tests for each public
method of a class.
- A proper unit test requires the unit to be testing in isolation,
hence stubs are created for the dependencies.
- **Dependency injection** is the process of replacing current
dependencies with another object, commonly seen with stubs.
Polymorphism can be used to implement this.
<!--list-separator-->
- Integration Testing
- testing whether different parts of the software work together as
expected. It aims to discover bugs in the "glue code" related to how
components interact with each other.
<!--list-separator-->
- System Testing
- Takes the whole system and tests it against the system specification
- System test cases are based on the specified external behaviour of
the system
- System testing includes testing against non-functional requirements
<!--list-separator-->
- Others
- alpha testing is performed by the users, under controlled conditions
set by the software development team
- beta testing is performed by a selected subset of users of the
system in their natural work setting
- dogfooding is the creators of the product using their own product
- developer testing is done by the developers themselves, so as to
locate the cause of test case failure or fixing bugs
- regression testing is the retesting the SUT to detect regressions when a system is modified.
<!--list-separator-->
- Exploratory vs Scripted Testing
- Exploratory testing devises test cases on-the-fly, creating new test
cases based on the results of past test cases
- dependent on the tester's prior experience and intuition
- Scripted testing is a set of test cases based on the expected
behaviour of the SUT
- more systematic, and hence likely to discover more bugs given
sufficient time
<!--list-separator-->
- Acceptance Testing
- test the delivered system to ensure it meets the user requirements
| System Testing | Acceptance Testing |
| ------------------------------------- | -------------------------------------------------- |
| done against the system specification | Done against the requirements specification |
| done by testers on the project team | done by a team that represents the customer |
| done on the development environment | done on the deployment site, or a close simulation |
| both negative and positive test cases | focus on positive test cases |
<!--list-separator-->
- Coverage
Coverage is the metric used to measure the extent to which testing
exercises the code.
function/method coverage
: based on the functions executed
statement coverage
: based on the number of lines of code executed
decision/branch coverage
: based on the decision points exercised
condition coverage
: based on the boolean sub-expressions
path coverage
: in terms of possible paths through a given part of
the code executed
entry/exit coverage
: in terms of possible calls to and exits from
the operations in the SUT
<!--list-separator-->
- Test Case Design
black-box
: designed exclusively based on the SUT's specified
external behaviour
white-box
: test cases are designed based on what is known about
the SUT's implementation
gray-box
: uses some important information about the
implementation.
Equivalence partitions are **groups of test inputs that are likely to
be processed by the SUTs in the same way**. This can be determined by
identifying:
1. target object of method call
2. input parameters of method call
3. other data objects accessed by the method, such as global
variables.
Boundary Value analysis is a \*test case design heuristic that is
based on the observation that bugs often result from incorrect
handling of boundaries of equivalence partitions\*.
Other heuristics include:
- each valid input at least once in a positive test case
- no more than 1 invalid input in a test case
## Software Engineering Principles {#software-engineering-principles}
<!--list-separator-->
- Law of Demeter
1. An object should have limited knowledge of another object
2. An object should have limited interaction with closely related
classes, if foo is coupled to bar, which is coupled to goo, foo
should not be coupled to goo
3. Reduces coupling
<!--list-separator-->
- SOLID
Single Responsibility Principle
: every module or class should
have responsibility over a single part of the functionality
provided by the software, and that responsibility should be
entirely encapsulated by the class.
Open-Closed Principle
: software entities (classes, modules,
functions, etc.) should be open for extension, but closed for
modification"; that is, such an entity can allow its behaviour to
be extended without modifying its source code.
Liskov Substitution Principle
: Functions that use pointers or
references to base classes must be able to use objects of derived
classes without knowing it.- Interface Segregation Principle :: no client should be forced to
depend on methods it does not use.
Dependency Inversion Principle
: high level modules should not
depend on low level modules; both should depend on abstractions.
Abstractions should not depend on details.
YAGNI
: a principle of extreme programming (XP) that states a
programmer should not add functionality until deemed
necessary.
DRY
: Don't repeat yourself, i.e. No duplicate implementations
Brook's Law
: Adding people to a late project makes it later
## Software Development Life Cycles {#software-development-life-cycles}
SDLC consists of different stages such as:
- Requirements
- Analysis
- Design
- Implementation
- Testing
<!--list-separator-->
- Sequential models
1. Software development as linear process
2. Useful for problems that are well-understood and stable
- Rarely applicable in real-world projects
3. Each stage provides artifacts for use in next stage
<!--list-separator-->
- Iterative models
1. Several iterations
2. Each iteration is a new version
- Each iteration is a complete product
3. Either breadth-first (all major components in parallel) or
depth-first (Flesh out some components at a time)
4. Most projects use both, i.e. iterative and incremental process
<!--list-separator-->
- Agile models
- Individuals and interactions over processes and tools
- Working software over comprehensive documentation
- Customer collaboration over contract negotiation
- Responding to change over following a plan
- Requirements based on needs of users, clarified regularly, factored
into developmental schedule when appropriate
- Rough project plan, high level design that evolves as the project
goes on
- Strong emphasis on transparency and responsibility sharing among
members
### Popular SDLC process models {#popular-sdlc-process-models}
<!--list-separator-->
- Scrum
- Scrum master
- Development team
- Product Owner
- Divided into Sprints (basic unit of development)
- Preceded by planning meeting
- Potentially deliverable product increment is done during Sprint
- Creates self-organising teams by encouraging co-location of team
members
- Customers can change their minds about their wants and needs
- Sprint backlog
- To do
- Daily scrums
- What did you do?
- What will you do?
- Are there any impediments?
<!--list-separator-->
- Extreme Programming (XP)
1. Stresses customer satisfaction
2. Empowers developers to respond to changing customer requirements
3. Emphasises teamwork
4. Completes software project via:
- Communication
- Simplicity
- Feedback
- Respect
- Courage
<!--list-separator-->
- Unified process
- Inception
- Understand problem and requirements
- Communicate
- Plan
- Elaboration
- Refine and expands requirements
- Construction
- Major implementation to support use cases
- Refine and flesh out design models
- Testing of all levels
- Multiple releases
- Transition
- Ready system for actual production use
- Familiarise end users with the system
### CMMI (Capability Maturity Model Integration) {#cmmi--capability-maturity-model-integration}
- Determine if process of an organisation is at a certain maturity level
- Initial
- Processes unpredictable, poorly controlled and reactive
- Managed
- Processes characterized for projects and reactive
- Defined
- Processes characterized for organisations and proactive
- Quantitatively Managed
- Processes measured and controllers
- Optimized
- Focus on process improvement
| {
"pile_set_name": "Github"
} |
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by client-gen. DO NOT EDIT.
package v1alpha1
import (
"time"
v1alpha1 "k8s.io/api/rbac/v1alpha1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
scheme "k8s.io/client-go/kubernetes/scheme"
rest "k8s.io/client-go/rest"
)
// RoleBindingsGetter has a method to return a RoleBindingInterface.
// A group's client should implement this interface.
type RoleBindingsGetter interface {
RoleBindings(namespace string) RoleBindingInterface
}
// RoleBindingInterface has methods to work with RoleBinding resources.
type RoleBindingInterface interface {
Create(*v1alpha1.RoleBinding) (*v1alpha1.RoleBinding, error)
Update(*v1alpha1.RoleBinding) (*v1alpha1.RoleBinding, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string, options v1.GetOptions) (*v1alpha1.RoleBinding, error)
List(opts v1.ListOptions) (*v1alpha1.RoleBindingList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.RoleBinding, err error)
RoleBindingExpansion
}
// roleBindings implements RoleBindingInterface
type roleBindings struct {
client rest.Interface
ns string
}
// newRoleBindings returns a RoleBindings
func newRoleBindings(c *RbacV1alpha1Client, namespace string) *roleBindings {
return &roleBindings{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the roleBinding, and returns the corresponding roleBinding object, and an error if there is any.
func (c *roleBindings) Get(name string, options v1.GetOptions) (result *v1alpha1.RoleBinding, err error) {
result = &v1alpha1.RoleBinding{}
err = c.client.Get().
Namespace(c.ns).
Resource("rolebindings").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of RoleBindings that match those selectors.
func (c *roleBindings) List(opts v1.ListOptions) (result *v1alpha1.RoleBindingList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha1.RoleBindingList{}
err = c.client.Get().
Namespace(c.ns).
Resource("rolebindings").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested roleBindings.
func (c *roleBindings) Watch(opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("rolebindings").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch()
}
// Create takes the representation of a roleBinding and creates it. Returns the server's representation of the roleBinding, and an error, if there is any.
func (c *roleBindings) Create(roleBinding *v1alpha1.RoleBinding) (result *v1alpha1.RoleBinding, err error) {
result = &v1alpha1.RoleBinding{}
err = c.client.Post().
Namespace(c.ns).
Resource("rolebindings").
Body(roleBinding).
Do().
Into(result)
return
}
// Update takes the representation of a roleBinding and updates it. Returns the server's representation of the roleBinding, and an error, if there is any.
func (c *roleBindings) Update(roleBinding *v1alpha1.RoleBinding) (result *v1alpha1.RoleBinding, err error) {
result = &v1alpha1.RoleBinding{}
err = c.client.Put().
Namespace(c.ns).
Resource("rolebindings").
Name(roleBinding.Name).
Body(roleBinding).
Do().
Into(result)
return
}
// Delete takes name of the roleBinding and deletes it. Returns an error if one occurs.
func (c *roleBindings) Delete(name string, options *v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("rolebindings").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *roleBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
var timeout time.Duration
if listOptions.TimeoutSeconds != nil {
timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("rolebindings").
VersionedParams(&listOptions, scheme.ParameterCodec).
Timeout(timeout).
Body(options).
Do().
Error()
}
// Patch applies the patch and returns the patched roleBinding.
func (c *roleBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.RoleBinding, err error) {
result = &v1alpha1.RoleBinding{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("rolebindings").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}
| {
"pile_set_name": "Github"
} |
<?php
/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return array_replace_recursive(require __DIR__.'/en.php', [
'meridiem' => ['Tesiran', 'Teipa'],
'weekdays' => ['Mderot ee are', 'Mderot ee kuni', 'Mderot ee ong’wan', 'Mderot ee inet', 'Mderot ee ile', 'Mderot ee sapa', 'Mderot ee kwe'],
'weekdays_short' => ['Are', 'Kun', 'Ong', 'Ine', 'Ile', 'Sap', 'Kwe'],
'weekdays_min' => ['Are', 'Kun', 'Ong', 'Ine', 'Ile', 'Sap', 'Kwe'],
'months' => ['Lapa le obo', 'Lapa le waare', 'Lapa le okuni', 'Lapa le ong’wan', 'Lapa le imet', 'Lapa le ile', 'Lapa le sapa', 'Lapa le isiet', 'Lapa le saal', 'Lapa le tomon', 'Lapa le tomon obo', 'Lapa le tomon waare'],
'months_short' => ['Obo', 'Waa', 'Oku', 'Ong', 'Ime', 'Ile', 'Sap', 'Isi', 'Saa', 'Tom', 'Tob', 'Tow'],
'formats' => [
'LT' => 'HH:mm',
'LTS' => 'HH:mm:ss',
'L' => 'DD/MM/YYYY',
'LL' => 'D MMM YYYY',
'LLL' => 'D MMMM YYYY HH:mm',
'LLLL' => 'dddd, D MMMM YYYY HH:mm',
],
]);
| {
"pile_set_name": "Github"
} |
eff6ef1bf28d085182756084b4ffbf00ce4fa6ce
| {
"pile_set_name": "Github"
} |
/* No comment provided by engineer. */
"Could not move to Applications folder" = "Не удалось переместить в папку «Программы»";
/* No comment provided by engineer. */
"Do Not Move" = "Не перемещать";
/* No comment provided by engineer. */
"I can move myself to the Applications folder if you'd like." = "Если хотите, я могу переместить себя в папку «Программы».";
/* No comment provided by engineer. */
"Move to Applications Folder" = "Переместить в папку «Программы»";
/* No comment provided by engineer. */
"Move to Applications folder in your Home folder?" = "Переместить в папку «Программы», расположенную в папке пользователя?";
/* No comment provided by engineer. */
"Move to Applications folder?" = "Переместить в папку «Программы»?";
/* No comment provided by engineer. */
"Note that this will require an administrator password." = "Вам понадобится пароль администратора.";
/* No comment provided by engineer. */
"This will keep your Downloads folder uncluttered." = "Это поможет содержать папку загрузок в порядке.";
| {
"pile_set_name": "Github"
} |
{
"name": "氣象法",
"status": "實施",
"content": [
{
"num": 1,
"zh": "第一條",
"article": "為加強氣象業務,健全測報制度,特制定本法;本法未規定者,依其他法律規定。",
"reason": "本條未修正。"
},
{
"num": 2,
"zh": "第二條",
"article": "本法所用名詞,定義如下:一、氣象業務:指從事氣象、地震、海象等現象之觀測、資料蒐集與研判結果之發布。二、氣象:指大氣諸現象。三、地震:指地層發生錯動或火山活動所引起地表振動及其相關現象。四、海象:指潮汐、波浪及其他存在於大氣與海洋交界面之自然現象。五、氣象改造:指運用科學技術從事改變天氣現象之行為。六、觀測:指對氣象、地震或海象等現象之觀察及測定。七、觀測站:指從事氣象、地震或海象等現象之觀測,於適當處所設置之觀測設施。八、觀測坪:指設置地面氣象觀測儀器之室外一定場所。九、探空儀追蹤器:指於氣象站建築物頂部設置追蹤天線,用以追蹤、接收以氣球為載具之探空儀收集觀測資料之觀測設施。十、氣象雷達天線:指於氣象雷達站建築物頂部設置之特定天線,用以發射並接收雷達電波之觀測設施。十一、繞極軌道氣象衛星追蹤天線:指於地面建築物頂部設置之特定天線,用以接收繞極軌道氣象衛星傳送偵照、遙測結果之觀測設施。十二、災害性天氣:指可能造成生命或財產損失之颱風、大雨、豪雨、雷電、冰雹、濃霧、龍捲風、強風、低溫、焚風、乾旱等天氣現象。十三、預報:指以觀測結果為基礎,發布氣象、地震或海象等現象所為之預測。十四、警報:指預測可能發生氣象、地震或海象災害而發布之警告性預報。十五、觀測儀器:指氣象業務觀測所使用器具。十六、專用觀測站:指機關、學校、團體或個人,為專供目的事業應用或本身學術研究之需要以從事定時觀測,而於適當處所設置觀測儀器,經中央氣象局認可之設施。",
"reason": "一、原條文第一款未修正,移列為第二款,另原條文第二款「氣象業務」酌作文字修正,並移列為第一款。二、增訂第三款「地震」之定義。三、由於本法制定之時,「潮汐」列為機密資料,故僅列「波浪」一詞,而未將「潮汐」納入;而目前「潮汐」資料業已解密,爰增訂第四款「海象」定義,並將其他如海水位、海溫、海流、海冰、湧流、暴潮及海嘯等存在於或可能發生於大氣與海洋交界面之自然現象予以概括納入。四、針對修正條文第六條中「氣象改造」一詞作定義性規範,並列為第五款。五、原第三款配合第二款之修正,酌作文字修正,並移列為第六款。六、針對修正條文第七條及第八條中「觀測站」一詞作定義性規範,並列為第七款。七、原第四款移列為第八款,並酌作文字修正。八、增訂第九款「探空儀追蹤器」、第十款「氣象雷達天線」、第十一款「繞極軌道氣象衛星追蹤天線」之定義。又因「氣象站」及「氣象雷達站」均為世界氣象組織(WMO)公用名詞,且現行實際作業亦是如此,爰依例引用。九、針對修正條文第十八條中「災害性天氣」一詞作定義性規範,並列為第十二款。十、原第五款「預報」一詞之定義,文字酌作修正,並移列為第十三款。十一、原第六款「警報」一詞之定義,文字酌作修正,並增列「地震或海象」文字,以包括整體氣象業務之內容,同時移列為第十四款。十二、原第八款修正為「觀測儀器」,並移列為第十五款。十三、原第七款「專用氣象觀測站」修正為「專用觀測站」,並作文字修正及移列為第十六款。"
},
{
"num": 3,
"zh": "第三條",
"article": "本法主管機關為交通部。氣象業務,由交通部中央氣象局辦理。",
"reason": "參考一般立法體例酌作文字修正。"
},
{
"num": 4,
"zh": "第四條",
"article": "為促進國際間氣象合作,交通部得本互惠原則,與外國氣象機關或機構簽訂氣象合作協定或交換氣象資料。前項業務,得委託民間團體辦理,且得代表政府與外國或國際氣象組織談判國際氣象業務或簽署有關協定;其協定事項,並應依相關法規規定辦理。",
"reason": "一、條次變更,本條為原條文第五條移列。二、由於國外氣象合作對象亦可能為政府機關之體制,為達到促進國際間氣象合作之需要,故增加外國氣象機關為合作對象。三、為能全面性參與國際間氣象事務,爰增訂第二項得委託民間團體以非正式管道,代表政府與外國或國際氣象組織從事國際氣象事務之談判或簽署有關協定。"
},
{
"num": 5,
"zh": "第五條",
"article": "中央氣象局因機關、學校、團體、個人研究或應用需要,得提供氣象、地震或海象等現象之資料,並得接受委託,提供氣象專業服務。",
"reason": "一、條次變更,本條為原條文第六條移列。二、配合修正條文第二條第一款「氣象業務」定義之修正,爰修正相關文字。"
},
{
"num": 6,
"zh": "第六條",
"article": "機關、學校、團體或個人進行氣象改造者,應先報交通部核准,交通部得派員監督。前項核准後,未實施或不接受監督者,交通部得廢止其核准。",
"reason": "一、條次變更,本條為原條文第八條移列。二、由於交通部中央氣象局組織條例第十二條已明確規定關於學術研究事項,得洽商國內外有關學術機關合作辦理,且其委託機關、學校辦理研究之事項,因不涉及公權力委託,無於本法規定之必要,爰將原條文第一項予以刪除。三、原條文第二項所訂「應」報交通部核准並派員監督,為法律上之強制規定。惟因核准為事前監督,對已核准進行氣象改造之事項,於執行中行政監督事項及方式之規範密度相對較低,為減少重複監督之行政資源浪費,爰修正對實施中改造行為之監督方式,由交通部依個案裁量決定。另因中央氣象局本身即為行政機關,無特別明列中央氣象局之必要,故刪除部分文字,並配合原條文第一項之刪除,移列為第一項。四、機關、學校、團體或個人經交通部核准進行氣象改造者,於核准後未實施或於進行中不接受監督者,為確保原計畫之目的及避免逾越計畫內容造成大氣環流改變,交通部得廢止核准。"
},
{
"num": 7,
"zh": "第七條",
"article": "中央氣象局得於全國重要地區選擇適當地點,設置觀測站,進行氣象、地震或海象等現象之觀測。",
"reason": "一、條次變更,本條為原條文第十條移列。二、配合修正條文第二條第一款「氣象業務」定義之修正,爰修正相關文字。三、由於交通部中央氣象局組織條例第十四條及交通部中央氣象局附屬氣象測報機構組織通則第三條已明定設立氣象測報機構之法源,故無規範之必要。惟因中央氣象局於必要觀測地點仍須設置無人之自動觀測站,爰將「設立氣象測報機構」修正為「設置觀測站」。四、由於觀測站僅作觀測及觀測資料之傳送,不經由人工通報,故將「測報」修正為「觀測」。"
},
{
"num": 8,
"zh": "第八條",
"article": "機關、學校、團體或個人得就其設置之觀測站,向中央氣象局申請認可為專用觀測站。前項專用觀測站認可之資格、條件、類別、觀測項目、觀測處所、儀器、觀測時間、觀測資料報備、輔導、訓練、申請程序、變更或廢止及其相關事項之辦法,由交通部定之。",
"reason": "一、條次變更,本條為原條文第十一條移列。二、現行條文明定機關、學校、團體或個人從事氣象、地震或海象觀測事務者,必須先經中央氣象局「許可」並發給登記證後,始得設立專用氣象觀測站進行觀測業務。茲為配合法規鬆綁政策,放寬為任何人不須經許可即可設立一般觀測站從事觀測。觀測站經申請中央氣象局認可後即為專用觀測站。三、經認可之專用觀測站所從事觀測人員、觀測環境及相關觀測設施等,具有配合世界氣象組織規範之技術性及專業性要求,故除由交通部統一編訂站號,以分配使用外,中央氣象局並得適時給予技術輔導、訓練及管理,以維持觀測資料之品質。又各專用觀測站,其觀測資料依中央氣象局規定之格式填報後,將統一建置氣候資料庫管理,供各界應用,以兼具維護資料品質及資源共享之意義。四、第二項明定授權法規之內容,以符合授權明確性之要求。其中「觀測時間」一詞係參照世界氣象組織規定,用以規範不同種類觀測站之每日觀測次數及指定觀測時點(例:綜觀氣象站每日應於世界標準時零、六、十二、十八時各觀測一次)。五、由於長時期收集之觀測資料方能製成氣候或相關資料,並具有代表性意義,為維持觀測資料之連續性及正確性,達到設站觀測之目的,專用觀測站之設立,各國均以永久設立為原則,因此,不需另訂認可期限。"
},
{
"num": 9,
"zh": "第九條",
"article": "專用觀測站及全國各氣象測報機構設置之觀測站,由交通部統一編訂站號,分配使用,並通告國內外氣象機關或機構。",
"reason": "一、條次變更,本條為原條文第十四條移列。二、鑑於本條所規範者為「觀測站」之登記管理,現行所列「氣象測報機構」並不明確,故修正以全國各氣象測報機構設置之觀測站為受統一編站對象,並酌作文字修正。三、由於國外氣象團體亦有由政府依機關體制建置者,為達到促進國際間氣象資料交換應用之需要,故增加國外氣象機關亦為通報之對象。"
},
{
"num": 10,
"zh": "第十條",
"article": "依船舶相關法律及法規命令規定裝置無線電設備之船舶,應依交通部規定裝置氣象儀器。前項船舶航行於我國專屬經濟海域時,須將氣象觀測資料及時提供中央氣象局。",
"reason": "一、條次變更,本條為原條文第十五條移列。二、船舶應裝置無線電設備列於船舶法第五十條第五款及船舶設備規則第六條第五款中規定,第一項爰修正為船舶相關法律及法規命令。三、為明確規範提供氣象及海象觀測資料之區域,爰將第二項「經交通部規定之區域」修正為「我國專屬經濟海域」。又因目前通報管道甚多,已無指定氣象收聽機構之必要,爰酌作修正。"
},
{
"num": 11,
"zh": "第十一條",
"article": "飛經臺北飛航情報區之國內外民用航空器,應按國際民航標準程序及交通部規定,向交通部民用航空局提供其飛行途中之氣象觀測資料。交通部民用航空局取得前項資料後,應立即傳送中央氣象局。",
"reason": "一、條次變更,本條為原條文第十六條移列。二、依國際飛航情報區劃分,將第一項「中華民國飛航情報區」修正為「臺北飛航情報區」,並酌作文字修正。三、有關飛經各飛航情報區之民用航空器駕駛員應作氣象觀測及報告,於國際民航公約附件六(Annex6)4.4.2、及臺北飛航情報區飛航指南航路1.8-1(4)、(5),已有明定。至觀測報告之格式,亦由國際民航組織會同世界氣象組織於國際民航公約附件三(Annex3)中明定。四、又依航空器飛航作業管理規則第七十三條規定「飛航中駕駛員製作氣象觀察及報告,應依飛航規則及相關規定所定之程序。」我國航空器亦負有氣象觀測及報告責任。五、由於目前國內尚無民用航空氣象機構,有關航空氣象業務亦僅由民用航空局航空氣象站掌理,故配合實務現況,修正為飛經臺北飛航情報區之國內外民用航空器,需向交通部民用航空局提供其飛行途中之氣象觀測資料。六、為期觀測資料之管理及利用,爰增定第二項明定交通部民用航空局取得第一項觀測資料後,應立即傳送中央氣象局,由中央氣象列入氣象資料庫管理。"
},
{
"num": 12,
"zh": "第十二條",
"article": "中央氣象局對前二條規定之船舶及航空器氣象觀測人員,得予技術指導。",
"reason": "條次變更,本條為原條文第十七條移列,並酌作體例修正。"
},
{
"num": 13,
"zh": "第十三條",
"article": "中央氣象局為確保地面氣象觀測之準確及遙測資料之完整性,就所屬探空儀追蹤器、氣象雷達天線或繞極軌道氣象衛星追蹤天線等氣象觀測設施或觀測坪周圍之土地,於必要限度內,得劃定禁止或限制建築之一定範圍,報請交通部會商內政部及有關機關後核定,由直轄市、縣 (市) 政府公告之。依前項規定公告禁止或限制建築之範圍、高度、公告程序、解除禁止或限制及其補償等相關事項之辦法,由交通部會同內政部定之。",
"reason": "一、條次變更,本條為原條文第十八條移列。二、由於現行使用之氣象設備及名稱,已隨科技進步變更,為配合於實際作業需求,爰修正第一項部分專有名詞;另為明確規範主體,酌作文字修正。三、又基於憲法第十五條人民財產權之保障,因公益目的須限制人民私權時,應以必要限度內為限,如尚有他種方式可達目的,即應選擇對人民損害最小之方式為之,故第一項增加「於必要限度內」之限制條件。四、第一項後段限制建築之公告程序,參考民用航空法第三十二條立法例修正。五、原第一項後段酌作文字修正並移列第二項,同時增列授權訂定限制建築辦法之內容、目的、範圍,以符授權明確性之要求。"
},
{
"num": 14,
"zh": "第十四條",
"article": "中央氣象局從事氣象、地震或海象之觀測人員,為執行觀測業務,必須進入私有土地或公有之土地或水面或他人之建築物時,應會同當地村(里)長並出示證明文件,其所有人、使用人或現住人不得拒絕、規避或妨礙。前項須進入他人之建築物時,應於三日前通知所有人、使用人或現住人。",
"reason": "一、條次變更,本條為原條文第十九條移列。二、配合修正條文第二條第一款「氣象業務」定義之修正,修正相關文字。三、氣象觀測之目的係為公眾利益,觀測人員基於觀測上之需要,必須進入私有或公有之土地或水面或他人之建築物時,該所有人、使用人或現住人應負有特別之容忍義務,為避免以其他間接之方法拒絕進入或阻礙觀測,爰於第一項增列不得以規避或妨礙等間接方式拒絕進入之規定。四、由於建築物管理使用之隱私權保護之要求比土地或水面高,為明確表示進入他人土地或水面與建築物觀測之情形不同,爰將原條文後段移列第二項,並限定應於三日前通知該建築物之所有人、使用人或現住人。"
},
{
"num": 15,
"zh": "第十五條",
"article": "中央氣象局從事氣象、地震或海象觀測遇有障礙物,於必要時,應通知所有人或占有人於三十日內自行拆除或遷移之;無法通知或屆期不為拆除、遷移者,得逕為拆除。",
"reason": "一、條次變更,本條為原條文第二十條移列。二、配合修正條文第二條第一款「氣象業務」定義之修正,修正相關文字。三、為減少對人民財產權使用之限制,明定必要時始得拆除或遷移。並對觀測障礙物之排除方式,除採拆除之方式外,另增加遷移至不影響觀測處所之方式,俾得選擇以對人民損害較輕之方式為之。四、又明定三十日以內之拆遷時間,俾當事人有充裕之準備或應變。如屆期仍不為拆除或遷移時,為使觀測能順利進行,中央氣象局得逕為拆除。五、另為明確本條之規範主體,酌作文字修正。"
},
{
"num": 16,
"zh": "第十六條",
"article": "依前二條規定進入公、私有土地、建築物或拆除、遷移障礙物致他人受有損失者,應予相當補償。前項補償金額,由中央氣象局與受補償人依協議為之。",
"reason": "一、條次變更,本條為原條文第二十一條移列。二、配合修正條文第十五條,增加進入建築物及遷移障礙物之補償。三、為明確規範對個別損失補償金額之決定方式,爰增訂第二項明定以協議為之,協議得於事前或事後與受補償人為之,協議不成時,則得以其他救濟方式為之。"
},
{
"num": 17,
"zh": "第十七條",
"article": "全國氣象、地震或海象等現象之預報或警報,由中央氣象局統一發布。但軍事或交通部民用航空局建制之氣象單位,因軍事或飛航安全需求對特定對象所發布,或依第十八條第一項規定許可發布者,不在此限。前項預報或警報之種類、內容、發布或解除及傳播程序事項之辦法,由交通部定之。",
"reason": "一、條次變更,本條為原條文第二十二條移列。二、配合修正條文第二條第一款「氣象業務」定義之修正,修正相關文字。三、有關民用航空氣象業務係為飛航安全特定需要之特殊氣象業務,其預報、警報發布之對象限於民用航空機構。而目前係由交通部民用航空局建制之氣象單位掌理,爰於第一項但書增列交通部民用航空局建制之氣象單位,以符實務現況。又依修正條文第十八條第一項經許可發布者,其於許可範圍內亦為本條統一發布之除外範圍,爰予明定。四、為因應軍事或民用航空上所必要之事項涉及國家安全及飛航安全,得以其特別需要為例外。故第一項明定軍事或交通部民用航空局建制之氣象單位,因軍事或飛航安全需求所發布之氣象資料,不需經由統一發布程序。但為符合特別需要之目的,渠等發布仍應以對該軍事或民用航空需求之特定對象所發布者為限。五、因現行國軍及交通部民用航空局之氣象單位,於組織體制上為行政機關之內部單位,爰修正為軍事或民用航空建制之氣象單位。六、第二項明定授權法規之發布種類、內容、發布或解除及傳播程序等事項,以符合授權明確性之要求。"
},
{
"num": 18,
"zh": "第十八條",
"article": "機關、學校、團體或個人經中央氣象局許可者,得發布氣象或海象之預報。但不得發布警報或災害性天氣之預報。為前項發布時,應註明發布者之名稱全銜或姓名。第一項發布氣象或海象預報之許可條件、許可期間、內容、程序、廢止條件、廢止許可及其相關事項之辦法,由交通部定之。",
"reason": "一、本條新增。二、為期民間力量共同投入氣象事業及配合法規鬆綁,現行預報業務除警報與災害性天氣及地震之預報外,其他一般性氣象預報業務開放得由民間從事,以促進氣象產業發展,爰增訂本條。三、鑑於地震因其突發性、短暫性,使其預測難度高於氣象及海象,以目前科技技術,尚難準確預測地震發生之時間、地點、範圍及強度等;且因地震之破壞力強大,如得以任意發布地震預測,易引起人心恐慌,嚴重影響社會公序。又氣象、地震或海象之警報,係為保護人民免受災變侵害所作出之緊急通知,該等警報所發布之破壞力預測如達一定程度,國家為保護人民生命、財產安全,尚可能據以實施公權力強制疏散、遷移,如得以任意發布恐將使人心惶動,影響社會秩序,故宜經統一發布程序發布,另災害天氣預報係對可能造成生命財產嚴重損害之天氣所作之預測,其影響社會經濟活動及人民權益甚巨,為維護安定之社會秩序,不宜開放由民間任意發布,故不在許可之範圍。四、為釐清氣象或海象預報資訊之來源,爰於第二項明定發布氣象或海象預報時,應註明發布者全銜。五、為符授權明確性原則,於第三項明定授權訂定得發布氣象或海象許可條件、內容、程序及廢止許可等事項之辦法,期使發布氣象或海象之機關、學校、團體或個人所提供之氣象資訊,符合一定水準。"
},
{
"num": 19,
"zh": "第十九條",
"article": "新聞傳播機構對中央氣象局發布之氣象、地震或海象之預報或警報,均應適時據實廣為傳播;如有錯誤,經中央氣象局通知後,應立即更正。",
"reason": "一、條次變更,本條為原條文第二十三條移列。二、配合修正條文第二條第一款「氣象業務」定義之修正,修正相關文字。三、鑑於本條立法原意,在基於鼓勵新聞傳播機構能適時據實廣為傳播中央氣象局所發布之氣象、地震或海象預報或警報,故對其播報內容有錯誤時,經中央氣象局通知後,應主動立即更正,如不予更正,則依廣播電視法第二十三條規定加以處理。"
},
{
"num": 20,
"zh": "第二十條",
"article": "專用觀測站設置一定類別之觀測儀器,應向中央氣象局或經國家認證體系認證之實驗室或在國際上與我國相互承認認證許可國所認證許可之實驗室,申請校驗合格後,方得使用。各專用觀測站設置經校驗合格之觀測儀器,應按校驗週期,向中央氣象局或經國家認證體系認證之實驗室或在國際上與我國相互承認認證許可國所認證許可之實驗室,申請校驗。違反前二項規定,使用未經申請校驗或未依校驗週期申請校驗或校驗不合格之觀測儀器者,中央氣象局應命其停止使用並限期改善;其不停止使用或屆期不改善者,廢止其認可。第一項及第二項所稱經國家認證體系認證之實驗室,指經濟部標準檢驗局所推動體系認證許可者。第一項及第二項應經校驗之觀測儀器類別,由中央氣象局定之。前項觀測儀器之校驗週期、申請校驗程序、校驗基準及其他校驗程序相關事項之辦法,由交通部會同經濟部定之。",
"reason": "一、條次變更,本條為原條文第二十五條移列。二、為促進民間參與觀測儀器校驗,以發展氣象業務,及因應我國加入WTO後國際情勢之需要,爰放寬第一項觀測儀器之種類及校驗單位,並酌作文字修正。又本條規範對象為專用觀測站所使用之觀測儀器。而設置及使用經校驗合格之觀測儀器為專用觀測站認可條件之一,如於專用觀測站申請認可時已存在之觀測儀器,未經校驗合格者,依修正條文第八條規定,得不予認可。於認可後始設置之觀測儀器,未經校驗合格前不得使用,如有違反,得廢止認可。三、為配合專用觀測站之設立修正為認可制,爰於第二項明定於認可後,應依校驗週期申請校驗。四、為避免觀測資料失準,俾維持觀測資料之準確度及正確性,對於使用未經申請校驗或未依校驗週期申請校驗或校驗不合格之觀測儀器,中央氣象局應命其停止使用並通知限期改善,對於不停止使用或屆期不改善者,得廢止認可。五、為明確界定第一項及第二項「經國家認證體系認證之實驗室」係以經濟部標準檢驗局所推動體系認證許可者為範圍,爰於第四項加以明定。六、由於科技發展迅速,為符合氣象儀器類別分類需要,爰刪除原條文所列舉各款觀測儀器類別,而於第五項授權由中央氣象局依氣象科技之發展及環境變更規定。七、為符合授權明確性原則,爰將原條文第二十六條後段酌作文字修正,增列授權訂定觀測儀器校驗辦法之內容,以符授權明確原則,並移列第六項。"
},
{
"num": 21,
"zh": "第二十一條",
"article": "機關、學校、團體或個人,從事氣象業務,著有績效者,中央氣象局得依職權或依申請,報請交通部獎勵或表揚。前項獎勵或表揚之申請程序、條件、種類、方式、評定等相關事項之辦法,由交通部定之。",
"reason": "一、條次變更,本條為原條文第二十七條移列。二、為鼓勵參與氣象業務研究,放寬獎勵對象為從事氣象業務者,不以受中央氣象局委託研究者為限。三、為符合授權明確性原則,增訂第二項明定授權訂定獎勵或表揚之申請程序、條件、種類、方式、評定等相關事項之辦法。"
},
{
"num": 22,
"zh": "第二十二條",
"article": "機關、學校、團體或個人違反第六條第一項規定,未經核准進行氣象改造者,交通部應命其立即停止或限期採取必要更正措施;其拒不停止或屆期未改正者,處新臺幣十萬元以上五十萬元以下罰鍰,並得按次連續處罰。",
"reason": "一、本條新增。二、為免過度或不當之氣象改造影響自然環境之穩定,於第六條第一項明定應事前核准,違反該強制規定者應即予以適當裁罰,以保護自然環境。"
},
{
"num": 23,
"zh": "第二十三條",
"article": "違反第十四條第一項規定,拒絕、規避或妨礙觀測人員進入者,處新臺幣二萬元以上十萬元以下罰鍰,並得按次連續處罰。",
"reason": "一、本條新增。二、為規範違反第十四條第一項規定者之處罰,爰增訂本條。"
},
{
"num": 24,
"zh": "第二十四條",
"article": "機關、學校、團體或個人違反第十八條第一項規定,未經許可或逾越許可範圍擅自發布氣象或海象預報者,中央氣象局應命其停止,並限期改善;其拒不停止或屆期不改善者,處新臺幣十萬元以上五十萬元以下罰鍰;並得按次連續處罰。情節重大者,並得廢止其許可。機關、學校、團體或個人違反第十八條第一項規定,擅自發布地震、災害性天氣之預報或氣象、地震或海象警報者,中央氣象局應命其停止,並限期改善;其拒不停止或屆期不改善者,處新臺幣二十萬元以上一百萬元以下罰鍰;並得按次連續處罰。情節重大者,得廢止其許可。違反第十九條規定,對警報、災害性天氣預報、地震預報報導錯誤,經中央氣象局通知更正而不立即更正者,得處新臺幣十萬元以上五十萬元以下罰鍰;並得連續處罰。",
"reason": "一、條次變更,本條為原條文第二十九條移列。二、鑑於氣象或海象預報之發布,除經許可之範圍外,應經統一發布程序發布,對於未經許可或逾越許可範圍擅自發布氣象或海象預報之行為,應加以處罰,爰於第一項規定之。三、又警報或地震、災害性天氣之預報,影響人民生活甚鉅,應由中央氣象局統一發布,對於學校、團體或個人擅自發布警報或地震、災害性天氣之預報者,有加重其處罰之必要,爰於第二項加以規定。四、罰鍰之貨幣單位增訂以新臺幣為單位,並酌量提高罰鍰金額。五、新聞傳播機構對警報、災害性天氣預報、地震預報,應適時據實廣為傳播,如有錯誤,經通知更正而不立即更正者,因鑑於警報、災害性天氣預報、地震預報對人民生命財產安全有重大影響,為積極維護人民生命財產安全,爰增訂第三項處罰規定。"
},
{
"num": 25,
"zh": "第二十五條",
"article": "依第二十二條及前條規定,處機關、學校或團體罰鍰者,對各該行為人並處以各該條所定之罰鍰。",
"reason": "一、本條新增。二、第二十二條規範內容為排除不當氣象改造之行為,以維護自然環境。故機關、學校、團體所用於實施氣象改造之行為人,為實際實施氣象改造行為之人,應併受處罰,又第二十四條規範之目的,為排除不當發布氣象預報或警報之行為。故機關、學校、團體及實際實施發布氣象預報或警報之行為人,亦應併受同一處罰,爰增訂本條。"
},
{
"num": 26,
"zh": "第二十六條",
"article": "本法所定之罰鍰,除第二十二條規定者外,由中央氣象局處罰。依本法所處之罰鍰,經限期繳納,屆期仍不繳納者,依法移送強制執行。",
"reason": "一、條次變更,本條為原條文第三十二條移列。二、配合行政執行法之施行,酌作文字修正。"
},
{
"num": 27,
"zh": "第二十七條",
"article": "擅自占用、損壞或移動氣象觀測用地或設施或有妨害其效用之行為者,除涉及刑責依法移送偵辦外,應負損害賠償責任,並回復損害發生前之原狀。",
"reason": "一、條次變更,本條為原條文第二十八條移列。二、侵害他人財產權者應負回復原狀及損害賠償責任,原條文對擅自占用、損壞或移動氣象觀測用地或設施或有妨害其效用者,所生損害賠償及回復原狀責任,由中央氣象局或專用觀測站負有通知行為人回復原狀之責任,與一般侵權行為責任相違,為明確本條立法原意係規範行為人負有對受損設備之損害賠償及回復損害發生前原狀之義務,爰加以修正。"
},
{
"num": 28,
"zh": "第二十八條",
"article": "軍事建制之氣象機構,除第九條及第十七條規定者外,不適用本法規定。",
"reason": "條次變更,本條為原條文第三十三條移列,並酌作文字修正。"
},
{
"num": 29,
"zh": "第二十九條",
"article": "本法未規定事項,涉及國際事務者,交通部得參照有關國際公約或協定及其附約所定規則、規程、辦法、標準、建議或程序,採用施行。",
"reason": "條次變更,本條為原條文第三十四條移列,並酌作文字修正。"
},
{
"num": 30,
"zh": "第三十條",
"article": "中央氣象局依本法提供氣象資料、儀器校驗、氣象專業服務或發給證照,得收取費用。前項費用之種類及費額,由交通部定之。",
"reason": "一、條次變更,本條為原條文第三十五條移列。二、原條文前段酌作文字修正,移列為第一項;後段依立法體例酌作文字修正,改列為第二項。"
},
{
"num": 31,
"zh": "第三十一條",
"article": "本法自公布日施行。",
"reason": "條次變更,本條為原條文第三十六條移列,內容未修正。"
},
{
"num": 32,
"zh": "第三十二條",
"article": "本法所定處罰,由中央氣象局為之,其罰鍰經通知而逾期不繳納者,得移送法院強制執行。"
},
{
"num": 33,
"zh": "第三十三條",
"article": "軍事建制之氣象機構,除第十四條規定外,不適用本法規定。"
},
{
"num": 34,
"zh": "第三十四條",
"article": "本法未規定事項,涉及國際事務者,交通部得參照有關國際公約或協定及其附約所定規則、規程、辦法、標準、建議或程序,採用發布施行。"
},
{
"num": 35,
"zh": "第三十五條",
"article": "中央氣象局,依本法提供氣象資料、儀器校驗、氣象專業服務或發給證照,得徵收費用,其費額由交通部定之。"
},
{
"num": 36,
"zh": "第三十六條",
"article": "本法自公布日施行。"
}
]
} | {
"pile_set_name": "Github"
} |
/*
* OpenClinica is distributed under the
* GNU Lesser General Public License (GNU LGPL).
* For details see: http://www.openclinica.org/license
* copyright 2003-2011 Akaza Research
*/
package org.akaza.openclinica.control.form.spreadsheet;
/**
* For CRF SpreadSheet uploading validation
*
*/
//ywang (Aug. 2011)
public interface SpreadSheetValidator {
public SheetErrors getSheetErrors();
public void validate();
}
| {
"pile_set_name": "Github"
} |
/*********************************************************************
* RPC for the Windows NT Operating System
* 1993 by Martin F. Gergeleit
* Users may use, copy or modify Sun RPC for the Windows NT Operating
* System according to the Sun copyright below.
*
* RPC for the Windows NT Operating System COMES WITH ABSOLUTELY NO
* WARRANTY, NOR WILL I BE LIABLE FOR ANY DAMAGES INCURRED FROM THE
* USE OF. USE ENTIRELY AT YOUR OWN RISK!!!
*********************************************************************/
/* @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
* program developed by the user.
*
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
*
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
*
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* OR ANY PART THEREOF.
*
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
*
* Sun Microsystems, Inc.
* 2550 Garcia Avenue
* Mountain View, California 94043
*/
/* @(#)xdr.h 1.19 87/04/22 SMI */
/*
* xdr.h, External Data Representation Serialization Routines.
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
#ifndef __XDR_HEADER__
#define __XDR_HEADER__
/*
* XDR provides a conventional way for converting between C data
* types and an external bit-string representation. Library supplied
* routines provide for the conversion on built-in C data types. These
* routines and utility routines defined here are used to help implement
* a type encode/decode routine for each user-defined type.
*
* Each data type provides a single procedure which takes two arguments:
*
* bool_t
* xdrproc(xdrs, argresp)
* XDR *xdrs;
* <type> *argresp;
*
* xdrs is an instance of a XDR handle, to which or from which the data
* type is to be converted. argresp is a pointer to the structure to be
* converted. The XDR handle contains an operation field which indicates
* which of the operations (ENCODE, DECODE * or FREE) is to be performed.
*
* XDR_DECODE may allocate space if the pointer argresp is null. This
* data can be freed with the XDR_FREE operation.
*
* We write only one procedure per data type to make it easy
* to keep the encode and decode procedures for a data type consistent.
* In many cases the same code performs all operations on a user defined type,
* because all the hard work is done in the component type routines.
* decode as a series of calls on the nested data types.
*/
/*
* Xdr operations. XDR_ENCODE causes the type to be encoded into the
* stream. XDR_DECODE causes the type to be extracted from the stream.
* XDR_FREE can be used to release the space allocated by an XDR_DECODE
* request.
*/
enum xdr_op {
XDR_ENCODE=0,
XDR_DECODE=1,
XDR_FREE=2
};
/*
* This is the number of bytes per unit of external data.
*/
#define BYTES_PER_XDR_UNIT (4)
#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \
* BYTES_PER_XDR_UNIT)
/*
* A xdrproc_t exists for each data type which is to be encoded or decoded.
*
* The second argument to the xdrproc_t is a pointer to an opaque pointer.
* The opaque pointer generally points to a structure of the data type
* to be decoded. If this pointer is 0, then the type routines should
* allocate dynamic storage of the appropriate size and return it.
* bool_t (*xdrproc_t)(XDR *, caddr_t *);
*/
typedef bool_t (*xdrproc_t)();
/*
* The XDR handle.
* Contains operation which is being applied to the stream,
* an operations vector for the paticular implementation (e.g. see xdr_mem.c),
* and two private fields for the use of the particular impelementation.
*/
typedef struct {
enum xdr_op x_op; /* operation; fast additional param */
struct xdr_ops {
bool_t (*x_getlong)(); /* get a long from underlying stream */
bool_t (*x_putlong)(); /* put a long to " */
bool_t (*x_getbytes)();/* get some bytes from " */
bool_t (*x_putbytes)();/* put some bytes to " */
u_int (*x_getpostn)();/* returns bytes off from beginning */
bool_t (*x_setpostn)();/* lets you reposition the stream */
long * (*x_inline)(); /* buf quick ptr to buffered data */
void (*x_destroy)(); /* free privates of this xdr_stream */
} *x_ops;
caddr_t x_public; /* users' data */
caddr_t x_private; /* pointer to private data */
caddr_t x_base; /* private used for position info */
int x_handy; /* extra private word */
} XDR;
/*
* Operations defined on a XDR handle
*
* XDR *xdrs;
* long *longp;
* caddr_t addr;
* u_int len;
* u_int pos;
*/
#define XDR_GETLONG(xdrs, longp) \
(*(xdrs)->x_ops->x_getlong)(xdrs, longp)
#define xdr_getlong(xdrs, longp) \
(*(xdrs)->x_ops->x_getlong)(xdrs, longp)
#define XDR_PUTLONG(xdrs, longp) \
(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
#define xdr_putlong(xdrs, longp) \
(*(xdrs)->x_ops->x_putlong)(xdrs, longp)
#define XDR_GETBYTES(xdrs, addr, len) \
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
#define xdr_getbytes(xdrs, addr, len) \
(*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
#define XDR_PUTBYTES(xdrs, addr, len) \
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
#define xdr_putbytes(xdrs, addr, len) \
(*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
#define XDR_GETPOS(xdrs) \
(*(xdrs)->x_ops->x_getpostn)(xdrs)
#define xdr_getpos(xdrs) \
(*(xdrs)->x_ops->x_getpostn)(xdrs)
#define XDR_SETPOS(xdrs, pos) \
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
#define xdr_setpos(xdrs, pos) \
(*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
#define XDR_INLINE(xdrs, len) \
(*(xdrs)->x_ops->x_inline)(xdrs, len)
#define xdr_inline(xdrs, len) \
(*(xdrs)->x_ops->x_inline)(xdrs, len)
#define XDR_DESTROY(xdrs) \
if ((xdrs)->x_ops->x_destroy) \
(*(xdrs)->x_ops->x_destroy)(xdrs)
#define xdr_destroy(xdrs) \
if ((xdrs)->x_ops->x_destroy) \
(*(xdrs)->x_ops->x_destroy)(xdrs)
/*
* Support struct for discriminated unions.
* You create an array of xdrdiscrim structures, terminated with
* a entry with a null procedure pointer. The xdr_union routine gets
* the discriminant value and then searches the array of structures
* for a matching value. If a match is found the associated xdr routine
* is called to handle that part of the union. If there is
* no match, then a default routine may be called.
* If there is no match and no default routine it is an error.
*/
#define NULL_xdrproc_t ((xdrproc_t)0)
struct xdr_discrim {
int value;
xdrproc_t proc;
};
/*
* In-line routines for fast encode/decode of primitve data types.
* Caveat emptor: these use single memory cycles to get the
* data from the underlying buffer, and will fail to operate
* properly if the data is not aligned. The standard way to use these
* is to say:
* if ((buf = XDR_INLINE(xdrs, count)) == NULL)
* return (FALSE);
* <<< macro calls >>>
* where ``count'' is the number of bytes of data occupied
* by the primitive data types.
*
* N.B. and frozen for all time: each data type here uses 4 bytes
* of external representation.
*/
#ifdef UNUSED
#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++))
#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v))
#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf))
#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf))
#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf))
#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf))
#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf))
#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
#endif
/*
* These are the "generic" xdr routines.
*/
extern bool_t xdr_void();
extern bool_t xdr_int();
extern bool_t xdr_u_int();
extern bool_t xdr_long();
extern bool_t xdr_u_long();
extern bool_t xdr_short();
extern bool_t xdr_u_short();
extern bool_t xdr_bool();
extern bool_t xdr_enum();
extern bool_t xdr_array();
extern bool_t xdr_bytes();
extern bool_t xdr_opaque();
extern bool_t xdr_string();
extern bool_t xdr_union();
extern bool_t xdr_char();
extern bool_t xdr_u_char();
extern bool_t xdr_vector();
extern bool_t xdr_float();
extern bool_t xdr_double();
extern bool_t xdr_reference();
extern bool_t xdr_pointer();
extern bool_t xdr_wrapstring();
/*
* Common opaque bytes objects used by many rpc protocols;
* declared here due to commonality.
*/
#define MAX_NETOBJ_SZ 1024
struct netobj {
u_int n_len;
char *n_bytes;
};
typedef struct netobj netobj;
extern bool_t xdr_netobj();
/*
* These are the public routines for the various implementations of
* xdr streams.
*/
extern void xdrmem_create(); /* XDR using memory buffers */
extern void xdrstdio_create(); /* XDR using stdio library */
extern void xdrrec_create(); /* XDR pseudo records for tcp */
extern bool_t xdrrec_endofrecord(); /* make end of xdr record */
extern bool_t xdrrec_skiprecord(); /* move to beginning of next record */
extern bool_t xdrrec_eof(); /* true if no more input */
#endif /* __XDR_HEADER__ */
| {
"pile_set_name": "Github"
} |
/* $OpenBSD: fmemopentest.c,v 1.4 2020/08/17 16:17:39 millert Exp $ */
/*
* Copyright (c) 2011 Martin Pieuchot <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int
simpletest(void)
{
FILE *s1, *s2;
char string[] = "fmemopen test string!";
char buffer[1024], *buf = NULL;
size_t len;
int c, failures = 0;
s1 = fmemopen(string, strlen(string) + 1, "r");
if (s1 == NULL) {
warn("unable to open a stream s1");
return (1);
}
s2 = fmemopen(buf, 22, "w+");
if (s2 == NULL) {
warn("unable to create a stream s2");
fclose(s1);
return (1);
}
while ((c = fgetc(s1)) != EOF)
fputc(c, s2);
if (ftell(s2) != strlen(string) + 1) {
warnx("failed copy test (1)");
failures++;
}
fclose(s1);
fseek(s2, 0, SEEK_SET);
if (ftell(s2) != 0) {
warnx("failed seek test (2)");
failures++;
}
len = fread(buffer, 1, sizeof(buffer) - 1, s2);
if (len != strlen(string) + 1) {
warnx("failed read test (3) %zu != %zu",
len, strlen(string) + 1);
failures++;
}
return (failures);
}
int
appendtest(const char *mode)
{
FILE *s1;
char string[] = "hello\0 test number 2";
char buffer[256];
size_t len;
int failures = 0;
s1 = fmemopen(string, 19, mode);
if (s1 == NULL)
return (1);
fseek(s1, 0, SEEK_SET);
if (ftell(s1) != 0) {
warnx("failed seek test [%s] (4)", mode);
failures++;
}
/* write should append even though seek position is 0 */
len = fwrite(" world", 1, 6, s1);
if (len != 6) {
warnx("failed write test [%s] (5)", mode);
failures++;
}
if (ftell(s1) != strlen("hello world")) {
warnx("failed seek test [%s] (6)", mode);
failures++;
}
if (mode[1] == '+') {
fseek(s1, 0, SEEK_SET);
len = fread(buffer, 1, sizeof(buffer) - 1, s1);
if (len == 0 || strncmp(string, buffer, len)) {
warnx("failed compare test [%s] (7)", mode);
failures++;
}
}
if (strcmp(string, "hello world")) {
warnx("failed compare test [%s] (8)", mode);
failures++;
}
if (strcmp(string + strlen(string) + 1, "number 2")) {
warnx("failed compare test [%s] (9)", mode);
failures++;
}
return (failures);
}
int
updatetest(void)
{
FILE *s1;
char string[] = "bah, what a day";
char buffer[256];
size_t len;
int failures = 0;
s1 = fmemopen(string, 19, "r+");
if (s1 == NULL)
return (1);
if (ftell(s1) != 0) {
warnx("failed seek test (10)");
failures++;
}
len = fwrite("oh frabjous", 1, 11, s1);
if (len != 11) {
warnx("failed write test (11)");
failures++;
}
fseek(s1, 0, SEEK_SET);
len = fread(buffer, 1, sizeof(buffer) - 1, s1);
if (len == 0 || strncmp(string, buffer, len)) {
warnx("failed compare test (12)");
failures++;
}
if (strcmp(string, "oh frabjous day")) {
warnx("failed compare test (13)");
failures++;
}
return (failures);
}
int
writetest(const char *mode)
{
FILE *s1;
char string[] = "super test number 3";
char buffer[256];
size_t len, slen;
int failures = 0;
slen = strlen(string) + 1;
s1 = fmemopen(string, slen, mode);
if (s1 == NULL)
return (1);
len = fwrite("short", 1, 5, s1);
if (len != strlen("short")) {
warnx("failed write test [%s] (14)", mode);
failures++;
}
fclose(s1);
s1 = fmemopen(string, slen, "r");
if (s1 == NULL) {
warnx("failed open test [%s] (15)", mode);
failures++;
}
len = fread(buffer, 1, sizeof(buffer) - 1, s1);
if (len == 0 || strncmp(string, buffer, len)) {
warnx("failed compare test [%s] (16)", mode);
failures++;
}
if (strcmp(string, "short")) {
warnx("failed compare test [%s] (17)", mode);
failures++;
}
if (strcmp(string + strlen(string) + 1, "test number 3")) {
warnx("failed compare test [%s] (18)", mode);
failures++;
}
return (failures);
}
int
seektest(void)
{
FILE *s1;
char string[] = "long string for testing seek";
size_t len, slen;
int failures = 0;
slen = strlen(string) + 1;
s1 = fmemopen(string, slen, "r");
if (s1 == NULL)
return (1);
if (fseek(s1, 8, SEEK_SET) != 0) {
warnx("failed to fseek. (19)");
failures++;
}
if (ftell(s1) != 8) {
warnx("failed seek test. (20)");
failures++;
}
/* Try to seek backward */
if (fseek(s1, -1, SEEK_CUR) != 0) {
warnx("failed to fseek. (21)");
failures++;
}
if (ftell(s1) != 7) {
warnx("failed seeking backward. (22)");
failures++;
}
return (failures);
}
int
main(void)
{
int failures = 0;
failures += simpletest();
failures += appendtest("a");
failures += appendtest("a+");
failures += updatetest();
failures += writetest("w");
failures += writetest("w+");
failures += seektest();
return (failures);
}
| {
"pile_set_name": "Github"
} |
/*!
* @license
* Copyright 2019 Alfresco, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityState, createEntityAdapter } from '@ngrx/entity';
import { Connector, ConnectorContent } from '../api/types';
export interface ConnectorEntitiesState extends EntityState<Connector> {
loading: boolean;
loaded: boolean;
entityContents: {[key: string]: ConnectorContent};
}
export const connectorEntityAdapter = createEntityAdapter<Connector>();
export const initialConnectorEntitiesState = connectorEntityAdapter.getInitialState<ConnectorEntitiesState>({
...connectorEntityAdapter.getInitialState(),
loading: false,
loaded: false,
entityContents: {}
});
| {
"pile_set_name": "Github"
} |
<template>
<li>
<a href="#" @click.stop.prevent="$emit('clickByEvent')">
<img :src="item.profileImageUrl" style="max-width:30px;border-radius:30px;float:left;" />
<div class="menu-info" style="margin-left:45px;">
<h4 class="control-sidebar-subheading" style="font-size:16px;">
<span style="font-weight:600;">
{{item.fullName}}
</span>
<slot></slot>
<br />
<small>{{timestamp}}</small>
</h4>
</div>
</a>
</li>
</template>
<script>
import moment from 'moment';
export default {
props: ['item'],
methods: { },
computed: {
timestamp: function() {
return Moment.utc(this.item.createdAt).fromNow();
}
},
mounted() { }
};
</script>
<style lang="sass">
.comment-message {
padding: 9px 11px;
background-color: #fff;
border-radius: 3px;
box-shadow: 0 1px 2px rgba(0,0,0,.23);
-moz-box-sizing: border-box;
box-sizing: border-box;
clear: both;
cursor: pointer;
display: inline-block;
margin: 6px 2px 6px 0;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}
</style>
| {
"pile_set_name": "Github"
} |
// Copyright 2013 the V8 project authors. All rights reserved.
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
description(
"A chunk of our port of PCRE's test suite, adapted to be more applicable to JavaScript."
);
var regex0 = /a.b/;
var input0 = "acb";
var results = ["acb"];
shouldBe('regex0.exec(input0);', 'results');
var input1 = "a\x7fb";
var results = ["a\u007fb"];
shouldBe('regex0.exec(input1);', 'results');
var input2 = "a\u0100b";
var results = ["a\u0100b"];
shouldBe('regex0.exec(input2);', 'results');
// Failers
var input3 = "a\nb";
var results = null;
shouldBe('regex0.exec(input3);', 'results');
var regex1 = /a(.{3})b/;
var input0 = "a\u4000xyb";
var results = ["a\u4000xyb", "\u4000xy"];
shouldBe('regex1.exec(input0);', 'results');
var input1 = "a\u4000\x7fyb";
var results = ["a\u4000\u007fyb", "\u4000\u007fy"];
shouldBe('regex1.exec(input1);', 'results');
var input2 = "a\u4000\u0100yb";
var results = ["a\u4000\u0100yb", "\u4000\u0100y"];
shouldBe('regex1.exec(input2);', 'results');
// Failers
var input3 = "a\u4000b";
var results = null;
shouldBe('regex1.exec(input3);', 'results');
var input4 = "ac\ncb";
var results = null;
shouldBe('regex1.exec(input4);', 'results');
var regex2 = /a(.*?)(.)/;
var input0 = "a\xc0\x88b";
var results = ["a\xc0", "", "\xc0"];
shouldBe('regex2.exec(input0);', 'results');
var regex3 = /a(.*?)(.)/;
var input0 = "a\u0100b";
var results = ["a\u0100", "", "\u0100"];
shouldBe('regex3.exec(input0);', 'results');
var regex4 = /a(.*)(.)/;
var input0 = "a\xc0\x88b";
var results = ["a\xc0\x88b", "\xc0\x88", "b"];
shouldBe('regex4.exec(input0);', 'results');
var regex5 = /a(.*)(.)/;
var input0 = "a\u0100b";
var results = ["a\u0100b", "\u0100", "b"];
shouldBe('regex5.exec(input0);', 'results');
var regex6 = /a(.)(.)/;
var input0 = "a\xc0\x92bcd";
var results = ["a\xc0\x92", "\xc0", "\x92"];
shouldBe('regex6.exec(input0);', 'results');
var regex7 = /a(.)(.)/;
var input0 = "a\u0240bcd";
var results = ["a\u0240b", "\u0240", "b"];
shouldBe('regex7.exec(input0);', 'results');
var regex8 = /a(.?)(.)/;
var input0 = "a\xc0\x92bcd";
var results = ["a\xc0\x92", "\xc0", "\x92"];
shouldBe('regex8.exec(input0);', 'results');
var regex9 = /a(.?)(.)/;
var input0 = "a\u0240bcd";
var results = ["a\u0240b", "\u0240", "b"];
shouldBe('regex9.exec(input0);', 'results');
var regex10 = /a(.??)(.)/;
var input0 = "a\xc0\x92bcd";
var results = ["a\xc0", "", "\xc0"];
shouldBe('regex10.exec(input0);', 'results');
var regex11 = /a(.??)(.)/;
var input0 = "a\u0240bcd";
var results = ["a\u0240", "", "\u0240"];
shouldBe('regex11.exec(input0);', 'results');
var regex12 = /a(.{3})b/;
var input0 = "a\u1234xyb";
var results = ["a\u1234xyb", "\u1234xy"];
shouldBe('regex12.exec(input0);', 'results');
var input1 = "a\u1234\u4321yb";
var results = ["a\u1234\u4321yb", "\u1234\u4321y"];
shouldBe('regex12.exec(input1);', 'results');
var input2 = "a\u1234\u4321\u3412b";
var results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"];
shouldBe('regex12.exec(input2);', 'results');
// Failers
var input3 = "a\u1234b";
var results = null;
shouldBe('regex12.exec(input3);', 'results');
var input4 = "ac\ncb";
var results = null;
shouldBe('regex12.exec(input4);', 'results');
var regex13 = /a(.{3,})b/;
var input0 = "a\u1234xyb";
var results = ["a\u1234xyb", "\u1234xy"];
shouldBe('regex13.exec(input0);', 'results');
var input1 = "a\u1234\u4321yb";
var results = ["a\u1234\u4321yb", "\u1234\u4321y"];
shouldBe('regex13.exec(input1);', 'results');
var input2 = "a\u1234\u4321\u3412b";
var results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"];
shouldBe('regex13.exec(input2);', 'results');
var input3 = "axxxxbcdefghijb";
var results = ["axxxxbcdefghijb", "xxxxbcdefghij"];
shouldBe('regex13.exec(input3);', 'results');
var input4 = "a\u1234\u4321\u3412\u3421b";
var results = ["a\u1234\u4321\u3412\u3421b", "\u1234\u4321\u3412\u3421"];
shouldBe('regex13.exec(input4);', 'results');
// Failers
var input5 = "a\u1234b";
var results = null;
shouldBe('regex13.exec(input5);', 'results');
var regex14 = /a(.{3,}?)b/;
var input0 = "a\u1234xyb";
var results = ["a\u1234xyb", "\u1234xy"];
shouldBe('regex14.exec(input0);', 'results');
var input1 = "a\u1234\u4321yb";
var results = ["a\u1234\u4321yb", "\u1234\u4321y"];
shouldBe('regex14.exec(input1);', 'results');
var input2 = "a\u1234\u4321\u3412b";
var results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"];
shouldBe('regex14.exec(input2);', 'results');
var input3 = "axxxxbcdefghijb";
var results = ["axxxxb", "xxxx"];
shouldBe('regex14.exec(input3);', 'results');
var input4 = "a\u1234\u4321\u3412\u3421b";
var results = ["a\u1234\u4321\u3412\u3421b", "\u1234\u4321\u3412\u3421"];
shouldBe('regex14.exec(input4);', 'results');
// Failers
var input5 = "a\u1234b";
var results = null;
shouldBe('regex14.exec(input5);', 'results');
var regex15 = /a(.{3,5})b/;
var input0 = "a\u1234xyb";
var results = ["a\u1234xyb", "\u1234xy"];
shouldBe('regex15.exec(input0);', 'results');
var input1 = "a\u1234\u4321yb";
var results = ["a\u1234\u4321yb", "\u1234\u4321y"];
shouldBe('regex15.exec(input1);', 'results');
var input2 = "a\u1234\u4321\u3412b";
var results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"];
shouldBe('regex15.exec(input2);', 'results');
var input3 = "axxxxbcdefghijb";
var results = ["axxxxb", "xxxx"];
shouldBe('regex15.exec(input3);', 'results');
var input4 = "a\u1234\u4321\u3412\u3421b";
var results = ["a\u1234\u4321\u3412\u3421b", "\u1234\u4321\u3412\u3421"];
shouldBe('regex15.exec(input4);', 'results');
var input5 = "axbxxbcdefghijb";
var results = ["axbxxb", "xbxx"];
shouldBe('regex15.exec(input5);', 'results');
var input6 = "axxxxxbcdefghijb";
var results = ["axxxxxb", "xxxxx"];
shouldBe('regex15.exec(input6);', 'results');
// Failers
var input7 = "a\u1234b";
var results = null;
shouldBe('regex15.exec(input7);', 'results');
var input8 = "axxxxxxbcdefghijb";
var results = null;
shouldBe('regex15.exec(input8);', 'results');
var regex16 = /a(.{3,5}?)b/;
var input0 = "a\u1234xyb";
var results = ["a\u1234xyb", "\u1234xy"];
shouldBe('regex16.exec(input0);', 'results');
var input1 = "a\u1234\u4321yb";
var results = ["a\u1234\u4321yb", "\u1234\u4321y"];
shouldBe('regex16.exec(input1);', 'results');
var input2 = "a\u1234\u4321\u3412b";
var results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"];
shouldBe('regex16.exec(input2);', 'results');
var input3 = "axxxxbcdefghijb";
var results = ["axxxxb", "xxxx"];
shouldBe('regex16.exec(input3);', 'results');
var input4 = "a\u1234\u4321\u3412\u3421b";
var results = ["a\u1234\u4321\u3412\u3421b", "\u1234\u4321\u3412\u3421"];
shouldBe('regex16.exec(input4);', 'results');
var input5 = "axbxxbcdefghijb";
var results = ["axbxxb", "xbxx"];
shouldBe('regex16.exec(input5);', 'results');
var input6 = "axxxxxbcdefghijb";
var results = ["axxxxxb", "xxxxx"];
shouldBe('regex16.exec(input6);', 'results');
// Failers
var input7 = "a\u1234b";
var results = null;
shouldBe('regex16.exec(input7);', 'results');
var input8 = "axxxxxxbcdefghijb";
var results = null;
shouldBe('regex16.exec(input8);', 'results');
var regex17 = /^[a\u00c0]/;
// Failers
var input0 = "\u0100";
var results = null;
shouldBe('regex17.exec(input0);', 'results');
var regex21 = /(?:\u0100){3}b/;
var input0 = "\u0100\u0100\u0100b";
var results = ["\u0100\u0100\u0100b"];
shouldBe('regex21.exec(input0);', 'results');
// Failers
var input1 = "\u0100\u0100b";
var results = null;
shouldBe('regex21.exec(input1);', 'results');
var regex22 = /\u00ab/;
var input0 = "\u00ab";
var results = ["\u00ab"];
shouldBe('regex22.exec(input0);', 'results');
var input1 = "\xc2\xab";
var results = ["\u00ab"];
shouldBe('regex22.exec(input1);', 'results');
// Failers
var input2 = "\x00{ab}";
var results = null;
shouldBe('regex22.exec(input2);', 'results');
var regex30 = /^[^a]{2}/;
var input0 = "\u0100bc";
var results = ["\u0100b"];
shouldBe('regex30.exec(input0);', 'results');
var regex31 = /^[^a]{2,}/;
var input0 = "\u0100bcAa";
var results = ["\u0100bcA"];
shouldBe('regex31.exec(input0);', 'results');
var regex32 = /^[^a]{2,}?/;
var input0 = "\u0100bca";
var results = ["\u0100b"];
shouldBe('regex32.exec(input0);', 'results');
var regex33 = /^[^a]{2}/i;
var input0 = "\u0100bc";
var results = ["\u0100b"];
shouldBe('regex33.exec(input0);', 'results');
var regex34 = /^[^a]{2,}/i;
var input0 = "\u0100bcAa";
var results = ["\u0100bc"];
shouldBe('regex34.exec(input0);', 'results');
var regex35 = /^[^a]{2,}?/i;
var input0 = "\u0100bca";
var results = ["\u0100b"];
shouldBe('regex35.exec(input0);', 'results');
var regex36 = /\u0100{0,0}/;
var input0 = "abcd";
var results = [""];
shouldBe('regex36.exec(input0);', 'results');
var regex37 = /\u0100?/;
var input0 = "abcd";
var results = [""];
shouldBe('regex37.exec(input0);', 'results');
var input1 = "\u0100\u0100";
var results = ["\u0100"];
shouldBe('regex37.exec(input1);', 'results');
var regex38 = /\u0100{0,3}/;
var input0 = "\u0100\u0100";
var results = ["\u0100\u0100"];
shouldBe('regex38.exec(input0);', 'results');
var input1 = "\u0100\u0100\u0100\u0100";
var results = ["\u0100\u0100\u0100"];
shouldBe('regex38.exec(input1);', 'results');
var regex39 = /\u0100*/;
var input0 = "abce";
var results = [""];
shouldBe('regex39.exec(input0);', 'results');
var input1 = "\u0100\u0100\u0100\u0100";
var results = ["\u0100\u0100\u0100\u0100"];
shouldBe('regex39.exec(input1);', 'results');
var regex40 = /\u0100{1,1}/;
var input0 = "abcd\u0100\u0100\u0100\u0100";
var results = ["\u0100"];
shouldBe('regex40.exec(input0);', 'results');
var regex41 = /\u0100{1,3}/;
var input0 = "abcd\u0100\u0100\u0100\u0100";
var results = ["\u0100\u0100\u0100"];
shouldBe('regex41.exec(input0);', 'results');
var regex42 = /\u0100+/;
var input0 = "abcd\u0100\u0100\u0100\u0100";
var results = ["\u0100\u0100\u0100\u0100"];
shouldBe('regex42.exec(input0);', 'results');
var regex43 = /\u0100{3}/;
var input0 = "abcd\u0100\u0100\u0100XX";
var results = ["\u0100\u0100\u0100"];
shouldBe('regex43.exec(input0);', 'results');
var regex44 = /\u0100{3,5}/;
var input0 = "abcd\u0100\u0100\u0100\u0100\u0100\u0100\u0100XX";
var results = ["\u0100\u0100\u0100\u0100\u0100"];
shouldBe('regex44.exec(input0);', 'results');
var regex45 = /\u0100{3,}/;
var input0 = "abcd\u0100\u0100\u0100\u0100\u0100\u0100\u0100XX";
var results = ["\u0100\u0100\u0100\u0100\u0100\u0100\u0100"];
shouldBe('regex45.exec(input0);', 'results');
var regex47 = /\D*/;
var input0 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
var results = ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"];
shouldBe('regex47.exec(input0);', 'results');
var regex48 = /\D*/;
var input0 = "\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100";
var results = ["\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100"];
shouldBe('regex48.exec(input0);', 'results');
var regex49 = /\D/;
var input0 = "1X2";
var results = ["X"];
shouldBe('regex49.exec(input0);', 'results');
var input1 = "1\u01002";
var results = ["\u0100"];
shouldBe('regex49.exec(input1);', 'results');
var regex50 = />\S/;
var input0 = "> >X Y";
var results = [">X"];
shouldBe('regex50.exec(input0);', 'results');
var input1 = "> >\u0100 Y";
var results = [">\u0100"];
shouldBe('regex50.exec(input1);', 'results');
var regex51 = /\d/;
var input0 = "\u01003";
var results = ["3"];
shouldBe('regex51.exec(input0);', 'results');
var regex52 = /\s/;
var input0 = "\u0100 X";
var results = [" "];
shouldBe('regex52.exec(input0);', 'results');
var regex53 = /\D+/;
var input0 = "12abcd34";
var results = ["abcd"];
shouldBe('regex53.exec(input0);', 'results');
// Failers
var input1 = "1234";
var results = null;
shouldBe('regex53.exec(input1);', 'results');
var regex54 = /\D{2,3}/;
var input0 = "12abcd34";
var results = ["abc"];
shouldBe('regex54.exec(input0);', 'results');
var input1 = "12ab34";
var results = ["ab"];
shouldBe('regex54.exec(input1);', 'results');
// Failers
var input2 = "1234";
var results = null;
shouldBe('regex54.exec(input2);', 'results');
var input3 = "12a34";
var results = null;
shouldBe('regex54.exec(input3);', 'results');
var regex55 = /\D{2,3}?/;
var input0 = "12abcd34";
var results = ["ab"];
shouldBe('regex55.exec(input0);', 'results');
var input1 = "12ab34";
var results = ["ab"];
shouldBe('regex55.exec(input1);', 'results');
// Failers
var input2 = "1234";
var results = null;
shouldBe('regex55.exec(input2);', 'results');
var input3 = "12a34";
var results = null;
shouldBe('regex55.exec(input3);', 'results');
var regex56 = /\d+/;
var input0 = "12abcd34";
var results = ["12"];
shouldBe('regex56.exec(input0);', 'results');
var regex57 = /\d{2,3}/;
var input0 = "12abcd34";
var results = ["12"];
shouldBe('regex57.exec(input0);', 'results');
var input1 = "1234abcd";
var results = ["123"];
shouldBe('regex57.exec(input1);', 'results');
// Failers
var input2 = "1.4";
var results = null;
shouldBe('regex57.exec(input2);', 'results');
var regex58 = /\d{2,3}?/;
var input0 = "12abcd34";
var results = ["12"];
shouldBe('regex58.exec(input0);', 'results');
var input1 = "1234abcd";
var results = ["12"];
shouldBe('regex58.exec(input1);', 'results');
// Failers
var input2 = "1.4";
var results = null;
shouldBe('regex58.exec(input2);', 'results');
var regex59 = /\S+/;
var input0 = "12abcd34";
var results = ["12abcd34"];
shouldBe('regex59.exec(input0);', 'results');
// Failers
var input1 = " ";
var results = null;
shouldBe('regex59.exec(input1);', 'results');
var regex60 = /\S{2,3}/;
var input0 = "12abcd34";
var results = ["12a"];
shouldBe('regex60.exec(input0);', 'results');
var input1 = "1234abcd";
var results = ["123"];
shouldBe('regex60.exec(input1);', 'results');
// Failers
var input2 = " ";
var results = null;
shouldBe('regex60.exec(input2);', 'results');
var regex61 = /\S{2,3}?/;
var input0 = "12abcd34";
var results = ["12"];
shouldBe('regex61.exec(input0);', 'results');
var input1 = "1234abcd";
var results = ["12"];
shouldBe('regex61.exec(input1);', 'results');
// Failers
var input2 = " ";
var results = null;
shouldBe('regex61.exec(input2);', 'results');
var regex62 = />\s+</;
var input0 = "12> <34";
var results = ["> <"];
shouldBe('regex62.exec(input0);', 'results');
var regex63 = />\s{2,3}</;
var input0 = "ab> <cd";
var results = ["> <"];
shouldBe('regex63.exec(input0);', 'results');
var input1 = "ab> <ce";
var results = ["> <"];
shouldBe('regex63.exec(input1);', 'results');
// Failers
var input2 = "ab> <cd";
var results = null;
shouldBe('regex63.exec(input2);', 'results');
var regex64 = />\s{2,3}?</;
var input0 = "ab> <cd";
var results = ["> <"];
shouldBe('regex64.exec(input0);', 'results');
var input1 = "ab> <ce";
var results = ["> <"];
shouldBe('regex64.exec(input1);', 'results');
// Failers
var input2 = "ab> <cd";
var results = null;
shouldBe('regex64.exec(input2);', 'results');
var regex65 = /\w+/;
var input0 = "12 34";
var results = ["12"];
shouldBe('regex65.exec(input0);', 'results');
// Failers
var input1 = "+++=*!";
var results = null;
shouldBe('regex65.exec(input1);', 'results');
var regex66 = /\w{2,3}/;
var input0 = "ab cd";
var results = ["ab"];
shouldBe('regex66.exec(input0);', 'results');
var input1 = "abcd ce";
var results = ["abc"];
shouldBe('regex66.exec(input1);', 'results');
// Failers
var input2 = "a.b.c";
var results = null;
shouldBe('regex66.exec(input2);', 'results');
var regex67 = /\w{2,3}?/;
var input0 = "ab cd";
var results = ["ab"];
shouldBe('regex67.exec(input0);', 'results');
var input1 = "abcd ce";
var results = ["ab"];
shouldBe('regex67.exec(input1);', 'results');
// Failers
var input2 = "a.b.c";
var results = null;
shouldBe('regex67.exec(input2);', 'results');
var regex68 = /\W+/;
var input0 = "12====34";
var results = ["===="];
shouldBe('regex68.exec(input0);', 'results');
// Failers
var input1 = "abcd";
var results = null;
shouldBe('regex68.exec(input1);', 'results');
var regex69 = /\W{2,3}/;
var input0 = "ab====cd";
var results = ["==="];
shouldBe('regex69.exec(input0);', 'results');
var input1 = "ab==cd";
var results = ["=="];
shouldBe('regex69.exec(input1);', 'results');
// Failers
var input2 = "a.b.c";
var results = null;
shouldBe('regex69.exec(input2);', 'results');
var regex70 = /\W{2,3}?/;
var input0 = "ab====cd";
var results = ["=="];
shouldBe('regex70.exec(input0);', 'results');
var input1 = "ab==cd";
var results = ["=="];
shouldBe('regex70.exec(input1);', 'results');
// Failers
var input2 = "a.b.c";
var results = null;
shouldBe('regex70.exec(input2);', 'results');
var regex71 = /[\u0100]/;
var input0 = "\u0100";
var results = ["\u0100"];
shouldBe('regex71.exec(input0);', 'results');
var input1 = "Z\u0100";
var results = ["\u0100"];
shouldBe('regex71.exec(input1);', 'results');
var input2 = "\u0100Z";
var results = ["\u0100"];
shouldBe('regex71.exec(input2);', 'results');
var regex72 = /[Z\u0100]/;
var input0 = "Z\u0100";
var results = ["Z"];
shouldBe('regex72.exec(input0);', 'results');
var input1 = "\u0100";
var results = ["\u0100"];
shouldBe('regex72.exec(input1);', 'results');
var input2 = "\u0100Z";
var results = ["\u0100"];
shouldBe('regex72.exec(input2);', 'results');
var regex73 = /[\u0100\u0200]/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex73.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex73.exec(input1);', 'results');
var regex74 = /[\u0100-\u0200]/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex74.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex74.exec(input1);', 'results');
var input2 = "ab\u0111cd";
var results = ["\u0111"];
shouldBe('regex74.exec(input2);', 'results');
var regex75 = /[z-\u0200]/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex75.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex75.exec(input1);', 'results');
var input2 = "ab\u0111cd";
var results = ["\u0111"];
shouldBe('regex75.exec(input2);', 'results');
var input3 = "abzcd";
var results = ["z"];
shouldBe('regex75.exec(input3);', 'results');
var input4 = "ab|cd";
var results = ["|"];
shouldBe('regex75.exec(input4);', 'results');
var regex76 = /[Q\u0100\u0200]/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex76.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex76.exec(input1);', 'results');
var input2 = "Q?";
var results = ["Q"];
shouldBe('regex76.exec(input2);', 'results');
var regex77 = /[Q\u0100-\u0200]/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex77.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex77.exec(input1);', 'results');
var input2 = "ab\u0111cd";
var results = ["\u0111"];
shouldBe('regex77.exec(input2);', 'results');
var input3 = "Q?";
var results = ["Q"];
shouldBe('regex77.exec(input3);', 'results');
var regex78 = /[Qz-\u0200]/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex78.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex78.exec(input1);', 'results');
var input2 = "ab\u0111cd";
var results = ["\u0111"];
shouldBe('regex78.exec(input2);', 'results');
var input3 = "abzcd";
var results = ["z"];
shouldBe('regex78.exec(input3);', 'results');
var input4 = "ab|cd";
var results = ["|"];
shouldBe('regex78.exec(input4);', 'results');
var input5 = "Q?";
var results = ["Q"];
shouldBe('regex78.exec(input5);', 'results');
var regex79 = /[\u0100\u0200]{1,3}/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex79.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex79.exec(input1);', 'results');
var input2 = "ab\u0200\u0100\u0200\u0100cd";
var results = ["\u0200\u0100\u0200"];
shouldBe('regex79.exec(input2);', 'results');
var regex80 = /[\u0100\u0200]{1,3}?/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex80.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex80.exec(input1);', 'results');
var input2 = "ab\u0200\u0100\u0200\u0100cd";
var results = ["\u0200"];
shouldBe('regex80.exec(input2);', 'results');
var regex81 = /[Q\u0100\u0200]{1,3}/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex81.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex81.exec(input1);', 'results');
var input2 = "ab\u0200\u0100\u0200\u0100cd";
var results = ["\u0200\u0100\u0200"];
shouldBe('regex81.exec(input2);', 'results');
var regex82 = /[Q\u0100\u0200]{1,3}?/;
var input0 = "ab\u0100cd";
var results = ["\u0100"];
shouldBe('regex82.exec(input0);', 'results');
var input1 = "ab\u0200cd";
var results = ["\u0200"];
shouldBe('regex82.exec(input1);', 'results');
var input2 = "ab\u0200\u0100\u0200\u0100cd";
var results = ["\u0200"];
shouldBe('regex82.exec(input2);', 'results');
var regex86 = /[^\u0100\u0200]X/;
var input0 = "AX";
var results = ["AX"];
shouldBe('regex86.exec(input0);', 'results');
var input1 = "\u0150X";
var results = ["\u0150X"];
shouldBe('regex86.exec(input1);', 'results');
var input2 = "\u0500X";
var results = ["\u0500X"];
shouldBe('regex86.exec(input2);', 'results');
// Failers
var input3 = "\u0100X";
var results = null;
shouldBe('regex86.exec(input3);', 'results');
var input4 = "\u0200X";
var results = null;
shouldBe('regex86.exec(input4);', 'results');
var regex87 = /[^Q\u0100\u0200]X/;
var input0 = "AX";
var results = ["AX"];
shouldBe('regex87.exec(input0);', 'results');
var input1 = "\u0150X";
var results = ["\u0150X"];
shouldBe('regex87.exec(input1);', 'results');
var input2 = "\u0500X";
var results = ["\u0500X"];
shouldBe('regex87.exec(input2);', 'results');
// Failers
var input3 = "\u0100X";
var results = null;
shouldBe('regex87.exec(input3);', 'results');
var input4 = "\u0200X";
var results = null;
shouldBe('regex87.exec(input4);', 'results');
var input5 = "QX";
var results = null;
shouldBe('regex87.exec(input5);', 'results');
var regex88 = /[^\u0100-\u0200]X/;
var input0 = "AX";
var results = ["AX"];
shouldBe('regex88.exec(input0);', 'results');
var input1 = "\u0500X";
var results = ["\u0500X"];
shouldBe('regex88.exec(input1);', 'results');
// Failers
var input2 = "\u0100X";
var results = null;
shouldBe('regex88.exec(input2);', 'results');
var input3 = "\u0150X";
var results = null;
shouldBe('regex88.exec(input3);', 'results');
var input4 = "\u0200X";
var results = null;
shouldBe('regex88.exec(input4);', 'results');
var regex91 = /[z-\u0100]/i;
var input0 = "z";
var results = ["z"];
shouldBe('regex91.exec(input0);', 'results');
var input1 = "Z";
var results = ["Z"];
shouldBe('regex91.exec(input1);', 'results');
var input2 = "\u0100";
var results = ["\u0100"];
shouldBe('regex91.exec(input2);', 'results');
// Failers
var input3 = "\u0102";
var results = null;
shouldBe('regex91.exec(input3);', 'results');
var input4 = "y";
var results = null;
shouldBe('regex91.exec(input4);', 'results');
var regex92 = /[\xFF]/;
var input0 = ">\xff<";
var results = ["\xff"];
shouldBe('regex92.exec(input0);', 'results');
var regex93 = /[\xff]/;
var input0 = ">\u00ff<";
var results = ["\u00ff"];
shouldBe('regex93.exec(input0);', 'results');
var regex94 = /[^\xFF]/;
var input0 = "XYZ";
var results = ["X"];
shouldBe('regex94.exec(input0);', 'results');
var regex95 = /[^\xff]/;
var input0 = "XYZ";
var results = ["X"];
shouldBe('regex95.exec(input0);', 'results');
var input1 = "\u0123";
var results = ["\u0123"];
shouldBe('regex95.exec(input1);', 'results');
var regex96 = /^[ac]*b/;
var input0 = "xb";
var results = null;
shouldBe('regex96.exec(input0);', 'results');
var regex97 = /^[ac\u0100]*b/;
var input0 = "xb";
var results = null;
shouldBe('regex97.exec(input0);', 'results');
var regex98 = /^[^x]*b/i;
var input0 = "xb";
var results = null;
shouldBe('regex98.exec(input0);', 'results');
var regex99 = /^[^x]*b/;
var input0 = "xb";
var results = null;
shouldBe('regex99.exec(input0);', 'results');
var regex100 = /^\d*b/;
var input0 = "xb";
var results = null;
shouldBe('regex100.exec(input0);', 'results');
var regex102 = /^\u0085$/i;
var input0 = "\u0085";
var results = ["\u0085"];
shouldBe('regex102.exec(input0);', 'results');
var regex103 = /^\xe1\x88\xb4/;
var input0 = "\xe1\x88\xb4";
var results = ["\xe1\x88\xb4"];
shouldBe('regex103.exec(input0);', 'results');
var regex104 = /^\xe1\x88\xb4/;
var input0 = "\xe1\x88\xb4";
var results = ["\xe1\x88\xb4"];
shouldBe('regex104.exec(input0);', 'results');
var regex105 = /(.{1,5})/;
var input0 = "abcdefg";
var results = ["abcde", "abcde"];
shouldBe('regex105.exec(input0);', 'results');
var input1 = "ab";
var results = ["ab", "ab"];
shouldBe('regex105.exec(input1);', 'results');
var regex106 = /a*\u0100*\w/;
var input0 = "a";
var results = ["a"];
shouldBe('regex106.exec(input0);', 'results');
var regex107 = /[\S\s]*/;
var input0 = "abc\n\r\u0442\u0435\u0441\u0442xyz";
var results = ["abc\u000a\u000d\u0442\u0435\u0441\u0442xyz"];
shouldBe('regex107.exec(input0);', 'results');
var regexGlobal0 = /[^a]+/g;
var input0 = "bcd";
var results = ["bcd"];
shouldBe('input0.match(regexGlobal0);', 'results');
var input1 = "\u0100aY\u0256Z";
var results = ["\u0100", "Y\u0256Z"];
shouldBe('input1.match(regexGlobal0);', 'results');
var regexGlobal1 = /\S\S/g;
var input0 = "A\u00a3BC";
var results = ["A\u00a3", "BC"];
shouldBe('input0.match(regexGlobal1);', 'results');
var regexGlobal2 = /\S{2}/g;
var input0 = "A\u00a3BC";
var results = ["A\u00a3", "BC"];
shouldBe('input0.match(regexGlobal2);', 'results');
var regexGlobal3 = /\W\W/g;
var input0 = "+\u00a3==";
var results = ["+\u00a3", "=="];
shouldBe('input0.match(regexGlobal3);', 'results');
var regexGlobal4 = /\W{2}/g;
var input0 = "+\u00a3==";
var results = ["+\u00a3", "=="];
shouldBe('input0.match(regexGlobal4);', 'results');
var regexGlobal5 = /\S/g;
var input0 = "\u0442\u0435\u0441\u0442";
var results = ["\u0442", "\u0435", "\u0441", "\u0442"];
shouldBe('input0.match(regexGlobal5);', 'results');
var regexGlobal6 = /[\S]/g;
var input0 = "\u0442\u0435\u0441\u0442";
var results = ["\u0442", "\u0435", "\u0441", "\u0442"];
shouldBe('input0.match(regexGlobal6);', 'results');
var regexGlobal7 = /\D/g;
var input0 = "\u0442\u0435\u0441\u0442";
var results = ["\u0442", "\u0435", "\u0441", "\u0442"];
shouldBe('input0.match(regexGlobal7);', 'results');
var regexGlobal8 = /[\D]/g;
var input0 = "\u0442\u0435\u0441\u0442";
var results = ["\u0442", "\u0435", "\u0441", "\u0442"];
shouldBe('input0.match(regexGlobal8);', 'results');
var regexGlobal9 = /\W/g;
var input0 = "\u2442\u2435\u2441\u2442";
var results = ["\u2442", "\u2435", "\u2441", "\u2442"];
shouldBe('input0.match(regexGlobal9);', 'results');
var regexGlobal10 = /[\W]/g;
var input0 = "\u2442\u2435\u2441\u2442";
var results = ["\u2442", "\u2435", "\u2441", "\u2442"];
shouldBe('input0.match(regexGlobal10);', 'results');
var regexGlobal11 = /[\u041f\S]/g;
var input0 = "\u0442\u0435\u0441\u0442";
var results = ["\u0442", "\u0435", "\u0441", "\u0442"];
shouldBe('input0.match(regexGlobal11);', 'results');
var regexGlobal12 = /.[^\S]./g;
var input0 = "abc def\u0442\u0443xyz\npqr";
var results = ["c d", "z\u000ap"];
shouldBe('input0.match(regexGlobal12);', 'results');
var regexGlobal13 = /.[^\S\n]./g;
var input0 = "abc def\u0442\u0443xyz\npqr";
var results = ["c d"];
shouldBe('input0.match(regexGlobal13);', 'results');
var regexGlobal14 = /[\W]/g;
var input0 = "+\u2442";
var results = ["+", "\u2442"];
shouldBe('input0.match(regexGlobal14);', 'results');
var regexGlobal15 = /[^a-zA-Z]/g;
var input0 = "+\u2442";
var results = ["+", "\u2442"];
shouldBe('input0.match(regexGlobal15);', 'results');
var regexGlobal16 = /[^a-zA-Z]/g;
var input0 = "A\u0442";
var results = ["\u0442"];
shouldBe('input0.match(regexGlobal16);', 'results');
var regexGlobal17 = /[\S]/g;
var input0 = "A\u0442";
var results = ["A", "\u0442"];
shouldBe('input0.match(regexGlobal17);', 'results');
var regexGlobal19 = /[\D]/g;
var input0 = "A\u0442";
var results = ["A", "\u0442"];
shouldBe('input0.match(regexGlobal19);', 'results');
var regexGlobal21 = /[^a-z]/g;
var input0 = "A\u0422";
var results = ["A", "\u0422"];
shouldBe('input0.match(regexGlobal21);', 'results');
var regexGlobal24 = /[\S]/g;
var input0 = "A\u0442";
var results = ["A", "\u0442"];
shouldBe('input0.match(regexGlobal24);', 'results');
var regexGlobal25 = /[^A-Z]/g;
var input0 = "a\u0442";
var results = ["a", "\u0442"];
shouldBe('input0.match(regexGlobal25);', 'results');
var regexGlobal26 = /[\W]/g;
var input0 = "+\u2442";
var results = ["+", "\u2442"];
shouldBe('input0.match(regexGlobal26);', 'results');
var regexGlobal27 = /[\D]/g;
var input0 = "M\u0442";
var results = ["M", "\u0442"];
shouldBe('input0.match(regexGlobal27);', 'results');
var regexGlobal28 = /[^a]+/ig;
var input0 = "bcd";
var results = ["bcd"];
shouldBe('input0.match(regexGlobal28);', 'results');
var input1 = "\u0100aY\u0256Z";
var results = ["\u0100", "Y\u0256Z"];
shouldBe('input1.match(regexGlobal28);', 'results');
var regexGlobal29 = /(a|)/g;
var input0 = "catac";
var results = ["", "a", "", "a", "", ""];
shouldBe('input0.match(regexGlobal29);', 'results');
var input1 = "a\u0256a";
var results = ["a", "", "a", ""];
shouldBe('input1.match(regexGlobal29);', 'results');
// DISABLED:
// These tests use (?<) or (?>) constructs. These are not currently valid in ECMAScript,
// but these tests may be useful if similar constructs are introduced in the future.
//var regex18 = /(?<=aXb)cd/;
//var input0 = "aXbcd";
//var results = ["cd"];
//shouldBe('regex18.exec(input0);', 'results');
//
//var regex19 = /(?<=a\u0100b)cd/;
//var input0 = "a\u0100bcd";
//var results = ["cd"];
//shouldBe('regex19.exec(input0);', 'results');
//
//var regex20 = /(?<=a\u100000b)cd/;
//var input0 = "a\u100000bcd";
//var results = ["cd"];
//shouldBe('regex20.exec(input0);', 'results');
//
//var regex23 = /(?<=(.))X/;
//var input0 = "WXYZ";
//var results = ["X", "W"];
//shouldBe('regex23.exec(input0);', 'results');
//var input1 = "\u0256XYZ";
//var results = ["X", "\u0256"];
//shouldBe('regex23.exec(input1);', 'results');
//// Failers
//var input2 = "XYZ";
//var results = null;
//shouldBe('regex23.exec(input2);', 'results');
//
//var regex46 = /(?<=a\u0100{2}b)X/;
//var input0 = "Xyyya\u0100\u0100bXzzz";
//var results = ["X"];
//shouldBe('regex46.exec(input0);', 'results');
//
//var regex83 = /(?<=[\u0100\u0200])X/;
//var input0 = "abc\u0200X";
//var results = ["X"];
//shouldBe('regex83.exec(input0);', 'results');
//var input1 = "abc\u0100X";
//var results = ["X"];
//shouldBe('regex83.exec(input1);', 'results');
//// Failers
//var input2 = "X";
//var results = null;
//shouldBe('regex83.exec(input2);', 'results');
//
//var regex84 = /(?<=[Q\u0100\u0200])X/;
//var input0 = "abc\u0200X";
//var results = ["X"];
//shouldBe('regex84.exec(input0);', 'results');
//var input1 = "abc\u0100X";
//var results = ["X"];
//shouldBe('regex84.exec(input1);', 'results');
//var input2 = "abQX";
//var results = ["X"];
//shouldBe('regex84.exec(input2);', 'results');
//// Failers
//var input3 = "X";
//var results = null;
//shouldBe('regex84.exec(input3);', 'results');
//
//var regex85 = /(?<=[\u0100\u0200]{3})X/;
//var input0 = "abc\u0100\u0200\u0100X";
//var results = ["X"];
//shouldBe('regex85.exec(input0);', 'results');
//// Failers
//var input1 = "abc\u0200X";
//var results = null;
//shouldBe('regex85.exec(input1);', 'results');
//var input2 = "X";
//var results = null;
//shouldBe('regex85.exec(input2);', 'results');
// DISABLED:
// These tests use PCRE's \C token. This is not currently valid in ECMAScript,
// but these tests may be useful if similar constructs are introduced in the future.
//var regex24 = /X(\C{3})/;
//var input0 = "X\u1234";
//var results = ["X\u1234", "\u1234"];
//shouldBe('regex24.exec(input0);', 'results');
//
//var regex25 = /X(\C{4})/;
//var input0 = "X\u1234YZ";
//var results = ["X\u1234Y", "\u1234Y"];
//shouldBe('regex25.exec(input0);', 'results');
//
//var regex26 = /X\C*/;
//var input0 = "XYZabcdce";
//var results = ["XYZabcdce"];
//shouldBe('regex26.exec(input0);', 'results');
//
//var regex27 = /X\C*?/;
//var input0 = "XYZabcde";
//var results = ["X"];
//shouldBe('regex27.exec(input0);', 'results');
//
//var regex28 = /X\C{3,5}/;
//var input0 = "Xabcdefg";
//var results = ["Xabcde"];
//shouldBe('regex28.exec(input0);', 'results');
//var input1 = "X\u1234";
//var results = ["X\u1234"];
//shouldBe('regex28.exec(input1);', 'results');
//var input2 = "X\u1234YZ";
//var results = ["X\u1234YZ"];
//shouldBe('regex28.exec(input2);', 'results');
//var input3 = "X\u1234\u0512";
//var results = ["X\u1234\u0512"];
//shouldBe('regex28.exec(input3);', 'results');
//var input4 = "X\u1234\u0512YZ";
//var results = ["X\u1234\u0512"];
//shouldBe('regex28.exec(input4);', 'results');
//
//var regex29 = /X\C{3,5}?/;
//var input0 = "Xabcdefg";
//var results = ["Xabc"];
//shouldBe('regex29.exec(input0);', 'results');
//var input1 = "X\u1234";
//var results = ["X\u1234"];
//shouldBe('regex29.exec(input1);', 'results');
//var input2 = "X\u1234YZ";
//var results = ["X\u1234"];
//shouldBe('regex29.exec(input2);', 'results');
//var input3 = "X\u1234\u0512";
//var results = ["X\u1234"];
//shouldBe('regex29.exec(input3);', 'results');
//
//var regex89 = /a\Cb/;
//var input0 = "aXb";
//var results = ["aXb"];
//shouldBe('regex89.exec(input0);', 'results');
//var input1 = "a\nb";
//var results = ["a\x0ab"];
//shouldBe('regex89.exec(input1);', 'results');
//
//var regex90 = /a\Cb/;
//var input0 = "aXb";
//var results = ["aXb"];
//shouldBe('regex90.exec(input0);', 'results');
//var input1 = "a\nb";
//var results = ["a\u000ab"];
//shouldBe('regex90.exec(input1);', 'results');
//// Failers
//var input2 = "a\u0100b";
//var results = null;
//shouldBe('regex90.exec(input2);', 'results');
| {
"pile_set_name": "Github"
} |
using Newtonsoft.Json;
namespace YouTrackSharp.AgileBoards
{
/// <summary>
/// A class that represents a YouTrack field used in the context of an agile board
/// </summary>
public class Field
{
/// <summary>
/// Gets or sets the name of the field
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }
/// <summary>
/// Gets or sets the localized name of the field
/// </summary>
[JsonProperty("localizedName")]
public string LocalizedName { get; set; }
}
} | {
"pile_set_name": "Github"
} |
--SKIPIF--
return !function_exists('hash_hmac');
--INI--
URI.Munge = "/redirect?s=%s&t=%t&r=%r&n=%n&m=%m&p=%p"
URI.MungeSecretKey = "foo"
URI.MungeResources = true
--HTML--
<a href="http://example.com">Link</a>
<img src="http://example.com" style="background-image:url(http://example.com);" alt="example.com" />
--EXPECT--
<a href="/redirect?s=http%3A%2F%2Fexample.com&t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&r=&n=a&m=href&p=">Link</a>
<img src="/redirect?s=http%3A%2F%2Fexample.com&t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&r=1&n=img&m=src&p=" style="background-image:url("/redirect?s=http%3A%2F%2Fexample.com&t=c763c4a30204eee8470a3292e0f0cd91a639654d039d45f1495a50207847e954&r=1&n=img&m=style&p=background-image");" alt="example.com" />
--# vim: et sw=4 sts=4
| {
"pile_set_name": "Github"
} |
// Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Test that we can handle function calls with up to 32766 arguments, and
// that function calls with more arguments throw an exception. Apply a
// similar limit to the number of function parameters.
// See http://code.google.com/p/v8/issues/detail?id=1122 and
// http://code.google.com/p/v8/issues/detail?id=1413.
function function_with_n_params_and_m_args(n, m) {
test_prefix = 'prefix ';
test_suffix = ' suffix';
var source = 'test_prefix + (function f(';
for (var arg = 0; arg < n ; arg++) {
if (arg != 0) source += ',';
source += 'arg' + arg;
}
source += ') { return arg' + (n - n % 2) / 2 + '; })(';
for (var arg = 0; arg < m ; arg++) {
if (arg != 0) source += ',';
source += arg;
}
source += ') + test_suffix';
return eval(source);
}
assertEquals('prefix 4000 suffix',
function_with_n_params_and_m_args(8000, 8000));
assertEquals('prefix 3000 suffix',
function_with_n_params_and_m_args(6000, 8000));
assertEquals('prefix 5000 suffix',
function_with_n_params_and_m_args(10000, 8000));
assertEquals('prefix 9000 suffix',
function_with_n_params_and_m_args(18000, 18000));
assertEquals('prefix 16000 suffix',
function_with_n_params_and_m_args(32000, 32000));
assertEquals('prefix undefined suffix',
function_with_n_params_and_m_args(32000, 10000));
assertThrows("function_with_n_params_and_m_args(66000, 30000)");
assertThrows("function_with_n_params_and_m_args(30000, 66000)");
| {
"pile_set_name": "Github"
} |
# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py
# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=znver1 -instruction-tables < %s | FileCheck %s
addpd %xmm0, %xmm2
addpd (%rax), %xmm2
addsd %xmm0, %xmm2
addsd (%rax), %xmm2
andnpd %xmm0, %xmm2
andnpd (%rax), %xmm2
andpd %xmm0, %xmm2
andpd (%rax), %xmm2
clflush (%rax)
cmppd $0, %xmm0, %xmm2
cmppd $0, (%rax), %xmm2
cmpsd $0, %xmm0, %xmm2
cmpsd $0, (%rax), %xmm2
comisd %xmm0, %xmm1
comisd (%rax), %xmm1
cvtdq2pd %xmm0, %xmm2
cvtdq2pd (%rax), %xmm2
cvtdq2ps %xmm0, %xmm2
cvtdq2ps (%rax), %xmm2
cvtpd2dq %xmm0, %xmm2
cvtpd2dq (%rax), %xmm2
cvtpd2pi %xmm0, %mm2
cvtpd2pi (%rax), %mm2
cvtpd2ps %xmm0, %xmm2
cvtpd2ps (%rax), %xmm2
cvtpi2pd %mm0, %xmm2
cvtpi2pd (%rax), %xmm2
cvtps2dq %xmm0, %xmm2
cvtps2dq (%rax), %xmm2
cvtps2pd %xmm0, %xmm2
cvtps2pd (%rax), %xmm2
cvtsd2si %xmm0, %ecx
cvtsd2si %xmm0, %rcx
cvtsd2si (%rax), %ecx
cvtsd2si (%rax), %rcx
cvtsd2ss %xmm0, %xmm2
cvtsd2ss (%rax), %xmm2
cvtsi2sd %ecx, %xmm2
cvtsi2sd %rcx, %xmm2
cvtsi2sd (%rax), %xmm2
cvtsi2sd (%rax), %xmm2
cvtss2sd %xmm0, %xmm2
cvtss2sd (%rax), %xmm2
cvttpd2dq %xmm0, %xmm2
cvttpd2dq (%rax), %xmm2
cvttpd2pi %xmm0, %mm2
cvttpd2pi (%rax), %mm2
cvttps2dq %xmm0, %xmm2
cvttps2dq (%rax), %xmm2
cvttsd2si %xmm0, %ecx
cvttsd2si %xmm0, %rcx
cvttsd2si (%rax), %ecx
cvttsd2si (%rax), %rcx
divpd %xmm0, %xmm2
divpd (%rax), %xmm2
divsd %xmm0, %xmm2
divsd (%rax), %xmm2
lfence
maskmovdqu %xmm0, %xmm1
maxpd %xmm0, %xmm2
maxpd (%rax), %xmm2
maxsd %xmm0, %xmm2
maxsd (%rax), %xmm2
mfence
minpd %xmm0, %xmm2
minpd (%rax), %xmm2
minsd %xmm0, %xmm2
minsd (%rax), %xmm2
movapd %xmm0, %xmm2
movapd %xmm0, (%rax)
movapd (%rax), %xmm2
movd %eax, %xmm2
movd (%rax), %xmm2
movd %xmm0, %ecx
movd %xmm0, (%rax)
movdqa %xmm0, %xmm2
movdqa %xmm0, (%rax)
movdqa (%rax), %xmm2
movdqu %xmm0, %xmm2
movdqu %xmm0, (%rax)
movdqu (%rax), %xmm2
movdq2q %xmm0, %mm2
movhpd %xmm0, (%rax)
movhpd (%rax), %xmm2
movlpd %xmm0, (%rax)
movlpd (%rax), %xmm2
movmskpd %xmm0, %rcx
movntil %eax, (%rax)
movntiq %rax, (%rax)
movntdq %xmm0, (%rax)
movntpd %xmm0, (%rax)
movq %xmm0, %xmm2
movq %rax, %xmm2
movq (%rax), %xmm2
movq %xmm0, %rcx
movq %xmm0, (%rax)
movq2dq %mm0, %xmm2
movsd %xmm0, %xmm2
movsd %xmm0, (%rax)
movsd (%rax), %xmm2
movupd %xmm0, %xmm2
movupd %xmm0, (%rax)
movupd (%rax), %xmm2
mulpd %xmm0, %xmm2
mulpd (%rax), %xmm2
mulsd %xmm0, %xmm2
mulsd (%rax), %xmm2
orpd %xmm0, %xmm2
orpd (%rax), %xmm2
packssdw %xmm0, %xmm2
packssdw (%rax), %xmm2
packsswb %xmm0, %xmm2
packsswb (%rax), %xmm2
packuswb %xmm0, %xmm2
packuswb (%rax), %xmm2
paddb %xmm0, %xmm2
paddb (%rax), %xmm2
paddd %xmm0, %xmm2
paddd (%rax), %xmm2
paddq %mm0, %mm2
paddq (%rax), %mm2
paddq %xmm0, %xmm2
paddq (%rax), %xmm2
paddsb %xmm0, %xmm2
paddsb (%rax), %xmm2
paddsw %xmm0, %xmm2
paddsw (%rax), %xmm2
paddusb %xmm0, %xmm2
paddusb (%rax), %xmm2
paddusw %xmm0, %xmm2
paddusw (%rax), %xmm2
paddw %xmm0, %xmm2
paddw (%rax), %xmm2
pand %xmm0, %xmm2
pand (%rax), %xmm2
pandn %xmm0, %xmm2
pandn (%rax), %xmm2
pavgb %xmm0, %xmm2
pavgb (%rax), %xmm2
pavgw %xmm0, %xmm2
pavgw (%rax), %xmm2
pcmpeqb %xmm0, %xmm2
pcmpeqb (%rax), %xmm2
pcmpeqd %xmm0, %xmm2
pcmpeqd (%rax), %xmm2
pcmpeqw %xmm0, %xmm2
pcmpeqw (%rax), %xmm2
pcmpgtb %xmm0, %xmm2
pcmpgtb (%rax), %xmm2
pcmpgtd %xmm0, %xmm2
pcmpgtd (%rax), %xmm2
pcmpgtw %xmm0, %xmm2
pcmpgtw (%rax), %xmm2
pextrw $1, %xmm0, %rcx
pinsrw $1, %rax, %xmm0
pinsrw $1, (%rax), %xmm0
pmaddwd %xmm0, %xmm2
pmaddwd (%rax), %xmm2
pmaxsw %xmm0, %xmm2
pmaxsw (%rax), %xmm2
pmaxub %xmm0, %xmm2
pmaxub (%rax), %xmm2
pminsw %xmm0, %xmm2
pminsw (%rax), %xmm2
pminub %xmm0, %xmm2
pminub (%rax), %xmm2
pmovmskb %xmm0, %rcx
pmulhuw %xmm0, %xmm2
pmulhuw (%rax), %xmm2
pmulhw %xmm0, %xmm2
pmulhw (%rax), %xmm2
pmullw %xmm0, %xmm2
pmullw (%rax), %xmm2
pmuludq %mm0, %mm2
pmuludq (%rax), %mm2
pmuludq %xmm0, %xmm2
pmuludq (%rax), %xmm2
por %xmm0, %xmm2
por (%rax), %xmm2
psadbw %xmm0, %xmm2
psadbw (%rax), %xmm2
pshufd $1, %xmm0, %xmm2
pshufd $1, (%rax), %xmm2
pshufhw $1, %xmm0, %xmm2
pshufhw $1, (%rax), %xmm2
pshuflw $1, %xmm0, %xmm2
pshuflw $1, (%rax), %xmm2
pslld $1, %xmm2
pslld %xmm0, %xmm2
pslld (%rax), %xmm2
pslldq $1, %xmm2
psllq $1, %xmm2
psllq %xmm0, %xmm2
psllq (%rax), %xmm2
psllw $1, %xmm2
psllw %xmm0, %xmm2
psllw (%rax), %xmm2
psrad $1, %xmm2
psrad %xmm0, %xmm2
psrad (%rax), %xmm2
psraw $1, %xmm2
psraw %xmm0, %xmm2
psraw (%rax), %xmm2
psrld $1, %xmm2
psrld %xmm0, %xmm2
psrld (%rax), %xmm2
psrldq $1, %xmm2
psrlq $1, %xmm2
psrlq %xmm0, %xmm2
psrlq (%rax), %xmm2
psrlw $1, %xmm2
psrlw %xmm0, %xmm2
psrlw (%rax), %xmm2
psubb %xmm0, %xmm2
psubb (%rax), %xmm2
psubd %xmm0, %xmm2
psubd (%rax), %xmm2
psubq %mm0, %mm2
psubq (%rax), %mm2
psubq %xmm0, %xmm2
psubq (%rax), %xmm2
psubsb %xmm0, %xmm2
psubsb (%rax), %xmm2
psubsw %xmm0, %xmm2
psubsw (%rax), %xmm2
psubusb %xmm0, %xmm2
psubusb (%rax), %xmm2
psubusw %xmm0, %xmm2
psubusw (%rax), %xmm2
psubw %xmm0, %xmm2
psubw (%rax), %xmm2
punpckhbw %xmm0, %xmm2
punpckhbw (%rax), %xmm2
punpckhdq %xmm0, %xmm2
punpckhdq (%rax), %xmm2
punpckhqdq %xmm0, %xmm2
punpckhqdq (%rax), %xmm2
punpckhwd %xmm0, %xmm2
punpckhwd (%rax), %xmm2
punpcklbw %xmm0, %xmm2
punpcklbw (%rax), %xmm2
punpckldq %xmm0, %xmm2
punpckldq (%rax), %xmm2
punpcklqdq %xmm0, %xmm2
punpcklqdq (%rax), %xmm2
punpcklwd %xmm0, %xmm2
punpcklwd (%rax), %xmm2
pxor %xmm0, %xmm2
pxor (%rax), %xmm2
shufpd $1, %xmm0, %xmm2
shufpd $1, (%rax), %xmm2
sqrtpd %xmm0, %xmm2
sqrtpd (%rax), %xmm2
sqrtsd %xmm0, %xmm2
sqrtsd (%rax), %xmm2
subpd %xmm0, %xmm2
subpd (%rax), %xmm2
subsd %xmm0, %xmm2
subsd (%rax), %xmm2
ucomisd %xmm0, %xmm1
ucomisd (%rax), %xmm1
unpckhpd %xmm0, %xmm2
unpckhpd (%rax), %xmm2
unpcklpd %xmm0, %xmm2
unpcklpd (%rax), %xmm2
xorpd %xmm0, %xmm2
xorpd (%rax), %xmm2
# CHECK: Instruction Info:
# CHECK-NEXT: [1]: #uOps
# CHECK-NEXT: [2]: Latency
# CHECK-NEXT: [3]: RThroughput
# CHECK-NEXT: [4]: MayLoad
# CHECK-NEXT: [5]: MayStore
# CHECK-NEXT: [6]: HasSideEffects (U)
# CHECK: [1] [2] [3] [4] [5] [6] Instructions:
# CHECK-NEXT: 1 3 1.00 addpd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * addpd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 addsd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * addsd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 andnpd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * andnpd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 andpd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * andpd (%rax), %xmm2
# CHECK-NEXT: 1 8 0.50 * * U clflush (%rax)
# CHECK-NEXT: 1 3 1.00 cmpeqpd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * cmpeqpd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 cmpeqsd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * cmpeqsd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 comisd %xmm0, %xmm1
# CHECK-NEXT: 1 10 1.00 * comisd (%rax), %xmm1
# CHECK-NEXT: 1 5 1.00 cvtdq2pd %xmm0, %xmm2
# CHECK-NEXT: 1 12 1.00 * cvtdq2pd (%rax), %xmm2
# CHECK-NEXT: 1 5 1.00 cvtdq2ps %xmm0, %xmm2
# CHECK-NEXT: 1 12 1.00 * cvtdq2ps (%rax), %xmm2
# CHECK-NEXT: 1 5 1.00 cvtpd2dq %xmm0, %xmm2
# CHECK-NEXT: 2 12 1.00 * cvtpd2dq (%rax), %xmm2
# CHECK-NEXT: 1 4 1.00 cvtpd2pi %xmm0, %mm2
# CHECK-NEXT: 1 12 1.00 * cvtpd2pi (%rax), %mm2
# CHECK-NEXT: 1 4 1.00 cvtpd2ps %xmm0, %xmm2
# CHECK-NEXT: 2 11 1.00 * cvtpd2ps (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 cvtpi2pd %mm0, %xmm2
# CHECK-NEXT: 1 12 1.00 * cvtpi2pd (%rax), %xmm2
# CHECK-NEXT: 1 5 1.00 cvtps2dq %xmm0, %xmm2
# CHECK-NEXT: 1 12 1.00 * cvtps2dq (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 cvtps2pd %xmm0, %xmm2
# CHECK-NEXT: 2 10 1.00 * cvtps2pd (%rax), %xmm2
# CHECK-NEXT: 1 5 1.00 cvtsd2si %xmm0, %ecx
# CHECK-NEXT: 1 5 1.00 cvtsd2si %xmm0, %rcx
# CHECK-NEXT: 1 12 1.00 * cvtsd2si (%rax), %ecx
# CHECK-NEXT: 1 12 1.00 * cvtsd2si (%rax), %rcx
# CHECK-NEXT: 1 4 1.00 cvtsd2ss %xmm0, %xmm2
# CHECK-NEXT: 2 11 1.00 * cvtsd2ss (%rax), %xmm2
# CHECK-NEXT: 1 5 1.00 cvtsi2sd %ecx, %xmm2
# CHECK-NEXT: 1 5 1.00 cvtsi2sd %rcx, %xmm2
# CHECK-NEXT: 1 12 1.00 * cvtsi2sdl (%rax), %xmm2
# CHECK-NEXT: 1 12 1.00 * cvtsi2sdl (%rax), %xmm2
# CHECK-NEXT: 1 4 1.00 cvtss2sd %xmm0, %xmm2
# CHECK-NEXT: 2 11 2.00 * cvtss2sd (%rax), %xmm2
# CHECK-NEXT: 1 5 1.00 cvttpd2dq %xmm0, %xmm2
# CHECK-NEXT: 2 12 1.00 * cvttpd2dq (%rax), %xmm2
# CHECK-NEXT: 1 4 1.00 cvttpd2pi %xmm0, %mm2
# CHECK-NEXT: 1 12 1.00 * cvttpd2pi (%rax), %mm2
# CHECK-NEXT: 1 5 1.00 cvttps2dq %xmm0, %xmm2
# CHECK-NEXT: 1 12 1.00 * cvttps2dq (%rax), %xmm2
# CHECK-NEXT: 1 5 1.00 cvttsd2si %xmm0, %ecx
# CHECK-NEXT: 1 5 1.00 cvttsd2si %xmm0, %rcx
# CHECK-NEXT: 1 12 1.00 * cvttsd2si (%rax), %ecx
# CHECK-NEXT: 1 12 1.00 * cvttsd2si (%rax), %rcx
# CHECK-NEXT: 1 15 1.00 divpd %xmm0, %xmm2
# CHECK-NEXT: 1 22 1.00 * divpd (%rax), %xmm2
# CHECK-NEXT: 1 15 1.00 divsd %xmm0, %xmm2
# CHECK-NEXT: 1 22 1.00 * divsd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.50 * * U lfence
# CHECK-NEXT: 1 100 0.25 * * U maskmovdqu %xmm0, %xmm1
# CHECK-NEXT: 1 3 1.00 maxpd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * maxpd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 maxsd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * maxsd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.50 * * U mfence
# CHECK-NEXT: 1 3 1.00 minpd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * minpd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 minsd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * minsd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 movapd %xmm0, %xmm2
# CHECK-NEXT: 1 1 0.50 * movapd %xmm0, (%rax)
# CHECK-NEXT: 1 8 0.50 * movapd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 movd %eax, %xmm2
# CHECK-NEXT: 1 8 0.50 * movd (%rax), %xmm2
# CHECK-NEXT: 1 2 1.00 movd %xmm0, %ecx
# CHECK-NEXT: 1 1 0.50 * movd %xmm0, (%rax)
# CHECK-NEXT: 1 1 0.25 movdqa %xmm0, %xmm2
# CHECK-NEXT: 1 1 0.50 * movdqa %xmm0, (%rax)
# CHECK-NEXT: 1 8 0.50 * movdqa (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 movdqu %xmm0, %xmm2
# CHECK-NEXT: 1 1 0.50 * movdqu %xmm0, (%rax)
# CHECK-NEXT: 1 8 0.50 * movdqu (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 movdq2q %xmm0, %mm2
# CHECK-NEXT: 1 1 0.50 * movhpd %xmm0, (%rax)
# CHECK-NEXT: 1 8 0.50 * movhpd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.50 * movlpd %xmm0, (%rax)
# CHECK-NEXT: 1 8 0.50 * movlpd (%rax), %xmm2
# CHECK-NEXT: 1 1 1.00 movmskpd %xmm0, %ecx
# CHECK-NEXT: 1 1 0.50 * movntil %eax, (%rax)
# CHECK-NEXT: 1 1 0.50 * movntiq %rax, (%rax)
# CHECK-NEXT: 1 1 0.50 * movntdq %xmm0, (%rax)
# CHECK-NEXT: 1 1 0.50 * movntpd %xmm0, (%rax)
# CHECK-NEXT: 1 1 0.25 movq %xmm0, %xmm2
# CHECK-NEXT: 1 3 1.00 movq %rax, %xmm2
# CHECK-NEXT: 1 8 0.50 * movq (%rax), %xmm2
# CHECK-NEXT: 1 2 1.00 movq %xmm0, %rcx
# CHECK-NEXT: 1 1 0.50 * movq %xmm0, (%rax)
# CHECK-NEXT: 1 1 0.25 movq2dq %mm0, %xmm2
# CHECK-NEXT: 1 1 0.50 movsd %xmm0, %xmm2
# CHECK-NEXT: 1 1 0.50 * movsd %xmm0, (%rax)
# CHECK-NEXT: 1 8 0.50 * movsd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 movupd %xmm0, %xmm2
# CHECK-NEXT: 1 1 0.50 * movupd %xmm0, (%rax)
# CHECK-NEXT: 1 8 0.50 * movupd (%rax), %xmm2
# CHECK-NEXT: 1 3 0.50 mulpd %xmm0, %xmm2
# CHECK-NEXT: 2 10 0.50 * mulpd (%rax), %xmm2
# CHECK-NEXT: 1 3 0.50 mulsd %xmm0, %xmm2
# CHECK-NEXT: 2 10 0.50 * mulsd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 orpd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * orpd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 packssdw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * packssdw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 packsswb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * packsswb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 packuswb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * packuswb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 paddb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * paddb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 paddd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * paddd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 paddq %mm0, %mm2
# CHECK-NEXT: 1 8 0.50 * paddq (%rax), %mm2
# CHECK-NEXT: 1 1 0.25 paddq %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * paddq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 paddsb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * paddsb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 paddsw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * paddsw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 paddusb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * paddusb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 paddusw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * paddusw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 paddw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * paddw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pand %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pand (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pandn %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pandn (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pavgb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pavgb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pavgw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pavgw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pcmpeqb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pcmpeqb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pcmpeqd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pcmpeqd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pcmpeqw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pcmpeqw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pcmpgtb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pcmpgtb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pcmpgtd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pcmpgtd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pcmpgtw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pcmpgtw (%rax), %xmm2
# CHECK-NEXT: 1 2 2.00 pextrw $1, %xmm0, %ecx
# CHECK-NEXT: 1 1 0.25 pinsrw $1, %eax, %xmm0
# CHECK-NEXT: 1 8 0.50 * pinsrw $1, (%rax), %xmm0
# CHECK-NEXT: 1 4 1.00 pmaddwd %xmm0, %xmm2
# CHECK-NEXT: 1 11 1.00 * pmaddwd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pmaxsw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pmaxsw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pmaxub %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pmaxub (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pminsw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pminsw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pminub %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pminub (%rax), %xmm2
# CHECK-NEXT: 1 1 1.00 pmovmskb %xmm0, %ecx
# CHECK-NEXT: 1 4 1.00 pmulhuw %xmm0, %xmm2
# CHECK-NEXT: 1 11 1.00 * pmulhuw (%rax), %xmm2
# CHECK-NEXT: 1 4 1.00 pmulhw %xmm0, %xmm2
# CHECK-NEXT: 1 11 1.00 * pmulhw (%rax), %xmm2
# CHECK-NEXT: 1 4 1.00 pmullw %xmm0, %xmm2
# CHECK-NEXT: 1 11 1.00 * pmullw (%rax), %xmm2
# CHECK-NEXT: 1 4 1.00 pmuludq %mm0, %mm2
# CHECK-NEXT: 1 11 1.00 * pmuludq (%rax), %mm2
# CHECK-NEXT: 1 4 1.00 pmuludq %xmm0, %xmm2
# CHECK-NEXT: 1 11 1.00 * pmuludq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 por %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * por (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 psadbw %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * psadbw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pshufd $1, %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pshufd $1, (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pshufhw $1, %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pshufhw $1, (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pshuflw $1, %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pshuflw $1, (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pslld $1, %xmm2
# CHECK-NEXT: 1 1 1.00 pslld %xmm0, %xmm2
# CHECK-NEXT: 1 8 1.00 * pslld (%rax), %xmm2
# CHECK-NEXT: 1 1 1.00 pslldq $1, %xmm2
# CHECK-NEXT: 1 1 0.25 psllq $1, %xmm2
# CHECK-NEXT: 1 1 1.00 psllq %xmm0, %xmm2
# CHECK-NEXT: 1 8 1.00 * psllq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psllw $1, %xmm2
# CHECK-NEXT: 1 1 1.00 psllw %xmm0, %xmm2
# CHECK-NEXT: 1 8 1.00 * psllw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psrad $1, %xmm2
# CHECK-NEXT: 1 1 1.00 psrad %xmm0, %xmm2
# CHECK-NEXT: 1 8 1.00 * psrad (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psraw $1, %xmm2
# CHECK-NEXT: 1 1 1.00 psraw %xmm0, %xmm2
# CHECK-NEXT: 1 8 1.00 * psraw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psrld $1, %xmm2
# CHECK-NEXT: 1 1 1.00 psrld %xmm0, %xmm2
# CHECK-NEXT: 1 8 1.00 * psrld (%rax), %xmm2
# CHECK-NEXT: 1 1 1.00 psrldq $1, %xmm2
# CHECK-NEXT: 1 1 0.25 psrlq $1, %xmm2
# CHECK-NEXT: 1 1 1.00 psrlq %xmm0, %xmm2
# CHECK-NEXT: 1 8 1.00 * psrlq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psrlw $1, %xmm2
# CHECK-NEXT: 1 1 1.00 psrlw %xmm0, %xmm2
# CHECK-NEXT: 1 8 1.00 * psrlw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psubb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * psubb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psubd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * psubd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psubq %mm0, %mm2
# CHECK-NEXT: 1 8 0.50 * psubq (%rax), %mm2
# CHECK-NEXT: 1 1 0.25 psubq %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * psubq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psubsb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * psubsb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psubsw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * psubsw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psubusb %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * psubusb (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psubusw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * psubusw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 psubw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * psubw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 punpckhbw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * punpckhbw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 punpckhdq %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * punpckhdq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 punpckhqdq %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * punpckhqdq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 punpckhwd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * punpckhwd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 punpcklbw %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * punpcklbw (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 punpckldq %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * punpckldq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 punpcklqdq %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * punpcklqdq (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 punpcklwd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * punpcklwd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 pxor %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * pxor (%rax), %xmm2
# CHECK-NEXT: 1 1 0.50 shufpd $1, %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * shufpd $1, (%rax), %xmm2
# CHECK-NEXT: 1 20 20.00 sqrtpd %xmm0, %xmm2
# CHECK-NEXT: 1 27 20.00 * sqrtpd (%rax), %xmm2
# CHECK-NEXT: 1 20 20.00 sqrtsd %xmm0, %xmm2
# CHECK-NEXT: 1 27 20.00 * sqrtsd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 subpd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * subpd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 subsd %xmm0, %xmm2
# CHECK-NEXT: 1 10 1.00 * subsd (%rax), %xmm2
# CHECK-NEXT: 1 3 1.00 ucomisd %xmm0, %xmm1
# CHECK-NEXT: 1 10 1.00 * ucomisd (%rax), %xmm1
# CHECK-NEXT: 1 1 0.50 unpckhpd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * unpckhpd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.50 unpcklpd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * unpcklpd (%rax), %xmm2
# CHECK-NEXT: 1 1 0.25 xorpd %xmm0, %xmm2
# CHECK-NEXT: 1 8 0.50 * xorpd (%rax), %xmm2
# CHECK: Resources:
# CHECK-NEXT: [0] - ZnAGU0
# CHECK-NEXT: [1] - ZnAGU1
# CHECK-NEXT: [2] - ZnALU0
# CHECK-NEXT: [3] - ZnALU1
# CHECK-NEXT: [4] - ZnALU2
# CHECK-NEXT: [5] - ZnALU3
# CHECK-NEXT: [6] - ZnDivider
# CHECK-NEXT: [7] - ZnFPU0
# CHECK-NEXT: [8] - ZnFPU1
# CHECK-NEXT: [9] - ZnFPU2
# CHECK-NEXT: [10] - ZnFPU3
# CHECK-NEXT: [11] - ZnMultiplier
# CHECK: Resource pressure per iteration:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
# CHECK-NEXT: 66.50 66.50 - - - - - 72.92 40.42 71.75 153.92 -
# CHECK: Resource pressure by instruction:
# CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] Instructions:
# CHECK-NEXT: - - - - - - - 1.00 - - - - addpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - addpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - addsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - addsd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - andnpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - andnpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - andpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - andpd (%rax), %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - clflush (%rax)
# CHECK-NEXT: - - - - - - - 1.00 - - - - cmpeqpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - cmpeqpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - cmpeqsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - cmpeqsd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - comisd %xmm0, %xmm1
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - comisd (%rax), %xmm1
# CHECK-NEXT: - - - - - - - - 0.50 0.50 1.00 - cvtdq2pd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvtdq2pd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvtdq2ps %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvtdq2ps (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - 0.50 0.50 1.00 - cvtpd2dq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - 0.50 0.50 1.00 - cvtpd2dq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvtpd2pi %xmm0, %mm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvtpd2pi (%rax), %mm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvtpd2ps %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - 1.00 - cvtpd2ps (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvtpi2pd %mm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvtpi2pd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvtps2dq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvtps2dq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvtps2pd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvtps2pd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 1.00 - cvtsd2si %xmm0, %ecx
# CHECK-NEXT: - - - - - - - - - 1.00 1.00 - cvtsd2si %xmm0, %rcx
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 1.00 - cvtsd2si (%rax), %ecx
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 1.00 - cvtsd2si (%rax), %rcx
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvtsd2ss %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - 1.00 - cvtsd2ss (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.33 0.33 - 1.33 - cvtsi2sd %ecx, %xmm2
# CHECK-NEXT: - - - - - - - 0.33 0.33 - 1.33 - cvtsi2sd %rcx, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvtsi2sdl (%rax), %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvtsi2sdl (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvtss2sd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 2.00 - cvtss2sd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - 0.50 0.50 1.00 - cvttpd2dq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - 0.50 0.50 1.00 - cvttpd2dq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvttpd2pi %xmm0, %mm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvttpd2pi (%rax), %mm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - cvttps2dq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - cvttps2dq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 1.00 - cvttsd2si %xmm0, %ecx
# CHECK-NEXT: - - - - - - - - - 1.00 1.00 - cvttsd2si %xmm0, %rcx
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 1.00 - cvttsd2si (%rax), %ecx
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 1.00 - cvttsd2si (%rax), %rcx
# CHECK-NEXT: - - - - - - - - - - 1.00 - divpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - divpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 1.00 - divsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 1.00 - divsd (%rax), %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - lfence
# CHECK-NEXT: - - - - - - - - - - - - maskmovdqu %xmm0, %xmm1
# CHECK-NEXT: - - - - - - - 1.00 - - - - maxpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - maxpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - maxsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - maxsd (%rax), %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - mfence
# CHECK-NEXT: - - - - - - - 1.00 - - - - minpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - minpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - minsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - minsd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - movapd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movapd %xmm0, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movapd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - movd %eax, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - movd %xmm0, %ecx
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movd %xmm0, (%rax)
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - movdqa %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movdqa %xmm0, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movdqa (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - movdqu %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movdqu %xmm0, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movdqu (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - movdq2q %xmm0, %mm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movhpd %xmm0, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - 0.50 0.50 - - movhpd (%rax), %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movlpd %xmm0, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - 0.50 0.50 - - movlpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - movmskpd %xmm0, %ecx
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movntil %eax, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movntiq %rax, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movntdq %xmm0, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movntpd %xmm0, (%rax)
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - movq %xmm0, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - movq %rax, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - movq %xmm0, %rcx
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movq %xmm0, (%rax)
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - movq2dq %mm0, %xmm2
# CHECK-NEXT: - - - - - - - - 0.50 0.50 - - movsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movsd %xmm0, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movsd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - movupd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movupd %xmm0, (%rax)
# CHECK-NEXT: 0.50 0.50 - - - - - - - - - - movupd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.50 0.50 - - - mulpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.50 0.50 - - - mulpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.50 0.50 - - - mulsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.50 0.50 - - - mulsd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - orpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - orpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - packssdw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - packssdw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - packsswb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - packsswb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - packuswb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - packuswb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddq %mm0, %mm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddq (%rax), %mm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddsb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddsb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddsw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddsw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddusb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddusb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddusw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddusw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - paddw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - paddw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pand %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pand (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pandn %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pandn (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pavgb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pavgb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pavgw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pavgw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pcmpeqb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pcmpeqb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pcmpeqd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pcmpeqd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pcmpeqw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pcmpeqw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pcmpgtb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pcmpgtb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pcmpgtd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pcmpgtd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pcmpgtw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pcmpgtw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - 0.50 2.50 - - pextrw $1, %xmm0, %ecx
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pinsrw $1, %eax, %xmm0
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pinsrw $1, (%rax), %xmm0
# CHECK-NEXT: - - - - - - - 1.00 - - - - pmaddwd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - pmaddwd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pmaxsw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pmaxsw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pmaxub %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pmaxub (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pminsw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pminsw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pminub %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pminub (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - pmovmskb %xmm0, %ecx
# CHECK-NEXT: - - - - - - - 1.00 - - - - pmulhuw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - pmulhuw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - pmulhw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - pmulhw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - pmullw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - pmullw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - pmuludq %mm0, %mm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - pmuludq (%rax), %mm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - pmuludq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - pmuludq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - por %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - por (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - psadbw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - psadbw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pshufd $1, %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pshufd $1, (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pshufhw $1, %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pshufhw $1, (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pshuflw $1, %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pshuflw $1, (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pslld $1, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - pslld %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 - - pslld (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - pslldq $1, %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psllq $1, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - psllq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 - - psllq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psllw $1, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - psllw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 - - psllw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psrad $1, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - psrad %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 - - psrad (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psraw $1, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - psraw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 - - psraw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psrld $1, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - psrld %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 - - psrld (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - psrldq $1, %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psrlq $1, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - psrlq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 - - psrlq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psrlw $1, %xmm2
# CHECK-NEXT: - - - - - - - - - 1.00 - - psrlw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - 1.00 - - psrlw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubq %mm0, %mm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubq (%rax), %mm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubsb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubsb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubsw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubsw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubusb %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubusb (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubusw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubusw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - psubw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - psubw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - punpckhbw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - punpckhbw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - punpckhdq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - punpckhdq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - punpckhqdq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - punpckhqdq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - punpckhwd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - punpckhwd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - punpcklbw %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - punpcklbw (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - punpckldq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - punpckldq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - punpcklqdq %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - punpcklqdq (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - punpcklwd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - punpcklwd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - pxor %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - pxor (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - 0.50 0.50 - - shufpd $1, %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - 0.50 0.50 - - shufpd $1, (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 20.00 - sqrtpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 20.00 - sqrtpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - - - 20.00 - sqrtsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - - - 20.00 - sqrtsd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - subpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - subpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - subsd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - subsd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 1.00 - - - - ucomisd %xmm0, %xmm1
# CHECK-NEXT: 0.50 0.50 - - - - - 1.00 - - - - ucomisd (%rax), %xmm1
# CHECK-NEXT: - - - - - - - - 0.50 0.50 - - unpckhpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - 0.50 0.50 - - unpckhpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - - 0.50 0.50 - - unpcklpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - - 0.50 0.50 - - unpcklpd (%rax), %xmm2
# CHECK-NEXT: - - - - - - - 0.25 0.25 0.25 0.25 - xorpd %xmm0, %xmm2
# CHECK-NEXT: 0.50 0.50 - - - - - 0.25 0.25 0.25 0.25 - xorpd (%rax), %xmm2
| {
"pile_set_name": "Github"
} |
<template>
<div class="comments">
<div class="disqus" :class="{ ready: disqusReady }">
<client-only>
<lazy-component @show="disqusReady = true">
<vue-disqus shortname="nuepress-kmr-io" :identifier="article.slug" />
</lazy-component>
</client-only>
</div>
</div>
</template>
<script>
export default {
props: {
article: Object
},
data() {
return {
disqusReady: false
};
}
};
</script>
<style lang="scss" scoped>
.comments {
border-top: 1px dotted #65676a;
padding-top: 32px;
margin-top: 32px;
.disqus {
min-height: 440px;
opacity: 0;
transform: translateY(16px);
transition: 1s;
&.ready {
opacity: 1;
transform: translateY(0);
}
}
}
</style>
| {
"pile_set_name": "Github"
} |
//
// MMShapeAssetGroup.h
// LooseLeaf
//
// Created by Adam Wulf on 7/21/18.
// Copyright © 2018 Milestone Made, LLC. All rights reserved.
//
#import "MMDisplayAssetGroup.h"
NS_ASSUME_NONNULL_BEGIN
@interface MMShapeAssetGroup : MMDisplayAssetGroup
+ (MMShapeAssetGroup*)sharedInstance;
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END
| {
"pile_set_name": "Github"
} |
# uncompyle6 version 2.9.10
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.6.0b2 (default, Oct 11 2016, 05:27:10)
# [GCC 6.2.0 20161005]
# Embedded file name: types.py
from types import *
MSG_KEY_PARAMS = 65536
MSG_KEY_PARAMS_FLAGS = 65537
MSG_KEY_PARAMS_SRC = 65538
MSG_KEY_PARAMS_DST = 65539
MSG_KEY_PARAMS_PROVIDER = 65540
MSG_KEY_RESULT = 131072
MSG_KEY_RESULT_SRC = 131073
MSG_KEY_RESULT_DST = 131074 | {
"pile_set_name": "Github"
} |
/* Original style from softwaremaniacs.org (c) Ivan Sagalaev <[email protected]> */
.swagger-section pre code {
display: block;
padding: 0.5em;
background: #F0F0F0;
}
.swagger-section pre code,
.swagger-section pre .subst,
.swagger-section pre .tag .title,
.swagger-section pre .lisp .title,
.swagger-section pre .clojure .built_in,
.swagger-section pre .nginx .title {
color: black;
}
.swagger-section pre .string,
.swagger-section pre .title,
.swagger-section pre .constant,
.swagger-section pre .parent,
.swagger-section pre .tag .value,
.swagger-section pre .rules .value,
.swagger-section pre .rules .value .number,
.swagger-section pre .preprocessor,
.swagger-section pre .ruby .symbol,
.swagger-section pre .ruby .symbol .string,
.swagger-section pre .aggregate,
.swagger-section pre .template_tag,
.swagger-section pre .django .variable,
.swagger-section pre .smalltalk .class,
.swagger-section pre .addition,
.swagger-section pre .flow,
.swagger-section pre .stream,
.swagger-section pre .bash .variable,
.swagger-section pre .apache .tag,
.swagger-section pre .apache .cbracket,
.swagger-section pre .tex .command,
.swagger-section pre .tex .special,
.swagger-section pre .erlang_repl .function_or_atom,
.swagger-section pre .markdown .header {
color: #800;
}
.swagger-section pre .comment,
.swagger-section pre .annotation,
.swagger-section pre .template_comment,
.swagger-section pre .diff .header,
.swagger-section pre .chunk,
.swagger-section pre .markdown .blockquote {
color: #888;
}
.swagger-section pre .number,
.swagger-section pre .date,
.swagger-section pre .regexp,
.swagger-section pre .literal,
.swagger-section pre .smalltalk .symbol,
.swagger-section pre .smalltalk .char,
.swagger-section pre .go .constant,
.swagger-section pre .change,
.swagger-section pre .markdown .bullet,
.swagger-section pre .markdown .link_url {
color: #080;
}
.swagger-section pre .label,
.swagger-section pre .javadoc,
.swagger-section pre .ruby .string,
.swagger-section pre .decorator,
.swagger-section pre .filter .argument,
.swagger-section pre .localvars,
.swagger-section pre .array,
.swagger-section pre .attr_selector,
.swagger-section pre .important,
.swagger-section pre .pseudo,
.swagger-section pre .pi,
.swagger-section pre .doctype,
.swagger-section pre .deletion,
.swagger-section pre .envvar,
.swagger-section pre .shebang,
.swagger-section pre .apache .sqbracket,
.swagger-section pre .nginx .built_in,
.swagger-section pre .tex .formula,
.swagger-section pre .erlang_repl .reserved,
.swagger-section pre .prompt,
.swagger-section pre .markdown .link_label,
.swagger-section pre .vhdl .attribute,
.swagger-section pre .clojure .attribute,
.swagger-section pre .coffeescript .property {
color: #8888ff;
}
.swagger-section pre .keyword,
.swagger-section pre .id,
.swagger-section pre .phpdoc,
.swagger-section pre .title,
.swagger-section pre .built_in,
.swagger-section pre .aggregate,
.swagger-section pre .css .tag,
.swagger-section pre .javadoctag,
.swagger-section pre .phpdoc,
.swagger-section pre .yardoctag,
.swagger-section pre .smalltalk .class,
.swagger-section pre .winutils,
.swagger-section pre .bash .variable,
.swagger-section pre .apache .tag,
.swagger-section pre .go .typename,
.swagger-section pre .tex .command,
.swagger-section pre .markdown .strong,
.swagger-section pre .request,
.swagger-section pre .status {
font-weight: bold;
}
.swagger-section pre .markdown .emphasis {
font-style: italic;
}
.swagger-section pre .nginx .built_in {
font-weight: normal;
}
.swagger-section pre .coffeescript .javascript,
.swagger-section pre .javascript .xml,
.swagger-section pre .tex .formula,
.swagger-section pre .xml .javascript,
.swagger-section pre .xml .vbscript,
.swagger-section pre .xml .css,
.swagger-section pre .xml .cdata {
opacity: 0.5;
}
.swagger-section .swagger-ui-wrap {
line-height: 1;
font-family: "Droid Sans", sans-serif;
max-width: 960px;
margin-left: auto;
margin-right: auto;
}
.swagger-section .swagger-ui-wrap b,
.swagger-section .swagger-ui-wrap strong {
font-family: "Droid Sans", sans-serif;
font-weight: bold;
}
.swagger-section .swagger-ui-wrap q,
.swagger-section .swagger-ui-wrap blockquote {
quotes: none;
}
.swagger-section .swagger-ui-wrap p {
line-height: 1.4em;
padding: 0 0 10px;
color: #333333;
}
.swagger-section .swagger-ui-wrap q:before,
.swagger-section .swagger-ui-wrap q:after,
.swagger-section .swagger-ui-wrap blockquote:before,
.swagger-section .swagger-ui-wrap blockquote:after {
content: none;
}
.swagger-section .swagger-ui-wrap .heading_with_menu h1,
.swagger-section .swagger-ui-wrap .heading_with_menu h2,
.swagger-section .swagger-ui-wrap .heading_with_menu h3,
.swagger-section .swagger-ui-wrap .heading_with_menu h4,
.swagger-section .swagger-ui-wrap .heading_with_menu h5,
.swagger-section .swagger-ui-wrap .heading_with_menu h6 {
display: block;
clear: none;
float: left;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
width: 60%;
}
.swagger-section .swagger-ui-wrap table {
border-collapse: collapse;
border-spacing: 0;
}
.swagger-section .swagger-ui-wrap table thead tr th {
padding: 5px;
font-size: 0.9em;
color: #666666;
border-bottom: 1px solid #999999;
}
.swagger-section .swagger-ui-wrap table tbody tr:last-child td {
border-bottom: none;
}
.swagger-section .swagger-ui-wrap table tbody tr.offset {
background-color: #f0f0f0;
}
.swagger-section .swagger-ui-wrap table tbody tr td {
padding: 6px;
font-size: 0.9em;
border-bottom: 1px solid #cccccc;
vertical-align: top;
line-height: 1.3em;
}
.swagger-section .swagger-ui-wrap ol {
margin: 0px 0 10px;
padding: 0 0 0 18px;
list-style-type: decimal;
}
.swagger-section .swagger-ui-wrap ol li {
padding: 5px 0px;
font-size: 0.9em;
color: #333333;
}
.swagger-section .swagger-ui-wrap ol,
.swagger-section .swagger-ui-wrap ul {
list-style: none;
}
.swagger-section .swagger-ui-wrap h1 a,
.swagger-section .swagger-ui-wrap h2 a,
.swagger-section .swagger-ui-wrap h3 a,
.swagger-section .swagger-ui-wrap h4 a,
.swagger-section .swagger-ui-wrap h5 a,
.swagger-section .swagger-ui-wrap h6 a {
text-decoration: none;
}
.swagger-section .swagger-ui-wrap h1 a:hover,
.swagger-section .swagger-ui-wrap h2 a:hover,
.swagger-section .swagger-ui-wrap h3 a:hover,
.swagger-section .swagger-ui-wrap h4 a:hover,
.swagger-section .swagger-ui-wrap h5 a:hover,
.swagger-section .swagger-ui-wrap h6 a:hover {
text-decoration: underline;
}
.swagger-section .swagger-ui-wrap h1 span.divider,
.swagger-section .swagger-ui-wrap h2 span.divider,
.swagger-section .swagger-ui-wrap h3 span.divider,
.swagger-section .swagger-ui-wrap h4 span.divider,
.swagger-section .swagger-ui-wrap h5 span.divider,
.swagger-section .swagger-ui-wrap h6 span.divider {
color: #aaaaaa;
}
.swagger-section .swagger-ui-wrap a {
color: #547f00;
}
.swagger-section .swagger-ui-wrap a img {
border: none;
}
.swagger-section .swagger-ui-wrap article,
.swagger-section .swagger-ui-wrap aside,
.swagger-section .swagger-ui-wrap details,
.swagger-section .swagger-ui-wrap figcaption,
.swagger-section .swagger-ui-wrap figure,
.swagger-section .swagger-ui-wrap footer,
.swagger-section .swagger-ui-wrap header,
.swagger-section .swagger-ui-wrap hgroup,
.swagger-section .swagger-ui-wrap menu,
.swagger-section .swagger-ui-wrap nav,
.swagger-section .swagger-ui-wrap section,
.swagger-section .swagger-ui-wrap summary {
display: block;
}
.swagger-section .swagger-ui-wrap pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
background-color: #fcf6db;
border: 1px solid #e5e0c6;
padding: 10px;
}
.swagger-section .swagger-ui-wrap pre code {
line-height: 1.6em;
background: none;
}
.swagger-section .swagger-ui-wrap .content > .content-type > div > label {
clear: both;
display: block;
color: #0F6AB4;
font-size: 1.1em;
margin: 0;
padding: 15px 0 5px;
}
.swagger-section .swagger-ui-wrap .content pre {
font-size: 12px;
margin-top: 5px;
padding: 5px;
}
.swagger-section .swagger-ui-wrap .icon-btn {
cursor: pointer;
}
.swagger-section .swagger-ui-wrap .info_title {
padding-bottom: 10px;
font-weight: bold;
font-size: 25px;
}
.swagger-section .swagger-ui-wrap p.big,
.swagger-section .swagger-ui-wrap div.big p {
font-size: 1em;
margin-bottom: 10px;
}
.swagger-section .swagger-ui-wrap form.fullwidth ol li.string input,
.swagger-section .swagger-ui-wrap form.fullwidth ol li.url input,
.swagger-section .swagger-ui-wrap form.fullwidth ol li.text textarea,
.swagger-section .swagger-ui-wrap form.fullwidth ol li.numeric input {
width: 500px !important;
}
.swagger-section .swagger-ui-wrap .info_license {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_tos {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .message-fail {
color: #cc0000;
}
.swagger-section .swagger-ui-wrap .info_url {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_email {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_name {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_description {
padding-bottom: 10px;
font-size: 15px;
}
.swagger-section .swagger-ui-wrap .markdown ol li,
.swagger-section .swagger-ui-wrap .markdown ul li {
padding: 3px 0px;
line-height: 1.4em;
color: #333333;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input,
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input,
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input {
display: block;
padding: 4px;
width: auto;
clear: both;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input.title,
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input.title,
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input.title {
font-size: 1.3em;
}
.swagger-section .swagger-ui-wrap table.fullwidth {
width: 100%;
}
.swagger-section .swagger-ui-wrap .model-signature {
font-family: "Droid Sans", sans-serif;
font-size: 1em;
line-height: 1.5em;
}
.swagger-section .swagger-ui-wrap .model-signature .signature-nav a {
text-decoration: none;
color: #AAA;
}
.swagger-section .swagger-ui-wrap .model-signature .signature-nav a:hover {
text-decoration: underline;
color: black;
}
.swagger-section .swagger-ui-wrap .model-signature .signature-nav .selected {
color: black;
text-decoration: none;
}
.swagger-section .swagger-ui-wrap .model-signature .propType {
color: #5555aa;
}
.swagger-section .swagger-ui-wrap .model-signature pre:hover {
background-color: #ffffdd;
}
.swagger-section .swagger-ui-wrap .model-signature pre {
font-size: .85em;
line-height: 1.2em;
overflow: auto;
max-height: 200px;
cursor: pointer;
}
.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav {
display: block;
margin: 0;
padding: 0;
}
.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav li:last-child {
padding-right: 0;
border-right: none;
}
.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav li {
float: left;
margin: 0 5px 5px 0;
padding: 2px 5px 2px 0;
border-right: 1px solid #ddd;
}
.swagger-section .swagger-ui-wrap .model-signature .propOpt {
color: #555;
}
.swagger-section .swagger-ui-wrap .model-signature .snippet small {
font-size: 0.75em;
}
.swagger-section .swagger-ui-wrap .model-signature .propOptKey {
font-style: italic;
}
.swagger-section .swagger-ui-wrap .model-signature .description .strong {
font-weight: bold;
color: #000;
font-size: .9em;
}
.swagger-section .swagger-ui-wrap .model-signature .description div {
font-size: 0.9em;
line-height: 1.5em;
margin-left: 1em;
}
.swagger-section .swagger-ui-wrap .model-signature .description .stronger {
font-weight: bold;
color: #000;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper {
border-spacing: 0;
position: absolute;
background-color: #ffffff;
border: 1px solid #bbbbbb;
display: none;
font-size: 11px;
max-width: 400px;
line-height: 30px;
color: black;
padding: 5px;
margin-left: 10px;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper th {
text-align: center;
background-color: #eeeeee;
border: 1px solid #bbbbbb;
font-size: 11px;
color: #666666;
font-weight: bold;
padding: 5px;
line-height: 15px;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper .optionName {
font-weight: bold;
}
.swagger-section .swagger-ui-wrap .model-signature .propName {
font-weight: bold;
}
.swagger-section .swagger-ui-wrap .model-signature .signature-container {
clear: both;
}
.swagger-section .swagger-ui-wrap .body-textarea {
width: 300px;
height: 100px;
border: 1px solid #aaa;
}
.swagger-section .swagger-ui-wrap .markdown p code,
.swagger-section .swagger-ui-wrap .markdown li code {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
background-color: #f0f0f0;
color: black;
padding: 1px 3px;
}
.swagger-section .swagger-ui-wrap .required {
font-weight: bold;
}
.swagger-section .swagger-ui-wrap input.parameter {
width: 300px;
border: 1px solid #aaa;
}
.swagger-section .swagger-ui-wrap h1 {
color: black;
font-size: 1.5em;
line-height: 1.3em;
padding: 10px 0 10px 0;
font-family: "Droid Sans", sans-serif;
font-weight: bold;
}
.swagger-section .swagger-ui-wrap .heading_with_menu {
float: none;
clear: both;
overflow: hidden;
display: block;
}
.swagger-section .swagger-ui-wrap .heading_with_menu ul {
display: block;
clear: none;
float: right;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
margin-top: 10px;
}
.swagger-section .swagger-ui-wrap h2 {
color: black;
font-size: 1.3em;
padding: 10px 0 10px 0;
}
.swagger-section .swagger-ui-wrap h2 a {
color: black;
}
.swagger-section .swagger-ui-wrap h2 span.sub {
font-size: 0.7em;
color: #999999;
font-style: italic;
}
.swagger-section .swagger-ui-wrap h2 span.sub a {
color: #777777;
}
.swagger-section .swagger-ui-wrap span.weak {
color: #666666;
}
.swagger-section .swagger-ui-wrap .message-success {
color: #89BF04;
}
.swagger-section .swagger-ui-wrap caption,
.swagger-section .swagger-ui-wrap th,
.swagger-section .swagger-ui-wrap td {
text-align: left;
font-weight: normal;
vertical-align: middle;
}
.swagger-section .swagger-ui-wrap .code {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.text textarea {
font-family: "Droid Sans", sans-serif;
height: 250px;
padding: 4px;
display: block;
clear: both;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.select select {
display: block;
clear: both;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean {
float: none;
clear: both;
overflow: hidden;
display: block;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean label {
display: block;
float: left;
clear: none;
margin: 0;
padding: 0;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean input {
display: block;
float: left;
clear: none;
margin: 0 5px 0 0;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.required label {
color: black;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li label {
display: block;
clear: both;
width: auto;
padding: 0 0 3px;
color: #666666;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li label abbr {
padding-left: 3px;
color: #888888;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li p.inline-hints {
margin-left: 0;
font-style: italic;
font-size: 0.9em;
margin: 0;
}
.swagger-section .swagger-ui-wrap form.formtastic fieldset.buttons {
margin: 0;
padding: 0;
}
.swagger-section .swagger-ui-wrap span.blank,
.swagger-section .swagger-ui-wrap span.empty {
color: #888888;
font-style: italic;
}
.swagger-section .swagger-ui-wrap .markdown h3 {
color: #547f00;
}
.swagger-section .swagger-ui-wrap .markdown h4 {
color: #666666;
}
.swagger-section .swagger-ui-wrap .markdown pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
background-color: #fcf6db;
border: 1px solid #e5e0c6;
padding: 10px;
margin: 0 0 10px 0;
}
.swagger-section .swagger-ui-wrap .markdown pre code {
line-height: 1.6em;
}
.swagger-section .swagger-ui-wrap div.gist {
margin: 20px 0 25px 0 !important;
}
.swagger-section .swagger-ui-wrap ul#resources {
font-family: "Droid Sans", sans-serif;
font-size: 0.9em;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource {
border-bottom: 1px solid #dddddd;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource:hover div.heading h2 a,
.swagger-section .swagger-ui-wrap ul#resources li.resource.active div.heading h2 a {
color: black;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource:hover div.heading ul.options li a,
.swagger-section .swagger-ui-wrap ul#resources li.resource.active div.heading ul.options li a {
color: #555555;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource:last-child {
border-bottom: none;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading {
border: 1px solid transparent;
float: none;
clear: both;
overflow: hidden;
display: block;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options {
overflow: hidden;
padding: 0;
display: block;
clear: none;
float: right;
margin: 14px 10px 0 0;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li {
float: left;
clear: none;
margin: 0;
padding: 2px 10px;
border-right: 1px solid #dddddd;
color: #666666;
font-size: 0.9em;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a {
color: #aaaaaa;
text-decoration: none;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover {
text-decoration: underline;
color: black;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover,
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:active,
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a.active {
text-decoration: underline;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li:first-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li.first {
padding-left: 0;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li:last-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li.last {
padding-right: 0;
border-right: none;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options:first-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options.first {
padding-left: 0;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
color: #999999;
padding-left: 0;
display: block;
clear: none;
float: left;
font-family: "Droid Sans", sans-serif;
font-weight: bold;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
color: #999999;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
color: black;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0 0 10px;
padding: 0;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading {
float: none;
clear: both;
overflow: hidden;
display: block;
margin: 0;
padding: 0;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 {
display: block;
clear: none;
float: left;
width: auto;
margin: 0;
padding: 0;
line-height: 1.1em;
color: black;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path {
padding-left: 10px;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a {
color: black;
text-decoration: none;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a:hover {
text-decoration: underline;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.http_method a {
text-transform: uppercase;
text-decoration: none;
color: white;
display: inline-block;
width: 50px;
font-size: 0.7em;
text-align: center;
padding: 7px 0 4px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
-o-border-radius: 2px;
-ms-border-radius: 2px;
-khtml-border-radius: 2px;
border-radius: 2px;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span {
margin: 0;
padding: 0;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options {
overflow: hidden;
padding: 0;
display: block;
clear: none;
float: right;
margin: 6px 10px 0 0;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li {
float: left;
clear: none;
margin: 0;
padding: 2px 10px;
font-size: 0.9em;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li a {
text-decoration: none;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li.access {
color: black;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content {
border-top: none;
padding: 10px;
-moz-border-radius-bottomleft: 6px;
-webkit-border-bottom-left-radius: 6px;
-o-border-bottom-left-radius: 6px;
-ms-border-bottom-left-radius: 6px;
-khtml-border-bottom-left-radius: 6px;
border-bottom-left-radius: 6px;
-moz-border-radius-bottomright: 6px;
-webkit-border-bottom-right-radius: 6px;
-o-border-bottom-right-radius: 6px;
-ms-border-bottom-right-radius: 6px;
-khtml-border-bottom-right-radius: 6px;
border-bottom-right-radius: 6px;
margin: 0 0 20px;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content h4 {
font-size: 1.1em;
margin: 0;
padding: 15px 0 5px;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header {
float: none;
clear: both;
overflow: hidden;
display: block;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header a {
padding: 4px 0 0 10px;
display: inline-block;
font-size: 0.9em;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
display: block;
clear: none;
float: left;
padding: 6px 8px;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
background-image: url('../images/throbber.gif');
width: 128px;
height: 16px;
display: block;
clear: none;
float: right;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
outline: 2px solid black;
outline-color: #cc0000;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
padding: 10px;
font-size: 0.9em;
max-height: 400px;
overflow-y: auto;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading {
background-color: #f9f2e9;
border: 1px solid #f0e0ca;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.http_method a {
background-color: #c5862b;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li {
border-right: 1px solid #dddddd;
border-right-color: #f0e0ca;
color: #c5862b;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a {
color: #c5862b;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content {
background-color: #faf5ee;
border: 1px solid #f0e0ca;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content h4 {
color: #c5862b;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a {
color: #dcb67f;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading {
background-color: #fcffcd;
border: 1px solid black;
border-color: #ffd20f;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading h3 span.http_method a {
text-transform: uppercase;
background-color: #ffd20f;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li {
border-right: 1px solid #dddddd;
border-right-color: #ffd20f;
color: #ffd20f;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li a {
color: #ffd20f;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content {
background-color: #fcffcd;
border: 1px solid black;
border-color: #ffd20f;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content h4 {
color: #ffd20f;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content div.sandbox_header a {
color: #6fc992;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading {
background-color: #f5e8e8;
border: 1px solid #e8c6c7;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a {
text-transform: uppercase;
background-color: #a41e22;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li {
border-right: 1px solid #dddddd;
border-right-color: #e8c6c7;
color: #a41e22;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a {
color: #a41e22;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content {
background-color: #f7eded;
border: 1px solid #e8c6c7;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content h4 {
color: #a41e22;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header a {
color: #c8787a;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading {
background-color: #e7f6ec;
border: 1px solid #c3e8d1;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.http_method a {
background-color: #10a54a;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li {
border-right: 1px solid #dddddd;
border-right-color: #c3e8d1;
color: #10a54a;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a {
color: #10a54a;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content {
background-color: #ebf7f0;
border: 1px solid #c3e8d1;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content h4 {
color: #10a54a;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header a {
color: #6fc992;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading {
background-color: #FCE9E3;
border: 1px solid #F5D5C3;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.http_method a {
background-color: #D38042;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li {
border-right: 1px solid #dddddd;
border-right-color: #f0cecb;
color: #D38042;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a {
color: #D38042;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content {
background-color: #faf0ef;
border: 1px solid #f0cecb;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content h4 {
color: #D38042;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header a {
color: #dcb67f;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading {
background-color: #e7f0f7;
border: 1px solid #c3d9ec;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.http_method a {
background-color: #0f6ab4;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li {
border-right: 1px solid #dddddd;
border-right-color: #c3d9ec;
color: #0f6ab4;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a {
color: #0f6ab4;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content {
background-color: #ebf3f9;
border: 1px solid #c3d9ec;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content h4 {
color: #0f6ab4;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a {
color: #6fa5d2;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading {
background-color: #e7f0f7;
border: 1px solid #c3d9ec;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading h3 span.http_method a {
background-color: #0f6ab4;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading ul.options li {
border-right: 1px solid #dddddd;
border-right-color: #c3d9ec;
color: #0f6ab4;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading ul.options li a {
color: #0f6ab4;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content {
background-color: #ebf3f9;
border: 1px solid #c3d9ec;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content h4 {
color: #0f6ab4;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content div.sandbox_header a {
color: #6fa5d2;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content {
border-top: none;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:last-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:last-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li:last-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:last-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li:last-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:last-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.last,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.last,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li.last,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.last,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li.last,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.last {
padding-right: 0;
border-right: none;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:hover,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a.active {
text-decoration: underline;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li:first-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li.first {
padding-left: 0;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations:first-child,
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations.first {
padding-left: 0;
}
.swagger-section .swagger-ui-wrap p#colophon {
margin: 0 15px 40px 15px;
padding: 10px 0;
font-size: 0.8em;
border-top: 1px solid #dddddd;
font-family: "Droid Sans", sans-serif;
color: #999999;
font-style: italic;
}
.swagger-section .swagger-ui-wrap p#colophon a {
text-decoration: none;
color: #547f00;
}
.swagger-section .swagger-ui-wrap h3 {
color: black;
font-size: 1.1em;
padding: 10px 0 10px 0;
}
.swagger-section .swagger-ui-wrap .markdown ol,
.swagger-section .swagger-ui-wrap .markdown ul {
font-family: "Droid Sans", sans-serif;
margin: 5px 0 10px;
padding: 0 0 0 18px;
list-style-type: disc;
}
.swagger-section .swagger-ui-wrap form.form_box {
background-color: #ebf3f9;
border: 1px solid #c3d9ec;
padding: 10px;
}
.swagger-section .swagger-ui-wrap form.form_box label {
color: #0f6ab4 !important;
}
.swagger-section .swagger-ui-wrap form.form_box input[type=submit] {
display: block;
padding: 10px;
}
.swagger-section .swagger-ui-wrap form.form_box p.weak {
font-size: 0.8em;
}
.swagger-section .swagger-ui-wrap form.form_box p {
font-size: 0.9em;
padding: 0 0 15px;
color: #7e7b6d;
}
.swagger-section .swagger-ui-wrap form.form_box p a {
color: #646257;
}
.swagger-section .swagger-ui-wrap form.form_box p strong {
color: black;
}
.swagger-section .title {
font-style: bold;
}
.swagger-section .secondary_form {
display: none;
}
.swagger-section .main_image {
display: block;
margin-left: auto;
margin-right: auto;
}
.swagger-section .oauth_body {
margin-left: 100px;
margin-right: 100px;
}
.swagger-section .oauth_submit {
text-align: center;
}
.swagger-section .api-popup-dialog {
z-index: 10000;
position: absolute;
width: 500px;
background: #FFF;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
display: none;
font-size: 13px;
color: #777;
}
.swagger-section .api-popup-dialog .api-popup-title {
font-size: 24px;
padding: 10px 0;
}
.swagger-section .api-popup-dialog .api-popup-title {
font-size: 24px;
padding: 10px 0;
}
.swagger-section .api-popup-dialog p.error-msg {
padding-left: 5px;
padding-bottom: 5px;
}
.swagger-section .api-popup-dialog button.api-popup-authbtn {
height: 30px;
}
.swagger-section .api-popup-dialog button.api-popup-cancel {
height: 30px;
}
.swagger-section .api-popup-scopes {
padding: 10px 20px;
}
.swagger-section .api-popup-scopes li {
padding: 5px 0;
line-height: 20px;
}
.swagger-section .api-popup-scopes .api-scope-desc {
padding-left: 20px;
font-style: italic;
}
.swagger-section .api-popup-scopes li input {
position: relative;
top: 2px;
}
.swagger-section .api-popup-actions {
padding-top: 10px;
}
.swagger-section .access {
float: right;
}
.swagger-section .auth {
float: right;
}
.swagger-section #api_information_panel {
position: absolute;
background: #FFF;
border: 1px solid #ccc;
border-radius: 5px;
display: none;
font-size: 13px;
max-width: 300px;
line-height: 30px;
color: black;
padding: 5px;
}
.swagger-section #api_information_panel p .api-msg-enabled {
color: green;
}
.swagger-section #api_information_panel p .api-msg-disabled {
color: red;
}
.swagger-section .api-ic {
height: 18px;
vertical-align: middle;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
}
.swagger-section .ic-info {
background-position: 0 0;
width: 18px;
margin-top: -7px;
margin-left: 4px;
}
.swagger-section .ic-warning {
background-position: -60px 0;
width: 18px;
margin-top: -7px;
margin-left: 4px;
}
.swagger-section .ic-error {
background-position: -30px 0;
width: 18px;
margin-top: -7px;
margin-left: 4px;
}
.swagger-section .ic-off {
background-position: -90px 0;
width: 58px;
margin-top: -4px;
cursor: pointer;
}
.swagger-section .ic-on {
background-position: -160px 0;
width: 58px;
margin-top: -4px;
cursor: pointer;
}
.swagger-section #header {
background-color: #89bf04;
padding: 14px;
}
.swagger-section #header a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
}
.swagger-section #header form#api_selector {
display: block;
clear: none;
float: right;
}
.swagger-section #header form#api_selector .input {
display: block;
clear: none;
float: left;
margin: 0 10px 0 0;
}
.swagger-section #header form#api_selector .input input#input_apiKey {
width: 200px;
}
.swagger-section #header form#api_selector .input input#input_baseUrl {
width: 400px;
}
.swagger-section #header form#api_selector .input a#explore {
display: block;
text-decoration: none;
font-weight: bold;
padding: 6px 8px;
font-size: 0.9em;
color: white;
background-color: #547f00;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
}
.swagger-section #header form#api_selector .input a#explore:hover {
background-color: #547f00;
}
.swagger-section #header form#api_selector .input input {
font-size: 0.9em;
padding: 3px;
margin: 0;
}
.swagger-section #content_message {
margin: 10px 15px;
font-style: italic;
color: #999999;
}
.swagger-section #message-bar {
min-height: 30px;
text-align: center;
padding-top: 10px;
}
| {
"pile_set_name": "Github"
} |
#!/usr/bin/env bash
#
#/**
# * Copyright 2007 The Apache Software Foundation
# *
# * Licensed to the Apache Software Foundation (ASF) under one
# * or more contributor license agreements. See the NOTICE file
# * distributed with this work for additional information
# * regarding copyright ownership. The ASF licenses this file
# * to you under the Apache License, Version 2.0 (the
# * "License"); you may not use this file except in compliance
# * with the License. You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */
#
# Run a shell command on all regionserver hosts.
#
# Environment Variables
#
# HBASE_REGIONSERVERS File naming remote hosts.
# Default is ${HADOOP_CONF_DIR}/regionservers
# HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_HOME}/conf.
# HBASE_CONF_DIR Alternate hbase conf dir. Default is ${HBASE_HOME}/conf.
# HADOOP_SLAVE_SLEEP Seconds to sleep between spawning remote commands.
# HADOOP_SSH_OPTS Options passed to ssh when running remote commands.
#
# Modelled after $HADOOP_HOME/bin/slaves.sh.
usage="Usage: regionservers [--config <hbase-confdir>] command..."
# if no args specified, show usage
if [ $# -le 0 ]; then
echo $usage
exit 1
fi
bin=`dirname "${BASH_SOURCE-$0}"`
bin=`cd "$bin">/dev/null; pwd`
. "$bin"/hbase-config.sh
# If the regionservers file is specified in the command line,
# then it takes precedence over the definition in
# hbase-env.sh. Save it here.
HOSTLIST=$HBASE_REGIONSERVERS
if [ "$HOSTLIST" = "" ]; then
if [ "$HBASE_REGIONSERVERS" = "" ]; then
export HOSTLIST="${HBASE_CONF_DIR}/regionservers"
else
export HOSTLIST="${HBASE_REGIONSERVERS}"
fi
fi
for regionserver in `cat "$HOSTLIST"`; do
if ${HBASE_SLAVE_PARALLEL:-true}; then
ssh $HBASE_SSH_OPTS $regionserver $"${@// /\\ }" \
2>&1 | sed "s/^/$regionserver: /" &
else # run each command serially
ssh $HBASE_SSH_OPTS $regionserver $"${@// /\\ }" \
2>&1 | sed "s/^/$regionserver: /"
fi
if [ "$HBASE_SLAVE_SLEEP" != "" ]; then
sleep $HBASE_SLAVE_SLEEP
fi
done
wait
| {
"pile_set_name": "Github"
} |
package com.gentics.mesh.core.console;
import java.io.IOException;
import java.io.InputStream;
/**
* Provider for console specific interactions. (e.g. Read Input, Password etc)
*/
public interface ConsoleProvider {
/**
* Read next byte from console.
*
* @see {@link InputStream#read()}
* @return the next byte of data, or -1 if the end of the stream is reached.
* @throws IOException
*/
int read() throws IOException;
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2019 Simon Edwards <[email protected]>
*
* This source code is licensed under the MIT license which is detailed in the LICENSE.txt file.
*/
export interface Rectangle {
x: number;
y: number;
width: number;
height: number;
}
export function rectangleIntersection(rect1: Rectangle, rect2: Rectangle): Rectangle {
const rect1x2 = rect1.x + rect1.width;
const rect1y2 = rect1.y + rect1.height;
const rect2x2 = rect2.x + rect2.width;
const rect2y2 = rect2.y + rect2.height;
const intersectionX1 = Math.max(rect1.x, rect2.x);
const intersectionY1 = Math.max(rect1.y, rect2.y);
const intersectionX2 = Math.min(rect1x2, rect2x2);
const intersectionY2 = Math.min(rect1y2, rect2y2);
const result: Rectangle = {
x: intersectionX1,
y: intersectionY1,
width: Math.max(0, intersectionX2 - intersectionX1),
height: Math.max(0, intersectionY2 - intersectionY1),
};
return result;
}
export function bestOverlap(primaryRect: Rectangle, candidateRects: Rectangle[]): number {
let bestArea = -1;
let bestRectIndex = -1;
let i = 0;
for (const rect of candidateRects) {
const intersectionRect = rectangleIntersection(primaryRect, rect);
const area = intersectionRect.width * intersectionRect.height;
if (area !== 0 && area > bestArea) {
bestRectIndex = i;
bestArea = area;
}
i++;
}
return bestRectIndex;
}
| {
"pile_set_name": "Github"
} |
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Recipes.DbConnector.Models;
using Recipes.RowCount;
namespace Recipes.DbConnector.RowCount
{
[TestClass]
public class RowCountTests : RowCountTests<EmployeeSimple>
{
protected override IRowCountScenario<EmployeeSimple> GetScenario()
{
return new RowCountScenario(Setup.SqlServerConnectionString);
}
}
}
| {
"pile_set_name": "Github"
} |
config HFSPLUS_FS
tristate "Apple Extended HFS file system support"
depends on BLOCK
select NLS
select NLS_UTF8
help
If you say Y here, you will be able to mount extended format
Macintosh-formatted hard drive partitions with full read-write access.
This file system is often called HFS+ and was introduced with
MacOS 8. It includes all Mac specific filesystem data such as
data forks and creator codes, but it also has several UNIX
style features such as file ownership and permissions.
config HFSPLUS_FS_POSIX_ACL
bool "HFS+ POSIX Access Control Lists"
depends on HFSPLUS_FS
select FS_POSIX_ACL
help
POSIX Access Control Lists (ACLs) support permissions for users and
groups beyond the owner/group/world scheme.
To learn more about Access Control Lists, visit the POSIX ACLs for
Linux website <http://acl.bestbits.at/>.
It needs to understand that POSIX ACLs are treated only under
Linux. POSIX ACLs doesn't mean something under Mac OS X.
Mac OS X beginning with version 10.4 ("Tiger") support NFSv4 ACLs,
which are part of the NFSv4 standard.
If you don't know what Access Control Lists are, say N
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2013 Qualcomm Atheros, Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef SPECTRAL_COMMON_H
#define SPECTRAL_COMMON_H
#define SPECTRAL_HT20_NUM_BINS 56
#define SPECTRAL_HT20_40_NUM_BINS 128
/* TODO: could possibly be 512, but no samples this large
* could be acquired so far.
*/
#define SPECTRAL_ATH10K_MAX_NUM_BINS 256
/* FFT sample format given to userspace via debugfs.
*
* Please keep the type/length at the front position and change
* other fields after adding another sample type
*
* TODO: this might need rework when switching to nl80211-based
* interface.
*/
enum ath_fft_sample_type {
ATH_FFT_SAMPLE_HT20 = 1,
ATH_FFT_SAMPLE_HT20_40,
ATH_FFT_SAMPLE_ATH10K,
};
struct fft_sample_tlv {
u8 type; /* see ath_fft_sample */
__be16 length;
/* type dependent data follows */
} __packed;
struct fft_sample_ht20 {
struct fft_sample_tlv tlv;
u8 max_exp;
__be16 freq;
s8 rssi;
s8 noise;
__be16 max_magnitude;
u8 max_index;
u8 bitmap_weight;
__be64 tsf;
u8 data[SPECTRAL_HT20_NUM_BINS];
} __packed;
struct fft_sample_ht20_40 {
struct fft_sample_tlv tlv;
u8 channel_type;
__be16 freq;
s8 lower_rssi;
s8 upper_rssi;
__be64 tsf;
s8 lower_noise;
s8 upper_noise;
__be16 lower_max_magnitude;
__be16 upper_max_magnitude;
u8 lower_max_index;
u8 upper_max_index;
u8 lower_bitmap_weight;
u8 upper_bitmap_weight;
u8 max_exp;
u8 data[SPECTRAL_HT20_40_NUM_BINS];
} __packed;
struct fft_sample_ath10k {
struct fft_sample_tlv tlv;
u8 chan_width_mhz;
__be16 freq1;
__be16 freq2;
__be16 noise;
__be16 max_magnitude;
__be16 total_gain_db;
__be16 base_pwr_db;
__be64 tsf;
s8 max_index;
u8 rssi;
u8 relpwr_db;
u8 avgpwr_db;
u8 max_exp;
u8 data[0];
} __packed;
#endif /* SPECTRAL_COMMON_H */
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<web-fragment xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"
version="3.0">
<name>webFragment2</name>
<listener>
<listener-class>webFragment2.WebFragmentServletContextListener</listener-class>
</listener>
</web-fragment>
| {
"pile_set_name": "Github"
} |
<!--
doc/src/sgml/ref/delete.sgml
PostgreSQL documentation
-->
<refentry id="sql-delete">
<indexterm zone="sql-delete">
<primary>DELETE</primary>
</indexterm>
<refmeta>
<refentrytitle>DELETE</refentrytitle>
<manvolnum>7</manvolnum>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>DELETE</refname>
<refpurpose>delete rows of a table</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
[ WITH [ RECURSIVE ] <replaceable class="parameter">with_query</replaceable> [, ...] ]
DELETE FROM [ ONLY ] <replaceable class="parameter">table_name</replaceable> [ * ] [ [ AS ] <replaceable class="parameter">alias</replaceable> ]
[ USING <replaceable class="parameter">from_item</replaceable> [, ...] ]
[ WHERE <replaceable class="parameter">condition</replaceable> | WHERE CURRENT OF <replaceable class="parameter">cursor_name</replaceable> ]
[ RETURNING * | <replaceable class="parameter">output_expression</replaceable> [ [ AS ] <replaceable class="parameter">output_name</replaceable> ] [, ...] ]
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>DELETE</command> deletes rows that satisfy the
<literal>WHERE</literal> clause from the specified table. If the
<literal>WHERE</literal> clause is absent, the effect is to delete
all rows in the table. The result is a valid, but empty table.
</para>
<tip>
<para>
<xref linkend="sql-truncate"/> provides a
faster mechanism to remove all rows from a table.
</para>
</tip>
<para>
There are two ways to delete rows in a table using information
contained in other tables in the database: using sub-selects, or
specifying additional tables in the <literal>USING</literal> clause.
Which technique is more appropriate depends on the specific
circumstances.
</para>
<para>
The optional <literal>RETURNING</literal> clause causes <command>DELETE</command>
to compute and return value(s) based on each row actually deleted.
Any expression using the table's columns, and/or columns of other
tables mentioned in <literal>USING</literal>, can be computed.
The syntax of the <literal>RETURNING</literal> list is identical to that of the
output list of <command>SELECT</command>.
</para>
<para>
You must have the <literal>DELETE</literal> privilege on the table
to delete from it, as well as the <literal>SELECT</literal>
privilege for any table in the <literal>USING</literal> clause or
whose values are read in the <replaceable
class="parameter">condition</replaceable>.
</para>
</refsect1>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term><replaceable class="parameter">with_query</replaceable></term>
<listitem>
<para>
The <literal>WITH</literal> clause allows you to specify one or more
subqueries that can be referenced by name in the <command>DELETE</command>
query. See <xref linkend="queries-with"/> and <xref linkend="sql-select"/>
for details.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">table_name</replaceable></term>
<listitem>
<para>
The name (optionally schema-qualified) of the table to delete rows
from. If <literal>ONLY</literal> is specified before the table name,
matching rows are deleted from the named table only. If
<literal>ONLY</literal> is not specified, matching rows are also deleted
from any tables inheriting from the named table. Optionally,
<literal>*</literal> can be specified after the table name to explicitly
indicate that descendant tables are included.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">alias</replaceable></term>
<listitem>
<para>
A substitute name for the target table. When an alias is
provided, it completely hides the actual name of the table. For
example, given <literal>DELETE FROM foo AS f</literal>, the remainder
of the <command>DELETE</command> statement must refer to this
table as <literal>f</literal> not <literal>foo</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">from_item</replaceable></term>
<listitem>
<para>
A table expression allowing columns from other tables to appear
in the <literal>WHERE</literal> condition. This uses the same
syntax as the <link linkend="sql-from"><literal>FROM</literal></link>
clause of a <command>SELECT</command> statement; for example, an alias
for the table name can be specified. Do not repeat the target
table as a <replaceable class="parameter">from_item</replaceable>
unless you wish to set up a self-join (in which case it must appear
with an alias in the <replaceable>from_item</replaceable>).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">condition</replaceable></term>
<listitem>
<para>
An expression that returns a value of type <type>boolean</type>.
Only rows for which this expression returns <literal>true</literal>
will be deleted.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">cursor_name</replaceable></term>
<listitem>
<para>
The name of the cursor to use in a <literal>WHERE CURRENT OF</literal>
condition. The row to be deleted is the one most recently fetched
from this cursor. The cursor must be a non-grouping
query on the <command>DELETE</command>'s target table.
Note that <literal>WHERE CURRENT OF</literal> cannot be
specified together with a Boolean condition. See
<xref linkend="sql-declare"/>
for more information about using cursors with
<literal>WHERE CURRENT OF</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">output_expression</replaceable></term>
<listitem>
<para>
An expression to be computed and returned by the <command>DELETE</command>
command after each row is deleted. The expression can use any
column names of the table named by <replaceable class="parameter">table_name</replaceable>
or table(s) listed in <literal>USING</literal>.
Write <literal>*</literal> to return all columns.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">output_name</replaceable></term>
<listitem>
<para>
A name to use for a returned column.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Outputs</title>
<para>
On successful completion, a <command>DELETE</command> command returns a command
tag of the form
<screen>
DELETE <replaceable class="parameter">count</replaceable>
</screen>
The <replaceable class="parameter">count</replaceable> is the number
of rows deleted. Note that the number may be less than the number of
rows that matched the <replaceable
class="parameter">condition</replaceable> when deletes were
suppressed by a <literal>BEFORE DELETE</literal> trigger. If <replaceable
class="parameter">count</replaceable> is 0, no rows were deleted by
the query (this is not considered an error).
</para>
<para>
If the <command>DELETE</command> command contains a <literal>RETURNING</literal>
clause, the result will be similar to that of a <command>SELECT</command>
statement containing the columns and values defined in the
<literal>RETURNING</literal> list, computed over the row(s) deleted by the
command.
</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
<productname>PostgreSQL</productname> lets you reference columns of
other tables in the <literal>WHERE</literal> condition by specifying the
other tables in the <literal>USING</literal> clause. For example,
to delete all films produced by a given producer, one can do:
<programlisting>
DELETE FROM films USING producers
WHERE producer_id = producers.id AND producers.name = 'foo';
</programlisting>
What is essentially happening here is a join between <structname>films</structname>
and <structname>producers</structname>, with all successfully joined
<structname>films</structname> rows being marked for deletion.
This syntax is not standard. A more standard way to do it is:
<programlisting>
DELETE FROM films
WHERE producer_id IN (SELECT id FROM producers WHERE name = 'foo');
</programlisting>
In some cases the join style is easier to write or faster to
execute than the sub-select style.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>
Delete all films but musicals:
<programlisting>
DELETE FROM films WHERE kind <> 'Musical';
</programlisting>
</para>
<para>
Clear the table <literal>films</literal>:
<programlisting>
DELETE FROM films;
</programlisting>
</para>
<para>
Delete completed tasks, returning full details of the deleted rows:
<programlisting>
DELETE FROM tasks WHERE status = 'DONE' RETURNING *;
</programlisting>
</para>
<para>
Delete the row of <structname>tasks</structname> on which the cursor
<literal>c_tasks</literal> is currently positioned:
<programlisting>
DELETE FROM tasks WHERE CURRENT OF c_tasks;
</programlisting></para>
</refsect1>
<refsect1>
<title>Compatibility</title>
<para>
This command conforms to the <acronym>SQL</acronym> standard, except
that the <literal>USING</literal> and <literal>RETURNING</literal> clauses
are <productname>PostgreSQL</productname> extensions, as is the ability
to use <literal>WITH</literal> with <command>DELETE</command>.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-truncate"/></member>
</simplelist>
</refsect1>
</refentry>
| {
"pile_set_name": "Github"
} |
/****************************************************************************
* *
* cryptlib SSHv2 Channel Management *
* Copyright Peter Gutmann 1998-2008 *
* *
****************************************************************************/
#if defined( INC_ALL )
#include "crypt.h"
#include "misc_rw.h"
#include "session.h"
#include "ssh.h"
#else
#include "crypt.h"
#include "enc_dec/misc_rw.h"
#include "session/session.h"
#include "session/ssh.h"
#endif /* Compiler-specific includes */
/* Channel flags */
#define CHANNEL_FLAG_NONE 0x00 /* No channel flag */
#define CHANNEL_FLAG_ACTIVE 0x01 /* Channel is active */
#define CHANNEL_FLAG_WRITECLOSED 0x02 /* Write-side of ch.closed */
/* Per-channel information. SSH channel IDs are 32-bit/4 byte data values
and can be reused during sessions so we provide our own guaranteed-unique
short int ID for users to identify a particular channel. Since each
channel can have its own distinct characteristics we have to record
information like the window size and count and packet size information on
a per-channel basis. In addition if the channel is tied to a forwarded
port we also record port-forwarding information in the generic channel-
type and channel-type-argument strings */
typedef struct {
/* General channel information. The read and write channel numbers are
the same for everything but Cisco software */
int channelID; /* cryptlib-level channel ID */
long readChannelNo, writeChannelNo; /* SSH-level channel ID */
int flags; /* Channel flags */
/* External interface information */
CRYPT_ATTRIBUTE_TYPE cursorPos; /* Virtual cursor position */
/* Channel parameters */
int windowCount, windowSize; /* Current window usage and tot.size */
int maxPacketSize; /* Max allowed packet size */
/* Channel naming information */
BUFFER( CRYPT_MAX_TEXTSIZE, typeLen ) \
char type[ CRYPT_MAX_TEXTSIZE + 8 ];
BUFFER( CRYPT_MAX_TEXTSIZE, arg1Len ) \
char arg1[ CRYPT_MAX_TEXTSIZE + 8 ];
BUFFER( CRYPT_MAX_TEXTSIZE, arg2Len ) \
char arg2[ CRYPT_MAX_TEXTSIZE + 8 ];
int typeLen, arg1Len, arg2Len;
/* Channel extra data. This contains encoded oddball protocol-specific
SSH packets to be sent or having been received */
BUFFER_FIXED( UINT_SIZE + CRYPT_MAX_TEXTSIZE + ( UINT_SIZE * 4 ) ) \
BYTE extraData[ ( UINT_SIZE + CRYPT_MAX_TEXTSIZE ) + \
( UINT_SIZE * 4 ) + 8 ];
} SSH_CHANNEL_INFO;
/* Check whether a channel corresponds to a null channel (a placeholder used
when there's currently no channel active) and whether a channel is
currently active */
#define isNullChannel( channelInfoPtr ) \
( ( channelInfoPtr )->readChannelNo == UNUSED_CHANNEL_NO )
#define isActiveChannel( channelInfoPtr ) \
( channelInfoPtr->flags & CHANNEL_FLAG_ACTIVE )
/* The maximum allowed number of channels */
#ifdef USE_SSH_EXTENDED
#define SSH_MAX_CHANNELS 4
#else
#define SSH_MAX_CHANNELS 1
#endif /* USE_SSH_EXTENDED */
#ifdef USE_SSH
/****************************************************************************
* *
* Utility Functions *
* *
****************************************************************************/
/* Check whether there are any active channels still present. Since a
channel can be half-closed (we've closed it for write but the other
side hasn't acknowledged the close yet) we allow the caller to specify
an excluded channel ID that's treated as logically closed for active
channel-check purposes even if a channel entry is still present for it.
This can also be used when closing channels to check whether this is the
last channel open, since closing the last channel also shuts down the
entire session */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
static BOOLEAN isChannelActive( const SESSION_INFO *sessionInfoPtr,
IN_INT_SHORT_Z const int excludedChannelID )
{
ATTRIBUTE_LIST *attributeListPtr;
int iterationCount;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES_B( ( excludedChannelID == UNUSED_CHANNEL_ID ) || \
( excludedChannelID > 0 && \
excludedChannelID < MAX_INTLENGTH_SHORT ) );
for( attributeListPtr = sessionInfoPtr->attributeList, \
iterationCount = 0;
attributeListPtr != NULL && \
iterationCount < FAILSAFE_ITERATIONS_MAX;
attributeListPtr = attributeListPtr->next, iterationCount++ )
{
const SSH_CHANNEL_INFO *channelInfoPtr;
/* If it's not an SSH channel, continue */
if( attributeListPtr->attributeID != CRYPT_SESSINFO_SSH_CHANNEL )
continue;
/* It's an SSH channel, check whether it's the one that we're
after */
ENSURES( attributeListPtr->valueLength == sizeof( SSH_CHANNEL_INFO ) );
channelInfoPtr = attributeListPtr->value;
if( isActiveChannel( channelInfoPtr ) && \
channelInfoPtr->channelID != excludedChannelID )
return( TRUE );
}
ENSURES_B( iterationCount < FAILSAFE_ITERATIONS_MAX );
return( FALSE );
}
/* Helper function used to access SSH-specific internal attributes within
an attribute group (== single attribute-list item containing multiple
sub-items). Returns the attribute ID of the currently selected attribute
when attrGetType == ATTR_CURRENT, otherwise a boolean indicating whether
ATTR_PREV/ATTR_NEXT is still within the current subgroup */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3 ) ) \
static int accessFunction( INOUT ATTRIBUTE_LIST *attributeListPtr,
IN_ENUM_OPT( ATTR ) const ATTR_TYPE attrGetType,
OUT_INT_Z int *value )
{
static const CRYPT_ATTRIBUTE_TYPE attributeOrderList[] = {
CRYPT_SESSINFO_SSH_CHANNEL, CRYPT_SESSINFO_SSH_CHANNEL_TYPE,
CRYPT_SESSINFO_SSH_CHANNEL_ARG1, CRYPT_SESSINFO_SSH_CHANNEL_ARG2,
CRYPT_SESSINFO_SSH_CHANNEL_ACTIVE, CRYPT_ATTRIBUTE_NONE,
CRYPT_ATTRIBUTE_NONE };
SSH_CHANNEL_INFO *channelInfoPtr = attributeListPtr->value;
CRYPT_ATTRIBUTE_TYPE attributeType = channelInfoPtr->cursorPos;
BOOLEAN doContinue;
int iterationCount;
assert( isWritePtr( attributeListPtr, sizeof( ATTRIBUTE_LIST ) ) );
assert( isWritePtr( value, sizeof( int ) ) );
REQUIRES( attrGetType >= ATTR_NONE && attrGetType < ATTR_LAST );
/* Clear return value */
*value = 0;
/* If we've just moved the cursor onto this attribute, reset the
position to the first internal attribute */
if( attributeListPtr->flags & ATTR_FLAG_CURSORMOVED )
{
attributeType = channelInfoPtr->cursorPos = \
CRYPT_SESSINFO_SSH_CHANNEL;
attributeListPtr->flags &= ~ATTR_FLAG_CURSORMOVED;
}
/* If it's an information fetch, return the currently-selected
attribute */
if( attrGetType == ATTR_NONE )
{
*value = attributeType;
return( CRYPT_OK );
}
for( doContinue = TRUE, iterationCount = 0;
doContinue && iterationCount < FAILSAFE_ITERATIONS_MED;
iterationCount++ )
{
int orderIndex;
/* Find the position of the current sub-attribute in the attribute
order list and use that to get its successor/predecessor sub-
attribute */
for( orderIndex = 0;
attributeOrderList[ orderIndex ] != attributeType && \
attributeOrderList[ orderIndex ] != CRYPT_ATTRIBUTE_NONE && \
orderIndex < FAILSAFE_ARRAYSIZE( attributeOrderList, \
CRYPT_ATTRIBUTE_TYPE );
orderIndex++ );
ENSURES( orderIndex < FAILSAFE_ARRAYSIZE( attributeOrderList, \
CRYPT_ATTRIBUTE_TYPE ) );
if( attributeOrderList[ orderIndex ] == CRYPT_ATTRIBUTE_NONE )
{
/* We've reached the first/last sub-attribute within the current
item/group, tell the caller that there are no more sub-
attributes present and they have to move on to the next item/
group */
*value = FALSE;
return( CRYPT_OK );
}
if( attrGetType == ATTR_PREV )
{
attributeType = ( orderIndex <= 0 ) ? \
CRYPT_ATTRIBUTE_NONE : \
attributeOrderList[ orderIndex - 1 ];
}
else
attributeType = attributeOrderList[ orderIndex + 1 ];
if( attributeType == CRYPT_ATTRIBUTE_NONE )
{
/* We've reached the first/last sub-attribute within the current
item/group, exit as before */
*value = FALSE;
return( CRYPT_OK );
}
/* Check whether the required sub-attribute is present. If not, we
continue and try the next one */
switch( attributeType )
{
case CRYPT_SESSINFO_SSH_CHANNEL:
case CRYPT_SESSINFO_SSH_CHANNEL_TYPE:
case CRYPT_SESSINFO_SSH_CHANNEL_ACTIVE:
doContinue = FALSE; /* Always present */
break;
case CRYPT_SESSINFO_SSH_CHANNEL_ARG1:
if( channelInfoPtr->arg1Len > 0 )
doContinue = FALSE;
break;
case CRYPT_SESSINFO_SSH_CHANNEL_ARG2:
if( channelInfoPtr->arg2Len > 0 )
doContinue = FALSE;
break;
default:
retIntError();
}
}
ENSURES( iterationCount < FAILSAFE_ITERATIONS_MED );
channelInfoPtr->cursorPos = attributeType;
*value = TRUE;
return( CRYPT_OK );
}
/****************************************************************************
* *
* Find Channel Information *
* *
****************************************************************************/
/* Find the attribute entry for a channel */
CHECK_RETVAL_PTR STDC_NONNULL_ARG( ( 1 ) ) \
static ATTRIBUTE_LIST *findChannelAttr( const SESSION_INFO *sessionInfoPtr,
IN const long channelNo )
{
ATTRIBUTE_LIST *attributeListPtr;
int iterationCount;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES_N( ( channelNo == CRYPT_USE_DEFAULT ) || \
( channelNo >= 0 && channelNo <= LONG_MAX ) );
for( attributeListPtr = sessionInfoPtr->attributeList, \
iterationCount = 0;
attributeListPtr != NULL && \
iterationCount < FAILSAFE_ITERATIONS_MAX;
attributeListPtr = attributeListPtr->next, iterationCount++ )
{
const SSH_CHANNEL_INFO *channelInfoPtr;
/* If it's not an SSH channel, continue */
if( attributeListPtr->attributeID != CRYPT_SESSINFO_SSH_CHANNEL )
continue;
/* It's an SSH channel, check whether it's the one that we're
after */
ENSURES_N( attributeListPtr->valueLength == sizeof( SSH_CHANNEL_INFO ) );
channelInfoPtr = attributeListPtr->value;
if( channelNo == CRYPT_USE_DEFAULT )
{
/* We're looking for any open channel channel, return the first
match */
if( channelInfoPtr->flags & CHANNEL_FLAG_WRITECLOSED )
continue;
return( attributeListPtr );
}
if( channelInfoPtr->readChannelNo == channelNo || \
channelInfoPtr->writeChannelNo == channelNo )
return( attributeListPtr );
}
ENSURES_N( iterationCount < FAILSAFE_ITERATIONS_MAX );
return( NULL );
}
/* Find the SSH channel information for a channel, matching by channel
number, channel ID, and channel host + port information */
CHECK_RETVAL_PTR STDC_NONNULL_ARG( ( 1 ) ) \
static SSH_CHANNEL_INFO *findChannelByChannelNo( const SESSION_INFO *sessionInfoPtr,
IN const long channelNo )
{
const ATTRIBUTE_LIST *attributeListPtr = \
findChannelAttr( sessionInfoPtr, channelNo );
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES_N( ( channelNo == CRYPT_USE_DEFAULT ) || \
( channelNo >= 0 && channelNo <= LONG_MAX ) );
return( ( attributeListPtr == NULL ) ? NULL : attributeListPtr->value );
}
CHECK_RETVAL_PTR STDC_NONNULL_ARG( ( 1 ) ) \
static SSH_CHANNEL_INFO *findChannelByID( const SESSION_INFO *sessionInfoPtr,
IN_INT_SHORT const int channelID )
{
ATTRIBUTE_LIST *attributeListPtr;
int iterationCount;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES_N( channelID > 0 && channelID < MAX_INTLENGTH_SHORT );
for( attributeListPtr = sessionInfoPtr->attributeList, \
iterationCount = 0;
attributeListPtr != NULL && \
iterationCount < FAILSAFE_ITERATIONS_MAX;
attributeListPtr = attributeListPtr->next, iterationCount++ )
{
const SSH_CHANNEL_INFO *channelInfoPtr;
/* If it's not an SSH channel, continue */
if( attributeListPtr->attributeID != CRYPT_SESSINFO_SSH_CHANNEL )
continue;
/* It's an SSH channel, check whether it's the that one we're
after */
ENSURES_N( attributeListPtr->valueLength == sizeof( SSH_CHANNEL_INFO ) );
channelInfoPtr = attributeListPtr->value;
if( channelInfoPtr->channelID == channelID )
return( ( SSH_CHANNEL_INFO * ) channelInfoPtr );
}
ENSURES_N( iterationCount < FAILSAFE_ITERATIONS_MAX );
return( NULL );
}
CHECK_RETVAL_PTR STDC_NONNULL_ARG( ( 1, 2 ) ) \
static SSH_CHANNEL_INFO *findChannelByAddr( const SESSION_INFO *sessionInfoPtr,
IN_BUFFER( addrInfoLen ) \
const char *addrInfo,
IN_LENGTH_SHORT \
const int addrInfoLen )
{
ATTRIBUTE_LIST *attributeListPtr;
int iterationCount;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isReadPtr( addrInfo, addrInfoLen ) );
REQUIRES_N( addrInfoLen > 0 && addrInfoLen < MAX_INTLENGTH_SHORT );
for( attributeListPtr = sessionInfoPtr->attributeList, \
iterationCount = 0;
attributeListPtr != NULL && \
iterationCount < FAILSAFE_ITERATIONS_MAX;
attributeListPtr = attributeListPtr->next, iterationCount++ )
{
const SSH_CHANNEL_INFO *channelInfoPtr;
/* If it's not an SSH channel, continue */
if( attributeListPtr->attributeID != CRYPT_SESSINFO_SSH_CHANNEL )
continue;
/* It's an SSH channel, check whether it's the one that we're
after */
ENSURES_N( attributeListPtr->valueLength == sizeof( SSH_CHANNEL_INFO ) );
channelInfoPtr = attributeListPtr->value;
if( channelInfoPtr->arg1Len == addrInfoLen && \
!memcmp( channelInfoPtr->arg1, addrInfo, addrInfoLen ) )
return( ( SSH_CHANNEL_INFO * ) channelInfoPtr );
}
ENSURES_N( iterationCount < FAILSAFE_ITERATIONS_MAX );
return( NULL );
}
CHECK_RETVAL_PTR STDC_NONNULL_ARG( ( 1 ) ) \
static const SSH_CHANNEL_INFO *getCurrentChannelInfo( const SESSION_INFO *sessionInfoPtr,
IN_ENUM( CHANNEL ) \
const CHANNEL_TYPE channelType )
{
static const SSH_CHANNEL_INFO nullChannel = \
{ UNUSED_CHANNEL_ID, UNUSED_CHANNEL_NO, UNUSED_CHANNEL_NO,
CHANNEL_FLAG_NONE, CRYPT_ATTRIBUTE_NONE, 0 /*...*/ };
SSH_INFO *sshInfo = sessionInfoPtr->sessionSSH;
const SSH_CHANNEL_INFO *channelInfoPtr;
const int channelID = ( channelType == CHANNEL_READ ) ? \
sshInfo->currReadChannel : \
sshInfo->currWriteChannel;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES_N( channelType > CHANNEL_NONE && \
channelType < CHANNEL_LAST );
/* If there's no channel open yet, return the null channel */
if( channelID == UNUSED_CHANNEL_ID )
return( ( SSH_CHANNEL_INFO * ) &nullChannel );
channelInfoPtr = findChannelByID( sessionInfoPtr,
( channelType == CHANNEL_READ ) ? \
sshInfo->currReadChannel : \
sshInfo->currWriteChannel );
return( ( channelInfoPtr == NULL ) ? \
( SSH_CHANNEL_INFO * ) &nullChannel : channelInfoPtr );
}
/****************************************************************************
* *
* Get/Set Channel Information *
* *
****************************************************************************/
/* Get the currently active channel */
CHECK_RETVAL_RANGE( 1, LONG_MAX ) STDC_NONNULL_ARG( ( 1 ) ) \
long getCurrentChannelNo( const SESSION_INFO *sessionInfoPtr,
IN_ENUM( CHANNEL ) const CHANNEL_TYPE channelType )
{
const SSH_CHANNEL_INFO *channelInfoPtr = \
getCurrentChannelInfo( sessionInfoPtr, channelType );
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES( channelType == CHANNEL_READ || channelType == CHANNEL_WRITE );
REQUIRES( channelInfoPtr != NULL );
return( ( channelType == CHANNEL_READ ) ? \
channelInfoPtr->readChannelNo : channelInfoPtr->writeChannelNo );
}
/* Get/set an attribute or SSH-specific internal attribute from/for the
current channel */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int getChannelAttribute( const SESSION_INFO *sessionInfoPtr,
IN_ATTRIBUTE const CRYPT_ATTRIBUTE_TYPE attribute,
OUT_INT_Z int *value )
{
const SSH_CHANNEL_INFO *channelInfoPtr = \
getCurrentChannelInfo( sessionInfoPtr, CHANNEL_READ );
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isWritePtr( value, sizeof( int ) ) );
REQUIRES( isAttribute( attribute ) );
REQUIRES( channelInfoPtr != NULL );
/* Clear return values */
*value = 0;
if( isNullChannel( channelInfoPtr ) )
return( CRYPT_ERROR_NOTFOUND );
switch( attribute )
{
case CRYPT_SESSINFO_SSH_CHANNEL:
*value = channelInfoPtr->channelID;
return( CRYPT_OK );
case CRYPT_SESSINFO_SSH_CHANNEL_ACTIVE:
*value = isActiveChannel( channelInfoPtr ) ? TRUE : FALSE;
return( CRYPT_OK );
}
retIntError();
}
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int getChannelAttributeS( const SESSION_INFO *sessionInfoPtr,
IN_ATTRIBUTE const CRYPT_ATTRIBUTE_TYPE attribute,
OUT_BUFFER_OPT( dataMaxLength, *dataLength ) \
void *data,
IN_LENGTH_SHORT_Z const int dataMaxLength,
OUT_LENGTH_SHORT_Z int *dataLength )
{
const SSH_CHANNEL_INFO *channelInfoPtr = \
getCurrentChannelInfo( sessionInfoPtr, CHANNEL_READ );
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( ( data == NULL && dataMaxLength == 0 ) || \
isWritePtr( data, dataMaxLength ) );
assert( isWritePtr( dataLength, sizeof( int ) ) );
REQUIRES( isAttribute( attribute ) );
REQUIRES( ( data == NULL && dataMaxLength == 0 ) || \
( data != NULL && \
dataMaxLength > 0 && \
dataMaxLength < MAX_INTLENGTH_SHORT ) );
REQUIRES( channelInfoPtr != NULL );
/* Clear return values */
if( data != NULL )
memset( data, 0, min( 16, dataMaxLength ) );
*dataLength = 0;
if( isNullChannel( channelInfoPtr ) )
return( CRYPT_ERROR_NOTFOUND );
switch( attribute )
{
case CRYPT_SESSINFO_SSH_CHANNEL_TYPE:
return( attributeCopyParams( data, dataMaxLength, dataLength,
channelInfoPtr->type,
channelInfoPtr->typeLen ) );
case CRYPT_SESSINFO_SSH_CHANNEL_ARG1:
return( attributeCopyParams( data, dataMaxLength, dataLength,
channelInfoPtr->arg1,
channelInfoPtr->arg1Len ) );
case CRYPT_SESSINFO_SSH_CHANNEL_ARG2:
return( attributeCopyParams( data, dataMaxLength, dataLength,
channelInfoPtr->arg2,
channelInfoPtr->arg2Len ) );
}
retIntError();
}
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int getChannelExtAttribute( const SESSION_INFO *sessionInfoPtr,
IN_ENUM( SSH_ATTRIBUTE ) \
const SSH_ATTRIBUTE_TYPE attribute,
OUT_INT_Z int *value )
{
const SSH_CHANNEL_INFO *channelInfoPtr = \
getCurrentChannelInfo( sessionInfoPtr, CHANNEL_READ );
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isWritePtr( value, sizeof( int ) ) );
REQUIRES( isAttribute( attribute ) );
REQUIRES( channelInfoPtr != NULL );
/* Clear return value */
*value = 0;
if( isNullChannel( channelInfoPtr ) )
return( CRYPT_ERROR_NOTFOUND );
switch( attribute )
{
case SSH_ATTRIBUTE_WINDOWCOUNT:
*value = channelInfoPtr->windowCount;
return( CRYPT_OK );
case SSH_ATTRIBUTE_WINDOWSIZE:
*value = channelInfoPtr->windowSize;
return( CRYPT_OK );
}
retIntError();
}
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int setChannelAttribute( INOUT SESSION_INFO *sessionInfoPtr,
IN_ATTRIBUTE const CRYPT_ATTRIBUTE_TYPE attribute,
IN_INT_SHORT const int value )
{
SSH_CHANNEL_INFO *channelInfoPtr;
assert( isWritePtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES( isAttribute( attribute ) );
REQUIRES( value > 0 && value < MAX_INTLENGTH_SHORT );
/* If we're setting the channel ID this doesn't change any channel
attribute but selects the one with the given ID */
if( attribute == CRYPT_SESSINFO_SSH_CHANNEL )
{
channelInfoPtr = findChannelByID( sessionInfoPtr, value );
if( channelInfoPtr == NULL )
return( CRYPT_ERROR_NOTFOUND );
return( selectChannel( sessionInfoPtr, channelInfoPtr->writeChannelNo,
CHANNEL_WRITE ) );
}
retIntError();
}
CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 3 ) ) \
int setChannelAttributeS( INOUT SESSION_INFO *sessionInfoPtr,
IN_ATTRIBUTE const CRYPT_ATTRIBUTE_TYPE attribute,
IN_BUFFER( dataLength ) const void *data,
IN_LENGTH_TEXT const int dataLength )
{
SSH_CHANNEL_INFO *channelInfoPtr;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isReadPtr( data, dataLength ) );
REQUIRES( isAttribute( attribute ) );
REQUIRES( dataLength > 0 && dataLength <= CRYPT_MAX_TEXTSIZE );
/* Set the attribute for the currently-active channel */
channelInfoPtr = ( SSH_CHANNEL_INFO * ) \
getCurrentChannelInfo( sessionInfoPtr, CHANNEL_READ );
REQUIRES( channelInfoPtr != NULL );
if( isNullChannel( channelInfoPtr ) )
return( CRYPT_ERROR_NOTFOUND );
switch( attribute )
{
case CRYPT_SESSINFO_SSH_CHANNEL_TYPE:
return( attributeCopyParams( channelInfoPtr->type,
CRYPT_MAX_TEXTSIZE,
&channelInfoPtr->typeLen,
data, dataLength ) );
case CRYPT_SESSINFO_SSH_CHANNEL_ARG1:
return( attributeCopyParams( channelInfoPtr->arg1,
CRYPT_MAX_TEXTSIZE,
&channelInfoPtr->arg1Len,
data, dataLength ) );
case CRYPT_SESSINFO_SSH_CHANNEL_ARG2:
return( attributeCopyParams( channelInfoPtr->arg2,
CRYPT_MAX_TEXTSIZE,
&channelInfoPtr->arg2Len,
data, dataLength ) );
}
retIntError();
}
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int setChannelExtAttribute( const SESSION_INFO *sessionInfoPtr,
IN_ATTRIBUTE const SSH_ATTRIBUTE_TYPE attribute,
IN_INT_Z const int value )
{
SSH_CHANNEL_INFO *channelInfoPtr = ( SSH_CHANNEL_INFO * ) \
getCurrentChannelInfo( sessionInfoPtr, CHANNEL_READ );
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES( ( attribute == SSH_ATTRIBUTE_ACTIVE && value == TRUE ) || \
( attribute != SSH_ATTRIBUTE_ACTIVE && \
value >= 0 && value < INT_MAX ) );
REQUIRES( channelInfoPtr != NULL );
if( isNullChannel( channelInfoPtr ) )
return( CRYPT_ERROR_NOTFOUND );
switch( attribute )
{
case SSH_ATTRIBUTE_ACTIVE:
channelInfoPtr->flags |= CHANNEL_FLAG_ACTIVE;
return( CRYPT_OK );
case SSH_ATTRIBUTE_WINDOWCOUNT:
channelInfoPtr->windowCount = value;
return( CRYPT_OK );
case SSH_ATTRIBUTE_WINDOWSIZE:
channelInfoPtr->windowSize = value;
return( CRYPT_OK );
case SSH_ATTRIBUTE_ALTCHANNELNO:
channelInfoPtr->writeChannelNo = value;
return( CRYPT_OK );
}
retIntError();
}
/* Get the status of a channel: Not open, read-side open/write-side closed,
open */
CHECK_RETVAL_ENUM( CHANNEL ) STDC_NONNULL_ARG( ( 1 ) ) \
CHANNEL_TYPE getChannelStatusByChannelNo( const SESSION_INFO *sessionInfoPtr,
IN const long channelNo )
{
SSH_CHANNEL_INFO *channelInfoPtr;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES_EXT( ( channelNo >= 0 && channelNo <= LONG_MAX ), \
CHANNEL_NONE );
channelInfoPtr = findChannelByChannelNo( sessionInfoPtr, channelNo );
return( ( channelInfoPtr == NULL ) ? CHANNEL_NONE : \
( channelInfoPtr->flags & CHANNEL_FLAG_WRITECLOSED ) ? \
CHANNEL_READ : CHANNEL_BOTH );
}
CHECK_RETVAL_ENUM( CHANNEL ) STDC_NONNULL_ARG( ( 1 ) ) \
CHANNEL_TYPE getChannelStatusByAddr( const SESSION_INFO *sessionInfoPtr,
IN_BUFFER( addrInfoLen ) const char *addrInfo,
IN_LENGTH_SHORT const int addrInfoLen )
{
const SSH_CHANNEL_INFO *channelInfoPtr;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isReadPtr( addrInfo, addrInfoLen ) );
REQUIRES_EXT( ( addrInfoLen > 0 && addrInfoLen < MAX_INTLENGTH_SHORT ), \
CHANNEL_NONE );
channelInfoPtr = findChannelByAddr( sessionInfoPtr, addrInfo,
addrInfoLen );
return( ( channelInfoPtr == NULL ) ? CHANNEL_NONE : \
( channelInfoPtr->flags & CHANNEL_FLAG_WRITECLOSED ) ? \
CHANNEL_READ : CHANNEL_BOTH );
}
/****************************************************************************
* *
* Channel Management Functions *
* *
****************************************************************************/
/* Select a channel */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int selectChannel( INOUT SESSION_INFO *sessionInfoPtr,
IN const long channelNo,
IN_ENUM_OPT( CHANNEL ) const CHANNEL_TYPE channelType )
{
SSH_INFO *sshInfo = sessionInfoPtr->sessionSSH;
SSH_CHANNEL_INFO *channelInfoPtr;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES( ( channelNo == CRYPT_USE_DEFAULT ) || \
( channelNo >= 0 && channelNo <= LONG_MAX ) );
/* CRYPT_USE_DEFAULT is used to select the first available
channel, used when closing all channels in a loop */
REQUIRES( ( channelType == CHANNEL_NONE ) || \
( channelType > CHANNEL_NONE && channelType < CHANNEL_LAST ) );
/* We allow CHANNEL_NONE to allow selection of created-but-not-
yet-active channels */
/* Locate the channel and update the current channel information. We
allow a special channel-type indicator of CHANNEL_NONE to specify the
selection of not-yet-activated channels. Since it's possible to have
per-channel packet sizes we also update the overall packet size
value */
channelInfoPtr = findChannelByChannelNo( sessionInfoPtr, channelNo );
if( channelInfoPtr == NULL )
return( CRYPT_ERROR_NOTFOUND );
if( !isActiveChannel( channelInfoPtr ) && channelType != CHANNEL_NONE )
return( CRYPT_ERROR_NOTINITED );
switch( channelType )
{
case CHANNEL_READ:
sshInfo->currReadChannel = channelInfoPtr->channelID;
break;
case CHANNEL_WRITE:
sshInfo->currWriteChannel = channelInfoPtr->channelID;
break;
case CHANNEL_BOTH:
case CHANNEL_NONE:
sshInfo->currReadChannel = \
sshInfo->currWriteChannel = channelInfoPtr->channelID;
break;
default:
retIntError();
}
sessionInfoPtr->maxPacketSize = channelInfoPtr->maxPacketSize;
return( CRYPT_OK );
}
/* Add/create/delete a channel */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 4 ) ) \
int addChannel( INOUT SESSION_INFO *sessionInfoPtr,
IN const long channelNo,
IN_LENGTH_MIN( 1024 ) const int maxPacketSize,
IN_BUFFER( typeLen ) const void *type,
IN_LENGTH_SHORT const int typeLen,
IN_BUFFER_OPT( arg1Len ) const void *arg1,
IN_LENGTH_SHORT const int arg1Len )
{
ATTRIBUTE_LIST *attributeListPtr;
SSH_INFO *sshInfo = sessionInfoPtr->sessionSSH;
SSH_CHANNEL_INFO channelInfo;
int channelCount, iterationCount, status;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isReadPtr( type, typeLen ) );
assert( ( arg1 == NULL && arg1Len == 0 ) ||
isReadPtr( arg1, arg1Len ) );
REQUIRES( channelNo >= 0 && channelNo <= LONG_MAX );
REQUIRES( maxPacketSize >= 1024 && maxPacketSize < MAX_INTLENGTH );
REQUIRES( typeLen > 0 && typeLen < MAX_INTLENGTH_SHORT );
REQUIRES( ( arg1 == NULL && arg1Len == 0 ) || \
( arg1 != NULL && \
arg1Len > 0 && arg1Len < MAX_INTLENGTH_SHORT ) );
/* Make sure that this channel doesn't already exist */
if( findChannelByChannelNo( sessionInfoPtr, channelNo ) != NULL )
{
retExt( CRYPT_ERROR_DUPLICATE,
( CRYPT_ERROR_DUPLICATE, SESSION_ERRINFO,
"Attempt to add duplicate channel %lX", channelNo ) );
}
/* SSH channels are allocated unique IDs for tracking by cryptlib,
since (at least in theory) the SSH-level channel IDs may repeat.
If the initial (not-yet-initialised) channel ID matches the
UNUSED_CHANNEL_ID magic value we initialise it to one past that
value */
if( sshInfo->channelIndex <= UNUSED_CHANNEL_ID )
sshInfo->channelIndex = UNUSED_CHANNEL_ID + 1;
/* Make sure that we haven't exceeded the maximum number of channels */
for( channelCount = 0, \
attributeListPtr = sessionInfoPtr->attributeList, \
iterationCount = 0;
attributeListPtr != NULL && \
iterationCount < FAILSAFE_ITERATIONS_MAX;
attributeListPtr = attributeListPtr->next, iterationCount++ )
{
if( attributeListPtr->attributeID == CRYPT_SESSINFO_SSH_CHANNEL )
channelCount++;
}
ENSURES( iterationCount < FAILSAFE_ITERATIONS_MAX );
if( channelCount > SSH_MAX_CHANNELS )
{
retExt( CRYPT_ERROR_OVERFLOW,
( CRYPT_ERROR_OVERFLOW, SESSION_ERRINFO,
"Maximum number (%d) of SSH channels reached",
SSH_MAX_CHANNELS ) );
}
/* Initialise the information for the new channel and create it */
memset( &channelInfo, 0, sizeof( SSH_CHANNEL_INFO ) );
channelInfo.channelID = sshInfo->channelIndex++;
channelInfo.readChannelNo = channelInfo.writeChannelNo = channelNo;
channelInfo.maxPacketSize = maxPacketSize;
status = attributeCopyParams( channelInfo.type, CRYPT_MAX_TEXTSIZE,
&channelInfo.typeLen, type, typeLen );
if( cryptStatusOK( status ) && arg1 != NULL )
status = attributeCopyParams( channelInfo.arg1, CRYPT_MAX_TEXTSIZE,
&channelInfo.arg1Len, arg1, arg1Len );
if( cryptStatusOK( status ) )
{
status = addSessionInfoComposite( &sessionInfoPtr->attributeList,
CRYPT_SESSINFO_SSH_CHANNEL,
accessFunction, &channelInfo,
sizeof( SSH_CHANNEL_INFO ),
ATTR_FLAG_MULTIVALUED | \
ATTR_FLAG_COMPOSITE );
}
if( cryptStatusError( status ) )
return( status );
/* Select the newly-created channel. We have to select it using the
special-case indicator of CHANNEL_NONE since we can't normally
select an inactive channel */
return( selectChannel( sessionInfoPtr, channelNo, CHANNEL_NONE ) );
}
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int createChannel( INOUT SESSION_INFO *sessionInfoPtr )
{
SSH_INFO *sshInfo = sessionInfoPtr->sessionSSH;
int iterationCount;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
/* Find an unused channel number. Since the peer can request the
creation of arbitrary-numbered channels we have to be careful to
ensure that we don't clash with any existing peer-requested channel
numbers when we create our own one */
for( iterationCount = 0;
findChannelByChannelNo( sessionInfoPtr, \
sshInfo->nextChannelNo ) != NULL && \
iterationCount < FAILSAFE_ITERATIONS_MED;
iterationCount++ )
{
/* This channel number is already in use, move on to the next one */
sshInfo->nextChannelNo++;
}
ENSURES( iterationCount < FAILSAFE_ITERATIONS_MED );
/* Create a channel with the new channel number */
return( addChannel( sessionInfoPtr, sshInfo->nextChannelNo++,
sessionInfoPtr->sendBufSize - EXTRA_PACKET_SIZE,
"session", 7, NULL, 0 ) );
}
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int deleteChannel( INOUT SESSION_INFO *sessionInfoPtr,
IN const long channelNo,
IN_ENUM( CHANNEL ) const CHANNEL_TYPE channelType,
const BOOLEAN deleteLastChannel )
{
SSH_INFO *sshInfo = sessionInfoPtr->sessionSSH;
SSH_CHANNEL_INFO *channelInfoPtr;
ATTRIBUTE_LIST *attributeListPtr;
int channelID;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES( channelNo >= 0 && channelNo <= LONG_MAX );
REQUIRES( channelType > CHANNEL_NONE && channelType < CHANNEL_LAST );
/* Locate the channel information */
attributeListPtr = findChannelAttr( sessionInfoPtr, channelNo );
if( attributeListPtr == NULL )
return( isChannelActive( sessionInfoPtr, UNUSED_CHANNEL_ID ) ? \
CRYPT_ERROR_NOTFOUND : OK_SPECIAL );
channelInfoPtr = attributeListPtr->value;
channelID = channelInfoPtr->channelID;
/* If we can't delete the last remaining channel (it has to be done
explicitly via a session close) and there are no active channels
left besides the current one then we can't do anything */
if( !deleteLastChannel && \
!isChannelActive( sessionInfoPtr, channelID ) )
return( CRYPT_ERROR_PERMISSION );
/* Delete the channel entry. If we're only closing the write side we
mark the channel as closed for write but leave the overall channel
open */
if( channelType == CHANNEL_WRITE )
{
REQUIRES( !( channelInfoPtr->flags & CHANNEL_FLAG_WRITECLOSED ) );
channelInfoPtr->flags |= CHANNEL_FLAG_WRITECLOSED;
if( channelID == sshInfo->currWriteChannel )
sshInfo->currWriteChannel = UNUSED_CHANNEL_ID;
return( isChannelActive( sessionInfoPtr, \
channelInfoPtr->channelID ) ? \
CRYPT_OK : OK_SPECIAL );
}
deleteSessionInfo( &sessionInfoPtr->attributeList,
&sessionInfoPtr->attributeListCurrent,
attributeListPtr );
/* If we've deleted the current channel, select a null channel until a
new one is created/selected */
if( channelID == sshInfo->currReadChannel )
sshInfo->currReadChannel = UNUSED_CHANNEL_ID;
if( channelID == sshInfo->currWriteChannel )
sshInfo->currWriteChannel = UNUSED_CHANNEL_ID;
/* We've deleted an open channel, check if there are any channels left
and if not let the caller know */
return( isChannelActive( sessionInfoPtr, UNUSED_CHANNEL_ID ) ? \
CRYPT_OK : OK_SPECIAL );
}
#if 0
CHECK_RETVAL STDC_NONNULL_ARG( ( 1, 2 ) ) \
int deleteChannelByAddr( INOUT SESSION_INFO *sessionInfoPtr,
IN_BUFFER( addrInfoLen ) const char *addrInfo,
IN_LENGTH_SHORT const int addrInfoLen )
{
const SSH_CHANNEL_INFO *channelInfoPtr;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( isReadPtr( addrInfo, addrInfoLen ) );
REQUIRES( addrInfoLen > 0 && addrInfoLen < MAX_INTLENGTH_SHORT );
channelInfoPtr = findChannelByAddr( sessionInfoPtr, addrInfo,
addrInfoLen );
if( channelInfoPtr == NULL )
return( CRYPT_ERROR_NOTFOUND );
/* We've found the entry that it corresponds to, clear it. This doesn't
actually delete the entire channel but merely deletes the forwarding.
See the note in ssh2_msg.c for why this is currently unused */
memset( channelInfoPtr->arg1, 0, CRYPT_MAX_TEXTSIZE );
channelInfoPtr->arg1Len = 0;
return( CRYPT_OK );
}
#endif /* 0 */
/****************************************************************************
* *
* Enqueue/Send Channel Messages *
* *
****************************************************************************/
/* Enqueue a response to a request, to be sent at the next available
opportunity. This is required because we may be in the middle of
assembling or sending a data packet when we need to send the response
so the response has to be deferred until after the data packet has been
completed and sent */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int enqueueResponse( INOUT SESSION_INFO *sessionInfoPtr,
IN_RANGE( 1, 255 ) const int type,
IN_RANGE( 0, 4 ) const int noParams,
IN const long channelNo,
const int param1, const int param2, const int param3 )
{
SSH_RESPONSE_INFO *respPtr = &sessionInfoPtr->sessionSSH->response;
STREAM stream;
int status = CRYPT_OK;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES( type > 0 && type <= 0xFF );
REQUIRES( noParams >= 0 && noParams <= 4 );
/* channelNo is the first parameter */
REQUIRES( channelNo >= 0 && channelNo <= LONG_MAX );
/* If there's already a response enqueued we can't enqueue another one
until it's been sent */
REQUIRES( respPtr->type == 0 );
respPtr->type = type;
sMemOpen( &stream, respPtr->data, SSH_MAX_RESPONSESIZE );
if( noParams > 0 )
status = writeUint32( &stream, channelNo );
if( noParams > 1 )
status = writeUint32( &stream, param1 );
if( noParams > 2 )
status = writeUint32( &stream, param2 );
if( noParams > 3 )
status = writeUint32( &stream, param3 );
ENSURES( cryptStatusOK( status ) );
respPtr->dataLen = stell( &stream );
sMemDisconnect( &stream );
return( CRYPT_OK );
}
/* Assemble a packet for and send a previously enqueued response. This
potentially appends a control packet after the end of an existing payload
packet so the buffer indicator used is sendBufSize rather than
maxPacketSize, since we may already have maxPacketSize bytes worth of
payload data present.
This can be called in one of two ways, if called as appendChannelData()
then it's being piggybacked onto the end of existing data at a location
specified by the 'offset' parameter and we assemble the packet at that
point but it'll be sent as part of the main packet send. If called as
enqueueChannelData() or sendEnqueuedResponse() then we have the send
buffer to ourselves (offset == CRYPT_UNUSED) and can assemble and send it
immediately */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
static int encodeSendResponse( INOUT SESSION_INFO *sessionInfoPtr,
IN_LENGTH_OPT const int offset,
OUT_OPT_LENGTH_Z int *responseSize )
{
SSH_RESPONSE_INFO *respPtr = &sessionInfoPtr->sessionSSH->response;
STREAM stream;
const BOOLEAN assembleOnly = ( offset != CRYPT_UNUSED ) ? TRUE : FALSE;
BOOLEAN adjustedStartOffset = FALSE;
int sendBufOffset = assembleOnly ? offset : sessionInfoPtr->sendBufPos;
int encodedResponseSize = DUMMY_INIT, dummy, status;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
assert( responseSize == NULL || \
isWritePtr( responseSize, sizeof( int ) ) );
REQUIRES( ( offset == CRYPT_UNUSED && responseSize == NULL ) || \
( offset >= 0 && offset < sessionInfoPtr->sendBufSize && \
responseSize != NULL ) );
REQUIRES( sendBufOffset >= 0 && offset < sessionInfoPtr->sendBufSize );
/* Make sure that there's room for at least two packets worth of
wrappers plus a short control packet, needed to handle a control
packet piggybacked onto the end of a data packet. The reason for the
doubling of the IV count is because the minimum padding length
requirement can result in an expansion by two encrypted blocks rather
than one */
static_assert( EXTRA_PACKET_SIZE > \
( 2 * ( SSH2_HEADER_SIZE + CRYPT_MAX_HASHSIZE + \
( 2 * CRYPT_MAX_IVSIZE ) ) ) + 32,
"Buffer packet size" );
/* Clear return value */
if( responseSize != NULL )
*responseSize = 0;
/* If there's an incomplete packet in the process of being assembled in
the send buffer then we can't do anything. If we're just assembling
a response to append to a completed packet then we know that the
packet that's present is a complete one so we skip this check */
if( assembleOnly && !sessionInfoPtr->partialWrite && \
( sendBufOffset > sessionInfoPtr->sendBufStartOfs ) )
return( CRYPT_OK );
/* The send buffer is allocated to always allow the piggybacking of one
packet of control data */
ENSURES( sendBufOffset + ( SSH2_HEADER_SIZE + 16 + respPtr->dataLen + \
CRYPT_MAX_HASHSIZE + CRYPT_MAX_IVSIZE ) <= \
sessionInfoPtr->sendBufSize );
ENSURES( ( sendBufOffset <= sessionInfoPtr->sendBufStartOfs ) || \
( sessionInfoPtr->partialWrite && \
sendBufOffset + ( SSH2_HEADER_SIZE + 16 + respPtr->dataLen + \
CRYPT_MAX_HASHSIZE + CRYPT_MAX_IVSIZE ) < \
sessionInfoPtr->sendBufSize ) );
/* If we're in the data transfer phase and there's nothing in the send
buffer, set the packet start offset to zero. We have to do this
because it's pre-adjusted to accomodate the header for a payload data
packet, since we're assembling our own packet in the buffer there's
no need for this additional header room */
if( ( sessionInfoPtr->flags & SESSION_ISOPEN ) && \
sendBufOffset == sessionInfoPtr->sendBufStartOfs )
{
sendBufOffset = 0;
adjustedStartOffset = TRUE;
}
/* Assemble the response as a new packet at the end of any existing
data */
REQUIRES( rangeCheckZ( sendBufOffset,
sessionInfoPtr->sendBufSize - sendBufOffset,
sessionInfoPtr->sendBufSize ) );
sMemOpen( &stream, sessionInfoPtr->sendBuffer + sendBufOffset,
sessionInfoPtr->sendBufSize - sendBufOffset );
swrite( &stream, "\x00\x00\x00\x00\x00", SSH2_HEADER_SIZE );
status = sputc( &stream, respPtr->type );
if( respPtr->dataLen > 0 )
{
/* Some responses can consist purely of an ID byte */
status = swrite( &stream, respPtr->data, respPtr->dataLen );
}
if( cryptStatusOK( status ) )
status = wrapPacketSSH2( sessionInfoPtr, &stream, 0, FALSE, TRUE );
if( cryptStatusOK( status ) )
encodedResponseSize = stell( &stream );
if( cryptStatusError( status ) )
{
sMemDisconnect( &stream );
return( status );
}
/* We've sent (or at least assembled) the response, clear the enqueued
data */
memset( respPtr, 0, sizeof( SSH_RESPONSE_INFO ) );
/* If we're only assembling the data and the caller is taking care of
sending the assembled packet, we're done */
if( assembleOnly )
{
sMemDisconnect( &stream );
*responseSize = encodedResponseSize;
return( CRYPT_OK );
}
/* If we're still in the handshake phase (so this is part of the initial
session negotiation, for example a response to a global or channel
request) then we need to send the packet directly to avoid messing
up the send buffering */
if( !( sessionInfoPtr->flags & SESSION_ISOPEN ) )
{
status = sendPacketSSH2( sessionInfoPtr, &stream, TRUE );
sMemDisconnect( &stream );
return( status );
}
/* Write the response, using the standard data-flush mechanism to try
and get the data out. We set the partial-write flag because what
we've just added is pre-packaged data that doesn't have to go through
the data-payload encoding process */
sMemDisconnect( &stream );
if( adjustedStartOffset )
{
/* We're in the data transfer phase, in which case the buffer
position is offset into the send buffer to leave room for the
packet header. Since we're adding our own header we've started
the packet at the start of the send buffer, i.e. with
sendBufPos = 0 rather than sendBufPos = sendBufStartOffset, so we
set the new position to the total size of the data written rather
than adding it to the existing value */
sessionInfoPtr->sendBufPos = encodedResponseSize;
}
else
{
assert( 0 ); /* When does this occur? */
sessionInfoPtr->sendBufPos += encodedResponseSize;
}
sessionInfoPtr->partialWrite = TRUE;
return( putSessionData( sessionInfoPtr, NULL, 0, &dummy ) );
}
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int sendEnqueuedResponse( INOUT SESSION_INFO *sessionInfoPtr )
{
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
return( encodeSendResponse( sessionInfoPtr, CRYPT_UNUSED, NULL ) );
}
/* Enqueue channel control data ready to be sent, and try and send it if
possible. This is used to send window-adjust messages for the SSH
performance handbrake by first enqueueing the window adjust and then,
if the send buffer is available, sending it. If it's not available
then it'll be piggybacked onto the channel payload data later on when
it's being sent via appendChannelData() below */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int enqueueChannelData( INOUT SESSION_INFO *sessionInfoPtr,
IN_RANGE( 1, 255 ) const int type,
IN const long channelNo,
const int param )
{
int status;
assert( isReadPtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES( type > 0 && type <= 0xFF );
REQUIRES( channelNo >= 0 && channelNo <= LONG_MAX );
status = enqueueResponse( sessionInfoPtr, type, 2, channelNo, param,
CRYPT_UNUSED, CRYPT_UNUSED );
if( cryptStatusError( status ) )
return( status );
return( encodeSendResponse( sessionInfoPtr, CRYPT_UNUSED, NULL ) );
}
/* Append enqueued channel control data to existing channel payload data
without trying to send it. In this case the control data send is being
piggybacked on a payload data send and will be handled by the caller,
with the control flow on the caller side being:
preparepacketFunction:
wrap channel data;
if( enqueued control data present )
appendChannelData();
send wrapped channel data and wrapped control data */
CHECK_RETVAL STDC_NONNULL_ARG( ( 1 ) ) \
int appendChannelData( INOUT SESSION_INFO *sessionInfoPtr,
IN_LENGTH_SHORT_Z const int offset )
{
int channelDataSize, status;
assert( isWritePtr( sessionInfoPtr, sizeof( SESSION_INFO ) ) );
REQUIRES( offset >= 0 && offset < sessionInfoPtr->sendBufSize );
status = encodeSendResponse( sessionInfoPtr, offset, &channelDataSize );
return( cryptStatusError( status ) ? status : channelDataSize );
}
#endif /* USE_SSH */
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2009,2010 Reality Jockey, Ltd.
* [email protected]
* http://rjdj.me/
*
* This file is part of ZenGarden.
*
* ZenGarden is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenGarden is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenGarden. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _MESSAGE_ADD_H_
#define _MESSAGE_ADD_H_
#include "MessageObject.h"
/** [+], [+ float] */
class MessageAdd : public MessageObject {
public:
MessageAdd(PdMessage *initMessage, PdGraph *graph);
~MessageAdd();
const char *getObjectLabel();
private:
void processMessage(int inletIndex, PdMessage *message);
float constant;
};
#endif // _MESSAGE_ADD_H_
| {
"pile_set_name": "Github"
} |
import React from 'react';
import PropTypes from 'prop-types';
const unitSymbols = {
USD: '$',
EUR: '€',
};
/**
* Price component that renders a price and a unit.
*/
export default function Price(props) {
let Host = 'span';
if (props.emphasize) {
Host = 'em';
}
return (
<Host>
{props.value}
{!props.symbol ? props.unit : unitSymbols[props.unit]}
</Host>
);
}
Price.propTypes = {
/** Price value. */
value: PropTypes.number.isRequired,
/** Price unit */
unit: PropTypes.oneOf(['EUR', 'USD']),
/** Flag that determines if the price should be emphasized or not. */
emphasize: PropTypes.bool,
/** Defines if the unit should be shown as a symbol or not. */
symbol: PropTypes.bool.isRequired,
};
| {
"pile_set_name": "Github"
} |
////
/// Copyright (c) 2016-2019 Martin Donath <[email protected]>
///
/// Permission is hereby granted, free of charge, to any person obtaining a
/// copy of this software and associated documentation files (the "Software"),
/// to deal in the Software without restriction, including without limitation
/// the rights to use, copy, modify, merge, publish, distribute, sublicense,
/// and/or sell copies of the Software, and to permit persons to whom the
/// Software is furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
/// DEALINGS
////
// ----------------------------------------------------------------------------
// Dependencies
// ----------------------------------------------------------------------------
@import "modularscale";
@import "material-color";
@import "material-shadows";
// ----------------------------------------------------------------------------
// Local imports
// ----------------------------------------------------------------------------
@import "helpers/break";
@import "helpers/px2em";
@import "config";
// ----------------------------------------------------------------------------
// Rules
// ----------------------------------------------------------------------------
// Color tile for presentation in theme documentation
button[data-md-color-primary],
button[data-md-color-accent] {
width: px2rem(130px);
margin-bottom: px2rem(4px);
padding: px2rem(24px) px2rem(8px) px2rem(4px);
transition:
background-color 0.25s,
opacity 0.25s;
border-radius: px2rem(2px);
color: $md-color-white;
font-size: ms(-1);
text-align: left;
cursor: pointer;
// Hovered color tile
&:hover {
opacity: 0.75;
}
}
// Build primary colors
@each $name, $color in (
"red": $clr-red-400,
"pink": $clr-pink-500,
"purple": $clr-purple-400,
"deep-purple": $clr-deep-purple-400,
"indigo": $clr-indigo-500,
"blue": $clr-blue-500,
"light-blue": $clr-light-blue-500,
"cyan": $clr-cyan-500,
"teal": $clr-teal-500,
"green": $clr-green-500,
"light-green": $clr-light-green-600,
"lime": $clr-lime-600,
"yellow": $clr-yellow-800,
"amber": $clr-amber-700,
"orange": $clr-orange-600,
"deep-orange": $clr-deep-orange-400,
"brown": $clr-brown-500,
"grey": $clr-grey-600,
"blue-grey": $clr-blue-grey-600
) {
// Color tile for presentation in theme documentation
button[data-md-color-primary="#{$name}"] {
background-color: $color;
}
// Color palette
[data-md-color-primary="#{$name}"] {
// Links in typesetted content
.md-typeset a {
color: $color;
}
// Application header (stays always on top)
.md-header {
background-color: $color;
}
// Hero teaser
.md-hero {
background-color: $color;
}
// Current or active link
.md-nav__link:active,
.md-nav__link--active {
color: $color;
}
// Reset active color for nested list titles
.md-nav__item--nested > .md-nav__link {
color: inherit;
}
// [tablet portrait -]: Layered navigation
@include break-to-device(tablet portrait) {
// Repository containing source
.md-nav__source {
background-color: mix($color, $md-color-black, 75%);
}
}
// [tablet -]: Layered navigation
@include break-to-device(tablet) {
// Site title in main navigation
html & .md-nav--primary .md-nav__title--site {
background-color: $color;
}
}
// [screen +]: Set background color for tabs
@include break-from-device(screen) {
// Tabs with outline
.md-tabs {
background-color: $color;
}
}
}
}
// Color tile for presentation in theme documentation
button[data-md-color-primary="white"] {
background-color: $md-color-white;
color: $md-color-black;
box-shadow: 0 0 px2rem(1px) $md-color-black--light inset;
}
// Overrides for white color
[data-md-color-primary="white"] {
// Application header (stays always on top)
.md-header {
background-color: $md-color-white;
color: $md-color-black;
}
// Hero teaser
.md-hero {
background-color: $md-color-white;
color: $md-color-black;
// Add a border if there are no tabs
&--expand {
border-bottom: px2rem(1px) solid $md-color-black--lightest;
}
}
// [tablet portrait -]: Layered navigation
@include break-to-device(tablet portrait) {
// Repository containing source
.md-nav__source {
background-color: $md-color-black--lightest;
color: $md-color-black;
}
}
// [tablet portrait +]: Change color of search input
@include break-from-device(tablet landscape) {
// Search input
.md-search__input {
background-color: $md-color-black--lightest;
// Search input placeholder
&::placeholder {
color: $md-color-black--light;
}
}
}
// [tablet -]: Layered navigation
@include break-to-device(tablet) {
// Site title in main navigation
html & .md-nav--primary .md-nav__title--site {
background-color: $md-color-white;
color: $md-color-black;
}
// Hero teaser
.md-hero {
border-bottom: px2rem(1px) solid $md-color-black--lightest;
}
}
// [screen +]: Set background color for tabs
@include break-from-device(screen) {
// Tabs with outline
.md-tabs {
border-bottom: px2rem(1px) solid $md-color-black--lightest;
background-color: $md-color-white;
color: $md-color-black;
}
}
}
// Build accent colors
@each $name, $color in (
"red": $clr-red-a400,
"pink": $clr-pink-a400,
"purple": $clr-purple-a200,
"deep-purple": $clr-deep-purple-a200,
"indigo": $clr-indigo-a200,
"blue": $clr-blue-a200,
"light-blue": $clr-light-blue-a700,
"cyan": $clr-cyan-a700,
"teal": $clr-teal-a700,
"green": $clr-green-a700,
"light-green": $clr-light-green-a700,
"lime": $clr-lime-a700,
"yellow": $clr-yellow-a700,
"amber": $clr-amber-a700,
"orange": $clr-orange-a400,
"deep-orange": $clr-deep-orange-a200
) {
// Color tile for presentation in theme documentation
button[data-md-color-accent="#{$name}"] {
background-color: $color;
}
// Color palette
[data-md-color-accent="#{$name}"] {
// Typesetted content
.md-typeset {
// Hovered and active links
a:hover,
a:active {
color: $color;
}
// Hovered scrollbar thumb
pre code::-webkit-scrollbar-thumb:hover,
.codehilite pre::-webkit-scrollbar-thumb:hover {
background-color: $color;
}
// Copy to clipboard active icon
.md-clipboard:hover::before,
.md-clipboard:active::before {
color: $color;
}
// Active or targeted back reference
.footnote li:hover .footnote-backref:hover,
.footnote li:target .footnote-backref {
color: $color;
}
// Active, targeted or focused permalink
[id]:hover .headerlink:hover,
[id]:target .headerlink,
[id] .headerlink:focus {
color: $color;
}
}
// Focused or hovered link
.md-nav__link:focus,
.md-nav__link:hover {
color: $color;
}
// Search container scrollbar thumb
.md-search__scrollwrap::-webkit-scrollbar-thumb:hover {
background-color: $color;
}
// Search result link
.md-search-result__link {
// Active or hovered link
&[data-md-state="active"],
&:hover {
background-color: transparentize($color, 0.9);
}
}
// Wrapper for scrolling on overflow
.md-sidebar__scrollwrap::-webkit-scrollbar-thumb:hover {
background-color: $color;
}
// Source file icon
.md-source-file:hover::before {
background-color: $color;
}
}
}
| {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
| {
"pile_set_name": "Github"
} |
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright 2011, Blender Foundation.
*/
#include "COM_InvertOperation.h"
InvertOperation::InvertOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputValueProgram = NULL;
this->m_inputColorProgram = NULL;
this->m_color = true;
this->m_alpha = false;
setResolutionInputSocketIndex(1);
}
void InvertOperation::initExecution()
{
this->m_inputValueProgram = this->getInputSocketReader(0);
this->m_inputColorProgram = this->getInputSocketReader(1);
}
void InvertOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float inputColor[4];
this->m_inputValueProgram->readSampled(inputValue, x, y, sampler);
this->m_inputColorProgram->readSampled(inputColor, x, y, sampler);
const float value = inputValue[0];
const float invertedValue = 1.0f - value;
if (this->m_color) {
output[0] = (1.0f - inputColor[0]) * value + inputColor[0] * invertedValue;
output[1] = (1.0f - inputColor[1]) * value + inputColor[1] * invertedValue;
output[2] = (1.0f - inputColor[2]) * value + inputColor[2] * invertedValue;
}
else {
copy_v3_v3(output, inputColor);
}
if (this->m_alpha) {
output[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue;
}
else {
output[3] = inputColor[3];
}
}
void InvertOperation::deinitExecution()
{
this->m_inputValueProgram = NULL;
this->m_inputColorProgram = NULL;
}
| {
"pile_set_name": "Github"
} |
(function( factory ) {
if ( typeof define === "function" && define.amd ) {
define( ["jquery", "../jquery.validate"], factory );
} else if (typeof module === "object" && module.exports) {
module.exports = factory( require( "jquery" ) );
} else {
factory( jQuery );
}
}(function( $ ) {
/*
* Translated default messages for the jQuery validation plugin.
* Locale: HR (Croatia; hrvatski jezik)
*/
$.extend( $.validator.messages, {
required: "Ovo polje je obavezno.",
remote: "Ovo polje treba popraviti.",
email: "Unesite ispravnu e-mail adresu.",
url: "Unesite ispravan URL.",
date: "Unesite ispravan datum.",
dateISO: "Unesite ispravan datum (ISO).",
number: "Unesite ispravan broj.",
digits: "Unesite samo brojeve.",
creditcard: "Unesite ispravan broj kreditne kartice.",
equalTo: "Unesite ponovo istu vrijednost.",
extension: "Unesite vrijednost sa ispravnom ekstenzijom.",
maxlength: $.validator.format( "Maksimalni broj znakova je {0} ." ),
minlength: $.validator.format( "Minimalni broj znakova je {0} ." ),
rangelength: $.validator.format( "Unesite vrijednost između {0} i {1} znakova." ),
range: $.validator.format( "Unesite vrijednost između {0} i {1}." ),
max: $.validator.format( "Unesite vrijednost manju ili jednaku {0}." ),
min: $.validator.format( "Unesite vrijednost veću ili jednaku {0}." )
} );
return $;
})); | {
"pile_set_name": "Github"
} |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>18E226</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>SMCBatteryManager</string>
<key>CFBundleIdentifier</key>
<string>ru.usrsse2.SMCBatteryManager</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>SMCBatteryManager</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
<string>1.1.6</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1.1.6</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>10E1001</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>18E219</string>
<key>DTSDKName</key>
<string>macosx10.14</string>
<key>DTXcode</key>
<string>1020</string>
<key>DTXcodeBuild</key>
<string>10E1001</string>
<key>IOKitPersonalities</key>
<dict>
<key>IOSMBusController</key>
<dict>
<key>CFBundleIdentifier</key>
<string>ru.usrsse2.SMCBatteryManager</string>
<key>IOClass</key>
<string>SMCSMBusController</string>
<key>IOMatchCategory</key>
<string>SMCSMBusController</string>
<key>IOProviderClass</key>
<string>IOResources</string>
<key>IOResourceMatch</key>
<string>IOKit</string>
</dict>
<key>SMCBatteryManager</key>
<dict>
<key>CFBundleIdentifier</key>
<string>ru.usrsse2.SMCBatteryManager</string>
<key>IOClass</key>
<string>SMCBatteryManager</string>
<key>IOMatchCategory</key>
<string>SMCBatteryManager</string>
<key>IOProviderClass</key>
<string>IOResources</string>
<key>IOResourceMatch</key>
<string>IOKit</string>
</dict>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 usrsse2. All rights reserved.</string>
<key>OSBundleCompatibleVersion</key>
<string>1.0.0</string>
<key>OSBundleLibraries</key>
<dict>
<key>as.vit9696.Lilu</key>
<string>1.2.0</string>
<key>as.vit9696.VirtualSMC</key>
<string>1.0.0</string>
<key>com.apple.iokit.IOACPIFamily</key>
<string>1.0.0d1</string>
<key>com.apple.iokit.IOSMBusFamily</key>
<string>1.0.0</string>
<key>com.apple.kpi.bsd</key>
<string>12.0.0</string>
<key>com.apple.kpi.dsep</key>
<string>12.0.0</string>
<key>com.apple.kpi.iokit</key>
<string>12.0.0</string>
<key>com.apple.kpi.libkern</key>
<string>12.0.0</string>
<key>com.apple.kpi.mach</key>
<string>12.0.0</string>
<key>com.apple.kpi.unsupported</key>
<string>12.0.0</string>
</dict>
<key>OSBundleRequired</key>
<string>Root</string>
</dict>
</plist>
| {
"pile_set_name": "Github"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.