text:
#ifdef HAVE_CONFIG_H
#include "../../../ext_config.h"
#endif

#include <php.h>
#include "../../../php_ext.h"
#include "../../../ext.h"

#include <Zend/zend_operators.h>
#include <Zend/zend_exceptions.h>
#include <Zend/zend_interfaces.h>

#include "kernel/main.h"

/**
 * Navigation invalid argument exception
 */
ZEPHIR_INIT_CLASS(ZendFramework_Navigation_Exception_InvalidArgumentException) {

	ZEPHIR_REGISTER_CLASS_EX(Zend\\Navigation\\Exception, InvalidArgumentException, zendframework, navigation_exception_invalidargumentexception, spl_ce_InvalidArgumentException, NULL, 0);

	zend_class_implements(zendframework_navigation_exception_invalidargumentexception_ce TSRMLS_CC, 1, zendframework_navigation_exception_exceptioninterface_ce);
	return SUCCESS;

}


text:
/* $Id: tif_read.c,v 1.8 2013/11/29 22:22:01 drolon Exp $ */

/*
 * Copyright (c) 1988-1997 Sam Leffler
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
 *
 * Permission to use, copy, modify, distribute, and sell this software and
 * its documentation for any purpose is hereby granted without fee, provided
 * that (i) the above copyright notices and this permission notice appear in
 * all copies of the software and related documentation, and (ii) the names of
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
 * publicity relating to the software without the specific, prior written
 * permission of Sam Leffler and Silicon Graphics.
 *
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
 *
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THIS SOFTWARE.
 */

/*
 * TIFF Library.
 * Scanline-oriented Read Support
 */
#include "tiffiop.h"
#include <stdio.h>

int TIFFFillStrip(TIFF* tif, uint32 strip);
int TIFFFillTile(TIFF* tif, uint32 tile);
static int TIFFStartStrip(TIFF* tif, uint32 strip);
static int TIFFStartTile(TIFF* tif, uint32 tile);
static int TIFFCheckRead(TIFF*, int);
static tmsize_t
TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,const char* module);

#define NOSTRIP ((uint32)(-1))       /* undefined state */
#define NOTILE ((uint32)(-1))         /* undefined state */

static int
TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
{
	static const char module[] = "TIFFFillStripPartial";
	register TIFFDirectory *td = &tif->tif_dir;
        tmsize_t unused_data;
        uint64 read_offset;
        tmsize_t cc, to_read;
        /* tmsize_t bytecountm; */

        if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
            return 0;

        /*
         * Expand raw data buffer, if needed, to hold data
         * strip coming from file (perhaps should set upper
         * bound on the size of a buffer we'll use?).
         */

        /* bytecountm=(tmsize_t) td->td_stripbytecount[strip]; */
        if (read_ahead*2 > tif->tif_rawdatasize) {
                assert( restart );

                tif->tif_curstrip = NOSTRIP;
                if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
                        TIFFErrorExt(tif->tif_clientdata, module,
                                     "Data buffer too small to hold part of strip %lu",
                                     (unsigned long) strip);
                        return (0);
                }
                if (!TIFFReadBufferSetup(tif, 0, read_ahead*2))
                        return (0);
        }

        if( restart )
        {
                tif->tif_rawdataloaded = 0;
                tif->tif_rawdataoff = 0;
        }

        /*
        ** If we are reading more data, move any unused data to the
        ** start of the buffer.
        */
        if( tif->tif_rawdataloaded > 0 )
                unused_data = tif->tif_rawdataloaded - (tif->tif_rawcp - tif->tif_rawdata);
        else
                unused_data = 0;

        if( unused_data > 0 )
        {
		assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
                memmove( tif->tif_rawdata, tif->tif_rawcp, unused_data );
        }

        /*
        ** Seek to the point in the file where more data should be read.
        */
        read_offset = td->td_stripoffset[strip]
                + tif->tif_rawdataoff + tif->tif_rawdataloaded;

        if (!SeekOK(tif, read_offset)) {
                TIFFErrorExt(tif->tif_clientdata, module,
                             "Seek error at scanline %lu, strip %lu",
                             (unsigned long) tif->tif_row, (unsigned long) strip);
                return 0;
        }

        /*
        ** How much do we want to read?
        */
        to_read = tif->tif_rawdatasize - unused_data;
        if( (uint64) to_read > td->td_stripbytecount[strip]
            - tif->tif_rawdataoff - tif->tif_rawdataloaded )
        {
                to_read = (tmsize_t) td->td_stripbytecount[strip]
                        - tif->tif_rawdataoff - tif->tif_rawdataloaded;
        }

	assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
        cc = TIFFReadFile(tif, tif->tif_rawdata + unused_data, to_read);

        if (cc != to_read) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
                TIFFErrorExt(tif->tif_clientdata, module,
                             "Read error at scanline %lu; got %I64u bytes, expected %I64u",
                             (unsigned long) tif->tif_row,
                             (unsigned __int64) cc,
                             (unsigned __int64) to_read);
#else
                TIFFErrorExt(tif->tif_clientdata, module,
                             "Read error at scanline %lu; got %llu bytes, expected %llu",
                             (unsigned long) tif->tif_row,
                             (unsigned long long) cc,
                             (unsigned long long) to_read);
#endif
                return 0;
        }

        tif->tif_rawdataoff = tif->tif_rawdataoff + tif->tif_rawdataloaded - unused_data ;
        tif->tif_rawdataloaded = unused_data + to_read;

        tif->tif_rawcp = tif->tif_rawdata;

        if (!isFillOrder(tif, td->td_fillorder) &&
            (tif->tif_flags & TIFF_NOBITREV) == 0) {
		assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
                TIFFReverseBits(tif->tif_rawdata + unused_data, to_read );
	}

        /*
        ** When starting a strip from the beginning we need to
        ** restart the decoder.
        */
        if( restart )
                return TIFFStartStrip(tif, strip);
        else
                return 1;
}

/*
 * Seek to a random row+sample in a file.
 *
 * Only used by TIFFReadScanline, and is only used on
 * strip organized files.  We do some tricky stuff to try
 * and avoid reading the whole compressed raw data for big
 * strips.
 */
static int
TIFFSeek(TIFF* tif, uint32 row, uint16 sample )
{
	register TIFFDirectory *td = &tif->tif_dir;
	uint32 strip;
        int    whole_strip;
	tmsize_t read_ahead = 0;

        /*
        ** Establish what strip we are working from.
        */
	if (row >= td->td_imagelength) {	/* out of range */
		TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
		    "%lu: Row out of range, max %lu",
		    (unsigned long) row,
		    (unsigned long) td->td_imagelength);
		return (0);
	}
	if (td->td_planarconfig == PLANARCONFIG_SEPARATE) {
		if (sample >= td->td_samplesperpixel) {
			TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
			    "%lu: Sample out of range, max %lu",
			    (unsigned long) sample, (unsigned long) td->td_samplesperpixel);
			return (0);
		}
		strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip;
	} else
		strip = row / td->td_rowsperstrip;

        /*
         * Do we want to treat this strip as one whole chunk or
         * read it a few lines at a time?
         */
#if defined(CHUNKY_STRIP_READ_SUPPORT)
        if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
            return 0;
        whole_strip = tif->tif_dir.td_stripbytecount[strip] < 10
                || isMapped(tif);
#else
        whole_strip = 1;
#endif

        if( !whole_strip )
        {
                read_ahead = tif->tif_scanlinesize * 16 + 5000;
        }

        /*
         * If we haven't loaded this strip, do so now, possibly
         * only reading the first part.
         */
	if (strip != tif->tif_curstrip) {	/* different strip, refill */

                if( whole_strip )
                {
                        if (!TIFFFillStrip(tif, strip))
                                return (0);
                }
                else
                {
                        if( !TIFFFillStripPartial(tif,strip,read_ahead,1) )
                                return 0;
                }
	}

        /*
        ** If we already have some data loaded, do we need to read some more?
        */
        else if( !whole_strip )
        {
                if( ((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < read_ahead
                    && (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < td->td_stripbytecount[strip] )
                {
                        if( !TIFFFillStripPartial(tif,strip,read_ahead,0) )
                                return 0;
                }
        }

        if (row < tif->tif_row) {
		/*
		 * Moving backwards within the same strip: backup
		 * to the start and then decode forward (below).
		 *
		 * NB: If you're planning on lots of random access within a
		 * strip, it's better to just read and decode the entire
		 * strip, and then access the decoded data in a random fashion.
		 */

                if( tif->tif_rawdataoff != 0 )
                {
                        if( !TIFFFillStripPartial(tif,strip,read_ahead,1) )
                                return 0;
                }
                else
                {
                        if (!TIFFStartStrip(tif, strip))
                                return (0);
                }
	}

	if (row != tif->tif_row) {
		/*
		 * Seek forward to the desired row.
		 */

                /* TODO: Will this really work with partial buffers? */

		if (!(*tif->tif_seek)(tif, row - tif->tif_row))
			return (0);
		tif->tif_row = row;
	}

	return (1);
}

int
TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample)
{
	int e;

	if (!TIFFCheckRead(tif, 0))
		return (-1);
	if( (e = TIFFSeek(tif, row, sample)) != 0) {
		/*
		 * Decompress desired row into user buffer.
		 */
		e = (*tif->tif_decoderow)
		    (tif, (uint8*) buf, tif->tif_scanlinesize, sample);

		/* we are now poised at the beginning of the next row */
		tif->tif_row = row + 1;

		if (e)
			(*tif->tif_postdecode)(tif, (uint8*) buf,
			    tif->tif_scanlinesize);
	}
	return (e > 0 ? 1 : -1);
}

/*
 * Read a strip of data and decompress the specified
 * amount into the user-supplied buffer.
 */
tmsize_t
TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
{
	static const char module[] = "TIFFReadEncodedStrip";
	TIFFDirectory *td = &tif->tif_dir;
	uint32 rowsperstrip;
	uint32 stripsperplane;
	uint32 stripinplane;
	uint16 plane;
	uint32 rows;
	tmsize_t stripsize;
	if (!TIFFCheckRead(tif,0))
		return((tmsize_t)(-1));
	if (strip>=td->td_nstrips)
	{
		TIFFErrorExt(tif->tif_clientdata,module,
		    "%lu: Strip out of range, max %lu",(unsigned long)strip,
		    (unsigned long)td->td_nstrips);
		return((tmsize_t)(-1));
	}
	/*
	 * Calculate the strip size according to the number of
	 * rows in the strip (check for truncated last strip on any
	 * of the separations).
	 */
	rowsperstrip=td->td_rowsperstrip;
	if (rowsperstrip>td->td_imagelength)
		rowsperstrip=td->td_imagelength;
	stripsperplane=((td->td_imagelength+rowsperstrip-1)/rowsperstrip);
	stripinplane=(strip%stripsperplane);
	plane=(strip/stripsperplane);
	rows=td->td_imagelength-stripinplane*rowsperstrip;
	if (rows>rowsperstrip)
		rows=rowsperstrip;
	stripsize=TIFFVStripSize(tif,rows);
	if (stripsize==0)
		return((tmsize_t)(-1));
	if ((size!=(tmsize_t)(-1))&&(size<stripsize))
		stripsize=size;
	if (!TIFFFillStrip(tif,strip))
		return((tmsize_t)(-1));
	if ((*tif->tif_decodestrip)(tif,buf,stripsize,plane)<=0)
		return((tmsize_t)(-1));
	(*tif->tif_postdecode)(tif,buf,stripsize);
	return(stripsize);
}

static tmsize_t
TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,
    const char* module)
{
	TIFFDirectory *td = &tif->tif_dir;

    if (!_TIFFFillStriles( tif ))
        return ((tmsize_t)(-1));

	assert((tif->tif_flags&TIFF_NOREADRAW)==0);
	if (!isMapped(tif)) {
		tmsize_t cc;

		if (!SeekOK(tif, td->td_stripoffset[strip])) {
			TIFFErrorExt(tif->tif_clientdata, module,
			    "Seek error at scanline %lu, strip %lu",
			    (unsigned long) tif->tif_row, (unsigned long) strip);
			return ((tmsize_t)(-1));
		}
		cc = TIFFReadFile(tif, buf, size);
		if (cc != size) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
			TIFFErrorExt(tif->tif_clientdata, module,
		"Read error at scanline %lu; got %I64u bytes, expected %I64u",
				     (unsigned long) tif->tif_row,
				     (unsigned __int64) cc,
				     (unsigned __int64) size);
#else
			TIFFErrorExt(tif->tif_clientdata, module,
		"Read error at scanline %lu; got %llu bytes, expected %llu",
				     (unsigned long) tif->tif_row,
				     (unsigned long long) cc,
				     (unsigned long long) size);
#endif
			return ((tmsize_t)(-1));
		}
	} else {
		tmsize_t ma,mb;
		tmsize_t n;
		ma=(tmsize_t)td->td_stripoffset[strip];
		mb=ma+size;
		if (((uint64)ma!=td->td_stripoffset[strip])||(ma>tif->tif_size))
			n=0;
		else if ((mb<ma)||(mb<size)||(mb>tif->tif_size))
			n=tif->tif_size-ma;
		else
			n=size;
		if (n!=size) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
			TIFFErrorExt(tif->tif_clientdata, module,
	"Read error at scanline %lu, strip %lu; got %I64u bytes, expected %I64u",
				     (unsigned long) tif->tif_row,
				     (unsigned long) strip,
				     (unsigned __int64) n,
				     (unsigned __int64) size);
#else
			TIFFErrorExt(tif->tif_clientdata, module,
	"Read error at scanline %lu, strip %lu; got %llu bytes, expected %llu",
				     (unsigned long) tif->tif_row,
				     (unsigned long) strip,
				     (unsigned long long) n,
				     (unsigned long long) size);
#endif
			return ((tmsize_t)(-1));
		}
		_TIFFmemcpy(buf, tif->tif_base + ma,
			    size);
	}
	return (size);
}

/*
 * Read a strip of data from the file.
 */
tmsize_t
TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
{
	static const char module[] = "TIFFReadRawStrip";
	TIFFDirectory *td = &tif->tif_dir;
	uint64 bytecount;
	tmsize_t bytecountm;

	if (!TIFFCheckRead(tif, 0))
		return ((tmsize_t)(-1));
	if (strip >= td->td_nstrips) {
		TIFFErrorExt(tif->tif_clientdata, module,
		     "%lu: Strip out of range, max %lu",
		     (unsigned long) strip,
		     (unsigned long) td->td_nstrips);
		return ((tmsize_t)(-1));
	}
	if (tif->tif_flags&TIFF_NOREADRAW)
	{
		TIFFErrorExt(tif->tif_clientdata, module,
		    "Compression scheme does not support access to raw uncompressed data");
		return ((tmsize_t)(-1));
	}
	bytecount = td->td_stripbytecount[strip];
	if (bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
		TIFFErrorExt(tif->tif_clientdata, module,
			     "%I64u: Invalid strip byte count, strip %lu",
			     (unsigned __int64) bytecount,
			     (unsigned long) strip);
#else
		TIFFErrorExt(tif->tif_clientdata, module,
			     "%llu: Invalid strip byte count, strip %lu",
			     (unsigned long long) bytecount,
			     (unsigned long) strip);
#endif
		return ((tmsize_t)(-1));
	}
	bytecountm = (tmsize_t)bytecount;
	if ((uint64)bytecountm!=bytecount) {
		TIFFErrorExt(tif->tif_clientdata, module, "Integer overflow");
		return ((tmsize_t)(-1));
	}
	if (size != (tmsize_t)(-1) && size < bytecountm)
		bytecountm = size;
	return (TIFFReadRawStrip1(tif, strip, buf, bytecountm, module));
}

/*
 * Read the specified strip and setup for decoding. The data buffer is
 * expanded, as necessary, to hold the strip's data.
 */
int
TIFFFillStrip(TIFF* tif, uint32 strip)
{
	static const char module[] = "TIFFFillStrip";
	TIFFDirectory *td = &tif->tif_dir;

    if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
        return 0;

	if ((tif->tif_flags&TIFF_NOREADRAW)==0)
	{
		uint64 bytecount = td->td_stripbytecount[strip];
		if (bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
			TIFFErrorExt(tif->tif_clientdata, module,
				"Invalid strip byte count %I64u, strip %lu",
				     (unsigned __int64) bytecount,
				     (unsigned long) strip);
#else
			TIFFErrorExt(tif->tif_clientdata, module,
				"Invalid strip byte count %llu, strip %lu",
				     (unsigned long long) bytecount,
				     (unsigned long) strip);
#endif
			return (0);
		}
		if (isMapped(tif) &&
		    (isFillOrder(tif, td->td_fillorder)
		    || (tif->tif_flags & TIFF_NOBITREV))) {
			/*
			 * The image is mapped into memory and we either don't
			 * need to flip bits or the compression routine is
			 * going to handle this operation itself.  In this
			 * case, avoid copying the raw data and instead just
			 * reference the data from the memory mapped file
			 * image.  This assumes that the decompression
			 * routines do not modify the contents of the raw data
			 * buffer (if they try to, the application will get a
			 * fault since the file is mapped read-only).
			 */
			if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
				_TIFFfree(tif->tif_rawdata);
				tif->tif_rawdata = NULL;
				tif->tif_rawdatasize = 0;
			}
			tif->tif_flags &= ~TIFF_MYBUFFER;
			/*
			 * We must check for overflow, potentially causing
			 * an OOB read. Instead of simple
			 *
			 *  td->td_stripoffset[strip]+bytecount > tif->tif_size
			 *
			 * comparison (which can overflow) we do the following
			 * two comparisons:
			 */
			if (bytecount > (uint64)tif->tif_size ||
			    td->td_stripoffset[strip] > (uint64)tif->tif_size - bytecount) {
				/*
				 * This error message might seem strange, but
				 * it's what would happen if a read were done
				 * instead.
				 */
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
				TIFFErrorExt(tif->tif_clientdata, module,

					"Read error on strip %lu; "
					"got %I64u bytes, expected %I64u",
					(unsigned long) strip,
					(unsigned __int64) tif->tif_size - td->td_stripoffset[strip],
					(unsigned __int64) bytecount);
#else
				TIFFErrorExt(tif->tif_clientdata, module,

					"Read error on strip %lu; "
					"got %llu bytes, expected %llu",
					(unsigned long) strip,
					(unsigned long long) tif->tif_size - td->td_stripoffset[strip],
					(unsigned long long) bytecount);
#endif
				tif->tif_curstrip = NOSTRIP;
				return (0);
			}
			tif->tif_rawdatasize = (tmsize_t)bytecount;
			tif->tif_rawdata = tif->tif_base + (tmsize_t)td->td_stripoffset[strip];
                        tif->tif_rawdataoff = 0;
                        tif->tif_rawdataloaded = (tmsize_t) bytecount;

			/*
			 * When we have tif_rawdata reference directly into the memory mapped file
			 * we need to be pretty careful about how we use the rawdata.  It is not
			 * a general purpose working buffer as it normally otherwise is.  So we
			 * keep track of this fact to avoid using it improperly.
			 */
			tif->tif_flags |= TIFF_BUFFERMMAP;
		} else {
			/*
			 * Expand raw data buffer, if needed, to hold data
			 * strip coming from file (perhaps should set upper
			 * bound on the size of a buffer we'll use?).
			 */
			tmsize_t bytecountm;
			bytecountm=(tmsize_t)bytecount;
			if ((uint64)bytecountm!=bytecount)
			{
				TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
				return(0);
			}
			if (bytecountm > tif->tif_rawdatasize) {
				tif->tif_curstrip = NOSTRIP;
				if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
					TIFFErrorExt(tif->tif_clientdata, module,
					    "Data buffer too small to hold strip %lu",
					    (unsigned long) strip);
					return (0);
				}
				if (!TIFFReadBufferSetup(tif, 0, bytecountm))
					return (0);
			}
			if (tif->tif_flags&TIFF_BUFFERMMAP) {
				tif->tif_curstrip = NOSTRIP;
				if (!TIFFReadBufferSetup(tif, 0, bytecountm))
					return (0);
			}
			if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata,
				bytecountm, module) != bytecountm)
				return (0);

                        tif->tif_rawdataoff = 0;
                        tif->tif_rawdataloaded = bytecountm;

			if (!isFillOrder(tif, td->td_fillorder) &&
			    (tif->tif_flags & TIFF_NOBITREV) == 0)
				TIFFReverseBits(tif->tif_rawdata, bytecountm);
                }
	}
	return (TIFFStartStrip(tif, strip));
}

/*
 * Tile-oriented Read Support
 * Contributed by Nancy Cam (Silicon Graphics).
 */

/*
 * Read and decompress a tile of data.  The
 * tile is selected by the (x,y,z,s) coordinates.
 */
tmsize_t
TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s)
{
	if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
		return ((tmsize_t)(-1));
	return (TIFFReadEncodedTile(tif,
	    TIFFComputeTile(tif, x, y, z, s), buf, (tmsize_t)(-1)));
}

/*
 * Read a tile of data and decompress the specified
 * amount into the user-supplied buffer.
 */
tmsize_t
TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
{
	static const char module[] = "TIFFReadEncodedTile";
	TIFFDirectory *td = &tif->tif_dir;
	tmsize_t tilesize = tif->tif_tilesize;

	if (!TIFFCheckRead(tif, 1))
		return ((tmsize_t)(-1));
	if (tile >= td->td_nstrips) {
		TIFFErrorExt(tif->tif_clientdata, module,
		    "%lu: Tile out of range, max %lu",
		    (unsigned long) tile, (unsigned long) td->td_nstrips);
		return ((tmsize_t)(-1));
	}
	if (size == (tmsize_t)(-1))
		size = tilesize;
	else if (size > tilesize)
		size = tilesize;
	if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif,
	    (uint8*) buf, size, (uint16)(tile/td->td_stripsperimage))) {
		(*tif->tif_postdecode)(tif, (uint8*) buf, size);
		return (size);
	} else
		return ((tmsize_t)(-1));
}

static tmsize_t
TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module)
{
	TIFFDirectory *td = &tif->tif_dir;

    if (!_TIFFFillStriles( tif ))
        return ((tmsize_t)(-1));

	assert((tif->tif_flags&TIFF_NOREADRAW)==0);
	if (!isMapped(tif)) {
		tmsize_t cc;

		if (!SeekOK(tif, td->td_stripoffset[tile])) {
			TIFFErrorExt(tif->tif_clientdata, module,
			    "Seek error at row %lu, col %lu, tile %lu",
			    (unsigned long) tif->tif_row,
			    (unsigned long) tif->tif_col,
			    (unsigned long) tile);
			return ((tmsize_t)(-1));
		}
		cc = TIFFReadFile(tif, buf, size);
		if (cc != size) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
			TIFFErrorExt(tif->tif_clientdata, module,
	"Read error at row %lu, col %lu; got %I64u bytes, expected %I64u",
				     (unsigned long) tif->tif_row,
				     (unsigned long) tif->tif_col,
				     (unsigned __int64) cc,
				     (unsigned __int64) size);
#else
			TIFFErrorExt(tif->tif_clientdata, module,
	"Read error at row %lu, col %lu; got %llu bytes, expected %llu",
				     (unsigned long) tif->tif_row,
				     (unsigned long) tif->tif_col,
				     (unsigned long long) cc,
				     (unsigned long long) size);
#endif
			return ((tmsize_t)(-1));
		}
	} else {
		tmsize_t ma,mb;
		tmsize_t n;
		ma=(tmsize_t)td->td_stripoffset[tile];
		mb=ma+size;
		if (((uint64)ma!=td->td_stripoffset[tile])||(ma>tif->tif_size))
			n=0;
		else if ((mb<ma)||(mb<size)||(mb>tif->tif_size))
			n=tif->tif_size-ma;
		else
			n=size;
		if (n!=size) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
			TIFFErrorExt(tif->tif_clientdata, module,
"Read error at row %lu, col %lu, tile %lu; got %I64u bytes, expected %I64u",
				     (unsigned long) tif->tif_row,
				     (unsigned long) tif->tif_col,
				     (unsigned long) tile,
				     (unsigned __int64) n,
				     (unsigned __int64) size);
#else
			TIFFErrorExt(tif->tif_clientdata, module,
"Read error at row %lu, col %lu, tile %lu; got %llu bytes, expected %llu",
				     (unsigned long) tif->tif_row,
				     (unsigned long) tif->tif_col,
				     (unsigned long) tile,
				     (unsigned long long) n,
				     (unsigned long long) size);
#endif
			return ((tmsize_t)(-1));
		}
		_TIFFmemcpy(buf, tif->tif_base + ma, size);
	}
	return (size);
}

/*
 * Read a tile of data from the file.
 */
tmsize_t
TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
{
	static const char module[] = "TIFFReadRawTile";
	TIFFDirectory *td = &tif->tif_dir;
	uint64 bytecount64;
	tmsize_t bytecountm;

	if (!TIFFCheckRead(tif, 1))
		return ((tmsize_t)(-1));
	if (tile >= td->td_nstrips) {
		TIFFErrorExt(tif->tif_clientdata, module,
		    "%lu: Tile out of range, max %lu",
		    (unsigned long) tile, (unsigned long) td->td_nstrips);
		return ((tmsize_t)(-1));
	}
	if (tif->tif_flags&TIFF_NOREADRAW)
	{
		TIFFErrorExt(tif->tif_clientdata, module,
		"Compression scheme does not support access to raw uncompressed data");
		return ((tmsize_t)(-1));
	}
	bytecount64 = td->td_stripbytecount[tile];
	if (size != (tmsize_t)(-1) && (uint64)size < bytecount64)
		bytecount64 = (uint64)size;
	bytecountm = (tmsize_t)bytecount64;
	if ((uint64)bytecountm!=bytecount64)
	{
		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
		return ((tmsize_t)(-1));
	}
	return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module));
}

/*
 * Read the specified tile and setup for decoding. The data buffer is
 * expanded, as necessary, to hold the tile's data.
 */
int
TIFFFillTile(TIFF* tif, uint32 tile)
{
	static const char module[] = "TIFFFillTile";
	TIFFDirectory *td = &tif->tif_dir;

    if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
        return 0;

	if ((tif->tif_flags&TIFF_NOREADRAW)==0)
	{
		uint64 bytecount = td->td_stripbytecount[tile];
		if (bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
			TIFFErrorExt(tif->tif_clientdata, module,
				"%I64u: Invalid tile byte count, tile %lu",
				     (unsigned __int64) bytecount,
				     (unsigned long) tile);
#else
			TIFFErrorExt(tif->tif_clientdata, module,
				"%llu: Invalid tile byte count, tile %lu",
				     (unsigned long long) bytecount,
				     (unsigned long) tile);
#endif
			return (0);
		}
		if (isMapped(tif) &&
		    (isFillOrder(tif, td->td_fillorder)
		     || (tif->tif_flags & TIFF_NOBITREV))) {
			/*
			 * The image is mapped into memory and we either don't
			 * need to flip bits or the compression routine is
			 * going to handle this operation itself.  In this
			 * case, avoid copying the raw data and instead just
			 * reference the data from the memory mapped file
			 * image.  This assumes that the decompression
			 * routines do not modify the contents of the raw data
			 * buffer (if they try to, the application will get a
			 * fault since the file is mapped read-only).
			 */
			if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
				_TIFFfree(tif->tif_rawdata);
				tif->tif_rawdata = NULL;
				tif->tif_rawdatasize = 0;
			}
			tif->tif_flags &= ~TIFF_MYBUFFER;
			/*
			 * We must check for overflow, potentially causing
			 * an OOB read. Instead of simple
			 *
			 *  td->td_stripoffset[tile]+bytecount > tif->tif_size
			 *
			 * comparison (which can overflow) we do the following
			 * two comparisons:
			 */
			if (bytecount > (uint64)tif->tif_size ||
			    td->td_stripoffset[tile] > (uint64)tif->tif_size - bytecount) {
				tif->tif_curtile = NOTILE;
				return (0);
			}
			tif->tif_rawdatasize = (tmsize_t)bytecount;
			tif->tif_rawdata =
				tif->tif_base + (tmsize_t)td->td_stripoffset[tile];
                        tif->tif_rawdataoff = 0;
                        tif->tif_rawdataloaded = (tmsize_t) bytecount;
			tif->tif_flags |= TIFF_BUFFERMMAP;
		} else {
			/*
			 * Expand raw data buffer, if needed, to hold data
			 * tile coming from file (perhaps should set upper
			 * bound on the size of a buffer we'll use?).
			 */
			tmsize_t bytecountm;
			bytecountm=(tmsize_t)bytecount;
			if ((uint64)bytecountm!=bytecount)
			{
				TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
				return(0);
			}
			if (bytecountm > tif->tif_rawdatasize) {
				tif->tif_curtile = NOTILE;
				if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
					TIFFErrorExt(tif->tif_clientdata, module,
					    "Data buffer too small to hold tile %lu",
					    (unsigned long) tile);
					return (0);
				}
				if (!TIFFReadBufferSetup(tif, 0, bytecountm))
					return (0);
			}
			if (tif->tif_flags&TIFF_BUFFERMMAP) {
				tif->tif_curtile = NOTILE;
				if (!TIFFReadBufferSetup(tif, 0, bytecountm))
					return (0);
			}

			if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata,
			    bytecountm, module) != bytecountm)
				return (0);

                        tif->tif_rawdataoff = 0;
                        tif->tif_rawdataloaded = bytecountm;

			if (!isFillOrder(tif, td->td_fillorder) &&
			    (tif->tif_flags & TIFF_NOBITREV) == 0)
				TIFFReverseBits(tif->tif_rawdata,
                                                tif->tif_rawdataloaded);
		}
	}
	return (TIFFStartTile(tif, tile));
}

/*
 * Setup the raw data buffer in preparation for
 * reading a strip of raw data.  If the buffer
 * is specified as zero, then a buffer of appropriate
 * size is allocated by the library.  Otherwise,
 * the client must guarantee that the buffer is
 * large enough to hold any individual strip of
 * raw data.
 */
int
TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
{
	static const char module[] = "TIFFReadBufferSetup";

	assert((tif->tif_flags&TIFF_NOREADRAW)==0);
	tif->tif_flags &= ~TIFF_BUFFERMMAP;

	if (tif->tif_rawdata) {
		if (tif->tif_flags & TIFF_MYBUFFER)
			_TIFFfree(tif->tif_rawdata);
		tif->tif_rawdata = NULL;
		tif->tif_rawdatasize = 0;
	}
	if (bp) {
		tif->tif_rawdatasize = size;
		tif->tif_rawdata = (uint8*) bp;
		tif->tif_flags &= ~TIFF_MYBUFFER;
	} else {
		tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024);
		if (tif->tif_rawdatasize==0)
			tif->tif_rawdatasize=(tmsize_t)(-1);
		tif->tif_rawdata = (uint8*) _TIFFmalloc(tif->tif_rawdatasize);
		tif->tif_flags |= TIFF_MYBUFFER;
	}
	if (tif->tif_rawdata == NULL) {
		TIFFErrorExt(tif->tif_clientdata, module,
		    "No space for data buffer at scanline %lu",
		    (unsigned long) tif->tif_row);
		tif->tif_rawdatasize = 0;
		return (0);
	}
	return (1);
}

/*
 * Set state to appear as if a
 * strip has just been read in.
 */
static int
TIFFStartStrip(TIFF* tif, uint32 strip)
{
	TIFFDirectory *td = &tif->tif_dir;

    if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
        return 0;

	if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
		if (!(*tif->tif_setupdecode)(tif))
			return (0);
		tif->tif_flags |= TIFF_CODERSETUP;
	}
	tif->tif_curstrip = strip;
	tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
        tif->tif_flags &= ~TIFF_BUF4WRITE;

	if (tif->tif_flags&TIFF_NOREADRAW)
	{
		tif->tif_rawcp = NULL;
		tif->tif_rawcc = 0;
	}
	else
	{
		tif->tif_rawcp = tif->tif_rawdata;
		tif->tif_rawcc = (tmsize_t)td->td_stripbytecount[strip];
	}
	return ((*tif->tif_predecode)(tif,
			(uint16)(strip / td->td_stripsperimage)));
}

/*
 * Set state to appear as if a
 * tile has just been read in.
 */
static int
TIFFStartTile(TIFF* tif, uint32 tile)
{
	TIFFDirectory *td = &tif->tif_dir;

    if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
        return 0;

	if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
		if (!(*tif->tif_setupdecode)(tif))
			return (0);
		tif->tif_flags |= TIFF_CODERSETUP;
	}
	tif->tif_curtile = tile;
	tif->tif_row =
	    (tile % TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth)) *
		td->td_tilelength;
	tif->tif_col =
	    (tile % TIFFhowmany_32(td->td_imagelength, td->td_tilelength)) *
		td->td_tilewidth;
        tif->tif_flags &= ~TIFF_BUF4WRITE;
	if (tif->tif_flags&TIFF_NOREADRAW)
	{
		tif->tif_rawcp = NULL;
		tif->tif_rawcc = 0;
	}
	else
	{
		tif->tif_rawcp = tif->tif_rawdata;
		tif->tif_rawcc = (tmsize_t)td->td_stripbytecount[tile];
	}
	return ((*tif->tif_predecode)(tif,
			(uint16)(tile/td->td_stripsperimage)));
}

static int
TIFFCheckRead(TIFF* tif, int tiles)
{
	if (tif->tif_mode == O_WRONLY) {
		TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "File not open for reading");
		return (0);
	}
	if (tiles ^ isTiled(tif)) {
		TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ?
		    "Can not read tiles from a stripped image" :
		    "Can not read scanlines from a tiled image");
		return (0);
	}
	return (1);
}

void
_TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc)
{
    (void) tif; (void) buf; (void) cc;
}

void
_TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc)
{
    (void) tif;
    assert((cc & 1) == 0);
    TIFFSwabArrayOfShort((uint16*) buf, cc/2);
}

void
_TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc)
{
    (void) tif;
    assert((cc % 3) == 0);
    TIFFSwabArrayOfTriples((uint8*) buf, cc/3);
}

void
_TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc)
{
    (void) tif;
    assert((cc & 3) == 0);
    TIFFSwabArrayOfLong((uint32*) buf, cc/4);
}

void
_TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc)
{
    (void) tif;
    assert((cc & 7) == 0);
    TIFFSwabArrayOfDouble((double*) buf, cc/8);
}

/* vim: set ts=8 sts=8 sw=8 noet: */
/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 8
 * fill-column: 78
 * End:
 */

redpajama_set_name: RedPajamaGithub


text:
//
//  LJPaymentSuccessViewController.m
//  xianchufang
//
//  Created by zhenglong duan on 01/03/2017.
//  Copyright © 2017 zhenglong duan. All rights reserved.
////    支付成功界面 (1.付款成功 2.确认收货成功)

#import "LJPaymentSuccessViewController.h"

@interface LJPaymentSuccessViewController ()

/**
 提示信息
 */
@property (nonatomic,strong) UILabel *tipLabel;
/*** 第二个背景 ***/
@property (nonatomic,strong) UIView *bga2;
@end

@implementation LJPaymentSuccessViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"付款成功";
    self.view.backgroundColor = LJCommonBgColor;
}

#pragma mark --子控件
- (void)addChildren {
    UIImageView *header = [[UIImageView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, spaceEdgeH(120))];
    header.image = [UIImage imageNamed:@"shopping_order_beijing"];
    [self.view addSubview:header];
    UILabel *tipL = [[UILabel alloc] initWithFrame:CGRectMake(spaceEdgeW(15), 0, SCREEN_WIDTH / 2, spaceEdgeH(20))];
    tipL.lj_centerY = header.lj_height / 2;
    tipL.textColor = [UIColor whiteColor];
    [header addSubview:tipL];
    tipL.text = @"交易完成,货款已到账";

    UIView *bg1 = [[UIView alloc] initWithFrame:CGRectMake(0, header.lj_bottom + spaceEdgeH(10), SCREEN_WIDTH, spaceEdgeH(40))];
    bg1.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bg1];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(ClickTap:)];
    bg1.userInteractionEnabled = YES;
    [bg1 addGestureRecognizer:tap];
    self.tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(spaceEdgeW(10), 0, SCREEN_WIDTH / 2, spaceEdgeH(40))];
    [self.tipLabel setFont:LJFontSize15];
    [self.tipLabel setTextColor:LJFontColor4c];
    [bg1 addSubview:self.tipLabel];

    UIImageView *imgaeView = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - spaceEdgeW(20), spaceEdgeH(10), 0, 0)];
    imgaeView.image = [UIImage imageNamed:@"my_go_icon"];
    [imgaeView sizeToFit];
    [bg1 addSubview:imgaeView];

    self.bga2= [[UIView alloc] initWithFrame:CGRectMake(0, bg1.lj_bottom + spaceEdgeH(2), SCREEN_WIDTH, spaceEdgeH(40))];
    self.bga2.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.bga2];

    UIButton *Btn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - spaceEdgeW(100), 0, spaceEdgeW(75), spaceEdgeH(27))];
    Btn.lj_centerY = self.bga2.lj_height / 2;
    [Btn setTitle:@"立即评价" forState:UIControlStateNormal];
    [Btn setTitleColor:LJFontColored forState:UIControlStateNormal];
    Btn.layer.borderColor = LJFontColored.CGColor;
    [Btn.titleLabel setFont:LJFontSize16];
    Btn.layer.borderWidth = 1;
    [Btn setLayerWithCr:3];
    [Btn addTarget:self action:@selector(ClickCommit:) forControlEvents:UIControlEventTouchUpInside];
    [self.bga2 addSubview:Btn];
}

- (void)setIsSuccess:(BOOL)isSuccess {
    _isSuccess = isSuccess;
    [self addChildren];//
    if (_isSuccess == NO) {
        [self.bga2 removeFromSuperview];
        self.tipLabel.text = @"查看订单";
    }else{
        self.tipLabel.text = [NSString stringWithFormat:@"本次交易获得%@积分",self.integral];
    }
}

#pragma mark --点击查看已付款订单或积分详情
- (void)ClickTap:(UITapGestureRecognizer *)tapGesture {
    if (self.isSuccess) {
        ///交易完成,进入积分明细页面
    }else{
        //付款成功,进入待发货页面
        LJLogFunc
    }
}

#pragma mark --点击查看待评价订单
- (void)ClickCommit:(UIButton *)sender {
    LJLogFunc
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end


text:
package com.oltruong.teamag.webbean;

import java.util.Date;

public class WorkWebBean {

    private String project;
    private TaskWebBean taskBean;
    private String task;

    private String member;

    private Date day;

    private Double amount;

    private Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getProject() {
        return project;
    }

    public void setProject(String project) {
        this.project = project;
    }

    public TaskWebBean getTaskBean() {
        return taskBean;
    }

    public void setTaskBean(TaskWebBean task) {
        this.taskBean = task;
    }

    public String getTask() {
        return task;
    }

    public void setTask(String task) {
        this.task = task;
    }

    public String getMember() {
        return member;
    }

    public void setMember(String member) {
        this.member = member;
    }

    public Date getDay() {
        return day;
    }

    public long getDaylong() {
        return day.getTime();
    }

    public void setDay(Date day) {
        this.day = day;
    }

    public Double getAmount() {
        return amount;
    }

    public Double getOriginal() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

}


text:
Noteworthy in Version 1.2.7
==============================================================================

Summary:

* Support `Gherkin v6 grammar`_ (to simplify usage of `Example Mapping`_)
* Use/Support :pypi:`cucumber-tag-expressions` (superceed: old-style tag-expressions)
* :pypi:`cucumber-tag-expressions` are extended by "tag-matching"
  to match partial tag names, like: ``@foo.*``
* `Select-by-location for Scenario Containers`_ (Feature, Rule, ScenarioOutline)
* `Support for emojis in feature files and steps`_
* `Improve Active-Tags Logic`_

.. _`Example Mapping`: https://cucumber.io/blog/example-mapping-introduction/
.. _`Example Mapping Webinar`: https://cucumber.io/blog/example-mapping-webinar/
.. _`Gherkin v6 grammar`: https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin.berp

Support Gherkin v6 Grammar
-------------------------------------------------------------------------------

Grammar changes:

* ``Rule`` concept added to better correspond to `Example Mapping`_ concepts
* Add aliases for ``Scenario`` and ``Scenario Outline`` (for similar reasons)

A Rule (or: business rule) allows to group multiple Scenario(s)/Example(s)::

    # -- RULE GRAMMAR PSEUDO-CODE:
    @tag1 @tag2
    Rule: Optional Rule Title...
        Description?        #< CARDINALITY: 0..1 (optional)
        Background?         #< CARDINALITY: 0..1 (optional)
        Scenario*           #< CARDINALITY: 0..N (many)
        ScenarioOutline*    #< CARDINALITY: 0..N (many)

Gherkin v6 keyword aliases::

    | Concept          | Preferred Keyword | Alias(es)          |
    | Scenario         | Example           | Scenario           |
    | Scenario Outline | Scenario Outline  | Scenario Template  |

Example:

.. code-block:: gherkin

    # -- FILE: features/example_with_rules.feature
    # USING: Gherkin v6
    Feature: With Rules

      Background: Feature.Background
        Given feature background step_1

      Rule: Rule_1
        Background: Rule_1.Background
          Given rule_1 background step_1

        Example: Rule_1.Example_1
          Given rule_1 scenario_1 step_1

      Rule: Rule_2

        Example: Rule_2.Example_1
          Given rule_2 scenario_1 step_1

      Rule: Rule_3
        Background: Rule_3.EmptyBackground
        Example: Rule_3.Example_1
          Given rule_3 scenario_1 step_1

Overview of the `Example Mapping`_ concepts:

.. image:: _static/Cucumber_ExampleMapping.png
    :scale: 50 %
    :alt: Cucumber: `Example Mapping`_

.. seealso::

    **Gherkin v6**:

    * https://docs.cucumber.io/gherkin/reference/
    * `Gherkin v6 grammar`_

    **Example Mapping:**

    * Cucumber: Introduction to `Example Mapping`_ (by: Matt Wynne)
    * Cucumber: `Example Mapping Webinar`_
    * https://docs.cucumber.io/bdd/example-mapping/

    **More on Example Mapping:**

    * https://speakerdeck.com/mattwynne/rules-vs-examples-bddx-london-2014
    * https://lisacrispin.com/2016/06/02/experiment-example-mapping/
    * https://tobythetesterblog.wordpress.com/2016/05/25/how-to-do-example-mapping/

.. hint:: **Gherkin v6 Grammar Issues**

    * :cucumber.issue:`632`: Rule tags are currently only supported in `behave`.
      The Cucumber Gherkin v6 grammar currently lacks this functionality.

    * :cucumber.issue:`590`: Rule Background:
      A proposal is pending to remove Rule Backgrounds again

.. include:: _content.tag_expressions_v2.rst

Select-by-location for Scenario Containers
-------------------------------------------------------------------------------

In the past, it was already possible to scenario(s) by using its **file-location**.

A **file-location** has the schema: ``<FILENAME>:<LINE_NUMBER>``.
Example: ``features/alice.feature:12``
(refers to ``line 12`` in ``features/alice.feature`` file).

Rules to select **Scenarios** by using the file-location:

* **Scenario:** Use a file-location that points to the keyword/title or its steps
  (until next Scenario/Entity starts).

* **Scenario of a ScenarioOutline:**
  Use the file-location of its Examples row.

Now you can select all entities of a **Scenario Container** (Feature, Rule, ScenarioOutline):

* **Feature:**
  Use file-location before first contained entity/Scenario starts.

* **Rule:**
  Use file-location from keyword/title line to line before its first Scenario/Background.

* **ScenarioOutline:**
  Use file-location from keyword/title line to line before its Examples rows.

A file-location into a **Scenario Container** selects all its entities
(Scenarios, ...).

Support for Emojis in Feature Files and Steps
-------------------------------------------------------------------------------

* Emojis can now be used in ``*.feature`` files.
* Emojis can now be used in step definitions.
* You can now use ``language=emoji (em)`` in ``*.feature`` files ;-)

.. literalinclude:: ../features/i18n_emoji.feature
    :prepend:  # -- FILE: features/i18n_emoji.feature
    :language: gherkin

.. literalinclude:: ../features/steps/i18n_emoji_steps.py
    :prepend:  # -- FILE: features/steps/i18n_emoji_steps.py
    :language: python

Improve Active-Tags Logic
-------------------------------------------------------------------------------

The active-tag computation logic was slightly changed (and fixed):

* if multiple active-tags with same category are used
* combination of positive active-tags (``use.with_{category}={value}``) and
  negative active-tags (``not.with_{category}={value}``) with same category
  are now supported

All active-tags with same category are combined into one category tag-group.
The following logical expression is used for active-tags with the same category::

    category_tag_group.enabled := positive-tag-expression and not negative-tag-expression
      positive-tag-expression  := enabled(tag1) or enabled(tag2) or ...
      negative-tag-expression  := enabled(tag3) or enabled(tag4) or ...
       tag1, tag2 are positive-tags, like @use.with_category=value
       tag3, tag4 are negative-tags, like @not.with_category=value

EXAMPLE:

.. code-block:: gherkin

    Feature: Active-Tag Example

      @use.with_browser=Safari
      @use.with_browser=Chrome
      @not.with_browser=Firefox
      Scenario: Use one active-tag group/category

        HINT: Only executed with web browser Safari and Chrome, Firefox is explicitly excluded.
        ...

      @use.with_browser=Firefox
      @use.with_os=linux
      @use.with_os=darwin
      Scenario: Use two active-tag groups/categories

        HINT 1: Only executed with browser: Firefox
        HINT 2: Only executed on OS: Linux and Darwin (macOS)
        ...


text:
COMMIT = $$(git describe --always)
DEBUG_FLAG = $(if $(DEBUG),-debug)

deps:
	go get -v golang.org/x/tools/cmd/vet
	go get -v github.com/golang/lint/golint
	go get -v github.com/jteeuwen/go-bindata/...
	go get -v -d -t ./...

build: deps
	cd skeleton; go-bindata -pkg="skeleton" resource/...
	go build -ldflags "-X main.GitCommit \"$(COMMIT)\"" -o bin/gcli

install: deps
	cd skeleton; go-bindata -pkg="skeleton" resource/...
	go install -ldflags "-X main.GitCommit \"$(COMMIT)\""

test: build
	./test.sh

tests: build
	cd tests; go test -v ./...

test-docker:
	./test-docker.sh


text:
/*
 *  user 用户表 的 CRUD 模块
 */
var mysql = require('mysql');
var config = require('./config');

// 用户表常用的 sql 语句(包括 like 表的增删查操作)
var sql = {
    insert:'insert into user(user, password, nickname) values(?,?,?)',
    insertLike: 'insert into likearticle(user_id, article_id) values(?,?)',
	delete: 'delete from user where id=?',
    delLike: 'delete from likearticle where user_id=? and article_id=?',
	updatePass: 'update user set password=? where id=?',
    updateInfo: 'update user set nickname=?,signature=? where id=?',
    updateAvatar: 'update user set avatar=? where id=?',
    queryCount: 'select count(*) as count from user',
	queryById: 'select * from user where id=?',
	queryByRange: 'select * from user limit ?,?',
    queryByUser: 'select * from user where user=?',
    queryByUP: 'select * from user where user=? and password=?',
    queryisLike: 'select count(*) as count from likearticle where user_id=? and article_id=?',
    queryAllLike: 'select * from likeartview where user_id=?',
};

var pool = mysql.createPool(config);

// 数据库操作
function crud(sql, param, cb) {
    pool.getConnection(function(err, connection) {
        connection.query(sql, param, function(err, rows) {
            cb && cb(rows);
            connection.release();
        });
    });
}

module.exports = {
    queryCount: function(param, cb) {
        crud(sql.queryCount, param, cb);
    },
    queryById: function(param, cb) {
        crud(sql.queryById, param, cb);
    },
    queryByRange: function(param, cb) {
        crud(sql.queryByRange, param, cb);
    },
    queryByUser: function(param, cb) {
        crud(sql.queryByUser, param, cb);
    },
    addUser: function(param, cb) {
        crud(sql.insert, param, cb);
    },
    delUser: function(param, cb) {
        crud(sql.delete, param, cb);
    },
    modPass: function(param, cb) {
        crud(sql.updatePass, param, cb);
    },
    upUserInfo: function(param, cb) {
        crud(sql.updateInfo, param, cb);
    },
    upAvatar: function(param, cb) {
        crud(sql.updateAvatar, param, cb);
    },
    queryByUP: function(param, cb) {
        crud(sql.queryByUP, param, cb);
    },
    insertLike: function(param, cb) {
        crud(sql.insertLike, param, cb);
    },
    delLike: function(param, cb) {
        crud(sql.delLike, param, cb);
    },
    queryisLike: function(param, cb) {
        crud(sql.queryisLike, param, cb);
    },
    queryAllLike: function(param, cb) {
        crud(sql.queryAllLike, param, cb);
    },
};


text:
namespace Bog.Web.Api
{
    using System;

    using Bog.Web.Api.Providers;

    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using Microsoft.Owin;
    using Microsoft.Owin.Security.Cookies;
    using Microsoft.Owin.Security.OAuth;

    using Owin;

    public partial class Startup
    {
        #region Constructors and Destructors

        static Startup()
        {
            PublicClientId = "self";

            UserManagerFactory = () => new UserManager<IdentityUser>(new UserStore<IdentityUser>());

            OAuthOptions = new OAuthAuthorizationServerOptions
                               {
                                   TokenEndpointPath = new PathString("/Token"),
                                   Provider =
                                       new ApplicationOAuthProvider(
                                       PublicClientId,
                                       UserManagerFactory),
                                   AuthorizeEndpointPath =
                                       new PathString("/api/Account/ExternalLogin"),
                                   AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
                                   AllowInsecureHttp = true
                               };
        }

        #endregion

        #region Public Properties

        public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }

        public static string PublicClientId { get; private set; }
        public static Func<UserManager<IdentityUser>> UserManagerFactory { get; set; }

        #endregion

        // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
        #region Public Methods and Operators

        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            // and to use a cookie to temporarily store information about a user logging in with a third party login provider
            app.UseCookieAuthentication(new CookieAuthenticationOptions());
            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

            // Enable the application to use bearer tokens to authenticate users
            app.UseOAuthBearerTokens(OAuthOptions);

            // Uncomment the following lines to enable logging in with third party login providers
            app.UseMicrosoftAccountAuthentication("000000004C107D13", "C5EFKmId45HlG0H0X65Rqidc1h7Fcw1A");

            app.UseTwitterAuthentication("9d61pQQu1XuCkc8Op6IqA", "bABg2DdiTa2tL0weeS4Y4VTAux87QWPi7zEa0IqFYg");

            app.UseFacebookAuthentication("178224175708352", "0f75d3ce541c9271abe13256fd4d6645");

            app.UseGoogleAuthentication();
        }

        #endregion
    }
}


text:
require 'administrate/base_dashboard'

# Dashboard for Pet model.
class PetDashboard < Administrate::BaseDashboard
  # ATTRIBUTE_TYPES
  # a hash that describes the type of each of the model's fields.
  #
  # Each different type represents an Administrate::Field object,
  # which determines how the attribute is displayed
  # on pages throughout the dashboard.
  ATTRIBUTE_TYPES = {
    breed: Field::BelongsTo,
    owner: Field::BelongsTo.with_options(class_name: 'User'),
    id: Field::Number,
    name: Field::String,
    owner_id: Field::Number,
    gender: Field::Number,
    created_at: Field::DateTime,
    updated_at: Field::DateTime
  }

  # COLLECTION_ATTRIBUTES
  # an array of attributes that will be displayed on the model's index page.
  #
  # By default, it's limited to four items to reduce clutter on index pages.
  # Feel free to add, remove, or rearrange items.
  COLLECTION_ATTRIBUTES = [
    :breed,
    :owner,
    :id,
    :name
  ]

  # SHOW_PAGE_ATTRIBUTES
  # an array of attributes that will be displayed on the model's show page.
  SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys

  # FORM_ATTRIBUTES
  # an array of attributes that will be displayed
  # on the model's form (`new` and `edit`) pages.
  FORM_ATTRIBUTES = [
    :breed,
    :owner,
    :name,
    :owner_id,
    :gender
  ]
end


text:
<?php

namespace backend\controllers;

use Yii;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\Category;
use common\models\Model;
use common\models\Upload;

class CategoryController extends BackendController {

    public function behaviors() {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    ['actions' => ['index', 'create', 'update', 'delete', 'delete-picture'], 'allow' => true, 'roles' => ['@']]
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'], 'delete-picture' => ['POST'],
                ],
            ],
        ];
    }

    public function actionIndex() {
        if (Yii::$app->request->isAjax) {
            Category::updateBySort(Yii::$app->request->post()) ? $this->ajaxSuccess() : $this->ajaxError();
        }

        $var['id'] = (int) Yii::$app->request->get('id');
        $var['list'] = Category::getCategory(['parent_id' => $var['id']]);
        $var['nav'] = Category::getNav($var['id']);
        $var['model_kv'] = Model::getKV();
        return $this->render('index', $var);
    }

    public function actionCreate() {
        if (Yii::$app->request->isAjax) {
            $this->commonCreate(new Category());
        }

        $var['id'] = (int) Yii::$app->request->get('id');
        $var['select'] = Category::getSelect($var['id']);
        $var['model_kv'] = Model::getKV();
        return $this->render('create', $var);
    }

    public function actionUpdate($id) {
        $model = $this->findModel($id);

        if (Yii::$app->request->isAjax) {
            $this->commonUpdate($model);
        }

        $var['model'] = $model;
        $var['select'] = Category::getSelect($model->c_parent_id);
        $var['model_kv'] = Model::getKV();
        $var['content'] = isset($model->content->c_content) ? $model->content->c_content : '';
        return $this->render('update', $var);
    }

    public function actionDelete($id) {
        if (Yii::$app->request->isAjax) {
            $model = $this->findModel($id);
            $model->delete() ? $this->ajaxSuccess() : $this->ajaxError();
        }
    }

    public function actionDeletePicture($id) {
        if (Yii::$app->request->isAjax) {
            $this->pictureDelete($this->findModel($id)) ? $this->ajaxSuccess() : $this->ajaxError();
        }
    }

    protected function findModel($id) {
        if (($model = Category::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }

}


text:
'use strict';

/*global mocha:true, alert:true, window:true */

(function() {
  // Send messages to the parent phantom.js process via alert! Good times!!
  var sendMessage = function sendMessage() {
    var args = [].slice.call(arguments);
    alert(JSON.stringify(args));
  };

  // Create a listener who'll bubble events from Phantomjs to Grunt
  var createGruntListener = function createGruntListener(ev, runner) {

    runner.on(ev, function(test, err) {
      var data = {
        err: err
      };

      if (test) {
        data.title = test.title;
        data.fullTitle = test.fullTitle();
      }

      if (ev === 'end' && window._$jscoverage) {
        var cov = {};
        for(var prop in window._$jscoverage) {
          var file = window._$jscoverage[prop];
          file[0] = file.source;
          cov[prop] = file;
        }
        data.cov = cov;
      }

      sendMessage('mocha.' + ev, data);

    });
  };

  var GruntReporter = function(runner){
    // 1.4.2 moved reporters to Mocha instead of mocha
    var mochaInstance = window.Mocha || window.mocha;

    if (!mochaInstance) {
      throw new Error(
        'Mocha was not found, make sure you include Mocha in your HTML ' +
        'spec file.'
      );
    }

    // Setup HTML reporter to output data on the screen
    mochaInstance.reporters.HTML.call(this, runner);

    // Create a Grunt listener for each Mocha events
    var events = [
      'start',
      'test',
      'test end',
      'suite',
      'suite end',
      'fail',
      'pass',
      'pending',
      'end'
    ];

    for(var i = 0; i < events.length; i++) {
      createGruntListener(events[i], runner);
    }

  };

  var options = window.PHANTOMJS;
  if (options) {
    // Default mocha options
    var config = {
      ui: 'bdd',
      ignoreLeaks: true,
      reporter: GruntReporter
    },
    run = options.run,
    key;

    if (options) {
      // If options is a string, assume it is to set the UI (bdd/tdd etc)
      if (typeof options === 'string') {
        config.ui = options;
      } else {
        // Extend defaults with passed options
        for (key in options.mocha) {
          config[key] = options.mocha[key];
        }
      }
    }

    config.reporter = GruntReporter;

    mocha.setup(config);

    // task option `run`, automatically runs mocha for grunt only
    if (run) {
      mocha.run();
    }
  } else {
    mocha.ui('bdd');
    mocha.reporter('html');
  }
}());


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>swift</artifactId>
    <packaging>pom</packaging>
    <version>3.8-SNAPSHOT</version>
    <name>Swift Modules</name>
    <url>http://swift.mayo.edu</url>
    <parent>
        <groupId>edu.mayo.mprc</groupId>
        <artifactId>mprc</artifactId>
        <version>3.7.3</version>
        <relativePath>../mprc/pom.xml</relativePath>
    </parent>

    <modules>
        <module>core</module>
        <module>web</module>
        <module>launcher</module>
        <module>config-ui</module>
        <module>db-curator-ui</module>
        <module>gwt-common</module>
        <module>scripts</module>
        <module>installer</module>
        <module>install-test</module>
    </modules>
</project>


text:
    <meta charset='utf-8'>
    <title>Quex</title>
    <meta name="description" content="">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">

    <link rel="stylesheet" href="vendor/core.css">

            Please enable JavaScript to view the comments powered by Disqus.

<link rel="stylesheet" href="vendor/extension/sidebar-background/main.css">

<link rel="stylesheet" href="vendor/extension/load-progress/dist/main.css">


text:
package com.ratingfund.app.model;

public class FundM extends FundA{
	private String spriceDiscount;
	private String bpriceDiscount;
	public String getSpriceDiscount() {
		return spriceDiscount;
	}
	public void setSpriceDiscount(String spriceDiscount) {
		this.spriceDiscount = spriceDiscount;
	}
	public String getBpriceDiscount() {
		return bpriceDiscount;
	}
	public void setBpriceDiscount(String bpriceDiscount) {
		this.bpriceDiscount = bpriceDiscount;
	}

}


text:
layout: base
---

Gaming the Lottery

An international investigation into the global lottery industry.

Read the stories


text:
Range
=====

Validates that a given number is *between* some minimum and maximum number.

+----------------+---------------------------------------------------------------------+
| Applies to     | :ref:`property or method <validation-property-target>`              |
+----------------+---------------------------------------------------------------------+
| Options        | - `min`_                                                            |
|                | - `max`_                                                            |
|                | - `minMessage`_                                                     |
|                | - `maxMessage`_                                                     |
|                | - `invalidMessage`_                                                 |
|                | - `payload`_                                                        |
+----------------+---------------------------------------------------------------------+
| Class          | :class:`Symfony\\Component\\Validator\\Constraints\\Range`          |
+----------------+---------------------------------------------------------------------+
| Validator      | :class:`Symfony\\Component\\Validator\\Constraints\\RangeValidator` |
+----------------+---------------------------------------------------------------------+

Basic Usage
-----------

To verify that the "height" field of a class is between "120" and "180",
you might add the following:

.. configuration-block::

    .. code-block:: php-annotations

        // src/AppBundle/Entity/Participant.php
        namespace AppBundle\Entity;

        use Symfony\Component\Validator\Constraints as Assert;

        class Participant
        {
            /**
             * @Assert\Range(
             *      min = 120,
             *      max = 180,
             *      minMessage = "You must be at least {{ limit }}cm tall to enter",
             *      maxMessage = "You cannot be taller than {{ limit }}cm to enter"
             * )
             */
             protected $height;
        }

    .. code-block:: yaml

        # src/AppBundle/Resources/config/validation.yml
        AppBundle\Entity\Participant:
            properties:
                height:
                    - Range:
                        min: 120
                        max: 180
                        minMessage: You must be at least {{ limit }}cm tall to enter
                        maxMessage: You cannot be taller than {{ limit }}cm to enter

    .. code-block:: xml

        <!-- src/AppBundle/Resources/config/validation.xml -->
        <?xml version="1.0" encoding="UTF-8" ?>
        <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

            <class name="AppBundle\Entity\Participant">
                <property name="height">
                    <constraint name="Range">
                        <option name="min">120</option>
                        <option name="max">180</option>
                        <option name="minMessage">You must be at least {{ limit }}cm tall to enter</option>
                        <option name="maxMessage">You cannot be taller than {{ limit }}cm to enter</option>
                    </constraint>
                </property>
            </class>
        </constraint-mapping>

    .. code-block:: php

        // src/AppBundle/Entity/Participant.php
        namespace AppBundle\Entity;

        use Symfony\Component\Validator\Mapping\ClassMetadata;
        use Symfony\Component\Validator\Constraints as Assert;

        class Participant
        {
            public static function loadValidatorMetadata(ClassMetadata $metadata)
            {
                $metadata->addPropertyConstraint('height', new Assert\Range(array(
                    'min'        => 120,
                    'max'        => 180,
                    'minMessage' => 'You must be at least {{ limit }}cm tall to enter',
                    'maxMessage' => 'You cannot be taller than {{ limit }}cm to enter',
                )));
            }
        }

Date Ranges
-----------

This constraint can be used to compare ``DateTime`` objects against date ranges.
The minimum and maximum date of the range should be given as any date string
`accepted by the DateTime constructor`_. For example, you could check that a
date must lie within the current year like this:

.. configuration-block::

    .. code-block:: php-annotations

        // src/AppBundle/Entity/Event.php
        namespace AppBundle\Entity;

        use Symfony\Component\Validator\Constraints as Assert;

        class Event
        {
            /**
             * @Assert\Range(
             *      min = "first day of January",
             *      max = "first day of January next year"
             * )
             */
            protected $startDate;
        }

    .. code-block:: yaml

        # src/AppBundle/Resources/config/validation.yml
        AppBundle\Entity\Event:
            properties:
                startDate:
                    - Range:
                        min: first day of January
                        max: first day of January next year

    .. code-block:: xml

        <!-- src/AppBundle/Resources/config/validation.xml -->
        <?xml version="1.0" encoding="UTF-8" ?>
        <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

            <class name="AppBundle\Entity\Event">
                <property name="startDate">
                    <constraint name="Range">
                        <option name="min">first day of January</option>
                        <option name="max">first day of January next year</option>
                    </constraint>
                </property>
            </class>
        </constraint-mapping>

    .. code-block:: php

        // src/AppBundle/Entity/Event.php
        namespace AppBundle\Entity;

        use Symfony\Component\Validator\Mapping\ClassMetadata;
        use Symfony\Component\Validator\Constraints as Assert;

        class Event
        {
            public static function loadValidatorMetadata(ClassMetadata $metadata)
            {
                $metadata->addPropertyConstraint('startDate', new Assert\Range(array(
                    'min' => 'first day of January',
                    'max' => 'first day of January next year',
                )));
            }
        }

Be aware that PHP will use the server's configured timezone to interpret these
dates. If you want to fix the timezone, append it to the date string:

.. configuration-block::

    .. code-block:: php-annotations

        // src/AppBundle/Entity/Event.php
        namespace AppBundle\Entity;

        use Symfony\Component\Validator\Constraints as Assert;

        class Event
        {
            /**
             * @Assert\Range(
             *      min = "first day of January UTC",
             *      max = "first day of January next year UTC"
             * )
             */
            protected $startDate;
        }

    .. code-block:: yaml

        # src/AppBundle/Resources/config/validation.yml
        AppBundle\Entity\Event:
            properties:
                startDate:
                    - Range:
                        min: first day of January UTC
                        max: first day of January next year UTC

    .. code-block:: xml

        <!-- src/AppBundle/Resources/config/validation.xml -->
        <?xml version="1.0" encoding="UTF-8" ?>
        <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

            <class name="AppBundle\Entity\Event">
                <property name="startDate">
                    <constraint name="Range">
                        <option name="min">first day of January UTC</option>
                        <option name="max">first day of January next year UTC</option>
                    </constraint>
                </property>
            </class>
        </constraint-mapping>

    .. code-block:: php

        // src/AppBundle/Entity/Person.php
        namespace AppBundle\Entity;

        use Symfony\Component\Validator\Mapping\ClassMetadata;
        use Symfony\Component\Validator\Constraints as Assert;

        class Event
        {
            public static function loadValidatorMetadata(ClassMetadata $metadata)
            {
                $metadata->addPropertyConstraint('startDate', new Assert\Range(array(
                    'min' => 'first day of January UTC',
                    'max' => 'first day of January next year UTC',
                )));
            }
        }

The ``DateTime`` class also accepts relative dates or times. For example, you
can check that a delivery date starts within the next five hours like this:

.. configuration-block::

    .. code-block:: php-annotations

        // src/AppBundle/Entity/Order.php
        namespace AppBundle\Entity;

        use Symfony\Component\Validator\Constraints as Assert;

        class Order
        {
            /**
             * @Assert\Range(
             *      min = "now",
             *      max = "+5 hours"
             * )
             */
            protected $deliveryDate;
        }

    .. code-block:: yaml

        # src/AppBundle/Resources/config/validation.yml
        AppBundle\Entity\Order:
            properties:
                deliveryDate:
                    - Range:
                        min: now
                        max: +5 hours

    .. code-block:: xml

        <!-- src/AppBundle/Resources/config/validation.xml -->
        <?xml version="1.0" encoding="UTF-8" ?>
        <constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

            <class name="AppBundle\Entity\Order">
                <property name="deliveryDate">
                    <constraint name="Range">
                        <option name="min">now</option>
                        <option name="max">+5 hours</option>
                    </constraint>
                </property>
            </class>
        </constraint-mapping>

    .. code-block:: php

        // src/AppBundle/Entity/Order.php
        namespace AppBundle\Entity;

        use Symfony\Component\Validator\Mapping\ClassMetadata;
        use Symfony\Component\Validator\Constraints as Assert;

        class Order
        {
            public static function loadValidatorMetadata(ClassMetadata $metadata)
            {
                $metadata->addPropertyConstraint('deliveryDate', new Assert\Range(array(
                    'min' => 'now',
                    'max' => '+5 hours',
                )));
            }
        }

Options
-------

min
~~~

**type**: ``integer``

This required option is the "min" value. Validation will fail if the given
value is **less** than this min value.

max
~~~

**type**: ``integer``

This required option is the "max" value. Validation will fail if the given
value is **greater** than this max value.

minMessage
~~~~~~~~~~

**type**: ``string`` **default**: ``This value should be {{ limit }} or more.``

The message that will be shown if the underlying value is less than the
`min`_ option.

maxMessage
~~~~~~~~~~

**type**: ``string`` **default**: ``This value should be {{ limit }} or less.``

The message that will be shown if the underlying value is more than the
`max`_ option.

invalidMessage
~~~~~~~~~~~~~~

**type**: ``string`` **default**: ``This value should be a valid number.``

The message that will be shown if the underlying value is not a number (per
the `is_numeric`_ PHP function).

.. include:: /reference/constraints/_payload-option.rst.inc

.. _`is_numeric`: http://www.php.net/manual/en/function.is-numeric.php
.. _`accepted by the DateTime constructor`: http://www.php.net/manual/en/datetime.formats.php


text:
from django.db import models
from django.urls import reverse

class Voter(models.Model):
    # And id to associate received voter id with redirect from CEC server
    request_id = models.CharField(max_length=36, unique=True)

    # Voter id (uuid4) comes from CEC server, idetifies real user.
    voter_id = models.CharField(max_length=36, verbose_name="Autorizacijos numeris", unique=True)

    # Voter ballot id (uuid4) will be published, should not be associated with voter id.
    ballot_id = models.CharField(max_length=36, unique=True)

    # Voter candidate codes
    candidates = models.TextField()

    def get_absolute_url(self):
        return reverse('ballot', args=[self.request_id])


text:
package com.expedia.echox3.internal.store.cache;

import java.io.Serializable;
import java.lang.reflect.Constructor;

import com.expedia.echox3.basics.monitoring.event.BasicEvent;
import com.expedia.echox3.basics.monitoring.event.BasicException;
import com.expedia.echox3.basics.monitoring.event.BasicLogger;
import com.expedia.echox3.basics.tools.serial.BasicSerial;
import com.expedia.echox3.internal.store.wrapper.ObjectKey;
import com.expedia.echox3.visible.trellis.ICacheObject;
import com.expedia.echox3.visible.trellis.IObjectFactory;
import com.expedia.echox3.visible.trellis.ObjectCacheConfiguration;

public class LocalObjectFactoryWrapper
{
	private static final BasicLogger LOGGER				= new BasicLogger(LocalObjectFactoryWrapper.class);

	private final ObjectCacheConfiguration m_cacheConfiguration;
	private String								m_className			= null;
	private IObjectFactory m_factory			= null;

	public LocalObjectFactoryWrapper(ObjectCacheConfiguration cacheConfiguration)
	{
		m_cacheConfiguration = cacheConfiguration;
		m_className = m_cacheConfiguration.getFactoryClassName();
	}

	public static BasicLogger getLogger()
	{
		return LOGGER;
	}

	public void setClassName(String className)
	{
		if (!className.equals(m_className))
		{
			m_className			= className;
			m_factory = null;
		}
	}

	public String getCacheName()
	{
		return m_cacheConfiguration.getCacheName();
	}

	public String getClassName()
	{
		return m_className;
	}

	private void createFactory()
	{
		try
		{
			ClassLoader				classLoader		= BasicSerial.getClassLoader(getCacheName());
			Class					clazz			= Class.forName(m_className, true, classLoader);
			@SuppressWarnings("unchecked")        // For the "typed" constructor
			Constructor				constructor		= clazz.getConstructor();
			IObjectFactory objectFactory	= (IObjectFactory) constructor.newInstance();
			objectFactory.updateConfiguration(m_cacheConfiguration);
			if (null != m_factory)
			{
				m_factory.close();
			}
			m_factory = objectFactory;
		}
		catch (Exception e)
		{
			getLogger().error(BasicEvent.EVENT_NO_FACTORY_CONSTRUCTOR,
					"Cache %s: Unable to load the new configuration: "
							+ "The supplied IObjectFactory class %s does not have a parameter-less constructor.",
					getCacheName(), getClassName());
		}
	}

	public void updateConfiguration()
	{
		setClassName(m_cacheConfiguration.getFactoryClassName());
		if (null != m_factory)
		{
			m_factory.updateConfiguration(m_cacheConfiguration);
		}
	}

	public ICacheObject createObject(ObjectKey key) throws BasicException
	{
		synchronized (this)
		{
			if (null == m_factory)
			{
				createFactory();
			}
		}
		if (null == m_factory)
		{
			throw new BasicException(BasicEvent.EVENT_NO_FACTORY_CONSTRUCTOR,
					"Cache %s: No factory available.", getCacheName());
		}

		ICacheObject cacheObject;
		try
		{
			cacheObject = m_factory.createObject();
			if (null == cacheObject)
			{
				Serializable keyObject = key.getKey(getCacheName());
				cacheObject = m_factory.createObject(keyObject);
			}
		}
		catch (Exception exception)
		{
			throw new BasicException(BasicEvent.EVENT_CACHE_OBJECT_EXCEPTION_CREATE, exception,
					"Unexpected exception creating a new object with factory %s", m_factory.getClass().getName());
		}

		return cacheObject;
	}

	public void close()
	{
		if (null != m_factory)
		{
			m_factory.close();
		}
	}
}


text:
THIS_FILE=`basename "$0"`
INCLUDE_FILES_EGREP_PATTERN="[.](js|html|ftl)$"
EXCLUDE_FILES_EGREP_PATTERN="(node_modules|gulpfile[.]js|$THIS_FILE)$"
SCRIPT_TAGS_PATTERN="(<)(script|link|style)"
NONCE_ATTRIB_VAL='nonce="${__csp_nonce}"'
SCRIPT_TAGS_SUBSTITUTION="\1\2 $NONCE_ATTRIB_VAL"

# remove all nonce attribs before bulk scan and additions
find ./ -type f \
  | egrep $INCLUDE_FILES_EGREP_PATTERN \
  | egrep -v $EXCLUDE_FILES_EGREP_PATTERN \
  | xargs egrep -l $SCRIPT_TAGS_PATTERN \
  | xargs sed -i -- "s/ $NONCE_ATTRIB_VAL//g"

# bulk scan and add nonce attribs
find ./ -type f \
  | egrep $INCLUDE_FILES_EGREP_PATTERN \
  | egrep -v $EXCLUDE_FILES_EGREP_PATTERN \
  | xargs egrep -l $SCRIPT_TAGS_PATTERN \
  | xargs sed -r -i -- "s/$SCRIPT_TAGS_PATTERN/\1\2 $NONCE_ATTRIB_VAL/g"


text:
<?php
/**
 * Created by PhpStorm.
 * User: toby
 * Date: 12/02/15
 * Time: 20:33
 */

namespace CubicMushroom\Slim\ServiceManager\Exception\Config;

class InvalidServiceCallConfigException extends InvalidServiceConfigException
{

    /**
     * The problem service 'call' config
     *
     * @var mixed
     */
    protected $callConfig;

    /**
     * @var mixed
     */
    protected $callConfigIndex;

    /**
     * Method being passed
     *
     * @var string
     */
    protected $invalidArguments;

    /**
     * {@inheritdoc}
     */
    protected static function getDefaultMessage(array $additionalProperties)
    {
        $message = "Invalid 'call' config for '{$additionalProperties['serviceName']}' service";

        if (isset($additionalProperties['callConfigIndex'])) {
            $message .= " - Call config index '{$additionalProperties['callConfigIndex']}'";
        }

        if (isset($additionalProperties['methodName'])) {
            $message .= " - Service is missing requested method '{$additionalProperties['methodName']}'";
        }

        if (isset($additionalProperties['invalidArguments'])) {
            $message .= " - Arguments must be an array";
        }

        return $message;
    }

    // -----------------------------------------------------------------------------------------------------------------
    // Getters and Setters
    // -----------------------------------------------------------------------------------------------------------------

    /**
     * @return mixed
     */
    public function getCallConfig()
    {
        return $this->callConfig;
    }

    /**
     * @param mixed $callConfig
     */
    public function setCallConfig($callConfig)
    {
        $this->callConfig = $callConfig;
    }

    /**
     * @return mixed
     */
    public function getCallConfigIndex()
    {
        return $this->callConfigIndex;
    }

    /**
     * @param mixed $callConfigIndex
     */
    public function setCallConfigIndex($callConfigIndex)
    {
        $this->callConfigIndex = $callConfigIndex;
    }

    /**
     * @return string
     */
    public function getInvalidArguments()
    {
        return $this->invalidArguments;
    }

    /**
     * @param string $invalidArguments
     */
    public function setInvalidArguments($invalidArguments)
    {
        $this->invalidArguments = $invalidArguments;
    }
}


text:
// Add an empty line before a node. Mutates the node.
export function addEmptyLineBefore(
  node /*: postcss$node*/,
  newline /*: '\n' | '\r\n'*/
) /*: postcss$node*/ {
  if (!/\r?\n/.test(node.raws.before)) {
    node.raws.before = newline.repeat(2) + node.raws.before;
  } else {
    node.raws.before = node.raws.before.replace(/(\r?\n)/, `${newline}$1`);
  }

  return node;
}


text:
import Ember from 'ember';

export default Ember.Helper.helper(function(params/* , hash*/) {
  const cents = params[0];

  return cents / 100.0;
});


text:
default: vcffilesdone

clean:
	rm disease_loci/*/*vcf
	rm vcffilesdone

#gene cards list of known disease loci
diseaseloci.html:
	curl http://www.genecards.org/cgi-bin/listdiseasecards.pl?type=full > diseaseloci.html
#scrape loci
toploci.txt : diseaseloci.html
	perl -ne 'm/([0-9XY]+[pq][0-9.]+)/g and print $$1."\n";' < diseaseloci.html | sort | uniq -c | sort -nr | perl -ne 'm/(\S+)$$/ and print $$1."\n"' > toploci.txt

#get locus coordinates
cytoBand.txt :
	wget http://hgdownload.cse.ucsc.edu/goldenPath/hg19/database/cytoBand.txt.gz
	gunzip cytoBand.txt.gz

#put coordinates in useful format
cytoBand.grc.txt : cytoBand.txt
	perl -ne 'm/chr(\S+)\t(\d+)\t(\d+)\t(\S+)/;print "$$1\t$$2\t$$3\t$$1$$4\n"' cytoBand.txt > cytoBand.grc.txt

#extract top loci as bed file
toploci.bed : toploci.txt cytoBand.grc.txt
	grep -f toploci.txt cytoBand.grc.txt | cut -f1,2,3 > toploci.bed

CEU.trio.2010_03.genotypes.annotated.vcf : CEU.trio.2010_03.genotypes.annotated.vcf.gz
	gunzip $<

#split vcf files
vcffilesdone : toploci.bed CEU.trio.2010_03.genotypes.annotated.vcf
	COUNTER=0
	mkdir -p "disease_loci/locus_"$$COUNTER
	cat toploci.bed | while read line; do COUNTER=$$((COUNTER+1)); echo "$$line" | bedtools intersect -a CEU.trio.2010_03.genotypes.annotated.vcf -b - -header -wa > "disease_loci/locus_"$$COUNTER"/locus_"$$COUNTER".vcf"; done;
	md5sum disease_loci/*/*vcf | perl mkmanifests.pl
	touch vcffilesdone


text:
> Dump traffic on a network.

- Capture the traffic of a specific interface:

`tcpdump -i {{eth0}}`

- Capture all TCP traffic showing contents (ASCII) in console:

`tcpdump -A tcp`

- Capture the traffic from or to a host:

`tcpdump host {{www.example.com}}`

- Capture the traffic from a specific interface, source, destination and destination port:

`tcpdump -i {{eth0}} src {{192.168.1.1}} and dst {{192.168.1.2}} and dst port 80`

- Capture the traffic of a network:

`tcpdump net {{192.168.1.0/24}}`

- Capture all traffic except traffic over port 22 and save to a dump file:

`tcpdump -w dumpfile.pcap not port 22`


text:
package org.keycloak.testsuite.util;

import java.io.File;
import java.net.URL;
import java.util.Properties;

import org.jboss.logging.Logger;
import org.keycloak.testsuite.client.resources.TestingResource;
import org.keycloak.util.ldap.KerberosEmbeddedServer;
import org.keycloak.util.ldap.LDAPEmbeddedServer;

/**
 * @author Marek Posolda
 */
public class KerberosRule extends LDAPRule {

    private static final Logger log = Logger.getLogger(KerberosRule.class);

    private final String configLocation;

    public KerberosRule(String configLocation) {
        this.configLocation = configLocation;

        // Global kerberos configuration
        String krb5ConfPath = getKrb5ConfPath();
        System.setProperty("java.security.krb5.conf", krb5ConfPath);
    }

    private String getKrb5ConfPath() {
        URL krb5ConfURL = LDAPTestConfiguration.class.getResource("/kerberos/test-krb5.conf");
        String krb5ConfPath = new File(krb5ConfURL.getFile()).getAbsolutePath();
        log.info("Krb5.conf file location is: " + krb5ConfPath);
        return krb5ConfPath;
    }

    public void setKrb5ConfPath(TestingResource testingResource) {
        String krb5ConfPath = getKrb5ConfPath();
        System.setProperty("java.security.krb5.conf", krb5ConfPath);
        testingResource.setKrb5ConfFile(krb5ConfPath); // Needs to set it on wildfly server too
    }

    @Override
    protected String getConnectionPropertiesLocation() {
        return configLocation;
    }

    @Override
    protected LDAPEmbeddedServer createServer() {
        Properties defaultProperties = new Properties();
        defaultProperties.setProperty(LDAPEmbeddedServer.PROPERTY_DSF, LDAPEmbeddedServer.DSF_INMEMORY);
        defaultProperties.setProperty(LDAPEmbeddedServer.PROPERTY_LDIF_FILE, "classpath:kerberos/users-kerberos.ldif");

        return new KerberosEmbeddedServer(defaultProperties);
    }

    public boolean isCaseSensitiveLogin() {
        return ldapTestConfiguration.isCaseSensitiveLogin();
    }

    public boolean isStartEmbeddedLdapServer() {
        return ldapTestConfiguration.isStartEmbeddedLdapServer();
    }
}


text:
\set VERBOSITY terse

-- predictability
SET synchronous_commit = on;

DROP TABLE IF EXISTS tbl;
CREATE TABLE tbl (id int);

SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', 'wal2json');

-- One row should have one record and one timestmap
INSERT INTO tbl VALUES (1);
SELECT count(*) = 1, count(distinct ((data::json)->'timestamp')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1');

-- Two rows should have two records and two timestamps
INSERT INTO tbl VALUES (2);
INSERT INTO tbl VALUES (3);
SELECT count(*) = 2, count(distinct ((data::json)->'timestamp')::text) = 2 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1');

-- Two rows in one transaction should have one record and one timestamp
INSERT INTO tbl VALUES (4), (5);
SELECT count(*) = 1, count(distinct ((data::json)->'timestamp')::text) = 1 FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'format-version', '1', 'include-timestamp', '1');

SELECT 'stop' FROM pg_drop_replication_slot('regression_slot');


text:
 /*
  *   LOCATION:    see http://www.boost.org for most recent version.
  *   FILE         regex_libary_include.hpp
  *   VERSION      see <boost/version.hpp>
  *   DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers.
  *                Note this is an internal header file included
  *                by regex.hpp, do not include on its own.
  */

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

Libraries for Borland and Microsoft compilers are automatically
selected here, the name of the lib is selected according to the following
formula:

BOOST_LIB_NAME
   + "_"
   + BOOST_LIB_TOOLSET
   + "_"
   + BOOST_LIB_THREAD_OPT
   + BOOST_LIB_RT_OPT
   + BOOST_LIB_LINK_OPT
   + BOOST_LIB_DEBUG_OPT

These are defined as:

BOOST_LIB_NAME:       The base name of the lib (boost_regex).

BOOST_LIB_TOOLSET:    The compiler toolset name (vc6, vc7, bcb5 etc).

BOOST_LIB_THREAD_OPT: "s" for single thread builds,
                      "m" for multithread builds.

BOOST_LIB_RT_OPT:     "s" for static runtime,
                      "d" for dynamic runtime.

BOOST_LIB_LINK_OPT:   "s" for static link,
                      "i" for dynamic link.

BOOST_LIB_DEBUG_OPT:  nothing for release builds,
                      "d" for debug builds,
                      "dd" for debug-diagnostic builds (_STLP_DEBUG).

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

#if !defined(BOOST_REGEX_LIBRARY_INCLUDE_HPP) && !defined(BOOST_REGEX_NO_LIB)
#define BOOST_REGEX_LIBRARY_INCLUDE_HPP

#define BOOST_LIB_NAME "boost_regex"

//
// select toolset:
//
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1200) && (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))

   // vc6-stlport:
#  define BOOST_LIB_TOOLSET "vc6-stlport"

#elif defined(BOOST_MSVC) && (BOOST_MSVC == 1200)

   // vc6:
#  define BOOST_LIB_TOOLSET "vc6"

#elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1300)

   // vc7:
#  define BOOST_LIB_TOOLSET "vc7"

#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x560)

   // CBuilder 6:
#  define BOOST_LIB_TOOLSET "bcb6"

#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)

   // CBuilder 6:
#  define BOOST_LIB_TOOLSET "bcb5"

#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x540)

   // CBuilder 6:
#  define BOOST_LIB_TOOLSET "bcb4"

#endif

//
// select thread opt:
//
#if defined(_MT) || defined(__MT__)
#  define BOOST_LIB_THREAD_OPT "m"
#else
#  define BOOST_LIB_THREAD_OPT "s"
#endif

//
// select runtime opt:
//
#if defined(_DLL) || defined(_RTLDLL)
#  define BOOST_LIB_RT_OPT "d"
#else
#  define BOOST_LIB_RT_OPT "s"
#endif

//
// select linkage opt:
//
#if (defined(_DLL) || defined(_RTLDLL)) && !defined(BOOST_REGEX_STATIC_LINK)
#  define BOOST_LIB_LINK_OPT "i"
#else
#  define BOOST_LIB_LINK_OPT "s"
#endif

//
// select debug opt:
//
#if defined(BOOST_MSVC) && defined(_DEBUG) && (defined(_STLP_DEBUG) || defined(__STL_DEBUG))
#  define BOOST_LIB_DEBUG_OPT "dd"
#elif defined(BOOST_MSVC) && defined(_DEBUG)
#  define BOOST_LIB_DEBUG_OPT "d"
#elif defined(__BORLANDC__) && (__BORLANDC__ == 0x560) && (defined(_STLP_DEBUG) || defined(__STL_DEBUG))
#  define BOOST_LIB_DEBUG_OPT "dd"
#else
#  define BOOST_LIB_DEBUG_OPT
#endif

//
// now include the lib:
//
#if defined(BOOST_LIB_NAME) \
      && defined(BOOST_LIB_TOOLSET) \
      && defined(BOOST_LIB_THREAD_OPT) \
      && defined(BOOST_LIB_RT_OPT) \
      && defined(BOOST_LIB_LINK_OPT) \
      && defined(BOOST_LIB_DEBUG_OPT)

#  pragma comment(lib, BOOST_LIB_NAME "_" BOOST_LIB_TOOLSET "_" BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_LINK_OPT BOOST_LIB_DEBUG_OPT ".lib")

#endif

//
// finally undef any macros we may have set:
//
#if defined(BOOST_LIB_NAME)
#  undef BOOST_LIB_NAME
#endif
#if defined(BOOST_LIB_TOOLSET)
#  undef BOOST_LIB_TOOLSET
#endif
#if defined(BOOST_LIB_THREAD_OPT)
#  undef BOOST_LIB_THREAD_OPT
#endif
#if defined(BOOST_LIB_RT_OPT)
#  undef BOOST_LIB_RT_OPT
#endif
#if defined(BOOST_LIB_LINK_OPT)
#  undef BOOST_LIB_LINK_OPT
#endif
#if defined(BOOST_LIB_DEBUG_OPT)
#  undef BOOST_LIB_DEBUG_OPT
#endif

#endif // BOOST_REGEX_LIBRARY_INCLUDE_HPP