From owner-freebsd-database Fri Aug 7 10:44:54 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA15903 for freebsd-database-outgoing; Fri, 7 Aug 1998 10:44:54 -0700 (PDT) (envelope-from owner-freebsd-database@FreeBSD.ORG) Received: from Altitude.CAM.ORG (Altitude.CAM.ORG [198.168.100.1]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA15886 for ; Fri, 7 Aug 1998 10:44:45 -0700 (PDT) (envelope-from intmktg@cam.org) Received: from cam.org (intmktg.HIP.CAM.ORG [204.19.190.173]) by Altitude.CAM.ORG (8.8.4/8.8.4) with ESMTP id NAA21880 for ; Fri, 7 Aug 1998 13:44:25 -0400 (EDT) Message-ID: <35CB3BAE.6C24C0FD@cam.org> Date: Fri, 07 Aug 1998 13:38:55 -0400 From: Marc Tardif X-Mailer: Mozilla 4.05 [en] (Win95; I) MIME-Version: 1.0 To: freebsd-database@FreeBSD.ORG Subject: db(3) help Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-database@FreeBSD.ORG Precedence: bulk Hi, I'm struggling to understand the db(3) function. I am trying to create a btree with a key and data, yet btreeop(1) only shows data for the following program. I'd appreciate any help... really. Marc #include #include #include #include #include #define PERM_SECURE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) #define MAX 12 int main() { DB *db; DBT data, key; char buf[MAX + 1], keybuf[MAX + 1]; char dbtmp[MAX + 1], dbname[MAX + 1]; (void)snprintf(dbtmp, sizeof(dbtmp), "dev.tmp"); (void)snprintf(dbname, sizeof(dbtmp), "dev.db"); if(!(db = dbopen(dbtmp, O_CREAT|O_EXLOCK|O_RDWR|O_TRUNC, PERM_SECURE, DB_BTREE, NULL))) err(1, "%s", dbtmp); key.data = keybuf; (void)strcpy(keybuf, "key"); keybuf[3] = '\0'; data.data = buf; (void)strcpy(buf, "dat"); buf[3] = '\0'; printf("%s\n%s\n", keybuf, buf); key.size = 4; data.size = 4; if ((db->put)(db, &key, &data, 0)) err(1, "dbput %s", dbtmp); (void)(db->close)(db); if (rename(dbtmp, dbname)) err(1, "rename %s to %s", dbtmp, dbname); exit(0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-database" in the body of the message