Replace namespace name to klay 05/196505/1
authorJaemin Ryu <jm77.ryu@samsung.com>
Wed, 2 Jan 2019 02:09:59 +0000 (11:09 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Wed, 2 Jan 2019 02:09:59 +0000 (11:09 +0900)
Change-Id: I3db4e497a20b729883c01bc0272f420473c199da
Signed-off-by: Jaemin Ryu <jm77.ryu@samsung.com>
23 files changed:
src/audit/audit-trail.cpp
src/auth/group.cpp
src/auth/user.cpp
src/cgroup.cpp
src/db/connection.cpp
src/db/statement.cpp
src/dbus/connection.cpp
src/dbus/introspection.cpp
src/eventfd.cpp
src/file-user.cpp
src/filesystem.cpp
src/namespace.cpp
src/netlink/netlink.cpp
src/pam.cpp
src/process.cpp
src/rmi/client.cpp
src/rmi/message.cpp
src/rmi/notification.cpp
src/rmi/service.cpp
src/rmi/socket.cpp
src/xml/document.cpp
src/xml/node.cpp
src/xml/parser.cpp

index 0de4ac20f2546e9d90cd1e0d225b84b5c8032537..1b6a606fc0d7731bf1b38c1f1a6c899d4e3e3b7b 100644 (file)
@@ -39,7 +39,7 @@ void AuditTrail::stop()
        }
 }
 
-void AuditTrail::subscribe(const int fd, const runtime::Mainloop::Event events, runtime::Mainloop::Callback&& callback)
+void AuditTrail::subscribe(const int fd, const klay::Mainloop::Event events, klay::Mainloop::Callback&& callback)
 {
        mainloop.addEventSource(fd, events, std::move(callback));
 }
index b61aaf29eeb716887c2588e7c53460cf1884b0d1..e65cf3bc59cb558cc17c2b1164107c0e94f8bedd 100644 (file)
@@ -48,9 +48,9 @@ Group::Group(const std::string& group)
        ret = ::getgrnam_r(group.c_str(), &grp, buf.get(), bufsize, &result);
        if (result == NULL) {
                if (ret == 0)
-                       throw runtime::Exception("Group doesn't exist");
+                       throw klay::Exception("Group doesn't exist");
                else
-                       throw runtime::Exception(runtime::GetSystemErrorMessage(ret));
+                       throw klay::Exception(klay::GetSystemErrorMessage(ret));
        }
 
        name = result->gr_name;
@@ -71,9 +71,9 @@ Group::Group(const gid_t group)
        ret = ::getgrgid_r(group, &grp, buf.get(), bufsize, &result);
        if (result == NULL) {
                if (ret == 0)
-                       throw runtime::Exception("Group doesn't exist");
+                       throw klay::Exception("Group doesn't exist");
                else
-                       throw runtime::Exception(runtime::GetSystemErrorMessage(ret));
+                       throw klay::Exception(klay::GetSystemErrorMessage(ret));
        }
 
        name = result->gr_name;
index 3e825f449c8ce174fac04f4ef54c6c24213f8ba9..8677759e89d4e9db772e33cb77fa9c219d25dbbd 100644 (file)
@@ -48,9 +48,9 @@ User::User(const std::string& user)
        ret = ::getpwnam_r(user.c_str(), &pwd, buf.get(), bufsize, &result);
        if (result == NULL) {
                if (ret == 0)
-                       throw runtime::Exception("User " + user + " doesn't exist");
+                       throw klay::Exception("User " + user + " doesn't exist");
                else
-                       throw runtime::Exception(runtime::GetSystemErrorMessage(ret));
+                       throw klay::Exception(klay::GetSystemErrorMessage(ret));
        }
 
        name = result->pw_name;
@@ -71,9 +71,9 @@ User::User(const uid_t user)
        ret = ::getpwuid_r(user, &pwd, buf.get(), bufsize, &result);
        if (result == NULL) {
                if (ret == 0)
-                       throw runtime::Exception("User " + std::to_string(user) + "doesn't exist");
+                       throw klay::Exception("User " + std::to_string(user) + "doesn't exist");
                else
-                       throw runtime::Exception(runtime::GetSystemErrorMessage(ret));
+                       throw klay::Exception(klay::GetSystemErrorMessage(ret));
        }
 
        name = result->pw_name;
index d643e69aac44fa5500d27dd7864e8c8d6c314f15..ef04aa34739b75a2c73f87895217ae150dc1ccd8 100644 (file)
@@ -39,15 +39,15 @@ bool Cgroup::existSubsystem(const std::string& name)
                        return false;
                }
        } catch (std::runtime_error &e) {
-               throw runtime::Exception("Unexpected regex error");
+               throw klay::Exception("Unexpected regex error");
        }
 
-       runtime::File dir("/sys/fs/cgroup/" + name);
+       klay::File dir("/sys/fs/cgroup/" + name);
        if (dir.exists()) {
                if (dir.isDirectory()) {
                        return true;
                }
-               throw runtime::Exception("Invalid subsystem name");
+               throw klay::Exception("Invalid subsystem name");
        }
 
        return false;
@@ -57,21 +57,21 @@ void Cgroup::createSubsystem(const std::string& name)
 {
        try {
                if (!std::regex_match(name, std::regex(NAME_PATTERN))) {
-                       throw runtime::Exception("Invalid subsystem name");
+                       throw klay::Exception("Invalid subsystem name");
                }
        } catch (std::runtime_error &e) {
-               throw runtime::Exception("Unexpected regex error");
+               throw klay::Exception("Unexpected regex error");
        }
 
        if (existSubsystem(name)) {
                return;
        }
 
-       runtime::File subsystem("/sys/fs/cgroup/" + name);
+       klay::File subsystem("/sys/fs/cgroup/" + name);
        if (::mount(NULL, "/sys/fs/cgroup/", NULL, MS_REMOUNT |
                        MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME,
                        "mode=755")) {
-               throw runtime::Exception("Failed to remount cgroupfs as the writable");
+               throw klay::Exception("Failed to remount cgroupfs as the writable");
        }
 
        if (!subsystem.exists()) {
@@ -82,29 +82,29 @@ void Cgroup::createSubsystem(const std::string& name)
                        "cgroup", MS_NODEV | MS_NOSUID | MS_NOEXEC,
                        ("none,name=" + name).c_str())) {
                subsystem.remove(false);
-               throw runtime::Exception("Failed to mount cgroup subsystem");
+               throw klay::Exception("Failed to mount cgroup subsystem");
        }
 
        if (::mount(NULL, "/sys/fs/cgroup/", NULL, MS_REMOUNT | MS_RDONLY |
                        MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME,
                        "mode=755")) {
-               throw runtime::Exception("Failed to remount cgroupfs as the read-only");
+               throw klay::Exception("Failed to remount cgroupfs as the read-only");
        }
 }
 
 void Cgroup::destroySubsystem(const std::string& name)
 {
        if (!existSubsystem(name)) {
-                throw runtime::Exception("No such subsystem");
+                throw klay::Exception("No such subsystem");
        }
 
        if (::mount(NULL, "/sys/fs/cgroup/", NULL, MS_REMOUNT |
                        MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME,
                        "mode=755")) {
-               throw runtime::Exception("Failed to remount cgroupfs as the writable");
+               throw klay::Exception("Failed to remount cgroupfs as the writable");
        }
 
-       runtime::File subsystem("/sys/fs/cgroup/" + name);
+       klay::File subsystem("/sys/fs/cgroup/" + name);
        ::umount2(subsystem.getPath().c_str(), MNT_EXPIRE);
 
        subsystem.remove(false);
@@ -112,7 +112,7 @@ void Cgroup::destroySubsystem(const std::string& name)
        if (::mount(NULL, "/sys/fs/cgroup/", NULL, MS_REMOUNT | MS_RDONLY |
                        MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_STRICTATIME,
                        "mode=755")) {
-               throw runtime::Exception("Failed to remount cgroupfs as the read-only");
+               throw klay::Exception("Failed to remount cgroupfs as the read-only");
        }
 }
 
@@ -123,15 +123,15 @@ bool Cgroup::exist(const std::string& subsystem, const std::string& path)
                        return false;
                }
        } catch (std::runtime_error &e) {
-               throw runtime::Exception("Unexpected regex error");
+               throw klay::Exception("Unexpected regex error");
        }
 
-       runtime::File dir("/sys/fs/cgroup/" + subsystem + "/" + path);
+       klay::File dir("/sys/fs/cgroup/" + subsystem + "/" + path);
        if (dir.exists()) {
                if (dir.isDirectory()) {
                        return true;
                }
-               throw runtime::Exception("Invalid path");
+               throw klay::Exception("Invalid path");
        }
 
        return false;
@@ -141,34 +141,34 @@ void Cgroup::create(const std::string& subsystem, const std::string& path)
 {
        try {
                if (!std::regex_match(path, std::regex(PATH_PATTERN))) {
-                       throw runtime::Exception("Invalid path");
+                       throw klay::Exception("Invalid path");
                }
        } catch (std::runtime_error &e) {
-               throw runtime::Exception("Unexpected regex error");
+               throw klay::Exception("Unexpected regex error");
        }
 
        if (exist(subsystem, path)) {
                return;
        }
 
-       runtime::File dir("/sys/fs/cgroup/" + subsystem + "/" + path);
+       klay::File dir("/sys/fs/cgroup/" + subsystem + "/" + path);
        dir.makeDirectory(true);
 }
 
 void Cgroup::destroy(const std::string& subsystem, const std::string& path)
 {
        if (!exist(subsystem, path)) {
-               throw runtime::Exception("No such path in subsystem");
+               throw klay::Exception("No such path in subsystem");
        }
 
-       runtime::File dir("/sys/fs/cgroup/" + subsystem + "/" + path);
+       klay::File dir("/sys/fs/cgroup/" + subsystem + "/" + path);
        dir.remove(false);
 }
 
 void Cgroup::addProcess(const std::string& subsystem, const std::string& path, const pid_t pid)
 {
        if (!exist(subsystem, path)) {
-               throw runtime::Exception("No such path in subsystem");
+               throw klay::Exception("No such path in subsystem");
        }
 
        std::ofstream ofs("/sys/fs/cgroup/" + subsystem + "/" + path +
index e39255f78126639a848d0809474ef7f712f19b2d..d1af8aba0dce69686b41d6e0b5b918ac529b83b0 100644 (file)
@@ -25,7 +25,7 @@ Connection::Connection(const std::string& name, const int flags, bool integrityC
        handle(nullptr), filename(name)
 {
        if (::sqlite3_open_v2(filename.c_str(), &handle, flags, NULL)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 
        if (integrityCheck) {
@@ -45,7 +45,7 @@ Connection::Connection(const std::string& name, const int flags, bool integrityC
 
                if (!verified) {
                        ::sqlite3_close(handle);
-                       throw runtime::Exception("Malformed database");
+                       throw klay::Exception("Malformed database");
                }
        }
 }
@@ -58,7 +58,7 @@ Connection::~Connection()
 int Connection::exec(const std::string& query)
 {
        if (::sqlite3_exec(handle, query.c_str(), NULL, NULL, NULL) != SQLITE_OK) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 
        return ::sqlite3_changes(handle);
index 9e03809a389d5d5b32e75b5bf7647d0aee15368c..a04efe0cef6d900d8450fc760bbf1b1c0819bb63 100644 (file)
@@ -35,7 +35,7 @@ Statement::Statement(const Connection& db, const std::string& query) :
                                                                                  query.size(),
                                                                                  &statement,
                                                                                  NULL)) {
-               throw runtime::Exception(db.getErrorMessage());
+               throw klay::Exception(db.getErrorMessage());
        }
 
        columnCount = sqlite3_column_count(statement);
@@ -49,14 +49,14 @@ Statement::~Statement()
 void Statement::reset()
 {
        if (::sqlite3_reset(statement) != SQLITE_OK) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
 void Statement::clearBindings()
 {
        if (::sqlite3_clear_bindings(statement) != SQLITE_OK) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -91,7 +91,7 @@ int Statement::exec()
 Column Statement::getColumn(const int index)
 {
        if (!validRow || (index >= columnCount)) {
-               throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
+               throw klay::Exception(getErrorMessage(SQLITE_RANGE));
        }
 
        return Column(*this, index);
@@ -100,7 +100,7 @@ Column Statement::getColumn(const int index)
 bool Statement::isNullColumn(const int index) const
 {
        if (!validRow || (index >= columnCount)) {
-               throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
+               throw klay::Exception(getErrorMessage(SQLITE_RANGE));
        }
 
        return (SQLITE_NULL == sqlite3_column_type(statement, index));
@@ -109,7 +109,7 @@ bool Statement::isNullColumn(const int index) const
 std::string Statement::getColumnName(const int index) const
 {
        if (index >= columnCount) {
-               throw runtime::Exception(getErrorMessage(SQLITE_RANGE));
+               throw klay::Exception(getErrorMessage(SQLITE_RANGE));
        }
 
        return sqlite3_column_name(statement, index);
@@ -119,28 +119,28 @@ std::string Statement::getColumnName(const int index) const
 void Statement::bind(const int index, const int& value)
 {
        if (SQLITE_OK != ::sqlite3_bind_int(statement, index, value)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
 void Statement::bind(const int index, const sqlite3_int64& value)
 {
        if (SQLITE_OK != ::sqlite3_bind_int64(statement, index, value)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
 void Statement::bind(const int index, const double& value)
 {
        if (SQLITE_OK != ::sqlite3_bind_double(statement, index, value)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
 void Statement::bind(const int index, const char* value)
 {
        if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -148,21 +148,21 @@ void Statement::bind(const int index, const std::string& value)
 {
        if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value.c_str(),
                                                                                 static_cast<int>(value.size()), SQLITE_TRANSIENT)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
 void Statement::bind(const int index, const void* value, const int size)
 {
        if (SQLITE_OK != ::sqlite3_bind_blob(statement, index, value, size, SQLITE_TRANSIENT)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
 void Statement::bind(const int index)
 {
        if (SQLITE_OK != ::sqlite3_bind_null(statement, index)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -170,7 +170,7 @@ void Statement::bind(const std::string& name, const int& value)
 {
        int index = sqlite3_bind_parameter_index(statement, name.c_str());
        if (SQLITE_OK != sqlite3_bind_int(statement, index, value)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -178,7 +178,7 @@ void Statement::bind(const std::string& name, const sqlite3_int64& value)
 {
        int index = sqlite3_bind_parameter_index(statement, name.c_str());
        if (SQLITE_OK != ::sqlite3_bind_int64(statement, index, value)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -186,7 +186,7 @@ void Statement::bind(const std::string& name, const double& value)
 {
        int index = sqlite3_bind_parameter_index(statement, name.c_str());
        if (SQLITE_OK != ::sqlite3_bind_double(statement, index, value)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -195,7 +195,7 @@ void Statement::bind(const std::string& name, const std::string& value)
        int index = sqlite3_bind_parameter_index(statement, name.c_str());
        if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value.c_str(),
                                                                                 static_cast<int>(value.size()), SQLITE_TRANSIENT)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -203,7 +203,7 @@ void Statement::bind(const std::string& name, const char* value)
 {
        int index = sqlite3_bind_parameter_index(statement, name.c_str());
        if (SQLITE_OK != ::sqlite3_bind_text(statement, index, value, -1, SQLITE_TRANSIENT)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -211,7 +211,7 @@ void Statement::bind(const std::string& name, const void* value, const int size)
 {
        int index = sqlite3_bind_parameter_index(statement, name.c_str());
        if (SQLITE_OK != ::sqlite3_bind_blob(statement, index, value, size, SQLITE_TRANSIENT)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
@@ -219,7 +219,7 @@ void Statement::bind(const std::string& name)
 {
        int index = sqlite3_bind_parameter_index(statement, name.c_str());
        if (SQLITE_OK != ::sqlite3_bind_null(statement, index)) {
-               throw runtime::Exception(getErrorMessage());
+               throw klay::Exception(getErrorMessage());
        }
 }
 
index 9724830aa0086a6883d85e9c08280413b76c662c..9a4dc5b8b3efb5140b4adf769b4af8b5e0f8e8d7 100644 (file)
@@ -50,7 +50,7 @@ Connection::Connection(const std::string& address) :
        connection = g_dbus_connection_new_for_address_sync(address.c_str(), flags, NULL, NULL, &error);
        if (error) {
                ERROR(KSINK, error->message);
-               throw runtime::Exception(error->message);
+               throw klay::Exception(error->message);
        }
 }
 
@@ -130,7 +130,7 @@ Variant Connection::methodcall(const std::string& busName,
 
        if (error) {
                ERROR(KSINK, error->message);
-               throw runtime::Exception(error->message);
+               throw klay::Exception(error->message);
        }
 
        return result;
@@ -159,7 +159,7 @@ void Connection::emitSignal(const std::string& busName,
                                                                  &error);
        if (error) {
                ERROR(KSINK, error->message);
-               throw runtime::Exception(error->message);
+               throw klay::Exception(error->message);
        }
 }
 
@@ -192,7 +192,7 @@ Connection::ObjectId Connection::registerObject(const std::string& object,
        }
 
        if (error) {
-               throw runtime::Exception(error->message);
+               throw klay::Exception(error->message);
        }
 
        GDBusInterfaceInfo* inf = node->interfaces[0];
@@ -211,7 +211,7 @@ Connection::ObjectId Connection::registerObject(const std::string& object,
        g_dbus_node_info_unref(node);
     if (error) {
         ERROR(KSINK, error->message);
-        throw runtime::Exception(error->message);
+        throw klay::Exception(error->message);
     }
 
        return id;
@@ -300,7 +300,7 @@ void Connection::onMethodCall(GDBusConnection* connection,
        try {
                Variant variant = callbackSet.methodcall(objectPath, interface, method, Variant(parameters));
                g_dbus_method_invocation_return_value(invocation, &variant);
-       } catch (runtime::Exception& e) {
+       } catch (klay::Exception& e) {
                ERROR(KSINK, "Error on metod handling");
                g_dbus_method_invocation_return_dbus_error(invocation, (interface + std::string(".Error")).c_str(), e.what());
        }
index 22f752e159ce0896752a473083680623f73931a1..36048a8e9325add45ed942369f5021abb57bdf3f 100644 (file)
@@ -52,12 +52,12 @@ Introspection::~Introspection(void)
 BusNode Introspection::getBusNode(const std::string &xmlData)
 {
        if (xmlData.empty())
-               throw runtime::Exception("Invalid argument.");
+               throw klay::Exception("Invalid argument.");
 
        dbus::Error error;
        auto busNode = ::g_dbus_node_info_new_for_xml(xmlData.c_str(), &error);
        if (busNode == nullptr || error)
-               throw runtime::Exception("Failed to get BusNode.");
+               throw klay::Exception("Failed to get BusNode.");
 
        return busNode;
 }
@@ -65,7 +65,7 @@ BusNode Introspection::getBusNode(const std::string &xmlData)
 Interface Introspection::getInterface(const std::string &name) const
 {
        if (name.empty())
-               throw runtime::Exception("Invalid argument.");
+               throw klay::Exception("Invalid argument.");
 
        return ::g_dbus_node_info_lookup_interface(busNode, name.c_str());
 }
@@ -75,7 +75,7 @@ Method Introspection::getMethod(const std::string &interfaceName,
 {
        auto interface = getInterface(interfaceName);
        if (interface == nullptr || methodName.empty())
-               throw runtime::Exception("Invalid argument.");
+               throw klay::Exception("Invalid argument.");
 
        return ::g_dbus_interface_info_lookup_method(interface, methodName.c_str());
 }
@@ -85,7 +85,7 @@ Signal Introspection::getSignal(const std::string &interfaceName,
 {
        auto interface = getInterface(interfaceName);
        if (interface == nullptr || signalName.empty())
-               throw runtime::Exception("Invalid argument.");
+               throw klay::Exception("Invalid argument.");
 
        return ::g_dbus_interface_info_lookup_signal(interface, signalName.c_str());
 }
@@ -95,7 +95,7 @@ Property Introspection::getProperty(const std::string &interfaceName,
 {
        auto interface = getInterface(interfaceName);
        if (interface == nullptr || propertyName.empty())
-               throw runtime::Exception("Invalid argument.");
+               throw klay::Exception("Invalid argument.");
 
        return ::g_dbus_interface_info_lookup_property(interface, propertyName.c_str());
 }
@@ -108,7 +108,7 @@ std::string Introspection::getXmlData(unsigned int indent)
                        ::g_string_free(ptr, TRUE);
                });
        if (buf == nullptr)
-               throw runtime::Exception("Out of memory.");
+               throw klay::Exception("Out of memory.");
 
        ::g_dbus_node_info_generate_xml(busNode, indent, buf.get());
        return std::string(buf->str);
@@ -116,7 +116,7 @@ std::string Introspection::getXmlData(unsigned int indent)
 
 std::string Introspection::createXmlDataFromFile(const std::string &path)
 {
-       runtime::File manifest(path);
+       klay::File manifest(path);
        if (!manifest.exists()) {
                manifest.create(0644);
                manifest.lock();
@@ -133,7 +133,7 @@ std::string Introspection::createXmlDataFromFile(const std::string &path)
 void Introspection::writeXmlDataToFile(const std::string &path,
                                                                           const std::string &xmlData)
 {
-       runtime::File manifest(path);
+       klay::File manifest(path);
        manifest.open(O_WRONLY | O_TRUNC);
        manifest.lock();
        manifest.write(xmlData.c_str(), xmlData.length());
@@ -143,11 +143,11 @@ void Introspection::writeXmlDataToFile(const std::string &path,
 void Introspection::addInterface(const std::string &name)
 {
        if (getInterface(name) != nullptr)
-               throw runtime::Exception("Interface is already exist:" + name);
+               throw klay::Exception("Interface is already exist:" + name);
 
        std::size_t offset = xmlData.find("</node>");
        if (offset == std::string::npos)
-               throw runtime::Exception("Failed to find </node>.");
+               throw klay::Exception("Failed to find </node>.");
 
        XmlProperties properties;
        properties.emplace_back(std::make_pair("name", name));
@@ -189,16 +189,16 @@ std::string Introspection::getXmlEndTag(const std::string &node) const
 void Introspection::checkDataFormat(const std::string &data) const
 {
        if (data.empty() || data.length() < 3)
-               throw runtime::Exception("Invalid argument.");
+               throw klay::Exception("Invalid argument.");
 
        const std::string beginChar = "<";
        if (data.compare(0, beginChar.length(), beginChar) != 0)
-               throw runtime::Exception("Xml data should be begin as: " + beginChar);
+               throw klay::Exception("Xml data should be begin as: " + beginChar);
 
        const std::string endChar = "/>";
        if (data.compare(data.length() - endChar.length(), endChar.length(), endChar) != 0 &&
                data.find("/") == std::string::npos)
-               throw runtime::Exception("Xml data should be contain '/' or end as: " + endChar);
+               throw klay::Exception("Xml data should be contain '/' or end as: " + endChar);
 }
 
 void Introspection::addMethod(const std::string &interfaceName,
@@ -257,7 +257,7 @@ void Introspection::addInternalData(const std::string &interfaceName,
        std::string iTemplate = getXmlBeginTag(INTERFACE_NODE, properties);
        std::size_t offset = xmlData.find(iTemplate);
        if (offset == std::string::npos)
-               throw runtime::Exception("Failed to find interface xml node: " + interfaceName);
+               throw klay::Exception("Failed to find interface xml node: " + interfaceName);
 
        xmlData.insert(offset + iTemplate.length() + 1, data);
        update();
index dd81c3889f2366036c5e00eee8feedfe23f16bed..1d937a93ae33e7ffb4286dfb5acb8610b07841c7 100644 (file)
@@ -29,7 +29,7 @@ EventFD::EventFD(unsigned int initval, int flags)
 {
        fd = ::eventfd(initval, flags);
        if (fd == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
@@ -49,7 +49,7 @@ void EventFD::send()
 {
        const std::uint64_t val = 1;
        if (::write(fd, &val, sizeof(val)) == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
@@ -57,7 +57,7 @@ void EventFD::receive()
 {
        std::uint64_t val;
        if (::read(fd, &val, sizeof(val)) == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
index 038f05a89e88eb44722f730beb883003c160cc29..a2a9393f62b785448fd6e81a47bcff3b4b076ac0 100644 (file)
@@ -33,16 +33,16 @@ bool FileUser::isUsedAsFD(const std::string &filePath, const pid_t pid, bool isM
        try {
                File file(filePath);
 
-               for (runtime::DirectoryIterator iter(path), end; iter != end;) {
+               for (klay::DirectoryIterator iter(path), end; iter != end;) {
                        File cur(File((++iter)->getPath()).readlink());
                        try {
                                if ((cur.getInode() == file.getInode() || isMount) &&
                                                cur.getDevice() == file.getDevice()) {
                                        return true;
                                }
-                       } catch (runtime::Exception &e) {}
+                       } catch (klay::Exception &e) {}
                }
-       } catch (runtime::Exception &e) {}
+       } catch (klay::Exception &e) {}
 
        return false;
 }
@@ -72,7 +72,7 @@ bool FileUser::isUsedAsMap(const std::string &filePath, const pid_t pid, bool is
                                }
                        }
                }
-       } catch (runtime::Exception &e) {}
+       } catch (klay::Exception &e) {}
 
        return false;
 }
@@ -88,7 +88,7 @@ bool FileUser::isUsedAsCwd(const std::string &filePath, const pid_t pid, bool is
                                cwd.getDevice() == file.getDevice()) {
                        return true;
                }
-       } catch (runtime::Exception &e) {}
+       } catch (klay::Exception &e) {}
 
        return false;
 }
@@ -104,7 +104,7 @@ bool FileUser::isUsedAsRoot(const std::string &filePath, const pid_t pid, bool i
                                root.getDevice() == file.getDevice()) {
                        return true;
                }
-       } catch (runtime::Exception &e) {}
+       } catch (klay::Exception &e) {}
 
        return false;
 }
@@ -114,7 +114,7 @@ std::vector<pid_t> FileUser::getList(const std::string &path, bool isMount)
        pid_t currentPid = ::getpid();
        std::vector<pid_t> list;
 
-       for (runtime::DirectoryIterator iter("/proc"), end; iter != end;) {
+       for (klay::DirectoryIterator iter("/proc"), end; iter != end;) {
                const std::string name = iter->getName();
                if (!std::isdigit(name[0])) {
                        ++iter;
index fa8484c2297c5d26b0831a9aae8f53da2de28b71..a98c7cde69d0950c096c5d377fa16e9f0ddc03a2 100644 (file)
@@ -82,7 +82,7 @@ bool File::isLink() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return S_ISLNK(st.st_mode);
@@ -92,7 +92,7 @@ bool File::isFile() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return S_ISREG(st.st_mode);
@@ -102,7 +102,7 @@ bool File::isDirectory() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return S_ISDIR(st.st_mode);
@@ -112,7 +112,7 @@ bool File::isDevice() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode));
@@ -122,7 +122,7 @@ mode_t File::getMode() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return st.st_mode;
@@ -132,7 +132,7 @@ uid_t File::getUid() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return st.st_uid;
@@ -142,7 +142,7 @@ gid_t File::getGid() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return st.st_gid;
@@ -152,7 +152,7 @@ ino_t File::getInode() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return st.st_ino;
@@ -162,7 +162,7 @@ dev_t File::getDevice() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return st.st_dev;
@@ -172,7 +172,7 @@ off_t File::size() const
 {
        struct stat st;
        if (::lstat(path.c_str(), &st) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        return st.st_size;
@@ -190,7 +190,7 @@ void File::create(mode_t mode)
                        if (errno == EINTR) {
                                continue;
                        }
-                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       throw klay::Exception(klay::GetSystemErrorMessage());
                }
                return;
        }
@@ -208,7 +208,7 @@ void File::create(int flags, mode_t mode)
                        if (errno == EINTR) {
                                continue;
                        }
-                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       throw klay::Exception(klay::GetSystemErrorMessage());
                }
                return;
        }
@@ -226,7 +226,7 @@ void File::open(int flags)
                        if (errno == EINTR) {
                                continue;
                        }
-                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       throw klay::Exception(klay::GetSystemErrorMessage());
                }
                return;
        }
@@ -251,7 +251,7 @@ void File::read(void *buffer, const size_t size) const
                } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
                        continue;
                } else {
-                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       throw klay::Exception(klay::GetSystemErrorMessage());
                }
        }
 }
@@ -267,7 +267,7 @@ void File::write(const void *buffer, const size_t size) const
                } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
                        continue;
                } else {
-                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       throw klay::Exception(klay::GetSystemErrorMessage());
                }
        }
 }
@@ -275,7 +275,7 @@ void File::write(const void *buffer, const size_t size) const
 void File::lseek(off_t offset, int whence) const
 {
        if (::lseek(descriptor, offset, whence) == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
@@ -303,7 +303,7 @@ File File::copyTo(const std::string& destDir)
                        ssize_t ret;
                        ret = ::sendfile(destFile.descriptor, descriptor, &s, size() - s);
                        if (ret < 0) {
-                               throw runtime::Exception(runtime::GetSystemErrorMessage());
+                               throw klay::Exception(klay::GetSystemErrorMessage());
                        }
                }
                destFile.close();
@@ -324,11 +324,11 @@ void File::remove(bool recursive)
                        }
                }
                if (::rmdir(path.c_str()) != 0) {
-                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       throw klay::Exception(klay::GetSystemErrorMessage());
                }
        } else {
                if (::unlink(path.c_str()) != 0) {
-                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       throw klay::Exception(klay::GetSystemErrorMessage());
                }
        }
 }
@@ -345,11 +345,11 @@ void File::makeBaseDirectory(uid_t uid, gid_t gid)
                } else if (ret == 0) {
                        if ((uid | gid) != 0) {
                                if (::chown(substr.c_str(), uid, gid) == -1) {
-                                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                                       throw klay::Exception(klay::GetSystemErrorMessage());
                                }
                        }
                } else {
-                       throw runtime::Exception(runtime::GetSystemErrorMessage());
+                       throw klay::Exception(klay::GetSystemErrorMessage());
                }
        }
 }
@@ -361,7 +361,7 @@ void File::makeDirectory(bool recursive, uid_t uid, gid_t gid)
        }
 
        if (::mkdir(path.c_str(), 0777) == -1) {
-               throw runtime::Exception("mkdir failed in makeDirectory: " + path);
+               throw klay::Exception("mkdir failed in makeDirectory: " + path);
        }
 
        if ((uid | gid) != 0) {
@@ -372,7 +372,7 @@ void File::makeDirectory(bool recursive, uid_t uid, gid_t gid)
 void File::chown(uid_t uid, gid_t gid, bool recursive)
 {
        if (::chown(path.c_str(), uid, gid) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        if (recursive && isDirectory()) {
@@ -387,7 +387,7 @@ void File::chown(uid_t uid, gid_t gid, bool recursive)
 void File::chmod(mode_t mode, bool recursive)
 {
        if (::chmod(path.c_str(), mode) != 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        if (recursive && isDirectory()) {
@@ -404,7 +404,7 @@ const std::string File::readlink() const
        char buf[PATH_MAX + 1];
        ssize_t ret = ::readlink(path.c_str(), buf, PATH_MAX);
        if (ret == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        buf[ret] = '\0';
@@ -414,14 +414,14 @@ const std::string File::readlink() const
 void File::lock() const
 {
        if (::flock(descriptor, LOCK_EX) == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
 void File::unlock() const
 {
        if (::flock(descriptor, LOCK_UN) == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
@@ -448,7 +448,7 @@ void DirectoryIterator::reset(const std::string& dir)
        basename = dir;
        directoryHandle = ::opendir(basename.c_str());
        if (directoryHandle == nullptr) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        next();
@@ -579,7 +579,7 @@ void Mount::mountEntry(const std::string& src, const std::string& dest, const st
                }
 
                if (ret) {
-                       throw runtime::Exception("failed to mount " + src + " on " + dest);
+                       throw klay::Exception("failed to mount " + src + " on " + dest);
                }
        }
 }
index 1b16ef1fef008d6a2420a0d5c5adf5cd0537e098..2890c6d21cc48b6931ecc6400655a53f03c8551f 100644 (file)
@@ -53,12 +53,12 @@ void Namespace::attach(const pid_t pid)
 
                if (fd == -1) {
                        if (errno != ENOENT) {
-                               throw runtime::Exception("Failed to open namesapce: " + nspath);
+                               throw klay::Exception("Failed to open namesapce: " + nspath);
                        }
                } else {
                        if (::setns(fd, ns.second)) {
                                ::close(fd);
-                               throw runtime::Exception("Failed to set namespace: " + nspath);
+                               throw klay::Exception("Failed to set namespace: " + nspath);
                        }
                        ::close(fd);
                }
@@ -68,12 +68,12 @@ void Namespace::attach(const pid_t pid)
 void Namespace::unshare(int flags)
 {
        if (::unshare(flags)) {
-               throw runtime::Exception("Failed to unshare namespace");
+               throw klay::Exception("Failed to unshare namespace");
        }
 
        if (flags & CLONE_NEWNS &&
                        ::mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) == -1) {
-               throw runtime::Exception("Failed to mount root filesystem");
+               throw klay::Exception("Failed to mount root filesystem");
        }
 }
 
index 9199d0acef4987aaf346a324408d0f77345aee55..ea67f5f296a67efed7fe42ce6b4e9ed9b9142eb8 100644 (file)
@@ -33,12 +33,12 @@ Netlink::Netlink(int protocol) :
 {
        fd = ::socket(PF_NETLINK, SOCK_RAW, protocol);
        if (fd < 0) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 
        if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
                ::close(fd);
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
@@ -89,14 +89,14 @@ void Netlink::send(int type, const std::vector<char>& data)
        } while (ret < 0 && errno == EINTR);
 
        if (ret < 0) {
-               throw runtime::Exception("Failed to send a netlink message");
+               throw klay::Exception("Failed to send a netlink message");
        }
 
        if (recv(MSG_PEEK).first == NLMSG_ERROR) {
                auto reply = recv().second;
                auto err = (struct nlmsgerr*)reply.data();
                if (err->error)
-                       throw runtime::Exception("Netlink error: " +
+                       throw klay::Exception("Netlink error: " +
                                                                                std::to_string(err->error));
        } else {
                        WARN("Missing ack of netlink message");
@@ -114,7 +114,7 @@ Netlink::Message Netlink::recv(int options)
        } while (ret < 0 && errno == EINTR);
 
        if (ret < 0) {
-               throw runtime::Exception("Failed to get the size of netlink message");
+               throw klay::Exception("Failed to get the size of netlink message");
        }
 
        struct sockaddr_nl nladdr;
@@ -130,19 +130,19 @@ Netlink::Message Netlink::recv(int options)
        ::memcpy(msg.second.data(), NLMSG_DATA(buf), msg.second.size());
 
        if (ret < 0) {
-               throw runtime::Exception("Failed to receive audit packet");
+               throw klay::Exception("Failed to receive audit packet");
        }
 
        if (nladdrlen != sizeof(nladdr)) {
-               throw runtime::Exception("Bad address size in netlink socket");
+               throw klay::Exception("Bad address size in netlink socket");
        }
 
        if (nladdr.nl_pid) {
-               throw runtime::Exception("Spoofed packet received on netlink socket");
+               throw klay::Exception("Spoofed packet received on netlink socket");
        }
 
        return msg;
 }
 
-} // namespace runtime
+} // namespace klay
 } // namespace klay
index 84cb6f3450e574db4a355713b6f6f89e3bb3378c..0ac705cf3da1b5eb256adb83b11c59d0a649dea1 100644 (file)
@@ -31,7 +31,7 @@ PAM::PAM(const std::string& service, const std::string& user)
 
        int error = ::pam_start(service.c_str(), user.c_str(), &pamc, &pamh);
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
 }
 
@@ -39,7 +39,7 @@ PAM::~PAM()
 {
        int error = ::pam_end(pamh, PAM_SUCCESS);
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
 }
 
@@ -47,7 +47,7 @@ void PAM::setData(const std::string &name, void* data, void (*cleanup)(pam_handl
 {
        int error = ::pam_set_data(pamh, name.c_str(), data, cleanup);
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
 }
 
@@ -56,7 +56,7 @@ const void* PAM::getData(const std::string &name) const
        const void* ret;
        int error = ::pam_get_data(pamh, name.c_str(), &ret);
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
        return ret;
 }
@@ -65,7 +65,7 @@ void PAM::setItem(int item, void* data)
 {
        int error = ::pam_set_item(pamh, item, data);
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
 }
 
@@ -74,7 +74,7 @@ const void* PAM::getItem(int item) const
        const void* ret;
        int error = ::pam_get_item(pamh, item, &ret);
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
        return ret;
 }
@@ -84,7 +84,7 @@ const std::string PAM::getUser(const std::string &prompt) const
        const char* user;
        int error = ::pam_get_user(pamh, &user, prompt.c_str());
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
        return std::string(user);
 }
@@ -93,7 +93,7 @@ void PAM::putEnv(const std::string &name_value)
 {
        int error = ::pam_putenv(pamh, name_value.c_str());
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
 }
 
@@ -101,7 +101,7 @@ const std::string PAM::getEnv(const std::string &name) const
 {
        const char* value = ::pam_getenv(pamh, name.c_str());
        if (value == NULL) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
        return value;
 }
@@ -111,7 +111,7 @@ const std::vector<std::string> PAM::getEnvList() const
        std::vector<std::string> ret;
        char** array = ::pam_getenvlist(pamh);
        if (array == NULL) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
        for (int i = 0; array[i] != NULL; i++) {
                ret.push_back(array[i]);
@@ -149,7 +149,7 @@ void PAM::openSession(int flags)
 {
        int error = ::pam_open_session(pamh, flags);
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
 }
 
@@ -157,7 +157,7 @@ void PAM::closeSession(int flags)
 {
        int error = ::pam_close_session(pamh, flags);
        if (error != PAM_SUCCESS) {
-               throw runtime::Exception("PAM Error");
+               throw klay::Exception("PAM Error");
        }
 }
 
index 9b2f583e0b8a0c3278c773dd94cc70bd79341006..dbb2e42a9777c12f6648d6797b2143a9ac85ef5b 100644 (file)
@@ -86,14 +86,14 @@ bool Process::isRunning() const
 void Process::kill()
 {
        if (::kill(pid, SIGKILL) == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
 void Process::terminate()
 {
        if (::kill(pid, SIGINT) == -1) {
-               throw runtime::Exception(runtime::GetSystemErrorMessage());
+               throw klay::Exception(klay::GetSystemErrorMessage());
        }
 }
 
index d29c75a18d0be3546ec4bb361f541f9f93eab843..d40c5dfa62f8b2d17863dc57b477926be3abf8df 100644 (file)
@@ -22,23 +22,23 @@ namespace rmi {
 void DefaultExceptionModel::raise(const std::string& target, const std::string& msg)
 {
        if (target == "InvalidArgumentException")
-               throw runtime::InvalidArgumentException(msg);
+               throw klay::InvalidArgumentException(msg);
        else if (target == "NotImplementedException")
-               throw runtime::InvalidArgumentException(msg);
+               throw klay::InvalidArgumentException(msg);
        else if (target == "RangeException")
-               throw runtime::RangeException(msg);
+               throw klay::RangeException(msg);
        else if (target == "NotFoundException")
-               throw runtime::NotFoundException(msg);
+               throw klay::NotFoundException(msg);
        else if (target == "UnsupportedException")
-               throw runtime::UnsupportedException(msg);
+               throw klay::UnsupportedException(msg);
        else if (target == "NoPermissionException")
-               throw runtime::NoPermissionException(msg);
+               throw klay::NoPermissionException(msg);
        else if (target == "IOException")
-               throw runtime::IOException(msg);
+               throw klay::IOException(msg);
        else if (target == "OutOfMemoryException")
-               throw runtime::OutOfMemoryException(msg);
+               throw klay::OutOfMemoryException(msg);
        else
-               throw runtime::Exception(msg);
+               throw klay::Exception(msg);
 }
 
 } // namespace rmi
index e09329fc4e58214e183808a43f4ba483fc3b4611..e007e383794116d6d0bfb21fc9987f12ff32dfc5 100644 (file)
@@ -90,16 +90,16 @@ Message Message::createErrorMessage(const std::string& target, const std::string
        return error;
 }
 
-template<> void Message::enclose(runtime::FileDescriptor&& fd)
+template<> void Message::enclose(klay::FileDescriptor&& fd)
 {
        if (fd.fileDescriptor == -1) {
-               throw runtime::Exception("Invalid file descriptor");
+               throw klay::Exception("Invalid file descriptor");
        }
 
        fileDescriptors.push_back(std::move(fd));
 }
 
-template<> void Message::disclose(runtime::FileDescriptor& fd)
+template<> void Message::disclose(klay::FileDescriptor& fd)
 {
        if (!fileDescriptors.empty()) {
                fd.fileDescriptor = std::move(fileDescriptors.front()).fileDescriptor;
index f071777d88df30547896d111e75907109cb0b51f..7cc78b53b612c3f35df9e04e99783cde2d1b8eac 100644 (file)
@@ -43,7 +43,7 @@ SubscriptionId Notification::createSubscriber()
 {
        int fds[2] = {-1, -1};
        if (::socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
-               throw runtime::Exception("Failed to create socket pair");
+               throw klay::Exception("Failed to create socket pair");
        }
 
        std::lock_guard<std::mutex> lock(subscriberLock);
index 17b8b3ea7d8909ad9cb4c1b95911c754f469f733..23d809dd43faebd2778f761ee65e1c1b397a1021 100644 (file)
@@ -50,7 +50,7 @@ Service::~Service()
 void Service::prepare(bool activation)
 {
        socket.reset(new Socket(Socket::create(address, activation)));
-       auto accept = [&](int fd, runtime::Mainloop::Event event) {
+       auto accept = [&](int fd, klay::Mainloop::Event event) {
                onNewConnection(std::make_shared<Connection>(socket->accept()));
        };
 
@@ -93,7 +93,7 @@ void Service::setAuditTrail(const AuditTrail& trail)
 void Service::setNewConnectionCallback(const ConnectionCallback& connectionCallback)
 {
        auto callback = [connectionCallback, this](const std::shared_ptr<Connection>& connection) {
-               auto handle = [&](int fd, runtime::Mainloop::Event event) {
+               auto handle = [&](int fd, klay::Mainloop::Event event) {
                        std::lock_guard<std::mutex> lock(stateLock);
 
                        auto iter = getConnectionIterator(fd);
@@ -142,7 +142,7 @@ void Service::createNotification(const std::string& name)
        std::lock_guard<std::mutex> lock(notificationLock);
 
        if (notificationRegistry.count(name)) {
-               throw runtime::Exception("Notification already registered");
+               throw klay::Exception("Notification already registered");
        }
 
        notificationRegistry.emplace(name, Notification(name));
@@ -150,7 +150,7 @@ void Service::createNotification(const std::string& name)
 
 int Service::subscribeNotification(const std::string& name)
 {
-       auto closeHandler = [&, name, this](int fd, runtime::Mainloop::Event event) {
+       auto closeHandler = [&, name, this](int fd, klay::Mainloop::Event event) {
                if ((event & EPOLLHUP) || (event & EPOLLRDHUP)) {
                        unsubscribeNotification(name, fd);
                        return;
@@ -170,7 +170,7 @@ int Service::subscribeNotification(const std::string& name)
                SubscriptionId slot = notification.createSubscriber();
                mainloop.addEventSource(slot.first, EPOLLHUP | EPOLLRDHUP, closeHandler);
                return slot.second;
-       } catch (runtime::Exception& e) {
+       } catch (klay::Exception& e) {
                ERROR(KSINK, e.what());
                return -1;
        }
@@ -205,7 +205,7 @@ void Service::onMessageProcess(const std::shared_ptr<Connection>& connection)
        auto process = [&, connection](Message& request) {
                try {
                        if (!methodRegistry.count(request.target()))
-                               throw runtime::NotFoundException("Method not found");
+                               throw klay::NotFoundException("Method not found");
 
                        std::shared_ptr<MethodContext> methodContext = methodRegistry.at(request.target());
 
@@ -213,11 +213,11 @@ void Service::onMessageProcess(const std::shared_ptr<Connection>& connection)
                        bool allowed = onPrivilegeCheck(processingContext.credentials, methodContext->privilege);
                        onAuditTrail(processingContext.credentials, request.target(), allowed);
                        if (!allowed) {
-                               throw runtime::NoPermissionException("Permission denied");
+                               throw klay::NoPermissionException("Permission denied");
                        }
 
                        connection->send(methodContext->dispatcher(request));
-               } catch (runtime::Exception& e) {
+               } catch (klay::Exception& e) {
                        connection->send(request.createErrorMessage(e.className(), e.what()));
                } catch (std::exception& e) {
                        try {
index 3e2e3721e606c3068b3975e9a362efd3b336abfe..9889acbd652c4e185855ef667b8ca050d46f9530 100644 (file)
@@ -39,7 +39,7 @@ const int MAX_BACKLOG_SIZE = 100;
 void setCloseOnExec(int fd)
 {
        if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 }
 
@@ -50,11 +50,11 @@ Credentials getCredentials(int fd)
        struct ucred cred;
        socklen_t credsz = sizeof(cred);
        if (::getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &credsz)) {
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        if (::getsockopt(fd, SOL_SOCKET, SO_PEERSEC, buf, &length)) {
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        return {cred.pid, cred.uid, cred.gid, buf};
@@ -85,7 +85,7 @@ Socket Socket::accept()
 {
        int sockfd = ::accept(socketFd, nullptr, nullptr);
        if (sockfd == -1) {
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        setCloseOnExec(sockfd);
@@ -114,7 +114,7 @@ void Socket::read(void *buffer, const size_t size) const
                } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
                        continue;
                } else {
-                       throw SocketException(runtime::GetSystemErrorMessage());
+                       throw SocketException(klay::GetSystemErrorMessage());
                }
        }
 }
@@ -130,7 +130,7 @@ void Socket::write(const void *buffer, const size_t size) const
                } else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
                        continue;
                } else {
-                       throw SocketException(runtime::GetSystemErrorMessage());
+                       throw SocketException(klay::GetSystemErrorMessage());
                }
        }
 }
@@ -170,7 +170,7 @@ void Socket::sendFileDescriptors(const int* fds, const size_t nr) const
                if (ret >= 0) {
                        written += ret;
                } else if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) {
-                       throw SocketException(runtime::GetSystemErrorMessage());
+                       throw SocketException(klay::GetSystemErrorMessage());
                }
        }
 }
@@ -203,7 +203,7 @@ void Socket::receiveFileDescriptors(int* fds, const size_t nr) const
                        bytes += ret;
                } else {
                        if ((errno != EAGAIN) && (errno != EWOULDBLOCK) && (errno != EINTR)) {
-                               throw SocketException(runtime::GetSystemErrorMessage());
+                               throw SocketException(klay::GetSystemErrorMessage());
                        }
                }
        }
@@ -240,12 +240,12 @@ int Socket::createSystemdSocket(const std::string& path)
 int Socket::createRegularSocket(const std::string& path)
 {
        if (path.size() >= sizeof(sockaddr_un::sun_path)) {
-               throw SocketException(runtime::GetSystemErrorMessage(ENAMETOOLONG));
+               throw SocketException(klay::GetSystemErrorMessage(ENAMETOOLONG));
        }
 
        int sockfd = ::socket(AF_UNIX, SOCK_STREAM, 0);
        if (sockfd == -1) {
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        setCloseOnExec(sockfd);
@@ -262,18 +262,18 @@ int Socket::createRegularSocket(const std::string& path)
 
        if (::bind(sockfd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_un)) == -1) {
                ::close(sockfd);
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        int optval = 1;
        if (::setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof(optval)) == -1) {
                ::close(sockfd);
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        if (::listen(sockfd, MAX_BACKLOG_SIZE) == -1) {
                ::close(sockfd);
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        return sockfd;
@@ -295,12 +295,12 @@ Socket Socket::create(const std::string& path, bool activation)
 Socket Socket::connect(const std::string& path)
 {
        if (path.size() >= sizeof(sockaddr_un::sun_path)) {
-               throw SocketException(runtime::GetSystemErrorMessage(ENAMETOOLONG));
+               throw SocketException(klay::GetSystemErrorMessage(ENAMETOOLONG));
        }
 
        int fd = ::socket(AF_UNIX, SOCK_STREAM, 0);
        if (fd == -1) {
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        setCloseOnExec(fd);
@@ -315,7 +315,7 @@ Socket Socket::connect(const std::string& path)
 
        if (::connect(fd, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_un)) == -1) {
                ::close(fd);
-               throw SocketException(runtime::GetSystemErrorMessage());
+               throw SocketException(klay::GetSystemErrorMessage());
        }
 
        return Socket(fd);
index b49d7a780405ef9f5a74a08985ec3e0e3ce27b1b..4d9ab576274af73bbd60b50023a23b486d17cc1d 100644 (file)
@@ -29,7 +29,7 @@ Document::Document(const std::string& root, const std::string& version) :
        implementation(xmlNewDoc((const xmlChar*)version.c_str()))
 {
        if (implementation == nullptr) {
-               throw runtime::Exception("Failed to create document");
+               throw klay::Exception("Failed to create document");
        }
 
        implementation->_private = this;
@@ -60,7 +60,7 @@ Document::~Document()
 Node& Document::getRootNode()
 {
        if (rootNode == nullptr) {
-               throw runtime::Exception("Empty document");
+               throw klay::Exception("Empty document");
        }
 
        return *rootNode;
@@ -70,20 +70,20 @@ Node::NodeList Document::evaluate(const std::string& xpath)
 {
        auto ctxt = xmlXPathNewContext(implementation);
        if (ctxt == nullptr) {
-               throw runtime::Exception("Failed to create XPath context for " + xpath);
+               throw klay::Exception("Failed to create XPath context for " + xpath);
        }
 
        auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt);
        if (result == nullptr) {
                xmlXPathFreeContext(ctxt);
-               throw runtime::Exception("Invalid XPath: " + xpath);
+               throw klay::Exception("Invalid XPath: " + xpath);
        }
 
        if (result ->type != XPATH_NODESET) {
                xmlXPathFreeObject(result);
                xmlXPathFreeContext(ctxt);
 
-               throw runtime::Exception("Only nodeset result types are supported");
+               throw klay::Exception("Only nodeset result types are supported");
        }
 
        auto nodeset = result->nodesetval;
@@ -128,7 +128,7 @@ void Document::write(const std::string& filename, const std::string& encoding, b
                                                                                        encoding.c_str(),
                                                                                        formatted);
        if (result == 0) {
-               throw runtime::Exception("Failed to write XML document");
+               throw klay::Exception("Failed to write XML document");
        }
 }
 
index a0055d041bdcf62f4a82814e9abb24d7e35ff64b..83b874230086458a0e8e6aefd0ce9dbb06047a45 100644 (file)
@@ -50,7 +50,7 @@ Node Node::addNewChild(const std::string& name)
 {
        xmlNode* nodePtr = xmlNewNode(NULL, xmlStrdup((const xmlChar*)name.c_str()));
        if (nodePtr == nullptr) {
-               throw runtime::Exception("Can not create a new node");
+               throw klay::Exception("Can not create a new node");
        }
        xmlAddChild(implementation, nodePtr);
 
@@ -86,7 +86,7 @@ void Node::setContent(const std::string& content)
 std::string Node::getProp(const std::string& name) const
 {
        if (implementation->type != XML_ELEMENT_NODE) {
-               throw runtime::Exception("This node type does not have properties");
+               throw klay::Exception("This node type does not have properties");
        }
 
        xmlChar* prop = xmlGetProp(implementation, (xmlChar*)name.c_str());
@@ -102,7 +102,7 @@ std::string Node::getProp(const std::string& name) const
 void Node::setProp(const std::string& name, const std::string& val)
 {
        if (implementation->type != XML_ELEMENT_NODE) {
-               throw runtime::Exception("Can not set properties for this node type");
+               throw klay::Exception("Can not set properties for this node type");
        }
 
        xmlSetProp(implementation, (xmlChar*)name.c_str(), (xmlChar*)val.c_str());
index ddae583adcfca1f8570745fffa9455f5588cc0ff..86ba1db8637572df5c780cfe84fb3868572531ef 100644 (file)
@@ -25,7 +25,7 @@ namespace xml {
 Document* Parser::parseContext(xmlParserCtxt* context, bool validate)
 {
        if (context == nullptr) {
-               throw runtime::Exception("Could not create parser context");
+               throw klay::Exception("Could not create parser context");
        }
 
        KeepBlanks(false);
@@ -42,7 +42,7 @@ Document* Parser::parseContext(xmlParserCtxt* context, bool validate)
 
        if (xmlParseDocument(context) < 0) {
                xmlFreeParserCtxt(context);
-               throw runtime::Exception("Parsing failed");
+               throw klay::Exception("Parsing failed");
        }
 
        xmlDoc* document = context->myDoc;
@@ -59,7 +59,7 @@ Document* Parser::parseFile(const std::string& filename, bool validate)
 {
        xmlParserCtxt* context = xmlCreateFileParserCtxt(filename.c_str());
        if (context == nullptr) {
-               throw runtime::Exception("Could not create parser context");
+               throw klay::Exception("Could not create parser context");
        }
 
        if (context->directory == nullptr) {
@@ -74,7 +74,7 @@ Document* Parser::parseString(const std::string& xml, bool validate)
        xmlParserCtxt* context = xmlCreateMemoryParserCtxt(xml.c_str(), xml.size() + 1);
 
        if (context == nullptr) {
-               throw runtime::Exception("Could not create parser context");
+               throw klay::Exception("Could not create parser context");
        }
 
        return parseContext(context, validate);