summaryrefslogtreecommitdiff
path: root/tools/ltgrey.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-30 04:55:41 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-30 04:55:41 (GMT)
commit67eb4c6c804c728db329a7f4a77d5a3cbd1b993c (patch)
tree1d28e818ca5ae77ab586267b2e90f8b74fb398c0 /tools/ltgrey.c
parent292a76b35fd16cf11613f79ea38693449e3317f6 (diff)
get40 seems to be working
Diffstat (limited to 'tools/ltgrey.c')
-rw-r--r--tools/ltgrey.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/tools/ltgrey.c b/tools/ltgrey.c
index c9f384f..7a63b04 100644
--- a/tools/ltgrey.c
+++ b/tools/ltgrey.c
@@ -16,10 +16,7 @@ void scan(const string progid, const string p, const int copies=1);
int main(int _argc, char** _argv){
- char* namevar;
std::string hostname;
- char* ipvar;
- std::string ipbase;
std::string ipname;
mypid = getpid();
@@ -29,27 +26,35 @@ int main(int _argc, char** _argv){
whatsit foo(argv[0], parent_dir); argc--; argv++;
int scanmode(0);
int copies(1);
- int penalty(0);
+ int shift(0);
int stain(0);
- int dnscheck(0);
+ int dns_mode(0);
+ string get40_mid;
while (argc > 0) {
string arg = argv[0]; argc--; argv++;
if (prefix(arg, "-scan")) {
scanmode++;
- } else if (prefix(arg, "-copy")) {
+ } else if (prefix(arg, "-copy")) {
copies++;
- } else if (prefix(arg, "-verbose")) {
+ } else if (prefix(arg, "-verbose")) {
foo.verbosity++;
- } else if (prefix(arg, "-dnscheck")) {
- dnscheck++;
- } else if (prefix(arg, "-penalize")
- || prefix(arg, "-penalty")) {
+ } else if (prefix(arg, "-dns_mode")) {
+ dns_mode++;
+ } else if (prefix(arg, "-get40")) {
if (!argc){
cerr << "Option '" << arg << "' requires an argument" << endl;
exeunt(ex_syserr);
}
- penalty = atoi(*argv++); argc--;
- } else if (prefix(arg, "-stain")) {
+ get40_mid = *argv++; argc--;
+
+ } else if (prefix(arg, "-shift")
+ || prefix(arg, "-shift")) {
+ if (!argc){
+ cerr << "Option '" << arg << "' requires an argument" << endl;
+ exeunt(ex_syserr);
+ }
+ shift = atoi(*argv++); argc--;
+ } else if (prefix(arg, "-stain")) {
if (!argc){
cerr << "Option '" << arg << "' requires an argument" << endl;
exeunt(ex_syserr);
@@ -68,27 +73,28 @@ int main(int _argc, char** _argv){
}
if (foo.setup()) return ex_syserr;
-// dnscheck mode ...
-// Probably a better design would be to
-// (a) make more thorough DNS checks, and
-// (b) move all the DNS checking to a separate module
-
- ipvar = getenv("TCPREMOTEIP");
- if (ipvar) ipbase = ipvar;
- namevar = getenv("TCPREMOTEHOST");
- if (namevar) hostname = namevar;
-
- if (dnscheck) {
+// dns_mode mode ...
+// Probably it would be better to make more thorough DNS checks.
+//
+ if (dns_mode) {
+ char* ipvar = getenv("TCPREMOTEIP");
+ char* namevar = getenv("TCPREMOTEHOST");
exeunt(foo.check_dns(ipvar, namevar));
}
+ if (get40_mid.length()){
+ state_40 rslt = foo.get40(get40_mid);
+ cerr << foo.decode_40[rslt] << endl;
+ return 0;
+ }
+
if (scanmode) {
string dirname = parent_dir + "/quarante";
scan(foo.progid, dirname, copies);
return 0;
}
- int sts = foo.doit(penalty, stain);
+ int sts = foo.doit(shift, stain);
return sts;
}
@@ -116,7 +122,7 @@ void scan(const string progid, const string p, const int copies){
gettimeofday(&now, NULL);
using namespace boost::filesystem;
- if (is_directory(p)) {
+ if (is_directory(p)) {
for (directory_iterator itr(p); itr!=directory_iterator(); ++itr) {
string basename = itr->path().filename();
for (int ii = 0; ii < copies; ii++)