Skip to content

Instantly share code, notes, and snippets.

@liuyanghejerry
Created October 12, 2013 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuyanghejerry/6949039 to your computer and use it in GitHub Desktop.
Save liuyanghejerry/6949039 to your computer and use it in GitHub Desktop.
Calculate how many different IP in painttyServer's log.
#include <QCoreApplication>
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
#include <QStringList>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
while(argc-- > 1){
QFile file(QString::fromLocal8Bit(argv[argc]));
bool is_open = file.open(QIODevice::ReadOnly);
if(!is_open){
qDebug()<<"Cannot open file!";
return 0;
}
QTextStream stream(&file);
QStringList list;
while(!stream.atEnd()){
QString line = stream.readLine();
line = line.remove(0, 78);
list.append(line);
}
list.removeDuplicates();
QFileInfo fi(file.fileName());
qDebug()<<fi.fileName()<<"has"<<list.length()<<"different IP.";
}
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment