blob: a0d220023fce49e72a650ac77df16f78aa114bce (
plain)
1 /* Find how deeply inside an .RPM the real data is */
2 /* kept, and report the offset in bytes */
3
4 /* Wouldn't it be a lot more sane if we could just untar these things? */
5
6 #include <stdlib.h>
7
8 /* These offsets keep getting bigger, so we're going to just bite a 2MB */
9 /* chunk of RAM right away so that we have enough. Yeah, horrible */
10 /* quick and dirty implementation, but hey -- it gets the job done. */
11
12 #define RPMBUFSIZ 2097152
13 const char magic[][3]={"\x1F\x8B\x08"/*gzip*/,"BZh"/*bzip2*/};
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 == magic[0][0] && p[1] == magic[0][1] && p[2] == magic[0][2]) ||
20 (*p == magic[1][0] && p[1] == magic[1][1] && p[2] == magic[1][2]))
21 printf("%d\n",p - buff),
22 exit(0);
23 exit(1);
24 }
|