public inbox for
 help / color / mirror / Atom feed
From: (Khamis Abuelkomboz)
Subject: Re: Using Source Nav. database API
Date: Thu, 03 Jan 2002 15:58:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <003401c194ad$05519410$2e91630f@DGRAYPC>

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)     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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>

#include "NTunixstubs.h"
#include "db.h"

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]);
        if (!(db = dbopen(argv[1],O_RDONLY,0644,DB_BTREE,NULL)))
                fprintf(stderr,"Could not open \"%s\",%s\n",argv[1],

        pattern = argv[2];
        len = strlen(pattern);

        if (len == 0)
   = "\0";
            key.size = 1;
   = (void *)pattern;
            key.size = len;
        for(flag = R_CURSOR;
                db->seq(db, &key,&data,flag) == 0
                && strncmp(,pattern,len) == 0
                flag = R_NEXT)
                printf("%s\t%s\n", (char *), (char *);

        exit (0);

      reply	other threads:[~2002-01-03 23:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-03 15:19 David Gray
2002-01-03 15:58 ` Khamis Abuelkomboz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).