---
name: "cdb"
section: "3qmail"
platform: "linux"
package: "qmail"
version: "1.06-6.2~deb10u1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/cdb/3qmail"
---

# cdb(3qmail)

read from a constant database

## NAME

cdb - read from a constant database

## SYNTAX

**#include \<cdb.h\>**

int **cdb\_seek(***fd,key,len,dlen***)**;

int *fd*;\
 char \**key*;\
 unsigned int *len*;\
 uint32 \**dlen*;

## DESCRIPTION

**cdb\_seek** looks up *key* in a constant database. It returns 1 if  *key* is present, 0 if  *key* is not present, or -1 if there was a read error. *key* is an array of *len* characters.

**cdb\_seek** needs an open file descriptor, *fd*, pointing to the database. If **cdb\_seek** returns 1, it points *fd* at the beginning of the data portion of the first record indexed by *key*, and it stores the data length in *dlen.* **cdb\_seek** does not provide a way to read subsequent records with the same key.

It's fine to do several **cdb\_seek** lookups with the same open file descriptor. Beware, however, that two simultaneous **cdb\_seek** lookups can fail horribly; separate processes should not share the same database descriptor. Furthermore, any updates after the database was opened will be invisible. It's rarely a good idea for a long-running program to hold a database open.

## SEE ALSO

[cdbget(1)](/cdbget/1.md)
