Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Use the Force, Luke.


devel / comp.unix.programmer / Question about hsearch(3) ENTER method

SubjectAuthor
* Question about hsearch(3) ENTER methodwij
+- Question about hsearch(3) ENTER methodKenny McCormack
`* Question about hsearch(3) ENTER methodLew Pitcher
 `* Question about hsearch(3) ENTER methodwij
  `* Question about hsearch(3) ENTER methodLew Pitcher
   `- Question about hsearch(3) ENTER methodwij

1
Question about hsearch(3) ENTER method

<40b905c7-54ae-4e9f-bd6c-990f8e0e804an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9951&group=comp.unix.programmer#9951

  copy link   Newsgroups: comp.unix.programmer
X-Received: by 2002:a05:620a:2b8d:b0:76d:a871:da22 with SMTP id dz13-20020a05620a2b8d00b0076da871da22mr13153qkb.6.1692597932150;
Sun, 20 Aug 2023 23:05:32 -0700 (PDT)
X-Received: by 2002:a17:903:22c1:b0:1b7:c803:4818 with SMTP id
y1-20020a17090322c100b001b7c8034818mr3257731plg.0.1692597931839; Sun, 20 Aug
2023 23:05:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.programmer
Date: Sun, 20 Aug 2023 23:05:31 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=124.218.76.41; posting-account=0Ek0TQoAAAAS0oceh95IuNV59QuIWNeN
NNTP-Posting-Host: 124.218.76.41
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <40b905c7-54ae-4e9f-bd6c-990f8e0e804an@googlegroups.com>
Subject: Question about hsearch(3) ENTER method
From: wynii...@gmail.com (wij)
Injection-Date: Mon, 21 Aug 2023 06:05:32 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1735
 by: wij - Mon, 21 Aug 2023 06:05 UTC

manpage of hsearch(3) says:
....
The argument action determines what hsearch() does after an unsuccess‐
ful search. This argument must either have the value ENTER, meaning
insert a copy of item (and return a pointer to the new hash table entry
as the function result), or the value FIND, meaning that NULL should be
returned. (If action is FIND, then data is ignored.)
....

When I want to insert an item into the hash table, I invokes hsearch(item,ENTER).
But I only want to insert the item when it is not in the hash table. How can I
do (Only invokes hsearch once. The manpage seems not mentioning the condition I
am looking for)?

Re: Question about hsearch(3) ENTER method

<ubvfh1$3rhht$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9953&group=comp.unix.programmer#9953

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer
Subject: Re: Question about hsearch(3) ENTER method
Date: Mon, 21 Aug 2023 10:50:09 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <ubvfh1$3rhht$1@news.xmission.com>
References: <40b905c7-54ae-4e9f-bd6c-990f8e0e804an@googlegroups.com>
Injection-Date: Mon, 21 Aug 2023 10:50:09 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="4048445"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 21 Aug 2023 10:50 UTC

In article <40b905c7-54ae-4e9f-bd6c-990f8e0e804an@googlegroups.com>,
wij <wyniijj5@gmail.com> wrote:
>manpage of hsearch(3) says:
>...
>The argument action determines what hsearch() does after an unsuccess
> ful search. This argument must either have the value ENTER, meaning
> insert a copy of item (and return a pointer to the new hash table entry
> as the function result), or the value FIND, meaning that NULL should be
> returned. (If action is FIND, then data is ignored.)
>...
>
>When I want to insert an item into the hash table, I invokes
>hsearch(item,ENTER). But I only want to insert the item when it is not
>in the hash table. How can I do (Only invokes hsearch once. The manpage
>seems not mentioning the condition I am looking for)?

I had never heard of these functions before reading your post. They look
interesting, so thanks for that.

Re: your question. It looks to me that it will "just work". I.e., if the
entry is already there, FIND & ENTER do the same thing.

P.S. The main thing I think is missing from these functions is a "delete"
capability. Oh, and an "edit" capability.

--
Just like Donald Trump today, Jesus Christ had a Messiah complex.

And, in fact, the similarities between the two figures are quite striking.
For example, both have a ragtag band of followers, whose faith cannot be shaken.

Re: Question about hsearch(3) ENTER method

<ubvl8t$1stl5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9954&group=comp.unix.programmer#9954

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.programmer
Subject: Re: Question about hsearch(3) ENTER method
Date: Mon, 21 Aug 2023 12:28:13 -0000 (UTC)
Organization: The Pitcher Digital Freehold
Lines: 45
Message-ID: <ubvl8t$1stl5$1@dont-email.me>
References: <40b905c7-54ae-4e9f-bd6c-990f8e0e804an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 21 Aug 2023 12:28:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ad93b3d0211da10c546ce0ea823dbc97";
logging-data="1996453"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gnsY1naw9YU0j0reNKPU43VcJ3lqAXJg="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:R0kXbzYJ5Mt2Tq+ng+zDpTVn5pc=
 by: Lew Pitcher - Mon, 21 Aug 2023 12:28 UTC

On Sun, 20 Aug 2023 23:05:31 -0700, wij wrote:

> manpage of hsearch(3) says:
> ...
> The argument action determines what hsearch() does after an unsuccess‐
> ful search. This argument must either have the value ENTER, meaning
> insert a copy of item (and return a pointer to the new hash table entry
> as the function result), or the value FIND, meaning that NULL should be
> returned. (If action is FIND, then data is ignored.)
> ...
>
> When I want to insert an item into the hash table, I invokes hsearch(item,ENTER).
> But I only want to insert the item when it is not in the hash table. How can I
> do (Only invokes hsearch once. The manpage seems not mentioning the condition I
> am looking for)?

The version of hsearch() (and it's manpage) that I have available to me says:
"The hsearch() function searches the hash table for an item with the
same key as item (where "the same" is determined using strcmp(3)), and
if successful returns a pointer to it.
...
The field key points to a null-terminated string which is the search
key. The field data points to data that is associated with that key.

The argument action determines what hsearch() does after an unsuccess-
ful search. This argument must either have the value ENTER, meaning
insert a copy of item (and return a pointer to the new hash table entry
as the function result), or the value FIND, meaning that NULL should be
returned. (If action is FIND, then data is ignored.)"

It seems pretty clear: hsearch() will either
a) find the matching entry in the hash table, and return a pointer to the
struct entry that defines the key and data of the matching entry, or
b) not find the matching entry, and return NULL (when ACTION is set to FIND), or
c) not find the matching entry, insert the supplied struct entry into the
hash table, and return a pointer to it (when ACTION is set to ENTER)

I believe that you are looking for the (c) behaviour; set ACTION to ENTER
when you "want to insert an item into the hash table", and to FIND when you
want to retrieve it.

HTH
--
Lew Pitcher
"In Skills We Trust"

Re: Question about hsearch(3) ENTER method

<124e2b02-b26c-48be-9d84-d18bc2322b86n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9955&group=comp.unix.programmer#9955

  copy link   Newsgroups: comp.unix.programmer
X-Received: by 2002:a05:6214:18e8:b0:64a:2de0:786d with SMTP id ep8-20020a05621418e800b0064a2de0786dmr39814qvb.7.1692624605027;
Mon, 21 Aug 2023 06:30:05 -0700 (PDT)
X-Received: by 2002:a17:90a:fd17:b0:26d:a6d:1dbe with SMTP id
cv23-20020a17090afd1700b0026d0a6d1dbemr1380716pjb.0.1692624604669; Mon, 21
Aug 2023 06:30:04 -0700 (PDT)
Path: i2pn2.org!rocksolid2!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.programmer
Date: Mon, 21 Aug 2023 06:30:04 -0700 (PDT)
In-Reply-To: <ubvl8t$1stl5$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=124.218.76.41; posting-account=0Ek0TQoAAAAS0oceh95IuNV59QuIWNeN
NNTP-Posting-Host: 124.218.76.41
References: <40b905c7-54ae-4e9f-bd6c-990f8e0e804an@googlegroups.com> <ubvl8t$1stl5$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <124e2b02-b26c-48be-9d84-d18bc2322b86n@googlegroups.com>
Subject: Re: Question about hsearch(3) ENTER method
From: wynii...@gmail.com (wij)
Injection-Date: Mon, 21 Aug 2023 13:30:05 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: wij - Mon, 21 Aug 2023 13:30 UTC

On Monday, August 21, 2023 at 8:28:18 PM UTC+8, Lew Pitcher wrote:
> On Sun, 20 Aug 2023 23:05:31 -0700, wij wrote:
>
> > manpage of hsearch(3) says:
> > ...
> > The argument action determines what hsearch() does after an unsuccess‐
> > ful search. This argument must either have the value ENTER, meaning
> > insert a copy of item (and return a pointer to the new hash table entry
> > as the function result), or the value FIND, meaning that NULL should be
> > returned. (If action is FIND, then data is ignored.)
> > ...
> >
> > When I want to insert an item into the hash table, I invokes hsearch(item,ENTER).
> > But I only want to insert the item when it is not in the hash table. How can I
> > do (Only invokes hsearch once. The manpage seems not mentioning the condition I
> > am looking for)?
> The version of hsearch() (and it's manpage) that I have available to me says:
> "The hsearch() function searches the hash table for an item with the
> same key as item (where "the same" is determined using strcmp(3)), and
> if successful returns a pointer to it.
> ...
> The field key points to a null-terminated string which is the search
> key. The field data points to data that is associated with that key.
>
> The argument action determines what hsearch() does after an unsuccess-
> ful search. This argument must either have the value ENTER, meaning
> insert a copy of item (and return a pointer to the new hash table entry
> as the function result), or the value FIND, meaning that NULL should be
> returned. (If action is FIND, then data is ignored.)"
> It seems pretty clear: hsearch() will either
> a) find the matching entry in the hash table, and return a pointer to the
> struct entry that defines the key and data of the matching entry, or
> b) not find the matching entry, and return NULL (when ACTION is set to FIND), or
> c) not find the matching entry, insert the supplied struct entry into the
> hash table, and return a pointer to it (when ACTION is set to ENTER)
>
> I believe that you are looking for the (c) behaviour; set ACTION to ENTER
> when you "want to insert an item into the hash table", and to FIND when you
> want to retrieve it.
>
> HTH
> --
> Lew Pitcher
> "In Skills We Trust"

None of the a,b,c option would work.
The usecase is like I am writting some kind of interpreter:

Type a=1;
Type a=2;

When the first "a=1" is encountered, I ENTER "a" into the hash table.
When the second "a=2" is encountered, the ENTER (because the parser saw 'Type')
should fail because it declares the same name of variable twice.

Re: Question about hsearch(3) ENTER method

<ubvrfd$1stl5$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9956&group=comp.unix.programmer#9956

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.programmer
Subject: Re: Question about hsearch(3) ENTER method
Date: Mon, 21 Aug 2023 14:14:05 -0000 (UTC)
Organization: The Pitcher Digital Freehold
Lines: 77
Message-ID: <ubvrfd$1stl5$2@dont-email.me>
References: <40b905c7-54ae-4e9f-bd6c-990f8e0e804an@googlegroups.com>
<ubvl8t$1stl5$1@dont-email.me>
<124e2b02-b26c-48be-9d84-d18bc2322b86n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 21 Aug 2023 14:14:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ad93b3d0211da10c546ce0ea823dbc97";
logging-data="1996453"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3Drd6E5UNCFWalj329yKIpcu/o5obCFo="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:MPs+Z+L2QvvMCpzquofx4oaLHn8=
 by: Lew Pitcher - Mon, 21 Aug 2023 14:14 UTC

On Mon, 21 Aug 2023 06:30:04 -0700, wij wrote:

> On Monday, August 21, 2023 at 8:28:18 PM UTC+8, Lew Pitcher wrote:
>> On Sun, 20 Aug 2023 23:05:31 -0700, wij wrote:
>>
>> > manpage of hsearch(3) says:
>> > ...
>> > The argument action determines what hsearch() does after an unsuccess‐
>> > ful search. This argument must either have the value ENTER, meaning
>> > insert a copy of item (and return a pointer to the new hash table entry
>> > as the function result), or the value FIND, meaning that NULL should be
>> > returned. (If action is FIND, then data is ignored.)
>> > ...
>> >
>> > When I want to insert an item into the hash table, I invokes hsearch(item,ENTER).
>> > But I only want to insert the item when it is not in the hash table. How can I
>> > do (Only invokes hsearch once. The manpage seems not mentioning the condition I
>> > am looking for)?
>[snip]
>> It seems pretty clear: hsearch() will either
>> a) find the matching entry in the hash table, and return a pointer to the
>> struct entry that defines the key and data of the matching entry, or
>> b) not find the matching entry, and return NULL (when ACTION is set to FIND), or
>> c) not find the matching entry, insert the supplied struct entry into the
>> hash table, and return a pointer to it (when ACTION is set to ENTER)
>>
>> I believe that you are looking for the (c) behaviour; set ACTION to ENTER
>> when you "want to insert an item into the hash table", and to FIND when you
>> want to retrieve it.

>
> None of the a,b,c option would work.

Let me make sure that I understand the issue here

> The usecase is like I am writting some kind of interpreter:
>
> Type a=1;
> Type a=2;
>
> When the first "a=1" is encountered, I ENTER "a" into the hash table.

So, at the first call to hsearch(,ENTER), you supply a pointer to a
struct entry {
char *key;
void *data;
} something;
initialized so that something.key points to the name "a", and something.data
points to the data you want to set "a" to (presumably, 1). That hsearch()
function returns a non-NULL value (which should be a pointer to your
struct entry something;) indicating that it saved the given hashtable entry.

> When the second "a=2" is encountered, the ENTER (because the parser saw 'Type')
> should fail because it declares the same name of variable twice.

Here, you should either first FIND, and decide what to do if FIND is successful,
or ENTER and just re-use the struct entry * that hsearch() returned to you.

I guess the choice depends on what your interpreter is expecting to do:
If
Type a=2;
is supposed to define a new something, and fail if that something already
exists, then you should hsearch(,FIND), and fail if FIND succeeded (or,
alternately, hsearch(,ENTER), and check whether the returned pointer has
a ->data that differs from the value you prepared for the hsearch() call).

OTOH, if
Type a=2;
is permitted to update/replace/overwrite the prior
Type a=1;
then you just hsearch(,ENTER) and update the returned ->data with the
new value for the key "a".

HTH
--
Lew Pitcher
"In Skills We Trust"

Re: Question about hsearch(3) ENTER method

<dc2163fa-b747-4298-aaab-1b4be80389een@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=9963&group=comp.unix.programmer#9963

  copy link   Newsgroups: comp.unix.programmer
X-Received: by 2002:ad4:5a13:0:b0:63d:b79:43ab with SMTP id ei19-20020ad45a13000000b0063d0b7943abmr78334qvb.4.1692670290281;
Mon, 21 Aug 2023 19:11:30 -0700 (PDT)
X-Received: by 2002:a17:903:785:b0:1b6:a2e4:c8f8 with SMTP id
kn5-20020a170903078500b001b6a2e4c8f8mr907128plb.2.1692670289762; Mon, 21 Aug
2023 19:11:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.programmer
Date: Mon, 21 Aug 2023 19:11:29 -0700 (PDT)
In-Reply-To: <ubvrfd$1stl5$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=124.218.76.41; posting-account=0Ek0TQoAAAAS0oceh95IuNV59QuIWNeN
NNTP-Posting-Host: 124.218.76.41
References: <40b905c7-54ae-4e9f-bd6c-990f8e0e804an@googlegroups.com>
<ubvl8t$1stl5$1@dont-email.me> <124e2b02-b26c-48be-9d84-d18bc2322b86n@googlegroups.com>
<ubvrfd$1stl5$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dc2163fa-b747-4298-aaab-1b4be80389een@googlegroups.com>
Subject: Re: Question about hsearch(3) ENTER method
From: wynii...@gmail.com (wij)
Injection-Date: Tue, 22 Aug 2023 02:11:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 6360
 by: wij - Tue, 22 Aug 2023 02:11 UTC

On Monday, August 21, 2023 at 10:14:10 PM UTC+8, Lew Pitcher wrote:
> On Mon, 21 Aug 2023 06:30:04 -0700, wij wrote:
>
> > On Monday, August 21, 2023 at 8:28:18 PM UTC+8, Lew Pitcher wrote:
> >> On Sun, 20 Aug 2023 23:05:31 -0700, wij wrote:
> >>
> >> > manpage of hsearch(3) says:
> >> > ...
> >> > The argument action determines what hsearch() does after an unsuccess‐
> >> > ful search. This argument must either have the value ENTER, meaning
> >> > insert a copy of item (and return a pointer to the new hash table entry
> >> > as the function result), or the value FIND, meaning that NULL should be
> >> > returned. (If action is FIND, then data is ignored.)
> >> > ...
> >> >
> >> > When I want to insert an item into the hash table, I invokes hsearch(item,ENTER).
> >> > But I only want to insert the item when it is not in the hash table. How can I
> >> > do (Only invokes hsearch once. The manpage seems not mentioning the condition I
> >> > am looking for)?
> >[snip]
> >> It seems pretty clear: hsearch() will either
> >> a) find the matching entry in the hash table, and return a pointer to the
> >> struct entry that defines the key and data of the matching entry, or
> >> b) not find the matching entry, and return NULL (when ACTION is set to FIND), or
> >> c) not find the matching entry, insert the supplied struct entry into the
> >> hash table, and return a pointer to it (when ACTION is set to ENTER)
> >>
> >> I believe that you are looking for the (c) behaviour; set ACTION to ENTER
> >> when you "want to insert an item into the hash table", and to FIND when you
> >> want to retrieve it.
>
> >
> > None of the a,b,c option would work.
> Let me make sure that I understand the issue here
> > The usecase is like I am writting some kind of interpreter:
> >
> > Type a=1;
> > Type a=2;
> >
> > When the first "a=1" is encountered, I ENTER "a" into the hash table.
> So, at the first call to hsearch(,ENTER), you supply a pointer to a
> struct entry {
> char *key;
> void *data;
> } something;
> initialized so that something.key points to the name "a", and something.data
> points to the data you want to set "a" to (presumably, 1). That hsearch()
> function returns a non-NULL value (which should be a pointer to your
> struct entry something;) indicating that it saved the given hashtable entry.
> > When the second "a=2" is encountered, the ENTER (because the parser saw 'Type')
> > should fail because it declares the same name of variable twice.
> Here, you should either first FIND, and decide what to do if FIND is successful,
> or ENTER and just re-use the struct entry * that hsearch() returned to you.
>
> I guess the choice depends on what your interpreter is expecting to do:
> If
> Type a=2;
> is supposed to define a new something, and fail if that something already
> exists, then you should hsearch(,FIND), and fail if FIND succeeded (or,
> alternately, hsearch(,ENTER), and check whether the returned pointer has
> a ->data that differs from the value you prepared for the hsearch() call)..
>
> OTOH, if
> Type a=2;
> is permitted to update/replace/overwrite the prior
> Type a=1;
> then you just hsearch(,ENTER) and update the returned ->data with the
> new value for the key "a".
> HTH
> --
> Lew Pitcher
> "In Skills We Trust"

class HSearch {
::hsearch_data m_htab;
size_t m_maxe;

public:
//....

template<typename T>
WY__WARNRET__ Errno declare(const char* key, T data) {
static_assert(sizeof(T)<=sizeof(void*));
static char kbuf[256];
if(key==NULL) {
WY_RETURN( EFAULT );
}
if(m_maxe==0) {
WY_RETURN( EBADF);
}
const size_t klen= strlen(key);
if(klen>=sizeof(kbuf)) {
WY_RETURN( ENAMETOOLONG );
}
memcpy(kbuf,key,klen);
kbuf[klen]=0;
::ENTRY item,*retv;
item.key= const_cast<char*>(kbuf);
if(::hsearch_r(item, ENTER,&retv,&m_htab)==0) {
WY_RETURN(errno);
}
if(retv->key!=kbuf) {
WY_RETURN(EEXIST);
}
union {
void * ptr;
T val;
} tt;
tt.val=data;
retv->key= const_cast<char*>(key);
retv->data= tt.ptr;
return Ok;
};

};

I think hsearch can't do what I want (directly). The work-around is copy the
key to a static buffer. The overhead is equ. to a single strcmp, so, fine.
The limit is string length.
I think the implement of declare(..) should comply with the spec. of hsearch
(to be exactly, hsearch_r), though such compliance is not explicitly stated..
How do you think?

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor