⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bk2site.c

📁 一百个病毒的源代码 包括熊猫烧香等 极其具有研究价值
💻 C
📖 第 1 页 / 共 2 页
字号:
					cerr << "ERROR: Could not open " << configFile << endl;					return 1;				};	    }	}	//now read the command line arguments.	for (int i = 1; i < argc; i++){		string s(argv[i]);		if (s == "-nd") {	    varValues[SUBDIRSEP] = "_";	    varValues[BACKDIRSEP] ="";		}		else if (s == "-ns"){			generateSite = 0;		}		else if (s == "-nc"){			varValues[COMMENTS] = "no";		}		else if (s == "-d")	    if (++i < argc)				varValues[DESTDIR] = argv[i];	    else 				printUsage(argv[0]);		else if (s == "-t")	    if (++i < argc)				varValues[TOPFOLDER] = argv[i];	    else				printUsage(argv[0]);		else if (s == "-f1")	    if (++i < argc)				varValues[INDEXFILENAME] = argv[i];	    else				printUsage(argv[0]);		else if (s == "-f2")	    if (++i < argc)				varValues[OTHERFILENAME] = argv[i];	    else				printUsage(argv[0]);		else if (s == "-old")	    if (++i < argc){				varValues[TIMECUTOFF] = argv[i];	    }	    else				printUsage(argv[0]);		else if (s == "-o")	    if (++i < argc){	      varValues[OUTPUTBOOKMARKFILE] = argv[i];	    }	    else				printUsage(argv[0]);		else if (s == "-xbel")	    if (++i < argc){				xbelFileName = argv[i];	    }	    else				printUsage(argv[0]);		else if (s == "-f") {	    ++i;	    continue;		}		else if (s == "-bf") {	    if (++i < argc)				varValues[BOOKMARKFILE] = argv[i];	    else				printUsage(argv[0]);		}		else if ((s == "-h") || (s == "--help") || (s == "-help") || (s == "-v")) {			printUsage(argv[0]);		}		else {			if (numBookmarkfiles == 0){				varValues[BOOKMARKFILE] = s;			}			else				bookmarkfiles.push_back(s);			numBookmarkfiles++;		}	}	int last;	if (varValues[DESTDIR] == "")  		varValues[DESTDIR] = "/home/httpd/html/";	last = varValues[DESTDIR].length() -1;	if (varValues[DESTDIR][last] != '/') varValues[DESTDIR] = varValues[DESTDIR] + "/";	if (varValues[BOOKMARKFILE] == "")		varValues[BOOKMARKFILE] = homeDir + "/.netscape/bookmarks.html";	last =varValues[SEARCHTOROOTPATH].length() -1;	if (varValues[SEARCHTOROOTPATH][last] != '/') 		varValues[SEARCHTOROOTPATH] =  varValues[SEARCHTOROOTPATH] + "/";	referenceTree rt;    	//    for (int i = 0; i <= NUMVARS; i++)	//	cout << varNames[i] << "\t" << varValues[i] << endl;	if (varValues[BOOKMARKFILE] != "") {		iwebstream istream(varValues[BOOKMARKFILE].c_str(), ios::in);		if (istream == 0){			cout << "Could not open " << varValues[BOOKMARKFILE] << endl;			return 1;		}		cout << "Reading " << varValues[BOOKMARKFILE] << endl;		istream >> rt;		cout << "Total Bookmarks in file= " << rt.getNumLeafs() << endl;	}	//    cout << rt;	referenceTree * myrt = rt.getSubtree(varValues[TOPFOLDER]);	if (myrt == 0) {		cerr << "ERROR: " << varValues[TOPFOLDER] << " not found in " << varValues[BOOKMARKFILE] << endl;		return 1;	}	//ugly hack to append the top folder title to the tree.	// we must undo this hack after all the merges.	referenceTree myrtTemp;	reference refTemp;	if (varValues[TOPFOLDER] != ""){		refTemp.title = varValues[TOPFOLDER];		refTemp.children = myrt;		refTemp.folder = true;		refTemp.aliasOf = "";		refTemp.priv = false;		myrtTemp.addReference(refTemp); //adds a copy of refTemp?, myrtTemp is a copy of myrt with new root.		myrt = &myrtTemp;		myrt->fixNumChildren();	}	//Merge all the other trees in	for (vector<string>::const_iterator fn = bookmarkfiles.begin(); fn != bookmarkfiles.end(); fn++){		referenceTree ort;		const string & bfname = * fn;		iwebstream obf(bfname.c_str(), ios::in);		if (obf == 0){			cout << "Could not open " << bfname << endl;			return 1;		}		cout << "Reading " << bfname << endl;		obf >> ort;		cout << "Total Bookmarks in file = " << ort.getNumLeafs()<< endl;		cout << "Merging " << bfname << " into main tree." << endl;		myrt->merge(ort);		cout << "Total Bookmarks in merged file = " << myrt->getNumLeafs() << endl;	} 	//undo the ugly hack	if (varValues[TOPFOLDER] != ""){		myrt = myrt->getFirstGrandchild();		refTemp.children = 0;	}	//read the urllog file if needed	if (varValues[URLLOGFILE] != ""){ 		iwebstream istream(varValues[URLLOGFILE].c_str(), ios::in);		vector<string> theURLS;		vector<time_t> theTimes;		if (istream == 0){ //If file exists but is empty			cout << "Could not open " << varValues[URLLOGFILE] << " for reading." << endl;		}		else {			cout << "Reading " << varValues[URLLOGFILE] << endl;			time_t curTime;			time_t cutoffTime = time(0) - atoi(varValues[HITSTIMECUTOFF].c_str());			string currentURL = "";			while (!(istream.eof())){				istream >> curTime;				istream >> currentURL;				//	    cout << curTime << "-" << currentURL << endl;				//       if (('0' <= currentURL[0] ) && ('9' >= currentURL[0])) { //starts with a num, then its not a URL				// 	int numhits = atoi(currentURL.c_str());				// 	myrt->increaseHits(oldURL, numhits - 1); //we already added 1				//       }				//       else				// 	myrt->increaseHits(currentURL, 1);				//       oldURL = currentURL;				//if url starts with a number (its a time) or url is null				//  keep trying to read a time/url pair.				while (((currentURL[0] >= '0' && currentURL[0] <= '9') || currentURL == "") && !istream.eof()){					curTime = atoi(currentURL.c_str());					istream >> currentURL;				}	    				if (curTime >= cutoffTime){					channels.increaseHits(currentURL, 1);					myrt->increaseHits(currentURL, 1);					theURLS.push_back(currentURL);					theTimes.push_back(curTime);				}			}			//write out only the ones after cutoffTime;			istream.close();		}		ofstream ostream(varValues[URLLOGFILE].c_str(), ios::out);		cout << "Opening " << varValues[URLLOGFILE] << " for writing" << endl;		if (ostream == 0){	    cout << "Could not open " << varValues[URLLOGFILE] << " for writing" << endl;	    return 1;		}		for (unsigned int i=0; i < theURLS.size(); i++)	    ostream << theTimes[i] << "\t" << theURLS[i] << endl;		ostream.close();	}	//Fix Aliases.	myrt->fixAliases(myrt, "", varValues, "");	//Set the creationtime for the folders to be the max of creation time of descendants	// or children.	if (varValues[FOLDERCREATION] == "maxdescendants")		myrt->setFolderCreationToMaxDescendant();	else if (varValues[FOLDERCREATION] == "maxchildren")		myrt->setFolderCreationToMaxChildren();	if (generateSite){		myrt->createSite(varValues, channels);		for (unsigned int ne = 0; ne < extraFileName.size(); ne++) 			myrt->createPage(extraFileBase[ne], varValues[DESTDIR] + extraFileName[ne], varValues, channels);	}	//write out the bookmark file    	if (varValues[OUTPUTBOOKMARKFILE] != "") {		ofstream otstream(varValues[OUTPUTBOOKMARKFILE].c_str(), ios::out);		cout << "Opening " << varValues[OUTPUTBOOKMARKFILE] << " for writing" << endl;		if (otstream == 0){			cout << "Could not open " << varValues[OUTPUTBOOKMARKFILE] << " for writing" << endl;			return 1;		}		myrt->writeAsBookmarkFile(otstream, varValues[TITLE]);	}	//write out the xbel file    	if (xbelFileName != "") {		ofstream otstream(xbelFileName.c_str(), ios::out);		cout << "Opening " << xbelFileName << " for writing" << endl;		if (otstream == 0){			cout << "Could not open " << xbelFileName << " for writing" << endl;			return 1;		}		myrt->writeAsXBELFile(otstream, varValues[TITLE]);	}	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -