summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/KerneloopsReporter.cpp
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-03-11 14:21:28 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2009-03-11 14:21:28 +0100
commit2036c6cc28f5d3f07142657ca148f8db516d9651 (patch)
tree28493a37a1cdd706012c10390d7e8b1d0acb652f /lib/Plugins/KerneloopsReporter.cpp
parentd852cf2bf1bdf4a0662fbd68f76dc7feb65c97ba (diff)
downloadabrt-2036c6cc28f5d3f07142657ca148f8db516d9651.tar.gz
abrt-2036c6cc28f5d3f07142657ca148f8db516d9651.tar.xz
abrt-2036c6cc28f5d3f07142657ca148f8db516d9651.zip
added kerneloops addon and plugin (aarapov)
Diffstat (limited to 'lib/Plugins/KerneloopsReporter.cpp')
-rw-r--r--lib/Plugins/KerneloopsReporter.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp
new file mode 100644
index 00000000..ef5f56f7
--- /dev/null
+++ b/lib/Plugins/KerneloopsReporter.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2007, Intel Corporation
+ * Copyright 2009, Red Hat Inc.
+ *
+ * This file is part of %TBD%
+ *
+ * This program file 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.
+ *
+ * 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 in a file named COPYING; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Authors:
+ * Anton Arapov <anton@redhat.com>
+ * Arjan van de Ven <arjan@linux.intel.com>
+ */
+
+#include "DebugDump.h"
+#include "KerneloopsReporter.h"
+
+#include <sstream>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/stat.h>
+#include <curl/curl.h>
+
+CKerneloopsReporter::CKerneloopsReporter() :
+ m_sSubmitURL("http://submit.kerneloops.org/submitoops.php")
+{}
+
+size_t writefunction(void *ptr, size_t size, size_t nmemb, void __attribute((unused)) *stream)
+{
+ char *c, *c1, *c2;
+
+ c = (char*)malloc(size*nmemb + 1);
+ memset(c, 0, size*nmemb + 1);
+ memcpy(c, ptr, size*nmemb);
+ printf("received %s \n", c);
+ c1 = strstr(c, "201 ");
+ if (c1) {
+ c1+=4;
+ c2 = strchr(c1, '\n');
+ if (c2)
+ *c2 = 0;
+ }
+
+ return size * nmemb;
+}
+
+void CKerneloopsReporter::Report(const crash_report_t& pReport)
+{
+ CURL *handle;
+ struct curl_httppost *post = NULL;
+ struct curl_httppost *last = NULL;
+
+ handle = curl_easy_init();
+ curl_easy_setopt(handle, CURLOPT_URL, m_sSubmitURL.c_str());
+
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "oopsdata",
+ CURLFORM_COPYCONTENTS, pReport.m_sTextData1.c_str(),
+ CURLFORM_END);
+ curl_formadd(&post, &last,
+ CURLFORM_COPYNAME, "pass_on_allowed",
+ CURLFORM_COPYCONTENTS, "yes",
+ CURLFORM_END);
+
+ curl_easy_setopt(handle, CURLOPT_HTTPPOST, post);
+ curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, writefunction);
+
+ curl_easy_perform(handle);
+
+ curl_formfree(post);
+ curl_easy_cleanup(handle);
+}
+
+void CKerneloopsReporter::SetSettings(const map_settings_t& pSettings)
+{
+ if (pSettings.find("SubmitURL") != pSettings.end())
+ {
+ m_sSubmitURL = pSettings.find("SubmitURL")->second;
+ }
+}