abrt  2.5.1
A tool to inform users about various problems on the running system
libabrt.h
Go to the documentation of this file.
1 /*
2  * Utility routines.
3  *
4  * Licensed under GPLv2, see file COPYING in this tarball for details.
5  */
6 
9 #ifndef LIBABRT_H_
10 #define LIBABRT_H_
11 
12 #include <regex.h>
13 
14 #include <gio/gio.h> /* dbus */
15 #include "abrt-dbus.h"
16 /* libreport's internal functions we use: */
17 #include <libreport/internal_libreport.h>
18 #include "hooklib.h"
19 
20 #undef ARRAY_SIZE
21 #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Some libc's forget to declare these, do it ourself */
28 extern char **environ;
29 #if defined(__GLIBC__) && __GLIBC__ < 2
30 int vdprintf(int d, const char *format, va_list ap);
31 #endif
32 
33 
34 #define low_free_space abrt_low_free_space
35 
41 int low_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location);
42 
43 #define trim_problem_dirs abrt_trim_problem_dirs
44 void trim_problem_dirs(const char *dirname, double cap_size, const char *exclude_path);
45 #define ensure_writable_dir abrt_ensure_writable_dir
46 void ensure_writable_dir(const char *dir, mode_t mode, const char *user);
47 #define run_unstrip_n abrt_run_unstrip_n
48 char *run_unstrip_n(const char *dump_dir_name, unsigned timeout_sec);
49 #define get_backtrace abrt_get_backtrace
50 char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char *debuginfo_dirs);
51 
52 
53 #define g_settings_nMaxCrashReportsSize abrt_g_settings_nMaxCrashReportsSize
54 extern unsigned int g_settings_nMaxCrashReportsSize;
55 #define g_settings_sWatchCrashdumpArchiveDir abrt_g_settings_sWatchCrashdumpArchiveDir
56 extern char * g_settings_sWatchCrashdumpArchiveDir;
57 #define g_settings_dump_location abrt_g_settings_dump_location
58 extern char * g_settings_dump_location;
59 #define g_settings_delete_uploaded abrt_g_settings_delete_uploaded
60 extern bool g_settings_delete_uploaded;
61 #define g_settings_autoreporting abrt_g_settings_autoreporting
62 extern bool g_settings_autoreporting;
63 #define g_settings_autoreporting_event abrt_g_settings_autoreporting_event
64 extern char * g_settings_autoreporting_event;
65 #define g_settings_shortenedreporting abrt_g_settings_shortenedreporting
66 extern bool g_settings_shortenedreporting;
67 
68 
69 #define load_abrt_conf abrt_load_abrt_conf
70 int load_abrt_conf(void);
71 #define free_abrt_conf_data abrt_free_abrt_conf_data
72 void free_abrt_conf_data(void);
73 
74 #define load_abrt_conf_file abrt_load_abrt_conf_file
75 int load_abrt_conf_file(const char *file, map_string_t *settings);
76 
77 #define load_abrt_plugin_conf_file abrt_load_abrt_plugin_conf_file
78 int load_abrt_plugin_conf_file(const char *file, map_string_t *settings);
79 
80 #define save_abrt_conf_file abrt_save_abrt_conf_file
81 int save_abrt_conf_file(const char *file, map_string_t *settings);
82 
83 #define save_abrt_plugin_conf_file abrt_save_abrt_plugin_conf_file
84 int save_abrt_plugin_conf_file(const char *file, map_string_t *settings);
85 
86 
87 void migrate_to_xdg_dirs(void);
88 
89 int check_recent_crash_file(const char *filename, const char *executable);
90 
91 /* Returns 1 if abrtd daemon is running, 0 otherwise. */
92 #define daemon_is_ok abrt_daemon_is_ok
93 int daemon_is_ok(void);
94 
100 #define notify_new_path abrt_notify_new_path
101 void notify_new_path(const char *path);
102 
103 /* Note: should be public since unit tests need to call it */
104 #define koops_extract_version abrt_koops_extract_version
105 char *koops_extract_version(const char *line);
106 #define kernel_tainted_short abrt_kernel_tainted_short
107 char *kernel_tainted_short(const char *kernel_bt);
108 #define kernel_tainted_long abrt_kernel_tainted_long
109 char *kernel_tainted_long(const char *tainted_short);
110 #define koops_hash_str_ext abrt_koops_hash_str_ext
111 int koops_hash_str_ext(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *oops_buf, int frame_count, int duphas_flags);
112 #define koops_hash_str abrt_koops_hash_str
113 int koops_hash_str(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *oops_buf);
114 
115 
116 #define koops_line_skip_level abrt_koops_line_skip_level
117 int koops_line_skip_level(const char **c);
118 #define koops_line_skip_jiffies abrt_koops_line_skip_jiffies
119 void koops_line_skip_jiffies(const char **c);
120 
121 /*
122  * extract_oops tries to find oops signatures in a log
123  */
125  char *ptr;
126  int level;
127 };
128 
129 #define koops_extract_oopses_from_lines abrt_koops_extract_oopses_from_lines
130 void koops_extract_oopses_from_lines(GList **oops_list, const struct abrt_koops_line_info *lines_info, int lines_info_size);
131 #define koops_extract_oopses abrt_koops_extract_oopses
132 void koops_extract_oopses(GList **oops_list, char *buffer, size_t buflen);
133 #define koops_suspicious_strings_list abrt_koops_suspicious_strings_list
134 GList *koops_suspicious_strings_list(void);
135 #define koops_print_suspicious_strings abrt_koops_print_suspicious_strings
136 void koops_print_suspicious_strings(void);
143 #define koops_print_suspicious_strings_filtered abrt_koops_print_suspicious_strings_filtered
144 void koops_print_suspicious_strings_filtered(const regex_t **filterout);
145 
146 /* dbus client api */
147 
155 int chown_dir_over_dbus(const char *problem_dir_path);
156 
164 int test_exist_over_dbus(const char *problem_id, const char *element_name);
165 
173 char *load_text_over_dbus(const char *problem_id, const char *element_name);
174 
182 int delete_problem_dirs_over_dbus(const GList *problem_dir_paths);
183 
189 problem_data_t *get_problem_data_dbus(const char *problem_dir_path);
190 
196 problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path);
197 
204 GList *get_problems_over_dbus(bool authorize);
205 
210 typedef struct ignored_problems ignored_problems_t;
211 
219 ignored_problems_t *ignored_problems_new(char *file_path);
220 
230 
239 void ignored_problems_add(ignored_problems_t *set, const char *problem_id);
240 
249 void ignored_problems_remove(ignored_problems_t *set, const char *problem_id);
250 
261 bool ignored_problems_contains(ignored_problems_t *set, const char *problem_id);
262 
271 void ignored_problems_add_problem_data(ignored_problems_t *set, problem_data_t *pd);
272 
281 void ignored_problems_remove_problem_data(ignored_problems_t *set, problem_data_t *pd);
282 
293 bool ignored_problems_contains_problem_data(ignored_problems_t *set, problem_data_t *pd);
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 #endif
int delete_problem_dirs_over_dbus(const GList *problem_dir_paths)
Delets multiple problems specified by their id (as returned from problem_data_save) ...
void ignored_problems_add_problem_data(ignored_problems_t *set, problem_data_t *pd)
Adds a problem defined by its data to the ignored problems.
GList * get_problems_over_dbus(bool authorize)
Fetches all problems from problem database.
An opaque structure holding a list of ignored problems.
void ignored_problems_remove(ignored_problems_t *set, const char *problem_id)
Removes a problem from the ignored problems.
bool ignored_problems_contains_problem_data(ignored_problems_t *set, problem_data_t *pd)
Checks if a problem defined its data is in the ignored problems.
bool ignored_problems_contains(ignored_problems_t *set, const char *problem_id)
Checks if a problem is in the ignored problems.
int test_exist_over_dbus(const char *problem_id, const char *element_name)
Checks whether the given element name exists.
ignored_problems_t * ignored_problems_new(char *file_path)
Initializes a new instance of ignored problems.
problem_data_t * get_full_problem_data_over_dbus(const char *problem_dir_path)
Fetches full problem data for specified problem id.
#define notify_new_path
Sends notification to abrtd that a new problem has been detected.
Definition: libabrt.h:100
char * load_text_over_dbus(const char *problem_id, const char *element_name)
void ignored_problems_remove_problem_data(ignored_problems_t *set, problem_data_t *pd)
Removes a problem defined by its data from the ignored problems.
problem_data_t * get_problem_data_dbus(const char *problem_dir_path)
Fetches problem information for specified problem id.
#define koops_print_suspicious_strings_filtered
Definition: libabrt.h:143
void ignored_problems_free(ignored_problems_t *set)
Destroys an instance of ignored problems.
void ignored_problems_add(ignored_problems_t *set, const char *problem_id)
Adds a problem to the ignored problems.
int low_free_space(unsigned setting_MaxCrashReportsSize, const char *dump_location)
Checks if there is enough free space to store the problem data.
int chown_dir_over_dbus(const char *problem_dir_path)
Changes the access rights of the problem specified by problem id.