diff options
Diffstat (limited to 'doc/gdbm.texi')
-rw-r--r-- | doc/gdbm.texi | 2567 |
1 files changed, 2567 insertions, 0 deletions
diff --git a/doc/gdbm.texi b/doc/gdbm.texi new file mode 100644 index 0000000..6322a9b --- /dev/null +++ b/doc/gdbm.texi | |||
@@ -0,0 +1,2567 @@ | |||
1 | \input texinfo @c -*- Texinfo -*- | ||
2 | @comment $Id$ | ||
3 | @comment %**start of header (This is for running Texinfo on a region.) | ||
4 | @setfilename gdbm.info | ||
5 | @include version.texi | ||
6 | @settitle GDBM manual | ||
7 | |||
8 | @ifinfo | ||
9 | @dircategory Programming & development tools | ||
10 | @direntry | ||
11 | * GDBM: (gdbm). The GNU database manager. | ||
12 | * gdbm_dump: (gdbm) gdbm_dump. Dump the GDBM database into a flat file. | ||
13 | * gdbm_load: (gdbm) gdbm_load. Load the database from a flat file. | ||
14 | @end direntry | ||
15 | @end ifinfo | ||
16 | |||
17 | @c @setchapternewpage odd | ||
18 | @comment %**end of header (This is for running Texinfo on a region.) | ||
19 | |||
20 | @c Use @kwindex for keywords | ||
21 | @defcodeindex kw | ||
22 | @syncodeindex kw cp | ||
23 | @c Use @flindex for files | ||
24 | @defcodeindex fl | ||
25 | @syncodeindex fl cp | ||
26 | @c Use @prindex for programs | ||
27 | @defcodeindex pr | ||
28 | @syncodeindex pr cp | ||
29 | |||
30 | @c Merge all indices into a single one | ||
31 | @syncodeindex fn cp | ||
32 | @syncodeindex vr cp | ||
33 | @syncodeindex ky cp | ||
34 | @syncodeindex pg cp | ||
35 | @syncodeindex tp cp | ||
36 | |||
37 | @iftex | ||
38 | @finalout | ||
39 | @end iftex | ||
40 | |||
41 | @copying | ||
42 | Published by the Free Software Foundation, | ||
43 | 51 Franklin Street, Fifth Floor | ||
44 | Boston, MA 02110-1301, USA | ||
45 | |||
46 | Copyright @copyright{} 1989-1999, 2007-2011 Free Software Foundation, Inc. | ||
47 | |||
48 | Permission is granted to copy, distribute and/or modify this document | ||
49 | under the terms of the GNU Free Documentation License, Version 1.3 or | ||
50 | any later version published by the Free Software Foundation; with no | ||
51 | Invariant Sections, no Front-Cover, and no Back-Cover texts. | ||
52 | A copy of the license is included in the section entitled ``GNU Free | ||
53 | Documentation License.'' | ||
54 | @end copying | ||
55 | |||
56 | @titlepage | ||
57 | @sp 6 | ||
58 | @center @titlefont{GNU dbm} | ||
59 | @sp 2 | ||
60 | @center A Database Manager | ||
61 | @sp 2 | ||
62 | @center by Philip A. Nelson, Jason Downs and Sergey Poznyakoff | ||
63 | @sp 4 | ||
64 | @center Manual by Pierre Gaumond, Philip A. Nelson, Jason Downs | ||
65 | @center and Sergey Poznyakoff | ||
66 | @sp 1 | ||
67 | @center Edition @value{EDITION} | ||
68 | @sp 1 | ||
69 | @center for GNU @code{dbm}, Version @value{VERSION} | ||
70 | @page | ||
71 | @vskip 0pt plus 1filll | ||
72 | @insertcopying | ||
73 | @end titlepage | ||
74 | |||
75 | @ifnothtml | ||
76 | @page | ||
77 | @summarycontents | ||
78 | @page | ||
79 | @end ifnothtml | ||
80 | @contents | ||
81 | |||
82 | @ifnottex | ||
83 | @node Top | ||
84 | @top The GNU database manager. | ||
85 | |||
86 | GNU @code{dbm} is a library of functions implementing a hashed database | ||
87 | on a disk file. This manual documents GNU @code{dbm} Version @value{VERSION} | ||
88 | (@code{gdbm}). The software was originally written by Philip A.@: | ||
89 | Nelson. This document was originally written by Pierre Gaumond from | ||
90 | texts written by Phil. | ||
91 | @end ifnottex | ||
92 | |||
93 | @menu | ||
94 | Introduction: | ||
95 | |||
96 | * Copying:: Your rights. | ||
97 | * Intro:: Introduction to GNU dbm. | ||
98 | * List:: List of functions. | ||
99 | |||
100 | Functions: | ||
101 | |||
102 | * Open:: Opening the database. | ||
103 | * Close:: Closing the database. | ||
104 | * Count:: Counting records in the database. | ||
105 | * Store:: Inserting and replacing records in the database. | ||
106 | * Fetch:: Searching records in the database. | ||
107 | * Delete:: Removing records from the database. | ||
108 | * Sequential:: Sequential access to records. | ||
109 | * Reorganization:: Database reorganization. | ||
110 | * Sync:: Insure all writes to disk have competed. | ||
111 | * Flat files:: Export and import to Flat file format. | ||
112 | * Errors:: Convert internal error codes into English. | ||
113 | * Options:: Setting internal options. | ||
114 | * Locking:: File locking. | ||
115 | * Variables:: Useful global variables. | ||
116 | |||
117 | * Error codes:: Error codes returned by @code{gdbm} calls. | ||
118 | * Compatibility:: Compatibility with UNIX dbm and ndbm. | ||
119 | |||
120 | Programs | ||
121 | |||
122 | * gdbmtool:: Examine and modify a GDBM database. | ||
123 | * gdbm_dump:: Dump the database into a flat file. | ||
124 | * gdbm_load:: Load the database from a flat file. | ||
125 | * gdbmexport:: Export a database into a portable format. | ||
126 | * Exit codes:: Exit codes returned by GDBM utilities. | ||
127 | |||
128 | Other topics: | ||
129 | |||
130 | * Bugs:: Problems and bugs. | ||
131 | * Resources:: Additional resources, | ||
132 | |||
133 | * GNU Free Documentation License:: Document license. | ||
134 | * Index:: Index | ||
135 | @end menu | ||
136 | |||
137 | @node Copying | ||
138 | @chapter Copying Conditions. | ||
139 | This library is @dfn{free}; this means that everyone is free to use | ||
140 | it and free to redistribute it on a free basis. GNU @code{dbm} (@code{gdbm}) | ||
141 | is not in the public domain; it is copyrighted and there | ||
142 | are restrictions on its distribution, but these restrictions are | ||
143 | designed to permit everything that a good cooperating citizen would want | ||
144 | to do. What is not allowed is to try to prevent others from further | ||
145 | sharing any version of @code{gdbm} that they might get from | ||
146 | you.@refill | ||
147 | |||
148 | Specifically, we want to make sure that you have the right to give | ||
149 | away copies @code{gdbm}, that you receive | ||
150 | source code or else can get it if you want it, that you can change these | ||
151 | functions or use pieces of them in new free programs, and that you know | ||
152 | you can do these things.@refill | ||
153 | |||
154 | To make sure that everyone has such rights, we have to forbid you to | ||
155 | deprive anyone else of these rights. For example, if you distribute | ||
156 | copies @code{gdbm}, you must give the recipients all | ||
157 | the rights that you have. You must make sure that they, too, receive or | ||
158 | can get the source code. And you must tell them their rights.@refill | ||
159 | |||
160 | Also, for our own protection, we must make certain that everyone finds | ||
161 | out that there is no warranty for anything in the @code{gdbm} distribution. | ||
162 | If these functions are modified by someone else and passed on, we want | ||
163 | their recipients to know that what they have is not what we distributed, | ||
164 | so that any problems introduced by others will not reflect on our | ||
165 | reputation.@refill | ||
166 | |||
167 | @code{Gdbm} is currently distributed under the terms of the GNU General | ||
168 | Public License, Version 3. (@emph{NOT} under the GNU General Library | ||
169 | Public License.) A copy the GNU General Public License is included with | ||
170 | the distribution of @code{gdbm}. | ||
171 | |||
172 | @node Intro | ||
173 | @chapter Introduction to GNU @code{dbm}. | ||
174 | |||
175 | GNU @code{dbm} (@code{gdbm}) is a library of database functions that use | ||
176 | extensible hashing and works similar to the standard UNIX @code{dbm} | ||
177 | functions. These routines are provided to a programmer needing to | ||
178 | create and manipulate a hashed database. (@code{gdbm} is @emph{NOT} a | ||
179 | complete database package for an end user.) | ||
180 | |||
181 | The basic use of @code{gdbm} is to store key/data pairs in a data file. | ||
182 | Each key must be unique and each key is paired with only one data item. | ||
183 | The keys can not be directly accessed in sorted order. The basic unit | ||
184 | of data in @code{gdbm} is the structure: | ||
185 | |||
186 | @example | ||
187 | typedef struct @{ | ||
188 | char *dptr; | ||
189 | int dsize; | ||
190 | @} datum; | ||
191 | @end example | ||
192 | |||
193 | This structure allows for arbitrary sized keys and data items. | ||
194 | |||
195 | The key/data pairs are stored in a @code{gdbm} disk file, called a | ||
196 | @code{gdbm} database. An application must open a @code{gdbm} database | ||
197 | to be able manipulate the keys and data contained in the database. | ||
198 | @code{gdbm} allows an application to have multiple databases open at the | ||
199 | same time. When an application opens a @code{gdbm} database, it is | ||
200 | designated as a @code{reader} or a @code{writer}. A @code{gdbm} | ||
201 | database can be opened by at most one writer at a time. However, many readers | ||
202 | may open the database simultaneously. Readers and writers can not | ||
203 | open the @code{gdbm} database at the same time. | ||
204 | |||
205 | @node List | ||
206 | @chapter List of functions. | ||
207 | |||
208 | The following is a quick list of the functions contained in the @code{gdbm} | ||
209 | library. The include file @code{gdbm.h}, that can be included by the user, | ||
210 | contains a definition of these functions. | ||
211 | |||
212 | @example | ||
213 | #include <gdbm.h> | ||
214 | |||
215 | GDBM_FILE gdbm_open(name, block_size, flags, mode, fatal_func); | ||
216 | void gdbm_close(dbf); | ||
217 | int gdbm_store(dbf, key, content, flag); | ||
218 | datum gdbm_fetch(dbf, key); | ||
219 | int gdbm_delete(dbf, key); | ||
220 | datum gdbm_firstkey(dbf); | ||
221 | datum gdbm_nextkey(dbf, key); | ||
222 | int gdbm_reorganize(dbf); | ||
223 | void gdbm_sync(dbf); | ||
224 | int gdbm_exists(dbf, key); | ||
225 | char *gdbm_strerror(errno); | ||
226 | int gdbm_setopt(dbf, option, value, size); | ||
227 | int gdbm_fdesc(dbf); | ||
228 | int gdbm_export (GDBM_FILE, const char *, int, int); | ||
229 | int gdbm_export_to_file (GDBM_FILE dbf, FILE *fp); | ||
230 | int gdbm_import (GDBM_FILE, const char *, int); | ||
231 | int gdbm_import_from_file (GDBM_FILE dbf, FILE *fp, int flag); | ||
232 | int gdbm_count (GDBM_FILE dbf, gdbm_count_t *pcount); | ||
233 | int gdbm_version_cmp (int const a[], int const b[]); | ||
234 | @end example | ||
235 | |||
236 | The @code{gdbm.h} include file is often in the @file{/usr/include} | ||
237 | directory. (The actual location of @code{gdbm.h} depends on your local | ||
238 | installation of @code{gdbm}.) | ||
239 | |||
240 | @node Open | ||
241 | @chapter Opening the database. | ||
242 | |||
243 | @cindex opening the database | ||
244 | @cindex database, opening or creating | ||
245 | @deftypefn {gdbm interface} GDBM_FILE gdbm_open (const char *@var{name}, int @var{block_size}, @ | ||
< |