text:
package org.fogbeam.experimental.reasoning.abductive.kbmanagement;

import static org.fogbeam.experimental.reasoning.abductive.AbductionConstants1.RESOURCE_BASE;
import static org.fogbeam.experimental.reasoning.abductive.AbductionConstants1.TDB_DIR;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.QuerySolution;
import org.apache.jena.query.ReadWrite;
import org.apache.jena.query.ResultSet;
import org.apache.jena.rdf.model.InfModel;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.reasoner.Reasoner;
import org.apache.jena.reasoner.ReasonerRegistry;
import org.apache.jena.tdb.TDBFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class VisualizeTrivialKBMain
{
	final static Logger logger = LoggerFactory.getLogger(VisualizeTrivialKBMain.class);

	public static void main(String[] args) throws IOException, InterruptedException
	{

		File tdbDir = new File( TDB_DIR + "/trivial" );
		if( !tdbDir.exists())
		{
			tdbDir.mkdirs();
		}

		Dataset ds = TDBFactory.createDataset( TDB_DIR + "/trivial" );
		Model model = ds.getDefaultModel();
		ds.begin(ReadWrite.READ);

		Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
		InfModel infmodel = ModelFactory.createInfModel(reasoner, model );

		// find all the causal links in the KB
		String sparqlQuery = "select ?disorder ?manifestation where {" + ( " ?disorder <" + RESOURCE_BASE + "#causes>" + " ?manifestation . }" );

		// logger.debug( "query: \n" + sparqlQuery + "\n" );

		// execute the query
		Query query = QueryFactory.create(sparqlQuery);
		QueryExecution qexec = QueryExecutionFactory.create(query, infmodel) ;

		// get all the resources on the LHS (the disorders)
		List<String> disorders = new ArrayList<String>();

		// get all the resources on the RHS (the manifestations)
		List<String> manifestations = new ArrayList<String>();

		Set<Link> links = new HashSet<Link>();

		try
		{
		    ResultSet resultSet = qexec.execSelect() ;
		    for ( ; resultSet.hasNext() ; )
		    {
		    	QuerySolution soln = resultSet.nextSolution() ;
		    	Resource d = soln.getResource( "disorder" );
		    	Resource m = soln.getResource( "manifestation") ;
		    	String disorder = d.toString();
		    	String manifestation = m.toString();

		    	logger.debug( disorder + " causes " + manifestation );

		    	if( !disorders.contains( disorder ) )
		    	{
		    		disorders.add( disorder );
		    	}

		    	if( !manifestations.contains( manifestation ) )
		    	{
		    		manifestations.add( manifestation );
		    	}

		    	Link link = new Link( disorder, manifestation );
		    	links.add( link );
		    }
		}
		finally
		{
			qexec.close();
		}

		logger.debug( "Links: " + links );

		infmodel.close();

		ds.close();

		File dotFile = new File( "./trivial.dot" );
		if( dotFile.exists() )
		{
			dotFile.delete();
		}

		try( FileWriter dotFileWriter = new FileWriter( dotFile ) )
		{

			dotFileWriter.write( "digraph \"trivial\" {\n" );

			for( String disorder: disorders )
			{
				logger.debug( "adding DOT vertex for disorder: " + disorder );
				String disorderId = StringUtils.substringAfter(disorder, "#");
				dotFileWriter.write( disorderId + " [id=\"" + disorderId + "\",label=\"" + disorderId + "\"]"+"\n" );
				dotFileWriter.flush();
			}

			for( String manifestation : manifestations )
			{
				logger.debug( "adding DOT vertext for manifestation: " + manifestation );
				String manifestationId = StringUtils.substringAfter(manifestation, "#");
				dotFileWriter.write( manifestationId + " [id=\"" + manifestationId + "\",label=\"" + manifestationId + "\"]"+"\n" );
				dotFileWriter.flush();

			}

			for( Link link : links )
			{
				dotFileWriter.write( StringUtils.substringAfter(link.getLeft(), "#" ) + " -> " +
									 StringUtils.substringAfter(link.getRight(), "#" ) + "\n");
			}

			dotFileWriter.write( "}" );

			dotFileWriter.flush();

		}
		catch( IOException e )
		{
			e.printStackTrace();
		}

		// create a DOT file with vertices for all disorders and manifestations
		// and edges pointing from the disorders to the manifestations

		// invoke a graphviewer on the dot file we just created
		// kgraphviewer, etc.
		ProcessBuilder pb = new ProcessBuilder();
		pb.command( "kgraphviewer", "./trivial.dot");
		Process kgraphProcess = pb.start();

		kgraphProcess.waitFor();

		logger.debug( "done: " + MethodHandles.lookup().lookupClass() );

	}

	static class Link extends Pair<String,String>
	{

		private static final long serialVersionUID = 1L;
		private String left;
		private String right;

		public Link( final String left, final String right )
		{
			this.left = left;
			this.right = right;
		}

		@Override
		public String getLeft()
		{
			return this.left;
		}

		@Override
		public String getRight()
		{
			return this.right;
		}

		@Override
		public String setValue(String value)
		{
			this.right = value;
			return value;
		}
	}
}


text:
/*
 * This node is used for high speed packet geneneration.  It queues
 * all data recieved on it's 'input' hook and when told to start via
 * a control message it sends the packets out it's 'output' hook.  In
 * this way this node can be preloaded with a packet stream which is
 * continuously sent.
 *
 * Currently it just copies the mbufs as required.  It could do various
 * tricks to try and avoid this.  Probably the best performance would
 * be achieved by modifying the appropriate drivers to be told to
 * self-re-enqueue packets (e.g. the if_bge driver could reuse the same
 * transmit descriptors) under control of this node; perhaps via some
 * flag in the mbuf or some such.  The node would peak at an appropriate
 * ifnet flag to see if such support is available for the connected
 * interface.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_ether.h>
#include <netgraph/ng_source.h>

#define NG_SOURCE_INTR_TICKS		1
#define NG_SOURCE_DRIVER_IFQ_MAXLEN	(4*1024)

/* Per hook info */
struct source_hookinfo {
	hook_p				hook;
};

/* Per node info */
struct privdata {
	node_p				node;
	struct source_hookinfo		input;
	struct source_hookinfo		output;
	struct ng_source_stats		stats;
	struct ifqueue			snd_queue;	/* packets to send */
	struct ifnet			*output_ifp;
	struct callout_handle		intr_ch;
	u_int64_t			packets;	/* packets to send */
	u_int32_t			queueOctets;
};
typedef struct privdata *sc_p;

/* Node flags */
#define NG_SOURCE_ACTIVE	(NGF_TYPE1)

/* XXX */
#if 1
#undef KASSERT
#define KASSERT(expr,msg) do {			\
		if (!(expr)) {			\
			printf msg ;		\
			panic("Assertion");	\
		}				\
	} while(0)
#endif

/* Netgraph methods */
static ng_constructor_t	ng_source_constructor;
static ng_rcvmsg_t	ng_source_rcvmsg;
static ng_shutdown_t	ng_source_rmnode;
static ng_newhook_t	ng_source_newhook;
static ng_rcvdata_t	ng_source_rcvdata;
static ng_disconnect_t	ng_source_disconnect;

/* Other functions */
static timeout_t	ng_source_intr;
static void		ng_source_request_output_ifp (sc_p);
static void		ng_source_clr_data (sc_p);
static void		ng_source_start (sc_p);
static void		ng_source_stop (sc_p);
static int		ng_source_send (sc_p, int, int *);
static int		ng_source_store_output_ifp(sc_p sc,
			    struct ng_mesg *msg);

/* Parse type for timeval */
static const struct ng_parse_struct_field ng_source_timeval_type_fields[] =
{
	{ "tv_sec",		&ng_parse_int32_type	},
	{ "tv_usec",		&ng_parse_int32_type	},
	{ NULL }
};
const struct ng_parse_type ng_source_timeval_type = {
	&ng_parse_struct_type,
	&ng_source_timeval_type_fields
};

/* Parse type for struct ng_source_stats */
static const struct ng_parse_struct_field ng_source_stats_type_fields[]
	= NG_SOURCE_STATS_TYPE_INFO;
static const struct ng_parse_type ng_source_stats_type = {
	&ng_parse_struct_type,
	&ng_source_stats_type_fields
};

/* List of commands and how to convert arguments to/from ASCII */
static const struct ng_cmdlist ng_source_cmds[] = {
	{
	  NGM_SOURCE_COOKIE,
	  NGM_SOURCE_GET_STATS,
	  "getstats",
	  NULL,
	  &ng_source_stats_type
	},
	{
	  NGM_SOURCE_COOKIE,
	  NGM_SOURCE_CLR_STATS,
	  "clrstats",
	  NULL,
	  NULL
	},
	{
	  NGM_SOURCE_COOKIE,
	  NGM_SOURCE_GETCLR_STATS,
	  "getclrstats",
	  NULL,
	  &ng_source_stats_type
	},
	{
	  NGM_SOURCE_COOKIE,
	  NGM_SOURCE_START,
	  "start",
	  &ng_parse_uint64_type,
	  NULL
	},
	{
	  NGM_SOURCE_COOKIE,
	  NGM_SOURCE_STOP,
	  "stop",
	  NULL,
	  NULL
	},
	{
	  NGM_SOURCE_COOKIE,
	  NGM_SOURCE_CLR_DATA,
	  "clrdata",
	  NULL,
	  NULL
	},
	{ 0 }
};

/* Netgraph type descriptor */
static struct ng_type ng_source_typestruct = {
	NG_VERSION,
	NG_SOURCE_NODE_TYPE,
	NULL,					/* module event handler */
	ng_source_constructor,
	ng_source_rcvmsg,
	ng_source_rmnode,
	ng_source_newhook,
	NULL,					/* findhook */
	NULL,
	ng_source_rcvdata,			/* rcvdata */
	ng_source_disconnect,
	ng_source_cmds
};
NETGRAPH_INIT(source, &ng_source_typestruct);

/*
 * Node constructor
 */
static int
ng_source_constructor(node_p node)
{
	sc_p sc;

	MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_NOWAIT);
	if (sc == NULL)
		return (ENOMEM);
	bzero(sc, sizeof(*sc));

	NG_NODE_SET_PRIVATE(node, sc);
	sc->node = node;
	sc->snd_queue.ifq_maxlen = 2048;	/* XXX not checked */
	callout_handle_init(&sc->intr_ch);   /* XXX fix.. will
						cause problems. */
	return (0);
}

/*
 * Add a hook
 */
static int
ng_source_newhook(node_p node, hook_p hook, const char *name)
{
	sc_p sc;

	sc = NG_NODE_PRIVATE(node);
	KASSERT(sc != NULL, ("%s: null node private", __FUNCTION__));
	if (strcmp(name, NG_SOURCE_HOOK_INPUT) == 0) {
		sc->input.hook = hook;
		NG_HOOK_SET_PRIVATE(hook, &sc->input);
	} else if (strcmp(name, NG_SOURCE_HOOK_OUTPUT) == 0) {
		sc->output.hook = hook;
		NG_HOOK_SET_PRIVATE(hook, &sc->output);
		sc->output_ifp = 0;
		bzero(&sc->stats, sizeof(sc->stats));
	} else
		return (EINVAL);
	return (0);
}

/*
 * Receive a control message
 */
static int
ng_source_rcvmsg(node_p node, item_p item, hook_p lasthook)
{
	sc_p sc;
	struct ng_mesg *resp = NULL;
	int error = 0;
	struct ng_mesg *msg;

	sc = NG_NODE_PRIVATE(node);
	NGI_GET_MSG(item, msg);
	KASSERT(sc != NULL, ("%s: null node private", __FUNCTION__));
	switch (msg->header.typecookie) {
	case NGM_SOURCE_COOKIE:
		if (msg->header.flags & NGF_RESP) {
			error = EINVAL;
			break;
		}
		switch (msg->header.cmd) {
		case NGM_SOURCE_GET_STATS:
		case NGM_SOURCE_CLR_STATS:
		case NGM_SOURCE_GETCLR_STATS:
                    {
			struct ng_source_stats *stats;

                        if (msg->header.cmd != NGM_SOURCE_CLR_STATS) {
                                NG_MKRESPONSE(resp, msg,
                                    sizeof(*stats), M_NOWAIT);
				if (resp == NULL) {
					error = ENOMEM;
					goto done;
				}
				sc->stats.queueOctets = sc->queueOctets;
				sc->stats.queueFrames = sc->snd_queue.ifq_len;
				if ((sc->node->nd_flags & NG_SOURCE_ACTIVE)
				    && !timevalisset(&sc->stats.endTime)) {
					getmicrotime(&sc->stats.elapsedTime);
					timevalsub(&sc->stats.elapsedTime,
					    &sc->stats.startTime);
				}
				stats = (struct ng_source_stats *)resp->data;
				bcopy(&sc->stats, stats, sizeof(* stats));
                        }
                        if (msg->header.cmd != NGM_SOURCE_GET_STATS)
				bzero(&sc->stats, sizeof(sc->stats));
		    }
		    break;
		case NGM_SOURCE_START:
		    {
			u_int64_t packets = *(u_int64_t *)msg->data;
			if (sc->output.hook == NULL) {
				printf("%s: start on node with no output hook\n"
				    , __FUNCTION__);
				error = EINVAL;
				break;
			}
			/* TODO validation of packets */
			sc->packets = packets;
			ng_source_start(sc);
		    }
		    break;
		case NGM_SOURCE_STOP:
			ng_source_stop(sc);
			break;
		case NGM_SOURCE_CLR_DATA:
			ng_source_clr_data(sc);
			break;
		default:
			error = EINVAL;
			break;
		}
		break;
	case NGM_ETHER_COOKIE:
		if (!(msg->header.flags & NGF_RESP)) {
			error = EINVAL;
			break;
		}
		switch (msg->header.cmd) {
		case NGM_ETHER_GET_IFINDEX:
			if (ng_source_store_output_ifp(sc, msg) == 0) {
				ng_source_set_autosrc(sc, 0);
				sc->node->nd_flags |= NG_SOURCE_ACTIVE;
				timevalclear(&sc->stats.elapsedTime);
				timevalclear(&sc->stats.endTime);
				getmicrotime(&sc->stats.startTime);
				sc->intr_ch = timeout(ng_source_intr, sc, 0);
			}
			break;
		default:
			error = EINVAL;
		}
		break;
	default:
		error = EINVAL;
		break;
	}

done:
	/* Take care of synchronous response, if any */
	NG_RESPOND_MSG(error, node, item, resp);
	/* Free the message and return */
	NG_FREE_MSG(msg);
	return (error);
}

/*
 * Receive data on a hook
 *
 * If data comes in the input hook, enqueue it on the send queue.
 * If data comes in the output hook, discard it.
 */
static int
ng_source_rcvdata(hook_p hook, item_p item)
{
	sc_p sc;
	struct source_hookinfo *hinfo;
	int error = 0;
	struct mbuf *m;

	sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
	NGI_GET_M(item, m);
	NG_FREE_ITEM(item);
	hinfo = NG_HOOK_PRIVATE(hook);
	KASSERT(sc != NULL, ("%s: null node private", __FUNCTION__));
	KASSERT(hinfo != NULL, ("%s: null hook info", __FUNCTION__));

	/* Which hook? */
	if (hinfo == &sc->output) {
		/* discard */
		NG_FREE_M(m);
		return (error);
	}
	KASSERT(hinfo == &sc->input, ("%s: no hook!", __FUNCTION__));

	if ((m->m_flags & M_PKTHDR) == 0) {
		printf("%s: mbuf without PKTHDR\n", __FUNCTION__);
		NG_FREE_M(m);
		return (EINVAL);
	}

	/* enque packet */
	/* XXX should we check IF_QFULL() ? */
	IF_ENQUEUE(&sc->snd_queue, m);
	sc->queueOctets += m->m_pkthdr.len;

	return (0);
}

/*
 * Shutdown processing
 */
static int
ng_source_rmnode(node_p node)
{
	sc_p sc;

	sc = NG_NODE_PRIVATE(node);
	KASSERT(sc != NULL, ("%s: null node private", __FUNCTION__));
	node->nd_flags |= NG_INVALID;
	ng_source_stop(sc);
	ng_source_clr_data(sc);
	NG_NODE_SET_PRIVATE(node, NULL);
	NG_NODE_UNREF(node);
	FREE(sc, M_NETGRAPH);
	return (0);
}

/*
 * Hook disconnection
 */
static int
ng_source_disconnect(hook_p hook)
{
	struct source_hookinfo *hinfo;
	sc_p sc;

	hinfo = NG_HOOK_PRIVATE(hook);
	sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
	KASSERT(sc != NULL, ("%s: null node private", __FUNCTION__));
	hinfo->hook = NULL;
	if (NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0 || hinfo == &sc->output)
		ng_rmnode_self(NG_HOOK_NODE(hook));
	return (0);
}

/*
 *
 * Ask out neighbour on the output hook side to send us it's interface
 * information.
 */
static void
ng_source_request_output_ifp(sc_p sc)
{
	struct ng_mesg *msg;
	int error = 0;

	sc->output_ifp = NULL;

	/* Ask the attached node for the connected interface's index */
	NG_MKMESSAGE(msg, NGM_ETHER_COOKIE, NGM_ETHER_GET_IFINDEX, 0, M_NOWAIT);
	if (msg == NULL)
		return (ENOBUFS);

	NG_SEND_MSG_HOOK(error, sc->node, msg, sc->output.hook, NULL);
	return (error);
}

/*
 * Set sc->output_ifp to point to the the struct ifnet of the interface
 * reached via our output hook.
 */
static int
ng_source_store_output_ifp(sc_p sc, struct ng_mesg *msg)
{
	struct ifnet *ifp;
	u_int32_t if_index;
	int s;

	if (msg->header.arglen < sizeof(u_int32_t))
		return (EINVAL);

	if_index = *(u_int32_t *)msg->data;
	/* Could use ifindex2ifnet[if_index] except that we have no
	 * way of verifying if_index is valid since if_indexlim is
	 * local to if_attach()
	 */
	TAILQ_FOREACH(ifp, &ifnet, if_link) {
		if (ifp->if_index == if_index)
			break;
	}

	if (ifp == NULL) {
		printf("%s: can't find interface %d\n", __FUNCTION__, if_index);
		return (EINVAL);
	}
	sc->output_ifp = ifp;

#if 1
	/* XXX mucking with a drivers ifqueue size is ugly but we need it
	 * to queue a lot of packets to get close to line rate on a gigabit
	 * interface with small packets.
	 * XXX we should restore the original value at stop or disconnect
	 */
	s = splimp();		/* XXX is this required? */
	if (ifp->if_snd.ifq_maxlen < NG_SOURCE_DRIVER_IFQ_MAXLEN)
	{
		printf("ng_source: changing ifq_maxlen from %d to %d\n",
		    ifp->if_snd.ifq_maxlen, NG_SOURCE_DRIVER_IFQ_MAXLEN);
		ifp->if_snd.ifq_maxlen = NG_SOURCE_DRIVER_IFQ_MAXLEN;
	}
	splx(s);
#endif
	return (0);
}

/*
 * Set the attached ethernet node's ethernet source address override flag.
 */
static int
ng_source_set_autosrc(sc_p sc, u_int32_t flag)
{
	struct ng_mesg *msg;
	int error = 0;

	NG_MKMESSAGE(msg, NGM_ETHER_COOKIE, NGM_ETHER_SET_AUTOSRC,
			sizeof (u_int32_t), M_NOWAIT);
	if (msg == NULL)
		return(ENOBUFS);

	*(u_int32_t *)msg->data = flag;
	NG_SEND_MSG_HOOK(error, sc->node, msg, sc->output.hook, NULL);
	return (error);
}

/*
 * Clear out the data we've queued
 */
static void
ng_source_clr_data (sc_p sc)
{
	struct mbuf *m;

	for (;;) {
		IF_DEQUEUE(&sc->snd_queue, m);
		if (m == NULL)
			break;
		NG_FREE_M(m);
	}
	sc->queueOctets = 0;
}

/*
 * Start sending queued data out the output hook
 */
static void
ng_source_start (sc_p sc)
{
	KASSERT(sc->output.hook != NULL,
			("%s: output hook unconnected", __FUNCTION__));
	if (((sc->node->nd_flags & NG_SOURCE_ACTIVE) == 0) &&
	    (sc->output_ifp == NULL))
		ng_source_request_output_ifp(sc);
}

/*
 * Stop sending queued data out the output hook
 */
static void
ng_source_stop (sc_p sc)
{
	if (sc->node->nd_flags & NG_SOURCE_ACTIVE) {
		untimeout(ng_source_intr, sc, sc->intr_ch);
		sc->node->nd_flags &= ~NG_SOURCE_ACTIVE;
		getmicrotime(&sc->stats.endTime);
		sc->stats.elapsedTime = sc->stats.endTime;
		timevalsub(&sc->stats.elapsedTime, &sc->stats.startTime);
		/* XXX should set this to the initial value instead */
		ng_source_set_autosrc(sc, 1);
	}
}

/*
 * While active called every NG_SOURCE_INTR_TICKS ticks.
 * Sends as many packets as the interface connected to our
 * output hook is able to enqueue.
 */
static void
ng_source_intr (void *arg)
{
	sc_p sc = (sc_p) arg;
	struct ifqueue *ifq;
	int packets;

	KASSERT(sc != NULL, ("%s: null node private", __FUNCTION__));

	callout_handle_init(&sc->intr_ch);
	if (sc->packets == 0 || sc->output.hook == NULL
	    || (sc->node->nd_flags & NG_SOURCE_ACTIVE) == 0) {
		ng_source_stop(sc);
		return;
	}

	ifq = &sc->output_ifp->if_snd;
	packets = ifq->ifq_maxlen - ifq->ifq_len;
	ng_source_send(sc, packets, NULL);
	if (sc->packets == 0) {
		int s = splnet();
		ng_source_stop(sc);
		splx(s);
	} else
		sc->intr_ch = timeout(ng_source_intr, sc, NG_SOURCE_INTR_TICKS);
}

/*
 * Send packets out our output hook
 */
static int
ng_source_send (sc_p sc, int tosend, int *sent_p)
{
	struct ifqueue tmp_queue;
	struct mbuf *m, *m2;
	int sent = 0;
	int error = 0;
	int s, s2;

	KASSERT(sc != NULL, ("%s: null node private", __FUNCTION__));
	KASSERT(tosend >= 0, ("%s: negative tosend param", __FUNCTION__));
	KASSERT(sc->node->nd_flags & NG_SOURCE_ACTIVE,
			("%s: inactive node", __FUNCTION__));

	if ((u_int64_t)tosend > sc->packets)
		tosend = sc->packets;

	/* Copy the required number of packets to a temporary queue */
	bzero (&tmp_queue, sizeof (tmp_queue));
	for (sent = 0; error == 0 && sent < tosend; ++sent) {
		s = splnet();
		IF_DEQUEUE(&sc->snd_queue, m);
		splx(s);
		if (m == NULL)
			break;

		/* duplicate the packet */
		m2 = m_copypacket(m, M_NOWAIT);
		if (m2 == NULL) {
			s = splnet();
			IF_PREPEND(&sc->snd_queue, m);
			splx(s);
			error = ENOBUFS;
			break;
		}

		/* re-enqueue the original packet for us */
		s = splnet();
		IF_ENQUEUE(&sc->snd_queue, m);
		splx(s);

		/* queue the copy for sending at smplimp */
		IF_ENQUEUE(&tmp_queue, m2);
	}

	sent = 0;
	s = splimp();
	for (;;) {
		IF_DEQUEUE(&tmp_queue, m2);
		if (m2 == NULL)
			break;
		if (error == 0) {
			++sent;
			sc->stats.outFrames++;
			sc->stats.outOctets += m2->m_pkthdr.len;
			s2 = splnet();
			NG_SEND_DATA_ONLY(error, sc->output.hook, m2);
			splx(s2);
		} else {
			NG_FREE_M(m2);
		}
	}
	splx(s);

	sc->packets -= sent;
	if (sent_p != NULL)
		*sent_p = sent;
	return (error);
}

redpajama_set_name: RedPajamaGithub


text:
#include <gtest/gtest.h>
#include <NiceMPI/NiceMPIexception.h>

using namespace NiceMPI;

TEST(NiceMPIexceptionTests, NiceMPIexceptionConstructor) {
	const int errorCode = 3;
	const NiceMPIexception x{errorCode};
	EXPECT_EQ(errorCode,x.error);
}


text:
@interface Home1 : UIViewController

@property (nonatomic, weak) UITableView *tableView;

@end


text:
ACCEPTED

#### According to
International Plant Names Index

#### Published in
null

#### Original name
Chrysanthemum dolichophyllum Kitam

### Remarks
null


text:
My own MEAN stack app skeleton based on best practices from:

https://scotch.io/tutorials/angularjs-best-practices-directory-structure
https://github.com/DaftMonk/generator-angular-fullstack


text:
/* { dg-options "-O2 -fno-inline-functions" } */
/* { dg-do run } */
/* When there are no call-clobbered variables, we should still create
   a .GLOBAL_VAR to model the side effects of functions.  Without it,
   we were moving the call to Faref() inside the second call to
   Faset().  */
extern void abort (void);
extern void exit (int);

main ()
{
  int table, c, elt;
  int tem = Faref (table, elt);
  Faset (table, elt, c);
  Faset (table, c, tem);/* tem cannot be replaced with Faref (table, elt) */
  exit (0);
}

int j = 0;

int __attribute__ ((noinline)) Faref (table, elt)
{
  j = 1;
  return 0;
}

int __attribute__ ((noinline)) Faset (table, elt, c)
{
  if (j != 1)
    abort ();
  return 0;
}


text:
namespace tera {

extern const int64_t kLatestTimestamp;
extern const int64_t kOldestTimestamp;

struct ACL {
  int32_t owner;
  int32_t role;
  int64_t acl;
};

class ColumnFamilyDescriptor {
 public:
  // Returns name of this column family
  virtual const std::string& Name() const = 0;

  // Set/get TTL(in second) of cells of this column family.
  virtual void SetTimeToLive(int32_t ttl) = 0;
  virtual int32_t TimeToLive() const = 0;

  // Set/get maximum versions of cells of this column family.
  virtual void SetMaxVersions(int32_t max_versions) = 0;
  virtual int32_t MaxVersions() const = 0;

  // Get name of locality group which this column family belong to.
  virtual const std::string& LocalityGroup() const = 0;

  // Get internal id.
  virtual int32_t Id() const = 0;

  // DEVELOPING
  virtual void SetType(const std::string& type) = 0;
  virtual const std::string& Type() const = 0;
  virtual void SetMinVersions(int32_t min_versions) = 0;
  virtual int32_t MinVersions() const = 0;
  virtual void SetDiskQuota(int64_t quota) = 0;
  virtual int64_t DiskQuota() const = 0;
  virtual void SetAcl(ACL acl) = 0;
  virtual ACL Acl() const = 0;
  virtual void EnableGlobalTransaction() = 0;
  virtual void DisableGlobalTransaction() = 0;
  virtual bool GlobalTransaction() const = 0;
  virtual void EnableNotify() = 0;
  virtual void DisableNotify() = 0;
  virtual bool IsNotifyEnabled() const = 0;

  ColumnFamilyDescriptor() {}
  virtual ~ColumnFamilyDescriptor() {}

 private:
  ColumnFamilyDescriptor(const ColumnFamilyDescriptor&);
  void operator=(const ColumnFamilyDescriptor&);
};

// Describes compress type for a locality group
enum CompressType {
  kNoneCompress = 1,
  kSnappyCompress = 2,
};

// Describes store type for a locality group
enum StoreType {
  kInDisk = 0,
  kInFlash = 1,
  kInMemory = 2,
};

class LocalityGroupDescriptor {
 public:
  // Returns name of this locality group
  virtual const std::string& Name() const = 0;

  // Set/get store medium.
  virtual void SetStore(StoreType type) = 0;
  virtual StoreType Store() const = 0;

  // Set/get block size in KB.
  virtual void SetBlockSize(int block_size) = 0;
  virtual int BlockSize() const = 0;

  // Set/get sst size in MB.
  virtual int32_t SstSize() const = 0;
  virtual void SetSstSize(int32_t sst_size) = 0;

  // Set/get compress type.
  virtual void SetCompress(CompressType type) = 0;
  virtual CompressType Compress() const = 0;

  // Set/get if use bloomfilter.
  virtual void SetUseBloomfilter(bool use_bloomfilter) = 0;
  virtual bool UseBloomfilter() const = 0;

  // Memtable on leveldb (disable/enable)
  virtual bool UseMemtableOnLeveldb() const = 0;
  virtual void SetUseMemtableOnLeveldb(bool use_mem_ldb) = 0;

  // Memtable-LDB write buffer size
  virtual int32_t MemtableLdbWriteBufferSize() const = 0;
  virtual void SetMemtableLdbWriteBufferSize(int32_t buffer_size) = 0;

  // Memtable-LDB block size
  virtual int32_t MemtableLdbBlockSize() const = 0;
  virtual void SetMemtableLdbBlockSize(int32_t block_size) = 0;

  // Get internal id.
  virtual int32_t Id() const = 0;

  LocalityGroupDescriptor() {}
  virtual ~LocalityGroupDescriptor() {}

 private:
  LocalityGroupDescriptor(const LocalityGroupDescriptor&);
  void operator=(const LocalityGroupDescriptor&);
};

// Describes internal raw key type
enum RawKeyType {
  kReadable = 0,
  kBinary = 1,
  kTTLKv = 2,
  kGeneralKv = 3,
};

class TableDescImpl;
class TableDescriptor {
 public:
  // Only {[a-z],[A-Z],[0-9],'_','-'} are allowed in table name.
  // Length of a table name should be less than 256.
  TableDescriptor(const std::string& name = "");
  ~TableDescriptor();

  // Set/Get table name
  void SetTableName(const std::string& name);
  std::string TableName() const;

  // Add a locality group named "lg_name".
  // Only {[a-z],[A-Z],[0-9],'_','-'} are allowed in locality group name.
  // Length of a locality group name should be less than 256.
  LocalityGroupDescriptor* AddLocalityGroup(const std::string& lg_name);
  // Remove a locality group by name. Operation returns false if there is a
  // column family in this locality group.
  bool RemoveLocalityGroup(const std::string& lg_name);
  // Get locality group handle by id.
  const LocalityGroupDescriptor* LocalityGroup(int32_t id) const;
  // Get locality group handle by name.
  const LocalityGroupDescriptor* LocalityGroup(const std::string& lg_name) const;
  // Return locality group number in this table.
  int32_t LocalityGroupNum() const;

  // Add a column family named "cf_name" into the locality group named
  // "lg_name".
  // Only {[a-z],[A-Z],[0-9],'_','-'} are allowed in column family name.
  // Length of a column family name should be less than 256.
  ColumnFamilyDescriptor* AddColumnFamily(const std::string& cf_name,
                                          const std::string& lg_name = "lg0");
  // Remove a column family by name.
  void RemoveColumnFamily(const std::string& cf_name);
  // Get column family handle by id.
  const ColumnFamilyDescriptor* ColumnFamily(int32_t id) const;
  // Get column family handle by name.
  const ColumnFamilyDescriptor* ColumnFamily(const std::string& cf_name) const;
  // Return column family number in this table.
  int32_t ColumnFamilyNum() const;

  // Set/get raw key type.
  void SetRawKey(RawKeyType type);
  RawKeyType RawKey() const;

  // Set/get the split size in MB.
  void SetSplitSize(int64_t size);
  int64_t SplitSize() const;

  // Set/get the merge size in MB.
  // mergesize should be less than splitsize / 3.
  void SetMergeSize(int64_t size);
  int64_t MergeSize() const;

  // Enable/disable write-ahead-log on this table.
  void DisableWal();
  bool IsWalDisabled() const;

  // Enable/disable transaction on this table.
  void EnableTxn();
  bool IsTxnEnabled() const;

  // Set/get admin of this table.
  void SetAdmin(const std::string& name);
  std::string Admin() const;

  // Set/get admin group of this table.
  void SetAdminGroup(const std::string& name);
  std::string AdminGroup() const;

  // DEVELOPING
  int32_t AddSnapshot(uint64_t snapshot);
  uint64_t Snapshot(int32_t id) const;
  int32_t SnapshotNum() const;

  // Enable hash read/write on this table.
  void EnableHash();
  bool IsHashEnabled() const;

  uint32_t BloomFilterBitsPerKey() const;
  void SetBloomFilterBitsPerKey(uint32_t val);

  // DEPRECATED
  LocalityGroupDescriptor* DefaultLocalityGroup();
  ColumnFamilyDescriptor* DefaultColumnFamily();

 private:
  TableDescriptor(const TableDescriptor&);
  void operator=(const TableDescriptor&);
  TableDescImpl* impl_;
};

}  // namespace tera
#pragma GCC visibility pop

#endif  // TERA_TABLE_DESCRIPTOR_


text:
@interface ZNBSetNameController ()
@property (weak, nonatomic) IBOutlet UITextField *textF;
@property (weak, nonatomic) IBOutlet UILabel *indicateLabel;

@end

@implementation ZNBSetNameController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置微信昵称";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(saveName)];
    if (self.vcType == ZNBSetNameControllerTypeSetName) {
        self.textF.placeholder = @"填写昵称";
        self.indicateLabel.text = @"昵称的长度在16个字以内";
    }else {
        self.textF.placeholder = @"填写来源";
        self.indicateLabel.text = @"来源的长度在8个字以内";
    }
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.textF becomeFirstResponder];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear: animated];
    [MobClick beginLogPageView:@"设置名字界面"];
}

- (void)viewWillDisappear:(BOOL)animated {

    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"设置名字界面"];

}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.textF resignFirstResponder];
}

- (void)saveName {
    if (self.nameBlock) {
        self.nameBlock(self.textF.text);
    }

    [self.navigationController popViewControllerAnimated:YES];
}

- (void)dealloc {
    NSLog(@"dealloc");
}
@end


text:
/**
 * Server-side methods related to the system.
 */
Meteor.methods({
    /**
     * Get the environment type from the server.
     * @returns {{env: *}} The system environment type (development or production)
     */
    getEnvironment: function() {
        return process.env.NODE_ENV;
    }
})


text:
#!/usr/bin/env node

'use strict';

const shell = require('shelljs');
const exec = require('child_process').exec;
const path = require('path');
const fs   = require('fs');
const animateProgress = require('./helpers/progress');
const addCheckMark = require('./helpers/checkmark');
const readline = require('readline');

process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdout.write('\n');
let interval;
let clearRepo = true;

cleanRepo(() => {
  process.stdout.write('\nInstalling dependencies... (This might take a while)');
  setTimeout(function () {
    readline.cursorTo(process.stdout, 0);
    interval = animateProgress('Installing dependencies');
  }, 500);

  installDeps();
});

/**
 * Deletes the .git folder in dir only if cloned from our repo
 */
function cleanRepo(callback) {
  fs.readFile('.git/config', 'utf8', (err, data) => {
    if(!err) {
      let isClonedRepo = typeof data === 'string'
        && (data.match(/url\s*=/g) || []).length === 1
        && /react-boilerplate\/react-boilerplate\.git/.test(data);
      if(isClonedRepo) {
        process.stdout.write('\nDo you want to clear old repository? [Y/n] ');
        process.stdin.resume();
        process.stdin.on('data', (data) => {
          let val = data.toString().trim();
          if(val === 'y' || val === 'Y' || val === '') {
            process.stdout.write('Removing old repository');
            shell.rm('-rf', '.git/');
            addCheckMark(callback);
          } else {
            dontClearRepo('', callback);
          }
        });
      } else {
        dontClearRepo('\n', callback);
      }
    } else {
      callback();
    }
  });
}

/**
 * Function which indicates that we are not cleaning git repo
 */
function dontClearRepo(nl, callback) {
  clearRepo = false;
  process.stdout.write(nl + 'Leaving your repository untouched');
  addCheckMark(callback);
}

/**
 * Initializes git again
 */
function initGit(callback) {
  exec('git init && git add . && git commit -m "Initial commit"', addCheckMark.bind(null, callback));
}

/**
 * Deletes a file in the current directory
 */
function deleteFileInCurrentDir(file, callback) {
  fs.unlink(path.join(__dirname, file), callback);
}

/**
 * Installs dependencies
 */
function installDeps() {
  exec('node --version', function (err, stdout, stderr) {
    const nodeVersion = stdout && parseFloat(stdout.substring(1));
    if (nodeVersion < 5 || err) {
      installDepsCallback(err || 'Unsupported node.js version, make sure you have the latest version installed.');
    } else {
      exec('yarn --version', function (err, stdout, stderr) {
        if (parseFloat(stdout) < 0.15 || err || process.env.USE_YARN === 'false') {
          exec('npm install', addCheckMark.bind(null, installDepsCallback));
        } else {
          exec('yarn install', addCheckMark.bind(null, installDepsCallback));
        }
      });
    }
  });
}

/**
 * Callback function after installing dependencies
 */
function installDepsCallback(error) {
  clearInterval(interval);
  process.stdout.write('\n\n');
  if (error) {
    process.stderr.write(error);
    process.stdout.write('\n');
    process.exit(1);
  }

  deleteFileInCurrentDir('setup.js', function () {
    if(clearRepo) {
      interval = animateProgress('Initialising new repository');
      process.stdout.write('Initialising new repository');
      initGit(function () {
        clearInterval(interval);
      });
    }
    process.stdout.write('\nDone!');
    process.exit(0);
  });
}


text:
#pragma once
#include <aws/elasticloadbalancingv2/ElasticLoadBalancingv2_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSStreamFwd.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/DateTime.h>
#include <aws/elasticloadbalancingv2/model/LoadBalancerSchemeEnum.h>
#include <aws/elasticloadbalancingv2/model/LoadBalancerState.h>
#include <aws/elasticloadbalancingv2/model/LoadBalancerTypeEnum.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/elasticloadbalancingv2/model/IpAddressType.h>
#include <aws/elasticloadbalancingv2/model/AvailabilityZone.h>
#include <utility>

namespace Aws
{
namespace Utils
{
namespace Xml
{
  class XmlNode;
} // namespace Xml
} // namespace Utils
namespace ElasticLoadBalancingv2
{
namespace Model
{

  /**
   *
Information about a load balancer.

See Also:
   AWS
   * API Reference

   */
  class AWS_ELASTICLOADBALANCINGV2_API LoadBalancer
  {
  public:
    LoadBalancer();
    LoadBalancer(const Aws::Utils::Xml::XmlNode& xmlNode);
    LoadBalancer& operator=(const Aws::Utils::Xml::XmlNode& xmlNode);

    void OutputToStream(Aws::OStream& ostream, const char* location, unsigned index, const char* locationValue) const;
    void OutputToStream(Aws::OStream& oStream, const char* location) const;

    /**
     *
The Amazon Resource Name (ARN) of the load balancer.

     */
    inline const Aws::String& GetLoadBalancerArn() const{ return m_loadBalancerArn; }

    /**
     *
The Amazon Resource Name (ARN) of the load balancer.

     */
    inline void SetLoadBalancerArn(const Aws::String& value) { m_loadBalancerArnHasBeenSet = true; m_loadBalancerArn = value; }

    /**
     *
The Amazon Resource Name (ARN) of the load balancer.

     */
    inline void SetLoadBalancerArn(Aws::String&& value) { m_loadBalancerArnHasBeenSet = true; m_loadBalancerArn = std::move(value); }

    /**
     *
The Amazon Resource Name (ARN) of the load balancer.

     */
    inline void SetLoadBalancerArn(const char* value) { m_loadBalancerArnHasBeenSet = true; m_loadBalancerArn.assign(value); }

    /**
     *
The Amazon Resource Name (ARN) of the load balancer.

     */
    inline LoadBalancer& WithLoadBalancerArn(const Aws::String& value) { SetLoadBalancerArn(value); return *this;}

    /**
     *
The Amazon Resource Name (ARN) of the load balancer.

     */
    inline LoadBalancer& WithLoadBalancerArn(Aws::String&& value) { SetLoadBalancerArn(std::move(value)); return *this;}

    /**
     *
The Amazon Resource Name (ARN) of the load balancer.

     */
    inline LoadBalancer& WithLoadBalancerArn(const char* value) { SetLoadBalancerArn(value); return *this;}

    /**
     *
The public DNS name of the load balancer.

     */
    inline const Aws::String& GetDNSName() const{ return m_dNSName; }

    /**
     *
The public DNS name of the load balancer.

     */
    inline void SetDNSName(const Aws::String& value) { m_dNSNameHasBeenSet = true; m_dNSName = value; }

    /**
     *
The public DNS name of the load balancer.

     */
    inline void SetDNSName(Aws::String&& value) { m_dNSNameHasBeenSet = true; m_dNSName = std::move(value); }

    /**
     *
The public DNS name of the load balancer.

     */
    inline void SetDNSName(const char* value) { m_dNSNameHasBeenSet = true; m_dNSName.assign(value); }

    /**
     *
The public DNS name of the load balancer.

     */
    inline LoadBalancer& WithDNSName(const Aws::String& value) { SetDNSName(value); return *this;}

    /**
     *
The public DNS name of the load balancer.

     */
    inline LoadBalancer& WithDNSName(Aws::String&& value) { SetDNSName(std::move(value)); return *this;}

    /**
     *
The public DNS name of the load balancer.

     */
    inline LoadBalancer& WithDNSName(const char* value) { SetDNSName(value); return *this;}

    /**
     *
The ID of the Amazon Route 53 hosted zone associated with the load
     * balancer.

     */
    inline const Aws::String& GetCanonicalHostedZoneId() const{ return m_canonicalHostedZoneId; }

    /**
     *
The ID of the Amazon Route 53 hosted zone associated with the load
     * balancer.

     */
    inline void SetCanonicalHostedZoneId(const Aws::String& value) { m_canonicalHostedZoneIdHasBeenSet = true; m_canonicalHostedZoneId = value; }

    /**
     *
The ID of the Amazon Route 53 hosted zone associated with the load
     * balancer.

     */
    inline void SetCanonicalHostedZoneId(Aws::String&& value) { m_canonicalHostedZoneIdHasBeenSet = true; m_canonicalHostedZoneId = std::move(value); }

    /**
     *
The ID of the Amazon Route 53 hosted zone associated with the load
     * balancer.

     */
    inline void SetCanonicalHostedZoneId(const char* value) { m_canonicalHostedZoneIdHasBeenSet = true; m_canonicalHostedZoneId.assign(value); }

    /**
     *
The ID of the Amazon Route 53 hosted zone associated with the load
     * balancer.

     */
    inline LoadBalancer& WithCanonicalHostedZoneId(const Aws::String& value) { SetCanonicalHostedZoneId(value); return *this;}

    /**
     *
The ID of the Amazon Route 53 hosted zone associated with the load
     * balancer.

     */
    inline LoadBalancer& WithCanonicalHostedZoneId(Aws::String&& value) { SetCanonicalHostedZoneId(std::move(value)); return *this;}

    /**
     *
The ID of the Amazon Route 53 hosted zone associated with the load
     * balancer.

     */
    inline LoadBalancer& WithCanonicalHostedZoneId(const char* value) { SetCanonicalHostedZoneId(value); return *this;}

    /**
     *
The date and time the load balancer was created.

     */
    inline const Aws::Utils::DateTime& GetCreatedTime() const{ return m_createdTime; }

    /**
     *
The date and time the load balancer was created.

     */
    inline void SetCreatedTime(const Aws::Utils::DateTime& value) { m_createdTimeHasBeenSet = true; m_createdTime = value; }

    /**
     *
The date and time the load balancer was created.

     */
    inline void SetCreatedTime(Aws::Utils::DateTime&& value) { m_createdTimeHasBeenSet = true; m_createdTime = std::move(value); }

    /**
     *
The date and time the load balancer was created.

     */
    inline LoadBalancer& WithCreatedTime(const Aws::Utils::DateTime& value) { SetCreatedTime(value); return *this;}

    /**
     *
The date and time the load balancer was created.

     */
    inline LoadBalancer& WithCreatedTime(Aws::Utils::DateTime&& value) { SetCreatedTime(std::move(value)); return *this;}

    /**
     *
The name of the load balancer.

     */
    inline const Aws::String& GetLoadBalancerName() const{ return m_loadBalancerName; }

    /**
     *
The name of the load balancer.

     */
    inline void SetLoadBalancerName(const Aws::String& value) { m_loadBalancerNameHasBeenSet = true; m_loadBalancerName = value; }

    /**
     *
The name of the load balancer.

     */
    inline void SetLoadBalancerName(Aws::String&& value) { m_loadBalancerNameHasBeenSet = true; m_loadBalancerName = std::move(value); }

    /**
     *
The name of the load balancer.

     */
    inline void SetLoadBalancerName(const char* value) { m_loadBalancerNameHasBeenSet = true; m_loadBalancerName.assign(value); }

    /**
     *
The name of the load balancer.

     */
    inline LoadBalancer& WithLoadBalancerName(const Aws::String& value) { SetLoadBalancerName(value); return *this;}

    /**
     *
The name of the load balancer.

     */
    inline LoadBalancer& WithLoadBalancerName(Aws::String&& value) { SetLoadBalancerName(std::move(value)); return *this;}

    /**
     *
The name of the load balancer.

     */
    inline LoadBalancer& WithLoadBalancerName(const char* value) { SetLoadBalancerName(value); return *this;}

    /**
     *
The nodes of an Internet-facing load balancer have public IP addresses. The
     * DNS name of an Internet-facing load balancer is publicly resolvable to the
     * public IP addresses of the nodes. Therefore, Internet-facing load balancers can
     * route requests from clients over the Internet.

The nodes of an internal
     * load balancer have only private IP addresses. The DNS name of an internal load
     * balancer is publicly resolvable to the private IP addresses of the nodes.
     * Therefore, internal load balancers can only route requests from clients with
     * access to the VPC for the load balancer.

     */
    inline const LoadBalancerSchemeEnum& GetScheme() const{ return m_scheme; }

    /**
     *
The nodes of an Internet-facing load balancer have public IP addresses. The
     * DNS name of an Internet-facing load balancer is publicly resolvable to the
     * public IP addresses of the nodes. Therefore, Internet-facing load balancers can
     * route requests from clients over the Internet.

The nodes of an internal
     * load balancer have only private IP addresses. The DNS name of an internal load
     * balancer is publicly resolvable to the private IP addresses of the nodes.
     * Therefore, internal load balancers can only route requests from clients with
     * access to the VPC for the load balancer.

     */
    inline void SetScheme(const LoadBalancerSchemeEnum& value) { m_schemeHasBeenSet = true; m_scheme = value; }

    /**
     *
The nodes of an Internet-facing load balancer have public IP addresses. The
     * DNS name of an Internet-facing load balancer is publicly resolvable to the
     * public IP addresses of the nodes. Therefore, Internet-facing load balancers can
     * route requests from clients over the Internet.

The nodes of an internal
     * load balancer have only private IP addresses. The DNS name of an internal load
     * balancer is publicly resolvable to the private IP addresses of the nodes.
     * Therefore, internal load balancers can only route requests from clients with
     * access to the VPC for the load balancer.

     */
    inline void SetScheme(LoadBalancerSchemeEnum&& value) { m_schemeHasBeenSet = true; m_scheme = std::move(value); }

    /**
     *
The nodes of an Internet-facing load balancer have public IP addresses. The
     * DNS name of an Internet-facing load balancer is publicly resolvable to the
     * public IP addresses of the nodes. Therefore, Internet-facing load balancers can
     * route requests from clients over the Internet.

The nodes of an internal
     * load balancer have only private IP addresses. The DNS name of an internal load
     * balancer is publicly resolvable to the private IP addresses of the nodes.
     * Therefore, internal load balancers can only route requests from clients with
     * access to the VPC for the load balancer.

     */
    inline LoadBalancer& WithScheme(const LoadBalancerSchemeEnum& value) { SetScheme(value); return *this;}

    /**
     *
The nodes of an Internet-facing load balancer have public IP addresses. The
     * DNS name of an Internet-facing load balancer is publicly resolvable to the
     * public IP addresses of the nodes. Therefore, Internet-facing load balancers can
     * route requests from clients over the Internet.

The nodes of an internal
     * load balancer have only private IP addresses. The DNS name of an internal load
     * balancer is publicly resolvable to the private IP addresses of the nodes.
     * Therefore, internal load balancers can only route requests from clients with
     * access to the VPC for the load balancer.

     */
    inline LoadBalancer& WithScheme(LoadBalancerSchemeEnum&& value) { SetScheme(std::move(value)); return *this;}

    /**
     *
The ID of the VPC for the load balancer.

     */
    inline const Aws::String& GetVpcId() const{ return m_vpcId; }

    /**
     *
The ID of the VPC for the load balancer.

     */
    inline void SetVpcId(const Aws::String& value) { m_vpcIdHasBeenSet = true; m_vpcId = value; }

    /**
     *
The ID of the VPC for the load balancer.

     */
    inline void SetVpcId(Aws::String&& value) { m_vpcIdHasBeenSet = true; m_vpcId = std::move(value); }

    /**
     *
The ID of the VPC for the load balancer.

     */
    inline void SetVpcId(const char* value) { m_vpcIdHasBeenSet = true; m_vpcId.assign(value); }

    /**
     *
The ID of the VPC for the load balancer.

     */
    inline LoadBalancer& WithVpcId(const Aws::String& value) { SetVpcId(value); return *this;}

    /**
     *
The ID of the VPC for the load balancer.

     */
    inline LoadBalancer& WithVpcId(Aws::String&& value) { SetVpcId(std::move(value)); return *this;}

    /**
     *
The ID of the VPC for the load balancer.

     */
    inline LoadBalancer& WithVpcId(const char* value) { SetVpcId(value); return *this;}

    /**
     *
The state of the load balancer.

     */
    inline const LoadBalancerState& GetState() const{ return m_state; }

    /**
     *
The state of the load balancer.

     */
    inline void SetState(const LoadBalancerState& value) { m_stateHasBeenSet = true; m_state = value; }

    /**
     *
The state of the load balancer.

     */
    inline void SetState(LoadBalancerState&& value) { m_stateHasBeenSet = true; m_state = std::move(value); }

    /**
     *
The state of the load balancer.

     */
    inline LoadBalancer& WithState(const LoadBalancerState& value) { SetState(value); return *this;}

    /**
     *
The state of the load balancer.

     */
    inline LoadBalancer& WithState(LoadBalancerState&& value) { SetState(std::move(value)); return *this;}

    /**
     *
The type of load balancer.

     */
    inline const LoadBalancerTypeEnum& GetType() const{ return m_type; }

    /**
     *
The type of load balancer.

     */
    inline void SetType(const LoadBalancerTypeEnum& value) { m_typeHasBeenSet = true; m_type = value; }

    /**
     *
The type of load balancer.

     */
    inline void SetType(LoadBalancerTypeEnum&& value) { m_typeHasBeenSet = true; m_type = std::move(value); }

    /**
     *
The type of load balancer.

     */
    inline LoadBalancer& WithType(const LoadBalancerTypeEnum& value) { SetType(value); return *this;}

    /**
     *
The type of load balancer.

     */
    inline LoadBalancer& WithType(LoadBalancerTypeEnum&& value) { SetType(std::move(value)); return *this;}

    /**
     *
The Availability Zones for the load balancer.

     */
    inline const Aws::Vector<AvailabilityZone>& GetAvailabilityZones() const{ return m_availabilityZones; }

    /**
     *
The Availability Zones for the load balancer.

     */
    inline void SetAvailabilityZones(const Aws::Vector<AvailabilityZone>& value) { m_availabilityZonesHasBeenSet = true; m_availabilityZones = value; }

    /**
     *
The Availability Zones for the load balancer.

     */
    inline void SetAvailabilityZones(Aws::Vector<AvailabilityZone>&& value) { m_availabilityZonesHasBeenSet = true; m_availabilityZones = std::move(value); }

    /**
     *
The Availability Zones for the load balancer.

     */
    inline LoadBalancer& WithAvailabilityZones(const Aws::Vector<AvailabilityZone>& value) { SetAvailabilityZones(value); return *this;}

    /**
     *
The Availability Zones for the load balancer.

     */
    inline LoadBalancer& WithAvailabilityZones(Aws::Vector<AvailabilityZone>&& value) { SetAvailabilityZones(std::move(value)); return *this;}

    /**
     *
The Availability Zones for the load balancer.

     */
    inline LoadBalancer& AddAvailabilityZones(const AvailabilityZone& value) { m_availabilityZonesHasBeenSet = true; m_availabilityZones.push_back(value); return *this; }

    /**
     *
The Availability Zones for the load balancer.

     */
    inline LoadBalancer& AddAvailabilityZones(AvailabilityZone&& value) { m_availabilityZonesHasBeenSet = true; m_availabilityZones.push_back(std::move(value)); return *this; }

    /**
     *
The IDs of the security groups for the load balancer.

     */
    inline const Aws::Vector<Aws::String>& GetSecurityGroups() const{ return m_securityGroups; }

    /**
     *
The IDs of the security groups for the load balancer.

     */
    inline void SetSecurityGroups(const Aws::Vector<Aws::String>& value) { m_securityGroupsHasBeenSet = true; m_securityGroups = value; }

    /**
     *
The IDs of the security groups for the load balancer.

     */
    inline void SetSecurityGroups(Aws::Vector<Aws::String>&& value) { m_securityGroupsHasBeenSet = true; m_securityGroups = std::move(value); }

    /**
     *
The IDs of the security groups for the load balancer.

     */
    inline LoadBalancer& WithSecurityGroups(const Aws::Vector<Aws::String>& value) { SetSecurityGroups(value); return *this;}

    /**
     *
The IDs of the security groups for the load balancer.

     */
    inline LoadBalancer& WithSecurityGroups(Aws::Vector<Aws::String>&& value) { SetSecurityGroups(std::move(value)); return *this;}

    /**
     *
The IDs of the security groups for the load balancer.

     */
    inline LoadBalancer& AddSecurityGroups(const Aws::String& value) { m_securityGroupsHasBeenSet = true; m_securityGroups.push_back(value); return *this; }

    /**
     *
The IDs of the security groups for the load balancer.

     */
    inline LoadBalancer& AddSecurityGroups(Aws::String&& value) { m_securityGroupsHasBeenSet = true; m_securityGroups.push_back(std::move(value)); return *this; }

    /**
     *
The IDs of the security groups for the load balancer.

     */
    inline LoadBalancer& AddSecurityGroups(const char* value) { m_securityGroupsHasBeenSet = true; m_securityGroups.push_back(value); return *this; }

    /**
     *
The type of IP addresses used by the subnets for your load balancer. The
     * possible values are ipv4 (for IPv4 addresses) and
     * dualstack (for IPv4 and IPv6 addresses).

     */
    inline const IpAddressType& GetIpAddressType() const{ return m_ipAddressType; }

    /**
     *
The type of IP addresses used by the subnets for your load balancer. The
     * possible values are ipv4 (for IPv4 addresses) and
     * dualstack (for IPv4 and IPv6 addresses).

     */
    inline void SetIpAddressType(const IpAddressType& value) { m_ipAddressTypeHasBeenSet = true; m_ipAddressType = value; }

    /**
     *
The type of IP addresses used by the subnets for your load balancer. The
     * possible values are ipv4 (for IPv4 addresses) and
     * dualstack (for IPv4 and IPv6 addresses).

     */
    inline void SetIpAddressType(IpAddressType&& value) { m_ipAddressTypeHasBeenSet = true; m_ipAddressType = std::move(value); }

    /**
     *
The type of IP addresses used by the subnets for your load balancer. The
     * possible values are ipv4 (for IPv4 addresses) and
     * dualstack (for IPv4 and IPv6 addresses).

     */
    inline LoadBalancer& WithIpAddressType(const IpAddressType& value) { SetIpAddressType(value); return *this;}

    /**
     *
The type of IP addresses used by the subnets for your load balancer. The
     * possible values are ipv4 (for IPv4 addresses) and
     * dualstack (for IPv4 and IPv6 addresses).

     */
    inline LoadBalancer& WithIpAddressType(IpAddressType&& value) { SetIpAddressType(std::move(value)); return *this;}

  private:
    Aws::String m_loadBalancerArn;
    bool m_loadBalancerArnHasBeenSet;
    Aws::String m_dNSName;
    bool m_dNSNameHasBeenSet;
    Aws::String m_canonicalHostedZoneId;
    bool m_canonicalHostedZoneIdHasBeenSet;
    Aws::Utils::DateTime m_createdTime;
    bool m_createdTimeHasBeenSet;
    Aws::String m_loadBalancerName;
    bool m_loadBalancerNameHasBeenSet;
    LoadBalancerSchemeEnum m_scheme;
    bool m_schemeHasBeenSet;
    Aws::String m_vpcId;
    bool m_vpcIdHasBeenSet;
    LoadBalancerState m_state;
    bool m_stateHasBeenSet;
    LoadBalancerTypeEnum m_type;
    bool m_typeHasBeenSet;
    Aws::Vector<AvailabilityZone> m_availabilityZones;
    bool m_availabilityZonesHasBeenSet;
    Aws::Vector<Aws::String> m_securityGroups;
    bool m_securityGroupsHasBeenSet;
    IpAddressType m_ipAddressType;
    bool m_ipAddressTypeHasBeenSet;
  };

} // namespace Model
} // namespace ElasticLoadBalancingv2
} // namespace Aws


text:
extern const char *jsonq(const char *s, const char *name, char *dstbuf, int dstlen);
extern long long jsonq_int(const char *s, const char *name);
extern double jsonq_real(const char *s, const char *name);
extern int jsonq_bool(const char *s, const char *name);
extern int jsonq_null(const char *s, const char *name);

extern const char *jsonqi(const char *s, int idx, char *nambuf, int namlen, char *dstbuf, int dstlen);

#endif


text:
package com.garethahealy.camel.dynamic.loadbalancer.statistics;

import com.garethahealy.camel.dynamic.loadbalancer.statistics.strategy.DeterministicCollectorStrategy;

import org.junit.Assert;
import org.junit.Test;

public class EveryXDeterministicCollectorStrategyTest {

    @Test
    public void shouldCollectIsTrueWhenXIsZero() {
        DeterministicCollectorStrategy collector = new EveryXDeterministicCollectorStrategy(0, 0);

        for (int i = 0; i < 1000; i++) {
            Assert.assertTrue(String.valueOf(i), collector.shouldCollect());
        }
    }

    @Test
    public void shouldCollectIsTrueAfterX() {
        DeterministicCollectorStrategy collector = new EveryXDeterministicCollectorStrategy(100, 1000);

        for (int i = 0; i < 1000; i++) {
            Assert.assertFalse(String.valueOf(i), collector.shouldCollect());
        }

        Assert.assertTrue(collector.shouldCollect());
    }

    @Test
    public void shouldCollectIsTrueAfterWarmup() {
        DeterministicCollectorStrategy collector = new EveryXDeterministicCollectorStrategy(1000, 100);

        for (int i = 0; i < 1000; i++) {
            Assert.assertFalse(String.valueOf(i), collector.shouldCollect());
        }

        Assert.assertTrue(collector.shouldCollect());
    }
}


text:
package service

import (
	"github.com/boivie/lovebeat/config"
	"github.com/boivie/lovebeat/model"
	"regexp"
	"strings"
)

// Instantiated from an alarm template
type alarm struct {
	servicesInAlarm []*service
	data            model.Alarm
	tmpl            alarmTemplate
}

type alarmTemplate struct {
	config   config.ConfigAlarm
	includes []*regexp.Regexp
	excludes []*regexp.Regexp
}

var VAR_RE = regexp.MustCompile("\\\\\\$([a-z]+)")

func makePattern(p string) string {
	pattern := "^" + regexp.QuoteMeta(p) + "$"
	pattern = strings.Replace(pattern, "\\*", ".*", -1)
	pattern = VAR_RE.ReplaceAllString(pattern, "(?P<$1>[^\\.]+)")
	return pattern
}

var NAME_RE = regexp.MustCompile("\\$([a-z]+)")

func (v *alarmTemplate) makeName(serviceName string) string {
	var matchingRegexp *regexp.Regexp

	for _, r := range v.includes {
		if r.Match([]byte(serviceName)) {
			matchingRegexp = r
			break
		}
	}

	if matchingRegexp != nil {
		for _, r := range v.excludes {
			if r.Match([]byte(serviceName)) {
				matchingRegexp = nil
				break
			}
		}
	}

	if matchingRegexp == nil {
		return ""
	}

	return expandName(matchingRegexp, serviceName, v.config.Name)
}

func expandName(p *regexp.Regexp, serviceName, namePattern string) string {
	groups := make(map[string]string)
	values := p.FindStringSubmatch(serviceName)
	for i, field := range p.SubexpNames() {
		if i != 0 {
			groups[field] = values[i]
		}
	}

	return NAME_RE.ReplaceAllStringFunc(namePattern, func(field string) string {
		if val, ok := groups[field[1:]]; ok {
			return val
		}
		return field[1:]
	})
}

func (v *alarm) name() string {
	return v.data.Name
}

func (v *alarm) calculateState() string {
	state := model.StateOk
	for _, s := range v.servicesInAlarm {
		if s.data.State == model.StateError {
			state = model.StateError
		}
	}
	return state
}

func (v *alarm) getExternalModel() model.Alarm {
	r := v.data
	r.FailedServices = make([]string, 0)
	for _, s := range v.servicesInAlarm {
		if s.data.State == model.StateError {
			r.FailedServices = append(r.FailedServices, s.data.Name)
		}
	}
	return r
}

func (v *alarm) removeService(service *service) {
	services := v.servicesInAlarm[:0]
	for _, x := range v.servicesInAlarm {
		if x != service {
			services = append(services, x)
		}
	}
	v.servicesInAlarm = services
}


text:
#ifndef lint
#if 0
static char sccsid[] = "@(#)ftree.c	8.2 (Berkeley) 4/18/94";
#endif
#endif /* not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: soc2013/dpl/head/bin/pax/ftree.c 222259 2011-05-22 14:03:38Z uqs $");

#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <fts.h>
#include "pax.h"
#include "ftree.h"
#include "extern.h"

/*
 * routines to interface with the fts library function.
 *
 * file args supplied to pax are stored on a single linked list (of type FTREE)
 * and given to fts to be processed one at a time. pax "selects" files from
 * the expansion of each arg into the corresponding file tree (if the arg is a
 * directory, otherwise the node itself is just passed to pax). The selection
 * is modified by the -n and -u flags. The user is informed when a specific
 * file arg does not generate any selected files. -n keeps expanding the file
 * tree arg until one of its files is selected, then skips to the next file
 * arg. when the user does not supply the file trees as command line args to
 * pax, they are read from stdin
 */

static FTS *ftsp = NULL;		/* current FTS handle */
static int ftsopts;			/* options to be used on fts_open */
static char *farray[2];			/* array for passing each arg to fts */
static FTREE *fthead = NULL;		/* head of linked list of file args */
static FTREE *fttail = NULL;		/* tail of linked list of file args */
static FTREE *ftcur = NULL;		/* current file arg being processed */
static FTSENT *ftent = NULL;		/* current file tree entry */
static int ftree_skip;			/* when set skip to next file arg */

static int ftree_arg(void);

/*
 * ftree_start()
 *	initialize the options passed to fts_open() during this run of pax
 *	options are based on the selection of pax options by the user
 *	fts_start() also calls fts_arg() to open the first valid file arg. We
 *	also attempt to reset directory access times when -t (tflag) is set.
 * Return:
 *	0 if there is at least one valid file arg to process, -1 otherwise
 */

int
ftree_start(void)
{
	/*
	 * Set up the operation mode of fts, open the first file arg. We must
	 * use FTS_NOCHDIR, as the user may have to open multiple archives and
	 * if fts did a chdir off into the boondocks, we may create an archive
	 * volume in a place where the user did not expect to.
	 */
	ftsopts = FTS_NOCHDIR;

	/*
	 * optional user flags that effect file traversal
	 * -H command line symlink follow only (half follow)
	 * -L follow symlinks (logical)
	 * -P do not follow symlinks (physical). This is the default.
	 * -X do not cross over mount points
	 * -t preserve access times on files read.
	 * -n select only the first member of a file tree when a match is found
	 * -d do not extract subtrees rooted at a directory arg.
	 */
	if (Lflag)
		ftsopts |= FTS_LOGICAL;
	else
		ftsopts |= FTS_PHYSICAL;
	if (Hflag)
#	ifdef NET2_FTS
		paxwarn(0, "The -H flag is not supported on this version");
#	else
		ftsopts |= FTS_COMFOLLOW;
#	endif
	if (Xflag)
		ftsopts |= FTS_XDEV;

	if ((fthead == NULL) && ((farray[0] = malloc(PAXPATHLEN+2)) == NULL)) {
		paxwarn(1, "Unable to allocate memory for file name buffer");
		return(-1);
	}

	if (ftree_arg() < 0)
		return(-1);
	if (tflag && (atdir_start() < 0))
		return(-1);
	return(0);
}

/*
 * ftree_add()
 *	add the arg to the linked list of files to process. Each will be
 *	processed by fts one at a time
 * Return:
 *	0 if added to the linked list, -1 if failed
 */

int
ftree_add(char *str, int chflg)
{
	FTREE *ft;
	int len;

	/*
	 * simple check for bad args
	 */
	if ((str == NULL) || (*str == '\0')) {
		paxwarn(0, "Invalid file name argument");
		return(-1);
	}

	/*
	 * allocate FTREE node and add to the end of the linked list (args are
	 * processed in the same order they were passed to pax). Get rid of any
	 * trailing / the user may pass us. (watch out for / by itself).
	 */
	if ((ft = (FTREE *)malloc(sizeof(FTREE))) == NULL) {
		paxwarn(0, "Unable to allocate memory for filename");
		return(-1);
	}

	if (((len = strlen(str) - 1) > 0) && (str[len] == '/'))
		str[len] = '\0';
	ft->fname = str;
	ft->refcnt = 0;
	ft->chflg = chflg;
	ft->fow = NULL;
	if (fthead == NULL) {
		fttail = fthead = ft;
		return(0);
	}
	fttail->fow = ft;
	fttail = ft;
	return(0);
}

/*
 * ftree_sel()
 *	this entry has been selected by pax. bump up reference count and handle
 *	-n and -d processing.
 */

void
ftree_sel(ARCHD *arcn)
{
	/*
	 * set reference bit for this pattern. This linked list is only used
	 * when file trees are supplied pax as args. The list is not used when
	 * the trees are read from stdin.
	 */
	if (ftcur != NULL)
		ftcur->refcnt = 1;

	/*
	 * if -n we are done with this arg, force a skip to the next arg when
	 * pax asks for the next file in next_file().
	 * if -d we tell fts only to match the directory (if the arg is a dir)
	 * and not the entire file tree rooted at that point.
	 */
	if (nflag)
		ftree_skip = 1;

	if (!dflag || (arcn->type != PAX_DIR))
		return;

	if (ftent != NULL)
		(void)fts_set(ftsp, ftent, FTS_SKIP);
}

/*
 * ftree_notsel()
 *	this entry has not been selected by pax.
 */

void
ftree_notsel(void)
{
	if (ftent != NULL)
		(void)fts_set(ftsp, ftent, FTS_SKIP);
}

/*
 * ftree_chk()
 *	called at end on pax execution. Prints all those file args that did not
 *	have a selected member (reference count still 0)
 */

void
ftree_chk(void)
{
	FTREE *ft;
	int wban = 0;

	/*
	 * make sure all dir access times were reset.
	 */
	if (tflag)
		atdir_end();

	/*
	 * walk down list and check reference count. Print out those members
	 * that never had a match
	 */
	for (ft = fthead; ft != NULL; ft = ft->fow) {
		if ((ft->refcnt > 0) || ft->chflg)
			continue;
		if (wban == 0) {
			paxwarn(1,"WARNING! These file names were not selected:");
			++wban;
		}
		(void)fprintf(stderr, "%s\n", ft->fname);
	}
}

/*
 * ftree_arg()
 *	Get the next file arg for fts to process. Can be from either the linked
 *	list or read from stdin when the user did not them as args to pax. Each
 *	arg is processed until the first successful fts_open().
 * Return:
 *	0 when the next arg is ready to go, -1 if out of file args (or EOF on
 *	stdin).
 */

static int
ftree_arg(void)
{
	char *pt;

	/*
	 * close off the current file tree
	 */
	if (ftsp != NULL) {
		(void)fts_close(ftsp);
		ftsp = NULL;
	}

	/*
	 * keep looping until we get a valid file tree to process. Stop when we
	 * reach the end of the list (or get an eof on stdin)
	 */
	for(;;) {
		if (fthead == NULL) {
			/*
			 * the user didn't supply any args, get the file trees
			 * to process from stdin;
			 */
			if (fgets(farray[0], PAXPATHLEN+1, stdin) == NULL)
				return(-1);
			if ((pt = strchr(farray[0], '\n')) != NULL)
				*pt = '\0';
		} else {
			/*
			 * the user supplied the file args as arguments to pax
			 */
			if (ftcur == NULL)
				ftcur = fthead;
			else if ((ftcur = ftcur->fow) == NULL)
				return(-1);
			if (ftcur->chflg) {
				/* First fchdir() back... */
				if (fchdir(cwdfd) < 0) {
					syswarn(1, errno,
					  "Can't fchdir to starting directory");
					return(-1);
				}
				if (chdir(ftcur->fname) < 0) {
					syswarn(1, errno, "Can't chdir to %s",
					    ftcur->fname);
					return(-1);
				}
				continue;
			} else
				farray[0] = ftcur->fname;
		}

		/*
		 * Watch it, fts wants the file arg stored in an array of char
		 * ptrs, with the last one a null. We use a two element array
		 * and set farray[0] to point at the buffer with the file name
		 * in it. We cannot pass all the file args to fts at one shot
		 * as we need to keep a handle on which file arg generates what
		 * files (the -n and -d flags need this). If the open is
		 * successful, return a 0.
		 */
		if ((ftsp = fts_open(farray, ftsopts, NULL)) != NULL)
			break;
	}
	return(0);
}

/*
 * next_file()
 *	supplies the next file to process in the supplied archd structure.
 * Return:
 *	0 when contents of arcn have been set with the next file, -1 when done.
 */

int
next_file(ARCHD *arcn)
{
	int cnt;
	time_t atime;
	time_t mtime;

	/*
	 * ftree_sel() might have set the ftree_skip flag if the user has the
	 * -n option and a file was selected from this file arg tree. (-n says
	 * only one member is matched for each pattern) ftree_skip being 1
	 * forces us to go to the next arg now.
	 */
	if (ftree_skip) {
		/*
		 * clear and go to next arg
		 */
		ftree_skip = 0;
		if (ftree_arg() < 0)
			return(-1);
	}

	/*
	 * loop until we get a valid file to process
	 */
	for(;;) {
		if ((ftent = fts_read(ftsp)) == NULL) {
			/*
			 * out of files in this tree, go to next arg, if none
			 * we are done
			 */
			if (ftree_arg() < 0)
				return(-1);
			continue;
		}

		/*
		 * handle each type of fts_read() flag
		 */
		switch(ftent->fts_info) {
		case FTS_D:
		case FTS_DEFAULT:
		case FTS_F:
		case FTS_SL:
		case FTS_SLNONE:
			/*
			 * these are all ok
			 */
			break;
		case FTS_DP:
			/*
			 * already saw this directory. If the user wants file
			 * access times reset, we use this to restore the
			 * access time for this directory since this is the
			 * last time we will see it in this file subtree
			 * remember to force the time (this is -t on a read
			 * directory, not a created directory).
			 */
#			ifdef NET2_FTS
			if (!tflag || (get_atdir(ftent->fts_statb.st_dev,
			    ftent->fts_statb.st_ino, &mtime, &atime) < 0))
#			else
			if (!tflag || (get_atdir(ftent->fts_statp->st_dev,
			    ftent->fts_statp->st_ino, &mtime, &atime) < 0))
#			endif
				continue;
			set_ftime(ftent->fts_path, mtime, atime, 1);
			continue;
		case FTS_DC:
			/*
			 * fts claims a file system cycle
			 */
			paxwarn(1,"File system cycle found at %s",ftent->fts_path);
			continue;
		case FTS_DNR:
#			ifdef NET2_FTS
			syswarn(1, errno,
#			else
			syswarn(1, ftent->fts_errno,
#			endif
			    "Unable to read directory %s", ftent->fts_path);
			continue;
		case FTS_ERR:
#			ifdef NET2_FTS
			syswarn(1, errno,
#			else
			syswarn(1, ftent->fts_errno,
#			endif
			    "File system traversal error");
			continue;
		case FTS_NS:
		case FTS_NSOK:
#			ifdef NET2_FTS
			syswarn(1, errno,
#			else
			syswarn(1, ftent->fts_errno,
#			endif
			    "Unable to access %s", ftent->fts_path);
			continue;
		}

		/*
		 * ok got a file tree node to process. copy info into arcn
		 * structure (initialize as required)
		 */
		arcn->skip = 0;
		arcn->pad = 0;
		arcn->ln_nlen = 0;
		arcn->ln_name[0] = '\0';
#		ifdef NET2_FTS
		arcn->sb = ftent->fts_statb;
#		else
		arcn->sb = *(ftent->fts_statp);
#		endif

		/*
		 * file type based set up and copy into the arcn struct
		 * SIDE NOTE:
		 * we try to reset the access time on all files and directories
		 * we may read when the -t flag is specified. files are reset
		 * when we close them after copying. we reset the directories
		 * when we are done with their file tree (we also clean up at
		 * end in case we cut short a file tree traversal). However
		 * there is no way to reset access times on symlinks.
		 */
		switch(S_IFMT & arcn->sb.st_mode) {
		case S_IFDIR:
			arcn->type = PAX_DIR;
			if (!tflag)
				break;
			add_atdir(ftent->fts_path, arcn->sb.st_dev,
			    arcn->sb.st_ino, arcn->sb.st_mtime,
			    arcn->sb.st_atime);
			break;
		case S_IFCHR:
			arcn->type = PAX_CHR;
			break;
		case S_IFBLK:
			arcn->type = PAX_BLK;
			break;
		case S_IFREG:
			/*
			 * only regular files with have data to store on the
			 * archive. all others will store a zero length skip.
			 * the skip field is used by pax for actual data it has
			 * to read (or skip over).
			 */
			arcn->type = PAX_REG;
			arcn->skip = arcn->sb.st_size;
			break;
		case S_IFLNK:
			arcn->type = PAX_SLK;
			/*
			 * have to read the symlink path from the file
			 */
			if ((cnt = readlink(ftent->fts_path, arcn->ln_name,
			    PAXPATHLEN - 1)) < 0) {
				syswarn(1, errno, "Unable to read symlink %s",
				    ftent->fts_path);
				continue;
			}
			/*
			 * set link name length, watch out readlink does not
			 * always NUL terminate the link path
			 */
			arcn->ln_name[cnt] = '\0';
			arcn->ln_nlen = cnt;
			break;
		case S_IFSOCK:
			/*
			 * under BSD storing a socket is senseless but we will
			 * let the format specific write function make the
			 * decision of what to do with it.
			 */
			arcn->type = PAX_SCK;
			break;
		case S_IFIFO:
			arcn->type = PAX_FIF;
			break;
		}
		break;
	}

	/*
	 * copy file name, set file name length
	 */
	arcn->nlen = l_strncpy(arcn->name, ftent->fts_path, sizeof(arcn->name) - 1);
	arcn->name[arcn->nlen] = '\0';
	arcn->org_name = ftent->fts_path;
	return(0);
}


text:
package com.codemetal.tapi.metadata;

/**
 * This class represents the input to be provided to a TestCase
 * @author Raghuveer Bhandarkar
 *
 */
public class TestCaseInput {

	/*Input to the API (JSON/XML etc)*/
	private String input;

	/*HTTP Request Parameters for the API*/
	private RequestParam param;

	public String getInput() {
		return input;
	}

	public void setInput(String input) {
		this.input = input;
	}

	public RequestParam getParam() {
		return param;
	}

	public void setParam(RequestParam param) {
		this.param = param;
	}

}


text:
export interface Location {
  latitude : number;
  longitude : number;
}


text:
import { Ray } from '../math/Ray.js';
import { Layers } from './Layers.js';

class Raycaster {

	constructor( origin, direction, near = 0, far = Infinity ) {

		this.ray = new Ray( origin, direction );
		// direction is assumed to be normalized (for accurate distance calculations)

		this.near = near;
		this.far = far;
		this.camera = null;
		this.layers = new Layers();

		this.params = {
			Mesh: {},
			Line: { threshold: 1 },
			LOD: {},
			Points: { threshold: 1 },
			Sprite: {}
		};

	}

	set( origin, direction ) {

		// direction is assumed to be normalized (for accurate distance calculations)

		this.ray.set( origin, direction );

	}

	setFromCamera( coords, camera ) {

		if ( camera.isPerspectiveCamera ) {

			this.ray.origin.setFromMatrixPosition( camera.matrixWorld );
			this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize();
			this.camera = camera;

		} else if ( camera.isOrthographicCamera ) {

			this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera
			this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );
			this.camera = camera;

		} else {

			console.error( 'THREE.Raycaster: Unsupported camera type: ' + camera.type );

		}

	}

	intersectObject( object, recursive = true, intersects = [] ) {

		intersectObject( object, this, intersects, recursive );

		intersects.sort( ascSort );

		return intersects;

	}

	intersectObjects( objects, recursive = true, intersects = [] ) {

		for ( let i = 0, l = objects.length; i < l; i ++ ) {

			intersectObject( objects[ i ], this, intersects, recursive );

		}

		intersects.sort( ascSort );

		return intersects;

	}

}

function ascSort( a, b ) {

	return a.distance - b.distance;

}

function intersectObject( object, raycaster, intersects, recursive ) {

	if ( object.layers.test( raycaster.layers ) ) {

		object.raycast( raycaster, intersects );

	}

	if ( recursive === true ) {

		const children = object.children;

		for ( let i = 0, l = children.length; i < l; i ++ ) {

			intersectObject( children[ i ], raycaster, intersects, true );

		}

	}

}

export { Raycaster };


text:
using namespace ::testing;

class time_MOCK
{
  public:
    time_MOCK();
    virtual ~time_MOCK()
    {
    }

    MOCK_METHOD2(clock_getres, int(clockid_t, struct timespec*));
    MOCK_METHOD2(clock_gettime, int(clockid_t, struct timespec*));
    MOCK_METHOD2(clock_settime, int(clockid_t, const struct timespec*));

    static std::unique_ptr<time_MOCK> mock;
    static bool doUseMock; // = true;
};

#if defined(__linux__)
int clock_getres(clockid_t clk_id, struct timespec* res) noexcept;
int clock_gettime(clockid_t clk_id, struct timespec* res) noexcept;
int clock_settime(clockid_t clk_id, const struct timespec* res) noexcept;
#else
int clock_getres(clockid_t clk_id, struct timespec* res);
int clock_gettime(clockid_t clk_id, struct timespec* res);
int clock_settime(clockid_t clk_id, const struct timespec* res);
#endif
#endif

#endif // IOX_HOOFS_MOCKS_TIME_MOCK_HPP


text:
using System;
using CPU = Cosmos.Assembler.x86;

namespace Cosmos.IL2CPU.X86.IL
{
    [Cosmos.IL2CPU.OpCode( ILOpCode.Code.Br )]
    public class Br : ILOp
    {
        public Br( Cosmos.Assembler.Assembler aAsmblr )
            : base( aAsmblr )
        {
        }

        public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
        {
            new CPU.Jump { DestinationLabel = AppAssembler.TmpBranchLabel(aMethod, aOpCode) };
        }

    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="2.5" client="site" method="upgrade">
	<name>Community - Whos Online</name>
	<author>JomSocial Team</author>
	<creationDate>April 2013</creationDate>
	<copyright>Copyright (C) 2008 - 2013 JomSocial. All rights reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
	<authorEmail>support@jomsocial.com</authorEmail>
	<authorUrl>http://www.jomsocial.com</authorUrl>
	<version>3.0.5.2</version>
	<description>Whos online</description>

	<files>
		<filename module="mod_community_whosonline">mod_community_whosonline.php</filename>
		<filename>mod_community_whosonline.xml</filename>
		<folder>tmpl</folder>
	</files>

	<config>
		<fields name="params">
			<fieldset name="basic">
				<field name="moduleclass_sfx" type="text" default="cModule cFrontPage-ShowOnline app-box" label="Module Class Suffix" description="PARAMMODULECLASSSUFFIX" />
				<field name="default" type="text" default="20" label="Default members online value" description="Default members online value" />
			</fieldset>
		</fields>
	</config>
</extension>


text:
{
	"translatorID": "caa8f42c-9dbf-446e-963b-6ee18e3133d2",
	"translatorType": 4,
	"label": "Sveriges radio",
	"creator": "Sebastian Berlin",
	"target": "^https?://sverigesradio\\.se/(artikel|sok\\?)",
	"minVersion": "3.0",
	"maxVersion": null,
	"priority": 100,
	"inRepository": true,
	"browserSupport": "gcsibv",
	"lastUpdated": "2021-06-15 16:25:00"
}

function detectWeb(doc, url) {
	if (url.includes('/artikel/')) {
		return "newspaperArticle";
	}
	else if (url.includes('/sok?') && getSearchResults(doc, true)) {
		return "multiple";
	}
	return false;
}

function getSearchResults(doc, checkOnly) {
	var items = {};
	var found = false;
	var rows = doc.querySelectorAll('a.search-item');
	for (let i = 0; i < rows.length; i++) {
		let href = rows[i].href;
		let title = ZU.trimInternal(rows[i].textContent);
		if (!href || !title) continue;
		if (checkOnly) return true;
		found = true;
		items[href] = title;
	}
	return found ? items : false;
}

function doWeb(doc, url) {
	if (detectWeb(doc, url) == "multiple") {
		Zotero.selectItems(getSearchResults(doc, false), function (items) {
			if (!items) {
				return;
			}
			var articles = [];
			for (var i in items) {
				articles.push(i);
			}
			ZU.processDocuments(articles, scrape);
		});
	}
	else {
		scrape(doc, url);
	}
}

function scrape(doc, url) {
	var translator = Zotero.loadTranslator('web');
	// Embedded Metadata
	translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');

	translator.setHandler('itemDone', function (obj, item) {
		item.publicationTitle = "Sveriges Radio";

		item.creators = [];
		var nameNodes = ZU.xpath(doc, '//p[@class="byline"]/text()');
		for (let node of nameNodes) {
			// Take the first two strings of non-spaces as the names. The byline
			// can vary in format, including:
			// First Last
			// First Last SecondLast
			// First Last, City
			// First Last City, Country
			var nameString = node.wholeText.split(" ", 2).join(" ");
			var author = ZU.cleanAuthor(nameString, "author");
			item.creators.push(author);
		}
		if (item.creators.length === 1 && item.creators[0].lastName === "Ekot") {
			// Special case when only signed as "Ekot", i.e. no person
			// specified as author.
			item.creators[0].fieldMode = true;
			item.creators[0].firstName = undefined;
		}

		// The title from the meta is in the format:
		// Australierna säger ja till samkönade äktenskap - Nyheter (Ekot)
		var titleString = attr(doc, 'meta[name="twitter:title"]', "content");
		var titleParts = titleString.split(" - ");
		item.title = titleParts[0];
		item.section = titleParts[1];

		var dateString = attr(doc, '.publication-metadata time', 'datetime');
		item.date = dateString;

		item.tags = [];

		item.complete();
	});

	translator.getTranslatorObject(function (trans) {
		trans.itemType = "newspaperArticle";
		trans.addCustomFields({
			'twitter:description': 'abstractNote'
		});
		trans.doWeb(doc, url);
	});
}

/** BEGIN TEST CASES **/
var testCases = [
	{
		"type": "web",
		"url": "https://sverigesradio.se/artikel/6821850",
		"items": [
			{
				"itemType": "newspaperArticle",
				"title": "Australierna säger ja till samkönade äktenskap",
				"creators": [
					{
						"lastName": "Ekot",
						"creatorType": "author",
						"fieldMode": true
					}
				],
				"date": "2017-11-15 00:11:00Z",
				"abstractNote": "I en rådgivande postomröstning i Australien svarade 61,6 procent av medborgarna att de ville se en lag som godkänner samkönade äktenskap.",
				"language": "sv",
				"libraryCatalog": "sverigesradio.se",
				"publicationTitle": "Sveriges Radio",
				"section": "Nyheter (Ekot)",
				"url": "https://sverigesradio.se/artikel/6821850",
				"attachments": [
					{
						"title": "Snapshot",
						"mimeType": "text/html"
					}
				],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://sverigesradio.se/artikel/6865752",
		"items": [
			{
				"itemType": "newspaperArticle",
				"title": "Här duschas de äldre av en robot",
				"creators": [
					{
						"firstName": "Emil",
						"lastName": "Hellerud",
						"creatorType": "author"
					}
				],
				"date": "2018-02-20 06:06:00Z",
				"abstractNote": "I Karlstad har äldreomsorgen börjat använda en duschrobot.",
				"language": "sv",
				"libraryCatalog": "sverigesradio.se",
				"publicationTitle": "Sveriges Radio",
				"section": "Nyheter (Ekot)",
				"url": "https://sverigesradio.se/artikel/6865752",
				"attachments": [
					{
						"title": "Snapshot",
						"mimeType": "text/html"
					}
				],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://sverigesradio.se/artikel/6891473",
		"items": [
			{
				"itemType": "newspaperArticle",
				"title": "Stim skriver internationellt avtal med Facebook",
				"creators": [
					{
						"firstName": "Emil",
						"lastName": "Salmaso",
						"creatorType": "author"
					}
				],
				"date": "2018-02-21 16:26:00Z",
				"abstractNote": "Musikskaparnas representantorganisation Stim har skrivit ett internationellt avtal med Facebook.",
				"language": "sv",
				"libraryCatalog": "sverigesradio.se",
				"publicationTitle": "Sveriges Radio",
				"section": "Kulturnytt i P1",
				"url": "https://sverigesradio.se/artikel/6891473",
				"attachments": [
					{
						"title": "Snapshot",
						"mimeType": "text/html"
					}
				],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://sverigesradio.se/artikel/6892065",
		"items": [
			{
				"itemType": "newspaperArticle",
				"title": "HD: Nawaz Sharif får inte leda sitt parti i Pakistan",
				"creators": [
					{
						"firstName": "Margita",
						"lastName": "Boström",
						"creatorType": "author"
					}
				],
				"date": "2018-02-22 11:44:00Z",
				"abstractNote": "Högsta domstolen i Pakistan har slagit fast att landets avsatte premiärminister Nawaz Sharif inte längre får leda det parti han själv grundat.",
				"language": "sv",
				"libraryCatalog": "sverigesradio.se",
				"publicationTitle": "Sveriges Radio",
				"section": "Nyheter (Ekot)",
				"shortTitle": "HD",
				"url": "https://sverigesradio.se/artikel/6892065",
				"attachments": [
					{
						"title": "Snapshot",
						"mimeType": "text/html"
					}
				],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://sverigesradio.se/artikel/6891577",
		"items": [
			{
				"itemType": "newspaperArticle",
				"title": "Alarmerande självmordssiffror bland ensamkommande unga",
				"creators": [
					{
						"firstName": "Åsa",
						"lastName": "Swee",
						"creatorType": "author"
					}
				],
				"date": "2018-02-22 06:21:00Z",
				"abstractNote": "Förra året begick 12 ensamkommande barn och ungdomar självmord i Sverige. Ett av fallen skedde i Jämtland.",
				"language": "sv",
				"libraryCatalog": "sverigesradio.se",
				"publicationTitle": "Sveriges Radio",
				"section": "P4 Jämtland",
				"url": "https://sverigesradio.se/artikel/6891577",
				"attachments": [
					{
						"title": "Snapshot",
						"mimeType": "text/html"
					}
				],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://sverigesradio.se/artikel/6892091",
		"items": [
			{
				"itemType": "newspaperArticle",
				"title": "Facebook låg nere – #facebookdown trendar",
				"creators": [
					{
						"firstName": "Karin",
						"lastName": "Ingströmer",
						"creatorType": "author"
					},
					{
						"firstName": "Estrid",
						"lastName": "Wagersten",
						"creatorType": "author"
					}
				],
				"date": "2018-02-22 12:09:00Z",
				"abstractNote": "Facebook och Instagram fick problem strax före 12. Minuter senare fungerade allt som vanligt för de flesta användare. Under tiden hade #facebookdown använts ...",
				"language": "sv",
				"libraryCatalog": "sverigesradio.se",
				"publicationTitle": "Sveriges Radio",
				"section": "P4 Halland",
				"url": "https://sverigesradio.se/artikel/6892091",
				"attachments": [
					{
						"title": "Snapshot",
						"mimeType": "text/html"
					}
				],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://sverigesradio.se/artikel/6894423",
		"items": [
			{
				"itemType": "newspaperArticle",
				"title": "Siberian 'Beast from the East' keeps Swedish kids inside",
				"creators": [
					{
						"firstName": "Richard",
						"lastName": "Orange",
						"creatorType": "author"
					}
				],
				"date": "2018-02-26 13:31:00Z",
				"abstractNote": "A Siberian cold front has brought Sweden unusually cold temperatures for late February. It was -42C when Kristina Lindqvist left home for her job at the ...",
				"language": "en",
				"libraryCatalog": "sverigesradio.se",
				"publicationTitle": "Sveriges Radio",
				"section": "Radio Sweden",
				"url": "https://sverigesradio.se/artikel/6894423",
				"attachments": [
					{
						"title": "Snapshot",
						"mimeType": "text/html"
					}
				],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	},
	{
		"type": "web",
		"url": "https://sverigesradio.se/sok?query=choklad",
		"defer": true,
		"items": "multiple"
	},
	{
		"type": "web",
		"url": "https://sverigesradio.se/artikel/har-gor-den-svenska-extrabubblan-sin-forsta-traning",
		"items": [
			{
				"itemType": "newspaperArticle",
				"title": "Här gör den svenska "extrabubblan" sin första träning",
				"creators": [
					{
						"firstName": "",
						"lastName": "Radiosporten",
						"creatorType": "author"
					}
				],
				"date": "2021-06-11 20:03:00Z",
				"abstractNote": "Under fredagen genomfördes den första träningen för de sex spelare som blixtinkallats till fotbollslandslagets extrabubbla. De som ska vara redo att skrivas ...",
				"language": "sv",
				"libraryCatalog": "sverigesradio.se",
				"publicationTitle": "Sveriges Radio",
				"section": "Radiosporten",
				"url": "https://sverigesradio.se/artikel/har-gor-den-svenska-extrabubblan-sin-forsta-traning",
				"attachments": [
					{
						"title": "Snapshot",
						"mimeType": "text/html"
					}
				],
				"tags": [],
				"notes": [],
				"seeAlso": []
			}
		]
	}
]
/** END TEST CASES **/


text:
locations_mandelHellerLibrary=[
	{
		"id":"schneider",
		"name":"Irving Schneider and Family Building (Heller School)",
		"nickname":"Heller (Schneider)",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369303, -71.259773],
			[42.369452, -71.259208],
			[42.369298, -71.259200],
			[42.369289, -71.259155],
			[42.369278, -71.259090],
			[42.369169, -71.259145],
			[42.369148, -71.259343],
			[42.369258, -71.259346],
			[42.369166, -71.259735]]
		]},
		"category":["offices","academics"],
		"entrances":["schneider_e01", "schneider_e02", "schneider_e03"],
		"area":["upper campus"],
		"function":"Home to the Heller School for Social Policy and Management, the Irving Schneider and Family Building contains classroom and lecture space, study areas, student lounges and the public atrium known as the Zinner Forum. The building also houses the Schneider Institute for Health Policy.",
		"nearby":["heller","chapelsfieldwetland","abraham","olin-sang","mandel","mandelJewish"]
	},
	heller = {
		"id":"heller",
		"name":"Heller-Brown Building",
		"nickname":"Heller (Brown)",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369326,-71.259107],
			[42.369187,-71.258417],
			[42.369025,-71.258474],
			[42.369158,-71.259171]]
		]},
		"function":"The Heller-Brown Building is one of two buildings making up the Heller School for Social Policy and Management. The building holds classrooms, conference rooms, offices, a library and Geographic Information Systems lab.",
		"description":"Heller-Brown is home to the Heller School for Social Policy and Management, one of the top ten schools of social policy in the United States and one of the eight approved U.S. training institutions for World Bank Scholars.",
		"category":["academics"],
		"entrances":["heller_e01", "heller_e02", "starbucksHeller_ie01"],
		"area":["upper campus"],
		"nearby":["schneider","abraham","chapelsfieldwetland","mandel","mandelJewish","olin-sang"]
		},
	{
		"id":"lown",
		"name":"Lown School of Near Eastern and Judaic Studies",
		"nickname":"Lown",
		"function":"The Lown Center for Judaica Studies is home to the Maurice & Marilyn Center for Modern Jewish Studies, the Near Eastern & Judaic Studies program, the Hornstein Jewish Professional Leadership Program and the university's National Center for Jewish Film. It also contains many courses in Near Eastern and Judaic Studies (NEJS) and Islamic and Middle Eastern Studies (IMES).",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.370321, -71.257312],
			[42.370185, -71.257497],
			[42.369941, -71.257161],
			[42.370076, -71.256976]]
		]},
		"category":["academics","offices"],
		"entrances":["lown_e01", "lown_e02"],
		"area":["upper campus","mandel"],
		"nearby":["golding","shiffman","olin-sang","mandel","rabb","gordon","stop_rabb"]
	},
	{
		"id":"abraham",
		"name":"Abraham Shapiro Academic Complex",
		"nickname":"Shapiro Academic Complex",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369827, -71.259680],
			[42.369761, -71.259332],
			[42.369684, -71.259351],
			[42.369666, -71.259279],
			[42.369609, -71.259300],
			[42.369722, -71.259721]]
		]},
		"category":["offices","academics"],
		"entrances":["abraham_e01"],
		"area":["upper campus"],
		"function":"The Abraham Shapiro Academic Complex houses the International Center for Ethics, Justice and Public Life and the Education Program. The building includes classrooms, offices, seminar and conference room space, as well as a graduate-student study area.",
		"nearby":["mandelJewish","mandel","heller","schneider","chapelsfieldwetland"]
	},
	{
		"id":"mandelJewish",
		"name":"Jack, Joseph, and Morton Mandel Center for Studies in Jewish Education",
		"nickname":"Mandel Center",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369615, -71.259750],
			[42.369553, -71.259402],
			[42.369590, -71.259387],
			[42.369577, -71.259318],
			[42.369605, -71.259309],
			[42.369609, -71.259300],
			[42.369722, -71.259721]]
		]},
		"category":["offices","academics"],
		"entrances":["mandelJewish_e01"],
		"area":["upper campus"],
		"function":"The Mandel Center for Studies in Jewish Education is located on the Brandeis University campus in the Abraham Shapiro Academic Complex. It pursues Jewish educational scholarship in service to the Jewish community in order to promote deeper understanding of the purposes and practices of Jewish education.",
		'nearby':["abraham","mandel","heller","schneider","chapelsfieldwetland","stop_rabb","olin-sang"]
	},
	olinsang = {
		"id":"olin-sang",
		"name":"Olin-Sang American Civilization Center",
		"nickname":"Olin-Sang",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369899, -71.257850],
			[42.369778, -71.258012],
			[42.369392, -71.257481],
			[42.369507, -71.257322]]
		]},
		"category":["academics"],
		"entrances":["olin-sang_e01", "olin-sang_ie01", "olin-sang_e02", "olin-sang_e03"],
		"area":["upper campus","mandel"],
		"function":"The Olin-Sang American Civilization Center holds classrooms and offices for various university departments including History, Latin American and Latino Studies, and the Film, Television and Interactive Media program, along with many lecture halls.",
		"nearby":["mandel","rabb","golding","lown","shiffman","tree","stop_rabb","heller","mandelJewish","schneider"]
	},
	goldfarb = {
		"id":"goldfarb",
		"name":"Goldfarb Library",
		"nickname":"Goldfarb",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.368789, -71.258209],
			[42.368123, -71.258451],
			[42.367935, -71.258283],
			[42.367945, -71.258188],
			[42.367892, -71.258129],
			[42.367823, -71.258152],
			[42.367790, -71.257981],
			[42.367993, -71.257914],
			[42.368135, -71.257891],
			[42.368118, -71.257811],
			[42.368674, -71.257622]]
		]},
		"category":["academics"],
		"function":"The Goldfarb Library is the main library on campus where students may access 30,000 electronic journals and 250 scholarly databases, group study rooms and computer tech support from Library Technology Services. It also houses university archives, special collections of rare books and manuscripts and its Judaica Collection of Jewish history, religious and cultural documents.",
		"description": "Goldfarb/Farber Libraries house ever growing collections and reference resources in creative arts, humanities, government documents, Judaica, and social sciences. Research materials are extremely accessible to students due to the online availability of resources, and additional resources are made available through the Boston Library Consortium and the Interlibrary Loan system. The library offers services for students including a listening center, computer labs, study rooms, a media lab that helps students edit their films and soundtracks, as well as the Writing Center. The Writing Center assists students in all aspects of writing their papers, from brainstorming to editing. Recently, a new café was added to the Green Room section of the library.",
		"entrances":["goldfarb_e01","goldfarb_e02", "library_ie01"],
		"area":["upper campus","libraries"],
		"nearby":["farber","usdan","chapelsfieldwetland","heller","schneider"]
	},
	farber = {
		"id":"farber",
		"name":"Leonard L. Farber Library",
		"nickname":"Farber",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.367907,-71.258866],
			[42.368046,-71.25855],
			[42.367823,-71.258354],
			[42.367688,-71.25867]]
		]},
		"category":["library"],
		"entrances":["farber_e01", "farber_ie01"],
		"area":["upper campus","libraries"],
		"function":"One of three libraries on campus, the Leonard L. Farber Library houses resources and services supporting the humanities, the social sciences, Judaica and creative arts. The university's Getz Multimedia Lab is also located here.",
		"nearby":["goldfarb","usdan","chapelsfield","chapelsfieldwetland"]
		},
	rabb = {
		"id":"rabb",
		"name":"Rabb Graduate Center",
		"nickname":"Rabb Graduate Center",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369289,-71.25762],
			[42.369127,-71.256792],
			[42.368996,-71.256845],
			[42.36915,-71.257674]]
		]},
		"category":["academics"],
		"entrances":["rabb_e01"],
		"area":["upper campus","mandel"],
		"function":"Rabb Graduate Center houses seminar rooms, faculty and administrative offices, and small offices for graduate students in study areas such as English, Romance Studies, Philosophy, and Environmental Studies.",
		"nearby":["olin-sang","shiffman","golding","mandel","stop_rabb","usdan"]
		},
	mandel = {
		"id":"mandel",
		"name":"Jack, Joseph, and Morton Mandel Center for the Humanities",
		"nickname":"Mandel",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369854, -71.258567],
			[42.369817, -71.258603],
			[42.369811, -71.258588],
			[42.369757, -71.258614],
			[42.369751, -71.258594],
			[42.369739, -71.258596],
			[42.369728, -71.258563],
			[42.369705, -71.258573],
			[42.369575, -71.258092],
			[42.369444, -71.258020],
			[42.369496, -71.257939],
			[42.369476, -71.257872],
			[42.369467, -71.257794],
			[42.369479, -71.257751],
			[42.369491, -71.257723],
			[42.369513, -71.257705],
			[42.369535, -71.257709],
			[42.369570, -71.257757],
			[42.369589, -71.257849],
			[42.369607, -71.257813],
			[42.369629, -71.257896],
			[42.369663, -71.257879]]
		]},
		"function": "Mandel is the main facility for liberal arts education, including humanities, social sciences, literature, language and philosophy. The four-story center, made up of multiple buildings linked with an outdoor quadrangle, has a 90-seat theater/lecture hall, classrooms, seminar rooms, offices and open workstations.",
		"description": "The Mandel Center for the Humanities was created as an interdisciplinary building \
						that specifically combines subjects in order for students to have a better understanding \
						of the major themes of the human experience. The Center's courses include languages, \
						literature, philosophy, history, anthropology, sociology, and are \
						intended for undergraduate students, graduate students, faculty, and visitors. This \
						building regularly hosts an interdisciplinary seminar taught by several professors from \
						different areas of study. Classes in this building are taught in a round-table setting \
						as well as in lecture halls.",
		"category":["academics"],
		"entrances":["mandel_e01", "mandel_e02", "olin-sang_ie01"],
		"nearby":["olin-sang","golding","rabbGrad", "heller"],
		"area":["upper campus","mandel"]
	},
	golding = {
		"id":"golding",
		"name":"Golding Judaic Center",
		"nickname":"Golding",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.370371, -71.257649],
			[42.370013, -71.258116],
			[42.369876, -71.257926],
			[42.370232, -71.257451]]
		]},
		"category":["academics"],
		"entrances":["golding_e01", "golding_e02"],
		"nearby":["olin-sang","mandel","lown","shiffman"],
		"area":["upper campus","mandel"],
		"function":"The Golding Judaica Center holds classrooms for subject areas including East Asian Studies, Near Eastern and Judaic Studies (NEJS), and African and Afro-American Studies (AAAS)."
	},
	shiffman = {
		"id":"shiffman",
		"name":"Shiffman Humanities Center",
		"nickname":"Shiffman",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369937, -71.257230],
			[42.369831, -71.257372],
			[42.369475, -71.256876],
			[42.369583, -71.256729]]
		]},
		"category":["academics"],
		"entrances":["shiffman_e01", "shiffman_e02", "shiffman_e03"],
		"area":["upper campus","mandel"],
		"function":"On the north side of campus, Shiffman Humanities Center houses offices and classrooms for the departments of Romance Studies, German Studies, Russian Studies, European Cultural Studies, and the Comparative Literature Program.",
		"nearby":["tree","golding","rabb","lown","olin-sang","gordon","kutz"]
	},
	kutz = {
		"id":"kutz",
		"name":"Kutz Hall",
		"nickname":"Kutz",
		"coordinates": {"type":"Polygon","coordinates":[
			[[42.369162, -71.256163],
			[42.369043, -71.256226],
			[42.369012, -71.256130],
			[42.368903, -71.256184],
			[42.368807, -71.255841],
			[42.368912, -71.255787],
			[42.368880, -71.255647],
			[42.368997, -71.255590],
			[42.369113, -71.256013],
			[42.369151, -71.255997],
			[42.369151, -71.256053],
			[42.369131, -71.256053]]
		]},
		"category":["administrative","offices","student life"],
		"entrances":["kutz_e01","kutz_e02"],
		"area":["upper campus"],
		"function":"Kutz Hall houses offices for the Graduate School of Arts and Sciences, the registrar, and Conference and Events Services, as well as the International Students & Scholars Office and the Campus Card Office. The Graduate Student Center on the first floor gives students use of a day locker and a lounge/study site.",
		"nearby":["gordon","usen","reitman","cable","usdan","shiffman","stop_rabb"]
	},

]