diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-05-13 09:51:33 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2011-05-13 09:51:33 +0200 |
commit | 7cfbac7966d99568565abea25a57522288d9a279 (patch) | |
tree | 70a55385a01e3bcf08424ba8282bbe05d4c42a71 /src/lib | |
parent | e027694734697f4aa27ed5858966f816de3d944e (diff) | |
download | abrt-7cfbac7966d99568565abea25a57522288d9a279.tar.gz abrt-7cfbac7966d99568565abea25a57522288d9a279.tar.xz abrt-7cfbac7966d99568565abea25a57522288d9a279.zip |
report api proposal
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Makefile.am | 4 | ||||
-rw-r--r-- | src/lib/report.c | 96 |
2 files changed, 99 insertions, 1 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 88671f54..6493db99 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -46,7 +46,8 @@ libreport_la_SOURCES = \ abrt_conf.c abrt_conf.h \ steal_directory.c \ event_xml_parser.c \ - event_config.c + event_config.c \ + report.c libreport_la_CPPFLAGS = \ -Wall -Wwrite-strings -Werror \ -I$(srcdir)/../include/report -I$(srcdir)/../include \ @@ -57,6 +58,7 @@ libreport_la_CPPFLAGS = \ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \ -DCONF_DIR=\"$(CONF_DIR)\" \ -DEVENTS_DIR=\"$(EVENTS_DIR)\" \ + -DBIN_DIR=\"$(bindir)\" \ $(GLIB_CFLAGS) \ -D_GNU_SOURCE libreport_la_LDFLAGS = \ diff --git a/src/lib/report.c b/src/lib/report.c new file mode 100644 index 00000000..f1729efc --- /dev/null +++ b/src/lib/report.c @@ -0,0 +1,96 @@ +/* + Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) + Copyright (C) 2009 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 "abrtlib.h" + +int analyze_and_report_dir(const char* dirname) +{ + /* + if is isatty -> run cli reporter + */ + pid_t pid = vfork(); + if (pid == 0) + { + /* Undo signal(SIGCHLD, SIG_IGN), or child inherits it and gets terribly confused */ + signal(SIGCHLD, SIG_DFL); // applet still set it to SIG_IGN + VERB1 log("Executing: %s %s", "bug-reporting-wizard", dirname); + execl(BIN_DIR"/bug-reporting-wizard", "bug-reporting-wizard", dirname, NULL); + // note the -o in options which means --report-only + /* Did not find abrt-gui in installation directory. Oh well */ + /* Trying to find it in PATH */ + execlp("bug-reporting-wizard", "bug-reporting-wizard", dirname, NULL); + perror_msg_and_die("Can't execute %s", "bug-reporting-wizard"); + } + return 0; +} + +/* analyzes AND reports a problem saved on disk + * - takes user through all the steps in reporting wizard + */ +int analyze_and_report(problem_data_t *pd) +{ + struct dump_dir *dd = create_dump_dir_from_problem_data(pd, "/tmp"/* /var/tmp ?? */); + if (!dd) + return -1; + char *dir_name = strdup(dd->dd_dirname); + dd_close(dd); + VERB2 log("Temp problem dir: '%s'\n", dir_name); + analyze_and_report_dir(dir_name); + free(dir_name); + + return 0; +} + +/* reports a problem saved on disk + * - shows only reporter selector and progress +*/ +int report_dir(const char* dirname) +{ + pid_t pid = vfork(); + if (pid == 0) + { + /* Undo signal(SIGCHLD, SIG_IGN), or child inherits it and gets terribly confused */ + signal(SIGCHLD, SIG_DFL); // applet still set it to SIG_IGN + VERB1 log("Executing: %s %s", "bug-reporting-wizard", dirname); + execl(BIN_DIR"/bug-reporting-wizard", "bug-reporting-wizard", + "-o", dirname, NULL); + // note the -o in options which means --report-only + /* Did not find abrt-gui in installation directory. Oh well */ + /* Trying to find it in PATH */ + execlp("bug-reporting-wizard", "bug-reporting-wizard", + "-o", dirname, NULL); + perror_msg_and_die("Can't execute %s", "bug-reporting-wizard"); + } + return 0; +} + +int report(problem_data_t *pd) +{ + struct dump_dir *dd = create_dump_dir_from_problem_data(pd, "/tmp"/* /var/tmp ?? */); + if (!dd) + return -1; + char *dir_name = strdup(dd->dd_dirname); + dd_close(dd); + VERB2 log("Temp problem dir: '%s'\n", dir_name); + report_dir(dir_name); + free(dir_name); + + return 0; +} + |