[Rpm-maint] rpm tag query and headerSprintf

Vento Neicapelli lascoscazzato at hotmail.com
Fri Dec 14 19:27:34 UTC 2007


the citation disappear...(due to hotmail...) 
_he said about db opening_:

"
You likely do _NOT_ want to open a rpmdb directly.

Instead see Chapter 15 of "The RedHat RPM Guide" at

    
http://docs.fedoraproject.org/drafts/rpm-guide-en/ch-programming-c.html

(aside) Hmmm, the example code I sent to Eric Foster-Johnson yearsago seems not to have survived editing by Eric or Fedora or ...

"

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

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rpm.org/pipermail/rpm-maint/attachments/20071214/53e06f37/attachment-0001.htm 


More information about the Rpm-maint mailing list