Created
October 12, 2013 11:34
-
-
Save liuyanghejerry/6949039 to your computer and use it in GitHub Desktop.
Calculate how many different IP in painttyServer's log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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