summaryrefslogtreecommitdiffstats
path: root/src/CLI
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-03-23 18:26:33 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-23 18:26:33 +0100
commit3c3d9ab3a7a804d2b0460240a4c96362a14c13ed (patch)
treebd84dd3b21b1e1e50cdcdc7dd250400c3fd45427 /src/CLI
parent13997243816d57f77d7a3e36a26dad784e45d5f9 (diff)
downloadabrt-3c3d9ab3a7a804d2b0460240a4c96362a14c13ed.tar.gz
abrt-3c3d9ab3a7a804d2b0460240a4c96362a14c13ed.tar.xz
abrt-3c3d9ab3a7a804d2b0460240a4c96362a14c13ed.zip
remove socket code, it is dead
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/CLI')
-rw-r--r--src/CLI/ABRTSocket.cpp155
-rw-r--r--src/CLI/ABRTSocket.h47
-rw-r--r--src/CLI/Makefile.am1
3 files changed, 0 insertions, 203 deletions
diff --git a/src/CLI/ABRTSocket.cpp b/src/CLI/ABRTSocket.cpp
deleted file mode 100644
index 61618c08..00000000
--- a/src/CLI/ABRTSocket.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program 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; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#include "ABRTSocket.h"
-#include "ABRTException.h"
-#include "CrashTypesSocket.h"
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <string.h>
-
-CABRTSocket::CABRTSocket() : m_nSocket(-1)
-{}
-
-CABRTSocket::~CABRTSocket()
-{
- /* Paranoia. In C++, destructor will abort() if it was called while unwinding
- * the stack and it throws an exception.
- */
- try
- {
- Disconnect();
- }
- catch (...)
- {
- error_msg_and_die("Internal error");
- }
-}
-
-void CABRTSocket::Send(const std::string& pMessage)
-{
- int ret = 0;
- int len = pMessage.length();
- int offset = 0;
- char* message = new char[len + 3];
- memcpy(message, pMessage.c_str(), len);
- message[len] = MESSAGE_END_MARKER;
- message[len + 1] = '\n';
- message[len + 2] = '\0';
-
- while (ret != strlen(message + offset))
- {
- offset += ret;
- ret = send(m_nSocket, message + offset, strlen(message + offset), 0);
- if (ret == -1)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Send(): Can not send data");
- }
- }
- delete[] message;
-}
-
-void CABRTSocket::Recv(std::string& pMessage)
-{
- std::string message;
- bool receivingMessage = true;
- char buff[1];
- int ret;
-
- pMessage = "";
- while (receivingMessage)
- {
- ret = recv(m_nSocket, buff, 1, 0);
- if (ret == -1)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Recv(): Can not recv data");
- }
- else if (ret == 0)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Recv(): Connection closed by abrt server");
- }
-
- message += buff[0];
-
- if (message.length() > 2 &&
- message[message.length() - 2] == MESSAGE_END_MARKER &&
- message[message.length() - 1] == '\n')
- {
- receivingMessage = false;
- message = message.substr(0, message.length() - 2);
- }
- }
- pMessage = message;
-}
-
-
-void CABRTSocket::Connect(const std::string& pPath)
-{
- int len;
- struct sockaddr_un remote;
- if ((m_nSocket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Connect(): Can not create socket");
- }
- remote.sun_family = AF_UNIX;
- strcpy(remote.sun_path, pPath.c_str());
- len = strlen(remote.sun_path) + sizeof(remote.sun_family);
- if (connect(m_nSocket, (struct sockaddr *)&remote, len) == -1)
- {
- throw CABRTException(EXCEP_FATAL, "CABRTSocket::Connect(): Can not connect to remote");
- }
-}
-
-void CABRTSocket::Disconnect()
-{
- if (m_nSocket != -1)
- close(m_nSocket);
-}
-
-vector_map_crash_data_t CABRTSocket::GetCrashInfos()
-{
- std::string message = MESSAGE_GET_CRASH_INFOS;
- Send(message);
- Recv(message);
- message.erase(0, sizeof(MESSAGE_GET_CRASH_INFOS) - 1);
- return string_to_crash_infos(message);
-}
-
-map_crash_data_t CABRTSocket::CreateReport(const std::string &pUUID)
-{
- std::string message = MESSAGE_CREATE_REPORT + pUUID;
- Send(message);
- Recv(message);
- message.erase(0, sizeof(MESSAGE_CREATE_REPORT) - 1);
- return string_to_crash_report(message);
-}
-
-void CABRTSocket::Report(const map_crash_data_t& pReport)
-{
- std::string message = MESSAGE_REPORT + crash_report_to_string(pReport);
- Send(message);
-}
-
-void CABRTSocket::DeleteDebugDump(const std::string& pUUID)
-{
- std::string message = MESSAGE_DELETE_DEBUG_DUMP + pUUID;
- Send(message);
-}
diff --git a/src/CLI/ABRTSocket.h b/src/CLI/ABRTSocket.h
deleted file mode 100644
index f8fb42b8..00000000
--- a/src/CLI/ABRTSocket.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 RedHat Inc
-
- This program 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; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-#ifndef ABRTSOCKET_H_
-#define ABRTSOCKET_H_
-
-#include <string>
-
-#include "CrashTypes.h"
-
-class CABRTSocket
-{
- private:
- int m_nSocket;
-
- void Send(const char *pMessage);
- void Recv(std::string& pMessage);
-
- public:
- CABRTSocket();
- ~CABRTSocket();
-
- void Connect(const char *pPath);
- void Disconnect();
-
- vector_map_crash_data_t GetCrashInfos();
- map_crash_data_t CreateReport(const char *pUUID);
- void Report(const map_crash_data_t& pReport);
- int32_t DeleteDebugDump(const char *pUUID);
-};
-
-#endif /* ABRTSOCKET_H_ */
diff --git a/src/CLI/Makefile.am b/src/CLI/Makefile.am
index d12b69b1..361b64f7 100644
--- a/src/CLI/Makefile.am
+++ b/src/CLI/Makefile.am
@@ -1,6 +1,5 @@
bin_PROGRAMS = abrt-cli
-# removed: ABRTSocket.h ABRTSocket.cpp
abrt_cli_SOURCES = \
CLI.cpp \
run-command.h run-command.cpp \