<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
the citation disappear...(due to hotmail...) <br>_he said about db opening_:<br><br>"<br><span class="EC_Apple-style-span" style="font-family: Helvetica; font-size: 12px;"><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;">You likely do _NOT_ want to open a rpmdb directly.
</div><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px;"><br></div><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;">Instead see Chapter 15 of "The RedHat RPM Guide" at
</div><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px;"><br></div><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"> <a href="http://docs.fedoraproject.org/drafts/rpm-guide-en/ch-programming-c.html" target="_blank">
http://docs.fedoraproject.org/drafts/rpm-guide-en/ch-programming-c.html</a></div><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px;"><br></div><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;">
(aside) Hmmm, the example code I sent to Eric Foster-Johnson years</div><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;">ago seems not to have survived editing by Eric or Fedora or ...
</div><div style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px;"><br>"<br></div></span><br>> Date: Fri, 14 Dec 2007 20:05:15 +0100<br>> From: mls@suse.de<br>> To: lascoscazzato@hotmail.com<br>> CC: rpm-maint@lists.dulug.duke.edu<br>> Subject: Re: [Rpm-maint] rpm tag query and headerSprintf<br>> <br>> On Fri, Dec 14, 2007 at 06:37:18PM +0000, Vento Neicapelli wrote:<br>> > I'm trying to use the librpm in a custom application, I use rpm 4.4.2.1 and I need your help about tag querying...<br>> > <br>> > 1) Have you got any snip of code to use the headerSprintf probably I'm doing it wrong...<br>> > 2) given the prototype:<br>> > char * headerSprintf(Header h, const char * fmt, const struct headerTagTableEntry_s * tags, const struct headerSprintfExtension_s * extensions, /*@null@*/ /*@out@*/ errmsg_t * errmsg)<br>> > if I understand the tag fmt should have the same format of the rpm tool (cli version) with --queryformat switch....or not?<br>> > <br>> > Below you find the code I wrote just to get familiar with rpmlib functions: it tries to search a package (by name) and then prints some tags....<br>> [...]<br>> > const char * qfmt = "[%{*:xml}\n]";<br>> > struct headerTagTableEntry_s hTTE;<br>> > struct headerSprintfExtension_s hSE;<br>> > sResult = headerSprintf(h, qfmt, &hTTE, &hSE, &errMsg);<br>> <br>> You shouldn't use your own extension table here, just use the ones<br>> from librpm:<br>> <br>> sResult = headerSprintf(h, qfmt, rpmTagTable, rpmHeaderFormats, &errMsg);<br>> <br>> > printf("ALLTAGS:\n %s",sResult);<br>> > free(sResult); sResult=NULL; errMsg=NULL;<br>> > <br>> > const char *qSummary="%{NAME}";<br>> > sResult = headerSprintf(h, qSummary, &hTTE, &hSE, &errMsg);<br>> <br>> see above<br>> <br>> > <br>> > if(!errMsg){<br>> > if(sResult){<br>> > printf("NAME:\n %s",sResult);<br>> > free(sResult); sResult=NULL; errMsg=NULL;<br>> > }<br>> > }else printf("ERROR: %s\n",errMsg);<br>> > <br>> > const char *qFiles="[%{DIRNAMES}%{BASENAMES}\n]";<br>> > <br>> > sResult = headerSprintf(h, qFiles, &hTTE, &hSE, &errMsg);<br>> <br>> This can't work as DIRNAMES and BASENAMES have different sizes. Use the<br>> pseudo-tag FILENAMES instead:<br>> <br>> const char *qFiles="[%{FILENAMES}\n]";<br>> sResult = headerSprintf(h, qFiles, rpmTagTable, rpmHeaderFormats, &errMsg);<br>> <br>> Cheers,<br>> Michael.<br>> <br>> -- <br>> Michael Schroeder mls@suse.de<br>> SUSE LINUX Products GmbH, GF Markus Rex, HRB 16746 AG Nuernberg<br>> main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}<br><br /><hr />Express yourself instantly with MSN Messenger! <a href='http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/' target='_new'>MSN Messenger</a></body>
</html>