Reorganize header, move objects under the appropriate source file
[platform/upstream/corewatcher.git] / src / corewatcher.h
1 /*
2  * Copyright 2007, Intel Corporation
3  *
4  * This file is part of corewatcher.org
5  *
6  * This program file is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program in a file named COPYING; if not, write to the
17  * Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301 USA
20  *
21  * Authors:
22  *      Arjan van de Ven <arjan@linux.intel.com>
23  *      William Douglas <william.douglas@intel.com>
24  */
25
26
27 #ifndef __INCLUDE_GUARD_KERNELOOPS_H_
28 #define __INCLUDE_GUARD_KERNELOOPS_H_
29
30 /* borrowed from the kernel */
31 #define barrier() __asm__ __volatile__("": : :"memory")
32 #define __unused  __attribute__ ((__unused__))
33
34 #define MAX_PROCESSING_OOPS 10
35 #define MAX_URLS 9
36
37 #define FREE_OOPS(oops)                                 \
38         do {                                            \
39                 if (oops) {                             \
40                         free(oops->application);        \
41                         free(oops->text);               \
42                         free(oops->filename);           \
43                         free(oops->detail_filename);    \
44                         free(oops);                     \
45                 }                                       \
46         } while(0)
47
48 struct oops {
49         struct oops *next;
50         char *application;
51         char *text;
52         char *filename;
53         char *detail_filename;
54 };
55
56 /* Always pick up the queued_mtx and then the
57    processing_mtx, reverse for setting down */
58 /* Considering the static mutexes the total global order should be:
59    queued_mtx -> processing_mtx -> gdb_mtx ->processing_queue_mtx */
60 /* The asked_mtx doesn't overlap with any of these */
61 struct core_status {
62         GHashTable *asked_oops;
63         GHashTable *processing_oops;
64         GHashTable *queued_oops;
65         pthread_mutex_t asked_mtx;
66         pthread_mutex_t processing_mtx;
67         pthread_mutex_t queued_mtx;
68 };
69
70 /* submit.c */
71 extern void queue_backtrace(struct oops *oops);
72 extern void submit_queue(void);
73 extern char *replace_name(char *filename, char *replace, char *new);
74
75 /* coredump.c */
76 extern int move_core(char *fullpath, char *ext);
77 extern int scan_dmesg(void * unused);
78 extern char *strip_directories(char *fullpath);
79 extern char *get_core_filename(char *filename, char *ext);
80 extern void remove_pid_from_hash(char *fullpath, GHashTable *ht);
81 extern int uid;
82 extern int sig;
83
84 /* configfile.c */
85 extern void read_config_file(char *filename);
86 extern int opted_in;
87 extern int allow_distro_to_pass_on;
88 extern char *submit_url[MAX_URLS];
89 extern char *build_release;
90 extern char *core_folder;
91 extern int url_count;
92 extern int do_unlink;
93 extern int private_report;
94
95 /* corewatcher.c */
96 extern void dbus_ask_permission(char *fullpath, char *appfile);
97 extern void dbus_say_thanks(char *url);
98 extern void dbus_say_found(char *fullpath, char *appfile);
99 extern int testmode;
100 extern int pinged;
101 extern struct core_status core_status;
102
103 /* find_file.c */
104 extern char *find_executable(char *fragment);
105 extern char *find_coredump(char *fullpath);
106
107 #endif