[prev in list] [next in list] [prev in thread] [next in thread]
List: rpm-devel
Subject: Re: rpm API available ?
From: Jeff Johnson <n3npq () mac ! com>
Date: 2009-04-27 9:54:23
Message-ID: B0114ECD-FB10-4216-BA9E-83274B4F630D () mac ! com
[Download RAW message or body]
On Apr 27, 2009, at 5:25 AM, Sven Luther wrote:
> On Wed, Apr 15, 2009 at 03:13:17PM -0400, Jeff Johnson wrote:
>>>> msg = NULL;
>>>> rc = rpmpkgRead(item, fd, &sigh, &msg);
>>>> switch (rc) {
>>>> default:
>>>> rpmlog(RPMLOG_ERR, "%s: %s: %s", fn, item,
>>>> (msg && *msg ? msg : _("read failed\n")));
>>>> msg = _free(msg);
>>>> goto exit;
>>>> /*@notreached@*/ break;
>>>> case RPMRC_OK:
>>>> if (sigh == NULL) {
>>>> rpmlog(RPMLOG_ERR, _("%s: No signature available\n"),
>>>> fn);
>>>> rc = RPMRC_FAIL;
>>>> goto exit;
>>>> }
>>>> break;
>>>> }
>>>> msg = _free(msg);
>>>> }
>>>>
>
> Hi Jeff, ...
>
> I continued working on this, tryign to read the headers with the
> following code :
>
> msg = NULL;
> rc = rpmpkgRead(header_item, rpm_handler, &headers, &msg);
> switch (rc) {
> case RPMRC_OK:
> if (headers == NULL) {
> rpmlog(RPMLOG_ERR, "%s: No signature
> available\n", header_item);
> rc = RPMRC_FAIL;
> goto error_open;
> }
> break;
> default:
> rpmlog(RPMLOG_ERR, "%s: %s", header_item,
> (msg && *msg ? msg : "read failed\n"));
> msg = _free(msg);
> goto error_open;
> /*@notreached@*/ break;
> }
> msg = _free(msg);
>
> size = rpmpkgSizeof(header_item, headers);
Try
size_t size = headerSizeof(header_item);
(if necessary) for headers; the lead is always 96b.
>
> printf ("Header size is %d\n", size);
>
Likely should be cast to int ...
> hi = headerInit (headers);
>
> rc = headerNext (hi, he, 0);
> switch (rc) {
> case RPMRC_OK:
> if (he == NULL) {
> rpmlog(RPMLOG_ERR, "Header: No tag
> available\n");
> rc = RPMRC_FAIL;
> goto error_open;
> }
> break;
> default:
> rpmlog(RPMLOG_ERR, "No header available, %d
> \n", rc);
> goto error_open;
> /*@notreached@*/ break;
> }
>
> printf ("Header is of tag %d, data type %d of size %d, index
> %d (%d/%d/%d)\n",
> he->tag, he->t, he->c, he->ix, he->freeData, he-
> >avail, he->append);
>
Note the bit fields in the HE_t.
For reading content tags, only he->tag, he->t, he->p.ptr,
and he->c are likely of any interest.
(aside)
There's something called a "header extension tag", which
is basically a transform applied to header tags, that
uses the other fields. But you should see only content
tags from headerNext() iirc.
You can use tagName(he->tag) to convert the tagno to a readable string.
> hi = headerFini (hi);
>
> But that fails to work, as i get :
>
> Header size is -1267349847
> error: No header available, 1
>
> so, headernext returns with RPMRC_NOTFOUND, which seems strange, i
> guess i somehow messed up the pointer stuff.
>
The rpmRC return codes are overloaded, so I can't instantly tell
what RPMRC_NOTFOUND means. In general RPMRC_NOTFOUND is used
for failing searches or magic mis-matches.
Note that digests/signatures are being verified on headers while being
read.
You can probably track the code flow if you do the equivalent of -vv:
rpmSetVerbosity(RPMLOG_DEBUG);
There's also pkgio specific debugging if you do
extern _pkgio_debug;
If I can see -vv output, I might be able to help more.
73 de Jeff
______________________________________________________________________
RPM Package Manager http://rpm5.org
Developer Communication List rpm-devel@rpm5.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic