Back to index

nordugrid-arc-nox  1.1.0~rc6
main.cpp
Go to the documentation of this file.
00001 #include "jura.h"
00002 
00003 #include <iostream>
00004 //TODO cross-platform
00005 #include <signal.h>
00006 #include <errno.h>
00007 #include <unistd.h>
00008 
00009 #ifdef WIN32
00010 #include <arc/win32.h>
00011 #endif
00012 
00013 #include "UsageReporter.h"
00014 
00015 
00016 int main(int argc, char **argv)
00017 {
00018 
00019   signal(SIGTTOU,SIG_IGN);
00020   signal(SIGTTIN,SIG_IGN);
00021 
00022   Arc::LogStream logcerr(std::cerr);
00023   logcerr.setFormat(Arc::ShortFormat);
00024   Arc::Logger::rootLogger.addDestination(logcerr);
00025 
00026   opterr=0;
00027   time_t ex_period = 0;
00028   std::list<std::string> urls;
00029   int n;
00030   while((n=getopt(argc,argv,":E:u:")) != -1) {
00031     switch(n) {
00032     case ':': { std::cerr<<"Missing argument\n"; return 1; }
00033     case '?': { std::cerr<<"Unrecognized option\n"; return 1; }
00034     case 'E': 
00035       {
00036         char* p;
00037         int i = strtol(optarg,&p,10);
00038         if(((*p) != 0) || (i<=0)) {
00039          std::cerr<<"Improper expiration period '"<<optarg<<"'"<<std::endl;
00040           exit(1);
00041         }
00042         ex_period=i*(60*60*24);
00043       } 
00044       break;
00045     case 'u':
00046       urls.push_back(std::string(optarg));
00047       break;
00048     default: { std::cerr<<"Options processing error\n"; return 1; }
00049     }
00050   }
00051 
00052   // The essence:
00053   int argind;
00054   Arc::UsageReporter *usagereporter;
00055   for (argind=optind ; argind<argc ; ++argind)
00056     {
00057       usagereporter=new Arc::UsageReporter(
00058                          std::string(argv[argind])+"/logs",
00059                        ex_period, urls );
00060       usagereporter->report();
00061       delete usagereporter;
00062     }
00063   return 0;
00064 }