📄 registryana.cpp
字号:
#include <fstream>#include <iostream>#include <cstdlib>#include <cstring>#include "Segment.h"#include "RegistryAna.h"using namespace std;// The macro __GNUG__ is set for GNU C++#ifdef __GNUG__#include <unistd.h> // for access()#else#include <io.h> // for _access()#endifRegistryAna::RegistryAna() { dbPath ="";}void RegistryAna::setDbPath(string pathapp) { dbPath = pathapp;}// 1 - success, 0 - failureint RegistryAna::searcher(string tosearch){ char filename[64], buffer[1024], command[128], tempFilename[9]; int lineno, hits = 0, files = 0, system_command_status; ifstream fin1, fin2; const char* searchapp = tosearch.c_str(); string newpath = dbPath + "6bone.db"; fin1.open(newpath.c_str()); if (fin1.peek() == EOF) { fin1.clear(); fin1.open("/etc/6bone.db"); if (fin1.peek() == EOF) { cerr << "Error : 6bone.db file not found...!\n"<< "Insert the 6bone.db in the directory where tunneltrace\n"<< "is running or in the directory /etc\n"; // exit (-4);//cambiare non deve uscire ma continuare esecuzione } } if (fin1.peek()!=EOF) { lineno = 0; fin1.clear(); fin1.seekg(0L, ios::beg); while (fin1.getline(buffer,sizeof(buffer))) { lineno++; if (strstr(buffer,searchapp)) hits++; } } fin1.close(); return hits;}// 1 - success , 0 - failure//i need the two hostnames to look into 6bone.dbint RegistryAna::searchDB(Segment s1) { string tothostname; if (s1.getHostnamein()!="" && s1.getHostnameout()!="") { tothostname = s1.getHostnamein() + " -> " + s1.getHostnameout(); if (searcher(tothostname)==0) { tothostname = s1.getHostnameout() + " -> " + s1.getHostnamein(); } return searcher(tothostname); } else return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -