home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / linux / utilities-general / rpmoffset.c < prev    next >
C/C++ Source or Header  |  2001-04-02  |  738b  |  24 lines

  1.  
  2. /* Find how deeply inside an .RPM the real data is */
  3. /* kept, and report the offset in bytes */
  4.  
  5. /* Wouldn't it be a lot more sane if we could just untar these things? */
  6.  
  7. #include <stdlib.h>
  8.  
  9. /* These offsets keep getting bigger, so we're going to just bite a 2MB */
  10. /* chunk of RAM right away so that we have enough.  Yeah, horrible */
  11. /* quick and dirty implementation, but hey -- it gets the job done. */
  12.  
  13. #define RPMBUFSIZ 2097152
  14.  
  15. main()
  16. {
  17.         char *buff = malloc(RPMBUFSIZ),*eb,*p;
  18.         for (p = buff, eb = buff + read(0,buff,RPMBUFSIZ); p < eb; p++)
  19.                 if (*p == '\037' && p[1] == '\213' && p[2] == '\010')
  20.                         printf("%d\n",p - buff),
  21.                         exit(0);
  22.         exit(1);
  23. }
  24.