From f2e2bba844ed36ab3b9ce0c936dad673cfc865b9 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 7 Mar 2011 15:36:07 +0100 Subject: added function to parse event description from xml file --- src/include/Makefile.am | 3 ++- src/include/abrtlib.h | 3 +++ src/include/report/event_xml_parser.h | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/include/report/event_xml_parser.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 477963c3..e21b043b 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -2,7 +2,8 @@ libreport_includedir = $(includedir)/report libreport_include_HEADERS = \ report/crash_data.h \ report/dump_dir.h \ - report/run_event.h + report/run_event.h \ + report/event_xml_parser.h libabrt_includedir = $(includedir)/abrt libabrt_include_HEADERS = \ diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 116f4b36..1b2f6bbc 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -82,6 +82,7 @@ int vdprintf(int d, const char *format, va_list ap); #include "abrt_types.h" #include "dump_dir.h" #include "run_event.h" +#include "event_xml_parser.h" #ifdef __cplusplus @@ -256,6 +257,8 @@ void parse_release_for_rhts(const char *pRelease, char **product, char **version #define load_conf_file abrt_load_conf_file bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue); +void load_event_description_from_file(event_obj_t *event_desc, const char* filename); + /* Tries to create a copy of dump_dir_name in base_dir, with same or similar basename. * Returns NULL if copying failed. In this case, logs a message before returning. */ #define steal_directory abrt_steal_directory diff --git a/src/include/report/event_xml_parser.h b/src/include/report/event_xml_parser.h new file mode 100644 index 00000000..caf81506 --- /dev/null +++ b/src/include/report/event_xml_parser.h @@ -0,0 +1,41 @@ +#include + +typedef enum +{ + OPTION_TYPE_TEXT, + OPTION_TYPE_BOOL, + OPTION_TYPE_PASSWORD, + OPTION_TYPE_NUMBER, + 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 +{ + const char* label; + const char* name; //name of the value which should be used for env variable + char *value; + option_type_t type; + const char* description; //can be used as tooltip in gtk app + const char* allowed_value; + int required; +} event_option_obj_t; + +//structure to hold the option data +typedef struct +{ + const char *name; //name of the event "Bugzilla" "RedHat Support Uploader" + const char *title; //window title - not used right now, maybe the "name" is enough? + const char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" + GList *options; +} event_obj_t; -- cgit From bad8487bf919ba4b221b7be065c346221943812c Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 7 Mar 2011 15:47:54 +0100 Subject: minor build fixes --- src/include/abrtlib.h | 2 -- src/include/report/event_xml_parser.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 1b2f6bbc..6122f467 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -257,8 +257,6 @@ void parse_release_for_rhts(const char *pRelease, char **product, char **version #define load_conf_file abrt_load_conf_file bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue); -void load_event_description_from_file(event_obj_t *event_desc, const char* filename); - /* Tries to create a copy of dump_dir_name in base_dir, with same or similar basename. * Returns NULL if copying failed. In this case, logs a message before returning. */ #define steal_directory abrt_steal_directory diff --git a/src/include/report/event_xml_parser.h b/src/include/report/event_xml_parser.h index caf81506..47852c67 100644 --- a/src/include/report/event_xml_parser.h +++ b/src/include/report/event_xml_parser.h @@ -39,3 +39,5 @@ typedef struct const char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" GList *options; } event_obj_t; + +void load_event_description_from_file(event_obj_t *event_desc, const char* filename); \ No newline at end of file -- cgit From 4af44e92c689fe442dddbf6e18e2731e2d479c5a Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 7 Mar 2011 15:59:00 +0100 Subject: event_xml_parser: string fields shouldn't be const, moved name and value higher in the structure --- src/include/report/event_xml_parser.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/include') diff --git a/src/include/report/event_xml_parser.h b/src/include/report/event_xml_parser.h index 47852c67..c6bda9d5 100644 --- a/src/include/report/event_xml_parser.h +++ b/src/include/report/event_xml_parser.h @@ -22,21 +22,21 @@ typedef enum */ typedef struct { - const char* label; - const char* name; //name of the value which should be used for env variable + char *name; //name of the value which should be used for env variable char *value; + char *label; option_type_t type; - const char* description; //can be used as tooltip in gtk app - const char* allowed_value; + char *description; //can be used as tooltip in gtk app + char *allowed_value; int required; } event_option_obj_t; //structure to hold the option data typedef struct { - const char *name; //name of the event "Bugzilla" "RedHat Support Uploader" - const char *title; //window title - not used right now, maybe the "name" is enough? - const char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" + char *name; //name of the event "Bugzilla" "RedHat Support Uploader" + char *title; //window title - not used right now, maybe the "name" is enough? + char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" GList *options; } event_obj_t; -- cgit From d18a48afc602a19130d13af6097df566fa260690 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 7 Mar 2011 16:11:33 +0100 Subject: event_option_obj_t -> event_option_t, event_obj_t -> event_config_t --- src/include/report/event_xml_parser.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/include') diff --git a/src/include/report/event_xml_parser.h b/src/include/report/event_xml_parser.h index c6bda9d5..8e55b1b0 100644 --- a/src/include/report/event_xml_parser.h +++ b/src/include/report/event_xml_parser.h @@ -29,7 +29,7 @@ typedef struct char *description; //can be used as tooltip in gtk app char *allowed_value; int required; -} event_option_obj_t; +} event_option_t; //structure to hold the option data typedef struct @@ -38,6 +38,6 @@ typedef struct char *title; //window title - not used right now, maybe the "name" is enough? char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" GList *options; -} event_obj_t; +} event_config_t; -void load_event_description_from_file(event_obj_t *event_desc, const char* filename); \ No newline at end of file +void load_event_description_from_file(event_config_t *event_config, const char* filename); \ No newline at end of file -- cgit From 75d2a56b6420fd65f596b8ee18b02e121147ea4e Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 7 Mar 2011 17:09:43 +0100 Subject: renamed some files, no code changes --- src/include/Makefile.am | 2 +- src/include/abrtlib.h | 2 +- src/include/report/event_config.h | 51 +++++++++++++++++++++++++++++++++++ src/include/report/event_xml_parser.h | 43 ----------------------------- 4 files changed, 53 insertions(+), 45 deletions(-) create mode 100644 src/include/report/event_config.h delete mode 100644 src/include/report/event_xml_parser.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index e21b043b..e6f0387b 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -3,7 +3,7 @@ libreport_include_HEADERS = \ report/crash_data.h \ report/dump_dir.h \ report/run_event.h \ - report/event_xml_parser.h + report/event_config.h libabrt_includedir = $(includedir)/abrt libabrt_include_HEADERS = \ diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 6122f467..435c4def 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -82,7 +82,7 @@ int vdprintf(int d, const char *format, va_list ap); #include "abrt_types.h" #include "dump_dir.h" #include "run_event.h" -#include "event_xml_parser.h" +#include "event_config.h" #ifdef __cplusplus diff --git a/src/include/report/event_config.h b/src/include/report/event_config.h new file mode 100644 index 00000000..ee0cf7ab --- /dev/null +++ b/src/include/report/event_config.h @@ -0,0 +1,51 @@ +#include + +typedef enum +{ + OPTION_TYPE_TEXT, + OPTION_TYPE_BOOL, + OPTION_TYPE_PASSWORD, + OPTION_TYPE_NUMBER, + 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 *name; //name of the value which should be used for env variable + char *value; + char *label; + option_type_t type; + char *description; //can be used as tooltip in gtk app + char *allowed_value; + int required; +} event_option_t; + +//structure to hold the option data +typedef struct +{ + char *name; //name of the event "Bugzilla" "RedHat Support Uploader" + char *title; //window title - not used right now, maybe the "name" is enough? + char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" + GList *options; +} event_config_t; + +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 *name); + +extern GList *g_event_config_list; // for iterating through entire list of all loaded configs \ No newline at end of file diff --git a/src/include/report/event_xml_parser.h b/src/include/report/event_xml_parser.h deleted file mode 100644 index 8e55b1b0..00000000 --- a/src/include/report/event_xml_parser.h +++ /dev/null @@ -1,43 +0,0 @@ -#include - -typedef enum -{ - OPTION_TYPE_TEXT, - OPTION_TYPE_BOOL, - OPTION_TYPE_PASSWORD, - OPTION_TYPE_NUMBER, - 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 *name; //name of the value which should be used for env variable - char *value; - char *label; - option_type_t type; - char *description; //can be used as tooltip in gtk app - char *allowed_value; - int required; -} event_option_t; - -//structure to hold the option data -typedef struct -{ - char *name; //name of the event "Bugzilla" "RedHat Support Uploader" - char *title; //window title - not used right now, maybe the "name" is enough? - char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" - GList *options; -} event_config_t; - -void load_event_description_from_file(event_config_t *event_config, const char* filename); \ No newline at end of file -- cgit From 1292529dafdca6543ce9e85d383effb2c566b79a Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 7 Mar 2011 17:25:15 +0100 Subject: add license and #ifdef EVENT_CONFIG_H around header Signed-off-by: Nikola Pajkovsky --- src/include/report/event_config.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/report/event_config.h b/src/include/report/event_config.h index ee0cf7ab..e4710dcf 100644 --- a/src/include/report/event_config.h +++ b/src/include/report/event_config.h @@ -1,5 +1,26 @@ +/* + Copyright (C) 2011 ABRT team + + 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 +#ifndef EVENT_CONFIG_H +#define EVENT_CONFIG_H + typedef enum { OPTION_TYPE_TEXT, @@ -48,4 +69,6 @@ void load_event_config_data(void); void free_event_config_data(void); event_config_t *get_event_config(const char *name); -extern GList *g_event_config_list; // for iterating through entire list of all loaded configs \ No newline at end of file +extern GList *g_event_config_list; // for iterating through entire list of all loaded configs + +#endif -- cgit From 62890f4365ce10d71d1e122aec1d65566825b1f6 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Mon, 7 Mar 2011 17:32:37 +0100 Subject: added event_config.c stub --- src/include/report/event_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/report/event_config.h b/src/include/report/event_config.h index ee0cf7ab..3d05a2c9 100644 --- a/src/include/report/event_config.h +++ b/src/include/report/event_config.h @@ -48,4 +48,4 @@ void load_event_config_data(void); void free_event_config_data(void); event_config_t *get_event_config(const char *name); -extern GList *g_event_config_list; // for iterating through entire list of all loaded configs \ No newline at end of file +extern GHashTable *g_event_config_list; // for iterating through entire list of all loaded configs \ No newline at end of file -- cgit From ef47609ab73ba222e0ef9f2da51dca4650af69d8 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 7 Mar 2011 21:49:51 +0100 Subject: gui-wizard-gtk: add code to export/unexport config variables. Untested Signed-off-by: Denys Vlasenko --- src/include/xfuncs.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/include') diff --git a/src/include/xfuncs.h b/src/include/xfuncs.h index 61188c81..5f2504b6 100644 --- a/src/include/xfuncs.h +++ b/src/include/xfuncs.h @@ -74,6 +74,19 @@ 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 -- cgit From abb11fca1bcd7932d14c911d63fb7c6c347dcbcd Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 8 Mar 2011 14:07:33 +0100 Subject: make fork_execv_on_steroids capable of setting env vars too Before, it could only unset them. Signed-off-by: Denys Vlasenko --- src/include/abrtlib.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 435c4def..f64046d9 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -170,12 +170,17 @@ enum { EXECFLG_SETGUID = 1 << 7, EXECFLG_SETSID = 1 << 8, }; -/* Returns pid */ +/* + * 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 abrt_fork_execv_on_steroids pid_t fork_execv_on_steroids(int flags, char **argv, int *pipefds, - char **unsetenv_vec, + char **env_vec, const char *dir, uid_t uid); /* Returns malloc'ed string. NULs are retained, and extra one is appended -- cgit From a6ee8958dbe6f45f95fca4fa2ea1490c7035be65 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 8 Mar 2011 16:23:31 +0100 Subject: implement load_event_config_data. Untested. Signed-off-by: Denys Vlasenko --- src/include/report/event_config.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/include') diff --git a/src/include/report/event_config.h b/src/include/report/event_config.h index c383bce4..d2624e60 100644 --- a/src/include/report/event_config.h +++ b/src/include/report/event_config.h @@ -52,6 +52,9 @@ typedef struct 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 { @@ -61,6 +64,10 @@ typedef struct 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} -- cgit From e2fdf6c58eba440770624d13e25a63c3d77040db Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Tue, 8 Mar 2011 21:31:45 +0100 Subject: added event description support into xml parser - so event now has: action: description of what will happen when this event is used - the main purpose is for the event selector in wizard description: description of the event --- src/include/report/event_config.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/include') diff --git a/src/include/report/event_config.h b/src/include/report/event_config.h index d2624e60..e2310885 100644 --- a/src/include/report/event_config.h +++ b/src/include/report/event_config.h @@ -61,6 +61,7 @@ typedef struct char *name; //name of the event "Bugzilla" "RedHat Support Uploader" char *title; //window title - not used right now, maybe the "name" is enough? char *action;//action description to show in gui like: Upload report to the Red Hat bugzilla" + char *description; GList *options; } event_config_t; -- cgit From 97db1f93f59091fc85624b618e7cec1ac3d48169 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Wed, 9 Mar 2011 12:31:03 +0100 Subject: view details in extrenal editor for multiline non-binary files Signed-off-by: Nikola Pajkovsky --- src/include/report/crash_data.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/include') diff --git a/src/include/report/crash_data.h b/src/include/report/crash_data.h index 3854118a..2dfdb242 100644 --- a/src/include/report/crash_data.h +++ b/src/include/report/crash_data.h @@ -32,8 +32,12 @@ enum { CD_FLAG_TXT = (1 << 1), CD_FLAG_ISEDITABLE = (1 << 2), CD_FLAG_ISNOTEDITABLE = (1 << 3), + CD_FLAG_ONELINE = (1 << 4), }; +#define IS_TXT(flag) ((flag) & CD_FLAG_TXT) +#define IS_ONELINE(flag) ((flag) & CD_FLAG_ONELINE) + struct crash_item { char *content; unsigned flags; -- cgit