Date: Sat, 15 Aug 1998 16:01:52 -0700 (PDT) From: animal <animal@skylink.net> To: Tom <tom@sdf.com> Cc: freebsd-database@FreeBSD.ORG Subject: Re: .dir .pag .db Message-ID: <Pine.BSF.3.95q.980815155751.17870A-100000@shell.skylink.net> In-Reply-To: <Pine.BSF.3.95q.980814153805.9258A-100000@misery.sdf.com>
next in thread | previous in thread | raw e-mail | index | archive | help
that was a mistake in typing only.....
it should look like this....
kename.dptr = "animal";
kename.dsize = strlen(kename.dptr)+1;
whatto.dptr = "Data to store";
whatto.dsize = strlen(whatto.dptr)+1;
On Fri, 14 Aug 1998, Tom wrote:
>
> 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 <stdio.h>
> > #include <fcntl.h>
> > #include <ndbm.h>
> >
> > 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 <stdio.h>
> > #include <fcntl.h>
> > #include <ndbm.h>
> >
> >
> > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.980815155751.17870A-100000>
