//! Returns a Molecule object corresponding to the current contents of the //! $molecule section Molecule* MoleculeSection::getMolecule() { if (m_molecule == 0) { m_molecule = new Molecule(); m_molecule->setCoordinates(myDump()); qDebug() << "Creating new molecule from"; qDebug() << myDump(); qDebug() << "--------------------------"; } return m_molecule; }
int main(int argc,char *argv[]){ if(argc<2) usage(0); char *sourceURL=argv[1]; clock_t begin, end; int i=0; char *handleURL; int pos; UPU *tmp; URL_FILE *buf; char prefix[10],host[1024],path[4096],filename[4096]; for(i=0;i<HashSize;i++){ URLPool[i]=NULL; finishPool[i]=NULL; failedPool[i]=NULL; } memset(prefix,0,10); memset(host,0,1024); memset(path,0,4096); memset(filename,0,4096); sepURL(sourceURL,prefix,host,path,filename); //check/create Folder folderInit(host); readRec(sourceURL); //init if(!logInit(host)){ printf("log file error\n"); exit(1); } pos=hashfn(sourceURL); myAdd(&URLPool[pos],sourceURL,strlen(sourceURL)); //start loop begin=clock(); i=0; while(getPoolSize(URLPool)!=0){ //random get one URL Structure Pointer from URLPool handleURL=randGet(URLPool); pos=hashfn(handleURL); printf("run [%d] %s\n",pos,handleURL); memset(prefix,0,10); memset(host,0,1024); memset(path,0,4096); memset(filename,0,4096); sepURL(handleURL,prefix,host,path,filename); //put the url in finishPool tmp=finishPool[pos]; if(tmp==NULL){ myAdd(&finishPool[pos],handleURL,strlen(handleURL)); }else{ while(tmp->next!=NULL){ tmp=tmp->next; } myAdd(&(tmp->next),handleURL,strlen(handleURL)); } //start run the CURL if((buf=runCURL(handleURL))!=NULL){ //write to File myWrite(host,filename,buf->buffer,buf->buffer_len,i++); getURL(buf->buffer,buf->buffer_len,handleURL,prefix,host,path,filename); printf("%d\n",getPoolSize(URLPool)); memset(buf->buffer,0,buf->buffer_len); free(buf->buffer); fflush(logfp); } else{ printf("no content\n"); } free(buf); } logClose(); end=clock(); printf("finally finish: %d 's URL, cost %lf sec\n",getPoolSize(finishPool),(double)( end - begin ) / CLOCKS_PER_SEC); myDump(host); return 0; }
QString MoleculeSection::dump() { QString s("$molecule\n"); s += myDump(); s += "$end\n"; return s; }