summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-11-15 15:29:24 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-11-15 15:29:24 +0100
commit2cf0d770b66b6c6ce50af2767f575db552cd784c (patch)
tree56ba70257c94add690ddaa8b0ec961c6964a146e /src/include
parent2169959c6ba2d77512b8b39366a4d3e476931b4a (diff)
downloadabrt-2cf0d770b66b6c6ce50af2767f575db552cd784c.tar.gz
abrt-2cf0d770b66b6c6ce50af2767f575db552cd784c.tar.xz
abrt-2cf0d770b66b6c6ce50af2767f575db552cd784c.zip
move inc/ and lib/ to src/. No code changes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile.am18
-rw-r--r--src/include/abrt_exception.h57
-rw-r--r--src/include/abrt_types.h50
-rw-r--r--src/include/abrtlib.h269
-rw-r--r--src/include/action.h44
-rw-r--r--src/include/analyzer.h34
-rw-r--r--src/include/comm_layer_inner.h61
-rw-r--r--src/include/crash_types.h133
-rw-r--r--src/include/database.h134
-rw-r--r--src/include/dbus_common.h28
-rw-r--r--src/include/dump_dir.h65
-rw-r--r--src/include/observer.h32
-rw-r--r--src/include/plugin.h135
-rw-r--r--src/include/reporter.h48
-rw-r--r--src/include/xfuncs.h95
15 files changed, 1203 insertions, 0 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
new file mode 100644
index 00000000..993fa62a
--- /dev/null
+++ b/src/include/Makefile.am
@@ -0,0 +1,18 @@
+HEADER_FILES = \
+ abrt_exception.h \
+ abrtlib.h \
+ abrt_types.h \
+ action.h \
+ analyzer.h \
+ comm_layer_inner.h \
+ crash_types.h \
+ database.h \
+ dbus_common.h \
+ dump_dir.h \
+ observer.h \
+ plugin.h \
+ reporter.h \
+ xfuncs.h
+
+lib_includedir=$(includedir)/abrt/
+lib_include_HEADERS = $(HEADER_FILES)
diff --git a/src/include/abrt_exception.h b/src/include/abrt_exception.h
new file mode 100644
index 00000000..b826bfa8
--- /dev/null
+++ b/src/include/abrt_exception.h
@@ -0,0 +1,57 @@
+/*
+ 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
new file mode 100644
index 00000000..38804895
--- /dev/null
+++ b/src/include/abrt_types.h
@@ -0,0 +1,50 @@
+/*
+ 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
+
+#include <map>
+#include <set>
+#include <vector>
+#include <string>
+
+typedef std::vector<std::string> vector_string_t;
+typedef std::set<std::string> set_string_t;
+typedef std::pair<std::string, std::string> pair_string_string_t;
+typedef std::map<std::string, std::string> map_string_t;
+
+typedef std::vector<pair_string_string_t> vector_pair_string_string_t;
+typedef std::vector<map_string_t> vector_map_string_t;
+typedef std::map<std::string, map_string_t> map_map_string_t;
+typedef std::map<std::string, vector_string_t> map_vector_string_t;
+typedef std::map<std::string, vector_pair_string_string_t> map_vector_pair_string_string_t;
+
+/* Report() method return type */
+typedef map_vector_string_t report_status_t;
+/* map_vector_string_t's vector element meaning: */
+#define REPORT_STATUS_IDX_FLAG 0
+#define REPORT_STATUS_IDX_MSG 1
+/* Holds result of .conf file section parsing: map["name"] = "value" */
+typedef map_string_t map_plugin_settings_t;
+
+#endif /* __cplusplus */
+
+#endif
diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h
new file mode 100644
index 00000000..4d565644
--- /dev/null
+++ b/src/include/abrtlib.h
@@ -0,0 +1,269 @@
+/*
+ * Utility routines.
+ *
+ * Licensed under GPLv2, see file COPYING in this tarball for details.
+ */
+#ifndef ABRTLIB_H_
+#define ABRTLIB_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
+
+#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 "hash_md5.h"
+
+#include "crash_types.h"
+#include "dump_dir.h"
+#include "abrt_types.h"
+#include "abrt_packages.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int prefixcmp(const char *str, const char *prefix);
+int suffixcmp(const char *str, const char *suffix);
+char *concat_path_file(const char *path, const char *filename);
+char *append_to_malloced_string(char *mstr, const char *append);
+char* skip_whitespace(const char *s);
+char* skip_non_whitespace(const char *s);
+/* Like strcpy but can copy overlapping strings. */
+void overlapping_strcpy(char *dst, const char *src);
+
+/* A-la fgets, but malloced and of unlimited size */
+char *xmalloc_fgets(FILE *file);
+/* Similar, but removes trailing \n */
+char *xmalloc_fgetline(FILE *file);
+
+/* On error, copyfd_XX prints error messages and returns -1 */
+enum {
+ COPYFD_SPARSE = 1 << 0,
+};
+off_t copyfd_eof(int src_fd, int dst_fd, int flags);
+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);
+off_t copy_file(const char *src_name, const char *dst_name, int mode);
+
+/* Returns malloc'ed block */
+char *encode_base64(const void *src, int length);
+
+unsigned xatou(const char *numstr);
+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);
+
+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,
+};
+/* Returns pid */
+pid_t fork_execv_on_steroids(int flags,
+ char **argv,
+ int *pipefds,
+ char **unsetenv_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) */
+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);
+
+/* Random utility functions */
+
+double get_dirsize(const char *pPath);
+double get_dirsize_find_largest_dir(
+ const char *pPath,
+ char **worst_dir, /* can be NULL */
+ const char *excluded /* can be NULL */
+);
+
+/* 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.
+ */
+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); }
+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
+
+
+/* C++ style stuff */
+#ifdef __cplusplus
+std::string unsigned_to_string(unsigned long long x);
+std::string signed_to_string(long long x);
+template <class T> 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);
+}
+
+void parse_args(const char *psArgs, vector_string_t& pArgs, int quote = -1);
+void parse_release(const char *pRelease, char **product, char **version);
+
+// 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
diff --git a/src/include/action.h b/src/include/action.h
new file mode 100644
index 00000000..21183366
--- /dev/null
+++ b/src/include/action.h
@@ -0,0 +1,44 @@
+/*
+ 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
new file mode 100644
index 00000000..1d78d576
--- /dev/null
+++ b/src/include/analyzer.h
@@ -0,0 +1,34 @@
+/*
+ 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 <string>
+#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/comm_layer_inner.h b/src/include/comm_layer_inner.h
new file mode 100644
index 00000000..2cca9add
--- /dev/null
+++ b/src/include/comm_layer_inner.h
@@ -0,0 +1,61 @@
+/*
+ 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/crash_types.h b/src/include/crash_types.h
new file mode 100644
index 00000000..de9f7bf2
--- /dev/null
+++ b/src/include/crash_types.h
@@ -0,0 +1,133 @@
+/*
+ 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 CRASHTYPES_H_
+#define CRASHTYPES_H_
+
+#include "abrt_types.h"
+
+// 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 CD_UID):
+#define FILENAME_ARCHITECTURE "architecture"
+#define FILENAME_KERNEL "kernel"
+#define FILENAME_TIME "time"
+#define FILENAME_RELEASE "release" /* from /etc/redhat-release */
+// filled by <what?>
+#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"
+// TODO: TicketUploader also has open-coded "TICKET", "CUSTOMER" files
+
+// Apart from CD_UID, which is also stored as a file in dump directory,
+// these items only exist in db. (CD_UID is also a file because
+// dump directory is created before its DB entry, and DB has to learn
+// CD_UID from _somewhere_ in order to be able to store it in DB record,
+// right?)
+#define CD_UID "uid"
+// Now uuid also is saved as a file (but is still stored in database too):
+#define CD_UUID "uuid"
+#define CD_INFORMALL "InformAll"
+#define CD_DUMPDIR "DumpDir"
+#define CD_COUNT "Count"
+#define CD_REPORTED "Reported"
+#define CD_MESSAGE "Message"
+// "Which events are possible (make sense) on this crash dump?"
+// (a string with "\n" terminated event names)
+#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
+}
+#endif
+
+
+#ifdef __cplusplus
+
+// <key, data>
+typedef map_vector_string_t map_crash_data_t;
+typedef std::vector<map_crash_data_t> 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_debug_dump(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 */
+
+
+#endif
diff --git a/src/include/database.h b/src/include/database.h
new file mode 100644
index 00000000..5eaceed7
--- /dev/null
+++ b/src/include/database.h
@@ -0,0 +1,134 @@
+/*
+ Database.h - header file for database 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 DATABASE_H_
+#define DATABASE_H_
+
+#include <glib.h>
+
+/**
+ * Table
+ * =====
+ * UUID | UID| DebugDumpPath | Count | Reported | Time | Message
+ *
+ * primary key (UUID, UID)
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A struct contains one database row.
+ */
+struct db_row
+{
+ char *db_uuid; /**< A local UUID.*/
+ char *db_uid; /**< An UID of an user.*/
+ char *db_inform_all;
+ char *db_dump_dir; /**< A debugdump directory of a crash.*/
+ char *db_count; /**< Crash rate.*/
+ char *db_reported; /**< Is a row reported?*/
+ char *db_message; /**< if a row is reported, then there can be store message abotu that*/
+ char *db_time; /**< Time of last occurred crash with same local UUID*/
+};
+
+void db_row_free(struct db_row *row);
+
+void db_list_free(GList *list);
+
+struct db_row *db_rowcpy_from_list(GList* list);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
+
+#include <string>
+#include <vector>
+
+#include "plugin.h"
+
+/**
+ * An abstract class. The class defines a database plugin interface.
+ */
+class CDatabase : public CPlugin
+{
+ public:
+ /**
+ * A method, which connects to a database.
+ */
+ virtual void Connect() = 0;
+ /**
+ * A method, which disconnects from a database.
+ */
+ virtual void DisConnect() = 0;
+ /**
+ * A method, which inserts one row to a database.
+ * @param pUUID A local UUID of a crash.
+ * @param pUID An UID of an user.
+ * @param pDebugDumpPath A debugdump path.
+ * @param pTime Time when a crash occurs.
+ */
+ virtual void Insert_or_Update(const char *crash_id,
+ bool inform_all_users,
+ const char *pDebugDumpPath,
+ const char *pTime) = 0;
+ /**
+ * A method, which deletes one row in a database.
+ * @param pUUID A lodal UUID of a crash.
+ * @param pUID An UID of an user.
+ */
+ virtual void DeleteRow(const char *crash_id) = 0;
+ virtual void DeleteRows_by_dir(const char *dump_dir) = 0;
+ /**
+ * A method, which sets that particular row was reported.
+ * @param pUUID A local UUID of a crash.
+ * @param pUID An UID of an user.
+ * @param pMessage A text explanation of reported problem
+ * (where it is stored etc)...
+ */
+ virtual void SetReported(const char *crash_id,
+ const char *pMessage) = 0;
+ virtual void SetReportedPerReporter(const char *crash_id,
+ const char *reporter,
+ const char *pMessage) = 0;
+ /**
+ * A method, which gets all rows which belongs to particular user.
+ * If the user is root, then all rows are returned. If there are no
+ * rows, empty vector is returned.
+ * @param pUID An UID of an user.
+ * @return A vector of matched rows.
+ */
+ virtual GList *GetUIDData(long caller_uid) = 0;
+ /**
+ * A method, which returns one row accordind to UUID of a crash and
+ * UID of an user. If there are no row, empty row is returned.
+ * @param pUUID A UUID of a crash.
+ * @param pUID An UID of an user.
+ * @return A matched row.
+ */
+ virtual struct db_row *GetRow(const char *crash_id) = 0;
+ virtual struct db_row *GetRow_by_dir(const char *dir) = 0;
+};
+#endif
+
+#endif
diff --git a/src/include/dbus_common.h b/src/include/dbus_common.h
new file mode 100644
index 00000000..63053cc9
--- /dev/null
+++ b/src/include/dbus_common.h
@@ -0,0 +1,28 @@
+/*
+ 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 "crash_types.h"
+
+#define ABRTD_DBUS_NAME "com.redhat.abrt"
+#define ABRTD_DBUS_PATH "/com/redhat/abrt"
+#define ABRTD_DBUS_IFACE "com.redhat.abrt"
+
+#endif
diff --git a/src/include/dump_dir.h b/src/include/dump_dir.h
new file mode 100644
index 00000000..aeaa3180
--- /dev/null
+++ b/src/include/dump_dir.h
@@ -0,0 +1,65 @@
+/*
+ DebugDump.h - header file for the library caring of writing new reports
+ to the specific directory
+
+ 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 DEBUGDUMP_H_
+#define DEBUGDUMP_H_
+
+#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_debug_dump_dir(const char *dd_dir);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/include/observer.h b/src/include/observer.h
new file mode 100644
index 00000000..1c8f2355
--- /dev/null
+++ b/src/include/observer.h
@@ -0,0 +1,32 @@
+/*
+ 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 <string>
+#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
diff --git a/src/include/plugin.h b/src/include/plugin.h
new file mode 100644
index 00000000..e0f45b6c
--- /dev/null
+++ b/src/include/plugin.h
@@ -0,0 +1,135 @@
+/*
+ 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 "crash_types.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,
+} 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,\
+ };
+
+/* helper functions */
+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_dsc_mailx(const map_crash_data_t& pCrashData);
+
+/**
+ * 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);
+
+#endif
diff --git a/src/include/reporter.h b/src/include/reporter.h
new file mode 100644
index 00000000..469e828e
--- /dev/null
+++ b/src/include/reporter.h
@@ -0,0 +1,48 @@
+/*
+ Reporter.h - header file for reporter 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 REPORTER_H_
+#define REPORTER_H_
+
+#include <string>
+#include "plugin.h"
+#include "crash_types.h"
+
+/**
+ * An abstract class. The class defines a reporter plugin interface.
+ */
+class CReporter : public CPlugin
+{
+ public:
+ /**
+ * A method, which reports a crash report to particular receiver.
+ * The plugin can takes arguments, but the plugin has to parse them
+ * by itself.
+ * @param pCrashData A crash report.
+ * @param pArgs Plugin's arguments.
+ * @retun A message which can be displayed after a report is created.
+ */
+///
+// virtual std::string Report(const map_crash_data_t& pCrashData,
+// const map_plugin_settings_t& pSettings,
+// const char *pArgs) = 0;
+};
+
+#endif /* REPORTER_H_ */
diff --git a/src/include/xfuncs.h b/src/include/xfuncs.h
new file mode 100644
index 00000000..20284564
--- /dev/null
+++ b/src/include/xfuncs.h
@@ -0,0 +1,95 @@
+/*
+ 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
+
+int ndelay_on(int fd);
+int ndelay_off(int fd);
+int close_on_exec_on(int fd);
+
+void* xcalloc(size_t nmemb, size_t size);
+void* xmalloc(size_t size);
+void* xrealloc(void *ptr, size_t size);
+void* xzalloc(size_t size);
+char* xstrdup(const char *s);
+char* xstrndup(const char *s, int n);
+
+void xpipe(int filedes[2]);
+void xdup(int from);
+void xdup2(int from, int to);
+void xmove_fd(int from, int to);
+
+void xwrite(int fd, const void *buf, size_t count);
+void xwrite_str(int fd, const char *str);
+
+off_t xlseek(int fd, off_t offset, int whence);
+
+void xchdir(const char *path);
+
+char* xvasprintf(const char *format, va_list p);
+char* xasprintf(const char *format, ...);
+
+void xsetenv(const char *key, const char *value);
+int xsocket(int domain, int type, int protocol);
+void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
+void xlisten(int s, int backlog);
+ssize_t xsendto(int s, const void *buf, size_t len,
+ const struct sockaddr *to, socklen_t tolen);
+
+void xstat(const char *name, struct stat *stat_buf);
+
+int xopen3(const char *pathname, int flags, int mode);
+int xopen(const char *pathname, int flags);
+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.
+ */
+int is_regular_file(struct dirent *dent, const char *dirname);
+bool dot_or_dotdot(const char *filename);
+char *last_char_is(const char *s, int c);
+
+bool string_to_bool(const char *s);
+
+void xseteuid(uid_t euid);
+void xsetegid(gid_t egid);
+void xsetreuid(uid_t ruid, uid_t euid);
+void xsetregid(gid_t rgid, gid_t egid);
+
+/* Returns getpwuid(uid)->pw_dir or NULL */
+const char *get_home_dir(uid_t uid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif