From cba369350c57dc763814376ac4cba8a011962fc7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 8 Dec 2010 15:05:56 +0100 Subject: Rename some .cpp files to .c Apart from src/lib/Makefile.am changes, this is a pure rename, no textual changes to the files. Before patch set: $ size libabrt.so.0.0.1; ldd libabrt.so.0.0.1 text data bss dec hex filename 58031 2312 32 60375 ebd7 libabrt.so.0.0.1 linux-vdso.so.1 => (0x00007fffd46dc000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f373eabc000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f373e7b6000) libm.so.6 => /lib64/libm.so.6 (0x00007f373e531000) libc.so.6 => /lib64/libc.so.6 (0x00007f373e1b2000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f373df9c000) /lib64/ld-linux-x86-64.so.2 (0x00007f373efde000) After patch set: $ size libabrt.so.0.0.1; ldd libabrt.so.0.0.1 text data bss dec hex filename 51777 2064 32 53873 d271 libabrt.so.0.0.1 linux-vdso.so.1 => (0x00007fff48703000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007fd63aa45000) libc.so.6 => /lib64/libc.so.6 (0x00007fd63a6c6000) /lib64/ld-linux-x86-64.so.2 (0x00007fd63af66000) Signed-off-by: Denys Vlasenko --- src/lib/parse_release.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/lib/parse_release.c (limited to 'src/lib/parse_release.c') diff --git a/src/lib/parse_release.c b/src/lib/parse_release.c new file mode 100644 index 00000000..f9057bfe --- /dev/null +++ b/src/lib/parse_release.c @@ -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); +} -- cgit From 7f5cbf38caa3c6fdd0afe3a4cb7a9bd3b3010596 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 25 Jan 2011 21:17:49 +0100 Subject: split parse_release() into Bz and RHTS versions Signed-off-by: Denys Vlasenko --- src/lib/parse_release.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/lib/parse_release.c') diff --git a/src/lib/parse_release.c b/src/lib/parse_release.c index f9057bfe..b24f928c 100644 --- a/src/lib/parse_release.c +++ b/src/lib/parse_release.c @@ -19,7 +19,7 @@ #include "abrtlib.h" // caller is reposible for freeing *product* and *version* -void parse_release(const char *release, char** product, char** version) +static void parse_release(const char *release, char** product, char** version, bool append_rhel_version) { if (strstr(release, "Rawhide")) { @@ -33,21 +33,31 @@ void parse_release(const char *release, char** product, char** version) 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 "); + strbuf_append_str(buf_product, "Red Hat Enterprise Linux"); + else + { + /* TODO: add logic for parsing other distros' names here */ + strbuf_append_str(buf_product, release); + } const char *r = strstr(release, "release"); const char *space = r ? strchr(r, ' ') : NULL; struct strbuf *buf_version = strbuf_new(); - if (space++) + if (space) { + 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)) + if (append_rhel_version + && strcmp(buf_product->buf, "Red Hat Enterprise Linux") == 0 + ) { + strbuf_append_char(buf_product, ' '); strbuf_append_char(buf_product, *space); - + } + append_rhel_version = false; space++; } } @@ -57,3 +67,15 @@ void parse_release(const char *release, char** product, char** version) VERB3 log("%s: version:'%s' product:'%s'", __func__, *version, *product); } + +void parse_release_for_bz(const char *release, char** product, char** version) +{ + /* Fedora/RH bugzilla uses "Red Hat Enterprise Linux N" product RHEL */ + parse_release(release, product, version, /*append_rhel_version:*/ true); +} + +void parse_release_for_rhts(const char *release, char** product, char** version) +{ + /* RHTS uses "Red Hat Enterprise Linux" product for RHEL */ + parse_release(release, product, version, /*append_rhel_version:*/ false); +} -- cgit