[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Hi
- From: Rohit Yadav <rohit yadav gmail com>
- To: Rpm-list redhat com
- Cc:
- Subject: Hi
- Date: Tue, 7 Feb 2006 12:10:58 +0530
Hi ,
I am new to the rpm programming to the C apis . I am able to create a test application for querying the database for the installed packages. The program works on a suse box which had all the dependent files. But the same fails if it does not find some dependent packages such as (
pacakges.rpm ) etc on some other boxes i tried. Since normal rpm command is working on that box it must be getting the information from somewhere.
Can you please tell me how to solve out this problem.The package name has been hard coded but can be replaced.I am attachin the program for reference.
Thanx in advance
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <curses.h>
#include <rpm/rpmlib.h>
#include <rpm/dbindex.h>
int main(int argc, char ** argv)
{
Header h;
int status;
rpmdb db;
int_32 type,count;
char *name=NULL,*version=NULL,*summary=NULL; //can give the name of any installed rpm
dbiIndexSet matches;
status=rpmReadConfigFiles((const char *)NULL, (const char *)NULL );
if (status !=0)
printf("Error reading RC Files. \n");
if (rpmdbOpen("", &db, O_RDONLY, 0644) != 0) {
printf("Could not open rpm dbase");
exit(1);
}
status = rpmdbFindPackage(db, "ca-cs-cawin" ,&matches);
if( status ==0 )
{
printf(" The search completed successfully \n");
h=rpmdbGetRecord(db,matches.recs[0].recOffset);
if(h)
{
headerGetEntry(h, RPMTAG_NAME, &type, (void **) &name, &count);
printf ( " The package Name is : %s\n",name);
headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &version, &count);
printf ( " The package Name is : %s\n",version);
headerGetEntry(h, RPMTAG_SUMMARY, &type, (void **) &summary, &count);
printf ( " The package Name is : %s\n",summary);
}
headerFree(h);
dbiFreeIndexRecord(matches);
}
rpmdbClose(db);
return 0;
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]