[comp.unix.questions] dbm

jdb@dkstar.UUCP (Jon Bennett ) (05/08/89)

	I believe that I have a bug in my dbm(3X) package.  I wrote
a program to store news header Message-I.D.: 's ( I am working on an
alternate news reader).  The program goes through articles in different
news groups, locates the message id field, and uses it as a key
to store the value returned from time(2).  After the program runs through
all of the articles in the list, all of the articles should be in a 
history file.  When I run the program again, about 1/3 of the articles
are re-read.  The fetch is not finding them in the history file.  The
other 2/3 are in the history file and are not re-read. If I run the
program a second time, storing the articles that are re-read, and
a third time, then the articles are finally marked as all read.  I wrote
a program to traverse the data base using the example code in the manpage
for dbm(3x) (firstkey().. nextkey...) and it retrieves several keys, but when
I fetch the data for they key it returns a null data pointer.

	DATA:
	Computer is Symmetric 375
	OS is Berkley 4.2 (probably modified by Symmetric)
	I looked at /usr/lib/libdbm.a and found it to be 1300 bytes long.
		I decide that this was too short so I looked (ar t) in my
		/lib/libc.a and found most of the entry points for 
		ndbm(?).  This may be of help.
	QUESTIONS:
1.	Am "I" doing something wrong?
2.	Can this be fixed without source code?
3.	Is there a public version of dbm(3x), or equivalent?
-- 
These postings are my own  and do not | Jon "There, that oughta do it" Bennett
represent the opinions of my employer |	jdb@dkstar.UUCP
{decvax hplabs linus rutgers seismo}!gatech!rebel!dkstar!jdb

vixie@decwrl.dec.com (Paul A Vixie) (05/11/89)

Jon Bennett asks a fair question: why doesn't dbm(3) work on a Symmetric?

As the former and present (sigh) owner of an s/375, I can share my own
experiences.  I noticed the corruption of the news history dbm long ago and
tracked it down to a problem in the Symmetric C compiler where bad code is
silently generated while compiling dbm.c or ndbm.c.  Symmetric insisted
that it was actually a problem in the isspace() macro or some strange
thing, but I finally showed a .c and a .s file to Bill Jolitz and he had to
agree that his compiler had done the wrong thing.  I never got a fix from
him.

Symmetric Computer Systems went out of business recently.

Moral of story: compile up a libdbm.a or libc.a(ndbm.o) with GCC.

Disclaimer: DEC owns no s/375 machines so this is obviously not DEC's opinion.
--
Paul Vixie
Work:    vixie@decwrl.dec.com    decwrl!vixie    +1 415 853 6600
Play:    paul@vixie.sf.ca.us     vixie!paul      +1 415 864 7013

cml@brachiosaur.cis.ohio-state.edu (Christopher Lott) (05/11/89)

In article <VIXIE.89May11030122@jove.pa.dec.com> vixie@decwrl.dec.com (Paul A Vixie) writes:
>Jon Bennett asks a fair question: why doesn't dbm(3) work on a Symmetric?
>
>Moral of story: compile up a libdbm.a or libc.a(ndbm.o) with GCC.

Hi,

I tinkered with gcc and dbm routines and want to tell anyone who tries this
to be certain to compile both the dbm libraries and your appl. with the
same compiler.

pcc-derived c compilers return structure contents in a different way from
gcc and they are not compatible.  dbm_fetch() and friends return datum structs;
you can't mix a dbm library compiled by pcc (as supplied by SunOS 3.5.1, which
does pcc-flavor struct returns) with an application compiled by gcc (which
will expect gcc-compliant struct return procedures). I tried this, and trust
me, it doesn't work. :-)

Look carefully at the gcc flag -pcc_struct_return,
although last I heard, it wasn't quite working correctly yet.

chris...
-=-
cml@cis.ohio-state.edu        Computer Science Dept, OSU          614-292-1826
 or:  ...!{att,pyramid,killer}!osu-cis!cml		<standard disclaimers>