<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;">&nbsp; &nbsp;&nbsp;<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>&gt; Date: Fri, 14 Dec 2007 20:05:15 +0100<br>&gt; From: mls@suse.de<br>&gt; To: lascoscazzato@hotmail.com<br>&gt; CC: rpm-maint@lists.dulug.duke.edu<br>&gt; Subject: Re: [Rpm-maint] rpm tag query and headerSprintf<br>&gt; <br>&gt; On Fri, Dec 14, 2007 at 06:37:18PM +0000, Vento Neicapelli wrote:<br>&gt; &gt; 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>&gt; &gt;  <br>&gt; &gt; 1) Have you got any snip of code to use the headerSprintf probably I'm doing it wrong...<br>&gt; &gt; 2)  given the  prototype:<br>&gt; &gt; char * headerSprintf(Header h, const char * fmt, const struct headerTagTableEntry_s * tags, const struct headerSprintfExtension_s * extensions, /*@null@*/ /*@out@*/ errmsg_t * errmsg)<br>&gt; &gt; if I understand the tag fmt should have the same format of the rpm tool (cli version) with  --queryformat switch....or not?<br>&gt; &gt;  <br>&gt; &gt; 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>&gt; [...]<br>&gt; &gt;         const char * qfmt = "[%{*:xml}\n]";<br>&gt; &gt;         struct headerTagTableEntry_s hTTE;<br>&gt; &gt;         struct headerSprintfExtension_s hSE;<br>&gt; &gt;         sResult = headerSprintf(h, qfmt, &amp;hTTE, &amp;hSE, &amp;errMsg);<br>&gt; <br>&gt; You shouldn't use your own extension table here, just use the ones<br>&gt; from librpm:<br>&gt; <br>&gt;           sResult = headerSprintf(h, qfmt, rpmTagTable, rpmHeaderFormats, &amp;errMsg);<br>&gt; <br>&gt; &gt;         printf("ALLTAGS:\n %s",sResult);<br>&gt; &gt;         free(sResult); sResult=NULL; errMsg=NULL;<br>&gt; &gt;        <br>&gt; &gt;         const char *qSummary="%{NAME}";<br>&gt; &gt;         sResult = headerSprintf(h, qSummary, &amp;hTTE, &amp;hSE, &amp;errMsg);<br>&gt; <br>&gt; see above<br>&gt; <br>&gt; &gt;    <br>&gt; &gt;         if(!errMsg){<br>&gt; &gt;             if(sResult){<br>&gt; &gt;                 printf("NAME:\n %s",sResult);<br>&gt; &gt;                 free(sResult); sResult=NULL; errMsg=NULL;<br>&gt; &gt;             }<br>&gt; &gt;         }else printf("ERROR: %s\n",errMsg);<br>&gt; &gt;        <br>&gt; &gt;         const char *qFiles="[%{DIRNAMES}%{BASENAMES}\n]";<br>&gt; &gt;        <br>&gt; &gt;         sResult = headerSprintf(h, qFiles, &amp;hTTE, &amp;hSE, &amp;errMsg);<br>&gt; <br>&gt; This can't work as DIRNAMES and BASENAMES have different sizes. Use the<br>&gt; pseudo-tag FILENAMES instead:<br>&gt; <br>&gt;           const char *qFiles="[%{FILENAMES}\n]";<br>&gt;           sResult = headerSprintf(h, qFiles, rpmTagTable, rpmHeaderFormats, &amp;errMsg);<br>&gt; <br>&gt; Cheers,<br>&gt;   Michael.<br>&gt; <br>&gt; -- <br>&gt; Michael Schroeder                                   mls@suse.de<br>&gt; SUSE LINUX Products GmbH, GF Markus Rex, HRB 16746 AG Nuernberg<br>&gt; 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>