diff options
Diffstat (limited to 'libreport/src/include')
-rw-r--r-- | libreport/src/include/Makefile.am | 17 | ||||
-rw-r--r-- | libreport/src/include/abrt_dbus.h | 360 | ||||
-rw-r--r-- | libreport/src/include/dump_dir.h | 80 | ||||
-rw-r--r-- | libreport/src/include/event_config.h | 108 | ||||
-rw-r--r-- | libreport/src/include/hash_sha1.h | 59 | ||||
-rw-r--r-- | libreport/src/include/libreport.h | 307 | ||||
-rw-r--r-- | libreport/src/include/libreport_problem_data.h | 99 | ||||
-rw-r--r-- | libreport/src/include/libreport_types.h | 45 | ||||
-rw-r--r-- | libreport/src/include/logging.h | 91 | ||||
-rw-r--r-- | libreport/src/include/parse_options.h | 80 | ||||
-rw-r--r-- | libreport/src/include/problem_data.h | 105 | ||||
-rw-r--r-- | libreport/src/include/read_write.h | 55 | ||||
-rw-r--r-- | libreport/src/include/report.h | 42 | ||||
-rw-r--r-- | libreport/src/include/run_event.h | 82 | ||||
-rw-r--r-- | libreport/src/include/strbuf.h | 112 | ||||
-rw-r--r-- | libreport/src/include/xfuncs.h | 144 |
16 files changed, 0 insertions, 1786 deletions
diff --git a/libreport/src/include/Makefile.am b/libreport/src/include/Makefile.am deleted file mode 100644 index f2afd2c3..00000000 --- a/libreport/src/include/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -libreport_includedir = $(includedir)/libreport -libreport_include_HEADERS = \ - abrt_dbus.h \ - dump_dir.h \ - event_config.h \ - hash_sha1.h \ - libreport.h \ - libreport_problem_data.h \ - libreport_types.h \ - logging.h \ - parse_options.h \ - problem_data.h \ - read_write.h \ - report.h \ - run_event.h \ - strbuf.h \ - xfuncs.h
\ No newline at end of file diff --git a/libreport/src/include/abrt_dbus.h b/libreport/src/include/abrt_dbus.h deleted file mode 100644 index efa70472..00000000 --- a/libreport/src/include/abrt_dbus.h +++ /dev/null @@ -1,360 +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 ABRT_DBUS_H -#define ABRT_DBUS_H - -#include <dbus/dbus.h> -#include "libreport.h" - - -#define ABRTD_DBUS_NAME "com.redhat.abrt" -#define ABRTD_DBUS_PATH "/com/redhat/abrt" -#define ABRTD_DBUS_IFACE "com.redhat.abrt" - - -#ifdef __cplusplus -extern "C" { -#endif - -extern DBusConnection* g_dbus_conn; - -/* - * Glib integration machinery - */ - -/* Hook up to DBus and to glib main loop. - * Usage cases: - * - * - server: - * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err); - * attach_dbus_conn_to_glib_main_loop(conn, "/some/path", handler_of_calls_to_some_path); - * rc = dbus_bus_request_name(conn, "server.name", DBUS_NAME_FLAG_REPLACE_EXISTING, &err); - * - * - client which does not receive signals (only makes calls and emits signals): - * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err); - * // needed only if you need to use async dbus calls (not shown below): - * attach_dbus_conn_to_glib_main_loop(conn, NULL, NULL); - * // synchronous method call: - * msg = dbus_message_new_method_call("some.serv", "/path/on/serv", "optional.iface.on.serv", "method_name"); - * reply = dbus_connection_send_with_reply_and_block(conn, msg, timeout, &err); - * // emitting signal: - * msg = dbus_message_new_signal("/path/sig/emitted/from", "iface.sig.emitted.from", "sig_name"); - * // (note: "iface.sig.emitted.from" is not optional for signals!) - * dbus_message_set_destination(msg, "peer"); // optional - * dbus_connection_send(conn, msg, &serial); // &serial can be NULL - * dbus_connection_unref(conn); // if you don't want to *stay* connected - * - * - client which receives and processes signals: - * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err); - * attach_dbus_conn_to_glib_main_loop(conn, NULL, NULL); - * dbus_connection_add_filter(conn, handle_message, NULL, NULL) - * dbus_bus_add_match(system_conn, "type='signal',...", &err); - * // signal is a dbus message which looks like this: - * // sender=XXX dest=YYY(or null) path=/path/sig/emitted/from interface=iface.sig.emitted.from member=sig_name - * // and handler_for_signals(conn,msg,opaque) will be called by glib - * // main loop to process received signals (and other messages - * // if you ask for them in dbus_bus_add_match[es], but this - * // would turn you into a server if you handle them too) ;] - */ -void attach_dbus_conn_to_glib_main_loop(DBusConnection* conn, - /* NULL if you are just a client */ - const char* object_path_to_register, - /* makes sense only if you use object_path_to_register: */ - DBusHandlerResult (*message_received_func)(DBusConnection *conn, DBusMessage *msg, void* data) -); - -/* Log dbus error if err has it set. Then log msg if it's !NULL. - * In both cases return 1. Otherwise return 0. - */ -int log_dbus_error(const char *msg, DBusError *err); - -/* Perform "DeleteDebugDump" call over g_dbus_conn */ -int32_t call_DeleteDebugDump(const char *dump_dir_name); - -/* Connect to system bus, find abrtd, perform "DeleteDebugDump" call, close g_dbus_conn */ -/* now static: int connect_to_abrtd_and_call_DeleteDebugDump(const char *dump_dir_name); */ -int delete_dump_dir_possibly_using_abrtd(const char *dump_dir_name); - - -/* - * Helpers for building DBus messages - */ -//void store_bool(DBusMessageIter* iter, bool val); -void store_int32(DBusMessageIter* iter, int32_t val); -void store_uint32(DBusMessageIter* iter, uint32_t val); -void store_int64(DBusMessageIter* iter, int64_t val); -void store_uint64(DBusMessageIter* iter, uint64_t val); -void store_string(DBusMessageIter* iter, const char* val); - -/* - * Helpers for parsing DBus messages - */ -enum { - ABRT_DBUS_ERROR = -1, - ABRT_DBUS_LAST_FIELD = 0, - ABRT_DBUS_MORE_FIELDS = 1, - /* note that dbus_message_iter_next() returns FALSE on last field - * and TRUE if there are more fields. - * It maps exactly on the above constants. */ -}; -/* Checks type, loads data, advances to the next arg. - * Returns TRUE if next arg exists. - */ -//int load_bool(DBusMessageIter* iter, bool& val); -int load_int32(DBusMessageIter* iter, int32_t *val); -int load_uint32(DBusMessageIter* iter, uint32_t *val); -int load_int64(DBusMessageIter* iter, int64_t *val); -int load_uint64(DBusMessageIter* iter, uint64_t *val); -int load_charp(DBusMessageIter* iter, const char **val); - -#ifdef __cplusplus -} -#endif - - -/* - * C++ style stuff - */ - -#ifdef __cplusplus - -#include <map> -#include <vector> - -/* - * Helpers for building DBus messages - */ - -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; -} - -//static inline void store_val(DBusMessageIter* iter, bool val) { store_bool(iter, val); } -static inline void store_val(DBusMessageIter* iter, int32_t val) { store_int32(iter, val); } -static inline void store_val(DBusMessageIter* iter, uint32_t val) { store_uint32(iter, val); } -static inline void store_val(DBusMessageIter* iter, int64_t val) { store_int64(iter, val); } -static inline void store_val(DBusMessageIter* iter, uint64_t val) { store_uint64(iter, val); } -static inline void store_val(DBusMessageIter* iter, const char* val) { store_string(iter, val); } -static inline void store_val(DBusMessageIter* iter, const std::string& val) { store_string(iter, val.c_str()); } - -/* Templates for vector and map */ -template <typename T> struct abrt_dbus_type {}; -//template <> struct abrt_dbus_type<bool> { static const char* csig() { return "b"; } }; -template <> struct abrt_dbus_type<int32_t> { static const char* csig() { return "i"; } static std::string sig(); }; -template <> struct abrt_dbus_type<uint32_t> { static const char* csig() { return "u"; } static std::string sig(); }; -template <> struct abrt_dbus_type<int64_t> { static const char* csig() { return "x"; } static std::string sig(); }; -template <> struct abrt_dbus_type<uint64_t> { static const char* csig() { return "t"; } static std::string sig(); }; -template <> struct abrt_dbus_type<std::string> { static const char* csig() { return "s"; } static std::string sig(); }; -#define ABRT_DBUS_SIG(T) (abrt_dbus_type<T>::csig() ? abrt_dbus_type<T>::csig() : abrt_dbus_type<T>::sig().c_str()) -template <typename E> -struct abrt_dbus_type< std::vector<E> > { - static const char* csig() { return NULL; } - static std::string sig() { return ssprintf("a%s", ABRT_DBUS_SIG(E)); } -}; -template <typename K, typename V> -struct abrt_dbus_type< std::map<K,V> > { - static const char* csig() { return NULL; } - static std::string sig() { return ssprintf("a{%s%s}", ABRT_DBUS_SIG(K), ABRT_DBUS_SIG(V)); } -}; - -template <typename E> -static void store_vector(DBusMessageIter* iter, const std::vector<E>& val) -{ - DBusMessageIter sub_iter; - if (!dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, ABRT_DBUS_SIG(E), &sub_iter)) - die_out_of_memory(); - - typename std::vector<E>::const_iterator vit = val.begin(); - for (; vit != val.end(); ++vit) - { - store_val(&sub_iter, *vit); - } - - if (!dbus_message_iter_close_container(iter, &sub_iter)) - die_out_of_memory(); -} -/* -template<> -static void store_vector(DBus::MessageIter &iter, const std::vector<uint8_t>& val) -{ - if we use such vector, MUST add specialized code here (see in dbus-c++ source) -} -*/ -template <typename K, typename V> -static void store_map(DBusMessageIter* iter, const std::map<K,V>& val) -{ - DBusMessageIter sub_iter; - if (!dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, - ssprintf("{%s%s}", ABRT_DBUS_SIG(K), ABRT_DBUS_SIG(V)).c_str(), - &sub_iter)) - die_out_of_memory(); - - typename std::map<K,V>::const_iterator mit = val.begin(); - for (; mit != val.end(); ++mit) - { - DBusMessageIter sub_sub_iter; - if (!dbus_message_iter_open_container(&sub_iter, DBUS_TYPE_DICT_ENTRY, NULL, &sub_sub_iter)) - die_out_of_memory(); - store_val(&sub_sub_iter, mit->first); - store_val(&sub_sub_iter, mit->second); - if (!dbus_message_iter_close_container(&sub_iter, &sub_sub_iter)) - die_out_of_memory(); - } - - if (!dbus_message_iter_close_container(iter, &sub_iter)) - die_out_of_memory(); -} - -template <typename E> -static inline void store_val(DBusMessageIter* iter, const std::vector<E>& val) { store_vector(iter, val); } -template <typename K, typename V> -static inline void store_val(DBusMessageIter* iter, const std::map<K,V>& val) { store_map(iter, val); } - - -/* - * Helpers for parsing DBus messages - */ - -//static inline int load_val(DBusMessageIter* iter, bool &val) { return load_bool(iter, &val); } -static inline int load_val(DBusMessageIter* iter, int32_t &val) { return load_int32(iter, &val); } -static inline int load_val(DBusMessageIter* iter, uint32_t &val) { return load_uint32(iter, &val); } -static inline int load_val(DBusMessageIter* iter, int64_t &val) { return load_int64(iter, &val); } -static inline int load_val(DBusMessageIter* iter, uint64_t &val) { return load_uint64(iter, &val); } -static inline int load_val(DBusMessageIter* iter, const char*& val) { return load_charp(iter, &val); } -static inline int load_val(DBusMessageIter* iter, std::string& val) -{ - const char* str; - int r = load_charp(iter, &str); - val = str; - return r; -} - -/* Templates for vector and map */ -template <typename E> -static int load_vector(DBusMessageIter* iter, std::vector<E>& val) -{ - int type = dbus_message_iter_get_arg_type(iter); - if (type != DBUS_TYPE_ARRAY) - { - error_msg("array expected in dbus message, but not found ('%c')", type); - return -1; - } - - DBusMessageIter sub_iter; - dbus_message_iter_recurse(iter, &sub_iter); - - int r; -//int cnt = 0; - /* When the vector has 0 elements, we see DBUS_TYPE_INVALID here */ - type = dbus_message_iter_get_arg_type(&sub_iter); - if (type != DBUS_TYPE_INVALID) - { - do { - E elem; -//cnt++; - r = load_val(&sub_iter, elem); - if (r < 0) - return r; - val.push_back(elem); - } while (r == ABRT_DBUS_MORE_FIELDS); - } -//log("%s: %d elems", __func__, cnt); - - return dbus_message_iter_next(iter); -} -/* -template<> -static int load_vector(DBusMessageIter* iter, std::vector<uint8_t>& val) -{ - if we use such vector, MUST add specialized code here (see in dbus-c++ source) -} -*/ -template <typename K, typename V> -static int load_map(DBusMessageIter* iter, std::map<K,V>& val) -{ - int type = dbus_message_iter_get_arg_type(iter); - if (type != DBUS_TYPE_ARRAY) - { - error_msg("array expected in dbus message, but not found ('%c')", type); - return -1; - } - - DBusMessageIter sub_iter; - dbus_message_iter_recurse(iter, &sub_iter); - - bool next_exists; - int r; -//int cnt = 0; - do { - type = dbus_message_iter_get_arg_type(&sub_iter); - if (type != DBUS_TYPE_DICT_ENTRY) - { - /* When the map has 0 elements, we see DBUS_TYPE_INVALID (on the first iteration) */ - if (type == DBUS_TYPE_INVALID) - break; - error_msg("sub_iter type is not DBUS_TYPE_DICT_ENTRY (%c)!", type); - return -1; - } - - DBusMessageIter sub_sub_iter; - dbus_message_iter_recurse(&sub_iter, &sub_sub_iter); - - K key; - r = load_val(&sub_sub_iter, key); - if (r != ABRT_DBUS_MORE_FIELDS) - { - if (r == ABRT_DBUS_LAST_FIELD) - error_msg("malformed map element in dbus message"); - return -1; - } - V value; - r = load_val(&sub_sub_iter, value); - if (r != ABRT_DBUS_LAST_FIELD) - { - if (r == ABRT_DBUS_MORE_FIELDS) - error_msg("malformed map element in dbus message"); - return -1; - } - val[key] = value; -//cnt++; - next_exists = dbus_message_iter_next(&sub_iter); - } while (next_exists); -//log("%s: %d elems", __func__, cnt); - - return dbus_message_iter_next(iter); -} - -template <typename E> -static inline int load_val(DBusMessageIter* iter, std::vector<E>& val) { return load_vector(iter, val); } -template <typename K, typename V> -static inline int load_val(DBusMessageIter* iter, std::map<K,V>& val) { return load_map(iter, val); } - -#endif /* __cplusplus */ - -#endif diff --git a/libreport/src/include/dump_dir.h b/libreport/src/include/dump_dir.h deleted file mode 100644 index c88ebe7f..00000000 --- a/libreport/src/include/dump_dir.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - On-disk storage of problem data - - 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 <sys/types.h> -#include <dirent.h> - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - DD_FAIL_QUIETLY_ENOENT = (1 << 0), - DD_FAIL_QUIETLY_EACCES = (1 << 1), - DD_OPEN_READONLY = (1 << 2), -}; - -struct dump_dir { - char *dd_dirname; - DIR *next_dir; - int locked; - uid_t dd_uid; - gid_t dd_gid; - /* mode fo saved files */ - mode_t mode; -}; - -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, mode_t mode); - -void dd_create_basic_files(struct dump_dir *dd, uid_t uid); -int dd_exist(struct dump_dir *dd, const char *path); -void dd_sanitize_mode_and_owner(struct dump_dir *dd); - -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_ENOENT bit is valid for dd_load_text_ext too, */ - DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE = (DD_OPEN_READONLY << 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); -/* Returns 0 if directory is deleted or not found */ -int dd_delete(struct dump_dir *dd); - -void delete_dump_dir(const char *dirname); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/event_config.h b/libreport/src/include/event_config.h deleted file mode 100644 index cdac4083..00000000 --- a/libreport/src/include/event_config.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - Copyright (C) 2011 ABRT team - Copyright (C) 2010 RedHat Inc - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include <glib.h> - -#ifndef EVENT_CONFIG_H -#define EVENT_CONFIG_H - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum -{ - OPTION_TYPE_TEXT, - OPTION_TYPE_BOOL, - OPTION_TYPE_PASSWORD, - OPTION_TYPE_NUMBER, - OPTION_TYPE_HINT_HTML, - OPTION_TYPE_INVALID, -} option_type_t; - -/* - * struct to hold information about config options - * it's supposed to hold information about: - * type -> which designates the widget used to display it and we can do some test based on the type - * label - * allowed value(s) -> regexp? - * name -> env variable name - * value -> value retrieved from the gui, so when we want to set the env - * evn variables, we can just traverse the list of the options - * and set the env variables according to name:value in this structure - */ -typedef struct -{ - char *eo_name; //name of the value which should be used for env variable - char *eo_value; - char *eo_label; - char *eo_note_html; - option_type_t eo_type; - int eo_allow_empty; - //char *description; //can be used as tooltip in gtk app - //char *allowed_value; - //int required; -} event_option_t; - -event_option_t *new_event_option(void); -void free_event_option(event_option_t *p); - -//structure to hold the option data -typedef struct -{ - char *screen_name; //ui friendly name of the event: "Bugzilla" "RedHat Support Upload" - char *description; // "Report to..."/"Save to file". Should be one sentence, not long - char *long_descr; // Long(er) explanation, if needed - - char *ec_creates_items; - char *ec_requires_items; - char *ec_exclude_items_by_default; - char *ec_include_items_by_default; - char *ec_exclude_items_always; - bool ec_exclude_binary_items; - - GList *options; -} event_config_t; - -event_config_t *new_event_config(void); -void free_event_config(event_config_t *p); - - -void load_event_description_from_file(event_config_t *event_config, const char* filename); - -// (Re)loads data from /etc/abrt/events/*.{conf,xml} -void load_event_config_data(void); -/* Frees all loaded data */ -void free_event_config_data(void); -event_config_t *get_event_config(const char *event_name); -event_option_t *get_event_option_from_list(const char *option_name, GList *event_options); - -extern GHashTable *g_event_config_list; // for iterating through entire list of all loaded configs - -GList *export_event_config(const char *event_name); -void unexport_event_config(GList *env_list); - -GHashTable *validate_event(const char *event_name); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/hash_sha1.h b/libreport/src/include/hash_sha1.h deleted file mode 100644 index 7299608b..00000000 --- a/libreport/src/include/hash_sha1.h +++ /dev/null @@ -1,59 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * Based on shasum from http://www.netsw.org/crypto/hash/ - * Majorly hacked up to use Dr Brian Gladman's sha1 code - * - * Copyright (C) 2002 Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK. - * Copyright (C) 2003 Glenn L. McGrath - * Copyright (C) 2003 Erik Andersen - * - * 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. - * - * --------------------------------------------------------------------------- - * Issue Date: 10/11/2002 - * - * This is a byte oriented version of SHA1 that operates on arrays of bytes - * stored in memory. It runs at 22 cycles per byte on a Pentium P4 processor - * - * --------------------------------------------------------------------------- - */ -#ifndef HASH_SHA1_H -#define HASH_SHA1_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -#define SHA1_RESULT_LEN (5 * 4) - -typedef struct sha1_ctx_t { - uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */ - /* for sha256: void (*process_block)(struct md5_ctx_t*); */ - uint64_t total64; /* must be directly before hash[] */ - uint32_t hash[8]; /* 4 elements for md5, 5 for sha1, 8 for sha256 */ -} sha1_ctx_t; - -#define sha1_begin abrt_sha1_begin -void sha1_begin(sha1_ctx_t *ctx); -#define sha1_hash abrt_sha1_hash -void sha1_hash(sha1_ctx_t *ctx, const void *buffer, size_t len); -#define sha1_end abrt_sha1_end -void sha1_end(sha1_ctx_t *ctx, void *resbuf); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/libreport.h b/libreport/src/include/libreport.h deleted file mode 100644 index cd8a5cb9..00000000 --- a/libreport/src/include/libreport.h +++ /dev/null @@ -1,307 +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 LIBREPORT_H_ -#define LIBREPORT_H_ - -#include <assert.h> -#include <ctype.h> -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <inttypes.h> -#include <setjmp.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <stddef.h> -#include <string.h> -#include <sys/poll.h> -#include <sys/mman.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <arpa/inet.h> /* sockaddr_in, sockaddr_in6 etc */ -#include <termios.h> -#include <time.h> -#include <unistd.h> -/* Try to pull in PATH_MAX */ -#include <limits.h> -#include <sys/param.h> -#ifndef PATH_MAX -# define PATH_MAX 256 -#endif -#include <pwd.h> -#include <grp.h> -/* C++ bits */ -#ifdef __cplusplus -# include <string> -#endif -#include <glib.h> - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -/* Must be after #include "config.h" */ -#if ENABLE_NLS -# include <libintl.h> -# define _(S) gettext(S) -#else -# define _(S) (S) -#endif - -/* Some libc's forget to declare these, do it ourself */ -extern char **environ; -#if defined(__GLIBC__) && __GLIBC__ < 2 -int vdprintf(int d, const char *format, va_list ap); -#endif - -#undef NORETURN -#define NORETURN __attribute__ ((noreturn)) - -#undef ERR_PTR -#define ERR_PTR ((void*)(uintptr_t)1) - -#undef ARRAY_SIZE -#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) - -#include "xfuncs.h" -#include "logging.h" -#include "read_write.h" -#include "strbuf.h" -#include "hash_sha1.h" -#include "parse_options.h" - -#include "problem_data.h" -#include "libreport_types.h" -#include "dump_dir.h" -//#include "hooklib.h" -#include "run_event.h" -#include "event_config.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -#define prefixcmp libreport_prefixcmp -int prefixcmp(const char *str, const char *prefix); -#define suffixcmp libreport_suffixcmp -int suffixcmp(const char *str, const char *suffix); -#define strtrim libreport_strtrim -char *strtrim(char *str); -#define concat_path_file libreport_concat_path_file -char *concat_path_file(const char *path, const char *filename); -#define append_to_malloced_string libreport_append_to_malloced_string -char *append_to_malloced_string(char *mstr, const char *append); -#define skip_whitespace libreport_skip_whitespace -char* skip_whitespace(const char *s); -#define skip_non_whitespace libreport_skip_non_whitespace -char* skip_non_whitespace(const char *s); -/* Like strcpy but can copy overlapping strings. */ -#define overlapping_strcpy libreport_overlapping_strcpy -void overlapping_strcpy(char *dst, const char *src); - -/* A-la fgets, but malloced and of unlimited size */ -#define xmalloc_fgets libreport_xmalloc_fgets -char *xmalloc_fgets(FILE *file); -/* Similar, but removes trailing \n */ -#define xmalloc_fgetline libreport_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 libreport_copyfd_eof -off_t copyfd_eof(int src_fd, int dst_fd, int flags); -#define copyfd_size libreport_copyfd_size -off_t copyfd_size(int src_fd, int dst_fd, off_t size, int flags); -#define copyfd_exact_size libreport_copyfd_exact_size -void copyfd_exact_size(int src_fd, int dst_fd, off_t size); -#define copy_file libreport_copy_file -off_t copy_file(const char *src_name, const char *dst_name, int mode); -#define copy_file_recursive libreport_copy_file_recursive -int copy_file_recursive(const char *source, const char *dest); - -/* Returns malloc'ed block */ -#define encode_base64 libreport_encode_base64 -char *encode_base64(const void *src, int length); - -#define xatou libreport_xatou -unsigned xatou(const char *numstr); -#define xatoi libreport_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. - * It should really be named xatoi_nonnegative (since it allows 0), - * but that would be too long. - */ -#define xatoi_positive libreport_xatoi_positive -int xatoi_positive(const char *numstr); - -//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 - * 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, -}; -/* - * env_vec: list of variables to set in environment (if string has - * "VAR=VAL" form) or unset in environment (if string has no '=' char). - * - * Returns pid. - */ -#define fork_execv_on_steroids libreport_fork_execv_on_steroids -pid_t fork_execv_on_steroids(int flags, - char **argv, - int *pipefds, - char **env_vec, - const char *dir, - 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 libreport_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); - -/* Random utility functions */ - -#define is_in_string_list libreport_is_in_string_list -bool is_in_string_list(const char *name, char **v); - -/* Frees every element'd data using free(), - * then frees list itself using g_list_free(list): - */ -#define list_free_with_free libreport_list_free_with_free -void list_free_with_free(GList *list); - -#define get_dirsize libreport_get_dirsize -double get_dirsize(const char *pPath); -#define get_dirsize_find_largest_dir libreport_get_dirsize_find_largest_dir -double get_dirsize_find_largest_dir( - const char *pPath, - char **worst_dir, /* can be NULL */ - const char *excluded /* can be NULL */ -); - -/* Emit a string of hex representation of bytes */ -#define bin2hex libreport_bin2hex -char* bin2hex(char *dst, const char *str, int count); -/* Convert "xxxxxxxx" hex string to binary, no more than COUNT bytes */ -#define hex2bin libreport_hex2bin -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, - * empty string is returned. - */ -#define get_cmdline libreport_get_cmdline -char* get_cmdline(pid_t pid); -#define get_environ libreport_get_environ -char* get_environ(pid_t pid); - -/* Returns 1 if abrtd daemon is running, 0 otherwise. */ -#define daemon_is_ok libreport_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 libreport_iso_date_string -char *iso_date_string(time_t *pt); - -enum { - MAKEDESC_SHOW_FILES = (1 << 0), - MAKEDESC_SHOW_MULTILINE = (1 << 1), - MAKEDESC_SHOW_ONLY_LIST = (1 << 2), -}; -#define make_description libreport_make_description -char *make_description(problem_data_t *problem_data, char **names_to_skip, unsigned max_text_size, unsigned desc_flags); -#define make_description_bz libreport_make_description_bz -char* make_description_bz(problem_data_t *problem_data); -#define make_description_logger libreport_make_description_logger -char* make_description_logger(problem_data_t *problem_data); -#define make_description_mailx libreport_make_description_mailx -char* make_description_mailx(problem_data_t *problem_data); - -#define parse_release_for_bz libreport_parse_release_for_bz -void parse_release_for_bz(const char *pRelease, char **product, char **version); -#define parse_release_for_rhts libreport_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 - * 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. - */ -#define load_conf_file libreport_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 libreport_steal_directory -struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name); - -#define kernel_tainted_short libreport_kernel_tainted_short -char *kernel_tainted_short(unsigned tainted); - -#define kernel_tainted_long libreport_kernel_tainted_long -GList *kernel_tainted_long(unsigned tainted); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/libreport_problem_data.h b/libreport/src/include/libreport_problem_data.h deleted file mode 100644 index 31ef7d25..00000000 --- a/libreport/src/include/libreport_problem_data.h +++ /dev/null @@ -1,99 +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 PROBLEM_DATA_H_ -#define PROBLEM_DATA_H_ - -#include <glib.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct dump_dir; - -enum { - CD_FLAG_BIN = (1 << 0), - CD_FLAG_TXT = (1 << 1), - CD_FLAG_ISEDITABLE = (1 << 2), - CD_FLAG_ISNOTEDITABLE = (1 << 3), - /* Show this element in "short" info (abrt-cli -l) */ - CD_FLAG_LIST = (1 << 4), - CD_FLAG_UNIXTIME = (1 << 5), -}; - -struct problem_item { - char *content; - unsigned flags; - /* Used by UI for presenting "item allowed/not allowed" checkboxes: */ - int selected_by_user; /* 0 "don't know", -1 "no", 1 "yes" */ - int allowed_by_reporter; /* 0 "no", 1 "yes" */ - int default_by_reporter; /* 0 "no", 1 "yes" */ - int required_by_reporter; /* 0 "no", 1 "yes" */ -}; -typedef struct problem_item problem_item; - -char *format_problem_item(struct problem_item *item); - - -/* In-memory problem data structure and accessors */ - -typedef GHashTable problem_data_t; - -problem_data_t *new_problem_data(void); - -void add_basics_to_problem_data(problem_data_t *pd); - -static inline void free_problem_data(problem_data_t *problem_data) -{ - if (problem_data) - g_hash_table_destroy(problem_data); -} - -void add_to_problem_data_ext(problem_data_t *problem_data, - const char *name, - const char *content, - unsigned flags); -/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */ -void add_to_problem_data(problem_data_t *problem_data, - const char *name, - const char *content); - -static inline struct problem_item *get_problem_data_item_or_NULL(problem_data_t *problem_data, const char *key) -{ - return (struct problem_item *)g_hash_table_lookup(problem_data, key); -} -const char *get_problem_item_content_or_NULL(problem_data_t *problem_data, const char *key); -/* Aborts if key is not found: */ -const char *get_problem_item_content_or_die(problem_data_t *problem_data, const char *key); - - -/* Conversions between in-memory and on-disk formats */ - -void load_problem_data_from_dump_dir(problem_data_t *problem_data, struct dump_dir *dd, char **excluding); -problem_data_t *create_problem_data_from_dump_dir(struct dump_dir *dd); -/* Helper for typical operation in reporters: */ -problem_data_t *create_problem_data_for_reporting(const char *dump_dir_name); - -struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/libreport_types.h b/libreport/src/include/libreport_types.h deleted file mode 100644 index 4636bb7d..00000000 --- a/libreport/src/include/libreport_types.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2009 Denys Vlasenko (dvlasenk@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 ABRT_TYPES_H_ -#define ABRT_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* TODO: rename to map_string_t */ -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) -{ - return (const char*)g_hash_table_lookup(ms, key); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/logging.h b/libreport/src/include/logging.h deleted file mode 100644 index 316c1a22..00000000 --- a/libreport/src/include/logging.h +++ /dev/null @@ -1,91 +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 LOGGING_H -#define LOGGING_H - -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <sys/syslog.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define NORETURN __attribute__ ((noreturn)) - -enum { - LOGMODE_NONE = 0, - LOGMODE_STDIO = (1 << 0), - LOGMODE_SYSLOG = (1 << 1), - LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO, - LOGMODE_CUSTOM = (1 << 2), -}; - -#define g_custom_logger abrt_g_custom_logger -extern void (*g_custom_logger)(const char*); -#define msg_prefix abrt_msg_prefix -extern const char *msg_prefix; -#define msg_eol abrt_msg_eol -extern const char *msg_eol; -#define logmode abrt_logmode -extern int logmode; -#define xfunc_error_retval abrt_xfunc_error_retval -extern int xfunc_error_retval; - -/* Verbosity level */ -#define g_verbose abrt_g_verbose -extern int g_verbose; -/* VERB1 log("what you sometimes want to see, even on a production box") */ -#define VERB1 if (g_verbose >= 1) -/* VERB2 log("debug message, not going into insanely small details") */ -#define VERB2 if (g_verbose >= 2) -/* VERB3 log("lots and lots of details") */ -#define VERB3 if (g_verbose >= 3) -/* there is no level > 3 */ - -#define abrt_ -#define xfunc_die abrt_xfunc_die -void xfunc_die(void) NORETURN; -#define log_msg abrt_log_msg -void log_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); -/* It's a macro, not function, since it collides with log() from math.h */ -#undef log -#define log(...) log_msg(__VA_ARGS__) -/* error_msg family will use g_custom_logger. log_msg does not. */ -#define error_msg abrt_error_msg -void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); -#define error_msg_and_die abrt_error_msg_and_die -void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); -/* Reports error message with libc's errno error description attached. */ -#define perror_msg abrt_perror_msg -void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); -#define perror_msg_and_die abrt_perror_msg_and_die -void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); -#define die_out_of_memory abrt_die_out_of_memory -void die_out_of_memory(void) NORETURN; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/parse_options.h b/libreport/src/include/parse_options.h deleted file mode 100644 index d86662e2..00000000 --- a/libreport/src/include/parse_options.h +++ /dev/null @@ -1,80 +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 PARSE_OPTIONS_H -#define PARSE_OPTIONS_H - -#ifdef __cplusplus -extern "C" { -#endif - -const char *abrt_init(char **argv); -#define export_abrt_envvars abrt_export_abrt_envvars -void export_abrt_envvars(int pfx); -#define g_progname abrt_g_progname -extern const char *g_progname; - - -enum parse_opt_type { - OPTION_BOOL, - OPTION_GROUP, - OPTION_STRING, - OPTION_INTEGER, - OPTION_OPTSTRING, - OPTION_LIST, - OPTION_END, -}; - -struct options { - enum parse_opt_type type; - int short_name; - const char *long_name; - void *value; - const char *argh; - const char *help; -}; - -/* - * s - short_name - * l - long_name - * v - value - * a - option parameter name (for help text) - * h - help - */ -#define OPT_END() { OPTION_END } -#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) } -#define OPT_BOOL( s, l, v, h) { OPTION_BOOL , (s), (l), (v), NULL , (h) } -#define OPT_INTEGER( s, l, v, h) { OPTION_INTEGER , (s), (l), (v), "NUM", (h) } -#define OPT_STRING( s, l, v, a, h) { OPTION_STRING , (s), (l), (v), (a) , (h) } -#define OPT_OPTSTRING(s, l, v, a, h) { OPTION_OPTSTRING, (s), (l), (v), (a) , (h) } -#define OPT_LIST( s, l, v, a, h) { OPTION_LIST , (s), (l), (v), (a) , (h) } - -#define OPT__VERBOSE(v) OPT_BOOL('v', "verbose", (v), _("Be verbose")) - -#define parse_opts abrt_parse_opts -unsigned parse_opts(int argc, char **argv, const struct options *opt, - const char *usage); - -#define show_usage_and_die abrt_show_usage_and_die -void show_usage_and_die(const char *usage, const struct options *opt); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/problem_data.h b/libreport/src/include/problem_data.h deleted file mode 100644 index f23cb050..00000000 --- a/libreport/src/include/problem_data.h +++ /dev/null @@ -1,105 +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_PROBLEM_DATA_H_ -#define ABRT_PROBLEM_DATA_H_ - -#include "libreport_problem_data.h" -#include "libreport_types.h" -#include "dump_dir.h" - -// Text bigger than this usually is attached, not added inline -// was 2k, now bumbed up to 20k: -#define CD_TEXT_ATT_SIZE (20*1024) - -// Filenames in dump directory: -// filled by a hook: -#define FILENAME_REASON "reason" /* mandatory */ -#define FILENAME_UID "uid" /* mandatory */ -#define FILENAME_TIME "time" /* mandatory */ -#define FILENAME_ANALYZER "analyzer" -#define FILENAME_EXECUTABLE "executable" -#define FILENAME_BINARY "binary" -#define FILENAME_CMDLINE "cmdline" -#define FILENAME_COREDUMP "coredump" -#define FILENAME_BACKTRACE "backtrace" -#define FILENAME_MAPS "maps" -#define FILENAME_SMAPS "smaps" -#define FILENAME_ENVIRON "environ" -#define FILENAME_DUPHASH "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" -// From /etc/system-release or /etc/redhat-release -#define FILENAME_OS_RELEASE "os_release" -// Filled by <what?> -#define FILENAME_PACKAGE "package" -#define FILENAME_COMPONENT "component" -#define FILENAME_COMMENT "comment" -#define FILENAME_RATING "backtrace_rating" -#define FILENAME_HOSTNAME "hostname" -// Optional. Set to "1" by abrt-handle-upload for every unpacked dump -#define FILENAME_REMOTE "remote" -#define FILENAME_TAINTED "kernel_tainted" -#define FILENAME_TAINTED_SHORT "kernel_tainted_short" -#define FILENAME_TAINTED_LONG "kernel_tainted_long" - -#define FILENAME_UUID "uuid" -#define FILENAME_COUNT "count" -/* Multi-line list of places problem was reported. - * Recommended line format: - * "Reporter: VAR=VAL VAR=VAL" - * Use add_reported_to(dd, "line_without_newline"): it adds line - * only if it is not already there. - */ -#define FILENAME_REPORTED_TO "reported_to" -#define FILENAME_EVENT_LOG "event_log" - -// Not stored as files, added "on the fly": -#define CD_DUMPDIR "Directory" -//UNUSED: -//// "Which events are possible (make sense) on this dump dir?" -//// (a string with "\n" terminated event names) -//#define CD_EVENTS "Events" - -/* FILENAME_EVENT_LOG is trimmed to below LOW_WATERMARK - * when it reaches HIGH_WATERMARK size - */ -enum { - EVENT_LOG_HIGH_WATERMARK = 30 * 1024, - EVENT_LOG_LOW_WATERMARK = 20 * 1024, -}; - -#ifdef __cplusplus -extern "C" { -#endif - -#define add_reported_to abrt_add_reported_to -void add_reported_to(struct dump_dir *dd, const char *line); - -#define log_problem_data abrt_log_problem_data -void log_problem_data(problem_data_t *problem_data, const char *pfx); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/read_write.h b/libreport/src/include/read_write.h deleted file mode 100644 index dc85f33b..00000000 --- a/libreport/src/include/read_write.h +++ /dev/null @@ -1,55 +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 READ_WRITE_H -#define READ_WRITE_H - -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> - -#ifdef __cplusplus -extern "C" { -#endif - - -// NB: will return short read on error, not -1, -// if some data was read before error occurred -#define xread abrt_xread -void xread(int fd, void *buf, size_t count); - -#define safe_read abrt_safe_read -ssize_t safe_read(int fd, void *buf, size_t count); -#define safe_write abrt_safe_write -ssize_t safe_write(int fd, const void *buf, size_t count); - -#define full_read abrt_full_read -ssize_t full_read(int fd, void *buf, size_t count); -#define full_write abrt_full_write -ssize_t full_write(int fd, const void *buf, size_t count); - -#define full_write_str abrt_full_write_str -ssize_t full_write_str(int fd, const char *buf); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/report.h b/libreport/src/include/report.h deleted file mode 100644 index a5e1fa8e..00000000 --- a/libreport/src/include/report.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2011 ABRT team. - Copyright (C) 2011 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 REPORT_H_ -#define REPORT_H_ - -#include "problem_data.h" - -enum { - LIBREPORT_NOWAIT = 0, - LIBREPORT_WAIT = (1 << 0), /* wait for report to finish and reload the problem data */ - LIBREPORT_ANALYZE = (1 << 1), /* run analyzers? */ - /* ("run reporters" is always on, has no flag (for now?)) */ - LIBREPORT_RELOAD_DATA = (1 << 3), /* reload problem data after run (needs WAIT) */ -}; - -int report_problem_in_dir(const char *dirname, int flags); - -/* Reports a problem stored in problem_data_t. - * It's first saved to /tmp and then processed as a dump dir. - */ -int report_problem_in_memory(problem_data_t *pd, int flags); - -/* Simple wrapper for trivial uses */ -int report_problem(problem_data_t *pd); - -#endif /* REPORT_H_ */ diff --git a/libreport/src/include/run_event.h b/libreport/src/include/run_event.h deleted file mode 100644 index 8e2ad589..00000000 --- a/libreport/src/include/run_event.h +++ /dev/null @@ -1,82 +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_ - -#include "problem_data.h" - -#ifdef __cplusplus -extern "C" { -#endif - -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 *rule_list; - 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); - -/* Asynchronous 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); - -/* Synchronous command execution */ - -/* 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); -int run_event_on_problem_data(struct run_event_state *state, problem_data_t *data, const char *event); - -/* Querying for possible events */ - -/* 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 -} -#endif - -#endif diff --git a/libreport/src/include/strbuf.h b/libreport/src/include/strbuf.h deleted file mode 100644 index 44c6599a..00000000 --- a/libreport/src/include/strbuf.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - strbuf.h - string buffer - - 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 STRBUF_H -#define STRBUF_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct strbuf -{ - /* Size of the allocated buffer. Always > 0. */ - int alloc; - /* Length of the string, without the ending \0. */ - int len; - char *buf; -}; - -/** - * Creates and initializes a new string buffer. - * @returns - * It never returns NULL. The returned pointer must be released by - * calling the function strbuf_free(). - */ -#define strbuf_new abrt_strbuf_new -struct strbuf *strbuf_new(void); - -/** - * Releases the memory held by the string buffer. - * @param strbuf - * If the strbuf is NULL, no operation is performed. - */ -#define strbuf_free abrt_strbuf_free -void strbuf_free(struct strbuf *strbuf); - -/** - * Releases the strbuf, but not the internal buffer. The internal - * string buffer is returned. Caller is responsible to release the - * returned memory using free(). - */ -#define strbuf_free_nobuf abrt_strbuf_free_nobuf -char* strbuf_free_nobuf(struct strbuf *strbuf); - -/** - * The string content is set to an empty string, erasing any previous - * content and leaving its length at 0 characters. - */ -#define strbuf_clear abrt_strbuf_clear -void strbuf_clear(struct strbuf *strbuf); - -/** - * The current content of the string buffer is extended by adding a - * character c at its end. - */ -#define strbuf_append_char abrt_strbuf_append_char -struct strbuf *strbuf_append_char(struct strbuf *strbuf, char c); - -/** - * The current content of the string buffer is extended by adding a - * string str at its end. - */ -#define strbuf_append_str abrt_strbuf_append_str -struct strbuf *strbuf_append_str(struct strbuf *strbuf, - const char *str); - -/** - * The current content of the string buffer is extended by inserting a - * string str at its beginning. - */ -#define strbuf_prepend_str abrt_strbuf_prepend_str -struct strbuf *strbuf_prepend_str(struct strbuf *strbuf, - const char *str); - -/** - * The current content of the string buffer is extended by adding a - * sequence of data formatted as the format argument specifies. - */ -#define strbuf_append_strf abrt_strbuf_append_strf -struct strbuf *strbuf_append_strf(struct strbuf *strbuf, - const char *format, ...); - -/** - * The current content of the string buffer is extended by inserting a - * sequence of data formatted as the format argument specifies at the - * buffer beginning. - */ -#define strbuf_prepend_strf abrt_strbuf_prepend_strf -struct strbuf *strbuf_prepend_strf(struct strbuf *strbuf, - const char *format, ...); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libreport/src/include/xfuncs.h b/libreport/src/include/xfuncs.h deleted file mode 100644 index 5f2504b6..00000000 --- a/libreport/src/include/xfuncs.h +++ /dev/null @@ -1,144 +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 ABRT_XFUNCS_H -#define ABRT_XFUNCS_H - -#include <sys/socket.h> -#include <sys/stat.h> -#include <dirent.h> -#include <stdbool.h> -#include <stdarg.h> - -#ifdef __cplusplus -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); - -#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); -/* - * Utility function to unsetenv a string which was possibly putenv'ed. - * The problem here is that "natural" optimization: - * strchrnul(var_val, '=')[0] = '\0'; - * unsetenv(var_val); - * is BUGGY: if string was put into environment via putenv, - * its modification (s/=/NUL/) is illegal, and unsetenv will fail to unset it. - * Of course, saving/restoring the char wouldn't work either. - * This helper creates a copy up to '=', unsetenv's it, and frees: - */ -#define safe_unsetenv abrt_safe_unsetenv -void safe_unsetenv(const char *var_val); - -#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 - * do not report the type, they report DT_UNKNOWN for every dirent - * (and this is not a bug in filesystem, this is allowed by standards). - * 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 -} -#endif - -#endif |