int cpp_main( int argc, char * argv[] )
{
  fs::initial_path();

  if ( argc > 1 && (std::strcmp( argv[1], "-help" ) == 0
    || std::strcmp( argv[1], "--help" ) == 0 ) )
  {
    std::clog << "Usage: inspect [-cvs] [options...]\n"
      "options:\n"
      << options();
    return 1;
  }

  bool license_ck = true;
  bool copyright_ck = true;
  bool crlf_ck = true;
  bool link_ck = true;
  bool long_name_ck = true;
  bool tab_ck = true;
  bool cvs = false;

  if ( argc > 1 && std::strcmp( argv[1], "-cvs" ) == 0 )
  {
    cvs = true;
    --argc; ++argv;
  }

  if ( argc > 1 && *argv[1] == '-' )
  {
    license_ck = false;
    copyright_ck = false;
    crlf_ck = false;
    link_ck = false;
    long_name_ck = false;
    tab_ck = false;
  }

  for(; argc > 1; --argc, ++argv )
  {
    if ( std::strcmp( argv[1], "-license" ) == 0 )
      license_ck = true;
    else if ( std::strcmp( argv[1], "-copyright" ) == 0 )
      copyright_ck = true;
    else if ( std::strcmp( argv[1], "-crlf" ) == 0 )
      crlf_ck = true;
    else if ( std::strcmp( argv[1], "-link" ) == 0 )
      link_ck = true;
    else if ( std::strcmp( argv[1], "-long_name" ) == 0 )
      long_name_ck = true;
    else if ( std::strcmp( argv[1], "-tab" ) == 0 )
      tab_ck = true;
    else
    {
      std::cerr << "unknown option: " << argv[1]
      << "\nvalid options are:\n"
      << options();
      return 1;
    }
  }

  inspector_list inspectors;

  if ( license_ck )
    inspectors.push_back( inspector_element( new boost::inspect::license_check ) );
  if ( copyright_ck )
    inspectors.push_back( inspector_element( new boost::inspect::copyright_check ) );
  if ( crlf_ck )
    inspectors.push_back( inspector_element( new boost::inspect::crlf_check ) );
  if ( link_ck )
    inspectors.push_back( inspector_element( new boost::inspect::link_check ) );
  if ( long_name_ck )
    inspectors.push_back( inspector_element( new boost::inspect::long_name_check ) );
  if ( tab_ck )
    inspectors.push_back( inspector_element( new boost::inspect::tab_check ) );

  // perform the actual inspection, using the requested type of iteration
  if ( cvs )
    visit_all<hack::cvs_iterator>( "boost-root",
      fs::initial_path(), inspectors );
  else
    visit_all<fs::directory_iterator>( "boost-root",
      fs::initial_path(), inspectors );

  // close
  for ( inspector_list::iterator itr = inspectors.begin();
        itr != inspectors.end(); ++itr )
  {
    itr->inspector->close();
  }

  char run_date[128];
  std::time_t tod;
  std::time( &tod );
  std::strftime( run_date, sizeof(run_date),
    "%X UTC, %A %d %B %Y", std::gmtime( &tod ) );

  std::cout << "<html>\n"
          "<head>\n"
          "<title>Boost Inspection Report</title>\n"
          "</head>\n"
          "<body bgcolor=\"#ffffff\" text=\"#000000\">\n"
          "<table border=\"0\">\n"
          "<tr>\n"
          "<td><img border=\"0\" src=\"../boost.png\" width=\"277\" "
          "height=\"86\"></td>\n"
          "<td align=\"center\">\n"
          "<h1>Boost Inspection Report</h1>\n"
          "<b>Run Date:</b> " << run_date  << "\n"
          "</td>\n"
          "</table>\n"
          "<p>An <a href=\"http://www.boost.org/tools/inspect/index.html\">inspection\n" 
          "program</a> checks each file in the current Boost CVS for various problems,\n" 
          "generating this web page as output. Problems detected include tabs in files,\n" 
          "missing copyrights, broken URL's, and similar misdemeanors.</p>\n"
          ;

  std::cout << "<h2>Totals</h2>\n<pre>"
            << file_count << " files scanned\n"
            << directory_count << " directories scanned\n"
            << error_count << " problems reported\n";

  std::cout << "\nproblem counts:\n";

  for ( inspector_list::iterator itr = inspectors.begin();
        itr != inspectors.end(); ++itr )
  {
    itr->inspector.reset();
  }

  std::sort( msgs.begin(), msgs.end() );

  if ( !msgs.empty() )
  {
    display_summary();
    display_details();
  }

  std::cout << "</body>\n"
               "</html>\n";
  return 0;
}
Beispiel #2
0
int cpp_main( int argc, char * argv[] )
{
    fs::initial_path();

    if ( argc > 1 && (std::strcmp( argv[1], "-help" ) == 0
                      || std::strcmp( argv[1], "--help" ) == 0 ) )
    {
        std::clog << "Usage: inspect [-cvs] [options...]\n"
        "options:\n"
        << options();
        return 1;
    }

    bool license_ck = true;
    bool copyright_ck = true;
    bool crlf_ck = true;
    bool link_ck = true;
    bool long_name_ck = true;
    bool tab_ck = true;
    bool minmax_ck = true;
    bool cvs = false;

    if ( argc > 1 && std::strcmp( argv[1], "-cvs" ) == 0 )
    {
        cvs = true;
        --argc;
        ++argv;
    }

    if ( argc > 1 && *argv[1] == '-' )
    {
        license_ck = false;
        copyright_ck = false;
        crlf_ck = false;
        link_ck = false;
        long_name_ck = false;
        tab_ck = false;
        minmax_ck = false;
    }

    for (; argc > 1; --argc, ++argv )
    {
        if ( std::strcmp( argv[1], "-license" ) == 0 )
            license_ck = true;
        else if ( std::strcmp( argv[1], "-copyright" ) == 0 )
            copyright_ck = true;
        else if ( std::strcmp( argv[1], "-crlf" ) == 0 )
            crlf_ck = true;
        else if ( std::strcmp( argv[1], "-link" ) == 0 )
            link_ck = true;
        else if ( std::strcmp( argv[1], "-long_name" ) == 0 )
            long_name_ck = true;
        else if ( std::strcmp( argv[1], "-tab" ) == 0 )
            tab_ck = true;
        else if ( std::strcmp( argv[1], "-minmax" ) == 0 )
            minmax_ck = true;
        else
        {
            std::cerr << "unknown option: " << argv[1]
                      << "\nvalid options are:\n"
                      << options();
            return 1;
        }
    }

    inspector_list inspectors;

    if ( license_ck )
        inspectors.push_back( inspector_element( new boost::inspect::license_check ) );
    if ( copyright_ck )
        inspectors.push_back( inspector_element( new boost::inspect::copyright_check ) );
    if ( crlf_ck )
        inspectors.push_back( inspector_element( new boost::inspect::crlf_check ) );
    //if ( link_ck )
    //inspectors.push_back( inspector_element( new boost::inspect::link_check ) );
    if ( long_name_ck )
        inspectors.push_back( inspector_element( new boost::inspect::long_name_check ) );
    if ( tab_ck )
        inspectors.push_back( inspector_element( new boost::inspect::tab_check ) );
    if ( minmax_ck )
        inspectors.push_back( inspector_element( new boost::inspect::minmax_check ) );

    // perform the actual inspection, using the requested type of iteration
    if ( cvs )
        visit_all<hack::cvs_iterator>( "lifev-root",
                                       fs::initial_path(), inspectors );
    else
        visit_all<fs::directory_iterator>( "lifev-root",
                                           fs::initial_path(), inspectors );

    // close
    for ( inspector_list::iterator itr = inspectors.begin();
            itr != inspectors.end(); ++itr )
    {
        itr->inspector->close();
    }

    char run_date[128];
    std::time_t tod;
    std::time( &tod );
    std::strftime( run_date, sizeof(run_date),
                   "%X UTC, %A %d %B %Y", std::gmtime( &tod ) );

    std::cout << "<html>\n"
              "<head>\n"
              "<title>LifeV Inspection Report</title>\n"
              "<style type=\"text/css\">\n"
              << css_style() <<
              "</style>\n"
              "</head>\n"
              "<body bgcolor=\"#ffffff\" text=\"#000000\">\n"
              "<h1>LifeV Inspection Report(95% based on Boost Inspection tool)</h1>\n"
              "<p><b>Run Date:</b> " << run_date  << "</p>\n"
              "<h2>Introduction</h2>\n"
              "<p>The <a href=\"http://www.boost.org/tools/inspect/index.html\">inspection\n"
              "program</a> checks each file in the current Life CVS for various problems,\n"
              "generating this web page as output. Problems detected include tabs in files,\n"
              "missing copyrights, broken URL's, and similar misdemeanors.</p>\n";

    std::cout <<
              "<p> Differences between <tt>LifeV::inspect</tt> and <tt>boost::inspect</tt>\n"
              "<ul>\n"
              "<li>LifeV::inspect is good looking thanks to proper css usage :)</li>\n"
              "<li>LifeV::inspect does not check in admin, Templates and autom4te.cache</li>\n"
              "<li>LifeV::inspect checks for GPL and LGPL presence in header and not Boost License</li>\n"
              "<li>LifeV::inspect does not check for links</li>\n"
              "</ul>\n";

    std::cout << "<h2>Totals</h2>\n<pre>"
              << file_count << " files scanned\n"
              << directory_count << " directories scanned\n"
              << error_count << " problems reported\n";

    std::cout << "\nproblem counts:\n";

    for ( inspector_list::iterator itr = inspectors.begin();
            itr != inspectors.end(); ++itr )
    {
        itr->inspector.reset();
    }

    std::sort( msgs.begin(), msgs.end() );

    if ( !msgs.empty() )
    {
        display_summary();
        display_details();
    }

    std::cout << "</body>\n"
              "</html>\n";
    return 0;
}