From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11399 invoked by alias); 3 Jan 2002 23:58:03 -0000 Mailing-List: contact sourcenav-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sourcenav-owner@sources.redhat.com Received: (qmail 11357 invoked from network); 3 Jan 2002 23:58:02 -0000 Message-ID: <3C34F02E.2050808@t-online.de> Date: Thu, 03 Jan 2002 15:58:00 -0000 From: khamis2@t-online.de (Khamis Abuelkomboz) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1 X-Accept-Language: en-us MIME-Version: 1.0 To: dgray@rsn.hp.com CC: sourcenav@sources.redhat.com Subject: Re: Using Source Nav. database API References: <003401c194ad$05519410$2e91630f@DGRAYPC> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Sender: 520027106440-0001@t-dialin.net X-SW-Source: 2002-q1/txt/msg00006.txt.bz2 Your example is correct! It works only if you specify a pattern, what the key begins with. The DB tool does only provide "BEGINS" functionality (maybe I'm wrong). The problem was, that you didn't hit any string combination, what the db key begins with :-) However, here is your example that displays all the database contents if you specify an empty pattern (""). One more tip! the SN database files contents differ from one to other. You need to use your example to study the contents of every file carefully. The extensions of the databases tell you about the file is used for: db.fil contains all symbols in a file (largest file) db.cl contains all classes db.f contains all files db.fu contains all functions ... and so on. /* * dbquery.c * * Copyright (C) 1998 Cygnus Solutions * * Description: * This example shows how to query the Source-Navigator database in C. */ #include #include #include #include #include #include "NTunixstubs.h" #include "db.h" int main(int argc, char *argv[]) { DB *db; DBT data; DBT key; int flag; int len; char *pattern; if (argc != 3) { printf("usage: %s database pattern\n",argv[0]); exit(1); } if (!(db = dbopen(argv[1],O_RDONLY,0644,DB_BTREE,NULL))) { fprintf(stderr,"Could not open \"%s\",%s\n",argv[1], strerror(errno)); exit(2); } pattern = argv[2]; len = strlen(pattern); if (len == 0) { key.data = "\0"; key.size = 1; } else { key.data = (void *)pattern; key.size = len; } for(flag = R_CURSOR; db->seq(db, &key,&data,flag) == 0 && strncmp(key.data,pattern,len) == 0 ; flag = R_NEXT) { printf("%s\t%s\n", (char *) key.data, (char *) data.data); } db->close(db); exit (0); }