mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-29 00:10:26 +00:00
1912d62d09
- rewrote parser to use boost.spirit instead of a hand-written parser - refactored request loading into 'request' object - added 'expr', a command-line tool to test the new parser - some performance fixes for affunctions
46 lines
805 B
C++
Executable file
46 lines
805 B
C++
Executable file
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <iterator>
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <fstream>
|
|
#include <map>
|
|
#include <cerrno>
|
|
#include <cstring>
|
|
|
|
#include <boost/format.hpp>
|
|
#include <boost/next_prior.hpp>
|
|
|
|
#include "request.h"
|
|
|
|
int main( int argc, char** argv ) {
|
|
while (true) {
|
|
request r;
|
|
bool result = false;
|
|
|
|
try {
|
|
if (argv[1]) {
|
|
std::ifstream inf(argv[1]);
|
|
if (!inf) {
|
|
std::cerr << boost::format("%s: %s: %s\n")
|
|
% argv[0] % argv[1] % std::strerror(errno);
|
|
return 0;
|
|
}
|
|
|
|
if (!r.load(inf))
|
|
return 0;
|
|
} else {
|
|
if (!r.load(std::cin))
|
|
return 0;
|
|
}
|
|
|
|
result = r.evaluate();
|
|
} catch (AFPException &excep) {
|
|
cerr << "EXCEPTION: " << excep.what() << endl;
|
|
}
|
|
|
|
cout << ( result ? "MATCH\n" : "NOMATCH\n" );
|
|
}
|
|
}
|
|
|