bool testBase64()
{
    printf("######### Base64 Out ############\n");
    Inkscape::URI plainInUri(xmlpath);
    Inkscape::IO::UriInputStream ins1(plainInUri);

    Inkscape::URI b64OutUri("crystalegg.xml.b64");
    Inkscape::IO::UriOutputStream outs1(b64OutUri);
    Inkscape::IO::Base64OutputStream b64Outs(outs1);

    pipeStream(ins1, b64Outs);

    ins1.close();
    b64Outs.close();

    printf("######### Base64 In ############\n");
    Inkscape::URI b64InUri("crystalegg.xml.b64");
    Inkscape::IO::UriInputStream ins2(b64InUri);
    Inkscape::IO::Base64InputStream b64Ins(ins2);

    Inkscape::URI plainOutUri("crystalegg.xml.b64dec");
    Inkscape::IO::UriOutputStream outs2(plainOutUri);

    pipeStream(b64Ins, outs2);

    outs2.close();
    b64Ins.close();

    return true;
}
Exemple #2
0
unsigned int svstatus_print(char *m) {
  int pid;
  int normallyup =0;
  struct stat s;
 
  if (stat("down", &s) == -1) {
    if (errno != error_noent) {
      outs2(WARN); outs2("unable to stat "); outs2(*service); outs2("/down: ");
      outs2(error_str(errno)); flush2("\n");
      return(0);
    }
    normallyup =1;
  }
  pid =(unsigned char) svstatus[15];
  pid <<=8; pid +=(unsigned char)svstatus[14];
  pid <<=8; pid +=(unsigned char)svstatus[13];
  pid <<=8; pid +=(unsigned char)svstatus[12];
  tai_unpack(svstatus, &tstatus);
  switch (svstatus[19]) {
  case 0: outs(DOWN); break;
  case 1: outs(RUN); break;
  case 2: outs(FINISH); break;
  }
  outs(m); outs(": ");
  if (svstatus[19]) {
    outs("(pid "); sulong[fmt_ulong(sulong, pid)] =0;
    outs(sulong); outs(") ");
  }
  buffer_put(buffer_1, sulong,
    fmt_ulong(sulong, tnow.sec.x < tstatus.x ? 0 : tnow.sec.x -tstatus.x));
  outs("s");
  if (pid && !normallyup) outs(", normally down");
  if (!pid && normallyup) outs(", normally up");
  if (pid && svstatus[16]) outs(", paused");
  if (!pid && (svstatus[17] == 'u')) outs(", want up");
  if (pid && (svstatus[17] == 'd')) outs(", want down");
  if (pid && svstatus[18]) outs(", got TERM");
  return(pid ? 1 : 2);
}
Exemple #3
0
void flush2(const char *s) { outs2(s); buffer_flush(buffer_2); }
Exemple #4
0
int checkscript() {
  char *prog[2];
  struct stat s;
  int pid, w;

  if (stat("check", &s) == -1) {
    if (errno == error_noent) return(1);
    outs2(WARN); outs2("unable to stat "); outs2(*service); outs2("/check: ");
    outs2(error_str(errno)); flush2("\n");
    return(0);
  }
  /* if (!(s.st_mode & S_IXUSR)) return(1); */
  if ((pid =fork()) == -1) {
    outs2(WARN); outs2("unable to fork for "); outs2(*service);
    outs2("/check: "); outs2(error_str(errno)); flush2("\n");
    return(0);
  }
  if (!pid) {
    prog[0] ="./check";
    prog[1] =0;
    close(1);
    execve("check", prog, environ);
    outs2(WARN); outs2("unable to run "); outs2(*service); outs2("/check: ");
    outs2(error_str(errno)); flush2("\n");
    _exit(0);
  }
  while (wait_pid(&w, pid) == -1) {
    if (errno == error_intr) continue;
    outs2(WARN); outs2("unable to wait for child "); outs2(*service);
    outs2("/check: "); outs2(error_str(errno)); flush2("\n");
    return(0);
  }
  return(!wait_exitcode(w));
}
void XMLScannerTest::run()
{
		//create a dummy map with a fakie f*****g modulewhateverinfo....
	std::vector<std::pair<std::string, std::string> > outs(1);
	std::vector<std::pair<std::string, std::string> > ins(0);
	std::pair<std::string, std::string> outpair("typ_string", "String");
	outs[0] = outpair;
	
	//Xpm dummy(dummyXpm, strlen(dummyXpm)+1);
	ModuleInfo* mi = new ModuleInfo("mod_stringModule", "String", 
								    ins, outs, true);

	
	std::vector<std::pair<std::string, std::string> > outs2(0);
	std::vector<std::pair<std::string, std::string> > ins2(1);
	std::pair<std::string, std::string> inpair("typ_framebuffer", "Bild");
	ins2[0] = inpair; 
	ModuleInfo* mi2 = new ModuleInfo("mod_glOutputModule", "GLoutput" , 
								    ins, outs, false);

	std::vector<std::pair<std::string, std::string> > outs3(1);
	std::vector<std::pair<std::string, std::string> > ins3(3);
	
	std::pair<std::string, std::string> inpair2("typ_number","Zahl");
	
	ins3[0] = inpair2; 
	ins3[1] = inpair2;
	ins3[2] = inpair;

	outs3[0] = inpair;

	ModuleInfo* mi3 = new ModuleInfo("mod_tunnelModule", "Tunnel" , 
								    ins, outs, false);

	
	std::map<int, ModuleInfo*> mi_map;
	mi_map[0] = mi;
	mi_map[1] = mi2;	
	mi_map[2] = mi3;

	//create storage room for the listener
	std::map<std::string, int> infos;
	std::map<std::string, std::pair<int,int> > nodes;
	std::map<int, std::string>  nodeIDs;
	std::map<std::string, std::pair<int,int> > controls;
	std::map<int, std::string> controlIDs;
	std::map<std::pair<int,int>, std::pair<int,int> > conns;
	std::map<std::pair<int,int>, std::pair<int,int> > ctrlconns;

	//create an xmlListener with that dummyinfo
	XMLTokenListener horcher(mi_map, infos, nodes, nodeIDs, controls, controlIDs, conns, ctrlconns);
	XMLFileScanner gucker(horcher);
	std::ifstream ifs("testCorrect.graph");
	if(ifs==0)
		std::cout<<"File not found \n";
	std::string testTextCorrect;	

	char tmp;
	while(ifs.get(tmp))
	{
		testTextCorrect += tmp;
	}

	gucker.scan(testTextCorrect);


	//eine datei ohne <model>
	//std::cout<<"Processing incorrect file 1...\n";
	std::ifstream ifs1("testInCorrect1.graph");
	if(ifs1==0)
		std::cout<<"File not found \n";
	std::string testTextInCorrect1;	
	while(ifs.get(tmp))
	{
		testTextInCorrect1 += tmp;
	}

	try
	{
		gucker.scan(testTextInCorrect1);
	}
	catch(std::runtime_error err)
	{
		//if(err.what() !=  "This is no Ge-Phex Graph file...go f**k your dog!!!")
		//	throw std::runtime_error(err.what());
		//std::cout<<err.what()<<std::endl;
		
	}


	//eine datei ohne </model>, ja, ich weiss, kreativ...
	//std::cout<<"Processing incorrect file 2...\n";
	std::ifstream ifs2("testInCorrect2.graph");
	if(ifs2==0)
		std::cout<<"File not found \n";
	std::string testTextInCorrect2;	
	while(ifs2.get(tmp))
	{
		testTextInCorrect2 += tmp;
	}

	try
	{
		gucker.scan(testTextInCorrect2);
	}
	catch(std::runtime_error err)
	{
		//if(err.what() !=  "File has a wrong finishing tag...wrong format")
		//	throw std::runtime_error(err.what());
		
		//std::cout<<err.what()<<std::endl;
	}

	//eine datei mit fehlender node section
	//std::cout<<"Processing incorrect file 3...\n";
	std::ifstream ifs3("testInCorrect3.graph");
	if(ifs3==0)
		std::cout<<"File not found \n";
	std::string testTextInCorrect3;	


	while(ifs3.get(tmp))
	{
		testTextInCorrect3 += tmp;
	}
	
	try
	{
		gucker.scan(testTextInCorrect3);	
	}
	catch(std::runtime_error err)
	{
		//if(err.what() !=  "File has wrong format...section nodes")
		//	throw std::runtime_error(err.what());
		
		//std::cout<<err.what()<<std::endl;
	}		
}