2008-08-08 12:35:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 Andrew Garrett.
|
|
|
|
* Copyright (c) 2008 River Tarnell <river@wikimedia.org>
|
|
|
|
* Derived from public domain code contributed by Victor Vasiliev.
|
|
|
|
*
|
|
|
|
* Permission is granted to anyone to use this software for any purpose,
|
|
|
|
* including commercial applications, and to alter it and redistribute it
|
|
|
|
* freely. This software is provided 'as-is', without any express or
|
|
|
|
* implied warranty.
|
|
|
|
*/
|
|
|
|
|
2008-08-07 14:35:45 +00:00
|
|
|
#include <cstdlib>
|
2008-07-31 16:28:24 +00:00
|
|
|
#include <iostream>
|
2008-08-08 00:01:22 +00:00
|
|
|
#include <iterator>
|
2008-07-31 16:28:24 +00:00
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
2008-08-07 13:53:18 +00:00
|
|
|
#include <fstream>
|
2008-07-31 16:28:24 +00:00
|
|
|
#include <map>
|
2008-08-07 14:43:26 +00:00
|
|
|
#include <cerrno>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include <boost/format.hpp>
|
2008-08-08 00:01:22 +00:00
|
|
|
#include <boost/next_prior.hpp>
|
2008-07-31 16:28:24 +00:00
|
|
|
|
2008-08-08 00:01:22 +00:00
|
|
|
#include "request.h"
|
2008-07-29 11:03:26 +00:00
|
|
|
|
|
|
|
int main( int argc, char** argv ) {
|
2008-08-10 03:52:17 +00:00
|
|
|
afp::request r;
|
|
|
|
|
2008-07-31 16:28:24 +00:00
|
|
|
while (true) {
|
2008-08-08 00:01:22 +00:00
|
|
|
bool result = false;
|
2008-07-31 16:28:24 +00:00
|
|
|
|
|
|
|
try {
|
2008-08-07 14:43:26 +00:00
|
|
|
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);
|
2008-08-08 00:01:22 +00:00
|
|
|
return 0;
|
2008-08-07 14:43:26 +00:00
|
|
|
}
|
|
|
|
|
2008-08-08 00:01:22 +00:00
|
|
|
if (!r.load(inf))
|
|
|
|
return 0;
|
2008-08-07 14:43:26 +00:00
|
|
|
} else {
|
2008-08-08 00:01:22 +00:00
|
|
|
if (!r.load(std::cin))
|
|
|
|
return 0;
|
2008-08-07 14:43:26 +00:00
|
|
|
}
|
|
|
|
|
2008-08-08 00:01:22 +00:00
|
|
|
result = r.evaluate();
|
2008-08-08 03:23:34 +00:00
|
|
|
} catch (afp::exception &excep) {
|
|
|
|
std::cerr << "EXCEPTION: " << excep.what() << std::endl;
|
2008-07-31 16:28:24 +00:00
|
|
|
}
|
|
|
|
|
2008-08-08 03:23:34 +00:00
|
|
|
std::cout << ( result ? "MATCH\n" : "NOMATCH\n" );
|
2008-07-31 16:28:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|