From d9e2d23b754c0a3a6ccfdaee423065e4a1cd7784 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 1 Dec 2010 17:40:44 +0100 Subject: factor out headers so that "report lib" API is separated out of abrt API This patch minimally affects code per se - it adds create_crash_dump_dir() function which takes in-memory representation of the dump (map_crash_data_t object) and creates an on-disk representation. Then it returns pointer to struct dump_dir. With this function, it is possible to run an event on a user-constructed map_crash_data_t: map_crash_data_t cd; add_to_crash_data(cd, "foo", "bar"); struct dump_dir *dd = create_crash_dump_dir(cd); char *dir_name = strdup(dd->dd_dir); dd_close(dd); run_event(run_state, dir_name, event); delete_crash_dump_dir(dir_name); which is, basically, what report library is about. The biggest part of the patch is reshuffling of header files, with the following result: three header files which are not cluttered by other ABRT stuff, and expose the following API each: crash_dump.h - in-memory crash dump data structs and ops dump_dir.h - on-disk crash dump data structs and ops run_event.h - run_event() and friends These is a test application, test_report.cpp.cpp, which demonstrates (and tests) usage of these headers. (grep for "test-report" and enable it in build system if you want it to be built). It creates a temporary dump in /var/run/abrt/tmp-NNNN-NNNNN and runs "report" event. Deleting of temp dump is disabled for testing purposes - you might want to see the contents. Here is how the binary looks like: text data bss dec hex filename 3730 668 48 4446 115e /usr/bin/test-report linux-vdso.so.1 => (0x00007ffffa80f000) libabrt.so.0 => /usr/lib64/libabrt.so.0 (0x00007fad1f35e000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x0000003c1f200000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000003c2c200000) libm.so.6 => /lib64/libm.so.6 (0x00007fad1f0da000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003c28e00000) libc.so.6 => /lib64/libc.so.6 (0x00007fad1ed5b000) /lib64/ld-linux-x86-64.so.2 (0x00007fad1f570000) Next step would be to clean up the namespace, then rename libabrt.so into libreport.so, then split it into a separate package so that we can install it without installing other two abrt .so files. Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 5 ++- src/include/abrt_crash_dump.h | 42 +++---------------------- src/include/abrtlib.h | 20 ++---------- src/include/crash_dump.h | 72 +++++++++++++++++++++++++++++++++++++++++++ src/include/dump_dir.h | 4 +++ src/include/run_event.h | 48 +++++++++++++++++++++++++++++ 6 files changed, 134 insertions(+), 57 deletions(-) create mode 100644 src/include/crash_dump.h create mode 100644 src/include/run_event.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 3716d19e..c035aaa9 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -1,11 +1,14 @@ HEADER_FILES = \ + crash_dump.h \ + dump_dir.h \ + run_event.h \ + \ abrt_exception.h \ abrtlib.h \ abrt_types.h \ comm_layer_inner.h \ abrt_crash_dump.h \ dbus_common.h \ - dump_dir.h \ observer.h \ plugin.h \ action.h \ diff --git a/src/include/abrt_crash_dump.h b/src/include/abrt_crash_dump.h index ed7ffe95..fe924256 100644 --- a/src/include/abrt_crash_dump.h +++ b/src/include/abrt_crash_dump.h @@ -19,8 +19,12 @@ #ifndef ABRT_CRASH_DUMP_H_ #define ABRT_CRASH_DUMP_H_ +#include "crash_dump.h" #include "abrt_types.h" +// Text bigger than this usually is attached, not added inline +#define CD_TEXT_ATT_SIZE (2*1024) + // Keep in sync with CCDump.py: // Filenames in dump directory: @@ -67,30 +71,10 @@ #define CD_EVENTS "Events" -// Crash data is a map of 3-element vectors of strings: type, editable, content -#define CD_TYPE 0 -#define CD_EDITABLE 1 -#define CD_CONTENT 2 - -// SYS - system value, should not be displayed -// BIN - binary data -// TXT - text data, can be displayed -#define CD_SYS "s" -#define CD_BIN "b" -#define CD_TXT "t" -// Text bigger than this usually is attached, not added inline -#define CD_TEXT_ATT_SIZE (2*1024) - -#define CD_ISEDITABLE "y" -#define CD_ISNOTEDITABLE "n" - - #ifdef __cplusplus extern "C" { #endif -extern const char *const must_have_files[]; - bool is_editable_file(const char *file_name); #ifdef __cplusplus @@ -100,26 +84,8 @@ bool is_editable_file(const char *file_name); #ifdef __cplusplus -// -typedef map_vector_string_t map_crash_data_t; typedef std::vector vector_map_crash_data_t; -void add_to_crash_data_ext(map_crash_data_t& pCrashData, - const char *pItem, - const char *pType, - const char *pEditable, - const char *pContent); -// Uses type:CD_TXT, editable:CD_ISNOTEDITABLE -void add_to_crash_data(map_crash_data_t& pCrashData, - const char *pItem, - const char *pContent); - -void load_crash_data_from_crash_dump_dir(struct dump_dir *dd, map_crash_data_t& data); - -const char *get_crash_data_item_content_or_NULL(const map_crash_data_t& crash_data, const char *key); -// Aborts if key is not found: -const std::string& get_crash_data_item_content(const map_crash_data_t& crash_data, const char *key); - void log_map_crash_data(const map_crash_data_t& data, const char *name); #endif /* __cplusplus */ diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 8cd0664a..cb2755b0 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -78,8 +78,9 @@ int vdprintf(int d, const char *format, va_list ap); #include "hash_md5.h" #include "abrt_crash_dump.h" -#include "dump_dir.h" #include "abrt_types.h" +#include "dump_dir.h" +#include "run_event.h" #ifdef __cplusplus @@ -216,23 +217,6 @@ char* get_cmdline(pid_t pid); /* Returns 1 if abrtd daemon is running, 0 otherwise. */ int daemon_is_ok(); -struct run_event_state { - int (*post_run_callback)(const char *dump_dir_name, void *param); - void *post_run_param; - char* (*logging_callback)(char *log_line, void *param); - void *logging_param; -}; -static inline struct run_event_state *new_run_event_state() - { return (struct run_event_state*)xzalloc(sizeof(struct run_event_state)); } -static inline void free_run_event_state(struct run_event_state *state) - { free(state); } -/* Returns exitcode of first failed action, or first nonzero return value - * of post_run_callback. If all actions are successful, returns 0. - * If no actions were run for the event, returns -1. - */ -int run_event(struct run_event_state *state, const char *dump_dir_name, const char *event); -char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); - #ifdef __cplusplus } #endif diff --git a/src/include/crash_dump.h b/src/include/crash_dump.h new file mode 100644 index 00000000..ab7835b4 --- /dev/null +++ b/src/include/crash_dump.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2009 Abrt team. + 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. +*/ +#ifndef CRASH_DUMP_H_ +#define CRASH_DUMP_H_ + + +// Crash data is a map of 3-element vectors of strings: type, editable, content +#define CD_TYPE 0 +#define CD_EDITABLE 1 +#define CD_CONTENT 2 + +// SYS - system value, should not be displayed +// BIN - binary data +// TXT - text data, can be displayed +#define CD_SYS "s" +#define CD_BIN "b" +#define CD_TXT "t" + +#define CD_ISEDITABLE "y" +#define CD_ISNOTEDITABLE "n" + +struct dump_dir; + +#ifdef __cplusplus + +#include +#include +#include + +/* In-memory crash data structure and accessors */ + +typedef std::map > map_crash_data_t; + +void add_to_crash_data_ext(map_crash_data_t& pCrashData, + const char *pItem, + const char *pType, + const char *pEditable, + const char *pContent); +/* Uses type:CD_TXT, editable:CD_ISNOTEDITABLE */ +void add_to_crash_data(map_crash_data_t& pCrashData, + const char *pItem, + const char *pContent); + +const char *get_crash_data_item_content_or_NULL(const map_crash_data_t& crash_data, const char *key); +/* Aborts if key is not found: */ +const std::string& get_crash_data_item_content(const map_crash_data_t& crash_data, const char *key); + + +/* Conversions between in-memory and on-disk formats */ + +void load_crash_data_from_crash_dump_dir(struct dump_dir *dd, map_crash_data_t& data); +struct dump_dir *create_crash_dump_dir(const map_crash_data_t& crash_data); + +#endif + +#endif diff --git a/src/include/dump_dir.h b/src/include/dump_dir.h index 7a38f1e4..8cec9459 100644 --- a/src/include/dump_dir.h +++ b/src/include/dump_dir.h @@ -21,6 +21,10 @@ #ifndef DUMP_DIR_H_ #define DUMP_DIR_H_ +/* For DIR */ +#include +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/src/include/run_event.h b/src/include/run_event.h new file mode 100644 index 00000000..c2e34650 --- /dev/null +++ b/src/include/run_event.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2009 Abrt team. + 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. +*/ +#ifndef RUN_EVENT_H_ +#define RUN_EVENT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +struct dump_dir; + +struct run_event_state { + int (*post_run_callback)(const char *dump_dir_name, void *param); + void *post_run_param; + char* (*logging_callback)(char *log_line, void *param); + void *logging_param; +}; +struct run_event_state *new_run_event_state(void); +void free_run_event_state(struct run_event_state *state); + +/* Returns exitcode of first failed action, or first nonzero return value + * of post_run_callback. If all actions are successful, returns 0. + * If no actions were run for the event, returns -1. + */ +int run_event(struct run_event_state *state, const char *dump_dir_name, const char *event); +char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit From 47728cc3c70c2b6d3a645e5760b39b20bd946e39 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 6 Dec 2010 16:56:50 +0100 Subject: This patch changes crash data to use C structures. The smallest data element is: struct crash_item { char *content; unsigned flags; }; where content is, eh, content, and flags is a bit flag field. crash_data_t is a map of crash_item's, implemented as a pointer to heap-allocated GHashTable. vector_of_crash_data_t is a vector of crash_data_t's, implemented as a pointer to heap-allocated GPtrArray. Most operations have light wrappers around them to hide the nature of the containers. For example, to free vector_of_crash_data, you need to use free_vector_of_crash_data(ptr) instead of open-coding g_ptr_array_free. The wrapper is thin. The goal is not so much to hide the implementation, but more to make it easier to use the correct function. dbus (un)marshalling functions convert crash_item to three-element array of strings, in order to keep compatibility with abrt-gui (python). This can be changed later to use native representation. crash_data_t and vector_of_crash_data_t are represented in "natural" way, no funny stuff there. Signed-off-by: Denys Vlasenko --- src/include/abrt_crash_dump.h | 12 +----- src/include/abrtlib.h | 8 ++-- src/include/crash_dump.h | 94 ++++++++++++++++++++++++++++--------------- 3 files changed, 67 insertions(+), 47 deletions(-) (limited to 'src/include') diff --git a/src/include/abrt_crash_dump.h b/src/include/abrt_crash_dump.h index fe924256..3a23285a 100644 --- a/src/include/abrt_crash_dump.h +++ b/src/include/abrt_crash_dump.h @@ -77,18 +77,10 @@ extern "C" { bool is_editable_file(const char *file_name); +void log_map_crash_data(crash_data_t *crash_data, const char *pfx); + #ifdef __cplusplus } #endif - -#ifdef __cplusplus - -typedef std::vector vector_map_crash_data_t; - -void log_map_crash_data(const map_crash_data_t& data, const char *name); - -#endif /* __cplusplus */ - - #endif diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index cb2755b0..1fadd31a 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -237,10 +237,10 @@ std::string to_string(T x) void parse_args(const char *psArgs, vector_string_t& pArgs, int quote = -1); void parse_release(const char *pRelease, char **product, char **version); -char* make_description_bz(const map_crash_data_t& pCrashData); -char* make_description_reproduce_comment(const map_crash_data_t& pCrashData); -char* make_description_logger(const map_crash_data_t& pCrashData); -char* make_description_mailx(const map_crash_data_t& pCrashData); +char* make_description_bz(crash_data_t *crash_data); +char* make_description_reproduce_comment(crash_data_t *crash_data); +char* make_description_logger(crash_data_t *crash_data); +char* make_description_mailx(crash_data_t *crash_data); /** * Loads settings and stores it in second parameter. On success it diff --git a/src/include/crash_dump.h b/src/include/crash_dump.h index ab7835b4..10ddc885 100644 --- a/src/include/crash_dump.h +++ b/src/include/crash_dump.h @@ -19,54 +19,82 @@ #ifndef CRASH_DUMP_H_ #define CRASH_DUMP_H_ +#include -// Crash data is a map of 3-element vectors of strings: type, editable, content -#define CD_TYPE 0 -#define CD_EDITABLE 1 -#define CD_CONTENT 2 - -// SYS - system value, should not be displayed -// BIN - binary data -// TXT - text data, can be displayed -#define CD_SYS "s" -#define CD_BIN "b" -#define CD_TXT "t" - -#define CD_ISEDITABLE "y" -#define CD_ISNOTEDITABLE "n" +#ifdef __cplusplus +extern "C" { +#endif struct dump_dir; -#ifdef __cplusplus +enum { + CD_FLAG_SYS = (1 << 0), + CD_FLAG_BIN = (1 << 1), + CD_FLAG_TXT = (1 << 2), + CD_FLAG_ISEDITABLE = (1 << 3), + CD_FLAG_ISNOTEDITABLE = (1 << 4), +}; -#include -#include -#include +struct crash_item { + char *content; + unsigned flags; +}; +typedef struct crash_item crash_item; /* In-memory crash data structure and accessors */ -typedef std::map > map_crash_data_t; +typedef GHashTable crash_data_t; + +crash_data_t *new_crash_data(void); + +static inline void free_crash_data(crash_data_t *crash_data) +{ + if (crash_data) + g_hash_table_destroy(crash_data); +} + +void add_to_crash_data_ext(crash_data_t *crash_data, + const char *name, + const char *content, + unsigned flags); +/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */ +void add_to_crash_data(crash_data_t *crash_data, + const char *name, + const char *content); + +static inline struct crash_item *get_crash_data_item_or_NULL(crash_data_t *crash_data, const char *key) +{ + return (struct crash_item *)g_hash_table_lookup(crash_data, key); +} +const char *get_crash_item_content_or_NULL(crash_data_t *crash_data, const char *key); +/* Aborts if key is not found: */ +const char *get_crash_item_content_or_die(crash_data_t *crash_data, const char *key); -void add_to_crash_data_ext(map_crash_data_t& pCrashData, - const char *pItem, - const char *pType, - const char *pEditable, - const char *pContent); -/* Uses type:CD_TXT, editable:CD_ISNOTEDITABLE */ -void add_to_crash_data(map_crash_data_t& pCrashData, - const char *pItem, - const char *pContent); -const char *get_crash_data_item_content_or_NULL(const map_crash_data_t& crash_data, const char *key); -/* Aborts if key is not found: */ -const std::string& get_crash_data_item_content(const map_crash_data_t& crash_data, const char *key); +/* Vector of these structures */ + +typedef GPtrArray vector_of_crash_data_t; + +static inline crash_data_t *get_crash_data(vector_of_crash_data_t *vector, unsigned i) +{ + return (crash_data_t *)g_ptr_array_index(vector, i); +} + +vector_of_crash_data_t *new_vector_of_crash_data(void); +static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) +{ + if (vector) + g_ptr_array_free(vector, TRUE); +} /* Conversions between in-memory and on-disk formats */ -void load_crash_data_from_crash_dump_dir(struct dump_dir *dd, map_crash_data_t& data); -struct dump_dir *create_crash_dump_dir(const map_crash_data_t& crash_data); +crash_data_t *load_crash_data_from_crash_dump_dir(struct dump_dir *dd); +struct dump_dir *create_crash_dump_dir(crash_data_t *crash_data); +#ifdef __cplusplus +} #endif #endif -- cgit From fc9639c850a341e3010465ecb0eecb7f0cd03fc9 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 7 Dec 2010 10:30:30 +0100 Subject: remove unused function parse_args; make a few functions extern "C" Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 1fadd31a..a4337709 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -217,6 +217,13 @@ char* get_cmdline(pid_t pid); /* Returns 1 if abrtd daemon is running, 0 otherwise. */ int daemon_is_ok(); +char* make_description_bz(crash_data_t *crash_data); +char* make_description_reproduce_comment(crash_data_t *crash_data); +char* make_description_logger(crash_data_t *crash_data); +char* make_description_mailx(crash_data_t *crash_data); + +void parse_release(const char *pRelease, char **product, char **version); + #ifdef __cplusplus } #endif @@ -234,14 +241,6 @@ std::string to_string(T x) return unsigned_to_string(x); } -void parse_args(const char *psArgs, vector_string_t& pArgs, int quote = -1); -void parse_release(const char *pRelease, char **product, char **version); - -char* make_description_bz(crash_data_t *crash_data); -char* make_description_reproduce_comment(crash_data_t *crash_data); -char* make_description_logger(crash_data_t *crash_data); -char* make_description_mailx(crash_data_t *crash_data); - /** * Loads settings and stores it in second parameter. On success it * returns true, otherwise returns false. -- cgit From 816f3e001271ed8ab7fdadb6d90aeb2c61362dac Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 8 Dec 2010 14:51:47 +0100 Subject: removal of C++isms from libabrt, part 1 This patch converts libabrt usage of C++ map to a glib-based container, GHashTable. It is typedef-ed to map_string_h. We can't typedef it to map_string_t, since other parts of ABRT (daemon, cli) still use that name for C++ container. Also, exceptions are removed everywhere. Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 1 - src/include/abrt_exception.h | 57 -------------------------------------------- src/include/abrt_types.h | 27 +++++++++++++++++++++ src/include/abrtlib.h | 30 +++++++++++------------ src/include/plugin.h | 1 + 5 files changed, 42 insertions(+), 74 deletions(-) delete mode 100644 src/include/abrt_exception.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index c035aaa9..5b61bd82 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -3,7 +3,6 @@ HEADER_FILES = \ dump_dir.h \ run_event.h \ \ - abrt_exception.h \ abrtlib.h \ abrt_types.h \ comm_layer_inner.h \ diff --git a/src/include/abrt_exception.h b/src/include/abrt_exception.h deleted file mode 100644 index b826bfa8..00000000 --- a/src/include/abrt_exception.h +++ /dev/null @@ -1,57 +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 ABRTEXCEPTION_H_ -#define ABRTEXCEPTION_H_ - -#include "abrtlib.h" - -typedef enum { - EXCEP_UNKNOW, - EXCEP_DD_OPEN, - EXCEP_DD_LOAD, - EXCEP_DD_SAVE, - EXCEP_DD_DELETE, - EXCEP_DL, - EXCEP_PLUGIN, - EXCEP_ERROR, -} abrt_exception_t; - -/* std::exception is a class with virtual members. - * deriving from it makes our ctor/dtor much more heavy, - * and those are inlined in every throw and catch site! - */ -class CABRTException /*: public std::exception*/ -{ - private: - abrt_exception_t m_type; - char *m_what; - - /* Not defined. You can't use it */ - CABRTException& operator= (const CABRTException&); - - public: - ~CABRTException() { free(m_what); } - CABRTException(abrt_exception_t type, const char* fmt, ...); - CABRTException(const CABRTException& rhs); - - abrt_exception_t type() { return m_type; } - const char* what() const { return m_what; } -}; - -#endif diff --git a/src/include/abrt_types.h b/src/include/abrt_types.h index 38804895..3ebd1697 100644 --- a/src/include/abrt_types.h +++ b/src/include/abrt_types.h @@ -19,6 +19,33 @@ #ifndef ABRT_TYPES_H_ #define ABRT_TYPES_H_ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* We can't typedef it to map_string_t, since other parts of ABRT + * (daemon, cli) still use that name for C++ container. For now, + * let's call it map_string_h: + */ +typedef GHashTable map_string_h; + +map_string_h *new_map_string(void); +void free_map_string(map_string_h *ms); +const char *get_map_string_item_or_empty(map_string_h *ms, const char *key); +static inline +const char *get_map_string_item_or_NULL(map_string_h *ms, const char *key) +{ + return (const char*)g_hash_table_lookup(ms, key); +} + + +#ifdef __cplusplus +} +#endif + + #ifdef __cplusplus #include diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index a4337709..f3a5de4e 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -224,6 +224,20 @@ char* make_description_mailx(crash_data_t *crash_data); void parse_release(const char *pRelease, char **product, char **version); +/** + * Loads settings and stores it in second parameter. On success it + * returns true, otherwise returns false. + * + * @param path A path of config file. + * Config file consists of "key=value" lines. + * @param settings A read plugin's settings. + * @param skipKeysWithoutValue + * If true, lines in format "key=" (without value) are skipped. + * Otherwise empty value "" is inserted into pSettings. + * @return if it success it returns true, otherwise it returns false. + */ +bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue); + #ifdef __cplusplus } #endif @@ -241,22 +255,6 @@ std::string to_string(T x) return unsigned_to_string(x); } -/** - * Loads settings and stores it in second parameter. On success it - * returns true, otherwise returns false. - * - * @param path A path of config file. - * Config file consists of "key=value" lines. - * @param settings A readed plugin's settings. - * @param skipKeysWithoutValue - * If true, lines in format "key=" (without value) are skipped. - * Otherwise empty value "" is inserted into pSettings. - * @return if it success it returns true, otherwise it returns false. - */ -extern bool LoadPluginSettings(const char *pPath, - map_plugin_settings_t& pSettings, - bool skipKeysWithoutValue = true); - // TODO: npajkovs: full rewrite ssprintf -> xasprintf static inline std::string ssprintf(const char *format, ...) { diff --git a/src/include/plugin.h b/src/include/plugin.h index 3f652e65..322c212f 100644 --- a/src/include/plugin.h +++ b/src/include/plugin.h @@ -76,6 +76,7 @@ typedef enum { REPORTER, /**< A reporter plugin*/ DATABASE, /**< A database plugin*/ MAX_PLUGIN_TYPE = DATABASE, + INVALID_PLUGIN_TYPE } plugin_type_t; /** -- cgit From def39238640489b41da5cdc8fd4a83d16d49fcc7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 8 Dec 2010 15:03:24 +0100 Subject: removal of C++isms from libabrt, part 2 This patch rewrites a few places where we use C++ strings Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index f3a5de4e..d8dd361a 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -245,16 +245,6 @@ bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWith /* C++ style stuff */ #ifdef __cplusplus -std::string unsigned_to_string(unsigned long long x); -std::string signed_to_string(long long x); -template inline -std::string to_string(T x) -{ - if ((T)~(T)0 < (T)0) /* T is a signed type */ - return signed_to_string(x); - return unsigned_to_string(x); -} - // TODO: npajkovs: full rewrite ssprintf -> xasprintf static inline std::string ssprintf(const char *format, ...) { -- cgit From dc3c5b79ba1ee6fd7a98842fde43d072e004f93b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 8 Dec 2010 16:07:31 +0100 Subject: add abrt_ prefixes to abrt-internal functions in libabrt.so Signed-off-by: Denys Vlasenko --- src/include/abrt_crash_dump.h | 2 + src/include/abrt_types.h | 3 ++ src/include/abrtlib.h | 120 +++++++++++++++++++++++++++--------------- src/include/xfuncs.h | 38 ++++++++++++- 4 files changed, 119 insertions(+), 44 deletions(-) (limited to 'src/include') diff --git a/src/include/abrt_crash_dump.h b/src/include/abrt_crash_dump.h index 3a23285a..9ecbf56d 100644 --- a/src/include/abrt_crash_dump.h +++ b/src/include/abrt_crash_dump.h @@ -75,8 +75,10 @@ extern "C" { #endif +#define is_editable_file abrt_is_editable_file bool is_editable_file(const char *file_name); +#define log_map_crash_data abrt_log_map_crash_data void log_map_crash_data(crash_data_t *crash_data, const char *pfx); #ifdef __cplusplus diff --git a/src/include/abrt_types.h b/src/include/abrt_types.h index 3ebd1697..858c0c79 100644 --- a/src/include/abrt_types.h +++ b/src/include/abrt_types.h @@ -31,8 +31,11 @@ extern "C" { */ typedef GHashTable map_string_h; +#define new_map_string abrt_new_map_string map_string_h *new_map_string(void); +#define free_map_string abrt_free_map_string void free_map_string(map_string_h *ms); +#define get_map_string_item_or_empty abrt_get_map_string_item_or_empty const char *get_map_string_item_or_empty(map_string_h *ms, const char *key); static inline const char *get_map_string_item_or_NULL(map_string_h *ms, const char *key) diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index d8dd361a..d3f355e9 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -87,43 +87,64 @@ int vdprintf(int d, const char *format, va_list ap); extern "C" { #endif +#define prefixcmp abrt_prefixcmp int prefixcmp(const char *str, const char *prefix); +#define suffixcmp abrt_suffixcmp int suffixcmp(const char *str, const char *suffix); +#define concat_path_file abrt_concat_path_file char *concat_path_file(const char *path, const char *filename); +#define append_to_malloced_string abrt_append_to_malloced_string char *append_to_malloced_string(char *mstr, const char *append); +#define skip_whitespace abrt_skip_whitespace char* skip_whitespace(const char *s); +#define skip_non_whitespace abrt_skip_non_whitespace char* skip_non_whitespace(const char *s); /* Like strcpy but can copy overlapping strings. */ +#define overlapping_strcpy abrt_overlapping_strcpy void overlapping_strcpy(char *dst, const char *src); /* A-la fgets, but malloced and of unlimited size */ +#define xmalloc_fgets abrt_xmalloc_fgets char *xmalloc_fgets(FILE *file); /* Similar, but removes trailing \n */ +#define xmalloc_fgetline abrt_xmalloc_fgetline char *xmalloc_fgetline(FILE *file); /* On error, copyfd_XX prints error messages and returns -1 */ enum { COPYFD_SPARSE = 1 << 0, }; +#define copyfd_eof abrt_copyfd_eof off_t copyfd_eof(int src_fd, int dst_fd, int flags); +#define copyfd_size abrt_copyfd_size off_t copyfd_size(int src_fd, int dst_fd, off_t size, int flags); +#define copyfd_exact_size abrt_copyfd_exact_size void copyfd_exact_size(int src_fd, int dst_fd, off_t size); +#define copy_file abrt_copy_file off_t copy_file(const char *src_name, const char *dst_name, int mode); /* Returns malloc'ed block */ +#define encode_base64 abrt_encode_base64 char *encode_base64(const void *src, int length); +#define xatou abrt_xatou unsigned xatou(const char *numstr); +#define xatoi abrt_xatoi int xatoi(const char *numstr); /* Using xatoi() instead of naive atoi() is not always convenient - * in many places people want *non-negative* values, but store them * in signed int. Therefore we need this one: - * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc */ -int xatoi_u(const char *numstr); + * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc. + * It should really be named xatoi_nonnegative (since it allows 0), + * but that would be too long. + */ +#define xatoi_positive abrt_xatoi_positive +int xatoi_positive(const char *numstr); -unsigned long long monotonic_ns(void); -unsigned long long monotonic_us(void); -unsigned monotonic_sec(void); +//unused for now +//unsigned long long monotonic_ns(void); +//unsigned long long monotonic_us(void); +//unsigned monotonic_sec(void); enum { /* on return, pipefds[1] is fd to which parent may write @@ -146,6 +167,7 @@ enum { EXECFLG_SETSID = 1 << 8, }; /* Returns pid */ +#define fork_execv_on_steroids abrt_fork_execv_on_steroids pid_t fork_execv_on_steroids(int flags, char **argv, int *pipefds, @@ -154,53 +176,57 @@ pid_t fork_execv_on_steroids(int flags, uid_t uid); /* Returns malloc'ed string. NULs are retained, and extra one is appended * after the last byte (this NUL is not accounted for in *size_p) */ +#define run_in_shell_and_save_output abrt_run_in_shell_and_save_output char *run_in_shell_and_save_output(int flags, const char *cmd, const char *dir, size_t *size_p); -/* Networking helpers */ -typedef struct len_and_sockaddr { - socklen_t len; - union { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; - } u; -} len_and_sockaddr; -enum { - LSA_LEN_SIZE = offsetof(len_and_sockaddr, u), - LSA_SIZEOF_SA = sizeof(struct sockaddr) > sizeof(struct sockaddr_in6) ? - sizeof(struct sockaddr) : sizeof(struct sockaddr_in6), -}; -void setsockopt_reuseaddr(int fd); -int setsockopt_broadcast(int fd); -int setsockopt_bindtodevice(int fd, const char *iface); -len_and_sockaddr* get_sock_lsa(int fd); -void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); -unsigned lookup_port(const char *port, const char *protocol, unsigned default_port); -int get_nport(const struct sockaddr *sa); -void set_nport(len_and_sockaddr *lsa, unsigned port); -len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af); -len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af); -len_and_sockaddr* host2sockaddr(const char *host, int port); -len_and_sockaddr* xhost2sockaddr(const char *host, int port); -len_and_sockaddr* xdotted2sockaddr(const char *host, int port); -int xsocket_type(len_and_sockaddr **lsap, int family, int sock_type); -int xsocket_stream(len_and_sockaddr **lsap); -int create_and_bind_stream_or_die(const char *bindaddr, int port); -int create_and_bind_dgram_or_die(const char *bindaddr, int port); -int create_and_connect_stream_or_die(const char *peer, int port); -int xconnect_stream(const len_and_sockaddr *lsa); -char* xmalloc_sockaddr2host(const struct sockaddr *sa); -char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa); -char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa); -char* xmalloc_sockaddr2dotted(const struct sockaddr *sa); -char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa); +//unused for now +///* Networking helpers */ +//typedef struct len_and_sockaddr { +// socklen_t len; +// union { +// struct sockaddr sa; +// struct sockaddr_in sin; +// struct sockaddr_in6 sin6; +// } u; +//} len_and_sockaddr; +//enum { +// LSA_LEN_SIZE = offsetof(len_and_sockaddr, u), +// LSA_SIZEOF_SA = sizeof(struct sockaddr) > sizeof(struct sockaddr_in6) ? +// sizeof(struct sockaddr) : sizeof(struct sockaddr_in6), +//}; +//void setsockopt_reuseaddr(int fd); +//int setsockopt_broadcast(int fd); +//int setsockopt_bindtodevice(int fd, const char *iface); +//len_and_sockaddr* get_sock_lsa(int fd); +//void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); +//unsigned lookup_port(const char *port, const char *protocol, unsigned default_port); +//int get_nport(const struct sockaddr *sa); +//void set_nport(len_and_sockaddr *lsa, unsigned port); +//len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af); +//len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af); +//len_and_sockaddr* host2sockaddr(const char *host, int port); +//len_and_sockaddr* xhost2sockaddr(const char *host, int port); +//len_and_sockaddr* xdotted2sockaddr(const char *host, int port); +//int xsocket_type(len_and_sockaddr **lsap, int family, int sock_type); +//int xsocket_stream(len_and_sockaddr **lsap); +//int create_and_bind_stream_or_die(const char *bindaddr, int port); +//int create_and_bind_dgram_or_die(const char *bindaddr, int port); +//int create_and_connect_stream_or_die(const char *peer, int port); +//int xconnect_stream(const len_and_sockaddr *lsa); +//char* xmalloc_sockaddr2host(const struct sockaddr *sa); +//char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa); +//char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa); +//char* xmalloc_sockaddr2dotted(const struct sockaddr *sa); +//char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa); /* Random utility functions */ +#define get_dirsize abrt_get_dirsize double get_dirsize(const char *pPath); +#define get_dirsize_find_largest_dir abrt_get_dirsize_find_largest_dir double get_dirsize_find_largest_dir( const char *pPath, char **worst_dir, /* can be NULL */ @@ -212,16 +238,23 @@ double get_dirsize_find_largest_dir( * If the pid is not valid or command line can not be obtained, * empty string is returned. */ +#define get_cmdline abrt_get_cmdline char* get_cmdline(pid_t pid); /* Returns 1 if abrtd daemon is running, 0 otherwise. */ +#define daemon_is_ok abrt_daemon_is_ok int daemon_is_ok(); +#define make_description_bz abrt_make_description_bz char* make_description_bz(crash_data_t *crash_data); +#define make_description_reproduce_comment abrt_make_description_reproduce_comment char* make_description_reproduce_comment(crash_data_t *crash_data); +#define make_description_logger abrt_make_description_logger char* make_description_logger(crash_data_t *crash_data); +#define make_description_mailx abrt_make_description_mailx char* make_description_mailx(crash_data_t *crash_data); +#define parse_release abrt_parse_release void parse_release(const char *pRelease, char **product, char **version); /** @@ -236,6 +269,7 @@ void parse_release(const char *pRelease, char **product, char **version); * Otherwise empty value "" is inserted into pSettings. * @return if it success it returns true, otherwise it returns false. */ +#define load_conf_file abrt_load_conf_file bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue); #ifdef __cplusplus diff --git a/src/include/xfuncs.h b/src/include/xfuncs.h index 20284564..61188c81 100644 --- a/src/include/xfuncs.h +++ b/src/include/xfuncs.h @@ -29,43 +29,69 @@ extern "C" { #endif +#define ndelay_on abrt_ndelay_on int ndelay_on(int fd); +#define ndelay_off abrt_ndelay_off int ndelay_off(int fd); +#define close_on_exec_on abrt_close_on_exec_on int close_on_exec_on(int fd); -void* xcalloc(size_t nmemb, size_t size); +#define xmalloc abrt_xmalloc void* xmalloc(size_t size); +#define xrealloc abrt_xrealloc void* xrealloc(void *ptr, size_t size); +#define xzalloc abrt_xzalloc void* xzalloc(size_t size); +#define xstrdup abrt_xstrdup char* xstrdup(const char *s); +#define xstrndup abrt_xstrndup char* xstrndup(const char *s, int n); +#define xpipe abrt_xpipe void xpipe(int filedes[2]); +#define xdup abrt_xdup void xdup(int from); +#define xdup2 abrt_xdup2 void xdup2(int from, int to); +#define xmove_fd abrt_xmove_fd void xmove_fd(int from, int to); +#define xwrite abrt_xwrite void xwrite(int fd, const void *buf, size_t count); +#define xwrite_str abrt_xwrite_str void xwrite_str(int fd, const char *str); +#define xlseek abrt_xlseek off_t xlseek(int fd, off_t offset, int whence); +#define xchdir abrt_xchdir void xchdir(const char *path); +#define xvasprintf abrt_xvasprintf char* xvasprintf(const char *format, va_list p); +#define xasprintf abrt_xasprintf char* xasprintf(const char *format, ...); +#define xsetenv abrt_xsetenv void xsetenv(const char *key, const char *value); +#define xsocket abrt_xsocket int xsocket(int domain, int type, int protocol); +#define xbind abrt_xbind void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); +#define xlisten abrt_xlisten void xlisten(int s, int backlog); +#define xsendto abrt_xsendto ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, socklen_t tolen); +#define xstat abrt_xstat void xstat(const char *name, struct stat *stat_buf); +#define xopen3 abrt_xopen3 int xopen3(const char *pathname, int flags, int mode); +#define xopen abrt_xopen int xopen(const char *pathname, int flags); +#define xunlink abrt_xunlink void xunlink(const char *pathname); /* Just testing dent->d_type == DT_REG is wrong: some filesystems @@ -74,18 +100,28 @@ void xunlink(const char *pathname); * This function handles this case. Note: it returns 0 on symlinks * even if they point to regular files. */ +#define is_regular_file abrt_is_regular_file int is_regular_file(struct dirent *dent, const char *dirname); + +#define dot_or_dotdot abrt_dot_or_dotdot bool dot_or_dotdot(const char *filename); +#define last_char_is abrt_last_char_is char *last_char_is(const char *s, int c); +#define string_to_bool abrt_string_to_bool bool string_to_bool(const char *s); +#define xseteuid abrt_xseteuid void xseteuid(uid_t euid); +#define xsetegid abrt_xsetegid void xsetegid(gid_t egid); +#define xsetreuid abrt_xsetreuid void xsetreuid(uid_t ruid, uid_t euid); +#define xsetregid abrt_xsetregid void xsetregid(gid_t rgid, gid_t egid); /* Returns getpwuid(uid)->pw_dir or NULL */ +#define get_home_dir abrt_get_home_dir const char *get_home_dir(uid_t uid); #ifdef __cplusplus -- cgit From 28c588d6a86daa3d2f2bb7cdb4604d79e7dcf08b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 9 Dec 2010 12:29:54 +0100 Subject: create report-libs-devel package; separate out report headers Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 16 +++---- src/include/crash_dump.h | 100 ---------------------------------------- src/include/dump_dir.h | 68 --------------------------- src/include/report/crash_dump.h | 100 ++++++++++++++++++++++++++++++++++++++++ src/include/report/dump_dir.h | 68 +++++++++++++++++++++++++++ src/include/report/run_event.h | 48 +++++++++++++++++++ src/include/run_event.h | 48 ------------------- 7 files changed, 224 insertions(+), 224 deletions(-) delete mode 100644 src/include/crash_dump.h delete mode 100644 src/include/dump_dir.h create mode 100644 src/include/report/crash_dump.h create mode 100644 src/include/report/dump_dir.h create mode 100644 src/include/report/run_event.h delete mode 100644 src/include/run_event.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 5b61bd82..165c705b 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -1,8 +1,11 @@ -HEADER_FILES = \ - crash_dump.h \ - dump_dir.h \ - run_event.h \ - \ +libreport_includedir = $(includedir)/report +libreport_include_HEADERS = \ + report/crash_dump.h \ + report/dump_dir.h \ + report/run_event.h + +libabrt_includedir = $(includedir)/abrt +libabrt_include_HEADERS = \ abrtlib.h \ abrt_types.h \ comm_layer_inner.h \ @@ -13,6 +16,3 @@ HEADER_FILES = \ action.h \ analyzer.h \ xfuncs.h - -lib_includedir=$(includedir)/abrt/ -lib_include_HEADERS = $(HEADER_FILES) diff --git a/src/include/crash_dump.h b/src/include/crash_dump.h deleted file mode 100644 index 10ddc885..00000000 --- a/src/include/crash_dump.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2009 Abrt team. - 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. -*/ -#ifndef CRASH_DUMP_H_ -#define CRASH_DUMP_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct dump_dir; - -enum { - CD_FLAG_SYS = (1 << 0), - CD_FLAG_BIN = (1 << 1), - CD_FLAG_TXT = (1 << 2), - CD_FLAG_ISEDITABLE = (1 << 3), - CD_FLAG_ISNOTEDITABLE = (1 << 4), -}; - -struct crash_item { - char *content; - unsigned flags; -}; -typedef struct crash_item crash_item; - -/* In-memory crash data structure and accessors */ - -typedef GHashTable crash_data_t; - -crash_data_t *new_crash_data(void); - -static inline void free_crash_data(crash_data_t *crash_data) -{ - if (crash_data) - g_hash_table_destroy(crash_data); -} - -void add_to_crash_data_ext(crash_data_t *crash_data, - const char *name, - const char *content, - unsigned flags); -/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */ -void add_to_crash_data(crash_data_t *crash_data, - const char *name, - const char *content); - -static inline struct crash_item *get_crash_data_item_or_NULL(crash_data_t *crash_data, const char *key) -{ - return (struct crash_item *)g_hash_table_lookup(crash_data, key); -} -const char *get_crash_item_content_or_NULL(crash_data_t *crash_data, const char *key); -/* Aborts if key is not found: */ -const char *get_crash_item_content_or_die(crash_data_t *crash_data, const char *key); - - -/* Vector of these structures */ - -typedef GPtrArray vector_of_crash_data_t; - -static inline crash_data_t *get_crash_data(vector_of_crash_data_t *vector, unsigned i) -{ - return (crash_data_t *)g_ptr_array_index(vector, i); -} - -vector_of_crash_data_t *new_vector_of_crash_data(void); -static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) -{ - if (vector) - g_ptr_array_free(vector, TRUE); -} - - -/* Conversions between in-memory and on-disk formats */ - -crash_data_t *load_crash_data_from_crash_dump_dir(struct dump_dir *dd); -struct dump_dir *create_crash_dump_dir(crash_data_t *crash_data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/include/dump_dir.h b/src/include/dump_dir.h deleted file mode 100644 index 8cec9459..00000000 --- a/src/include/dump_dir.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - On-disk storage of crash dumps - - 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. -*/ -#ifndef DUMP_DIR_H_ -#define DUMP_DIR_H_ - -/* For DIR */ -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - DD_FAIL_QUIETLY = (1 << 0), -}; - -struct dump_dir { - char *dd_dir; - DIR *next_dir; - int locked; - uid_t dd_uid; - gid_t dd_gid; -}; - -void dd_close(struct dump_dir *dd); - -struct dump_dir *dd_opendir(const char *dir, int flags); -struct dump_dir *dd_create(const char *dir, uid_t uid); -int dd_exist(struct dump_dir *dd, const char *path); -DIR *dd_init_next_file(struct dump_dir *dd); -int dd_get_next_file(struct dump_dir *dd, char **short_name, char **full_name); - -enum { - /* DD_FAIL_QUIETLY bit is valid for dd_load_text_ext too, */ - DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (1 << 1), -}; -char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned flags); -char* dd_load_text(const struct dump_dir *dd, const char *name); -void dd_save_text(struct dump_dir *dd, const char *name, const char *data); -void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size); -void dd_delete(struct dump_dir *dd); - -void delete_crash_dump_dir(const char *dd_dir); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/include/report/crash_dump.h b/src/include/report/crash_dump.h new file mode 100644 index 00000000..10ddc885 --- /dev/null +++ b/src/include/report/crash_dump.h @@ -0,0 +1,100 @@ +/* + Copyright (C) 2009 Abrt team. + 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. +*/ +#ifndef CRASH_DUMP_H_ +#define CRASH_DUMP_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct dump_dir; + +enum { + CD_FLAG_SYS = (1 << 0), + CD_FLAG_BIN = (1 << 1), + CD_FLAG_TXT = (1 << 2), + CD_FLAG_ISEDITABLE = (1 << 3), + CD_FLAG_ISNOTEDITABLE = (1 << 4), +}; + +struct crash_item { + char *content; + unsigned flags; +}; +typedef struct crash_item crash_item; + +/* In-memory crash data structure and accessors */ + +typedef GHashTable crash_data_t; + +crash_data_t *new_crash_data(void); + +static inline void free_crash_data(crash_data_t *crash_data) +{ + if (crash_data) + g_hash_table_destroy(crash_data); +} + +void add_to_crash_data_ext(crash_data_t *crash_data, + const char *name, + const char *content, + unsigned flags); +/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */ +void add_to_crash_data(crash_data_t *crash_data, + const char *name, + const char *content); + +static inline struct crash_item *get_crash_data_item_or_NULL(crash_data_t *crash_data, const char *key) +{ + return (struct crash_item *)g_hash_table_lookup(crash_data, key); +} +const char *get_crash_item_content_or_NULL(crash_data_t *crash_data, const char *key); +/* Aborts if key is not found: */ +const char *get_crash_item_content_or_die(crash_data_t *crash_data, const char *key); + + +/* Vector of these structures */ + +typedef GPtrArray vector_of_crash_data_t; + +static inline crash_data_t *get_crash_data(vector_of_crash_data_t *vector, unsigned i) +{ + return (crash_data_t *)g_ptr_array_index(vector, i); +} + +vector_of_crash_data_t *new_vector_of_crash_data(void); +static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) +{ + if (vector) + g_ptr_array_free(vector, TRUE); +} + + +/* Conversions between in-memory and on-disk formats */ + +crash_data_t *load_crash_data_from_crash_dump_dir(struct dump_dir *dd); +struct dump_dir *create_crash_dump_dir(crash_data_t *crash_data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/report/dump_dir.h b/src/include/report/dump_dir.h new file mode 100644 index 00000000..8cec9459 --- /dev/null +++ b/src/include/report/dump_dir.h @@ -0,0 +1,68 @@ +/* + On-disk storage of crash dumps + + 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. +*/ +#ifndef DUMP_DIR_H_ +#define DUMP_DIR_H_ + +/* For DIR */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + DD_FAIL_QUIETLY = (1 << 0), +}; + +struct dump_dir { + char *dd_dir; + DIR *next_dir; + int locked; + uid_t dd_uid; + gid_t dd_gid; +}; + +void dd_close(struct dump_dir *dd); + +struct dump_dir *dd_opendir(const char *dir, int flags); +struct dump_dir *dd_create(const char *dir, uid_t uid); +int dd_exist(struct dump_dir *dd, const char *path); +DIR *dd_init_next_file(struct dump_dir *dd); +int dd_get_next_file(struct dump_dir *dd, char **short_name, char **full_name); + +enum { + /* DD_FAIL_QUIETLY bit is valid for dd_load_text_ext too, */ + DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (1 << 1), +}; +char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned flags); +char* dd_load_text(const struct dump_dir *dd, const char *name); +void dd_save_text(struct dump_dir *dd, const char *name, const char *data); +void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size); +void dd_delete(struct dump_dir *dd); + +void delete_crash_dump_dir(const char *dd_dir); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h new file mode 100644 index 00000000..c2e34650 --- /dev/null +++ b/src/include/report/run_event.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2009 Abrt team. + 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. +*/ +#ifndef RUN_EVENT_H_ +#define RUN_EVENT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +struct dump_dir; + +struct run_event_state { + int (*post_run_callback)(const char *dump_dir_name, void *param); + void *post_run_param; + char* (*logging_callback)(char *log_line, void *param); + void *logging_param; +}; +struct run_event_state *new_run_event_state(void); +void free_run_event_state(struct run_event_state *state); + +/* Returns exitcode of first failed action, or first nonzero return value + * of post_run_callback. If all actions are successful, returns 0. + * If no actions were run for the event, returns -1. + */ +int run_event(struct run_event_state *state, const char *dump_dir_name, const char *event); +char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/run_event.h b/src/include/run_event.h deleted file mode 100644 index c2e34650..00000000 --- a/src/include/run_event.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2009 Abrt team. - 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. -*/ -#ifndef RUN_EVENT_H_ -#define RUN_EVENT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -struct dump_dir; - -struct run_event_state { - int (*post_run_callback)(const char *dump_dir_name, void *param); - void *post_run_param; - char* (*logging_callback)(char *log_line, void *param); - void *logging_param; -}; -struct run_event_state *new_run_event_state(void); -void free_run_event_state(struct run_event_state *state); - -/* Returns exitcode of first failed action, or first nonzero return value - * of post_run_callback. If all actions are successful, returns 0. - * If no actions were run for the event, returns -1. - */ -int run_event(struct run_event_state *state, const char *dump_dir_name, const char *event); -char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); - -#ifdef __cplusplus -} -#endif - -#endif -- cgit From 6a2b728d7525214402eff838bb37be175ddce6c3 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 15 Dec 2010 18:44:55 +0100 Subject: Rename foo_crash_dump_dir -> foo_dump_dir To be exact, these three functions are renamed: load_crash_data_from_crash_dump_dir create_crash_dump_dir delete_crash_dump_dir Rationale: data structure is called "struct dump_dir", not "struct crash_dump_dir" Signed-off-by: Denys Vlasenko --- src/include/report/crash_dump.h | 4 ++-- src/include/report/dump_dir.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/include') diff --git a/src/include/report/crash_dump.h b/src/include/report/crash_dump.h index 10ddc885..aabfa022 100644 --- a/src/include/report/crash_dump.h +++ b/src/include/report/crash_dump.h @@ -90,8 +90,8 @@ static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) /* Conversions between in-memory and on-disk formats */ -crash_data_t *load_crash_data_from_crash_dump_dir(struct dump_dir *dd); -struct dump_dir *create_crash_dump_dir(crash_data_t *crash_data); +crash_data_t *load_crash_data_from_dump_dir(struct dump_dir *dd); +struct dump_dir *create_dump_dir(crash_data_t *crash_data); #ifdef __cplusplus } diff --git a/src/include/report/dump_dir.h b/src/include/report/dump_dir.h index 8cec9459..bf3b120d 100644 --- a/src/include/report/dump_dir.h +++ b/src/include/report/dump_dir.h @@ -59,7 +59,7 @@ void dd_save_text(struct dump_dir *dd, const char *name, const char *data); void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size); void dd_delete(struct dump_dir *dd); -void delete_crash_dump_dir(const char *dd_dir); +void delete_dump_dir(const char *dd_dir); #ifdef __cplusplus } -- cgit From 628fb1fbae2a9e3e8fc3add070bceb5557973029 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 16 Dec 2010 18:28:07 +0100 Subject: create_dump_dir: add base_dir_name parameter. This makes python wrappers more usable. src/report-python/test_full demonstrates how pyhton programs can run reporting now. Signed-off-by: Denys Vlasenko --- src/include/report/crash_dump.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/report/crash_dump.h b/src/include/report/crash_dump.h index aabfa022..86cdadd0 100644 --- a/src/include/report/crash_dump.h +++ b/src/include/report/crash_dump.h @@ -91,7 +91,7 @@ static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) /* Conversions between in-memory and on-disk formats */ crash_data_t *load_crash_data_from_dump_dir(struct dump_dir *dd); -struct dump_dir *create_dump_dir(crash_data_t *crash_data); +struct dump_dir *create_dump_dir(crash_data_t *crash_data, const char *base_dir_name); #ifdef __cplusplus } -- cgit From df1b1d501106687fcf0039dc9771c4455c346df5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 22 Dec 2010 13:57:14 +0100 Subject: *: rename *crash_dump.* -> *crash_data.* Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 4 +- src/include/abrt_crash_data.h | 88 +++++++++++++++++++++++++++++++++++ src/include/abrt_crash_dump.h | 88 ----------------------------------- src/include/abrtlib.h | 2 +- src/include/dbus_common.h | 2 +- src/include/plugin.h | 2 +- src/include/report/crash_data.h | 100 ++++++++++++++++++++++++++++++++++++++++ src/include/report/crash_dump.h | 100 ---------------------------------------- 8 files changed, 193 insertions(+), 193 deletions(-) create mode 100644 src/include/abrt_crash_data.h delete mode 100644 src/include/abrt_crash_dump.h create mode 100644 src/include/report/crash_data.h delete mode 100644 src/include/report/crash_dump.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 165c705b..b5d604ef 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -1,6 +1,6 @@ libreport_includedir = $(includedir)/report libreport_include_HEADERS = \ - report/crash_dump.h \ + report/crash_data.h \ report/dump_dir.h \ report/run_event.h @@ -9,7 +9,7 @@ libabrt_include_HEADERS = \ abrtlib.h \ abrt_types.h \ comm_layer_inner.h \ - abrt_crash_dump.h \ + abrt_crash_data.h \ dbus_common.h \ observer.h \ plugin.h \ diff --git a/src/include/abrt_crash_data.h b/src/include/abrt_crash_data.h new file mode 100644 index 00000000..b3278858 --- /dev/null +++ b/src/include/abrt_crash_data.h @@ -0,0 +1,88 @@ +/* + Copyright (C) 2009 Abrt team. + 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. +*/ +#ifndef ABRT_CRASH_DUMP_H_ +#define ABRT_CRASH_DUMP_H_ + +#include "crash_data.h" +#include "abrt_types.h" + +// Text bigger than this usually is attached, not added inline +#define CD_TEXT_ATT_SIZE (2*1024) + +// Keep in sync with CCDump.py: + +// Filenames in dump directory: +// filled by a hook: +#define FILENAME_ANALYZER "analyzer" +#define FILENAME_EXECUTABLE "executable" +#define FILENAME_BINARY "binary" +#define FILENAME_CMDLINE "cmdline" +#define FILENAME_REASON "reason" +#define FILENAME_COREDUMP "coredump" +#define FILENAME_BACKTRACE "backtrace" +#define FILENAME_MEMORYMAP "memorymap" +#define FILENAME_DUPHASH "global_uuid" /* name is compat, to be renamed to "duphash" */ +// Name of the function where the application crashed. +// Optional. +#define FILENAME_CRASH_FUNCTION "crash_function" +// filled by CDebugDump::Create() (which also fills FILENAME_UID): +#define FILENAME_ARCHITECTURE "architecture" +#define FILENAME_KERNEL "kernel" +#define FILENAME_TIME "time" +#define FILENAME_RELEASE "release" /* from /etc/redhat-release */ +// filled by +#define FILENAME_PACKAGE "package" +#define FILENAME_COMPONENT "component" +#define FILENAME_DESCRIPTION "description" /* package descr (not crash descr) */ +#define FILENAME_COMMENT "comment" +#define FILENAME_REPRODUCE "reproduce" +#define FILENAME_RATING "rating" +#define FILENAME_HOSTNAME "hostname" +// Optional. Set to "1" by abrt-handle-upload for every unpacked crashdump +#define FILENAME_REMOTE "remote" +#define FILENAME_TAINTED "kernel_tainted" +// TODO: TicketUploader also has open-coded "TICKET", "CUSTOMER" files + +#define FILENAME_UID "uid" +#define FILENAME_UUID "uuid" +#define FILENAME_INFORMALL "inform_all_users" +#define FILENAME_COUNT "count" +#define FILENAME_MESSAGE "message" +// Not stored as files, added "on the fly": +#define CD_DUMPDIR "DumpDir" +// "Which events are possible (make sense) on this crash dump?" +// (a string with "\n" terminated event names) +#define CD_EVENTS "Events" + + +#ifdef __cplusplus +extern "C" { +#endif + +#define is_editable_file abrt_is_editable_file +bool is_editable_file(const char *file_name); + +#define log_crash_data abrt_log_crash_data +void log_crash_data(crash_data_t *crash_data, const char *pfx); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/abrt_crash_dump.h b/src/include/abrt_crash_dump.h deleted file mode 100644 index 9ecbf56d..00000000 --- a/src/include/abrt_crash_dump.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2009 Abrt team. - 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. -*/ -#ifndef ABRT_CRASH_DUMP_H_ -#define ABRT_CRASH_DUMP_H_ - -#include "crash_dump.h" -#include "abrt_types.h" - -// Text bigger than this usually is attached, not added inline -#define CD_TEXT_ATT_SIZE (2*1024) - -// Keep in sync with CCDump.py: - -// Filenames in dump directory: -// filled by a hook: -#define FILENAME_ANALYZER "analyzer" -#define FILENAME_EXECUTABLE "executable" -#define FILENAME_BINARY "binary" -#define FILENAME_CMDLINE "cmdline" -#define FILENAME_REASON "reason" -#define FILENAME_COREDUMP "coredump" -#define FILENAME_BACKTRACE "backtrace" -#define FILENAME_MEMORYMAP "memorymap" -#define FILENAME_DUPHASH "global_uuid" /* name is compat, to be renamed to "duphash" */ -// Name of the function where the application crashed. -// Optional. -#define FILENAME_CRASH_FUNCTION "crash_function" -// filled by CDebugDump::Create() (which also fills FILENAME_UID): -#define FILENAME_ARCHITECTURE "architecture" -#define FILENAME_KERNEL "kernel" -#define FILENAME_TIME "time" -#define FILENAME_RELEASE "release" /* from /etc/redhat-release */ -// filled by -#define FILENAME_PACKAGE "package" -#define FILENAME_COMPONENT "component" -#define FILENAME_DESCRIPTION "description" /* package descr (not crash descr) */ -#define FILENAME_COMMENT "comment" -#define FILENAME_REPRODUCE "reproduce" -#define FILENAME_RATING "rating" -#define FILENAME_HOSTNAME "hostname" -// Optional. Set to "1" by abrt-handle-upload for every unpacked crashdump -#define FILENAME_REMOTE "remote" -#define FILENAME_TAINTED "kernel_tainted" -// TODO: TicketUploader also has open-coded "TICKET", "CUSTOMER" files - -#define FILENAME_UID "uid" -#define FILENAME_UUID "uuid" -#define FILENAME_INFORMALL "inform_all_users" -#define FILENAME_COUNT "count" -#define FILENAME_MESSAGE "message" -// Not stored as files, added "on the fly": -#define CD_DUMPDIR "DumpDir" -// "Which events are possible (make sense) on this crash dump?" -// (a string with "\n" terminated event names) -#define CD_EVENTS "Events" - - -#ifdef __cplusplus -extern "C" { -#endif - -#define is_editable_file abrt_is_editable_file -bool is_editable_file(const char *file_name); - -#define log_map_crash_data abrt_log_map_crash_data -void log_map_crash_data(crash_data_t *crash_data, const char *pfx); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index d3f355e9..0eb0f2d0 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -77,7 +77,7 @@ int vdprintf(int d, const char *format, va_list ap); #include "hash_sha1.h" #include "hash_md5.h" -#include "abrt_crash_dump.h" +#include "abrt_crash_data.h" #include "abrt_types.h" #include "dump_dir.h" #include "run_event.h" diff --git a/src/include/dbus_common.h b/src/include/dbus_common.h index 6c739169..4e980d34 100644 --- a/src/include/dbus_common.h +++ b/src/include/dbus_common.h @@ -19,7 +19,7 @@ #ifndef DBUSCOMMON_H_ #define DBUSCOMMON_H_ -#include "abrt_crash_dump.h" +#include "abrt_crash_data.h" #define ABRTD_DBUS_NAME "com.redhat.abrt" #define ABRTD_DBUS_PATH "/com/redhat/abrt" diff --git a/src/include/plugin.h b/src/include/plugin.h index 322c212f..e3f1f81f 100644 --- a/src/include/plugin.h +++ b/src/include/plugin.h @@ -23,7 +23,7 @@ #define PLUGIN_H_ #include "abrt_types.h" -#include "abrt_crash_dump.h" +#include "abrt_crash_data.h" #define PLUGINS_MAGIC_NUMBER 6 diff --git a/src/include/report/crash_data.h b/src/include/report/crash_data.h new file mode 100644 index 00000000..86cdadd0 --- /dev/null +++ b/src/include/report/crash_data.h @@ -0,0 +1,100 @@ +/* + Copyright (C) 2009 Abrt team. + 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. +*/ +#ifndef CRASH_DUMP_H_ +#define CRASH_DUMP_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct dump_dir; + +enum { + CD_FLAG_SYS = (1 << 0), + CD_FLAG_BIN = (1 << 1), + CD_FLAG_TXT = (1 << 2), + CD_FLAG_ISEDITABLE = (1 << 3), + CD_FLAG_ISNOTEDITABLE = (1 << 4), +}; + +struct crash_item { + char *content; + unsigned flags; +}; +typedef struct crash_item crash_item; + +/* In-memory crash data structure and accessors */ + +typedef GHashTable crash_data_t; + +crash_data_t *new_crash_data(void); + +static inline void free_crash_data(crash_data_t *crash_data) +{ + if (crash_data) + g_hash_table_destroy(crash_data); +} + +void add_to_crash_data_ext(crash_data_t *crash_data, + const char *name, + const char *content, + unsigned flags); +/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */ +void add_to_crash_data(crash_data_t *crash_data, + const char *name, + const char *content); + +static inline struct crash_item *get_crash_data_item_or_NULL(crash_data_t *crash_data, const char *key) +{ + return (struct crash_item *)g_hash_table_lookup(crash_data, key); +} +const char *get_crash_item_content_or_NULL(crash_data_t *crash_data, const char *key); +/* Aborts if key is not found: */ +const char *get_crash_item_content_or_die(crash_data_t *crash_data, const char *key); + + +/* Vector of these structures */ + +typedef GPtrArray vector_of_crash_data_t; + +static inline crash_data_t *get_crash_data(vector_of_crash_data_t *vector, unsigned i) +{ + return (crash_data_t *)g_ptr_array_index(vector, i); +} + +vector_of_crash_data_t *new_vector_of_crash_data(void); +static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) +{ + if (vector) + g_ptr_array_free(vector, TRUE); +} + + +/* Conversions between in-memory and on-disk formats */ + +crash_data_t *load_crash_data_from_dump_dir(struct dump_dir *dd); +struct dump_dir *create_dump_dir(crash_data_t *crash_data, const char *base_dir_name); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/report/crash_dump.h b/src/include/report/crash_dump.h deleted file mode 100644 index 86cdadd0..00000000 --- a/src/include/report/crash_dump.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2009 Abrt team. - 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. -*/ -#ifndef CRASH_DUMP_H_ -#define CRASH_DUMP_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct dump_dir; - -enum { - CD_FLAG_SYS = (1 << 0), - CD_FLAG_BIN = (1 << 1), - CD_FLAG_TXT = (1 << 2), - CD_FLAG_ISEDITABLE = (1 << 3), - CD_FLAG_ISNOTEDITABLE = (1 << 4), -}; - -struct crash_item { - char *content; - unsigned flags; -}; -typedef struct crash_item crash_item; - -/* In-memory crash data structure and accessors */ - -typedef GHashTable crash_data_t; - -crash_data_t *new_crash_data(void); - -static inline void free_crash_data(crash_data_t *crash_data) -{ - if (crash_data) - g_hash_table_destroy(crash_data); -} - -void add_to_crash_data_ext(crash_data_t *crash_data, - const char *name, - const char *content, - unsigned flags); -/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */ -void add_to_crash_data(crash_data_t *crash_data, - const char *name, - const char *content); - -static inline struct crash_item *get_crash_data_item_or_NULL(crash_data_t *crash_data, const char *key) -{ - return (struct crash_item *)g_hash_table_lookup(crash_data, key); -} -const char *get_crash_item_content_or_NULL(crash_data_t *crash_data, const char *key); -/* Aborts if key is not found: */ -const char *get_crash_item_content_or_die(crash_data_t *crash_data, const char *key); - - -/* Vector of these structures */ - -typedef GPtrArray vector_of_crash_data_t; - -static inline crash_data_t *get_crash_data(vector_of_crash_data_t *vector, unsigned i) -{ - return (crash_data_t *)g_ptr_array_index(vector, i); -} - -vector_of_crash_data_t *new_vector_of_crash_data(void); -static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) -{ - if (vector) - g_ptr_array_free(vector, TRUE); -} - - -/* Conversions between in-memory and on-disk formats */ - -crash_data_t *load_crash_data_from_dump_dir(struct dump_dir *dd); -struct dump_dir *create_dump_dir(crash_data_t *crash_data, const char *base_dir_name); - -#ifdef __cplusplus -} -#endif - -#endif -- cgit From dba326f60e159697a740f08959d098e19c200453 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 22 Dec 2010 16:28:39 +0100 Subject: extend run_event() to run_event_on_dir_name() and run_event_on_crash_data() Signed-off-by: Denys Vlasenko --- src/include/report/crash_data.h | 10 ++++++---- src/include/report/run_event.h | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/include') diff --git a/src/include/report/crash_data.h b/src/include/report/crash_data.h index 86cdadd0..86543a4f 100644 --- a/src/include/report/crash_data.h +++ b/src/include/report/crash_data.h @@ -16,8 +16,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef CRASH_DUMP_H_ -#define CRASH_DUMP_H_ +#ifndef CRASH_DATA_H_ +#define CRASH_DATA_H_ #include @@ -90,8 +90,10 @@ static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) /* Conversions between in-memory and on-disk formats */ -crash_data_t *load_crash_data_from_dump_dir(struct dump_dir *dd); -struct dump_dir *create_dump_dir(crash_data_t *crash_data, const char *base_dir_name); +void load_crash_data_from_dump_dir(crash_data_t *crash_data, struct dump_dir *dd); +crash_data_t *create_crash_data_from_dump_dir(struct dump_dir *dd); + +struct dump_dir *create_dump_dir_from_crash_data(crash_data_t *crash_data, const char *base_dir_name); #ifdef __cplusplus } diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index c2e34650..b58ea66a 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -19,6 +19,8 @@ #ifndef RUN_EVENT_H_ #define RUN_EVENT_H_ +#include "crash_data.h" + #ifdef __cplusplus extern "C" { #endif @@ -38,7 +40,8 @@ void free_run_event_state(struct run_event_state *state); * of post_run_callback. If all actions are successful, returns 0. * If no actions were run for the event, returns -1. */ -int run_event(struct run_event_state *state, const char *dump_dir_name, const char *event); +int run_event_on_dir_name(struct run_event_state *state, const char *dump_dir_name, const char *event); +int run_event_on_crash_data(struct run_event_state *state, crash_data_t *data, const char *event); char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); #ifdef __cplusplus -- cgit From 3b1a9d1f8db031563903a493be755419d7ba6620 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 4 Jan 2011 16:23:21 +0100 Subject: dump_dir: make chown'ing of new files optional - needed for non-root usage Signed-off-by: Denys Vlasenko --- src/include/report/dump_dir.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/include') diff --git a/src/include/report/dump_dir.h b/src/include/report/dump_dir.h index bf3b120d..4f2914d0 100644 --- a/src/include/report/dump_dir.h +++ b/src/include/report/dump_dir.h @@ -44,6 +44,9 @@ struct dump_dir { void dd_close(struct dump_dir *dd); struct dump_dir *dd_opendir(const char *dir, int flags); +/* Pass uid = (uid_t)-1L to disable chown'ing of newly created files + * (IOW: if you aren't running under root): + */ struct dump_dir *dd_create(const char *dir, uid_t uid); int dd_exist(struct dump_dir *dd, const char *path); DIR *dd_init_next_file(struct dump_dir *dd); -- cgit From d108d7d2fbe0b178110295fd8335c258f699a5d4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 6 Jan 2011 16:18:09 +0100 Subject: pass old pattern to ccpp hook and use it abrtd: instead of "|/usr/libexec/abrt-ccpp-hook DEBUG_DUMPS_DIR %p %s %u %c", sets coredump handler to "|/usr/libexec/abrt-ccpp-hook DEBUG_DUMPS_DIR %s %c %p %u %g %t %h %e OLD_PATTERN" abrt-ccpp-hook: expands OLD_PATTERN using values of %s %c %p %u %g %t %h %e and uses it as a name of "compat coredump". Patch has a feature which prevents usage of kernel-truncated OLD_PATTERN: it is passed as hex string *with terminating NUL* (encoded as 00). If ccpp hook doesn't see 00, it refuses to use OLD_PATTERN and uses string "core" instead. Run tested. On a new kernel, passes up to 27 char long old pattern. Longer patterns are still truncated. This may be improved in future kernels. Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 0eb0f2d0..2e23805a 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -233,6 +233,11 @@ double get_dirsize_find_largest_dir( const char *excluded /* can be NULL */ ); +/* Emit a string of hex representation of bytes */ +char* bin2hex(char *dst, const char *str, int count); +/* Convert "xxxxxxxx" hex string to binary, no more than COUNT bytes */ +char* hex2bin(char *dst, const char *str, int count); + /* Returns command line of running program. * Caller is responsible to free() the returned value. * If the pid is not valid or command line can not be obtained, -- cgit From f4dcdc9a1ee5971bfda6acf079d615a6f40382b1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 11 Jan 2011 18:51:20 +0100 Subject: do not pollute library namespace: prefix bin2hex and hex2bin with abrt_ Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 2e23805a..9f428486 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -234,8 +234,10 @@ double get_dirsize_find_largest_dir( ); /* Emit a string of hex representation of bytes */ +#define bin2hex abrt_bin2hex char* bin2hex(char *dst, const char *str, int count); /* Convert "xxxxxxxx" hex string to binary, no more than COUNT bytes */ +#define hex2bin abrt_hex2bin char* hex2bin(char *dst, const char *str, int count); /* Returns command line of running program. -- cgit From e7fde9b01293d7bfdfe644b73f8ac679211d0b08 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 11 Jan 2011 18:53:22 +0100 Subject: remove C++-ism ssprintf from abrtlib.h Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 9f428486..88e52fff 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -283,23 +283,4 @@ bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWith } #endif - -/* C++ style stuff */ -#ifdef __cplusplus -// TODO: npajkovs: full rewrite ssprintf -> xasprintf -static inline std::string ssprintf(const char *format, ...) -{ - va_list p; - char *string_ptr; - - va_start(p, format); - string_ptr = xvasprintf(format, p); - va_end(p); - - std::string res = string_ptr; - free(string_ptr); - return res; -} -#endif - #endif -- cgit From 6cff54c0b97d162e8c0461a28b10c260495458f2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 14 Jan 2011 14:02:07 +0100 Subject: preliminary cleanup patches Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 82 +++++++++++++-------------------------------------- 1 file changed, 21 insertions(+), 61 deletions(-) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 88e52fff..0c0d4be4 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -147,24 +147,24 @@ int xatoi_positive(const char *numstr); //unsigned monotonic_sec(void); enum { - /* on return, pipefds[1] is fd to which parent may write - * and deliver data to child's stdin: */ - EXECFLG_INPUT = 1 << 0, - /* on return, pipefds[0] is fd from which parent may read - * child's stdout: */ - EXECFLG_OUTPUT = 1 << 1, - /* open child's stdin to /dev/null: */ - EXECFLG_INPUT_NUL = 1 << 2, - /* open child's stdout to /dev/null: */ - EXECFLG_OUTPUT_NUL = 1 << 3, - /* redirect child's stderr to stdout: */ - EXECFLG_ERR2OUT = 1 << 4, - /* open child's stderr to /dev/null: */ - EXECFLG_ERR_NUL = 1 << 5, - /* suppress perror_msg("Can't execute 'foo'") if exec fails */ - EXECFLG_QUIET = 1 << 6, - EXECFLG_SETGUID = 1 << 7, - EXECFLG_SETSID = 1 << 8, + /* on return, pipefds[1] is fd to which parent may write + * and deliver data to child's stdin: */ + EXECFLG_INPUT = 1 << 0, + /* on return, pipefds[0] is fd from which parent may read + * child's stdout: */ + EXECFLG_OUTPUT = 1 << 1, + /* open child's stdin to /dev/null: */ + EXECFLG_INPUT_NUL = 1 << 2, + /* open child's stdout to /dev/null: */ + EXECFLG_OUTPUT_NUL = 1 << 3, + /* redirect child's stderr to stdout: */ + EXECFLG_ERR2OUT = 1 << 4, + /* open child's stderr to /dev/null: */ + EXECFLG_ERR_NUL = 1 << 5, + /* suppress perror_msg("Can't execute 'foo'") if exec fails */ + EXECFLG_QUIET = 1 << 6, + EXECFLG_SETGUID = 1 << 7, + EXECFLG_SETSID = 1 << 8, }; /* Returns pid */ #define fork_execv_on_steroids abrt_fork_execv_on_steroids @@ -178,49 +178,9 @@ pid_t fork_execv_on_steroids(int flags, * after the last byte (this NUL is not accounted for in *size_p) */ #define run_in_shell_and_save_output abrt_run_in_shell_and_save_output char *run_in_shell_and_save_output(int flags, - const char *cmd, - const char *dir, - size_t *size_p); - -//unused for now -///* Networking helpers */ -//typedef struct len_and_sockaddr { -// socklen_t len; -// union { -// struct sockaddr sa; -// struct sockaddr_in sin; -// struct sockaddr_in6 sin6; -// } u; -//} len_and_sockaddr; -//enum { -// LSA_LEN_SIZE = offsetof(len_and_sockaddr, u), -// LSA_SIZEOF_SA = sizeof(struct sockaddr) > sizeof(struct sockaddr_in6) ? -// sizeof(struct sockaddr) : sizeof(struct sockaddr_in6), -//}; -//void setsockopt_reuseaddr(int fd); -//int setsockopt_broadcast(int fd); -//int setsockopt_bindtodevice(int fd, const char *iface); -//len_and_sockaddr* get_sock_lsa(int fd); -//void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); -//unsigned lookup_port(const char *port, const char *protocol, unsigned default_port); -//int get_nport(const struct sockaddr *sa); -//void set_nport(len_and_sockaddr *lsa, unsigned port); -//len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af); -//len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af); -//len_and_sockaddr* host2sockaddr(const char *host, int port); -//len_and_sockaddr* xhost2sockaddr(const char *host, int port); -//len_and_sockaddr* xdotted2sockaddr(const char *host, int port); -//int xsocket_type(len_and_sockaddr **lsap, int family, int sock_type); -//int xsocket_stream(len_and_sockaddr **lsap); -//int create_and_bind_stream_or_die(const char *bindaddr, int port); -//int create_and_bind_dgram_or_die(const char *bindaddr, int port); -//int create_and_connect_stream_or_die(const char *peer, int port); -//int xconnect_stream(const len_and_sockaddr *lsa); -//char* xmalloc_sockaddr2host(const struct sockaddr *sa); -//char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa); -//char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa); -//char* xmalloc_sockaddr2dotted(const struct sockaddr *sa); -//char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa); + const char *cmd, + const char *dir, + size_t *size_p); /* Random utility functions */ -- cgit From 480cac7647d567c3c3cb148c5a4750091b651934 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 19 Jan 2011 17:14:05 +0100 Subject: remove old plugin machinery. -10k and -1 library dependence in abrtd Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 2 -- src/include/action.h | 44 -------------------------- src/include/analyzer.h | 34 -------------------- src/include/plugin.h | 84 ------------------------------------------------- 4 files changed, 164 deletions(-) delete mode 100644 src/include/action.h delete mode 100644 src/include/analyzer.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index b5d604ef..cf524f7e 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -13,6 +13,4 @@ libabrt_include_HEADERS = \ dbus_common.h \ observer.h \ plugin.h \ - action.h \ - analyzer.h \ xfuncs.h diff --git a/src/include/action.h b/src/include/action.h deleted file mode 100644 index 21183366..00000000 --- a/src/include/action.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Action.h - header file for action plugin - - 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. -*/ -#ifndef ACTION_H_ -#define ACTION_H_ - -#include "plugin.h" - -/** - * An abstract class. The class defines an action plugin interface. - */ -class CAction : public CPlugin -{ - public: - /** - * A Method which performs particular action. As the first parameter it - * takes an action directory. It could be either a directory of actual - * crash or it could be a directory contains all crashes. It depends on - * who call the plugin. The plugin can takes arguments, but the plugin - * has to parse them by itself. - * @param pActionDir An actual directory. - * @param pArgs Plugin's arguments. - */ - virtual void Run(const char *pActionDir, const char *pArgs, int force) = 0; -}; - -#endif diff --git a/src/include/analyzer.h b/src/include/analyzer.h deleted file mode 100644 index 1d78d576..00000000 --- a/src/include/analyzer.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - Analyzer.h - header file for analyzer plugin - - 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. -*/ -#ifndef ANALYZER_H_ -#define ANALYZER_H_ - -#include -#include "plugin.h" - -/** - * An abstract class. The class defines an analyzer plugin interface. - */ -class CAnalyzer : public CPlugin -{ -}; - -#endif /*ANALYZER_H_*/ diff --git a/src/include/plugin.h b/src/include/plugin.h index e3f1f81f..5af5753c 100644 --- a/src/include/plugin.h +++ b/src/include/plugin.h @@ -25,90 +25,6 @@ #include "abrt_types.h" #include "abrt_crash_data.h" -#define PLUGINS_MAGIC_NUMBER 6 - #define PLUGINS_CONF_EXTENSION "conf" -#define PLUGINS_LIB_EXTENSION "so" -#define PLUGINS_LIB_PREFIX "lib" - -/** - * An abstract class. The class defines a common plugin interface. If a plugin - * has some settings, then a *Settings(*) method has to be written. - */ -class CPlugin -{ - protected: - map_plugin_settings_t m_pSettings; - - public: - CPlugin(); - /** - * A destructor. - */ - virtual ~CPlugin(); - /** - * A method, which initializes a plugin. It is not mandatory method. - */ - virtual void Init(); - /** - * A method, which deinitializes a plugin. It is not mandatory method. - */ - virtual void DeInit(); - /** - * A method, which takes a settings and apply them. It is not a mandatory method. - * @param pSettings Plugin's settings - */ - virtual void SetSettings(const map_plugin_settings_t& pSettings); - /** - * A method, which return current settings. It is not mandatory method. - * @return Plugin's settings - */ -/// -// virtual const map_plugin_settings_t& GetSettings(); -}; - -/** - * An enum of plugin types. - */ -typedef enum { - ANALYZER, /**< An analyzer plugin*/ - ACTION, /**< An action plugin*/ - REPORTER, /**< A reporter plugin*/ - DATABASE, /**< A database plugin*/ - MAX_PLUGIN_TYPE = DATABASE, - INVALID_PLUGIN_TYPE -} plugin_type_t; - -/** - * A struct contains all needed data about particular plugin. - */ -typedef struct SPluginInfo -{ - const plugin_type_t m_Type; /**< Plugin type.*/ - const char *const m_sName; /**< Plugin name.*/ - const char *const m_sVersion; /**< Plugin version.*/ - const char *const m_sDescription; /**< Plugin description.*/ - const char *const m_sEmail; /**< Plugin author's email.*/ - const char *const m_sWWW; /**< Plugin's home page.*/ - const char *const m_sGTKBuilder; /**< Plugin's gui description.*/ - const int m_nMagicNumber; /**< Plugin magical number.*/ -} plugin_info_t; - -#define PLUGIN_INFO(type, plugin_class, name, version, description, email, www, gtk_builder)\ - extern "C" CPlugin* plugin_new()\ - {\ - return new plugin_class();\ - }\ - extern "C" const plugin_info_t plugin_info =\ - {\ - type,\ - name,\ - version,\ - description,\ - email,\ - www,\ - gtk_builder,\ - PLUGINS_MAGIC_NUMBER,\ - }; #endif -- cgit From d7d62ea5ee19f5cad52dcfb2f2a49d8d36fa1228 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 18:34:08 +0100 Subject: introduce and use new helper function list_free_with_free Signed-off-by: Denys Vlasenko --- src/include/abrt_types.h | 2 -- src/include/abrtlib.h | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/abrt_types.h b/src/include/abrt_types.h index 858c0c79..200946e1 100644 --- a/src/include/abrt_types.h +++ b/src/include/abrt_types.h @@ -19,8 +19,6 @@ #ifndef ABRT_TYPES_H_ #define ABRT_TYPES_H_ -#include - #ifdef __cplusplus extern "C" { #endif diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 0c0d4be4..4ad2f6fc 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -42,6 +42,7 @@ #ifdef __cplusplus # include #endif +#include #ifdef HAVE_CONFIG_H # include "config.h" @@ -184,6 +185,12 @@ char *run_in_shell_and_save_output(int flags, /* Random utility functions */ +/* Frees every element'd data using free(), + * then frees list itself using g_list_free(list): + */ +#define list_free_with_free abrt_list_free_with_free +void list_free_with_free(GList *list); + #define get_dirsize abrt_get_dirsize double get_dirsize(const char *pPath); #define get_dirsize_find_largest_dir abrt_get_dirsize_find_largest_dir -- cgit From 320724188859d96b0a974d9e84bacd49a614f97d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 20 Jan 2011 21:43:54 +0100 Subject: remove plugin.h, move its only macro into into only user Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 1 - src/include/plugin.h | 30 ------------------------------ 2 files changed, 31 deletions(-) delete mode 100644 src/include/plugin.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index cf524f7e..de9b39a2 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -12,5 +12,4 @@ libabrt_include_HEADERS = \ abrt_crash_data.h \ dbus_common.h \ observer.h \ - plugin.h \ xfuncs.h diff --git a/src/include/plugin.h b/src/include/plugin.h deleted file mode 100644 index 5af5753c..00000000 --- a/src/include/plugin.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Plugin.h - header file for plugin. It contains mandatory macros - and common function for plugins - - 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. -*/ -#ifndef PLUGIN_H_ -#define PLUGIN_H_ - -#include "abrt_types.h" -#include "abrt_crash_data.h" - -#define PLUGINS_CONF_EXTENSION "conf" - -#endif -- cgit From a387e6c91cd45ffc35c03e42bde7ba926231de4b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 21 Jan 2011 00:44:39 +0100 Subject: Remove CCrashWatcher and CObserver classes; merge libabrt_daemon into abrtd Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 2 -- src/include/comm_layer_inner.h | 61 ------------------------------------------ src/include/observer.h | 32 ---------------------- 3 files changed, 95 deletions(-) delete mode 100644 src/include/comm_layer_inner.h delete mode 100644 src/include/observer.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index de9b39a2..84e56d6d 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -8,8 +8,6 @@ libabrt_includedir = $(includedir)/abrt libabrt_include_HEADERS = \ abrtlib.h \ abrt_types.h \ - comm_layer_inner.h \ abrt_crash_data.h \ dbus_common.h \ - observer.h \ xfuncs.h diff --git a/src/include/comm_layer_inner.h b/src/include/comm_layer_inner.h deleted file mode 100644 index 2cca9add..00000000 --- a/src/include/comm_layer_inner.h +++ /dev/null @@ -1,61 +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 COMMLAYERINNER_H_ -#define COMMLAYERINNER_H_ - -#ifdef __cplusplus - -#include "observer.h" - -void init_daemon_logging(CObserver *pObs); - -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Set client's name (dbus ID). NULL unsets it. - */ -void set_client_name(const char* name); - -/* - * Ask a client to warn the user about a non-fatal, but unexpected condition. - * In GUI, it will usually be presented as a popup message. - * Usually there is no need to call it directly, just use [p]error_msg(). - */ -//now static: -//void warn_client(const char *msg); -//use [p]error_msg[_and_die] instead, it sends the message as a warning to client -//as well as to the log. - -/* - * Logs a message to a client. - * In UI, it will usually appear as a new status line message in GUI, - * or as a new message line in CLI. - */ -void update_client(const char *fmt, ...); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/include/observer.h b/src/include/observer.h deleted file mode 100644 index 1c8f2355..00000000 --- a/src/include/observer.h +++ /dev/null @@ -1,32 +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 OBSERVER_H_ -#define OBSERVER_H_ - -#include -#include "dbus_common.h" - -class CObserver { - public: - virtual ~CObserver() {} - virtual void Status(const char *pMessage, const char* peer) = 0; - virtual void Warning(const char *pMessage, const char* peer) = 0; -}; - -#endif -- cgit From 7f5cbf38caa3c6fdd0afe3a4cb7a9bd3b3010596 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Jan 2011 21:17:49 +0100 Subject: split parse_release() into Bz and RHTS versions Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 4ad2f6fc..22b63baf 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -228,8 +228,10 @@ char* make_description_logger(crash_data_t *crash_data); #define make_description_mailx abrt_make_description_mailx char* make_description_mailx(crash_data_t *crash_data); -#define parse_release abrt_parse_release -void parse_release(const char *pRelease, char **product, char **version); +#define parse_release_for_bz abrt_parse_release_for_bz +void parse_release_for_bz(const char *pRelease, char **product, char **version); +#define parse_release_for_rhts abrt_parse_release_for_rhts +void parse_release_for_rhts(const char *pRelease, char **product, char **version); /** * Loads settings and stores it in second parameter. On success it -- cgit From 5c71e00f814f679bd6ea652eda8552f746b5f725 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 27 Jan 2011 15:59:28 +0100 Subject: preparatory changes for abrt-cli local processing change Signed-off-by: Denys Vlasenko --- src/include/report/run_event.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/include') diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index b58ea66a..bab7cd2c 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -28,8 +28,12 @@ extern "C" { struct dump_dir; struct run_event_state { + /* Used only for post-create dup detection. TODO: document its API */ int (*post_run_callback)(const char *dump_dir_name, void *param); void *post_run_param; + /* Can take ownership of log_line, which is malloced. In this case, return NULL. + * Otherwise should return log_line (it will be freed by caller) + */ char* (*logging_callback)(char *log_line, void *param); void *logging_param; }; -- cgit From a96e56e3cd33b0ea5043793c1e56f4bd21c8a48c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 27 Jan 2011 16:00:37 +0100 Subject: run_event: add children_count Signed-off-by: Denys Vlasenko --- src/include/report/run_event.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/include') diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index bab7cd2c..4d06896a 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -28,6 +28,7 @@ extern "C" { struct dump_dir; struct run_event_state { + int children_count; /* Used only for post-create dup detection. TODO: document its API */ int (*post_run_callback)(const char *dump_dir_name, void *param); void *post_run_param; -- cgit From 55ae0eaea8684aa78089bbd0c2116e0c8cb25585 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 1 Feb 2011 16:04:30 +0100 Subject: abrt-cli -r DIR: copy non-writable DIR into $HOME/abrt/spool Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 2 ++ src/include/report/dump_dir.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 22b63baf..bb3dddc2 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -123,6 +123,8 @@ off_t copyfd_size(int src_fd, int dst_fd, off_t size, int flags); void copyfd_exact_size(int src_fd, int dst_fd, off_t size); #define copy_file abrt_copy_file off_t copy_file(const char *src_name, const char *dst_name, int mode); +#define copy_file_recursive abrt_copy_file_recursive +int copy_file_recursive(const char *source, const char *dest); /* Returns malloc'ed block */ #define encode_base64 abrt_encode_base64 diff --git a/src/include/report/dump_dir.h b/src/include/report/dump_dir.h index 4f2914d0..3bcc526d 100644 --- a/src/include/report/dump_dir.h +++ b/src/include/report/dump_dir.h @@ -31,6 +31,7 @@ extern "C" { enum { DD_FAIL_QUIETLY = (1 << 0), + DD_OPEN_READONLY = (1 << 1), }; struct dump_dir { @@ -48,13 +49,14 @@ struct dump_dir *dd_opendir(const char *dir, int flags); * (IOW: if you aren't running under root): */ struct dump_dir *dd_create(const char *dir, uid_t uid); +void dd_create_basic_files(struct dump_dir *dd, uid_t uid); int dd_exist(struct dump_dir *dd, const char *path); DIR *dd_init_next_file(struct dump_dir *dd); int dd_get_next_file(struct dump_dir *dd, char **short_name, char **full_name); enum { /* DD_FAIL_QUIETLY bit is valid for dd_load_text_ext too, */ - DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (1 << 1), + DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (1 << 2), }; char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned flags); char* dd_load_text(const struct dump_dir *dd, const char *name); -- cgit From 60de0b858894e43b6a537d20abb18c01a5ed04cf Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 1 Feb 2011 16:41:27 +0100 Subject: run_event: fix comment which become outdated after recent change Signed-off-by: Denys Vlasenko --- src/include/report/run_event.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/include') diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index 4d06896a..a1c1f56b 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -43,7 +43,6 @@ void free_run_event_state(struct run_event_state *state); /* Returns exitcode of first failed action, or first nonzero return value * of post_run_callback. If all actions are successful, returns 0. - * If no actions were run for the event, returns -1. */ int run_event_on_dir_name(struct run_event_state *state, const char *dump_dir_name, const char *event); int run_event_on_crash_data(struct run_event_state *state, crash_data_t *data, const char *event); -- cgit From f8c0e544a905ba42c8b550409f492081534977f5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 10 Feb 2011 15:48:15 +0100 Subject: get rid of FILENAME_DESCRIPTION, rename "release" to "os_release" Signed-off-by: Denys Vlasenko --- src/include/abrt_crash_data.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/include') diff --git a/src/include/abrt_crash_data.h b/src/include/abrt_crash_data.h index b3278858..3243de8c 100644 --- a/src/include/abrt_crash_data.h +++ b/src/include/abrt_crash_data.h @@ -45,11 +45,11 @@ #define FILENAME_ARCHITECTURE "architecture" #define FILENAME_KERNEL "kernel" #define FILENAME_TIME "time" -#define FILENAME_RELEASE "release" /* from /etc/redhat-release */ -// filled by +// From /etc/syste-release or /etc/redhat-release +#define FILENAME_OS_RELEASE "os_release" +// Filled by #define FILENAME_PACKAGE "package" #define FILENAME_COMPONENT "component" -#define FILENAME_DESCRIPTION "description" /* package descr (not crash descr) */ #define FILENAME_COMMENT "comment" #define FILENAME_REPRODUCE "reproduce" #define FILENAME_RATING "rating" -- cgit From 2abf0fc078221715abbd20c8451d300eaf787848 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 10 Feb 2011 18:04:43 +0100 Subject: abrt-gtk: make Delete key actually delete the dump dir Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 1 - src/include/dbus_common.h | 28 ---------------------------- 2 files changed, 29 deletions(-) delete mode 100644 src/include/dbus_common.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 84e56d6d..477963c3 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -9,5 +9,4 @@ libabrt_include_HEADERS = \ abrtlib.h \ abrt_types.h \ abrt_crash_data.h \ - dbus_common.h \ xfuncs.h diff --git a/src/include/dbus_common.h b/src/include/dbus_common.h deleted file mode 100644 index 4e980d34..00000000 --- a/src/include/dbus_common.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2009 Jiri Moskovcak (jmoskovc@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. -*/ -#ifndef DBUSCOMMON_H_ -#define DBUSCOMMON_H_ - -#include "abrt_crash_data.h" - -#define ABRTD_DBUS_NAME "com.redhat.abrt" -#define ABRTD_DBUS_PATH "/com/redhat/abrt" -#define ABRTD_DBUS_IFACE "com.redhat.abrt" - -#endif -- cgit From a330886781635606626b3b91432525128d0e8a8f Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 7 Feb 2011 11:54:07 +0100 Subject: get rid of unused CD_FLAG_SYS Signed-off-by: Nikola Pajkovsky --- src/include/report/crash_data.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/include') diff --git a/src/include/report/crash_data.h b/src/include/report/crash_data.h index 86543a4f..3854118a 100644 --- a/src/include/report/crash_data.h +++ b/src/include/report/crash_data.h @@ -28,11 +28,10 @@ extern "C" { struct dump_dir; enum { - CD_FLAG_SYS = (1 << 0), - CD_FLAG_BIN = (1 << 1), - CD_FLAG_TXT = (1 << 2), - CD_FLAG_ISEDITABLE = (1 << 3), - CD_FLAG_ISNOTEDITABLE = (1 << 4), + CD_FLAG_BIN = (1 << 0), + CD_FLAG_TXT = (1 << 1), + CD_FLAG_ISEDITABLE = (1 << 2), + CD_FLAG_ISNOTEDITABLE = (1 << 3), }; struct crash_item { -- cgit From 7cc0d036579337f3e1013086ec3dc61d09b5c529 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 17 Feb 2011 12:31:13 +0100 Subject: gui-wizard-gtk: show correct list of analyzers available Signed-off-by: Denys Vlasenko --- src/include/report/run_event.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/include') diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index a1c1f56b..388a74e6 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -46,6 +46,7 @@ void free_run_event_state(struct run_event_state *state); */ int run_event_on_dir_name(struct run_event_state *state, const char *dump_dir_name, const char *event); int run_event_on_crash_data(struct run_event_state *state, crash_data_t *data, const char *event); +/* Returns a malloced string with '\n'-terminated event names */ char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); #ifdef __cplusplus -- cgit From 406b2cffd5e9120bea74ab01479039714ce9e2d5 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Thu, 17 Feb 2011 15:44:20 +0100 Subject: move steal_directory() into libreport --- src/include/abrtlib.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index bb3dddc2..c5959b34 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -250,6 +250,9 @@ void parse_release_for_rhts(const char *pRelease, char **product, char **version #define load_conf_file abrt_load_conf_file bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue); +#define steal_directory abrt_steal_directory +struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name); + #ifdef __cplusplus } #endif -- cgit From e09e019ca971e8ce4164e04a3b6007a679bef288 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 Feb 2011 15:11:32 +0100 Subject: run_event: add async run event machinery Signed-off-by: Denys Vlasenko --- src/include/report/run_event.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/include') diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index 388a74e6..8730eea8 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -29,23 +29,46 @@ struct dump_dir; struct run_event_state { int children_count; + /* Used only for post-create dup detection. TODO: document its API */ int (*post_run_callback)(const char *dump_dir_name, void *param); void *post_run_param; + /* Can take ownership of log_line, which is malloced. In this case, return NULL. * Otherwise should return log_line (it will be freed by caller) */ char* (*logging_callback)(char *log_line, void *param); void *logging_param; + + /* Internal data for async command execution */ + GList *commands; + pid_t command_pid; + int command_out_fd; }; struct run_event_state *new_run_event_state(void); void free_run_event_state(struct run_event_state *state); +/* Asyncronous command execution */ + +/* Returns 0 if no commands found for this dump_dir_name+event, else >0 */ +int prepare_commands(struct run_event_state *state, const char *dump_dir_name, const char *event); +/* Returns -1 is no more commands needs to be executed, + * else sets state->command_pid and state->command_out_fd and returns >=0 + */ +int spawn_next_command(struct run_event_state *state, const char *dump_dir_name, const char *event); +/* Cleans up internal state created in prepare_commands */ +void free_commands(struct run_event_state *state); + +/* Syncronous command execution */ + /* Returns exitcode of first failed action, or first nonzero return value * of post_run_callback. If all actions are successful, returns 0. */ int run_event_on_dir_name(struct run_event_state *state, const char *dump_dir_name, const char *event); int run_event_on_crash_data(struct run_event_state *state, crash_data_t *data, const char *event); + +/* Querying for possible events */ + /* Returns a malloced string with '\n'-terminated event names */ char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); -- cgit From 75aa0e2d9616241effda82462a90efc8afec2a99 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Fri, 18 Feb 2011 16:17:05 +0100 Subject: copy /proc//[map,smap] files into crash dir Signed-off-by: Nikola Pajkovsky --- src/include/abrt_crash_data.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/abrt_crash_data.h b/src/include/abrt_crash_data.h index 3243de8c..b71b046f 100644 --- a/src/include/abrt_crash_data.h +++ b/src/include/abrt_crash_data.h @@ -36,7 +36,8 @@ #define FILENAME_REASON "reason" #define FILENAME_COREDUMP "coredump" #define FILENAME_BACKTRACE "backtrace" -#define FILENAME_MEMORYMAP "memorymap" +#define FILENAME_MAPS "maps" +#define FILENAME_SMAPS "smaps" #define FILENAME_DUPHASH "global_uuid" /* name is compat, to be renamed to "duphash" */ // Name of the function where the application crashed. // Optional. -- cgit From 72a31a2a391e6c37255ed08b3bdbf1c38f20d753 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 22 Feb 2011 18:17:13 +0100 Subject: gui-wizard-gtk: add forward_page_func which skips analyze step when it is missing Signed-off-by: Denys Vlasenko --- src/include/report/run_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index 8730eea8..3fd3d7d1 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -61,7 +61,7 @@ void free_commands(struct run_event_state *state); /* Syncronous command execution */ -/* Returns exitcode of first failed action, or first nonzero return value +/* Returns exit code of first failed action, or first nonzero return value * of post_run_callback. If all actions are successful, returns 0. */ int run_event_on_dir_name(struct run_event_state *state, const char *dump_dir_name, const char *event); -- cgit From 66ce847a00e742ae5c3959fb347fc3fc14715ccb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 23 Feb 2011 23:07:41 +0100 Subject: gui-wizard-gtk: run multiple reporters if they are selected Signed-off-by: Denys Vlasenko --- src/include/report/run_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index 3fd3d7d1..5d108a27 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -56,7 +56,7 @@ int prepare_commands(struct run_event_state *state, const char *dump_dir_name, c * else sets state->command_pid and state->command_out_fd and returns >=0 */ int spawn_next_command(struct run_event_state *state, const char *dump_dir_name, const char *event); -/* Cleans up internal state created in prepare_commands */ +/* Cleans up internal state created in prepare_commands */ void free_commands(struct run_event_state *state); /* Syncronous command execution */ -- cgit From 1f73de4e422ffe046e3faf0e4fb7f5523a14ff2d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 24 Feb 2011 13:55:15 +0100 Subject: gui-wizard-gtk: make [Refresh] button work Looks for reanalyze_FOO events, enables them on "Select analyzer" page and sends user go to that page to pick the [re]analyzer to run. Signed-off-by: Denys Vlasenko --- src/include/report/run_event.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index 5d108a27..7fd8edea 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -69,7 +69,10 @@ int run_event_on_crash_data(struct run_event_state *state, crash_data_t *data, c /* Querying for possible events */ -/* Returns a malloced string with '\n'-terminated event names */ +/* Scans event.conf for events starting with pfx which are applicable + * to dd, or (if dd is NULL), to dump_dir. + * Returns a malloced string with '\n'-terminated event names. + */ char *list_possible_events(struct dump_dir *dd, const char *dump_dir_name, const char *pfx); #ifdef __cplusplus -- cgit From c00b15ff52f89ada9770453580e5828fd466e9c5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 25 Feb 2011 15:55:44 +0100 Subject: change stealing semantics from copy to move Signed-off-by: Denys Vlasenko --- src/include/report/dump_dir.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/report/dump_dir.h b/src/include/report/dump_dir.h index 3bcc526d..66b61054 100644 --- a/src/include/report/dump_dir.h +++ b/src/include/report/dump_dir.h @@ -62,7 +62,8 @@ char* dd_load_text_ext(const struct dump_dir *dd, const char *name, unsigned fla char* dd_load_text(const struct dump_dir *dd, const char *name); void dd_save_text(struct dump_dir *dd, const char *name, const char *data); void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, unsigned size); -void dd_delete(struct dump_dir *dd); +/* Returns 0 if directory is deleted or not found */ +int dd_delete(struct dump_dir *dd); void delete_dump_dir(const char *dd_dir); -- cgit From 1bbf4c784aa9fda4d137013ea584874d56d45a33 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 25 Feb 2011 18:25:40 +0100 Subject: gui-wizard-gtk: show error messages as msg boxes Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index c5959b34..ecae0de7 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -250,6 +250,8 @@ void parse_release_for_rhts(const char *pRelease, char **product, char **version #define load_conf_file abrt_load_conf_file bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue); +/* Tries to create a copy of dump_dir_name in base_dir, with same or similar basename. + * Returns NULL if copying failed. In this case, logs a message before returning. */ #define steal_directory abrt_steal_directory struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name); -- cgit From 39ce00f37c753ae7830a8f33631de468a0ec8212 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 28 Feb 2011 17:16:28 +0100 Subject: show more useful columns in abrt-gtk; use human-readable time in dir names For most users, "hostname" is the same for every crash (it is their hostname). Not every problem even has "Application" field ("low on disk space" problem, for example, doesn't), whereas any problem should have "Reason" field. For non-root, it is useful to see which dumps are in /var/spool/abrt (and aren't writable), and which are in $HOME/.abrt/spool. Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index ecae0de7..61731587 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -221,6 +221,12 @@ char* get_cmdline(pid_t pid); #define daemon_is_ok abrt_daemon_is_ok int daemon_is_ok(); +/* Takes ptr to time_t, or NULL if you want to use current time. + * Returns "YYYY-MM-DD-hh:mm:ss" string. + */ +#define iso_date_string abrt_iso_date_string +char *iso_date_string(time_t *pt); + #define make_description_bz abrt_make_description_bz char* make_description_bz(crash_data_t *crash_data); #define make_description_reproduce_comment abrt_make_description_reproduce_comment -- cgit From 3a6d12fcd182c0de13800fe463482d6a4408f885 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 28 Feb 2011 17:23:50 +0100 Subject: dump_dir API: rename dd_dir field to dd_dirname Signed-off-by: Denys Vlasenko --- src/include/report/dump_dir.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/report/dump_dir.h b/src/include/report/dump_dir.h index 66b61054..1376d7f3 100644 --- a/src/include/report/dump_dir.h +++ b/src/include/report/dump_dir.h @@ -35,7 +35,7 @@ enum { }; struct dump_dir { - char *dd_dir; + char *dd_dirname; DIR *next_dir; int locked; uid_t dd_uid; @@ -65,7 +65,7 @@ void dd_save_binary(struct dump_dir *dd, const char *name, const char *data, uns /* Returns 0 if directory is deleted or not found */ int dd_delete(struct dump_dir *dd); -void delete_dump_dir(const char *dd_dir); +void delete_dump_dir(const char *dirname); #ifdef __cplusplus } -- cgit