File: hsearch.html

package info (click to toggle)
evolution-data-server 1.0.4-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 39,504 kB
  • ctags: 26,423
  • sloc: ansic: 175,347; tcl: 30,499; sh: 20,699; perl: 11,320; xml: 9,039; java: 7,653; cpp: 6,029; makefile: 4,866; awk: 1,338; yacc: 1,103; sed: 772; cs: 505; lex: 134; asm: 14
file content (106 lines) | stat: -rw-r--r-- 4,784 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!--$Id: hsearch.html,v 1.1.1.1 2003/11/20 22:14:26 toshok Exp $-->
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
<!--All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: hsearch</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
</head>
<body bgcolor=white>
<a name="2"><!--meow--></a>
<table width="100%"><tr valign=top>
<td>
<h1>hsearch</h1>
</td>
<td align=right>
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<hr size=1 noshade>
<tt>
<h3><pre>
#define DB_DBM_HSEARCH    1
#include &lt;db.h&gt;
<p>
typedef enum {
        FIND, ENTER
} ACTION;
<p>
typedef struct entry {
        char *key;
        void *data;
} ENTRY;
<p>
ENTRY *
hsearch(ENTRY item, ACTION action);
<p>
int
hcreate(size_t nelem);
<p>
void
hdestroy(void);
</pre></h3>
<h1>Description</h1>
<p>The hsearch interface to the Berkeley DB library is intended to
provide a high-performance implementation and source code compatibility
for applications written to the historic hsearch interface.
It is not recommended for any other purpose.
<p>To compile hsearch applications, replace the application's
<b>#include</b> of the hsearch include
file (for example, <b>#include &lt;search.h&gt;</b>)
with the following two lines:
<p><blockquote><pre>#define DB_DBM_HSEARCH    1
#include &lt;db.h&gt;</pre></blockquote>
<p>and recompile.
<p>The hcreate function creates an in-memory database.  The
<b>nelem</b> argument is an estimation of the maximum number of key/data
pairs that will be stored in the database.
<p>The <b>hdestroy</b> function discards the database.
<p>Database elements are structures of type <b>ENTRY</b>, which contain at
least two fields: <b>key</b> and <b>data</b>.  The field <b>key</b> is
declared to be of type <b>char *</b>, and is the key used for storage
and retrieval.  The field <b>data</b> is declared to be of type
<b>void *</b>, and is its associated data.
<p>The hsearch function retrieves key/data pairs from, and stores
key/data pairs into the database.
<p>The <b>action</b> argument must be set to one of two values:
<p><dl compact>
<p><dt>ENTER<dd>If the key does not already appear in the database, insert the key/data
pair into the database.  If the key already appears in the database,
return a reference to an <b>ENTRY</b> structure which refers to the
existing key and its associated data element.
<p><dt>FIND<dd>Retrieve the specified key/data pair from the database.
</dl>
<h3>Compatibility Notes</h3>
<p>Historically, hsearch required applications to maintain the keys
and data in the application's memory for as long as the <b>hsearch</b>
database existed.  Because Berkeley DB handles key and data management
internally, there is no requirement that applications maintain local
copies of key and data items, although the only effect of doing so
should be the allocation of additional memory.
<h3>Hsearch Diagnostics</h3>
<p>The <b>hcreate</b> function returns 0 on failure, setting
<b>errno</b>, and non-zero on success.
<p>The <b>hsearch</b> function returns a pointer to an ENTRY structure on
success, and NULL, setting <b>errno</b>, if the <b>action</b>
specified was FIND and the item did not appear in the database.
<h1>Errors</h1>
<p>The hcreate method may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
If a catastrophic error has occurred, the hcreate method may fail and
return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>,
in which case all subsequent Berkeley DB calls will fail in the same way.
<p>The hsearch method may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
If a catastrophic error has occurred, the hsearch method may fail and
return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>,
in which case all subsequent Berkeley DB calls will fail in the same way.
<p>In addition, the <b>hsearch</b> function will fail, setting <b>errno</b>
to 0, if the <b>action</b> specified was FIND and the item did not appear in
the database.
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
</body>
</html>