text:
#include <linux/pagemap.h>
#include <linux/vfs.h>
#include "cifsglob.h"
#include "cifsproto.h"
#include "cifs_debug.h"
#include "cifspdu.h"
#include "cifs_unicode.h"

/*
 * An NT cancel request header looks just like the original request except:
 *
 * The Command is SMB_COM_NT_CANCEL
 * The WordCount is zeroed out
 * The ByteCount is zeroed out
 *
 * This function mangles an existing request buffer into a
 * SMB_COM_NT_CANCEL request and then sends it.
 */
static int
send_nt_cancel(struct TCP_Server_Info *server, void *buf,
	       struct mid_q_entry *mid)
{
	int rc = 0;
	struct smb_hdr *in_buf = (struct smb_hdr *)buf;

	/* -4 for RFC1001 length and +2 for BCC field */
	in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4  + 2);
	in_buf->Command = SMB_COM_NT_CANCEL;
	in_buf->WordCount = 0;
	put_bcc(0, in_buf);

	mutex_lock(&server->srv_mutex);
	rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);
	if (rc) {
		mutex_unlock(&server->srv_mutex);
		return rc;
	}

	/*
	 * The response to this call was already factored into the sequence
	 * number when the call went out, so we must adjust it back downward
	 * after signing here.
	 */
	--server->sequence_number;
	rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
	if (rc < 0)
		server->sequence_number--;

	mutex_unlock(&server->srv_mutex);

	cifs_dbg(FYI, "issued NT_CANCEL for mid %u, rc = %d\n",
		 get_mid(in_buf), rc);

	return rc;
}

static bool
cifs_compare_fids(struct cifsFileInfo *ob1, struct cifsFileInfo *ob2)
{
	return ob1->fid.netfid == ob2->fid.netfid;
}

static unsigned int
cifs_read_data_offset(char *buf)
{
	READ_RSP *rsp = (READ_RSP *)buf;
	return le16_to_cpu(rsp->DataOffset);
}

static unsigned int
cifs_read_data_length(char *buf)
{
	READ_RSP *rsp = (READ_RSP *)buf;
	return (le16_to_cpu(rsp->DataLengthHigh) << 16) +
	       le16_to_cpu(rsp->DataLength);
}

static struct mid_q_entry *
cifs_find_mid(struct TCP_Server_Info *server, char *buffer)
{
	struct smb_hdr *buf = (struct smb_hdr *)buffer;
	struct mid_q_entry *mid;

	spin_lock(&GlobalMid_Lock);
	list_for_each_entry(mid, &server->pending_mid_q, qhead) {
		if (compare_mid(mid->mid, buf) &&
		    mid->mid_state == MID_REQUEST_SUBMITTED &&
		    le16_to_cpu(mid->command) == buf->Command) {
			spin_unlock(&GlobalMid_Lock);
			return mid;
		}
	}
	spin_unlock(&GlobalMid_Lock);
	return NULL;
}

static void
cifs_add_credits(struct TCP_Server_Info *server, const unsigned int add,
		 const int optype)
{
	spin_lock(&server->req_lock);
	server->credits += add;
	server->in_flight--;
	spin_unlock(&server->req_lock);
	wake_up(&server->request_q);
}

static void
cifs_set_credits(struct TCP_Server_Info *server, const int val)
{
	spin_lock(&server->req_lock);
	server->credits = val;
	server->oplocks = val > 1 ? enable_oplocks : false;
	spin_unlock(&server->req_lock);
}

static int *
cifs_get_credits_field(struct TCP_Server_Info *server, const int optype)
{
	return &server->credits;
}

static unsigned int
cifs_get_credits(struct mid_q_entry *mid)
{
	return 1;
}

/*
 * Find a free multiplex id (SMB mid). Otherwise there could be
 * mid collisions which might cause problems, demultiplexing the
 * wrong response to this request. Multiplex ids could collide if
 * one of a series requests takes much longer than the others, or
 * if a very large number of long lived requests (byte range
 * locks or FindNotify requests) are pending. No more than
 * 64K-1 requests can be outstanding at one time. If no
 * mids are available, return zero. A future optimization
 * could make the combination of mids and uid the key we use
 * to demultiplex on (rather than mid alone).
 * In addition to the above check, the cifs demultiplex
 * code already used the command code as a secondary
 * check of the frame and if signing is negotiated the
 * response would be discarded if the mid were the same
 * but the signature was wrong. Since the mid is not put in the
 * pending queue until later (when it is about to be dispatched)
 * we do have to limit the number of outstanding requests
 * to somewhat less than 64K-1 although it is hard to imagine
 * so many threads being in the vfs at one time.
 */
static __u64
cifs_get_next_mid(struct TCP_Server_Info *server)
{
	__u64 mid = 0;
	__u16 last_mid, cur_mid;
	bool collision;

	spin_lock(&GlobalMid_Lock);

	/* mid is 16 bit only for CIFS/SMB */
	cur_mid = (__u16)((server->CurrentMid) & 0xffff);
	/* we do not want to loop forever */
	last_mid = cur_mid;
	cur_mid++;

	/*
	 * This nested loop looks more expensive than it is.
	 * In practice the list of pending requests is short,
	 * fewer than 50, and the mids are likely to be unique
	 * on the first pass through the loop unless some request
	 * takes longer than the 64 thousand requests before it
	 * (and it would also have to have been a request that
	 * did not time out).
	 */
	while (cur_mid != last_mid) {
		struct mid_q_entry *mid_entry;
		unsigned int num_mids;

		collision = false;
		if (cur_mid == 0)
			cur_mid++;

		num_mids = 0;
		list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) {
			++num_mids;
			if (mid_entry->mid == cur_mid &&
			    mid_entry->mid_state == MID_REQUEST_SUBMITTED) {
				/* This mid is in use, try a different one */
				collision = true;
				break;
			}
		}

		/*
		 * if we have more than 32k mids in the list, then something
		 * is very wrong. Possibly a local user is trying to DoS the
		 * box by issuing long-running calls and SIGKILL'ing them. If
		 * we get to 2^16 mids then we're in big trouble as this
		 * function could loop forever.
		 *
		 * Go ahead and assign out the mid in this situation, but force
		 * an eventual reconnect to clean out the pending_mid_q.
		 */
		if (num_mids > 32768)
			server->tcpStatus = CifsNeedReconnect;

		if (!collision) {
			mid = (__u64)cur_mid;
			server->CurrentMid = mid;
			break;
		}
		cur_mid++;
	}
	spin_unlock(&GlobalMid_Lock);
	return mid;
}

/*
	return codes:
		0	not a transact2, or all data present
		>0	transact2 with that much data missing
		-EINVAL	invalid transact2
 */
static int
check2ndT2(char *buf)
{
	struct smb_hdr *pSMB = (struct smb_hdr *)buf;
	struct smb_t2_rsp *pSMBt;
	int remaining;
	__u16 total_data_size, data_in_this_rsp;

	if (pSMB->Command != SMB_COM_TRANSACTION2)
		return 0;

	/* check for plausible wct, bcc and t2 data and parm sizes */
	/* check for parm and data offset going beyond end of smb */
	if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
		cifs_dbg(FYI, "invalid transact2 word count\n");
		return -EINVAL;
	}

	pSMBt = (struct smb_t2_rsp *)pSMB;

	total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
	data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);

	if (total_data_size == data_in_this_rsp)
		return 0;
	else if (total_data_size < data_in_this_rsp) {
		cifs_dbg(FYI, "total data %d smaller than data in frame %d\n",
			 total_data_size, data_in_this_rsp);
		return -EINVAL;
	}

	remaining = total_data_size - data_in_this_rsp;

	cifs_dbg(FYI, "missing %d bytes from transact2, check next response\n",
		 remaining);
	if (total_data_size > CIFSMaxBufSize) {
		cifs_dbg(VFS, "TotalDataSize %d is over maximum buffer %d\n",
			 total_data_size, CIFSMaxBufSize);
		return -EINVAL;
	}
	return remaining;
}

static int
coalesce_t2(char *second_buf, struct smb_hdr *target_hdr)
{
	struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)second_buf;
	struct smb_t2_rsp *pSMBt  = (struct smb_t2_rsp *)target_hdr;
	char *data_area_of_tgt;
	char *data_area_of_src;
	int remaining;
	unsigned int byte_count, total_in_tgt;
	__u16 tgt_total_cnt, src_total_cnt, total_in_src;

	src_total_cnt = get_unaligned_le16(&pSMBs->t2_rsp.TotalDataCount);
	tgt_total_cnt = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);

	if (tgt_total_cnt != src_total_cnt)
		cifs_dbg(FYI, "total data count of primary and secondary t2 differ source=%hu target=%hu\n",
			 src_total_cnt, tgt_total_cnt);

	total_in_tgt = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);

	remaining = tgt_total_cnt - total_in_tgt;

	if (remaining < 0) {
		cifs_dbg(FYI, "Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%hu\n",
			 tgt_total_cnt, total_in_tgt);
		return -EPROTO;
	}

	if (remaining == 0) {
		/* nothing to do, ignore */
		cifs_dbg(FYI, "no more data remains\n");
		return 0;
	}

	total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount);
	if (remaining < total_in_src)
		cifs_dbg(FYI, "transact2 2nd response contains too much data\n");

	/* find end of first SMB data area */
	data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
				get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);

	/* validate target area */
	data_area_of_src = (char *)&pSMBs->hdr.Protocol +
				get_unaligned_le16(&pSMBs->t2_rsp.DataOffset);

	data_area_of_tgt += total_in_tgt;

	total_in_tgt += total_in_src;
	/* is the result too big for the field? */
	if (total_in_tgt > USHRT_MAX) {
		cifs_dbg(FYI, "coalesced DataCount too large (%u)\n",
			 total_in_tgt);
		return -EPROTO;
	}
	put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount);

	/* fix up the BCC */
	byte_count = get_bcc(target_hdr);
	byte_count += total_in_src;
	/* is the result too big for the field? */
	if (byte_count > USHRT_MAX) {
		cifs_dbg(FYI, "coalesced BCC too large (%u)\n", byte_count);
		return -EPROTO;
	}
	put_bcc(byte_count, target_hdr);

	byte_count = be32_to_cpu(target_hdr->smb_buf_length);
	byte_count += total_in_src;
	/* don't allow buffer to overflow */
	if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
		cifs_dbg(FYI, "coalesced BCC exceeds buffer size (%u)\n",
			 byte_count);
		return -ENOBUFS;
	}
	target_hdr->smb_buf_length = cpu_to_be32(byte_count);

	/* copy second buffer into end of first buffer */
	memcpy(data_area_of_tgt, data_area_of_src, total_in_src);

	if (remaining != total_in_src) {
		/* more responses to go */
		cifs_dbg(FYI, "waiting for more secondary responses\n");
		return 1;
	}

	/* we are done */
	cifs_dbg(FYI, "found the last secondary response\n");
	return 0;
}

static void
cifs_downgrade_oplock(struct TCP_Server_Info *server,
			struct cifsInodeInfo *cinode, bool set_level2)
{
	if (set_level2)
		cifs_set_oplock_level(cinode, OPLOCK_READ);
	else
		cifs_set_oplock_level(cinode, 0);
}

static bool
cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
		  char *buf, int malformed)
{
	if (malformed)
		return false;
	if (check2ndT2(buf) <= 0)
		return false;
	mid->multiRsp = true;
	if (mid->resp_buf) {
		/* merge response - fix up 1st*/
		malformed = coalesce_t2(buf, mid->resp_buf);
		if (malformed > 0)
			return true;
		/* All parts received or packet is malformed. */
		mid->multiEnd = true;
		dequeue_mid(mid, malformed);
		return true;
	}
	if (!server->large_buf) {
		/*FIXME: switch to already allocated largebuf?*/
		cifs_dbg(VFS, "1st trans2 resp needs bigbuf\n");
	} else {
		/* Have first buffer */
		mid->resp_buf = buf;
		mid->large_buf = true;
		server->bigbuf = NULL;
	}
	return true;
}

static bool
cifs_need_neg(struct TCP_Server_Info *server)
{
	return server->maxBuf == 0;
}

static int
cifs_negotiate(const unsigned int xid, struct cifs_ses *ses)
{
	int rc;
	rc = CIFSSMBNegotiate(xid, ses);
	if (rc == -EAGAIN) {
		/* retry only once on 1st time connection */
		set_credits(ses->server, 1);
		rc = CIFSSMBNegotiate(xid, ses);
		if (rc == -EAGAIN)
			rc = -EHOSTDOWN;
	}
	return rc;
}

static unsigned int
cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
{
	__u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
	struct TCP_Server_Info *server = tcon->ses->server;
	unsigned int wsize;

	/* start with specified wsize, or default */
	if (volume_info->wsize)
		wsize = volume_info->wsize;
	else if (tcon->unix_ext && (unix_cap & CIFS_UNIX_LARGE_WRITE_CAP))
		wsize = CIFS_DEFAULT_IOSIZE;
	else
		wsize = CIFS_DEFAULT_NON_POSIX_WSIZE;

	/* can server support 24-bit write sizes? (via UNIX extensions) */
	if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP))
		wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1002_WSIZE);

	/*
	 * no CAP_LARGE_WRITE_X or is signing enabled without CAP_UNIX set?
	 * Limit it to max buffer offered by the server, minus the size of the
	 * WRITEX header, not including the 4 byte RFC1001 length.
	 */
	if (!(server->capabilities & CAP_LARGE_WRITE_X) ||
	    (!(server->capabilities & CAP_UNIX) && server->sign))
		wsize = min_t(unsigned int, wsize,
				server->maxBuf - sizeof(WRITE_REQ) + 4);

	/* hard limit of CIFS_MAX_WSIZE */
	wsize = min_t(unsigned int, wsize, CIFS_MAX_WSIZE);

	return wsize;
}

static unsigned int
cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
{
	__u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
	struct TCP_Server_Info *server = tcon->ses->server;
	unsigned int rsize, defsize;

	/*
	 * Set default value...
	 *
	 * HACK alert! Ancient servers have very small buffers. Even though
	 * MS-CIFS indicates that servers are only limited by the client's
	 * bufsize for reads, testing against win98se shows that it throws
	 * INVALID_PARAMETER errors if you try to request too large a read.
	 * OS/2 just sends back short reads.
	 *
	 * If the server doesn't advertise CAP_LARGE_READ_X, then assume that
	 * it can't handle a read request larger than its MaxBufferSize either.
	 */
	if (tcon->unix_ext && (unix_cap & CIFS_UNIX_LARGE_READ_CAP))
		defsize = CIFS_DEFAULT_IOSIZE;
	else if (server->capabilities & CAP_LARGE_READ_X)
		defsize = CIFS_DEFAULT_NON_POSIX_RSIZE;
	else
		defsize = server->maxBuf - sizeof(READ_RSP);

	rsize = volume_info->rsize ? volume_info->rsize : defsize;

	/*
	 * no CAP_LARGE_READ_X? Then MS-CIFS states that we must limit this to
	 * the client's MaxBufferSize.
	 */
	if (!(server->capabilities & CAP_LARGE_READ_X))
		rsize = min_t(unsigned int, CIFSMaxBufSize, rsize);

	/* hard limit of CIFS_MAX_RSIZE */
	rsize = min_t(unsigned int, rsize, CIFS_MAX_RSIZE);

	return rsize;
}

static void
cifs_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon)
{
	CIFSSMBQFSDeviceInfo(xid, tcon);
	CIFSSMBQFSAttributeInfo(xid, tcon);
}

static int
cifs_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
			struct cifs_sb_info *cifs_sb, const char *full_path)
{
	int rc;
	FILE_ALL_INFO *file_info;

	file_info = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
	if (file_info == NULL)
		return -ENOMEM;

	rc = CIFSSMBQPathInfo(xid, tcon, full_path, file_info,
			      0 /* not legacy */, cifs_sb->local_nls,
			      cifs_remap(cifs_sb));

	if (rc == -EOPNOTSUPP || rc == -EINVAL)
		rc = SMBQueryInformation(xid, tcon, full_path, file_info,
				cifs_sb->local_nls, cifs_remap(cifs_sb));
	kfree(file_info);
	return rc;
}

static int
cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
		     struct cifs_sb_info *cifs_sb, const char *full_path,
		     FILE_ALL_INFO *data, bool *adjustTZ, bool *symlink)
{
	int rc;

	*symlink = false;

	/* could do find first instead but this returns more info */
	rc = CIFSSMBQPathInfo(xid, tcon, full_path, data, 0 /* not legacy */,
			      cifs_sb->local_nls, cifs_remap(cifs_sb));
	/*
	 * BB optimize code so we do not make the above call when server claims
	 * no NT SMB support and the above call failed at least once - set flag
	 * in tcon or mount.
	 */
	if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
		rc = SMBQueryInformation(xid, tcon, full_path, data,
					 cifs_sb->local_nls,
					 cifs_remap(cifs_sb));
		*adjustTZ = true;
	}

	if (!rc && (le32_to_cpu(data->Attributes) & ATTR_REPARSE)) {
		int tmprc;
		int oplock = 0;
		struct cifs_fid fid;
		struct cifs_open_parms oparms;

		oparms.tcon = tcon;
		oparms.cifs_sb = cifs_sb;
		oparms.desired_access = FILE_READ_ATTRIBUTES;
		oparms.create_options = 0;
		oparms.disposition = FILE_OPEN;
		oparms.path = full_path;
		oparms.fid = &fid;
		oparms.reconnect = false;

		/* Need to check if this is a symbolic link or not */
		tmprc = CIFS_open(xid, &oparms, &oplock, NULL);
		if (tmprc == -EOPNOTSUPP)
			*symlink = true;
		else if (tmprc == 0)
			CIFSSMBClose(xid, tcon, fid.netfid);
	}

	return rc;
}

static int
cifs_get_srv_inum(const unsigned int xid, struct cifs_tcon *tcon,
		  struct cifs_sb_info *cifs_sb, const char *full_path,
		  u64 *uniqueid, FILE_ALL_INFO *data)
{
	/*
	 * We can not use the IndexNumber field by default from Windows or
	 * Samba (in ALL_INFO buf) but we can request it explicitly. The SNIA
	 * CIFS spec claims that this value is unique within the scope of a
	 * share, and the windows docs hint that it's actually unique
	 * per-machine.
	 *
	 * There may be higher info levels that work but are there Windows
	 * server or network appliances for which IndexNumber field is not
	 * guaranteed unique?
	 */
	return CIFSGetSrvInodeNumber(xid, tcon, full_path, uniqueid,
				     cifs_sb->local_nls,
				     cifs_remap(cifs_sb));
}

static int
cifs_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
		     struct cifs_fid *fid, FILE_ALL_INFO *data)
{
	return CIFSSMBQFileInfo(xid, tcon, fid->netfid, data);
}

static void
cifs_clear_stats(struct cifs_tcon *tcon)
{
#ifdef CONFIG_CIFS_STATS
	atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
	atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
	atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
	atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
	atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
	atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
	atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
	atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
	atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
	atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
	atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
	atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
	atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
	atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
	atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
	atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
	atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
	atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
	atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
	atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
	atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
#endif
}

static void
cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
{
#ifdef CONFIG_CIFS_STATS
	seq_printf(m, " Oplocks breaks: %d",
		   atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
	seq_printf(m, "\nReads:  %d Bytes: %llu",
		   atomic_read(&tcon->stats.cifs_stats.num_reads),
		   (long long)(tcon->bytes_read));
	seq_printf(m, "\nWrites: %d Bytes: %llu",
		   atomic_read(&tcon->stats.cifs_stats.num_writes),
		   (long long)(tcon->bytes_written));
	seq_printf(m, "\nFlushes: %d",
		   atomic_read(&tcon->stats.cifs_stats.num_flushes));
	seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
		   atomic_read(&tcon->stats.cifs_stats.num_locks),
		   atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
		   atomic_read(&tcon->stats.cifs_stats.num_symlinks));
	seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
		   atomic_read(&tcon->stats.cifs_stats.num_opens),
		   atomic_read(&tcon->stats.cifs_stats.num_closes),
		   atomic_read(&tcon->stats.cifs_stats.num_deletes));
	seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
		   atomic_read(&tcon->stats.cifs_stats.num_posixopens),
		   atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
	seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
		   atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
		   atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
	seq_printf(m, "\nRenames: %d T2 Renames %d",
		   atomic_read(&tcon->stats.cifs_stats.num_renames),
		   atomic_read(&tcon->stats.cifs_stats.num_t2renames));
	seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
		   atomic_read(&tcon->stats.cifs_stats.num_ffirst),
		   atomic_read(&tcon->stats.cifs_stats.num_fnext),
		   atomic_read(&tcon->stats.cifs_stats.num_fclose));
#endif
}

static void
cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
		   struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
		   const unsigned int xid)
{
	FILE_BASIC_INFO info;
	struct cifsInodeInfo *cifsInode;
	u32 dosattrs;
	int rc;

	memset(&info, 0, sizeof(info));
	cifsInode = CIFS_I(inode);
	dosattrs = cifsInode->cifsAttrs|ATTR_READONLY;
	info.Attributes = cpu_to_le32(dosattrs);
	rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls,
				cifs_remap(cifs_sb));
	if (rc == 0)
		cifsInode->cifsAttrs = dosattrs;
}

static int
cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
	       __u32 *oplock, FILE_ALL_INFO *buf)
{
	if (!(oparms->tcon->ses->capabilities & CAP_NT_SMBS))
		return SMBLegacyOpen(xid, oparms->tcon, oparms->path,
				     oparms->disposition,
				     oparms->desired_access,
				     oparms->create_options,
				     &oparms->fid->netfid, oplock, buf,
				     oparms->cifs_sb->local_nls,
				     cifs_remap(oparms->cifs_sb));
	return CIFS_open(xid, oparms, oplock, buf);
}

static void
cifs_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
{
	struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
	cfile->fid.netfid = fid->netfid;
	cifs_set_oplock_level(cinode, oplock);
	cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
}

static void
cifs_close_file(const unsigned int xid, struct cifs_tcon *tcon,
		struct cifs_fid *fid)
{
	CIFSSMBClose(xid, tcon, fid->netfid);
}

static int
cifs_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
		struct cifs_fid *fid)
{
	return CIFSSMBFlush(xid, tcon, fid->netfid);
}

static int
cifs_sync_read(const unsigned int xid, struct cifs_fid *pfid,
	       struct cifs_io_parms *parms, unsigned int *bytes_read,
	       char **buf, int *buf_type)
{
	parms->netfid = pfid->netfid;
	return CIFSSMBRead(xid, parms, bytes_read, buf, buf_type);
}

static int
cifs_sync_write(const unsigned int xid, struct cifs_fid *pfid,
		struct cifs_io_parms *parms, unsigned int *written,
		struct kvec *iov, unsigned long nr_segs)
{

	parms->netfid = pfid->netfid;
	return CIFSSMBWrite2(xid, parms, written, iov, nr_segs);
}

static int
smb_set_file_info(struct inode *inode, const char *full_path,
		  FILE_BASIC_INFO *buf, const unsigned int xid)
{
	int oplock = 0;
	int rc;
	__u32 netpid;
	struct cifs_fid fid;
	struct cifs_open_parms oparms;
	struct cifsFileInfo *open_file;
	struct cifsInodeInfo *cinode = CIFS_I(inode);
	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
	struct tcon_link *tlink = NULL;
	struct cifs_tcon *tcon;

	/* if the file is already open for write, just use that fileid */
	open_file = find_writable_file(cinode, true);
	if (open_file) {
		fid.netfid = open_file->fid.netfid;
		netpid = open_file->pid;
		tcon = tlink_tcon(open_file->tlink);
		goto set_via_filehandle;
	}

	tlink = cifs_sb_tlink(cifs_sb);
	if (IS_ERR(tlink)) {
		rc = PTR_ERR(tlink);
		tlink = NULL;
		goto out;
	}
	tcon = tlink_tcon(tlink);

	rc = CIFSSMBSetPathInfo(xid, tcon, full_path, buf, cifs_sb->local_nls,
				cifs_remap(cifs_sb));
	if (rc == 0) {
		cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
		goto out;
	} else if (rc != -EOPNOTSUPP && rc != -EINVAL) {
		goto out;
	}

	oparms.tcon = tcon;
	oparms.cifs_sb = cifs_sb;
	oparms.desired_access = SYNCHRONIZE | FILE_WRITE_ATTRIBUTES;
	oparms.create_options = CREATE_NOT_DIR;
	oparms.disposition = FILE_OPEN;
	oparms.path = full_path;
	oparms.fid = &fid;
	oparms.reconnect = false;

	cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n");
	rc = CIFS_open(xid, &oparms, &oplock, NULL);
	if (rc != 0) {
		if (rc == -EIO)
			rc = -EINVAL;
		goto out;
	}

	netpid = current->tgid;

set_via_filehandle:
	rc = CIFSSMBSetFileInfo(xid, tcon, buf, fid.netfid, netpid);
	if (!rc)
		cinode->cifsAttrs = le32_to_cpu(buf->Attributes);

	if (open_file == NULL)
		CIFSSMBClose(xid, tcon, fid.netfid);
	else
		cifsFileInfo_put(open_file);
out:
	if (tlink != NULL)
		cifs_put_tlink(tlink);
	return rc;
}

static int
cifs_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
		   struct cifsFileInfo *cfile)
{
	return CIFSSMB_set_compression(xid, tcon, cfile->fid.netfid);
}

static int
cifs_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
		     const char *path, struct cifs_sb_info *cifs_sb,
		     struct cifs_fid *fid, __u16 search_flags,
		     struct cifs_search_info *srch_inf)
{
	return CIFSFindFirst(xid, tcon, path, cifs_sb,
			     &fid->netfid, search_flags, srch_inf, true);
}

static int
cifs_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon,
		    struct cifs_fid *fid, __u16 search_flags,
		    struct cifs_search_info *srch_inf)
{
	return CIFSFindNext(xid, tcon, fid->netfid, search_flags, srch_inf);
}

static int
cifs_close_dir(const unsigned int xid, struct cifs_tcon *tcon,
	       struct cifs_fid *fid)
{
	return CIFSFindClose(xid, tcon, fid->netfid);
}

static int
cifs_oplock_response(struct cifs_tcon *tcon, struct cifs_fid *fid,
		     struct cifsInodeInfo *cinode)
{
	return CIFSSMBLock(0, tcon, fid->netfid, current->tgid, 0, 0, 0, 0,
			   LOCKING_ANDX_OPLOCK_RELEASE, false,
			   CIFS_CACHE_READ(cinode) ? 1 : 0);
}

static int
cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
	     struct kstatfs *buf)
{
	int rc = -EOPNOTSUPP;

	buf->f_type = CIFS_MAGIC_NUMBER;

	/*
	 * We could add a second check for a QFS Unix capability bit
	 */
	if ((tcon->ses->capabilities & CAP_UNIX) &&
	    (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability)))
		rc = CIFSSMBQFSPosixInfo(xid, tcon, buf);

	/*
	 * Only need to call the old QFSInfo if failed on newer one,
	 * e.g. by OS/2.
	 **/
	if (rc && (tcon->ses->capabilities & CAP_NT_SMBS))
		rc = CIFSSMBQFSInfo(xid, tcon, buf);

	/*
	 * Some old Windows servers also do not support level 103, retry with
	 * older level one if old server failed the previous call or we
	 * bypassed it because we detected that this was an older LANMAN sess
	 */
	if (rc)
		rc = SMBOldQFSInfo(xid, tcon, buf);
	return rc;
}

static int
cifs_mand_lock(const unsigned int xid, struct cifsFileInfo *cfile, __u64 offset,
	       __u64 length, __u32 type, int lock, int unlock, bool wait)
{
	return CIFSSMBLock(xid, tlink_tcon(cfile->tlink), cfile->fid.netfid,
			   current->tgid, length, offset, unlock, lock,
			   (__u8)type, wait, 0);
}

static int
cifs_unix_dfs_readlink(const unsigned int xid, struct cifs_tcon *tcon,
		       const unsigned char *searchName, char **symlinkinfo,
		       const struct nls_table *nls_codepage)
{
#ifdef CONFIG_CIFS_DFS_UPCALL
	int rc;
	unsigned int num_referrals = 0;
	struct dfs_info3_param *referrals = NULL;

	rc = get_dfs_path(xid, tcon->ses, searchName, nls_codepage,
			  &num_referrals, &referrals, 0);

	if (!rc && num_referrals > 0) {
		*symlinkinfo = kstrndup(referrals->node_name,
					strlen(referrals->node_name),
					GFP_KERNEL);
		if (!*symlinkinfo)
			rc = -ENOMEM;
		free_dfs_info_array(referrals, num_referrals);
	}
	return rc;
#else /* No DFS support */
	return -EREMOTE;
#endif
}

static int
cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
		   const char *full_path, char **target_path,
		   struct cifs_sb_info *cifs_sb)
{
	int rc;
	int oplock = 0;
	struct cifs_fid fid;
	struct cifs_open_parms oparms;

	cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);

	/* Check for unix extensions */
	if (cap_unix(tcon->ses)) {
		rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, target_path,
					     cifs_sb->local_nls,
					     cifs_remap(cifs_sb));
		if (rc == -EREMOTE)
			rc = cifs_unix_dfs_readlink(xid, tcon, full_path,
						    target_path,
						    cifs_sb->local_nls);

		goto out;
	}

	oparms.tcon = tcon;
	oparms.cifs_sb = cifs_sb;
	oparms.desired_access = FILE_READ_ATTRIBUTES;
	oparms.create_options = OPEN_REPARSE_POINT;
	oparms.disposition = FILE_OPEN;
	oparms.path = full_path;
	oparms.fid = &fid;
	oparms.reconnect = false;

	rc = CIFS_open(xid, &oparms, &oplock, NULL);
	if (rc)
		goto out;

	rc = CIFSSMBQuerySymLink(xid, tcon, fid.netfid, target_path,
				 cifs_sb->local_nls);
	if (rc)
		goto out_close;

	convert_delimiter(*target_path, '/');
out_close:
	CIFSSMBClose(xid, tcon, fid.netfid);
out:
	if (!rc)
		cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);
	return rc;
}

static bool
cifs_is_read_op(__u32 oplock)
{
	return oplock == OPLOCK_READ;
}

static unsigned int
cifs_wp_retry_size(struct inode *inode)
{
	return CIFS_SB(inode->i_sb)->wsize;
}

static bool
cifs_dir_needs_close(struct cifsFileInfo *cfile)
{
	return !cfile->srch_inf.endOfSearch && !cfile->invalidHandle;
}

struct smb_version_operations smb1_operations = {
	.send_cancel = send_nt_cancel,
	.compare_fids = cifs_compare_fids,
	.setup_request = cifs_setup_request,
	.setup_async_request = cifs_setup_async_request,
	.check_receive = cifs_check_receive,
	.add_credits = cifs_add_credits,
	.set_credits = cifs_set_credits,
	.get_credits_field = cifs_get_credits_field,
	.get_credits = cifs_get_credits,
	.wait_mtu_credits = cifs_wait_mtu_credits,
	.get_next_mid = cifs_get_next_mid,
	.read_data_offset = cifs_read_data_offset,
	.read_data_length = cifs_read_data_length,
	.map_error = map_smb_to_linux_error,
	.find_mid = cifs_find_mid,
	.check_message = checkSMB,
	.dump_detail = cifs_dump_detail,
	.clear_stats = cifs_clear_stats,
	.print_stats = cifs_print_stats,
	.is_oplock_break = is_valid_oplock_break,
	.downgrade_oplock = cifs_downgrade_oplock,
	.check_trans2 = cifs_check_trans2,
	.need_neg = cifs_need_neg,
	.negotiate = cifs_negotiate,
	.negotiate_wsize = cifs_negotiate_wsize,
	.negotiate_rsize = cifs_negotiate_rsize,
	.sess_setup = CIFS_SessSetup,
	.logoff = CIFSSMBLogoff,
	.tree_connect = CIFSTCon,
	.tree_disconnect = CIFSSMBTDis,
	.get_dfs_refer = CIFSGetDFSRefer,
	.qfs_tcon = cifs_qfs_tcon,
	.is_path_accessible = cifs_is_path_accessible,
	.query_path_info = cifs_query_path_info,
	.query_file_info = cifs_query_file_info,
	.get_srv_inum = cifs_get_srv_inum,
	.set_path_size = CIFSSMBSetEOF,
	.set_file_size = CIFSSMBSetFileSize,
	.set_file_info = smb_set_file_info,
	.set_compression = cifs_set_compression,
	.echo = CIFSSMBEcho,
	.mkdir = CIFSSMBMkDir,
	.mkdir_setinfo = cifs_mkdir_setinfo,
	.rmdir = CIFSSMBRmDir,
	.unlink = CIFSSMBDelFile,
	.rename_pending_delete = cifs_rename_pending_delete,
	.rename = CIFSSMBRename,
	.create_hardlink = CIFSCreateHardLink,
	.query_symlink = cifs_query_symlink,
	.open = cifs_open_file,
	.set_fid = cifs_set_fid,
	.close = cifs_close_file,
	.flush = cifs_flush_file,
	.async_readv = cifs_async_readv,
	.async_writev = cifs_async_writev,
	.sync_read = cifs_sync_read,
	.sync_write = cifs_sync_write,
	.query_dir_first = cifs_query_dir_first,
	.query_dir_next = cifs_query_dir_next,
	.close_dir = cifs_close_dir,
	.calc_smb_size = smbCalcSize,
	.oplock_response = cifs_oplock_response,
	.queryfs = cifs_queryfs,
	.mand_lock = cifs_mand_lock,
	.mand_unlock_range = cifs_unlock_range,
	.push_mand_locks = cifs_push_mandatory_locks,
	.query_mf_symlink = cifs_query_mf_symlink,
	.create_mf_symlink = cifs_create_mf_symlink,
	.is_read_op = cifs_is_read_op,
	.wp_retry_size = cifs_wp_retry_size,
	.dir_needs_close = cifs_dir_needs_close,
#ifdef CONFIG_CIFS_XATTR
	.query_all_EAs = CIFSSMBQAllEAs,
	.set_EA = CIFSSMBSetEA,
#endif /* CIFS_XATTR */
#ifdef CONFIG_CIFS_ACL
	.get_acl = get_cifs_acl,
	.get_acl_by_fid = get_cifs_acl_by_fid,
	.set_acl = set_cifs_acl,
#endif /* CIFS_ACL */
};

struct smb_version_values smb1_values = {
	.version_string = SMB1_VERSION_STRING,
	.large_lock_type = LOCKING_ANDX_LARGE_FILES,
	.exclusive_lock_type = 0,
	.shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
	.unlock_lock_type = 0,
	.header_size = sizeof(struct smb_hdr),
	.max_header_size = MAX_CIFS_HDR_SIZE,
	.read_rsp_size = sizeof(READ_RSP),
	.lock_cmd = cpu_to_le16(SMB_COM_LOCKING_ANDX),
	.cap_unix = CAP_UNIX,
	.cap_nt_find = CAP_NT_SMBS | CAP_NT_FIND,
	.cap_large_files = CAP_LARGE_FILES,
	.signing_enabled = SECMODE_SIGN_ENABLED,
	.signing_required = SECMODE_SIGN_REQUIRED,
};


text:
import { SkyAgGridCellEditorUtils } from './cell-editor-utils';

describe('Cell editor utils', () => {
  describe('subtractIf()', () => {
    it('should return the difference if minuend is not null or undefined', () => {
      expect(SkyAgGridCellEditorUtils.subtractOrZero(2, 1)).toBe(1);
      expect(SkyAgGridCellEditorUtils.subtractOrZero(2, 3)).toBe(-1);
      expect(SkyAgGridCellEditorUtils.subtractOrZero(0, 0)).toBe(0);
    });

    it('should return 0 if minuend is null or undefined', () => {
      expect(SkyAgGridCellEditorUtils.subtractOrZero(null, 4)).toBe(0);
      expect(SkyAgGridCellEditorUtils.subtractOrZero(undefined, 8)).toBe(0);
    });
  });
});

redpajama_set_name: RedPajamaGithub


text:
namespace IK
{

	class KeyGenerator: public IK::Singleton<KeyGenerator>
	{
	public:
		KeyGenerator();
		~KeyGenerator();

		std::wstring getKey();
		void push(std::wstring value);

	private:

		void initialize();
		int maxKeyCode = 30000;

		tbb::concurrent_queue<std::wstring> keyQueue;

	};
}


text:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="latest_ob.xsl" type="text/xsl"?>
<current_observation version="1.0"
	 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:noNamespaceSchemaLocation="http://www.weather.gov/view/current_observation.xsd">
	<credit>NOAA's National Weather Service</credit>
	<credit_URL>http://weather.gov/</credit_URL>
	<image>
		<url>http://weather.gov/images/xml_logo.gif</url>
		<title>NOAA's National Weather Service</title>
		<link>http://weather.gov</link>
	</image>
	<suggested_pickup>15 minutes after the hour</suggested_pickup>
	<suggested_pickup_period>60</suggested_pickup_period>
	<location>Glens Falls, Floyd Bennett Memorial Airport, NY</location>
	<station_id>KGFL</station_id>
	<latitude>43.34111</latitude>
	<longitude>-73.61056</longitude>
	<observation_time>Last Updated on Jan 4 2016, 9:53 pm EST</observation_time>
        <observation_time_rfc822>Mon, 04 Jan 2016 21:53:00 -0500</observation_time_rfc822>
	<weather>Overcast</weather>
	<temperature_string>7.0 F (-13.9 C)</temperature_string>
	<temp_f>7.0</temp_f>
	<temp_c>-13.9</temp_c>
	<relative_humidity>63</relative_humidity>
	<wind_string>Northeast at 6.9 MPH (6 KT)</wind_string>
	<wind_dir>Northeast</wind_dir>
	<wind_degrees>50</wind_degrees>
	<wind_mph>6.9</wind_mph>
	<wind_kt>6</wind_kt>
	<pressure_string>1033.2 mb</pressure_string>
	<pressure_mb>1033.2</pressure_mb>
	<pressure_in>30.47</pressure_in>
	<dewpoint_string>-2.9 F (-19.4 C)</dewpoint_string>
	<dewpoint_f>-2.9</dewpoint_f>
	<dewpoint_c>-19.4</dewpoint_c>
	<windchill_string>-5 F (-21 C)</windchill_string>
      	<windchill_f>-5</windchill_f>
      	<windchill_c>-21</windchill_c>
	<visibility_mi>10.00</visibility_mi>
 	<icon_url_base>http://forecast.weather.gov/images/wtf/small/</icon_url_base>
	<two_day_history_url>http://www.weather.gov/data/obhistory/KGFL.html</two_day_history_url>
	<icon_url_name>novc.png</icon_url_name>
	<ob_url>http://www.weather.gov/data/METAR/KGFL.1.txt</ob_url>
	<disclaimer_url>http://weather.gov/disclaimer.html</disclaimer_url>
	<copyright_url>http://weather.gov/disclaimer.html</copyright_url>
	<privacy_policy_url>http://weather.gov/notice.html</privacy_policy_url>
</current_observation>


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Example_FacebookLogin</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>

</resources>


text:
package info.rmapproject.testdata.service;

/**
 * The test data files available.
 * @author khanson
 */
public enum TestFile {

	/** Based on IEEE data, working DiSCO "A" - different from DiSCO A, an alternative DiSCO to use
	 *  for tests where you just want a working DiSCO
	 * 	has multiple aggregated resources. Some BNodes. The DiSCO shares some URIs with DiSCO B and C*/
	DISCOA_XML("/discos/discoA.rdf","RDFXML"),

	/** DiSCO "A" in Turtle RDF format */
	DISCOA_TURTLE("/discos/discoA.ttl","TURTLE"),

	/** DiSCO "A" in JSON-LD format */
	DISCOA_JSONLD("/discos/discoA.jsonld","JSONLD"),

	/** DiSCO "A" as XML with bad syntax (one of the close tags is an ampersand), for testing badly formed RDF error */
	DISCOA_XML_BAD_SYNTAX("/discos/discoA_badsyntax.rdf","RDFXML"),

	/** DiSCO "A" as XML with no DiSCO type definition. */
	DISCOA_XML_NO_TYPE("/discos/discoA_notype.rdf","RDFXML"),

	/** DiSCO "A" as XML with no ore:aggregate defined */
	DISCOA_XML_NO_AGGREGATES("/discos/discoA_noaggregates.rdf","RDFXML"),

	/** DiSCO "A" as XML with no ore:aggregate defined */
	DISCOA_XML_AGGREGATES_ONLY("/discos/discoA_aggregatesonly.rdf","RDFXML"),

	/** DiSCO "A" as XML with some BNodes */
	DISCOA_XML_WITH_BNODES("/discos/discoA_withbnodes.rdf","RDFXML"),

	/** DiSCO "A" as XML with some BNodes */
	DISCOA_TURTLE_WITH_BNODES("/discos/discoA_withbnodes.ttl","TURTLE"),

	/** DiSCO "A" as XML with some BNodes */
	DISCOA_JSONLD_WITH_BNODES("/discos/discoA_withbnodes.jsonld","JSONLD"),

	/** DiSCO "A" as XML but includes a provider ID - RMap retains the provider-provided ID on creation */
	DISCOA_XML_WITH_PROVIDERID("/discos/discoA_withproviderid.rdf","RDFXML"),

	/** DISCO "A" as XML with a space in one of the URIs making it badly formed.  */
	DISCOA_XML_ENCODED_SPACE_IN_URL("/discos/discoA_encodedspaceinurl.rdf","RDFXML"),

	/** DiSCO "A" as XML repeated twice (i.e. 2 DiSCOs in one file) */
	DISCOA_XML_X2("/discos/discoA_x2.rdf","RDFXML"),

	/** DiSCO "A" as XML with URI modified so that graph is not connected (one of files in zip has altered name */
	DISCOA_XML_NOT_CONNECTED("/discos/discoA_notconnected.rdf","RDFXML"),

	/** DiSCO "A" as XML with no additional statements */
	DISCOA_XML_NO_BODY("/discos/discoA_nobody.rdf","RDFXML"),

	/** DiSCO "A" as XML with no additional statements or aggregates*/
	DISCOA_XML_NO_BODY_NO_AGGREGATES("/discos/discoA_nobody_noaggregates.rdf","RDFXML"),

	/** DiSCO "A" as turtle with some inverse relationships that form new roots and break the directionality of the DiSCO
	 * Can be used to check any connected graph OK even if it's not a one directional graph rooted from aggregates*/
	DISCOA_TURTLE_NON_AGGREGATE_ROOTS("/discos/discoA_nonaggregateroots.ttl","TURTLE"),

	/** Based on Portico data, working DiSCO "B" version 1, use for tests where you just want a working
	 *  DiSCO. This DiSCO contains 1 aggregated resource, 3 authors (2 BNodes, one with ORCID), a
	 *  person name with an accent, quotes in quotes, blank nodes, a DiSCO Creator, and description */
	DISCOB_V1_XML("/discos/discoB_v1.rdf","RDFXML"),

	/** Working DiSCO "B" version 2. Slight variation on "v1" - one of the ARK IDs is different.
	 * Use for tests where you want a second version of a DiSCO */
	DISCOB_V2_XML("/discos/discoB_v2.rdf","RDFXML"),

	/** Working DiSCO "B" version 3. Slight variation on "v2" - the DOI type changed to Conference Paper.
	 * Use for tests where you want a third version of a DiSCO */
	DISCOB_V3_XML("/discos/discoB_v3.rdf","RDFXML"),

	/** Working DiSCO "B" version 4. Slight variation on "v3" - one of the aggregated objects has been removed.
	 * Use for tests where you want a fourth version of a DiSCO */
	DISCOB_V4_XML("/discos/discoB_v4.rdf","RDFXML"),

	/** Based on DataCite data, working DiSCO "C" - different from DiSCO A or B, an alternative DiSCO to
	 *  use for tests where you just want a working DiSCO.  Has multiple aggregated resources, no BNodes.
	 *  The DiSCO shares some URIs with DiSCO A and B*/
	DISCOC_XML("/discos/discoC.rdf","RDFXML"),

	/** Valid Agent "A" as XML for testing. Many tests need a system agent to start. This can be used.   */
	AGENTA_XML("/agents/agentA.rdf","RDFXML"),

	/** Valid Agent "A" as Turtle for testing */
	AGENTA_TURTLE("/agents/agentA.ttl","TURTLE"),

	/** Valid Agent "A" as JSON-LD for testing */
	AGENTA_JSONLD("/agents/agentA.jsonld","JSONLD"),

	/** Agent "A" as XML for testing but with no ID. System should create one.*/
	AGENTA_XML_NO_ID("/agents/agentA_noid.rdf","RDFXML"),

	/** Agent "A" as XML for testing but with no Agent type defined*/
	AGENTA_XML_NO_TYPE("/agents/agentA_notype.rdf","RDFXML"),

	/** Agent "A" as XML for testing but with no Agent Name defined*/
	AGENTA_XML_NO_NAME("/agents/agentA_noname.rdf","RDFXML"),

	/** Agent "A" as XML for testing but with no Agent ID Provider defined*/
	AGENTA_XML_NO_ID_PROVIDER("/agents/agentA_noidprovider.rdf","RDFXML"),

	/** Agent "A" as XML for testing but with no Agent AuthID defined*/
	AGENTA_XML_NO_AUTHID("/agents/agentA_noauthid.rdf","RDFXML"),

	/** Working generic Agent "B" record for use in testing versions or as a second test agent. */
	AGENTB_V1_XML("/agents/agentB_v1.rdf","RDFXML"),

	/** Working generic Agent "B" record, name different from V1. Use to check Agent updates.  */
	AGENTB_V2_XML("/agents/agentB_v2.rdf","RDFXML"),

	/** Working generic Agent "B" record, id provider and auth id changed since V2.  use to check Agent updates. */
	AGENTB_V3_XML("/agents/agentB_v3.rdf","RDFXML"),

	/*
	 * TODO: COMMENTING OUT EVENTS, NO FILES FOR THESE - REMOVE IF NOT USED
	 */

//	/** Creation Event as RDF XML*/
//	EVENT_CREATION_XML("/events/event_creation.rdf","RDFXML"),
//
//	/** Creation Event as RDF XML with missing target type*/
//	EVENT_CREATION_XML_NO_TARGETTYPE("/events/event_creation_no_targettype.rdf","RDFXML"),
//
//	/** Creation Event as RDF XML with missing created object*/
//	EVENT_CREATION_NO_CREATED_OBJ("/events/event_creation_no_createdobjs.rdf","RDFXML"),
//
//	/** Deletion Event as RDF XML*/
//	EVENT_DELETION_XML("/events/event_deletion.rdf","RDFXML"),
//
//	/** Deletion Event as RDF XML with missing deleted objs*/
//	EVENT_DELETION_XML_NO_DELETED_OBJ("/events/event_deletion_no_deletedobjs.rdf","RDFXML"),
//
//	/** Derivation Event as RDF XML*/
//	EVENT_DERIVATION_XML("/events/event_derivation.rdf","RDFXML"),
//
//	/** Derivation Event as RDF XML with missing source obj*/
//	EVENT_DERIVATION_XML_NO_SOURCE_OBJ("/events/event_derivattion_no_sourceobj.rdf","RDFXML"),
//
//	/** Derivation Event as RDF XML with missing derived obj*/
//	EVENT_DERIVATION_XML_NO_DERIVED_OBJ("/events/event_derivation_no_deletedobj.rdf","RDFXML"),
//
//	/** Inactivation Event as RDF XML*/
//	EVENT_INACTIVATION_XML("/events/event_inactivation.rdf","RDFXML"),
//
//	/** Inactivation Event as RDF XML with no inactivated obj*/
//	EVENT_INACTIVATION_XML_NO_INACTIVATED_OBJ("/events/event_inactivation_no_inactivatedobj.rdf","RDFXML"),
//
//	/** Tombstone Event as RDF XML*/
//	EVENT_TOMBSTONE_XML("/events/event_tombstone.rdf","RDFXML"),
//
//	/** Tombstone Event as RDF XML with no tombstoned obj*/
//	EVENT_TOMBSTONE_XML_NO_TOMBSTONED_OBJ("/events/event_tombstone_no_tombstonedobj.rdf","RDFXML"),
//
//	/** Update Event as RDF XML*/
//	EVENT_UPDATE_XML("/events/event_update.rdf","RDFXML"),
//
//	/** Update Event as RDF XML with missing inactivated obj*/
//	EVENT_UPDATE_XML_NO_INACTIVATED_OBJ("/events/event_update_no_inactivatedobj.rdf","RDFXML"),
//
//	/** Update Event as RDF XML with missing derived obj*/
//	EVENT_UPDATE_XML_NO_DERIVED_OBJ("/events/event_update_no_derivedobj.rdf","RDFXML"),
//
//	/** Update with replace Event as RDF XML*/
//	EVENT_UPDATE_REPLACE_XML("/events/event_udpate_with_replace.rdf","RDFXML"),
//
//	/** Update with replace Event as RDF XML with missing inactivated obj*/
//	EVENT_UPDATE_REPLACE_XML_NO_INACTIVATED_OBJ("/events/event_updatereplace_no_inactivatedobj.rdf","RDFXML"),
//
//	/** Update with replace Event as RDF XML with missing derived obj*/
//	EVENT_UPDATE_REPLACE_XML_NO_DERIVED_OBJ("/events/event_updatereplace_no_derivedobj.rdf","RDFXML"),
//
//	EVENT_XML_NO_TYPE("/events/event_creation_no_targettype.rdf","RDFXML"),

	/** An empty file+ */
	EMPTY_FILE("/empty.txt", "");

	/** The media type. */
	private final String filepath;

	/** The media type. */
	private final String type;
	/**
	 * Instantiates a new test object type.
	 *
	 * @param filepath the filepath
	 */
	private TestFile (String filepath, String type) {
		this.filepath = filepath;
		this.type = type;
	}

	/**
	 * Gets the filepath.
	 *
	 * @return the filepath
	 */
	public String getFilePath()  {
		return filepath;
	}
	/**
	 * Gets the filepath.
	 *
	 * @return the filepath
	 */

	public String getType()  {
		return type;
	}

}


text:
TEST(BuildTime, DateLooksValid) {
  char build_date[] = BUILD_DATE;

  EXPECT_EQ(20u, strlen(build_date));
  EXPECT_EQ(' ', build_date[3]);
  EXPECT_EQ(' ', build_date[6]);
  EXPECT_EQ(' ', build_date[11]);
#if !defined(OFFICIAL_BUILD)
  EXPECT_EQ('0', build_date[12]);
  EXPECT_EQ('5', build_date[13]);
#endif
  EXPECT_EQ(':', build_date[14]);
#if !defined(OFFICIAL_BUILD)
  EXPECT_EQ('0', build_date[15]);
  EXPECT_EQ('0', build_date[16]);
#endif
  EXPECT_EQ(':', build_date[17]);
#if !defined(OFFICIAL_BUILD)
  EXPECT_EQ('0', build_date[18]);
  EXPECT_EQ('0', build_date[19]);
#endif
}

#if defined(OS_FUCHSIA)
// TODO(https://crbug.com/1060357): Enable when RTC flake is fixed.
#define MAYBE_InThePast DISABLED_InThePast
#else
#define MAYBE_InThePast InThePast
#endif

TEST(BuildTime, MAYBE_InThePast) {
  EXPECT_LT(base::GetBuildTime(), base::Time::Now());
  EXPECT_LT(base::GetBuildTime(), base::Time::NowFromSystemTime());
}


text:
'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

/**
 * Function for measuring sizeof objects
 *
 * @param object
 * @returns {*}
 */
var sizeof = exports.sizeof = function sizeof(object) {
    var objects = [];

    function transverse(value) {
        var bytes = 0;

        switch (true) {
            case typeof value === 'boolean':
                {
                    bytes = 4;
                }break;

            case typeof value === 'string':
                {
                    bytes = value.length * 2;
                }break;

            case typeof value === 'number':
                {
                    bytes = 8;
                }break;

            case (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && objects.indexOf(value) === -1:
                {
                    objects[objects.length] = value;

                    for (var i in value) {
                        bytes += 8;
                        bytes += transverse(value[i]);
                    }
                }break;
        }

        return bytes;
    }

    return transverse(object);
};


text:
ARG repo
ARG arch=amd64
ARG python=3.6
FROM ${repo}:${arch}-conda-python-${python}

ARG jdk=8
ARG maven=3.5

RUN conda install -q \
        openjdk=${jdk} \
        maven=${maven} \
        pandas && \
    conda clean --all

# installing specific version of spark
ARG spark=master
COPY ci/scripts/install_spark.sh /arrow/ci/scripts/
RUN /arrow/ci/scripts/install_spark.sh ${spark} /spark

# build cpp with tests
ENV CC=gcc \
    CXX=g++ \
    ARROW_PYTHON=ON \
    ARROW_HDFS=ON \
    ARROW_BUILD_TESTS=OFF \
    SPARK_VERSION=${spark}


text:
<?php

require_once('tcpdf_include.php');

require_once('../tcpdf.php');

include ('../../protected/config/db_config.php');

$db = new db_config();

$connect = $db->connect();

// create new PDF document
//$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// add a page
$pdf = new TCPDF();

//$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', true, 'UTF-8', false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);

$pdf->SetCreator(PDF_CREATOR);

//$pdf->SetAuthor('Nicola Asuni');

$pdf->SetSubject('');

$pdf->SetKeywords('');

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.'ZÁRIL lifestyle store', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));

$pdf->setFooterData(array(0,1,0), array(0,1,1));

$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));

$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);

$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);

$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

$resolution= array(80, 100);
$pdf->AddPage('P', $resolution);
$pdf->SetTitle('Tenant Sales Report');

$html = $_GET['html'];

#$html .='<div>'. $html .'</div>';

$pdf->writeHTML($html, false, false, true, false, '');
$pdf->Output('..');


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

			Event 1

			Event 2

			Event 3


text:
package net.bootsfaces.expressions;

import java.util.List;

import javax.faces.component.UIComponent;

public interface AbstractExpressionResolver {
	public List<UIComponent> resolve(UIComponent component, List<UIComponent> parentComponents, String currentId, String originalExpression, String[] parameters);

}


text:
<?php

namespace Prodeko\IlmoBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * FreeTextFieldRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class FreeTextFieldRepository extends EntityRepository
{
}


text:
<ccConfig tempDirectory="/Users/rtholmes/tmp/hgTmp/">
	<project myKind="HG" myShortName="tortoise"
		myClone="/Users/rtholmes/dev/hgRepos/tortoiseHg/">
		<sources>
			<source kind="HG" shortName="face" clone="https://bitbucket.org/face/tortoisehgqueue" />
			<source kind="HG" shortName="pyQt" clone="https://bitbucket.org/tortoisehg/thg" />
			<source kind="HG" shortName="HEAD" clone="http://bitbucket.org/tortoisehg/stable" />
		</sources>
	</project>
	<!--
	<project myKind="HG" myShortName="murky"
		myClone="/Users/rtholmes/dev/hgRepos/murky/">
		<sources>
			<source kind="HG" shortName="bordezo" clone="https://bitbucket.org/boredzo/murky" />
			<source kind="HG" shortName="oscherler" clone="https://bitbucket.org/oscherler/murky" />
			<source kind="HG" shortName="mazdak" clone="https://bitbucket.org/mazdak/murky-with-sparkle" />
			<source kind="HG" shortName="HEAD" clone="http://bitbucket.org/snej/murky" />
		</sources>
	</project>
	<project myKind="HG" myShortName="plume-lib"
		myClone="/Users/rtholmes/dev/hgRepos/plume-lib/">
		<sources>
			<source kind="HG" shortName="HEAD" clone=" https://plume-lib.googlecode.com/hg/" />
		</sources>
	</project>
	<project myKind="HG" myShortName="ductile-paper"
		myClone="/Users/rtholmes/dev/hgRepos/ductile-paper/">
		<sources>
			<source kind="HG" shortName="HEAD" clone="ssh://tricycle.cs.washington.edu//projects/swlab1/ductile/paper-2010/" />
		</sources>
	</project>
	<project myKind="HG" myShortName="javarifier"
		myClone="/Users/rtholmes/dev/hgRepos/javarifier/">
		<sources>
			<source kind="HG" shortName="HEAD" clone="https://javarifier.googlecode.com/hg/" />
		</sources>
	</project>
	-->
	<!-- Too slow for a good demo.
	<project myKind="HG" myShortName="checker-framework"
		myClone="/Users/rtholmes/dev/hgRepos/checker-framework/">
		<sources>
			<source kind="HG" shortName="HEAD" clone="https://checker-framework.googlecode.com/hg/" />
		</sources>
	</project>
	-->
</ccConfig>


text:
<?php
defined('IN_DESTOON') or exit('Access Denied');
$time = $today_endtime - 30*86400;
$db->query("DELETE FROM {$DT_PRE}login WHERE logintime<$time");
?>


text:
/**
 * @author qiao / https://github.com/qiao
 * @author mrdoob / http://mrdoob.com
 * @author alteredq / http://alteredqualia.com/
 * @author WestLangley / http://github.com/WestLangley
 * @author erich666 / http://erichaines.com
 * @author mrflix / http://felixniklas.de
 *
 * released under MIT License (MIT)
 */
/*global THREE, console */

// This set of controls performs orbiting, dollying (zooming), and panning. It maintains
// the "up" direction as +Y, unlike the TrackballControls. Touch on tablet and phones is
// supported.
//
//    Orbit - left mouse / touch: one finger move
//    Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
//    Pan - right mouse, or arrow keys / touch: three finter swipe
//
// This is a drop-in replacement for (most) TrackballControls used in examples.
// That is, include this js file and wherever you see:
//    	controls = new THREE.TrackballControls( camera );
//      controls.target.z = 150;
// Simple substitute "OrbitControls" and the control should work as-is.

THREE.OrbitControls = function ( object, domElement, localElement ) {

	this.object = object;
	this.domElement = ( domElement !== undefined ) ? domElement : document;
	this.localElement = ( localElement !== undefined ) ? localElement : document;

	// API

	// Set to false to disable this control
	this.enabled = true;

	// "target" sets the location of focus, where the control orbits around
	// and where it pans with respect to.
	this.target = new THREE.Vector3();
	// center is old, deprecated; use "target" instead
	this.center = this.target;

	// This option actually enables dollying in and out; left as "zoom" for
	// backwards compatibility
	this.noZoom = false;
	this.zoomSpeed = 1.0;
	// Limits to how far you can dolly in and out
	this.minDistance = 0;
	this.maxDistance = Infinity;

	// Set to true to disable this control
	this.noRotate = false;
	this.rotateSpeed = 1.0;

	// Set to true to disable this control
	this.noPan = false;
	this.keyPanSpeed = 7.0;	// pixels moved per arrow key push

	// Set to true to automatically rotate around the target
	this.autoRotate = false;
	this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60

	// How far you can orbit vertically, upper and lower limits.
	// Range is 0 to Math.PI radians.
	this.minPolarAngle = 0; // radians
	this.maxPolarAngle = Math.PI; // radians

	// Set to true to disable use of the keys
	this.noKeys = false;
	// The four arrow keys
	this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };

	////////////
	// internals

	var scope = this;

	var EPS = 0.000001;

	var rotateStart = new THREE.Vector2();
	var rotateEnd = new THREE.Vector2();
	var rotateDelta = new THREE.Vector2();

	var panStart = new THREE.Vector2();
	var panEnd = new THREE.Vector2();
	var panDelta = new THREE.Vector2();

	var dollyStart = new THREE.Vector2();
	var dollyEnd = new THREE.Vector2();
	var dollyDelta = new THREE.Vector2();

	var phiDelta = 0;
	var thetaDelta = 0;
	var scale = 1;
	var pan = new THREE.Vector3();

	var lastPosition = new THREE.Vector3();

	var STATE = { NONE : -1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
	var state = STATE.NONE;

	// events

	var changeEvent = { type: 'change' };

	this.rotateLeft = function ( angle ) {

		if ( angle === undefined ) {

			angle = getAutoRotationAngle();

		}

		thetaDelta -= angle;

	};

	this.rotateUp = function ( angle ) {

		if ( angle === undefined ) {

			angle = getAutoRotationAngle();

		}

		phiDelta -= angle;

	};

	// pass in distance in world space to move left
	this.panLeft = function ( distance ) {

		var panOffset = new THREE.Vector3();
		var te = this.object.matrix.elements;
		// get X column of matrix
		panOffset.set( te[0], te[1], te[2] );
		panOffset.multiplyScalar(-distance);

		pan.add( panOffset );

	};

	// pass in distance in world space to move up
	this.panUp = function ( distance ) {

		var panOffset = new THREE.Vector3();
		var te = this.object.matrix.elements;
		// get Y column of matrix
		panOffset.set( te[4], te[5], te[6] );
		panOffset.multiplyScalar(distance);

		pan.add( panOffset );
	};

	// main entry point; pass in Vector2 of change desired in pixel space,
	// right and down are positive
	this.pan = function ( delta ) {

		var element = scope.domElement === document ? scope.domElement.body : scope.domElement;

		if ( scope.object.fov !== undefined ) {

			// perspective
			var position = scope.object.position;
			var offset = position.clone().sub( scope.target );
			var targetDistance = offset.length();

			// half of the fov is center to top of screen
			targetDistance *= Math.tan( (scope.object.fov/2) * Math.PI / 180.0 );
			// we actually don't use screenWidth, since perspective camera is fixed to screen height
			scope.panLeft( 2 * delta.x * targetDistance / element.clientHeight );
			scope.panUp( 2 * delta.y * targetDistance / element.clientHeight );

		} else if ( scope.object.top !== undefined ) {

			// orthographic
			scope.panLeft( delta.x * (scope.object.right - scope.object.left) / element.clientWidth );
			scope.panUp( delta.y * (scope.object.top - scope.object.bottom) / element.clientHeight );

		} else {

			// camera neither orthographic or perspective - warn user
			console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );

		}

	};

	this.dollyIn = function ( dollyScale ) {

		if ( dollyScale === undefined ) {

			dollyScale = getZoomScale();

		}

		scale /= dollyScale;

	};

	this.dollyOut = function ( dollyScale ) {

		if ( dollyScale === undefined ) {

			dollyScale = getZoomScale();

		}

		scale *= dollyScale;

	};

	this.update = function () {
        var position = this.object.position;
		var offset = position.clone().sub( this.target );

		// angle from z-axis around y-axis

		var theta = Math.atan2( offset.x, offset.z );

		// angle from y-axis

		var phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );

		if ( this.autoRotate ) {

			this.rotateLeft( getAutoRotationAngle() );

		}

		theta += thetaDelta;
		phi += phiDelta;

		// restrict phi to be between desired limits
		phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );

		// restrict phi to be betwee EPS and PI-EPS
		phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );

		var radius = offset.length() * scale;

		// restrict radius to be between desired limits
		radius = Math.max( this.minDistance, Math.min( this.maxDistance, radius ) );

		// move target to panned location
		this.target.add( pan );

		offset.x = radius * Math.sin( phi ) * Math.sin( theta );
		offset.y = radius * Math.cos( phi );
		offset.z = radius * Math.sin( phi ) * Math.cos( theta );

		position.copy( this.target ).add( offset );

		this.object.lookAt( this.target );

		thetaDelta = 0;
		phiDelta = 0;
		scale = 1;
		pan.set(0,0,0);

		if ( lastPosition.distanceTo( this.object.position ) > 0 ) {

			this.dispatchEvent( changeEvent );

			lastPosition.copy( this.object.position );

		}

	};

	function getAutoRotationAngle() {

		return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;

	}

	function getZoomScale() {

		return Math.pow( 0.95, scope.zoomSpeed );

	}

	function onMouseDown( event ) {

		if ( scope.enabled === false ) { return; }
		event.preventDefault();

		if ( event.button === 0 ) {
			if ( scope.noRotate === true ) { return; }

			state = STATE.ROTATE;

			rotateStart.set( event.clientX, event.clientY );

		} else if ( event.button === 1 ) {
			if ( scope.noZoom === true ) { return; }

			state = STATE.DOLLY;

			dollyStart.set( event.clientX, event.clientY );

		} else if ( event.button === 2 ) {
			if ( scope.noPan === true ) { return; }

			state = STATE.PAN;

			panStart.set( event.clientX, event.clientY );

		}

		// Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
		scope.domElement.addEventListener( 'mousemove', onMouseMove, false );
		scope.domElement.addEventListener( 'mouseup', onMouseUp, false );

	}

	function onMouseMove( event ) {

		if ( scope.enabled === false ) return;

		event.preventDefault();

		var element = scope.domElement === document ? scope.domElement.body : scope.domElement;

		if ( state === STATE.ROTATE ) {

			if ( scope.noRotate === true ) return;

			rotateEnd.set( event.clientX, event.clientY );
			rotateDelta.subVectors( rotateEnd, rotateStart );

			// rotating across whole screen goes 360 degrees around
			scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
			// rotating up and down along whole screen attempts to go 360, but limited to 180
			scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );

			rotateStart.copy( rotateEnd );

		} else if ( state === STATE.DOLLY ) {

			if ( scope.noZoom === true ) return;

			dollyEnd.set( event.clientX, event.clientY );
			dollyDelta.subVectors( dollyEnd, dollyStart );

			if ( dollyDelta.y > 0 ) {

				scope.dollyIn();

			} else {

				scope.dollyOut();

			}

			dollyStart.copy( dollyEnd );

		} else if ( state === STATE.PAN ) {

			if ( scope.noPan === true ) return;

			panEnd.set( event.clientX, event.clientY );
			panDelta.subVectors( panEnd, panStart );

			scope.pan( panDelta );

			panStart.copy( panEnd );

		}

		// Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
		scope.update();

	}

	function onMouseUp( /* event */ ) {

		if ( scope.enabled === false ) return;

		// Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
		scope.domElement.removeEventListener( 'mousemove', onMouseMove, false );
		scope.domElement.removeEventListener( 'mouseup', onMouseUp, false );

		state = STATE.NONE;

	}

	function onMouseWheel( event ) {

		if ( scope.enabled === false || scope.noZoom === true ) return;

		var delta = 0;

		if ( event.wheelDelta ) { // WebKit / Opera / Explorer 9

			delta = event.wheelDelta;

		} else if ( event.detail ) { // Firefox

			delta = - event.detail;

		}

		if ( delta > 0 ) {

			scope.dollyOut();

		} else {

			scope.dollyIn();

		}

	}

	function onKeyDown( event ) {

		if ( scope.enabled === false ) { return; }
		if ( scope.noKeys === true ) { return; }
		if ( scope.noPan === true ) { return; }

		// pan a pixel - I guess for precise positioning?
		// Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
		var needUpdate = false;

		switch ( event.keyCode ) {

			case scope.keys.UP:
				scope.pan( new THREE.Vector2( 0, scope.keyPanSpeed ) );
				needUpdate = true;
				break;
			case scope.keys.BOTTOM:
				scope.pan( new THREE.Vector2( 0, -scope.keyPanSpeed ) );
				needUpdate = true;
				break;
			case scope.keys.LEFT:
				scope.pan( new THREE.Vector2( scope.keyPanSpeed, 0 ) );
				needUpdate = true;
				break;
			case scope.keys.RIGHT:
				scope.pan( new THREE.Vector2( -scope.keyPanSpeed, 0 ) );
				needUpdate = true;
				break;
		}

		// Greggman fix: https://github.com/greggman/three.js/commit/fde9f9917d6d8381f06bf22cdff766029d1761be
		if ( needUpdate ) {

			scope.update();

		}

	}

	function touchstart( event ) {

		if ( scope.enabled === false ) { return; }

		switch ( event.touches.length ) {

			case 1:	// one-fingered touch: rotate
				if ( scope.noRotate === true ) { return; }

				state = STATE.TOUCH_ROTATE;

				rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
				break;

			case 2:	// two-fingered touch: dolly
				if ( scope.noZoom === true ) { return; }

				state = STATE.TOUCH_DOLLY;

				var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
				var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
				var distance = Math.sqrt( dx * dx + dy * dy );
				dollyStart.set( 0, distance );
				break;

			case 3: // three-fingered touch: pan
				if ( scope.noPan === true ) { return; }

				state = STATE.TOUCH_PAN;

				panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
				break;

			default:
				state = STATE.NONE;

		}
	}

	function touchmove( event ) {

		if ( scope.enabled === false ) { return; }

		event.preventDefault();
		event.stopPropagation();

		var element = scope.domElement === document ? scope.domElement.body : scope.domElement;

		switch ( event.touches.length ) {

			case 1: // one-fingered touch: rotate
				if ( scope.noRotate === true ) { return; }
				if ( state !== STATE.TOUCH_ROTATE ) { return; }

				rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
				rotateDelta.subVectors( rotateEnd, rotateStart );

				// rotating across whole screen goes 360 degrees around
				scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
				// rotating up and down along whole screen attempts to go 360, but limited to 180
				scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );

				rotateStart.copy( rotateEnd );
				break;

			case 2: // two-fingered touch: dolly
				if ( scope.noZoom === true ) { return; }
				if ( state !== STATE.TOUCH_DOLLY ) { return; }

				var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
				var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
				var distance = Math.sqrt( dx * dx + dy * dy );

				dollyEnd.set( 0, distance );
				dollyDelta.subVectors( dollyEnd, dollyStart );

				if ( dollyDelta.y > 0 ) {

					scope.dollyOut();

				} else {

					scope.dollyIn();

				}

				dollyStart.copy( dollyEnd );
				break;

			case 3: // three-fingered touch: pan
				if ( scope.noPan === true ) { return; }
				if ( state !== STATE.TOUCH_PAN ) { return; }

				panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
				panDelta.subVectors( panEnd, panStart );

				scope.pan( panDelta );

				panStart.copy( panEnd );
				break;

			default:
				state = STATE.NONE;

		}

	}

	function touchend( /* event */ ) {

		if ( scope.enabled === false ) { return; }

		state = STATE.NONE;
	}

	this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
	this.localElement.addEventListener( 'mousedown', onMouseDown, false );
	this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
	this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox

	this.domElement.addEventListener( 'keydown', onKeyDown, false );

	this.localElement.addEventListener( 'touchstart', touchstart, false );
	this.domElement.addEventListener( 'touchend', touchend, false );
	this.domElement.addEventListener( 'touchmove', touchmove, false );

};

THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );


text:
{-# LANGUAGE
    EmptyDataDecls
  , ExistentialQuantification
  , FlexibleInstances
  , TemplateHaskell
  , UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Data.ClassFile.Desc.Typed
       ( module Data.ClassFile.Desc
       , Int (..)
       , Long (..)
       , Float (..)
       , Double (..)
       , ReturnAddress ()
       , Reference (..)
       , Void (..)
       , FieldDesc ()
       , ParameterDesc ()
       , ReturnDesc ()
       ) where

import Control.Monad

import Data.ClassFile.Desc
import Data.List
import Data.Word

import GHC.Exts (maxTupleSize)

import Language.Haskell.TH

import Prelude hiding (Double, Float, Int)

data Int = B | S | I | C | Z
data Long = J

data Float = F
data Double = D

data ReturnAddress

data Reference = L String
               | forall a. ComponentType a => A a

data Void = V

instance Desc Int where
  desc B = "B"
  desc S = "S"
  desc I = "I"
  desc C = "C"
  desc Z = "Z"

instance Desc Long where
  desc = const "L"
  stackSize _ = 2

instance Desc Float where
  desc = const "F"

instance Desc Double where
  desc = const "D"
  stackSize _ = 2

instance Desc Reference where
  descs (L x) = showChar 'L' . showString x . showChar ';'
  descs (A x) = showChar '[' . descs x

instance Desc Void where
  desc _ = "V"
  stackSize _ = 0

instance Desc () where
  descs _ = id
  stackSize _ = 0

instance FieldType a => Desc [a] where
  descs = undefined
  stackSize = foldl' ((. stackSize) . (+)) 0

class Friend a
instance Friend Int
instance Friend Long
instance Friend Float
instance Friend Double
instance Friend Reference
instance Friend ()
instance Friend Void
instance (FieldType a, Desc [a]) => Friend [a]

class Desc a => FieldType a
instance FieldType Int
instance FieldType Long
instance FieldType Float
instance FieldType Double
instance FieldType Reference

class FieldType a => ComponentType a
instance FieldType a => ComponentType a

class (Friend a, FieldType a) => FieldDesc a
instance (Friend a, FieldType a) => FieldDesc a

class (Friend a, Desc a) => ParameterDesc a
instance ParameterDesc Int
instance ParameterDesc Long
instance ParameterDesc Float
instance ParameterDesc Double
instance ParameterDesc Reference
instance ParameterDesc ()

$(do
  let n = min 255 maxTupleSize
  names <- replicateM n $ newName "a"
  liftM concat $ forM [2 .. n] $ \i -> do

    let names' = take i names
        tvs = map varT names'
        ctxt = cxt . map (\tv -> classP ''FieldType [tv]) $ tvs
        tupleTyp = foldl' appT (tupleT i) tvs

    let
      p = tupP . map varP $ names'
      es = map varE names'

      descTyp = appT (conT ''Desc) tupleTyp

      descsDec = funD 'descs [clause [p] (normalB g) []]
        where
          xs = map (\e -> [| descs $e |]) es
          g = foldr1 (\a b -> [| $a . $b |]) xs

      stackSizeDec = funD 'stackSize [clause [p] (normalB g) []]
        where
          xs = map (\e -> [| stackSize $e |]) es
          g = foldl1' (\a b -> [| ($a :: Word16) + $b |]) xs

      parameterDescTyp = appT (conT ''ParameterDesc) tupleTyp

      friendTyp = appT (conT ''Friend) tupleTyp

    sequence [ instanceD ctxt descTyp [descsDec, stackSizeDec]
             , instanceD (cxt []) friendTyp []
             , instanceD ctxt parameterDescTyp []
             ])

class (Friend a, Desc a) => ReturnDesc a
instance ReturnDesc Int
instance ReturnDesc Long
instance ReturnDesc Float
instance ReturnDesc Double
instance ReturnDesc Reference
instance ReturnDesc Void


text:
package es.inf.uc3m.kr.rdf2rshp.loader;

import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import org.apache.log4j.Logger;

import es.inf.uc3m.kr.rdf2rshp.exceptions.ResourceNotFoundException;
import es.inf.uc3m.kr.rdf2rshp.to.KnowledgeResourcesTO;

/**
 *
 * This class implements the interface ResourceLoader loading the data
 * from a file referenced by a name of the current classpath.
 *
 */
public class FilesResourceLoader  implements ResourceLoader {

	private static final Logger logger = Logger.getLogger(FilesResourceLoader.class);

	private String []resourceNames;

	public FilesResourceLoader(String[] filenames) {
		this.resourceNames = filenames;
	}
	public FilesResourceLoader(List <String>filenames) {
		this.resourceNames = filenames.toArray(new String[filenames.size()]);
	}

	protected InputStream openInputStream(String filename) throws FileNotFoundException {
		logger.debug("Opening resource input stream for filename: " + filename);
		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
		InputStream in = classLoader.getResourceAsStream(filename);
		if (in == null) {
			logger.error("Resource file not found: " + filename);
			throw new FileNotFoundException(filename);
		} else {
			return in;
		}
	}

	public KnowledgeResourcesTO[] getKnowledgeResources() {
		Collection<KnowledgeResourcesTO> ontologies = new LinkedList<KnowledgeResourcesTO>();
		String file = "";
		try {
			for (int i = 0 ;i< resourceNames.length;i++) {
				file =  resourceNames[i];
				KnowledgeResourcesTO resource = new KnowledgeResourcesTO(
						(this.openInputStream(file)));
				ontologies.add(resource);
			}
		} catch (FileNotFoundException e) {
			throw new ResourceNotFoundException(e, "Resource Files getting resource file:  "+file);
		}
		return  ontologies.toArray(new KnowledgeResourcesTO[ontologies.size()]);
	}

	public String getKnowledgeResourceAsString(String filename)
			throws ResourceNotFoundException {
		// TODO Auto-generated method stub
		throw new UnsupportedOperationException();
	}

}


text:
"""
Print the information of the current user
"""
from __future__ import unicode_literals

import logging

from binstar_client import errors
from binstar_client.utils import get_server_api
from binstar_client.utils.pprint import pprint_user

logger = logging.getLogger('binstar.whoami')

def main(args):
    aserver_api = get_server_api(args.token, args.site)

    try:
        user = aserver_api.user()
    except errors.Unauthorized as err:
        logger.debug(err)
        logger.info('Anonymous User')
        return 1

    pprint_user(user)

def add_parser(subparsers):
    subparser = subparsers.add_parser('whoami',
                                      help='Print the information of the current user',
                                      description=__doc__)

    subparser.set_defaults(main=main)


text:
submit-sitemap module for Node.js
==

Module to submit/ping a sitemap XML file to [Google](http://www.google.com) and [Bing](http://www.bing.com). This automates the manual process of submitting your sitemap via [Google's webmaster tools](https://support.google.com/sites/answer/100283?hl=en) and [Bing's webmaster tools](http://www.bing.com/webmaster/help/how-to-submit-sitemaps-82a15bd4).

Use this after your site content has changed to encourage search engines to recrawl your site for Search Engine Optimisation (SEO) purposes. For example, this is useful to do after deploying a site update in [Grunt](http://gruntjs.com/) and  [Gulp](http://gulpjs.com/) scripts.

If you're looking for modules to generate sitemaps, you may want to consider [grunt-sitemap for Grunt](https://www.npmjs.com/package/grunt-sitemap) and [gulp-sitemap for Gulp](https://www.npmjs.com/package/gulp-sitemap).

# Usage

To install:

    npm install submit-sitemap --save-dev

To submit your sitemap:

    var submitSitemap  = require('submit-sitemap').submitSitemap;
    var yourSitemapUrl = "http://www.google.com/sitemap.xml";

    submitSitemap(yourSitemapUrl);

Use the callback parameter to respond to success and failure:

    submitSitemap(yourSitemapUrl,  function(err) { console.error(err); });

- On success, `err` will be undefined.

- On error, `err` will be set to an error message. This happens if the sitemap URL could not be reached or any of the sitemap submission attempts failed.

# Tests

To run the test suite:

    npm test

# License

MIT

# Author

Written by [Sean Wilson](https://www.seanw.org) ([sw@seanw.org](mailto:sw@seanw.org)).


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MBODM.FtpGuest.Shared
{
    public interface IAuthenticator
    {
        bool Authenticate(Credentials credentials);
    }
}