home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / misc / src / rpm / tools / dump.c next >
C/C++ Source or Header  |  1997-09-17  |  611b  |  38 lines

  1. #include <errno.h>
  2. #include <fcntl.h>
  3. #include <stdio.h>
  4. #include <unistd.h>
  5. #include <string.h>
  6.  
  7. #include "header.h"
  8. #include "rpmlib.h"
  9.  
  10. void main(int argc, char ** argv)
  11. {
  12.     Header h;
  13.     int fd;
  14.  
  15.     if (argc == 1) {
  16.     fd = 0;
  17.     } else {
  18.     fd = open(argv[1], O_RDONLY, 0644);
  19.     }
  20.  
  21.     if (fd < 0) {
  22.     fprintf(stderr, "cannot open %s: %s\n", argv[1], strerror(errno));
  23.     exit(1);
  24.     }
  25.  
  26.     h = headerRead(fd, HEADER_MAGIC_YES);
  27.     if (!h) {
  28.     fprintf(stderr, "headerRead error: %s\n", strerror(errno));
  29.     exit(1);
  30.     }
  31.     close(fd);
  32.   
  33.     headerDump(h, stdout, 1, rpmTagTable);
  34.     headerFree(h);
  35. }
  36.  
  37.   
  38.