Esempio n. 1
0
TEST(NFSStream, Simple)
{
    Nidium::IO::NFSStream nfs("nfs://127.0.0.1:/tmp/tst.txt");

    ASSERT_STREQ(Nidium::IO::NFSStream::GetBaseDir(), nullptr);
    EXPECT_TRUE(nfs.AllowSyncStream() == true);
    EXPECT_TRUE(nfs.AllowLocalFileStream() == true);
}
Esempio n. 2
0
File: sl.c Progetto: bitemyapp/j
A jtstcreate(J jt,C k,I p,I n,C*u){A g,*pv,x,y;C s[20];I m,*nv;L*v;
 GA(g,SYMB,ptab[p],1,0); 
 RZ(v=symnew(AV(g))); v->flag|=LINFO; v->sn=jt->symindex++;
 switch(k){
  case 0:  /* named    locale */
   RZ(x=nfs(n,u));
   LOCNAME(g)=x; LOCPATH(g)=ra(1==n&&'z'==*u?vec(BOX,0L,0L):zpath);
   symbis(x,g,jt->stloc);
   break;
  case 1:  /* numbered locale */
   ASSERT(0<=jt->stmax,EVLOCALE);
   sprintf(s,FMTI,n); RZ(x=nfs(strlen(s),s));
   LOCNAME(g)=x; LOCPATH(g)=ra(zpath);
   ++jt->stused;
   m=AN(jt->stnum);
   if(m<jt->stused){
    x=ext(1,jt->stnum); y=ext(1,jt->stptr); RZ(x&&y); jt->stnum=x; jt->stptr=y;
    nv=m+AV(jt->stnum); pv=m+AAV(jt->stptr); DO(AN(x)-m, *nv++=-1; *pv++=0;); 
   }
Esempio n. 3
0
int jget(J jt, C* name, VARIANT* v, int dobstr)
{
	A a;
	char gn[256];
	I old;
	int er;

	if(strlen(name) >= sizeof(gn)) return EVILNAME;
	if(valid(name, gn)) return EVILNAME; 
	RZ(a=symbrd(nfs(strlen(gn),gn)));
	old = jt->tnextpushx;
	er = a2v (jt, a, v, dobstr);
	tpop (old);
	return er;
}
Esempio n. 4
0
int loadkernel(const char *fname)
{
	static const struct proto * const last_proto = 
		&protos[sizeof(protos)/sizeof(protos[0])];
	const struct proto *proto;
	in_addr ip;
	int len;
	const char *name;

#if 0 && defined(CAN_BOOT_DISK)
	if (!memcmp(fname,"/dev/",5) && fname[6] == 'd') {
		int dev, part = 0;
		if (fname[5] == 'f') {
			if ((dev = fname[7] - '0') < 0 || dev > 3)
				goto nodisk; }
		else if (fname[5] == 'h' || fname[5] == 's') {
			if ((dev = 0x80 + fname[7] - 'a') < 0x80 || dev > 0x83)
				goto nodisk;
			if (fname[8]) {
				part = fname[8] - '0';
				if (fname[9])
					part = 10*part + fname[9] - '0'; }
			/* bootdisk cannot cope with more than eight partitions */
			if (part < 0 || part > 8)
				goto nodisk; }
		else
			goto nodisk;
		return(bootdisk(dev, part, load_block));
	}
#endif
	ip.s_addr = arptable[ARP_SERVER].ipaddr.s_addr;
	name = fname;
	url_port = -1;
	len = 0;
	while(fname[len] && fname[len] != ':') {
		len++;
	}
	for(proto = &protos[0]; proto < last_proto; proto++) {
		if (memcmp(name, proto->name, len) == 0) {
			break;
		}
	}
	if ((proto < last_proto) && (memcmp(fname + len, "://", 3) == 0)) {
		name += len + 3;
		if (name[0] != '/') {
			name += inet_aton(name, &ip);
			if (name[0] == ':') {
				name++;
				url_port = strtoul(name, &name, 10);
			}
		}
		if (name[0] == '/') {
			arptable[ARP_SERVER].ipaddr.s_addr = ip.s_addr;
			printf( "Loading %s ", fname );
			return proto->load(name + 1, load_block);
		}
	}
	printf("Loading %@:%s ", arptable[ARP_SERVER].ipaddr, fname);
#ifdef	DEFAULT_PROTO_NFS
	return nfs(fname, load_block);
#else
	return tftp(fname, load_block);
#endif
}
Esempio n. 5
0
int main(int argc, char** argv)
{
	std::cout<<"INFO: Atrail_search, searchs for an Atrail for a given planar embedding."<<std::endl;
	if(argc < 2)
	{
		std::cerr << "ERROR! Usage: " << "Atrail_search " << "input_edgecode " <<"[output_edgetrail] "<<"[output_nodetrail]" <<std::endl;
		return 1;
	}else
	{
		std::string edgecode_file(argv[1]);
		std::string edgetrail_file;
		std::string nodetrail_file;
		if( argc == 2)
		{
			edgetrail_file = edgecode_file.substr(0, edgecode_file.find_last_of('.')).append(".trail");
			nodetrail_file = edgecode_file.substr(0, edgecode_file.find_last_of('.')).append(".ntrail");
		}else{
			edgetrail_file = std::string(argv[2]);
			if(argc >= 4) nodetrail_file = std::string(argv[3]);
			if(argc >= 5) std::cerr<<"WARNING: You have more arguments than required, ignoring the arguments after the third ..."<<std::endl;
		}

		std::vector<std::vector<size_t> > edge_code;

		// Attempt to read the edge code from the provided file and process if read was successful.
		if(read_edge_code(std::string(edgecode_file), edge_code))
		{
			std::list<std::size_t> edge_trail;
			Graph G(edge_code.size());
			std::size_t m = 0;
			for( unsigned int i = 0; i < edge_code.size(); ++i ) m += edge_code[i].size();
			m = m / 2;
			std::vector<std::vector<unsigned int> > ind2pair(m, std::vector<unsigned int>(0));
			for( unsigned int i = 0; i < edge_code.size(); ++i)
			{
				for( unsigned int j = 0; j < edge_code[i].size(); ++j)
				{
					ind2pair[edge_code[i][j]].push_back(i);
				}
			}

			for( unsigned int i = 0; i < m; ++i)
			{
				add_edge(ind2pair[i][0], ind2pair[i][1], i, G);
			}
			std::cout<<"INFO: Read graph from the edgecode "<<edgecode_file<<std::endl;
			//std::cout<<"INFO: Graph "<<edgecode_file<<"\n"<<to_string_graph(G)<<std::endl;
			std::list<Vertex> node_trail;
			if(Atrail_search(G, edge_code, edge_trail, node_trail) == true)
			{
				std::cout<<"INFO: Found an A-trail for the graph"<<std::endl;
				std::ofstream ofs(edgetrail_file.c_str(), std::ios::out);
				if( !ofs.is_open())
				{
					std::cerr<<"ERROR! Unable to create file "<<edgetrail_file<<std::endl;
					return 2;
				}else
				{
					std::cout<<"INFO: Appending the trail as edge list to file "<<edgetrail_file<<std::endl;
					for( std::list<std::size_t>::iterator it = edge_trail.begin(); it != edge_trail.end(); it++)
					{
							ofs<<*it<<" ";
					}
				}
				ofs.close();
				std::ofstream nfs(nodetrail_file.c_str(), std::ios::out);
				if( !nfs.is_open())
				{
					std::cerr<<"ERROR! Unable to create file "<<nodetrail_file<<std::endl;
					return 2;
				}else
				{
					std::cout<<"INFO: Appending the trail as node list to file "<<nodetrail_file<<std::endl;
					for( std::list<Vertex>::iterator it = node_trail.begin(); it != node_trail.end(); it++)
					{
							nfs<<*it<<" ";
					}
				}
				nfs.close();
				return 0;
			}else
			{
				std::cerr<<"ERROR! Unable to find an Atrail for the given code"<<std::endl;
				return 1;
			}
		} else
		{
			std::cerr<<"ERROR! Invalid edge code..., aborting with error"<<std::endl;
			return 3;
		}
	}
}