From owner-freebsd-database Fri Aug 14 16:15:55 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id QAA11309 for freebsd-database-outgoing; Fri, 14 Aug 1998 16:15:55 -0700 (PDT) (envelope-from owner-freebsd-database@FreeBSD.ORG) Received: from misery.sdf.com (misery.sdf.com [204.244.213.49]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id QAA11303 for ; Fri, 14 Aug 1998 16:15:49 -0700 (PDT) (envelope-from tom@sdf.com) Received: from tom by misery.sdf.com with smtp (Exim 1.82 #3) id 0z7SW8-0002Pd-00; Fri, 14 Aug 1998 15:40:16 -0700 Date: Fri, 14 Aug 1998 15:40:15 -0700 (PDT) From: Tom To: animal cc: freebsd-database@FreeBSD.ORG Subject: Re: .dir .pag .db In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-database@FreeBSD.ORG Precedence: bulk On Fri, 14 Aug 1998, animal wrote: > > I am for one haveing a hard time even getiing any documentation on all of > these.... > > When i create a database with perl it makes a .db..... > > but i am trying to compile a c prog that will add keys to a data base... > > can you tell me what i am doing wrong.... > > I use this to create the database...... > > #include > #include > #include > > main() { > > DBM *db; > > db = dbm_open("/usr/local/radius/users",O_CREAT,0000664); > > dbm_close(db); > } > > > > and then i am trying to add data to it by.......... > > #include > #include > #include > > > main() { > > DBM *db > datum kename,whatto; > > db = dbm_open("/usr/local/radius/users",O_WRONLY,0000664); > > kename.dptr = "animal"; > kename.dsize = strlen(kename.dptr)+1; > > whatto.dptr = "Data to be stored in database"; > kename.dsize = strlen(whatto.dptr)+1; This is a bit of problem. You are setting kename.dsize twice, and the second time to the length of whatto.dptr, so dbm_store will read beyond the end of kename.dptr. > if (dbm_store(db,kename,whatto,DBM_INSERT) < 0) { > printf("Insert messed up"); > } > > dbm_close(db); > } Tom To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-database" in the body of the message