-->

Previous | Table of Contents | Next

Page 334

After checking for successful status, the count of matching package records is checked. If there is at least one match, the first matching record is retrieved and dumped. Note that there could be more than one match. Although this example doesn't dump more than the first matching record, it would be simple to access all matches by stepping through the matches.recs array.

Once we're done with the record, we free it, as well as the list of matching records:


rpmdbClose(db);



}

The last thing we do before exiting is close the database. Here's some sample output from the program (note the successful status and the number of matches printed before the dump):


# ./showdb2 rpm

Status is: 0

Number of matches: 1

Entry count: 37

Data count : 2920



             CT  TAG                 TYPE                 OFSET      COUNT

Entry      : 000 (1000)NAME        STRING_TYPE        0x00000000 00000001

       Data: 000 rpm

Entry      : 001 (1001)VERSION     STRING_TYPE        0x00000004 00000001

        Data: 000 2.2.9

Entry      : 002 (1002)RELEASE     STRING_TYPE        0x0000000a 00000001

       Data: 000 1

Entry      : 003 (1004)SUMMARY     STRING_TYPE        0x0000000c 00000001

        Data: 000 Red Hat Package Manager

...

Entry      : 034 (1049)REQUIRENAME STRING_ARRAY_TYPE 0x00000b40 00000003

         Data: 000 libz.so.1

         Data: 001 libdb.so.2

         Data: 002 libc.so.5

Entry      : 035 (1050)REQUIREVERSION STRING_ARRAY_TYPE 0x00000b5f 00000003

       Data: 000

       Data: 001

       Data: 002

Entry      : 036 (1064)RPMVERSION     STRING_TYPE      0x00000b62 00000001

       Data: 000 2.2.9

#



Page 335

PART III
Appendixes

Page 336

Previous | Table of Contents | Next