diff options
| author | Petr Machata <[email protected]> | 2010-08-17 19:34:12 +0200 |
|---|---|---|
| committer | Petr Machata <[email protected]> | 2010-08-18 14:55:18 +0200 |
| commit | 3c5d0c0fc4671e32c05d0050959251fc16958e21 (patch) | |
| tree | 5c7e8c315344b9f85afe89d3be2ec45d1bd1835a /dwarflint/dwarflint.cc | |
| parent | 566dd3f1f4c73e683e5a248da9785e21c47f9a16 (diff) | |
Move dwarflint to separate directory
Diffstat (limited to 'dwarflint/dwarflint.cc')
| -rw-r--r-- | dwarflint/dwarflint.cc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/dwarflint/dwarflint.cc b/dwarflint/dwarflint.cc new file mode 100644 index 00000000..3e23ec23 --- /dev/null +++ b/dwarflint/dwarflint.cc @@ -0,0 +1,70 @@ +/* Dwarflint check scheduler. + Copyright (C) 2008,2009 Red Hat, Inc. + This file is part of Red Hat elfutils. + + Red Hat elfutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by the + Free Software Foundation; version 2 of the License. + + Red Hat elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with Red Hat elfutils; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. + + Red Hat elfutils is an included package of the Open Invention Network. + An included package of the Open Invention Network is a package for which + Open Invention Network licensees cross-license their patents. No patent + license is granted, either expressly or impliedly, by designation as an + included package. Should you wish to participate in the Open Invention + Network licensing program, please visit www.openinventionnetwork.com + <http://www.openinventionnetwork.com>. */ + +#include "dwarflint.hh" +#include "messages.h" +#include "checks.hh" + +#include <fcntl.h> +#include <cstring> +#include <cerrno> +#include <stdexcept> +#include <sstream> + +namespace +{ + int + get_fd (char const *fname) + { + /* Open the file. */ + int fd = open (fname, O_RDONLY); + if (fd == -1) + { + std::stringstream ss; + ss << "Cannot open input file: " << strerror (errno) << "."; + throw std::runtime_error (ss.str ()); + } + + return fd; + } +} + +dwarflint::dwarflint (char const *a_fname) + : _m_fname (a_fname) + , _m_fd (get_fd (_m_fname)) +{ + check_registrar::inst ()->enroll (*this); +} + +dwarflint::~dwarflint () +{ + if (close (_m_fd) < 0) + // Not that we can do anything about it... + wr_error () << "Couldn't close the file " << _m_fname << ": " + << strerror (errno) << "." << std::endl; + for (check_map::const_iterator it = _m_checks.begin (); + it != _m_checks.end (); ++it) + delete it->second; +} |
