Pure rename, no textual changes to the files
--
vda
diff -x '*.po' -d -urpN abrt.9/src/lib/crash_dump.c abrt.a/src/lib/crash_dump.c
--- abrt.9/src/lib/crash_dump.c 1970-01-01 01:00:00.000000000 +0100
+++ abrt.a/src/lib/crash_dump.c 2010-12-06 16:36:07.894642513 +0100
@@ -0,0 +1,246 @@
+/*
+ Copyright (C) 2010 Denys Vlasenko (dvlasenk@redhat.com)
+ 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 "abrtlib.h"
+#include "abrt_crash_dump.h"
+
+static void free_crash_item(void *ptr)
+{
+ if (ptr)
+ {
+ struct crash_item *item = (struct crash_item *)ptr;
+ free(item->content);
+ free(item);
+ }
+}
+
+
+/* crash_data["name"] = { "content", CD_FLAG_foo_bits } */
+
+crash_data_t *new_crash_data(void)
+{
+ return g_hash_table_new_full(g_str_hash, g_str_equal,
+ free, free_crash_item);
+}
+
+void add_to_crash_data_ext(crash_data_t *crash_data,
+ const char *name,
+ const char *content,
+ unsigned flags)
+{
+ struct crash_item *item = (struct crash_item *)xzalloc(sizeof(*item));
+ item->content = xstrdup(content);
+ item->flags = flags;
+ g_hash_table_replace(crash_data, xstrdup(name), item);
+}
+
+void add_to_crash_data(crash_data_t *crash_data,
+ const char *name,
+ const char *content)
+{
+ add_to_crash_data_ext(crash_data, name, content, CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE);
+}
+
+const char *get_crash_item_content_or_die(crash_data_t *crash_data, const char *key)
+{
+ struct crash_item *item = get_crash_data_item_or_NULL(crash_data, key);
+ if (!item)
+ error_msg_and_die("Error accessing crash data: no ['%s']", key);
+ return item->content;
+}
+
+const char *get_crash_item_content_or_NULL(crash_data_t *crash_data, const char *key)
+{
+ struct crash_item *item = get_crash_data_item_or_NULL(crash_data, key);
+ if (!item)
+ return NULL;
+ return item->content;
+}
+
+
+/* crash_data_vector[i] = { "name" = { "content", CD_FLAG_foo_bits } } */
+
+vector_of_crash_data_t *new_vector_of_crash_data(void)
+{
+ return g_ptr_array_new_with_free_func((void (*)(void*)) &free_crash_data);
+}
+
+
+/* Miscellaneous helpers */
+
+static const char *const editable_files[] = {
+ FILENAME_DESCRIPTION,
+ FILENAME_COMMENT ,
+ FILENAME_REPRODUCE ,
+ FILENAME_BACKTRACE ,
+ NULL
+};
+
+static bool is_editable(const char *name, const char *const *v)
+{
+ while (*v) {
+ if (strcmp(*v, name) == 0)
+ return true;
+ v++;
+ }
+ return false;
+}
+
+bool is_editable_file(const char *file_name)
+{
+ return is_editable(file_name, editable_files);
+}
+
+static char* is_text_file(const char *name, ssize_t *sz)
+{
+ /* We were using magic.h API to check for file being text, but it thinks
+ * that file containing just "0" is not text (!!)
+ * So, we do it ourself.
+ */
+
+ int fd = open(name, O_RDONLY);
+ if (fd < 0)
+ return NULL; /* it's not text (because it does not exist! :) */
+
+ /* Maybe 64k limit is small. But _some_ limit is necessary:
+ * fields declared "text" may end up in editing fields and such.
+ * We don't want to accidentally end up with 100meg text in a textbox!
+ * So, don't remove this. If you really need to, raise the limit.
+ */
+ off_t size = lseek(fd, 0, SEEK_END);
+ if (size < 0 || size > 64*1024)
+ {
+ close(fd);
+ return NULL; /* it's not a SMALL text */
+ }
+ lseek(fd, 0, SEEK_SET);
+
+ char *buf = (char*)xmalloc(*sz);
+ ssize_t r = *sz = full_read(fd, buf, *sz);
+ close(fd);
+ if (r < 0)
+ {
+ free(buf);
+ return NULL; /* it's not text (because we can't read it) */
+ }
+
+ /* Some files in our dump directories are known to always be textual */
+ const char *base = strrchr(name, '/');
+ if (base)
+ {
+ base++;
+ if (strcmp(base, FILENAME_BACKTRACE) == 0
+ || strcmp(base, FILENAME_CMDLINE) == 0
+ ) {
+ return buf;
+ }
+ }
+
+ /* Every once in a while, even a text file contains a few garbled
+ * or unexpected non-ASCII chars. We should not declare it "binary".
+ */
+ const unsigned RATIO = 50;
+ unsigned total_chars = r + RATIO;
+ unsigned bad_chars = 1; /* 1 prevents division by 0 later */
+ while (--r >= 0)
+ {
+ if (buf[r] >= 0x7f
+ /* among control chars, only '\t','\n' etc are allowed */
+ || (buf[r] < ' ' && !isspace(buf[r]))
+ ) {
+ if (buf[r] == '\0')
+ {
+ /* We don't like NULs very much. Not text for sure! */
+ free(buf);
+ return NULL;
+ }
+ bad_chars++;
+ }
+ }
+
+ if ((total_chars / bad_chars) >= RATIO)
+ return buf; /* looks like text to me */
+
+ free(buf);
+ return NULL; /* it's binary */
+}
+
+crash_data_t *load_crash_data_from_crash_dump_dir(struct dump_dir *dd)
+{
+ char *short_name;
+ char *full_name;
+ crash_data_t *crash_data = new_crash_data();
+
+ dd_init_next_file(dd);
+ while (dd_get_next_file(dd, &short_name, &full_name))
+ {
+ ssize_t sz = 4*1024;
+ char *text = NULL;
+ bool editable = is_editable_file(short_name);
+
+ if (!editable)
+ {
+ text = is_text_file(full_name, &sz);
+ if (!text)
+ {
+ add_to_crash_data_ext(crash_data,
+ short_name,
+ full_name,
+ CD_FLAG_BIN + CD_FLAG_ISNOTEDITABLE
+ );
+
+ free(short_name);
+ free(full_name);
+ continue;
+ }
+ }
+
+ char *content;
+ if (sz < 4*1024) /* is_text_file did read entire file */
+ content = xstrndup(text, sz); //TODO: can avoid this copying if is_text_file() adds NUL
+ else /* no, need to read it all */
+ content = dd_load_text(dd, short_name);
+ free(text);
+
+ add_to_crash_data_ext(crash_data,
+ short_name,
+ content,
+ (editable ? CD_FLAG_TXT + CD_FLAG_ISEDITABLE : CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE)
+ );
+ free(short_name);
+ free(full_name);
+ free(content);
+ }
+ return crash_data;
+}
+
+void log_map_crash_data(crash_data_t *crash_data, const char *pfx)
+{
+ GHashTableIter iter;
+ char *name;
+ struct crash_item *value;
+ g_hash_table_iter_init(&iter, crash_data);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+ log("%s[%s]:'%s' 0x%x",
+ pfx, name,
+ value->content,
+ value->flags
+ );
+ }
+}
diff -x '*.po' -d -urpN abrt.9/src/lib/crash_dump.cpp abrt.a/src/lib/crash_dump.cpp
--- abrt.9/src/lib/crash_dump.cpp 2010-12-06 16:36:07.894642513 +0100
+++ abrt.a/src/lib/crash_dump.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,246 +0,0 @@
-/*
- Copyright (C) 2010 Denys Vlasenko (dvlasenk@redhat.com)
- 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 "abrtlib.h"
-#include "abrt_crash_dump.h"
-
-static void free_crash_item(void *ptr)
-{
- if (ptr)
- {
- struct crash_item *item = (struct crash_item *)ptr;
- free(item->content);
- free(item);
- }
-}
-
-
-/* crash_data["name"] = { "content", CD_FLAG_foo_bits } */
-
-crash_data_t *new_crash_data(void)
-{
- return g_hash_table_new_full(g_str_hash, g_str_equal,
- free, free_crash_item);
-}
-
-void add_to_crash_data_ext(crash_data_t *crash_data,
- const char *name,
- const char *content,
- unsigned flags)
-{
- struct crash_item *item = (struct crash_item *)xzalloc(sizeof(*item));
- item->content = xstrdup(content);
- item->flags = flags;
- g_hash_table_replace(crash_data, xstrdup(name), item);
-}
-
-void add_to_crash_data(crash_data_t *crash_data,
- const char *name,
- const char *content)
-{
- add_to_crash_data_ext(crash_data, name, content, CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE);
-}
-
-const char *get_crash_item_content_or_die(crash_data_t *crash_data, const char *key)
-{
- struct crash_item *item = get_crash_data_item_or_NULL(crash_data, key);
- if (!item)
- error_msg_and_die("Error accessing crash data: no ['%s']", key);
- return item->content;
-}
-
-const char *get_crash_item_content_or_NULL(crash_data_t *crash_data, const char *key)
-{
- struct crash_item *item = get_crash_data_item_or_NULL(crash_data, key);
- if (!item)
- return NULL;
- return item->content;
-}
-
-
-/* crash_data_vector[i] = { "name" = { "content", CD_FLAG_foo_bits } } */
-
-vector_of_crash_data_t *new_vector_of_crash_data(void)
-{
- return g_ptr_array_new_with_free_func((void (*)(void*)) &free_crash_data);
-}
-
-
-/* Miscellaneous helpers */
-
-static const char *const editable_files[] = {
- FILENAME_DESCRIPTION,
- FILENAME_COMMENT ,
- FILENAME_REPRODUCE ,
- FILENAME_BACKTRACE ,
- NULL
-};
-
-static bool is_editable(const char *name, const char *const *v)
-{
- while (*v) {
- if (strcmp(*v, name) == 0)
- return true;
- v++;
- }
- return false;
-}
-
-bool is_editable_file(const char *file_name)
-{
- return is_editable(file_name, editable_files);
-}
-
-static char* is_text_file(const char *name, ssize_t *sz)
-{
- /* We were using magic.h API to check for file being text, but it thinks
- * that file containing just "0" is not text (!!)
- * So, we do it ourself.
- */
-
- int fd = open(name, O_RDONLY);
- if (fd < 0)
- return NULL; /* it's not text (because it does not exist! :) */
-
- /* Maybe 64k limit is small. But _some_ limit is necessary:
- * fields declared "text" may end up in editing fields and such.
- * We don't want to accidentally end up with 100meg text in a textbox!
- * So, don't remove this. If you really need to, raise the limit.
- */
- off_t size = lseek(fd, 0, SEEK_END);
- if (size < 0 || size > 64*1024)
- {
- close(fd);
- return NULL; /* it's not a SMALL text */
- }
- lseek(fd, 0, SEEK_SET);
-
- char *buf = (char*)xmalloc(*sz);
- ssize_t r = *sz = full_read(fd, buf, *sz);
- close(fd);
- if (r < 0)
- {
- free(buf);
- return NULL; /* it's not text (because we can't read it) */
- }
-
- /* Some files in our dump directories are known to always be textual */
- const char *base = strrchr(name, '/');
- if (base)
- {
- base++;
- if (strcmp(base, FILENAME_BACKTRACE) == 0
- || strcmp(base, FILENAME_CMDLINE) == 0
- ) {
- return buf;
- }
- }
-
- /* Every once in a while, even a text file contains a few garbled
- * or unexpected non-ASCII chars. We should not declare it "binary".
- */
- const unsigned RATIO = 50;
- unsigned total_chars = r + RATIO;
- unsigned bad_chars = 1; /* 1 prevents division by 0 later */
- while (--r >= 0)
- {
- if (buf[r] >= 0x7f
- /* among control chars, only '\t','\n' etc are allowed */
- || (buf[r] < ' ' && !isspace(buf[r]))
- ) {
- if (buf[r] == '\0')
- {
- /* We don't like NULs very much. Not text for sure! */
- free(buf);
- return NULL;
- }
- bad_chars++;
- }
- }
-
- if ((total_chars / bad_chars) >= RATIO)
- return buf; /* looks like text to me */
-
- free(buf);
- return NULL; /* it's binary */
-}
-
-crash_data_t *load_crash_data_from_crash_dump_dir(struct dump_dir *dd)
-{
- char *short_name;
- char *full_name;
- crash_data_t *crash_data = new_crash_data();
-
- dd_init_next_file(dd);
- while (dd_get_next_file(dd, &short_name, &full_name))
- {
- ssize_t sz = 4*1024;
- char *text = NULL;
- bool editable = is_editable_file(short_name);
-
- if (!editable)
- {
- text = is_text_file(full_name, &sz);
- if (!text)
- {
- add_to_crash_data_ext(crash_data,
- short_name,
- full_name,
- CD_FLAG_BIN + CD_FLAG_ISNOTEDITABLE
- );
-
- free(short_name);
- free(full_name);
- continue;
- }
- }
-
- char *content;
- if (sz < 4*1024) /* is_text_file did read entire file */
- content = xstrndup(text, sz); //TODO: can avoid this copying if is_text_file() adds NUL
- else /* no, need to read it all */
- content = dd_load_text(dd, short_name);
- free(text);
-
- add_to_crash_data_ext(crash_data,
- short_name,
- content,
- (editable ? CD_FLAG_TXT + CD_FLAG_ISEDITABLE : CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE)
- );
- free(short_name);
- free(full_name);
- free(content);
- }
- return crash_data;
-}
-
-void log_map_crash_data(crash_data_t *crash_data, const char *pfx)
-{
- GHashTableIter iter;
- char *name;
- struct crash_item *value;
- g_hash_table_iter_init(&iter, crash_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- log("%s[%s]:'%s' 0x%x",
- pfx, name,
- value->content,
- value->flags
- );
- }
-}
diff -x '*.po' -d -urpN abrt.9/src/lib/create_crash_dump_dir.c abrt.a/src/lib/create_crash_dump_dir.c
--- abrt.9/src/lib/create_crash_dump_dir.c 1970-01-01 01:00:00.000000000 +0100
+++ abrt.a/src/lib/create_crash_dump_dir.c 2010-12-07 16:11:19.649344001 +0100
@@ -0,0 +1,51 @@
+/*
+ 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.
+*/
+
+#include "abrtlib.h"
+
+struct dump_dir *create_crash_dump_dir(crash_data_t *crash_data)
+{
+ char *path = xasprintf(LOCALSTATEDIR"/run/abrt/tmp-%lu-%lu", (long)getpid(), (long)time(NULL));
+ struct dump_dir *dd = dd_create(path, getuid());
+ free(path);
+ if (!dd)
+ return NULL;
+
+ GHashTableIter iter;
+ char *name;
+ struct crash_item *value;
+ g_hash_table_iter_init(&iter, crash_data);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+ if (name[0] == '.' || strchr(name, '/'))
+ {
+ error_msg("Crash data field name contains disallowed chars: '%s'", name);
+ goto next;
+ }
+
+//FIXME: what to do with CD_FLAG_BINs??
+ if (value->flags & CD_FLAG_BIN)
+ goto next;
+
+ dd_save_text(dd, name, value->content);
+ next: ;
+ }
+
+ return dd;
+}
diff -x '*.po' -d -urpN abrt.9/src/lib/create_crash_dump_dir.cpp abrt.a/src/lib/create_crash_dump_dir.cpp
--- abrt.9/src/lib/create_crash_dump_dir.cpp 2010-12-07 16:11:19.649344001 +0100
+++ abrt.a/src/lib/create_crash_dump_dir.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,51 +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.
-*/
-
-#include "abrtlib.h"
-
-struct dump_dir *create_crash_dump_dir(crash_data_t *crash_data)
-{
- char *path = xasprintf(LOCALSTATEDIR"/run/abrt/tmp-%lu-%lu", (long)getpid(), (long)time(NULL));
- struct dump_dir *dd = dd_create(path, getuid());
- free(path);
- if (!dd)
- return NULL;
-
- GHashTableIter iter;
- char *name;
- struct crash_item *value;
- g_hash_table_iter_init(&iter, crash_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- if (name[0] == '.' || strchr(name, '/'))
- {
- error_msg("Crash data field name contains disallowed chars: '%s'", name);
- goto next;
- }
-
-//FIXME: what to do with CD_FLAG_BINs??
- if (value->flags & CD_FLAG_BIN)
- goto next;
-
- dd_save_text(dd, name, value->content);
- next: ;
- }
-
- return dd;
-}
diff -x '*.po' -d -urpN abrt.9/src/lib/load_plugin_settings.c abrt.a/src/lib/load_plugin_settings.c
--- abrt.9/src/lib/load_plugin_settings.c 1970-01-01 01:00:00.000000000 +0100
+++ abrt.a/src/lib/load_plugin_settings.c 2010-12-07 16:30:38.847594192 +0100
@@ -0,0 +1,98 @@
+/*
+ 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.
+*/
+#include "abrtlib.h"
+
+/* Returns NULL if open failed.
+ * Returns empty hash if conf file is empty.
+ */
+bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue)
+{
+ FILE *fp = stdin;
+ if (strcmp(pPath, "-") != 0)
+ {
+ fp = fopen(pPath, "r");
+ if (!fp)
+ return false;
+ }
+
+ char *line;
+ while ((line = xmalloc_fgetline(fp)) != NULL)
+ {
+ unsigned ii;
+ bool is_value = false;
+ bool valid = false;
+ bool in_quote = false;
+ /* We are reusing line buffer to form temporary
+ * "key\0value\0..." in its beginning
+ */
+ char *key = line;
+ char *value = line;
+ char *cur = line;
+
+ for (ii = 0; line[ii] != '\0'; ii++)
+ {
+ if (line[ii] == '"')
+ {
+ in_quote = !in_quote;
+ }
+ if (isspace(line[ii]) && !in_quote)
+ {
+ continue;
+ }
+ if (line[ii] == '#' && !in_quote && cur == line)
+ {
+ break;
+ }
+ if (line[ii] == '=' && !in_quote)
+ {
+ is_value = true;
+ valid = true;
+ *cur++ = '\0'; /* terminate key */
+ value = cur; /* remember where value starts */
+ continue;
+ }
+ *cur++ = line[ii]; /* store next key or value char */
+ }
+ *cur++ = '\0'; /* terminate value */
+
+ /* Skip broken or empty lines. */
+ if (!valid)
+ goto free_line;
+
+ /* Skip lines with empty key. */
+ if (key[0] == '\0')
+ goto free_line;
+
+ if (skipKeysWithoutValue && value[0] == '\0')
+ goto free_line;
+
+ /* Skip lines with unclosed quotes. */
+ if (in_quote)
+ goto free_line;
+
+ g_hash_table_replace(settings, xstrdup(key), xstrdup(value));
+ free_line:
+ free(line);
+ }
+
+ if (fp != stdin)
+ fclose(fp);
+
+ return true;
+}
diff -x '*.po' -d -urpN abrt.9/src/lib/load_plugin_settings.cpp abrt.a/src/lib/load_plugin_settings.cpp
--- abrt.9/src/lib/load_plugin_settings.cpp 2010-12-07 16:30:38.847594192 +0100
+++ abrt.a/src/lib/load_plugin_settings.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,98 +0,0 @@
-/*
- 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.
-*/
-#include "abrtlib.h"
-
-/* Returns NULL if open failed.
- * Returns empty hash if conf file is empty.
- */
-bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue)
-{
- FILE *fp = stdin;
- if (strcmp(pPath, "-") != 0)
- {
- fp = fopen(pPath, "r");
- if (!fp)
- return false;
- }
-
- char *line;
- while ((line = xmalloc_fgetline(fp)) != NULL)
- {
- unsigned ii;
- bool is_value = false;
- bool valid = false;
- bool in_quote = false;
- /* We are reusing line buffer to form temporary
- * "key\0value\0..." in its beginning
- */
- char *key = line;
- char *value = line;
- char *cur = line;
-
- for (ii = 0; line[ii] != '\0'; ii++)
- {
- if (line[ii] == '"')
- {
- in_quote = !in_quote;
- }
- if (isspace(line[ii]) && !in_quote)
- {
- continue;
- }
- if (line[ii] == '#' && !in_quote && cur == line)
- {
- break;
- }
- if (line[ii] == '=' && !in_quote)
- {
- is_value = true;
- valid = true;
- *cur++ = '\0'; /* terminate key */
- value = cur; /* remember where value starts */
- continue;
- }
- *cur++ = line[ii]; /* store next key or value char */
- }
- *cur++ = '\0'; /* terminate value */
-
- /* Skip broken or empty lines. */
- if (!valid)
- goto free_line;
-
- /* Skip lines with empty key. */
- if (key[0] == '\0')
- goto free_line;
-
- if (skipKeysWithoutValue && value[0] == '\0')
- goto free_line;
-
- /* Skip lines with unclosed quotes. */
- if (in_quote)
- goto free_line;
-
- g_hash_table_replace(settings, xstrdup(key), xstrdup(value));
- free_line:
- free(line);
- }
-
- if (fp != stdin)
- fclose(fp);
-
- return true;
-}
diff -x '*.po' -d -urpN abrt.9/src/lib/make_descr.c abrt.a/src/lib/make_descr.c
--- abrt.9/src/lib/make_descr.c 1970-01-01 01:00:00.000000000 +0100
+++ abrt.a/src/lib/make_descr.c 2010-12-07 16:12:27.745594631 +0100
@@ -0,0 +1,284 @@
+/*
+ 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.
+*/
+#include "abrtlib.h"
+#include "abrt_crash_dump.h"
+
+// caller is responsible for freeing **dsc
+static void add_content(bool *was_multiline, char **dsc, const char *header, const char *content)
+{
+ struct strbuf *buf_description = strbuf_new();
+ if (*was_multiline)
+ strbuf_append_char(buf_description, '\n');
+
+ while (content[0] == '\n')
+ content++;
+
+ if (strchr(content, '\n') == NULL)
+ {
+ if (skip_whitespace(content)[0] == '\0')
+ {
+ /* empty, dont report at all */
+ *dsc = strbuf_free_nobuf(buf_description);
+ return;
+ }
+ /* one string value, like OS release */
+ strbuf_append_strf(buf_description, "%s: %s\n", header, content);
+ *was_multiline = 0;
+ }
+ else
+ {
+ /* multi-string value, like backtrace */
+ if (!*was_multiline && (buf_description->len != 0)) /* if wasn't yet separated */
+ strbuf_append_char(buf_description, '\n');
+
+ strbuf_append_strf(buf_description, "%s\n-----\n%s", header, content);
+ if (content[strlen(content) - 1] != '\n')
+ strbuf_append_char(buf_description, '\n');
+
+ *was_multiline = 1;
+ }
+
+ *dsc = strbuf_free_nobuf(buf_description);
+}
+
+/* Items we don't want to include */
+static const char *const blacklisted_items[] = {
+ FILENAME_ANALYZER ,
+ FILENAME_COREDUMP ,
+ FILENAME_DESCRIPTION, /* package description - basically useless */
+ FILENAME_HOSTNAME ,
+ FILENAME_DUPHASH ,
+ FILENAME_UUID ,
+ FILENAME_INFORMALL,
+ CD_DUMPDIR ,
+ FILENAME_COUNT ,
+ FILENAME_MESSAGE ,
+ NULL
+};
+
+char* make_description_mailx(crash_data_t *crash_data)
+{
+ struct strbuf *buf_dsc = strbuf_new();
+ struct strbuf *buf_additional_files = strbuf_new();
+ struct strbuf *buf_duphash_file = strbuf_new();
+ struct strbuf *buf_common_files = strbuf_new();
+
+ GHashTableIter iter;
+ char *name;
+ struct crash_item *value;
+ g_hash_table_iter_init(&iter, crash_data);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+ if (value->flags & CD_FLAG_TXT)
+ {
+ if ((strcmp(name, FILENAME_DUPHASH) != 0)
+ && (strcmp(name, FILENAME_ARCHITECTURE) != 0)
+ && (strcmp(name, FILENAME_KERNEL) != 0)
+ && (strcmp(name, FILENAME_PACKAGE) != 0)
+ ) {
+ strbuf_append_strf(buf_additional_files, "%s\n-----\n%s\n\n", name, value->content);
+ }
+ else if (strcmp(name, FILENAME_DUPHASH) == 0)
+ strbuf_append_strf(buf_duphash_file, "%s\n-----\n%s\n\n", name, value->content);
+ else
+ strbuf_append_strf(buf_common_files, "%s\n-----\n%s\n\n", name, value->content);
+ }
+ }
+
+ char *common_files = strbuf_free_nobuf(buf_common_files);
+ char *duphash_file = strbuf_free_nobuf(buf_duphash_file);
+ char *additional_files = strbuf_free_nobuf(buf_additional_files);
+
+ strbuf_append_strf(buf_dsc, "Duplicate check\n=====\n%s\n\n", duphash_file);
+ strbuf_append_strf(buf_dsc, "Common information\n=====\n%s\n\n", common_files);
+ strbuf_append_strf(buf_dsc, "Additional information\n=====\n%s\n", additional_files);
+
+ free(common_files);
+ free(duphash_file);
+ free(additional_files);
+
+ return strbuf_free_nobuf(buf_dsc);
+}
+
+char* make_description_bz(crash_data_t *crash_data)
+{
+ struct strbuf *buf_dsc = strbuf_new();
+ struct strbuf *buf_long_dsc = strbuf_new();
+
+ GHashTableIter iter;
+ char *name;
+ struct crash_item *value;
+ g_hash_table_iter_init(&iter, crash_data);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+ unsigned flags = value->flags;
+ const char *content = value->content;
+ if (flags & CD_FLAG_TXT)
+ {
+ /* Skip items we are not interested in */
+ const char *const *bl = blacklisted_items;
+ while (*bl)
+ {
+ if (strcmp(name, *bl) == 0)
+ break;
+ bl++;
+ }
+ if (*bl)
+ continue; /* blacklisted */
+ if (strcmp(content, "1.\n2.\n3.\n") == 0)
+ continue; /* user did not change default "How to reproduce" */
+
+ if (strlen(content) <= CD_TEXT_ATT_SIZE)
+ {
+ /* Add small (less than few kb) text items inline */
+ bool was_multiline = 0;
+ char *tmp = NULL;
+ add_content(&was_multiline,
+ &tmp,
+ /* "reproduce: blah" looks ugly, fixing: */
+ (strcmp(name, FILENAME_REPRODUCE) == 0) ? "How to reproduce" : name,
+ content
+ );
+
+ if (was_multiline)
+ {
+ /* Not one-liner */
+ if (buf_long_dsc->len != 0)
+ strbuf_append_char(buf_long_dsc, '\n');
+
+ strbuf_append_str(buf_long_dsc, tmp);
+ }
+ else
+ strbuf_append_str(buf_dsc, tmp);
+
+ free(tmp);
+ } else {
+ bool was_multiline = 0;
+ char *dsc = NULL;
+ add_content(&was_multiline, &dsc, "Attached file", name);
+ strbuf_append_str(buf_dsc, dsc);
+ free(dsc);
+ }
+ }
+ }
+
+ /* One-liners go first, then multi-line items */
+ if (buf_dsc->len != 0 && buf_long_dsc->len != 0)
+ strbuf_append_char(buf_dsc, '\n');
+
+
+ char *long_dsc = strbuf_free_nobuf(buf_long_dsc);
+ strbuf_append_str(buf_dsc, long_dsc);
+ free(long_dsc);
+
+ return strbuf_free_nobuf(buf_dsc);
+}
+
+char* make_description_logger(crash_data_t *crash_data)
+{
+ struct strbuf *buf_dsc = strbuf_new();
+ struct strbuf *buf_long_dsc = strbuf_new();
+
+ GHashTableIter iter;
+ char *name;
+ struct crash_item *value;
+ g_hash_table_iter_init(&iter, crash_data);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
+ {
+ const char *content = value->content;
+ if (value->flags & (CD_FLAG_TXT|CD_FLAG_BIN))
+ {
+ /* Skip items we are not interested in */
+ const char *const *bl = blacklisted_items;
+ while (*bl)
+ {
+ if (name == *bl)
+ break;
+ bl++;
+ }
+ if (*bl)
+ continue; /* blacklisted */
+ if (strcmp(content, "1.\n2.\n3.\n") == 0)
+ continue; /* user did not change default "How to reproduce" */
+
+ bool was_multiline = 0;
+ char *tmp = NULL;
+ add_content(&was_multiline, &tmp, name, content);
+
+ if (was_multiline)
+ {
+ if (buf_long_dsc->len != 0)
+ strbuf_append_char(buf_long_dsc, '\n');
+
+ strbuf_append_str(buf_long_dsc, tmp);
+ }
+ else
+ strbuf_append_str(buf_dsc, tmp);
+ }
+ }
+
+ if (buf_dsc->len != 0 && buf_long_dsc->len != 0)
+ strbuf_append_char(buf_dsc, '\n');
+
+ char *long_dsc = strbuf_free_nobuf(buf_long_dsc);
+ strbuf_append_str(buf_dsc, long_dsc);
+ free(long_dsc);
+
+ return strbuf_free_nobuf(buf_dsc);
+}
+
+char* make_description_reproduce_comment(crash_data_t *crash_data)
+{
+ char *repro = NULL;
+ char *comment = NULL;
+ struct crash_item *value;
+
+ value = get_crash_data_item_or_NULL(crash_data, FILENAME_REPRODUCE);
+ if (value)
+ {
+ if (value->content[0]
+ && strcmp(value->content, "1.\n2.\n3.\n") != 0
+ ) {
+ repro = xasprintf("\n\nHow to reproduce\n-----\n%s", value->content);
+ }
+ }
+
+ value = get_crash_data_item_or_NULL(crash_data, FILENAME_COMMENT);
+ if (value)
+ {
+ if (value->content[0])
+ comment = xasprintf("\n\nComment\n-----\n%s", value->content);
+ }
+
+ if (!repro && !comment)
+ return NULL;
+
+ struct strbuf *buf_dsc = strbuf_new();
+
+ if (repro)
+ strbuf_append_str(buf_dsc, repro);
+
+ if (comment)
+ strbuf_append_str(buf_dsc, comment);
+
+ free(repro);
+ free(comment);
+
+ return strbuf_free_nobuf(buf_dsc);
+}
diff -x '*.po' -d -urpN abrt.9/src/lib/make_descr.cpp abrt.a/src/lib/make_descr.cpp
--- abrt.9/src/lib/make_descr.cpp 2010-12-07 16:12:27.745594631 +0100
+++ abrt.a/src/lib/make_descr.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,284 +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.
-*/
-#include "abrtlib.h"
-#include "abrt_crash_dump.h"
-
-// caller is responsible for freeing **dsc
-static void add_content(bool *was_multiline, char **dsc, const char *header, const char *content)
-{
- struct strbuf *buf_description = strbuf_new();
- if (*was_multiline)
- strbuf_append_char(buf_description, '\n');
-
- while (content[0] == '\n')
- content++;
-
- if (strchr(content, '\n') == NULL)
- {
- if (skip_whitespace(content)[0] == '\0')
- {
- /* empty, dont report at all */
- *dsc = strbuf_free_nobuf(buf_description);
- return;
- }
- /* one string value, like OS release */
- strbuf_append_strf(buf_description, "%s: %s\n", header, content);
- *was_multiline = 0;
- }
- else
- {
- /* multi-string value, like backtrace */
- if (!*was_multiline && (buf_description->len != 0)) /* if wasn't yet separated */
- strbuf_append_char(buf_description, '\n');
-
- strbuf_append_strf(buf_description, "%s\n-----\n%s", header, content);
- if (content[strlen(content) - 1] != '\n')
- strbuf_append_char(buf_description, '\n');
-
- *was_multiline = 1;
- }
-
- *dsc = strbuf_free_nobuf(buf_description);
-}
-
-/* Items we don't want to include */
-static const char *const blacklisted_items[] = {
- FILENAME_ANALYZER ,
- FILENAME_COREDUMP ,
- FILENAME_DESCRIPTION, /* package description - basically useless */
- FILENAME_HOSTNAME ,
- FILENAME_DUPHASH ,
- FILENAME_UUID ,
- FILENAME_INFORMALL,
- CD_DUMPDIR ,
- FILENAME_COUNT ,
- FILENAME_MESSAGE ,
- NULL
-};
-
-char* make_description_mailx(crash_data_t *crash_data)
-{
- struct strbuf *buf_dsc = strbuf_new();
- struct strbuf *buf_additional_files = strbuf_new();
- struct strbuf *buf_duphash_file = strbuf_new();
- struct strbuf *buf_common_files = strbuf_new();
-
- GHashTableIter iter;
- char *name;
- struct crash_item *value;
- g_hash_table_iter_init(&iter, crash_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- if (value->flags & CD_FLAG_TXT)
- {
- if ((strcmp(name, FILENAME_DUPHASH) != 0)
- && (strcmp(name, FILENAME_ARCHITECTURE) != 0)
- && (strcmp(name, FILENAME_KERNEL) != 0)
- && (strcmp(name, FILENAME_PACKAGE) != 0)
- ) {
- strbuf_append_strf(buf_additional_files, "%s\n-----\n%s\n\n", name, value->content);
- }
- else if (strcmp(name, FILENAME_DUPHASH) == 0)
- strbuf_append_strf(buf_duphash_file, "%s\n-----\n%s\n\n", name, value->content);
- else
- strbuf_append_strf(buf_common_files, "%s\n-----\n%s\n\n", name, value->content);
- }
- }
-
- char *common_files = strbuf_free_nobuf(buf_common_files);
- char *duphash_file = strbuf_free_nobuf(buf_duphash_file);
- char *additional_files = strbuf_free_nobuf(buf_additional_files);
-
- strbuf_append_strf(buf_dsc, "Duplicate check\n=====\n%s\n\n", duphash_file);
- strbuf_append_strf(buf_dsc, "Common information\n=====\n%s\n\n", common_files);
- strbuf_append_strf(buf_dsc, "Additional information\n=====\n%s\n", additional_files);
-
- free(common_files);
- free(duphash_file);
- free(additional_files);
-
- return strbuf_free_nobuf(buf_dsc);
-}
-
-char* make_description_bz(crash_data_t *crash_data)
-{
- struct strbuf *buf_dsc = strbuf_new();
- struct strbuf *buf_long_dsc = strbuf_new();
-
- GHashTableIter iter;
- char *name;
- struct crash_item *value;
- g_hash_table_iter_init(&iter, crash_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- unsigned flags = value->flags;
- const char *content = value->content;
- if (flags & CD_FLAG_TXT)
- {
- /* Skip items we are not interested in */
- const char *const *bl = blacklisted_items;
- while (*bl)
- {
- if (strcmp(name, *bl) == 0)
- break;
- bl++;
- }
- if (*bl)
- continue; /* blacklisted */
- if (strcmp(content, "1.\n2.\n3.\n") == 0)
- continue; /* user did not change default "How to reproduce" */
-
- if (strlen(content) <= CD_TEXT_ATT_SIZE)
- {
- /* Add small (less than few kb) text items inline */
- bool was_multiline = 0;
- char *tmp = NULL;
- add_content(&was_multiline,
- &tmp,
- /* "reproduce: blah" looks ugly, fixing: */
- (strcmp(name, FILENAME_REPRODUCE) == 0) ? "How to reproduce" : name,
- content
- );
-
- if (was_multiline)
- {
- /* Not one-liner */
- if (buf_long_dsc->len != 0)
- strbuf_append_char(buf_long_dsc, '\n');
-
- strbuf_append_str(buf_long_dsc, tmp);
- }
- else
- strbuf_append_str(buf_dsc, tmp);
-
- free(tmp);
- } else {
- bool was_multiline = 0;
- char *dsc = NULL;
- add_content(&was_multiline, &dsc, "Attached file", name);
- strbuf_append_str(buf_dsc, dsc);
- free(dsc);
- }
- }
- }
-
- /* One-liners go first, then multi-line items */
- if (buf_dsc->len != 0 && buf_long_dsc->len != 0)
- strbuf_append_char(buf_dsc, '\n');
-
-
- char *long_dsc = strbuf_free_nobuf(buf_long_dsc);
- strbuf_append_str(buf_dsc, long_dsc);
- free(long_dsc);
-
- return strbuf_free_nobuf(buf_dsc);
-}
-
-char* make_description_logger(crash_data_t *crash_data)
-{
- struct strbuf *buf_dsc = strbuf_new();
- struct strbuf *buf_long_dsc = strbuf_new();
-
- GHashTableIter iter;
- char *name;
- struct crash_item *value;
- g_hash_table_iter_init(&iter, crash_data);
- while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
- {
- const char *content = value->content;
- if (value->flags & (CD_FLAG_TXT|CD_FLAG_BIN))
- {
- /* Skip items we are not interested in */
- const char *const *bl = blacklisted_items;
- while (*bl)
- {
- if (name == *bl)
- break;
- bl++;
- }
- if (*bl)
- continue; /* blacklisted */
- if (strcmp(content, "1.\n2.\n3.\n") == 0)
- continue; /* user did not change default "How to reproduce" */
-
- bool was_multiline = 0;
- char *tmp = NULL;
- add_content(&was_multiline, &tmp, name, content);
-
- if (was_multiline)
- {
- if (buf_long_dsc->len != 0)
- strbuf_append_char(buf_long_dsc, '\n');
-
- strbuf_append_str(buf_long_dsc, tmp);
- }
- else
- strbuf_append_str(buf_dsc, tmp);
- }
- }
-
- if (buf_dsc->len != 0 && buf_long_dsc->len != 0)
- strbuf_append_char(buf_dsc, '\n');
-
- char *long_dsc = strbuf_free_nobuf(buf_long_dsc);
- strbuf_append_str(buf_dsc, long_dsc);
- free(long_dsc);
-
- return strbuf_free_nobuf(buf_dsc);
-}
-
-char* make_description_reproduce_comment(crash_data_t *crash_data)
-{
- char *repro = NULL;
- char *comment = NULL;
- struct crash_item *value;
-
- value = get_crash_data_item_or_NULL(crash_data, FILENAME_REPRODUCE);
- if (value)
- {
- if (value->content[0]
- && strcmp(value->content, "1.\n2.\n3.\n") != 0
- ) {
- repro = xasprintf("\n\nHow to reproduce\n-----\n%s", value->content);
- }
- }
-
- value = get_crash_data_item_or_NULL(crash_data, FILENAME_COMMENT);
- if (value)
- {
- if (value->content[0])
- comment = xasprintf("\n\nComment\n-----\n%s", value->content);
- }
-
- if (!repro && !comment)
- return NULL;
-
- struct strbuf *buf_dsc = strbuf_new();
-
- if (repro)
- strbuf_append_str(buf_dsc, repro);
-
- if (comment)
- strbuf_append_str(buf_dsc, comment);
-
- free(repro);
- free(comment);
-
- return strbuf_free_nobuf(buf_dsc);
-}
diff -x '*.po' -d -urpN abrt.9/src/lib/parse_release.c abrt.a/src/lib/parse_release.c
--- abrt.9/src/lib/parse_release.c 1970-01-01 01:00:00.000000000 +0100
+++ abrt.a/src/lib/parse_release.c 2010-11-10 00:12:48.000000000 +0100
@@ -0,0 +1,59 @@
+/*
+ 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.
+*/
+#include "abrtlib.h"
+
+// caller is reposible for freeing *product* and *version*
+void parse_release(const char *release, char** product, char** version)
+{
+ if (strstr(release, "Rawhide"))
+ {
+ *product = xstrdup("Fedora");
+ *version = xstrdup("rawhide");
+ VERB3 log("%s: version:'%s' product:'%s'", __func__, *version, *product);
+ return;
+ }
+
+ struct strbuf *buf_product = strbuf_new();
+ if (strstr(release, "Fedora"))
+ strbuf_append_str(buf_product, "Fedora");
+ else if (strstr(release, "Red Hat Enterprise Linux"))
+ strbuf_append_str(buf_product, "Red Hat Enterprise Linux ");
+
+ const char *r = strstr(release, "release");
+ const char *space = r ? strchr(r, ' ') : NULL;
+
+ struct strbuf *buf_version = strbuf_new();
+ if (space++)
+ {
+ while (*space != '\0' && *space != ' ')
+ {
+ /* Eat string like "5.2" */
+ strbuf_append_char(buf_version, *space);
+ if ((strcmp(buf_product->buf, "Red Hat Enterprise Linux ") == 0))
+ strbuf_append_char(buf_product, *space);
+
+ space++;
+ }
+ }
+
+ *version = strbuf_free_nobuf(buf_version);
+ *product = strbuf_free_nobuf(buf_product);
+
+ VERB3 log("%s: version:'%s' product:'%s'", __func__, *version, *product);
+}
diff -x '*.po' -d -urpN abrt.9/src/lib/parse_release.cpp abrt.a/src/lib/parse_release.cpp
--- abrt.9/src/lib/parse_release.cpp 2010-11-10 00:12:48.000000000 +0100
+++ abrt.a/src/lib/parse_release.cpp 1970-01-01 01:00:00.000000000 +0100
@@ -1,59 +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.
-*/
-#include "abrtlib.h"
-
-// caller is reposible for freeing *product* and *version*
-void parse_release(const char *release, char** product, char** version)
-{
- if (strstr(release, "Rawhide"))
- {
- *product = xstrdup("Fedora");
- *version = xstrdup("rawhide");
- VERB3 log("%s: version:'%s' product:'%s'", __func__, *version, *product);
- return;
- }
-
- struct strbuf *buf_product = strbuf_new();
- if (strstr(release, "Fedora"))
- strbuf_append_str(buf_product, "Fedora");
- else if (strstr(release, "Red Hat Enterprise Linux"))
- strbuf_append_str(buf_product, "Red Hat Enterprise Linux ");
-
- const char *r = strstr(release, "release");
- const char *space = r ? strchr(r, ' ') : NULL;
-
- struct strbuf *buf_version = strbuf_new();
- if (space++)
- {
- while (*space != '\0' && *space != ' ')
- {
- /* Eat string like "5.2" */
- strbuf_append_char(buf_version, *space);
- if ((strcmp(buf_product->buf, "Red Hat Enterprise Linux ") == 0))
- strbuf_append_char(buf_product, *space);
-
- space++;
- }
- }
-
- *version = strbuf_free_nobuf(buf_version);
- *product = strbuf_free_nobuf(buf_product);
-
- VERB3 log("%s: version:'%s' product:'%s'", __func__, *version, *product);
-}