aboutsummaryrefslogtreecommitdiffstats
path: root/hdlist2names.cc
diff options
context:
space:
mode:
authorChmouel Boudjnah <chmouel@mandriva.org>2000-02-17 17:58:25 +0000
committerChmouel Boudjnah <chmouel@mandriva.org>2000-02-17 17:58:25 +0000
commitec103b683b1679b09e1d1a54b14a4ba178d67a37 (patch)
treebaeb8862d2fbee36aa6c58c282a3383c9aeb7c4c /hdlist2names.cc
parent30066bc80a46d6b873549c8d6b31e426195ecfbe (diff)
downloadrpmtools-ec103b683b1679b09e1d1a54b14a4ba178d67a37.tar
rpmtools-ec103b683b1679b09e1d1a54b14a4ba178d67a37.tar.gz
rpmtools-ec103b683b1679b09e1d1a54b14a4ba178d67a37.tar.bz2
rpmtools-ec103b683b1679b09e1d1a54b14a4ba178d67a37.tar.xz
rpmtools-ec103b683b1679b09e1d1a54b14a4ba178d67a37.zip
Initial revisioncookertopic/MandrakeSoft
Diffstat (limited to 'hdlist2names.cc')
-rw-r--r--hdlist2names.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/hdlist2names.cc b/hdlist2names.cc
new file mode 100644
index 0000000..cdb0c32
--- /dev/null
+++ b/hdlist2names.cc
@@ -0,0 +1,46 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <rpm/rpmlib.h>
+#include <rpm/header.h>
+#include <iostream>
+
+
+char *get_name(Header header, int_32 tag) {
+ int_32 type, count;
+ char *name;
+
+ headerGetEntry(header, tag, &type, (void **) &name, &count);
+ return name;
+}
+
+int get_int(Header header, int_32 tag) {
+ int_32 type, count;
+ int *i;
+
+ headerGetEntry(header, tag, &type, (void **) &i, &count);
+ return *i;
+}
+
+int main(int argc, char **argv)
+{
+ if (argc <= 1) {
+ cerr << "usage: hdlist2names <hdlist> [<hdlists...>]\n";
+ exit(1);
+ }
+ for (int i = 1; i < argc; i++) {
+ FD_t fd = strcmp(argv[i], "-") == 0 ? fdDup(STDIN_FILENO) : fdOpen(argv[i], O_RDONLY, 0);
+ if (fdFileno(fd) < 0) cerr << "rpmpackdeps: cannot open file " << argv[i] << "\n";
+ else {
+ Header header;
+ while ((header=headerRead(fd, HEADER_MAGIC_YES))) {
+ printf("%s-%s-%s.%s.rpm\n",
+ get_name(header, RPMTAG_NAME),
+ get_name(header, RPMTAG_VERSION),
+ get_name(header, RPMTAG_RELEASE),
+ get_name(header, RPMTAG_ARCH));
+ }
+ }
+ fdClose(fd);
+ }
+}