summaryrefslogtreecommitdiffstats
path: root/lib/Utils/abrt_packages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Utils/abrt_packages.cpp')
-rw-r--r--lib/Utils/abrt_packages.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Utils/abrt_packages.cpp b/lib/Utils/abrt_packages.cpp
new file mode 100644
index 00000000..37a86eea
--- /dev/null
+++ b/lib/Utils/abrt_packages.cpp
@@ -0,0 +1,26 @@
+#include "abrtlib.h"
+
+
+/* cuts the name from the NVR format: foo-1.2.3-1.el6
+ returns a newly allocated string
+*/
+char* get_package_name_from_NVR_or_NULL(const char* packageNVR)
+{
+ char* package_name = NULL;
+ if(packageNVR != NULL)
+ {
+ VERB1 log("packageNVR %s", packageNVR);
+ package_name = xstrdup(packageNVR);
+ char *pos = strrchr(package_name, '-');
+ if(pos != NULL)
+ {
+ *pos = 0;
+ pos = strrchr(package_name, '-');
+ if(pos != NULL)
+ {
+ *pos = 0;
+ }
+ }
+ }
+ return package_name;
+}