Exemplo n.º 1
0
void printFrame(ODRFrame receivedFrame){
	char hostname[1024],sourceHost[1024],destHost[1024];
	memset(hostname,'\0',1024);
	memset(sourceHost, '\0', 1024);
	memset(destHost, '\0', 1024);
	gethostname(hostname,1023);
	getDomainName(receivedFrame.data.source, sourceHost);
	getDomainName(receivedFrame.data.destination, destHost);
	printf("ODR at node %s : sending frame hdr src %s dest ",hostname, hostname);
	printMacAddress(receivedFrame.header.destAddress);
	printf("\t\tODR msg type %d src %s dest %s \n",receivedFrame.header.packetType, sourceHost, destHost);
}
Exemplo n.º 2
0
STDMETHODIMP HostWrap::COMGETTER(DomainName)(BSTR *aDomainName)
{
    LogRelFlow(("{%p} %s: enter aDomainName=%p\n", this, "Host::getDomainName", aDomainName));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aDomainName);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = getDomainName(BSTROutConverter(aDomainName).str());
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave *aDomainName=%ls hrc=%Rhrc\n", this, "Host::getDomainName", *aDomainName, hrc));
    return hrc;
}
Exemplo n.º 3
0
int main()
{
    char url[200];
    char buf[BUFSIZ+1];

    int port = 80;

    struct sockaddr_in serverAddress;
    struct hostent* dnsResolved;
    printf("Enter the url to acces the images from\n");
    printf("Ex: http://www-archive.mozilla.org/quality/networking/testing/datatests.html\n");
    scanf("%s",url);
    printf("length of url is %d\n",strlen(url));
    char domainname[strlen(url)];
    char *page = (char *)malloc(strlen(url));
    //puts(url);
    getDomainName(url,domainname,page);
    printf("The domain name is %s\n",domainname);
        
    char *ip = (char *)malloc(strlen(url));
    char *isDomainName = strstr(domainname, "www");
    if(isDomainName != NULL)
    {
        getHostIP(domainname,&dnsResolved);
        ip = (char *)inet_ntoa(dnsResolved->h_addr_list[0]);//"127.0.0.1";
        printf("the Ip is %s\n",inet_ntoa(dnsResolved->h_addr_list[0]));
    }
    else
    {
        ip = domainname;
    }

    int sockid = createTcpSocket();
    assignAddressToSocket(sockid,&serverAddress,port,"127.0.0.1");

    connectSocket(sockid,(struct sockaddr *) &serverAddress,(int)sizeof(serverAddress));
    char *getQuery = build_get_query(ip,page);
    sendQuery(sockid,getQuery);
    fetchHtmlPage(sockid,buf);

    int status = closeSocket(sockid);    
    
    return 0;
    
}
Exemplo n.º 4
0
std::string dhcpOption15Check()
{
	char const* status;
	DWORD result;
	bool found = false;

	enumAdapters( [&found](IP_ADAPTER_INFO& info) {
		std::string domain = getDomainName( ATL::CA2W(info.AdapterName) );
		found = (domain.length() > 0);
		return !found;
	});

	if( found )
		status = "OK";
	else
		status = "can't find domain name suffix on any adapter";

	return std::string(status);
};
Exemplo n.º 5
0
void GeneOntology::writeOntologyFiles(){
	ostringstream theFile;
	theFile<<m_parameters->getPrefix()<<"/BiologicalAbundances/_GeneOntology";

	string directory=theFile.str();
	createDirectory(directory.c_str());

	theFile<<"/Terms";

	ostringstream xmlFileStream;
	xmlFileStream<<theFile.str()<<".xml";
	ostringstream tsvFileStream;
	tsvFileStream<<theFile.str()<<".tsv";

	string xmlFile=xmlFileStream.str();
	string tsvFile=tsvFileStream.str();

	if(!m_gotGeneOntologyParameter){
		return;
	}


	map<GeneOntologyIdentifier,int> modeCoverages;
	map<GeneOntologyIdentifier,double> meanCoverages;
	map<GeneOntologyIdentifier,double> estimatedProportions;



	ofstream xmlStream(xmlFile.c_str());
	ostringstream operationBuffer; //-------------

	cout<<"TOTAL: "<<m_kmerObservationsWithGeneOntologies<<endl;

	operationBuffer<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl;
	operationBuffer<<"<root>"<<endl;

	LargeCount totalForTheGraph=m_searcher->getTotalNumberOfColoredKmerObservationsForANameSpace(COLOR_NAMESPACE_EMBL_CDS);
	operationBuffer<<"<totalColoredKmerObservations>";
	operationBuffer<<totalForTheGraph<<"</totalColoredKmerObservations>"<<endl;

	// declare tsv files
	map<string,FILE*> tsvFiles;
	map<string,ostringstream*> tsvBuffers;



	for(map<GeneOntologyIdentifier,map<CoverageDepth,int> >::iterator i=
		m_ontologyTermFrequencies.begin();i!=m_ontologyTermFrequencies.end();i++){

		GeneOntologyIdentifier handle=i->first;

		int mode=0;
		int modeCount=0;
		int total=0;

		LargeCount totalObservations=0;

		for(map<CoverageDepth,int>::iterator j=i->second.begin();j!=i->second.end();j++){

			CoverageDepth coverage=j->first;
			int frequency=j->second;

			if(frequency>modeCount){
				mode=coverage;
				modeCount=frequency;
			}

			total+=frequency;

			totalObservations+=coverage*frequency;
		}

		double mean=totalObservations;

		if(total!=0){
			mean/=total;
		}
		
		#ifdef ASSERT
		assert(modeCoverages.count(handle)==0);
		assert(meanCoverages.count(handle)==0);
		#endif /**/

		modeCoverages[handle]=mode;
		meanCoverages[handle]=mean; /**/

		GeneOntologyDomain domain=getDomain(handle);
		string domainName=getDomainName(domain);

		operationBuffer<<"<geneOntologyTerm>"<<endl;
		operationBuffer<<"<identifier>";
		operationBuffer<<getGeneOntologyIdentifier(handle)<<"</identifier><name>";
		operationBuffer<<getGeneOntologyName(handle)<<"</name>"<<endl;
		operationBuffer<<"<domain>"<<domainName<<"</domain>"<<endl;

		/* print paths to root */
		printPathsFromRoot(handle,&operationBuffer);

		operationBuffer<<"<modeKmerCoverage>"<<mode<<"</modeKmerCoverage>";
		operationBuffer<<"<meanKmerCoverage>"<<mean<<"</meanKmerCoverage>"<<endl;
		operationBuffer<<"<totalColoredKmerObservations>"<<totalObservations<<"</totalColoredKmerObservations>"<<endl;

		double estimatedProportion=(0.0+totalObservations);

		if(totalForTheGraph!=0){
			estimatedProportion/=totalForTheGraph;
		}
		
		estimatedProportions[handle]=estimatedProportion;

		m_termCounts[handle]=totalObservations;

		operationBuffer<<"<proportion>"<<estimatedProportion<<"</proportion>"<<endl;
		operationBuffer<<"<distribution>"<<endl;

		operationBuffer<<"#Coverage	Frequency"<<endl;

		for(map<CoverageDepth,int>::iterator j=i->second.begin();j!=i->second.end();j++){

			CoverageDepth coverage=j->first;
			int frequency=j->second;

			operationBuffer<<coverage<<"	"<<frequency<<endl;
		}

		operationBuffer<<"</distribution></geneOntologyTerm>"<<endl;

		flushFileOperationBuffer(false,&operationBuffer,&xmlStream,CONFIG_FILE_IO_BUFFER_SIZE);


		// also output beautiful tsv file too


		if(tsvFiles.count(domainName)==0){
			ostringstream theFile;
			theFile<<m_parameters->getPrefix()<<"/BiologicalAbundances/";
			theFile<<"0.Profile.GeneOntologyDomain="<<domainName<<".tsv";
	
			string tsvFile=theFile.str();
			tsvFiles[domainName]=fopen(tsvFile.c_str(),"a");

			tsvBuffers[domainName]=new ostringstream();

			*(tsvBuffers[domainName])<<"#TermIdentifier	TermName	TermDomain	TermProportion"<<endl;
		}

		*(tsvBuffers[domainName])<<getGeneOntologyIdentifier(handle)<<"	";
		*(tsvBuffers[domainName])<<getGeneOntologyName(handle)<<"	";
		*(tsvBuffers[domainName])<<domainName;
		*(tsvBuffers[domainName])<<"	"<<estimatedProportion<<endl;

	}

	operationBuffer<<"</root>"<<endl;

	flushFileOperationBuffer(true,&operationBuffer,&xmlStream,CONFIG_FILE_IO_BUFFER_SIZE);

	xmlStream.close();

	ofstream tsvStream(tsvFile.c_str());

	operationBuffer<<"#Identifier	Name	Mode k-mer coverage	Mean k-mer coverage	Proportion"<<endl;


	// close tsv files
	for(map<string,FILE*>::iterator i=tsvFiles.begin();i!=tsvFiles.end();i++){
	
		string category=i->first;
		FILE*file=i->second;

		string text=tsvBuffers[category]->str();
		fprintf(file,"%s",text.c_str());

		delete tsvBuffers[category];

		fclose(file);
	}

	tsvBuffers.clear();
	tsvFiles.clear();



	for(map<GeneOntologyIdentifier,map<CoverageDepth,int> >::iterator i=
		m_ontologyTermFrequencies.begin();i!=m_ontologyTermFrequencies.end();i++){

		GeneOntologyIdentifier handle=i->first;

		operationBuffer<<getGeneOntologyIdentifier(handle)<<"	";
		operationBuffer<<getGeneOntologyName(handle)<<"	";
		operationBuffer<<modeCoverages[handle]<<"	";
		operationBuffer<<meanCoverages[handle]<<"	";
		operationBuffer<<estimatedProportions[handle]<<endl;

		flushFileOperationBuffer(false,&operationBuffer,&tsvStream,CONFIG_FILE_IO_BUFFER_SIZE);
	}

	flushFileOperationBuffer(true,&operationBuffer,&tsvStream,CONFIG_FILE_IO_BUFFER_SIZE);

	tsvStream.close();
}