I've been working on a test program in C (shown below) that allows me to use the headerUnload function and dump that to a file. After I open a given rpm file with Fopen and attempt to read its header I hit an error. The line, 'Header h = headerRead(fd, HEADER_MAGIC_YES)', should return a Header for the given file or return null if it encounters an error, per the documentation. It returns NULL regardless of whether I'm checking the magic bytes or not, and no error message is printed. This happens on rpm files I know to be good. Now for the strange part. If I use a header file created by the python bindings for reading and unloading a header and supply that as the argument to this program everything works. Though it's important to note that I have to disable the checking of the magic bytes. I'm hoping that someone can show me what I'm doing wrong or what I'm missing in this seemingly simple task. Thanks in advance for any light you can shed on this, and let me know if I can clarify anything with more detail. #include <rpm/rpmlib.h> #include <rpm/header.h> int main(int argc, char ** argv) { FD_t fd = Fopen(argv[1], "r.ufdio"); if (fd == NULL) { printf("error opening file\n"); exit(1); } Header h = headerRead(fd, HEADER_MAGIC_YES); if (h == NULL) { printf("headerRead error: %s.\n", Fstrerror(fd)); exit(1); } Fclose(fd); unsigned int size = headerSizeof(h, HEADER_MAGIC_YES); printf("headerSizeof: %i\n", size); char * hbuf = headerUnload(h); FILE * out = fopen("out.hdr", "w+"); if(out == NULL) { printf("error opening out file\n"); exit(1); } fwrite(hbuf, sizeof(char), size, out); fclose(out); h = headerFree(h); free(hbuf); return 0; } -- Greg Kuchyt _______________________________________________ Rpm-list mailing list Rpm-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/rpm-list