diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2000-03-31 14:41:03 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2000-03-31 14:41:03 +0000 |
commit | 0e00ea5201dc638344db1c2200070cda150a4d40 (patch) | |
tree | 50ddafab262a7658f970e0daf9d26bfc4697483a /hdlist2groups.cc | |
parent | 4a4469e87a3a3098cb4d9f54debac141dac48aff (diff) | |
download | rpmtools-0e00ea5201dc638344db1c2200070cda150a4d40.tar rpmtools-0e00ea5201dc638344db1c2200070cda150a4d40.tar.gz rpmtools-0e00ea5201dc638344db1c2200070cda150a4d40.tar.bz2 rpmtools-0e00ea5201dc638344db1c2200070cda150a4d40.tar.xz rpmtools-0e00ea5201dc638344db1c2200070cda150a4d40.zip |
no_comment
Diffstat (limited to 'hdlist2groups.cc')
-rw-r--r-- | hdlist2groups.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/hdlist2groups.cc b/hdlist2groups.cc new file mode 100644 index 0000000..55e53ac --- /dev/null +++ b/hdlist2groups.cc @@ -0,0 +1,44 @@ +#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: hdlist2groups <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 << "hdlist2groups: cannot open file " << argv[i] << "\n"; + else { + Header header; + while ((header=headerRead(fd, HEADER_MAGIC_YES))) { + printf("%s:%s\n", + get_name(header, RPMTAG_NAME), + get_name(header, RPMTAG_GROUP)); + } + } + fdClose(fd); + } +} |