Imported Upstream version 1.11
[platform/upstream/gdbm.git] / doc / gdbm.info
1 This is gdbm.info, produced by makeinfo version 4.13 from gdbm.texinfo.
2
3 INFO-DIR-SECTION Programming & development tools
4 START-INFO-DIR-ENTRY
5 * GDBM: (gdbm).                 The GNU database manager.
6 * gdbm_dump: gdbm_dump(gdbm).   Dump the GDBM database into a flat file.
7 * gdbm_load: gdbm_load(gdbm).   Load the database from a flat file.
8 END-INFO-DIR-ENTRY
9
10    Published by the Free Software Foundation, 51 Franklin Street, Fifth
11 Floor Boston, MA 02110-1301, USA
12
13    Copyright (C) 1989-1999, 2007-2011 Free Software Foundation, Inc.
14
15    Permission is granted to copy, distribute and/or modify this document
16 under the terms of the GNU Free Documentation License, Version 1.3 or
17 any later version published by the Free Software Foundation; with no
18 Invariant Sections, no Front-Cover, and no Back-Cover texts.  A copy of
19 the license is included in the section entitled "GNU Free Documentation
20 License."
21
22 \1f
23 File: gdbm.info,  Node: Top,  Next: Copying,  Up: (dir)
24
25 The GNU database manager.
26 *************************
27
28 GNU `dbm' is a library of functions implementing a hashed database on a
29 disk file.  This manual documents GNU `dbm' Version 1.11 (`gdbm').  The
30 software was originally written by Philip A.  Nelson.  This document
31 was originally written by Pierre Gaumond from texts written by Phil.
32
33 * Menu:
34
35 Introduction:
36
37 * Copying::                    Your rights.
38 * Intro::                      Introduction to GNU dbm.
39 * List::                       List of functions.
40
41 Functions:
42
43 * Open::                       Opening the database.
44 * Close::                      Closing the database.
45 * Count::                      Counting records in the database.
46 * Store::                      Inserting and replacing records in the database.
47 * Fetch::                      Searching records in the database.
48 * Delete::                     Removing records from the database.
49 * Sequential::                 Sequential access to records.
50 * Reorganization::             Database reorganization.
51 * Sync::                       Insure all writes to disk have competed.
52 * Flat files::                 Export and import to Flat file format.
53 * Errors::                     Convert internal error codes into English.
54 * Options::                    Setting internal options.
55 * Locking::                    File locking.
56
57 * Error codes::                Error codes returned by `gdbm' calls.
58 * Variables::                  Two useful variables.
59 * Compatibility::              Compatibility with UNIX dbm and ndbm.
60
61 Programs
62
63 * gdbmtool::                   Examine and modify a GDBM database.
64 * gdbm_dump::                  Dump the database into a flat file.
65 * gdbm_load::                  Load the database from a flat file.
66 * gdbmexport::                 Export a database into a portable format.
67 * Exit codes::                 Exit codes returned by GDBM utilities.
68
69 Other topics:
70
71 * Bugs::                       Problems and bugs.
72 * Resources::                  Additional resources,
73
74 * GNU Free Documentation License::      Document license.
75 * Index::                       Index
76
77 \1f
78 File: gdbm.info,  Node: Copying,  Next: Intro,  Prev: Top,  Up: Top
79
80 1 Copying Conditions.
81 *********************
82
83 This library is "free"; this means that everyone is free to use it and
84 free to redistribute it on a free basis.  GNU `dbm' (`gdbm') is not in
85 the public domain; it is copyrighted and there are restrictions on its
86 distribution, but these restrictions are designed to permit everything
87 that a good cooperating citizen would want to do.  What is not allowed
88 is to try to prevent others from further sharing any version of `gdbm'
89 that they might get from you.
90
91    Specifically, we want to make sure that you have the right to give
92 away copies `gdbm', that you receive source code or else can get it if
93 you want it, that you can change these functions or use pieces of them
94 in new free programs, and that you know you can do these things.
95
96    To make sure that everyone has such rights, we have to forbid you to
97 deprive anyone else of these rights.  For example, if you distribute
98 copies `gdbm', you must give the recipients all the rights that you
99 have.  You must make sure that they, too, receive or can get the source
100 code.  And you must tell them their rights.
101
102    Also, for our own protection, we must make certain that everyone
103 finds out that there is no warranty for anything in the `gdbm'
104 distribution.  If these functions are modified by someone else and
105 passed on, we want their recipients to know that what they have is not
106 what we distributed, so that any problems introduced by others will not
107 reflect on our reputation.
108
109    `Gdbm' is currently distributed under the terms of the GNU General
110 Public License, Version 3.  (_NOT_ under the GNU General Library Public
111 License.)  A copy the GNU General Public License is included with the
112 distribution of `gdbm'.
113
114 \1f
115 File: gdbm.info,  Node: Intro,  Next: List,  Prev: Copying,  Up: Top
116
117 2 Introduction to GNU `dbm'.
118 ****************************
119
120 GNU `dbm' (`gdbm') is a library of database functions that use
121 extensible hashing and works similar to the standard UNIX `dbm'
122 functions.  These routines are provided to a programmer needing to
123 create and manipulate a hashed database. (`gdbm' is _NOT_ a complete
124 database package for an end user.)
125
126    The basic use of `gdbm' is to store key/data pairs in a data file.
127 Each key must be unique and each key is paired with only one data item.
128 The keys can not be directly accessed in sorted order.  The basic unit
129 of data in `gdbm' is the structure:
130
131        typedef struct {
132                   char *dptr;
133                   int  dsize;
134                } datum;
135
136    This structure allows for arbitrary sized keys and data items.
137
138    The key/data pairs are stored in a `gdbm' disk file, called a `gdbm'
139 database.  An application must open a `gdbm' database to be able
140 manipulate the keys and data contained in the database.  `gdbm' allows
141 an application to have multiple databases open at the same time.  When
142 an application opens a `gdbm' database, it is designated as a `reader'
143 or a `writer'.  A `gdbm' database can be opened by at most one writer
144 at a time.  However, many readers may open the database simultaneously.
145 Readers and writers can not open the `gdbm' database at the same time.
146
147 \1f
148 File: gdbm.info,  Node: List,  Next: Open,  Prev: Intro,  Up: Top
149
150 3 List of functions.
151 ********************
152
153 The following is a quick list of the functions contained in the `gdbm'
154 library.  The include file `gdbm.h', that can be included by the user,
155 contains a definition of these functions.
156
157      #include <gdbm.h>
158
159      GDBM_FILE gdbm_open(name, block_size, flags, mode, fatal_func);
160      void gdbm_close(dbf);
161      int gdbm_store(dbf, key, content, flag);
162      datum gdbm_fetch(dbf, key);
163      int gdbm_delete(dbf, key);
164      datum gdbm_firstkey(dbf);
165      datum gdbm_nextkey(dbf, key);
166      int gdbm_reorganize(dbf);
167      void gdbm_sync(dbf);
168      int gdbm_exists(dbf, key);
169      char *gdbm_strerror(errno);
170      int gdbm_setopt(dbf, option, value, size);
171      int gdbm_fdesc(dbf);
172      int gdbm_export (GDBM_FILE, const char *, int, int);
173      int gdbm_export_to_file (GDBM_FILE dbf, FILE *fp);
174      int gdbm_import (GDBM_FILE, const char *, int);
175      int gdbm_import_from_file (GDBM_FILE dbf, FILE *fp, int flag);
176      int gdbm_count (GDBM_FILE dbf, gdbm_count_t *pcount);
177      int gdbm_version_cmp (int const a[], int const b[]);
178
179    The `gdbm.h' include file is often in the `/usr/local/include'
180 directory. (The actual location of `gdbm.h' depends on your local
181 installation of `gdbm'.)
182
183 \1f
184 File: gdbm.info,  Node: Open,  Next: Close,  Prev: List,  Up: Top
185
186 4 Opening the database.
187 ***********************
188
189  -- gdbm interface: GDBM_FILE gdbm_open (const char *NAME, int
190           BLOCK_SIZE, int FLAGS, int MODE, void (*fatal_func)(const
191           char *))
192      Initializes `gdbm' system.  If the file has a size of zero bytes,
193      a file initialization procedure is performed, setting up the
194      initial structure in the file.
195
196      The arguments are:
197
198     NAME
199           The name of the file (the complete name, `gdbm' does not
200           append any characters to this name).
201
202     BLOCK_SIZE
203           It is used during initialization to determine the size of
204           various constructs.  It is the size of a single transfer from
205           disk to memory.  This parameter is ignored if the file has
206           been previously initialized.  The minimum size is 512.  If
207           the value is less than 512, the file system block size is
208           used, otherwise the value of BLOCK_SIZE is used.
209
210     FLAGS
211           If `flags' is set to `GDBM_READER', the user wants to just
212           read the database and any call to `gdbm_store' or
213           `gdbm_delete' will fail.  Many readers can access the
214           database at the same time.  If `flags' is set to
215           `GDBM_WRITER', the user wants both read and write access to
216           the database and requires exclusive access.  If `flags' is set
217           to `GDBM_WRCREAT', the user wants both read and write access
218           to the database and wants it created if it does not already
219           exist.  If `flags' is set to `GDBM_NEWDB', the user want a
220           new database created, regardless of whether one existed, and
221           wants read and write access to the new database.
222
223           The following may also be logically or'd into the database
224           flags: `GDBM_SYNC', which causes all database operations to be
225           synchronized to the disk, `GDBM_NOLOCK', which prevents the
226           library from performing any locking on the database file, and
227           `GDBM_NOMMAP', which disables the memory mapping mechanism.
228           The option `GDBM_FAST' is now obsolete, since `gdbm' defaults
229           to no-sync mode.
230
231           If the host `open' call (*note open: (open(2))open.)
232           supports the `O_CLOEXEC' flag, the `GDBM_CLOEXEC' can be or'd
233           into the flags, to enable the close-on-exec flag for the
234           database file descriptor.
235
236     MODE
237           File mode (see *note change permissions of a file:
238           (chmod(2))chmod, and *note open a file: (open(2))open.),
239           which is used if the file is created).
240
241     FATAL_FUNC
242           A function for `gdbm' to call if it detects a fatal error.
243           The only parameter of this function is a string.  If the
244           value of `NULL' is provided, `gdbm' will use a default
245           function.
246
247      The return value, is the pointer needed by all other functions to
248      access that `gdbm' file.  If the return is the `NULL' pointer,
249      `gdbm_open' was not successful.  The errors can be found in
250      `gdbm_errno' variable (*note gdbm_errno: Variables.).  Available
251      error codes are discussed in *note Error codes::.
252
253      In all of the following calls, the parameter DBF refers to the
254      pointer returned from `gdbm_open'.
255
256 \1f
257 File: gdbm.info,  Node: Close,  Next: Count,  Prev: Open,  Up: Top
258
259 5 Closing the database.
260 ***********************
261
262 It is important that every file opened is also closed.  This is needed
263 to update the reader/writer count on the file:
264
265  -- gdbm interface: void gdbm_close (GDBM_FILE DBF)
266      This function closes the `gdbm' file and frees all memory
267      associated with it.  The parameter is:
268
269     DBF
270           The pointer returned by `gdbm_open'.
271
272 \1f
273 File: gdbm.info,  Node: Count,  Next: Store,  Prev: Close,  Up: Top
274
275 6 Number of Records
276 *******************
277
278  -- gdbm interface: int gdbm_count (GDBM_FILE DBF, gdbm_count_t *PCOUNT)
279      Counts number of records in the database DBF.  On success, stores
280      it in the memory location pointed to by PCOUNT and return 0.  On
281      error, sets `gdbm_errno' (if relevant, also `errno') and returns
282      -1.
283
284 \1f
285 File: gdbm.info,  Node: Store,  Next: Fetch,  Prev: Count,  Up: Top
286
287 7 Inserting and replacing records in the database.
288 **************************************************
289
290  -- gdbm interface: int gdbm_store (GDBM_FILE DBF, datum KEY, datum
291           CONTENT, int FLAG)
292      The function `gdbm_store' inserts or replaces records in the
293      database.
294
295      The parameters are:
296
297     DBF
298           The pointer returned by `gdbm_open'.
299
300     KEY
301           The search key.
302
303     CONTENT
304           The data to be associated with the key.
305
306     FLAG
307           Defines the action to take when the key is already in the
308           database.  The value `GDBM_REPLACE' (defined in `gdbm.h')
309           asks that the old data be replaced by the new CONTENT.  The
310           value `GDBM_INSERT' asks that an error be returned and no
311           action taken if the KEY already exists.
312
313      This function can return the following values:
314
315     -1
316           The item was not stored in the database because the caller
317           was not an official writer or either KEY or CONTENT have a
318           `NULL' `dptr' field.
319
320           Both KEY and CONTENT must have the `dptr' field be a
321           non-`NULL' value.  Since a `NULL' `dptr' field is used by
322           other functions to indicate an error, it cannot be valid data.
323
324     +1
325           The item was not stored because the argument FLAG was
326           `GDBM_INSERT' and the KEY was already in the database.
327
328     0
329           No error.  The value of CONTENT is keyed by KEY.  The file on
330           disk is updated to reflect the structure of the new database
331           before returning from this function.
332
333 If you store data for a KEY that is already in the data base, `gdbm'
334 replaces the old data with the new data if called with `GDBM_REPLACE'.
335 You do not get two data items for the same `key' and you do not get an
336 error from `gdbm_store'.
337
338    The size in `gdbm' is not restricted like `dbm' or `ndbm'.  Your
339 data can be as large as you want.
340
341 \1f
342 File: gdbm.info,  Node: Fetch,  Next: Delete,  Prev: Store,  Up: Top
343
344 8 Searching for records in the database.
345 ****************************************
346
347  -- gdbm interface: datum gdbm_fetch (GDBM_FILE DBF, datum KEY)
348      Looks up a given KEY and returns the information associated with
349      it.  The `dptr' field in the structure that is returned points to a
350      memory block allocated by `malloc'.  It is the caller's
351      responsibility to free it when no longer needed.
352
353      If the `dptr' is `NULL', no data was found.
354
355      The parameters are:
356
357     DBF
358           The pointer returned by `gdbm_open'.
359
360     KEY
361           The search key.
362
363 An example of using this function:
364
365      content = gdbm_fetch (dbf, key);
366      if (content.dptr == NULL)
367        {
368          fprintf(stderr, "key not found\n");
369        }
370      else
371        {
372          /* do something with content.dptr */
373        }
374
375    You may also search for a particular key without retrieving it:
376
377  -- gdbm interface: int gdbm_exists (GDBM_FILE DBF, datum KEY)
378      Returns `true' (`1') if the KEY exists in DBF and `false' (`0')
379      otherwise.
380
381      The parameters are:
382
383     DBF
384           The pointer returned by `gdbm_open'.
385
386     KEY
387           The search key.
388
389 \1f
390 File: gdbm.info,  Node: Delete,  Next: Sequential,  Prev: Fetch,  Up: Top
391
392 9 Removing records from the database.
393 *************************************
394
395 To remove some data from the database, use the `gdbm_delete' function.
396
397  -- gdbm interface: int gdbm_delete (GDBM_FILE DBF, datum KEY)
398      Deletes the data associated with the given KEY, if it exists in
399      the database DBF.  The file on disk is updated to reflect the
400      structure of the new database before returning from this function.
401
402      The parameters are:
403
404     DBF
405           The pointer returned by `gdbm_open'.
406
407     DATUM KEY
408           The search key.
409
410      The function returns `-1' if the item is not present or the
411      requester is a reader.  The return of `0' marks a successful
412      delete.
413
414 \1f
415 File: gdbm.info,  Node: Sequential,  Next: Reorganization,  Prev: Delete,  Up: Top
416
417 10 Sequential access to records.
418 ********************************
419
420 The next two functions allow for accessing all items in the database.
421 This access is not `key' sequential, but it is guaranteed to visit every
422 `key' in the database once.  The order has to do with the hash values.
423 `gdbm_firstkey' starts the visit of all keys in the database.
424 `gdbm_nextkey' finds and reads the next entry in the hash structure for
425 `dbf'.
426
427  -- gdbm interface: datum gdbm_firstkey (GDBM_FILE DBF)
428      Initiate sequential access to the database DBF.  The returned
429      value is the first key accessed in the database.  If the `dptr'
430      field in the returned datum is `NULL', the database contains no
431      data.
432
433      Otherwise, `dptr' points to a memory block obtained from `malloc',
434      which holds the key value.  The caller is responsible for freeing
435      this memory block when no longer needed.
436
437  -- gdbm interface: datum gdbm_nextkey (GDBM_FILE DBF, datum PREV)
438      This function continues the iteration over the keys in DBF,
439      initiated by `gdbm_firstkey'.  The parameter PREV holds the value
440      returned from a previous call to `gdbm_nextkey' or `gdbm_firstkey'.
441
442      The function returns next key from the database.  If the `dptr'
443      field in the returned datum is `NULL', all keys in the database
444      has been visited.
445
446      Otherwise, `dptr' points to a memory block obtained from `malloc',
447      which holds the key value.  The caller is responsible for freeing
448      this memory block when no longer needed.
449
450    These functions were intended to visit the database in read-only
451 algorithms, for instance, to validate the database or similar
452 operations.  The usual algorithm for sequential access is:
453
454         key = gdbm_firstkey (dbf);
455         while (key.dptr)
456           {
457              datum nextkey;
458
459              /* do something with the key */
460              ...
461
462              /* Obtain the next key */
463              nextkey = gdbm_nextkey (dbf, key);
464              /* Reclaim the memory used by the key */
465              free (key.dptr);
466              /* Use nextkey in the next iteration. */
467              key = nextkey;
468           }
469
470    Care should be taken when the `gdbm_delete' function is used in such
471 a loop.  File visiting is based on a "hash table".  The `gdbm_delete'
472 function re-arranges the hash table to make sure that any collisions in
473 the table do not leave some item "un-findable".  The original key order
474 is _not_ guaranteed to remain unchanged in all instances.  So it is
475 possible that some key will not be visited if a loop like the following
476 is executed:
477
478         key = gdbm_firstkey (dbf);
479         while (key.dptr)
480           {
481              datum nextkey;
482              if (some condition)
483                {
484                   gdbm_delete (dbf, key);
485                }
486               nextkey = gdbm_nextkey (dbf, key);
487               free (key.dptr);
488               key = nextkey;
489            }
490
491 \1f
492 File: gdbm.info,  Node: Reorganization,  Next: Sync,  Prev: Sequential,  Up: Top
493
494 11 Database reorganization.
495 ***************************
496
497 The following function should be used very seldom.
498
499  -- gdbm interface: int gdbm_reorganize (GDBM_FILE DBF)
500      Reorganizes the database.
501
502      The parameter is:
503
504     DBF
505           The pointer returned by `gdbm_open'.
506
507    If you have had a lot of deletions and would like to shrink the space
508 used by the `gdbm' file, this function will reorganize the database.
509 This results, in particular, in shortening the length of a `gdbm' file
510 by removing the space occupied by deleted records.
511
512    This reorganization requires creating a new file and inserting all
513 the elements in the old file DBF into the new file.  The new file is
514 then renamed to the same name as the old file and DBF is updated to
515 contain all the correct information about the new file.  If an error is
516 detected, the return value is negative.  The value zero is returned
517 after a successful reorganization.
518
519 \1f
520 File: gdbm.info,  Node: Sync,  Next: Flat files,  Prev: Reorganization,  Up: Top
521
522 12 Database Synchronization
523 ***************************
524
525 Unless your database was opened with the `GDBM_SYNC' flag, `gdbm' does
526 not wait for writes to be flushed to the disk before continuing.  This
527 allows for faster writing of databases at the risk of having a
528 corrupted database if the application terminates in an abnormal
529 fashion.  The following function allows the programmer to make sure the
530 disk version of the database has been completely updated with all
531 changes to the current time.
532
533  -- gdbm interface: void gdbm_sync (GDBM_FILE DBF)
534      Synchronizes the changes in DBF with its disk file.  The parameter
535      is a pointer returned by `gdbm_open'.
536
537      This function would usually be called after a complete set of
538      changes have been made to the database and before some long
539      waiting time.  The `gdbm_close' function automatically calls the
540      equivalent of `gdbm_sync' so no call is needed if the database is
541      to be closed immediately after the set of changes have been made.
542
543 \1f
544 File: gdbm.info,  Node: Flat files,  Next: Errors,  Prev: Sync,  Up: Top
545
546 13 Export and Import
547 ********************
548
549 `Gdbm' databases can be converted into so-called "flat format" files.
550 Such files cannot be used for searching, their sole purpose is to keep
551 the data from the database for restoring it when the need arrives.
552 There are two flat file formats, which differ in the way they represent
553 the data and in the amount of meta-information stored.  Both formats
554 can be used, for example, to migrate between the different versions of
555 `gdbm' databases.  Generally speaking, flat files are safe to send over
556 the network, and can be used to recreate the database on another
557 machine.  The recreated database is guaranteed to be a byte-to-byte
558 equivalent of the database from which the flat file was created.  This
559 does not necessarily mean, however, that this file can be used in the
560 same way as the original one.  For example, if the original database
561 contained non-ASCII data (e.g. C structures, integers etc.), the
562 recreated database can be of any use only if the target machine has the
563 same integer size and byte ordering as the source one and if its C
564 compiler uses the same packing conventions as the one which generated C
565 which populated the original database.  In general, such binary
566 databases are not portable between machines, unless you follow some
567 stringent rules on what data is written to them and how it is
568 interpreted.
569
570    The GDBM version 1.11 supports two flat file formats.  The "binary"
571 flat file format was first implemented in GDBM version 1.9.1.  This
572 format stores only key/data pairs, it does not keep information about
573 the database file itself.  As its name implies, files in this format
574 are binary files.
575
576    The "ascii" flat file format encodes all data in base64 and stores
577 not only key/data pairs, but also the original database file metadata,
578 such as file name, mode and ownership.  Files in this format can be
579 sent without additional encapsulation over transmission channels that
580 normally allow only ASCII data, such as, e.g. SMTP.  Due to additional
581 metadata they allow for restoring an exact copy of the database,
582 including file ownership and privileges, which is especially important
583 if the database in question contained some security-related data.
584
585    We call a process of creating a flat file from a database
586 "exporting" or "dumping" this database.  The reverse process, creating
587 the database from a flat file is called "importing" or "loading" the
588 database.
589
590  -- gdbm interface: int gdbm_dump (GDBM_FILE DBF, const char *FILENAME,
591           int FORMAT, int OPEN_FLAGS, int MODE)
592      Dumps the database file to the named file in requested format.
593      Arguments are:
594
595     DBF
596           A pointer to the source database, returned by a prior call to
597           `gdbm_open'.
598
599     FILENAME
600           Name of the dump file.
601
602     FORMAT
603           Output file format.  Allowed values are:
604           `GDBM_DUMP_FMT_BINARY' to create a binary dump and
605           `GDBM_DUMP_FMT_ASCII' to create an ASCII dump file.
606
607     OPEN_FLAGS
608           How to create the output file.  If FLAG is `GDBM_WRCREAT' the
609           file will be created if it does not exist.  If it does exist,
610           the `gdbm_dump' will fail.
611
612           If FLAG is `GDBM_NEWDB', the function will create a new
613           output file, replacing it if it already exists.
614
615     MODE
616           The permissions to use when creating the output file.  See
617           *note open a file: (open(2))open, for a detailed discussion.
618
619  -- gdbm interface: int gdbm_load (GDBM_FILE *PDBF, const char
620           *FILENAME, int FLAG, int META_MASK, unsigned long *ERRLINE)
621      Loads data from the dump file FILENAME into the database pointed
622      to by PDBF.  The latter can point to `NULL', in which case the
623      function will try to create a new database.  If it succeeds, the
624      function will return, in the memory location pointed to by PDBF, a
625      pointer to the newly created database.  If the dump file carries no
626      information about the original database file name, the function
627      will set `gdbm_errno' to `GDBM_NO_DBNAME' and return `-1',
628      indicating failure.
629
630      The FLAG has the same meaning as the FLAG argument to the
631      `gdbm_store' function (*note Store::).
632
633      The META_MASK argument can be used to disable restoring certain
634      bits of file's meta-data from the information in the input dump
635      file.  It is a binary OR of zero or more of the following:
636
637     GDBM_META_MASK_MODE
638           Do not restore file mode.
639
640     GDBM_META_MASK_OWNER
641           Do not restore file owner.
642
643      The function returns 0 upon successful completion or -1 on fatal
644      errors and 1 on mild (non-fatal) errors.
645
646      If a fatal error occurs, `gdbm_errno' will be set to one of the
647      following values:
648
649     GDBM_FILE_OPEN_ERROR
650           Input file (FILENAME) cannot be opened.  The `errno' variable
651           can be used to get more detail about the failure.
652
653     GDBM_MALLOC_ERROR
654           Not enough memory to load data.
655
656     GDBM_FILE_READ_ERROR
657           Reading from FILENAME failed.  The `errno' variable can be
658           used to get more detail about the failure.
659
660     GDBM_ILLEGAL_DATA
661           Input contained some illegal data.
662
663     GDBM_ITEM_NOT_FOUND
664           This error can occur only when the input file is in ASCII
665           format.  It indicates that the data part of the record about
666           to be read lacked length specification.  Application
667           developers are advised to treat this error equally as
668           `GDBM_ILLEGAL_DATA'.
669
670      Mild errors mean that the function was able to successfully load
671      and restore the data, but was unable to change database file
672      metadata afterward.  The table below lists possible values for
673      `gdbm_errno' in this case.  To get more detail, inspect the system
674      `errno' variable.
675
676     GDBM_ERR_FILE_OWNER
677           The function was unable to restore database file owner.
678
679     GDBM_ERR_FILE_MODE
680           The function was unable to restore database file mode
681           (permission bits).
682
683      If an error occurs while loading data from an input file in ASCII
684      format, the number of line in which the error occurred will be
685      stored in the location pointed to by the ERRLINE parameter, unless
686      it is `NULL'.
687
688      If the line information is not available or applicable, ERRLINE
689      will be set to `0'.
690
691  -- gdbm interface: int gdbm_dump_to_file (GDBM_FILE DBF, FILE *FP, int
692           FORMAT)
693      This is an alternative entry point to `gdbm_dump' (which see).
694      Arguments are:
695
696     DBF
697           A pointer to the source database, returned by a call to
698           `gdbm_open'.
699
700     FP
701           File to write the data to.
702
703     FORMAT
704           Format of the dump file.  See the FORMAT argument to the
705           `gdbm_dump' function.
706
707  -- gdbm interface: int gdbm_load_from_file (GDBM_FILE *PDBF, FILE *FP,
708           int REPLACE, int META_MASK, unsigned long *LINE)
709      This is an alternative entry point to `gdbm_dump'.  It writes the
710      output to FP which must be a file open for writing.  The rest of
711      arguments is the same as for `gdbm_load' (excepting of course
712      FLAG, which is not needed in this case).
713
714  -- gdbm interface: int gdbm_export (GDBM_FILE DBF, const char
715           *EXPORTFILE, int FLAG, int MODE)
716      This function is retained for compatibility with GDBM 1.10 and
717      earlier.  It dumps the database to a file in binary dump format and
718      is entirely equivalent to
719
720           gdbm_dump(DBF, EXPORTFILE, GDBM_DUMP_FMT_BINARY,
721                     FLAG, MODE)
722
723
724  -- gdbm interface: int gdbm_export_to_file (GDBM_FILE DBF, FILE *FP)
725      This is an alternative entry point to `gdbm_export'.  This
726      function writes to file FP a binary dump of the database DBF.
727
728  -- gdbm interface: int gdbm_import (GDBM_FILE DBF, const char
729           *IMPORTFILE, int FLAG)
730      This function is retained for compatibility with GDBM 1.10 and
731      earlier.  It loads the file IMPORTFILE, which must be a binary
732      flat file, into the database DBF and is equivalent to the
733      following construct:
734
735           DBF = gdbm_open (IMPORTFILE, 0,
736                                  FLAG == GDBM_REPLACE ?
737                                    GDBM_WRCREAT : GDBM_NEWDB,
738                                  0600, NULL);
739           gdbm_load (&DBF, EXPORTFILE, 0, FLAG, NULL)
740
741  -- gdbm interface: int gdbm_import_from_file (GDBM_FILE DBF, FILE *FP,
742           int FLAG)
743      An alternative entry point to `gdbm_import'.  Reads the binary
744      dump from the file FP and stores the key/value pairs to DBF.
745      *Note Store::, for a description of FLAG.
746
747      This function is equivalent to:
748
749           DBF = gdbm_open (IMPORTFILE, 0,
750                                  FLAG == GDBM_REPLACE ?
751                                    GDBM_WRCREAT : GDBM_NEWDB,
752                                  0600, NULL);
753           gdbm_load_from_file (DBF, FP, FLAG, 0, NULL);
754
755 \1f
756 File: gdbm.info,  Node: Errors,  Next: Options,  Prev: Flat files,  Up: Top
757
758 14 Error strings.
759 *****************
760
761 To convert a `gdbm' error code into English text, use this routine:
762
763  -- gdbm interface: const char * gdbm_strerror (gdbm_error ERRNO)
764      Converts ERRNO (which is an integer value) into a human-readable
765      descriptive text.  Returns a pointer to a static string.  The
766      caller must not alter or free the returned pointer.
767
768      The ERRNO argument is usually the value of the global variable
769      `gdbm_errno'.  *Note gdbm_errno: Variables.
770
771 \1f
772 File: gdbm.info,  Node: Options,  Next: Locking,  Prev: Errors,  Up: Top
773
774 15 Setting options
775 ******************
776
777 `Gdbm' supports the ability to set certain options on an already open
778 database.
779
780  -- gdbm interface: int gdbm_setopt (GDBM_FILE DBF, int OPTION, void
781           *VALUE, int SIZE)
782      Sets an option on the database or returns the value of an option.
783
784      The parameters are:
785
786     DBF
787           The pointer returned by `gdbm_open'.
788
789     OPTION
790           The option to be set or retrieved.
791
792     VALUE
793           A pointer to the value to which OPTION will be set or where to
794           place the option value (depending on the option).
795
796     SIZE
797           The length of the data pointed to by VALUE.
798
799    The valid options are:
800
801 GDBM_SETCACHESIZE
802 GDBM_CACHESIZE
803      Set the size of the internal bucket cache.  This option may only be
804      set once on each GDBM_FILE descriptor, and is set automatically to
805      100 upon the first access to the database.  The VALUE should point
806      to a `size_t' holding the desired cache size.
807
808      The `GDBM_CACHESIZE' option is provided for compatibility with
809      earlier versions.
810
811 GDBM_GETCACHESIZE
812      Return the size of the internal bucket cache.  The VALUE should
813      point to a `size_t' variable, where the size will be stored.
814
815 GDBM_GETFLAGS
816      Return the flags describing the state of the database.  The VALUE
817      should point to a `int' variable where to store the flags.  The
818      return is the same as the flags used when opening the database
819      (*note gdbm_open: Open.), except that it reflects the current
820      state (which may have been altered by another calls to
821      `gdbm_setopt'.
822
823 GDBM_FASTMODE
824      Enable or disable the "fast writes mode", i.e. writes without
825      subsequent synchronization.  The VALUE should point to an integer:
826      `TRUE' to enable fast mode, and `FALSE' to disable it.
827
828      This option is retained for compatibility with previous versions of
829      `gdbm'.  Its effect is the reverse of `GDBM_SETSYNCMODE' (see
830      below).
831
832 GDBM_SETSYNCMODE
833 GDBM_SYNCMODE
834      Turn on or off file system synchronization operations.  This
835      setting defaults to off.  The VALUE should point to an integer:
836      `TRUE' to turn synchronization on, and `FALSE' to turn it off.
837
838      Note, that this option is a reverse of `GDBM_FASTMODE', i.e.
839      calling `GDBM_SETSYNCMODE' with `TRUE' has the same effect as
840      calling `GDBM_FASTMODE' with `FALSE'.
841
842      The `GDBM_SYNCMODE' option is provided for compatibility with
843      earlier versions.
844
845 GDBM_GETSYNCMODE
846      Return the current synchronization status.  The VALUE should point
847      to an `int' where the status will be stored.
848
849 GDBM_SETCENTFREE
850 GDBM_CENTFREE
851      _NOTICE: This feature is still under study._
852
853      Set central free block pool to either on or off.  The default is
854      off, which is how previous versions of `gdbm' handled free blocks.
855      If set, this option causes all subsequent free blocks to be placed
856      in the _global_ pool, allowing (in theory) more file space to be
857      reused more quickly.  The VALUE should point to an integer: `TRUE'
858      to turn central block pool on, and `FALSE' to turn it off.
859
860      The `GDBM_CENTFREE' option is provided for compatibility with
861      earlier versions.
862
863 GDBM_SETCOALESCEBLKS
864 GDBM_COALESCEBLKS
865      _NOTICE: This feature is still under study._
866
867      Set free block merging to either on or off.  The default is off,
868      which is how previous versions of `gdbm' handled free blocks.  If
869      set, this option causes adjacent free blocks to be merged.  This
870      can become a CPU expensive process with time, though, especially if
871      used in conjunction with GDBM_CENTFREE.  The VALUE should point to
872      an integer: `TRUE' to turn free block merging on, and `FALSE' to
873      turn it off.
874
875 GDBM_GETCOALESCEBLKS
876      Return the current status of free block merging.  The VALUE should
877      point to an `int' where the status will be stored.
878
879 GDBM_SETMAXMAPSIZE
880      Sets maximum size of a memory mapped region.  The VALUE should
881      point to a value of type `size_t', `unsigned long' or `unsigned'.
882      The actual value is rounded to the nearest page boundary (the page
883      size is obtained from `sysconf(_SC_PAGESIZE)').
884
885 GDBM_GETMAXMAPSIZE
886      Return the maximum size of a memory mapped region.  The VALUE
887      should point to a value of type `size_t' where to return the data.
888
889 GDBM_SETMMAP
890      Enable or disable memory mapping mode.  The VALUE should point to
891      an integer: `TRUE' to enable memory mapping or `FALSE' to disable
892      it.
893
894 GDBM_GETMMAP
895      Check whether memory mapping is enabled.  The VALUE should point
896      to an integer where to return the status.
897
898 GDBM_GETDBNAME
899      Return the name of the database disk file.  The VALUE should point
900      to a variable of type `char**'.  A pointer to the newly allocated
901      copy of the file name will be placed there.  The caller is
902      responsible for freeing this memory when no longer needed.  For
903      example:
904
905           char *name;
906
907           if (gdbm_setopt (dbf, GDBM_GETDBNAME, &name, sizeof (name)))
908             {
909                fprintf (stderr, "gdbm_setopt failed: %s\n",
910                         gdbm_strerror (gdbm_errno));
911             }
912           else
913             {
914               printf ("database name: %s\n", name);
915               free (name);
916             }
917
918
919    The return value will be `-1' upon failure, or `0' upon success.
920 The global variable `gdbm_errno' will be set upon failure.
921
922    For instance, to set a database to use a cache of 10, after opening
923 it with `gdbm_open', but prior to accessing it in any way, the following
924 code could be used:
925
926      int value = 10;
927      ret = gdbm_setopt (dbf, GDBM_CACHESIZE, &value, sizeof (int));
928
929 \1f
930 File: gdbm.info,  Node: Locking,  Next: Error codes,  Prev: Options,  Up: Top
931
932 16 File Locking.
933 ****************
934
935 With locking disabled (if `gdbm_open' was called with `GDBM_NOLOCK'),
936 the user may want to perform their own file locking on the database file
937 in order to prevent multiple writers operating on the same file
938 simultaneously.
939
940    In order to support this, the `gdbm_fdesc' routine is provided.
941
942  -- gdbm interface: int gdbm_fdesc (GDBM_FILE DBF)
943      Returns the file descriptor of the database DBF.  This value can
944      be used as an argument to `flock', `lockf' or similar calls.
945
946 \1f
947 File: gdbm.info,  Node: Variables,  Next: Compatibility,  Prev: Error codes,  Up: Top
948
949 17 Useful global variables.
950 ***************************
951
952 The following global variables and constants are available:
953
954  -- Variable: gdbm_error gdbm_errno
955      This variable contains error code from the last failed `gdbm'
956      call.  *Note Error codes::, for a list of available error codes and
957      their descriptions.
958
959      Use `gdbm_strerror' (*note Errors::) to convert it to a
960      descriptive text.
961
962  -- Variable: const char * gdbm_errlist[]
963      This variable is an array of error descriptions, which is used by
964      `gdbm_strerror' to convert error codes to human-readable text
965      (*note Errors::).  You can access it directly, if you wish so.  It
966      contains `_GDBM_MAX_ERRNO + 1' elements and can be directly
967      indexed by the error code to obtain a corresponding descriptive
968      text.
969
970  -- Constant: _GDBM_MIN_ERRNO
971      The minimum error code used by `gdbm'.
972
973  -- Constant: _GDBM_MAX_ERRNO
974      The maximum error code used by `gdbm'.
975
976  -- Variable: const char * gdbm_version
977      A string containing the version information.
978
979  -- Variable: int const gdbm_version_number[3]
980      This variable contains the `gdbm' version numbers:
981
982      Index                       Meaning
983      --------------------------------------------------------------- 
984      0                           Major number
985      1                           Minor number
986      2                           Patchlevel number
987
988      Additionally, the following constants are defined in the `gdbm.h'
989      file:
990
991     GDBM_VERSION_MAJOR
992           Major number.
993
994     GDBM_VERSION_MINOR
995           Minor number.
996
997     GDBM_VERSION_PATCH
998           Patchlevel number.
999
1000      These can be used to verify whether the header file matches the
1001      library.
1002
1003    To compare two split-out version numbers, use the following function:
1004
1005  -- gdbm interface: int gdbm_version_cmp (int const A[3], int const
1006           B[3])
1007      Compare two version numbers.  Return `-1' if A is less than B, `1'
1008      if A is greater than B and `0' if they are equal.
1009
1010      Comparison is done from left to right, so that:
1011
1012           a = { 1, 8, 3 };
1013           b = { 1, 8, 3 };
1014           gdbm_version_cmp (a, b) => 0
1015
1016           a = { 1, 8, 3 };
1017           b = { 1, 8, 2 };
1018           gdbm_version_cmp (a, b) => 1
1019
1020           a = { 1, 8, 3 };
1021           b = { 1, 9. 0 };
1022           gdbm_version_cmp (a, b) => -1
1023
1024 \1f
1025 File: gdbm.info,  Node: Error codes,  Next: Variables,  Prev: Locking,  Up: Top
1026
1027 18 Error codes
1028 **************
1029
1030 This chapter summarizes error codes which can be set by the functions
1031 in `gdbm' library.
1032
1033 GDBM_NO_ERROR
1034      No error occurred.
1035
1036 GDBM_MALLOC_ERROR
1037      Memory allocation failed.  Not enough memory.
1038
1039 GDBM_BLOCK_SIZE_ERROR
1040      This error is set by the `gdbm_open' function (*note Open::), if
1041      the value of its BLOCK_SIZE argument is incorrect.
1042
1043 GDBM_FILE_OPEN_ERROR
1044      The library was not able to open a disk file.  This can be set by
1045      `gdbm_open' (*note Open::), `gdbm_export' and `gdbm_import'
1046      functions (*note Flat files::).
1047
1048      Inspect the value of the system `errno' variable to get more
1049      detailed diagnostics.
1050
1051 GDBM_FILE_WRITE_ERROR
1052      Writing to a disk file failed.  This can be set by `gdbm_open'
1053      (*note Open::), `gdbm_export' and `gdbm_import' functions.
1054
1055      Inspect the value of the system `errno' variable to get more
1056      detailed diagnostics.
1057
1058 GDBM_FILE_SEEK_ERROR
1059      Positioning in a disk file failed.  This can be set by `gdbm_open'
1060      (*note Open::) function.
1061
1062      Inspect the value of the system `errno' variable to get a more
1063      detailed diagnostics.
1064
1065 GDBM_FILE_READ_ERROR
1066      Reading from a disk file failed.  This can be set by `gdbm_open'
1067      (*note Open::), `gdbm_export' and `gdbm_import' functions.
1068
1069      Inspect the value of the system `errno' variable to get a more
1070      detailed diagnostics.
1071
1072 GDBM_BAD_MAGIC_NUMBER
1073      The file given as argument to `gdbm_open' function is not a valid
1074      `gdbm' file: it has a wrong magic number.
1075
1076 GDBM_EMPTY_DATABASE
1077      The file given as argument to `gdbm_open' function is not a valid
1078      `gdbm' file: it has zero length.
1079
1080 GDBM_CANT_BE_READER
1081      This error code is set by the `gdbm_open' function if it is not
1082      able to lock file when called in `GDBM_READER' mode (*note
1083      GDBM_READER: Open.).
1084
1085 GDBM_CANT_BE_WRITER
1086      This error code is set by the `gdbm_open' function if it is not
1087      able to lock file when called in writer mode (*note Open::).
1088
1089 GDBM_READER_CANT_DELETE
1090      Set by the `gdbm_delete' (*note Delete::) if it attempted to
1091      operate on a database that is open in read-only mode (*note
1092      GDBM_READER: Open.).
1093
1094 GDBM_READER_CANT_STORE
1095      Set by the `gdbm_store' (*note Store::) if it attempted to operate
1096      on a database that is open in read-only mode (*note GDBM_READER:
1097      Open.).
1098
1099 GDBM_READER_CANT_REORGANIZE
1100      Set by the `gdbm_reorganize' (*note Reorganization::) if it
1101      attempted to operate on a database that is open in read-only mode
1102      (*note GDBM_READER: Open.).
1103
1104 GDBM_UNKNOWN_UPDATE
1105      Currently unused.  Reserved for future uses.
1106
1107 GDBM_ITEM_NOT_FOUND
1108      Requested item was not found.  This error is set by `gdbm_delete'
1109      (*note Delete::) and `gdbm_fetch' (*note Fetch::) when the
1110      requested KEY value is not found in the database.
1111
1112 GDBM_REORGANIZE_FAILED
1113      The `gdbm_reorganize' function is not able to create a temporary
1114      database.  *Note Reorganization::.
1115
1116 GDBM_CANNOT_REPLACE
1117      Cannot replace existing item.  This error is set by the
1118      `gdbm_store' if the requested KEY value is found in the database
1119      and the FLAG parameter is not `GDBM_REPLACE'.  *Note Store::, for
1120      a detailed discussion.
1121
1122 GDBM_ILLEGAL_DATA
1123      Either KEY or CONTENT parameter was wrong in a call to to
1124      `gdbm_store' (*note Store::).
1125
1126 GDBM_OPT_ALREADY_SET
1127      Requested option can be set only once and was already set.  This
1128      error is returned by the `gdbm_setopt' function.  *Note
1129      GDBM_CACHESIZE: Options.
1130
1131 GDBM_OPT_ILLEGAL
1132      The OPTION argument is not valid or the VALUE argument points to
1133      an invalid value in a call to `gdbm_setopt' function.  *Note
1134      Options::.
1135
1136 GDBM_BYTE_SWAPPED
1137      The `gdbm_open' function (*note Open::) attempts to open a
1138      database which is created on a machine with different byte
1139      ordering.
1140
1141 GDBM_BAD_FILE_OFFSET
1142      The `gdbm_open' function (*note Open::) sets this error code if
1143      the file it tries to open has a wrong magic number.
1144
1145 GDBM_BAD_OPEN_FLAGS
1146      Set by the `gdbm_export' function if supplied an invalid FLAGS
1147      argument.  *Note Flat files::.
1148
1149 GDBM_FILE_STAT_ERROR
1150      Getting information about a disk file failed.  The system `errno'
1151      will give more details about the error.
1152
1153      This error can be set by the following functions: `gdbm_open',
1154      `gdbm_reorganize'.
1155
1156 GDBM_FILE_EOF
1157      End of file was encountered where more data was expected to be
1158      present.  This error can occur when fetching data from the database
1159      and usually means that the database is truncated or otherwise
1160      corrupted.
1161
1162      This error can be set by any GDBM function that does I/O.  Some of
1163      these functions are: `gdbm_delete', `gdbm_exists', `gdbm_fetch',
1164      `gdbm_export', `gdbm_import', `gdbm_reorganize', `gdbm_firstkey',
1165      `gdbm_nextkey', `gdbm_store'.
1166
1167 GDBM_NO_DBNAME
1168      Output database name is not specified.  This error code is set by
1169      `gdbm_load' (*note gdbm_load: gdbm_load function.) if the first
1170      argument points to `NULL' and the input file does not specify the
1171      database name.
1172
1173 GDBM_ERR_FILE_OWNER
1174      This error code is set by `gdbm_load' if it is unable to restore
1175      database file owner.  It is a mild error condition, meaning that
1176      the data have been restored successfully, only changing the target
1177      file owner failed.  Inspect the system `errno' variable to get a
1178      more detailed diagnostics.
1179
1180 GDBM_ERR_FILE_MODE
1181      This error code is set by `gdbm_load' if it is unable to restore
1182      database file mode.  It is a mild error condition, meaning that
1183      the data have been restored successfully, only changing the target
1184      file owner failed.  Inspect the system `errno' variable to get a
1185      more detailed diagnostics.
1186
1187
1188 \1f
1189 File: gdbm.info,  Node: Compatibility,  Next: gdbmtool,  Prev: Variables,  Up: Top
1190
1191 19 Compatibility with standard `dbm' and `ndbm'.
1192 ************************************************
1193
1194 `Gdbm' includes a compatibility layer, which provides traditional
1195 `ndbm' and older `dbm' functions.  The layer is compiled and installed
1196 if the `--enable-libgdbm-compat' option is used when configuring the
1197 package.
1198
1199    The compatibility layer consists of two header files: `ndbm.h' and
1200 `dbm.h' and the `libgdbm_compat' library.
1201
1202    Older programs using `ndbm' or `dbm' interfaces can use
1203 `libgdbm_compat' without any changes.  To link a program with the
1204 compatibility library, add the following two options to the `cc'
1205 invocation: `-lgdbm -lgdbm_compat'.  The `-L' option may also be
1206 required, depending on where `gdbm' is installed, e.g.:
1207
1208      cc ... -L/usr/local/lib -lgdbm -lgdbm_compat
1209
1210    Databases created and manipulated by the compatibility interfaces
1211 consist of two different files: `FILE.dir' and `FILE.pag'.  This is
1212 required by the POSIX specification and corresponds to the traditional
1213 usage.  Note, however, that despite the similarity of the naming
1214 convention, actual data stored in these files has not the same format as
1215 in the databases created by other `dbm' or `ndbm' libraries.  In other
1216 words, you cannot access a standard UNIX `dbm' file with GNU `dbm'!
1217
1218    GNU `dbm' files are not `sparse'.  You can copy them with the usual
1219 `cp' command and they will not expand in the copying process.
1220
1221 * Menu:
1222
1223 * ndbm::  NDBM interface functions.
1224 * dbm::   DBM interface functions.
1225
1226 \1f
1227 File: gdbm.info,  Node: ndbm,  Next: dbm,  Up: Compatibility
1228
1229 19.1 NDBM interface functions.
1230 ==============================
1231
1232 The functions below implement the POSIX `ndbm' interface:
1233
1234  -- ndbm: DBM * dbm_open (char *FILE, int FLAGS, int MODE)
1235      Opens a database.  The FILE argument is the full name of the
1236      database file to be opened.  The function opens two files:
1237      `FILE.pag' and `FILE.dir'.  The FLAGS and MODE arguments have the
1238      same meaning as the second and third arguments of `open' (*note
1239      open a file: (open(2))open.), except that a database opened for
1240      write-only access opens the files for read and write access and
1241      the behavior of the `O_APPEND' flag is unspecified.
1242
1243      The function returns a pointer to the `DBM' structure describing
1244      the database.  This pointer is used to refer to this database in
1245      all operations described below.
1246
1247      Any error detected will cause a return value of `NULL' and an
1248      appropriate value will be stored in `gdbm_errno' (*note
1249      Variables::).
1250
1251  -- ndbm: void dbm_close (DBM *DBF)
1252      Closes the database.  The DBF argument must be a pointer returned
1253      by an earlier call to `dbm_open'.
1254
1255  -- ndbm: datum dbm_fetch (DBM *DBF, datum KEY)
1256      Reads a record from the database with the matching key.  The KEY
1257      argument supplies the key that is being looked for.
1258
1259      If no matching record is found, the `dptr' member of the returned
1260      datum is `NULL'.  Otherwise, the `dptr' member of the returned
1261      datum points to the memory managed by the compatibility library.
1262      The application should never free it.
1263
1264  -- ndbm: int dbm_store (DBM *DBF, datum KEY, datum CONTENT, int MODE)
1265      Writes a key/value pair to the database.  The argument DBF is a
1266      pointer to the `DBM' structure returned from a call to `dbm_open'.
1267      The KEY and CONTENT provide the values for the record key and
1268      content.  The MODE argument controls the behavior of `dbm_store'
1269      in case a matching record already exists in the database.  It can
1270      have one of the following two values:
1271
1272     `DBM_REPLACE'
1273           Replace existing record with the new one.
1274
1275     `DBM_INSERT'
1276           The existing record is left unchanged, and the function
1277           returns `1'.
1278
1279      If no matching record exists in the database, new record will be
1280      inserted no matter what the value of the MODE is.
1281
1282  -- ndbm: int dbm_delete (DBM *DBF, datum KEY)
1283      Deletes the record with the matching key from the database.  If the
1284      function succeeds, `0' is returned.  Otherwise, if no matching
1285      record is found or if an error occurs, `-1' is returned.
1286
1287  -- ndbm: datum dbm_firstkey (DBM *DBF)
1288      Initializes iteration over the keys from the database and returns
1289      the first key.  Note, that the word `first' does not imply any
1290      specific ordering of the keys.
1291
1292      If there are no records in the database, the `dptr' member of the
1293      returned datum is `NULL'.  Otherwise, the `dptr' member of the
1294      returned datum points to the memory managed by the compatibility
1295      library.  The application should never free it.
1296
1297  -- ndbm: datum dbm_nextkey (DBM *DBF)
1298      Continues the iteration started by `dbm_firstkey'.  Returns the
1299      next key in the database.  If the iteration covered all keys in the
1300      database, the `dptr' member of the returned datum is `NULL'.
1301      Otherwise, the `dptr' member of the returned datum points to the
1302      memory managed by the compatibility library.  The application
1303      should never free it.
1304
1305      The usual way of iterating over all the records in the database is:
1306
1307           for (key = dbm_firstkey (dbf);
1308                key.ptr;
1309                key = dbm_nextkey (dbf))
1310             {
1311               /* do something with the key */
1312             }
1313
1314      The loop above should not try to delete any records from the
1315      database, otherwise the iteration is not guaranteed to cover all
1316      the keys.  *Note Sequential::, for a detailed discussion of this.
1317
1318  -- ndbm: int dbm_error (DBM *DBF)
1319      Returns the error condition of the database: `0' if no errors
1320      occurred so far while manipulating the database, and a non-zero
1321      value otherwise.
1322
1323  -- ndbm: void dbm_clearerr (DBM *DBF)
1324      Clears the error condition of the database.
1325
1326  -- ndbm: int dbm_dirfno (DBM *DBF)
1327      Returns the file descriptor of the `dir' file of the database.  It
1328      is guaranteed to be different from the descriptor returned by the
1329      `dbm_pagfno' function (see below).
1330
1331      The application can lock this descriptor to serialize accesses to
1332      the database.
1333
1334  -- ndbm: int dbm_pagfno (DBM *DBF)
1335      Returns the file descriptor of the `pag' file of the database.
1336      See also `dbm_dirfno'.
1337
1338  -- ndbm: int dbm_rdonly (DBM *DBF)
1339      Returns `1' if the database DBF is open in a read-only mode and
1340      `0' otherwise.
1341
1342 \1f
1343 File: gdbm.info,  Node: dbm,  Prev: ndbm,  Up: Compatibility
1344
1345 19.2 DBM interface functions.
1346 =============================
1347
1348 The functions below are provided for compatibility with the old UNIX
1349 `DBM' interface.  Only one database at a time can be manipulated using
1350 them.
1351
1352  -- dbm: int dbminit (char *FILE)
1353      Opens a database.  The FILE argument is the full name of the
1354      database file to be opened.  The function opens two files:
1355      `FILE.pag' and `FILE.dir'.  If any of them does not exist, the
1356      function fails.  It never attempts to create the files.
1357
1358      The database is opened in the read-write mode, if its disk
1359      permissions permit.
1360
1361      The application must ensure that the functions described below in
1362      this section are called only after a successful call to `dbminit'.
1363
1364  -- dbm: int dbmclose (void)
1365      Closes the database opened by an earlier call to `dbminit'.
1366
1367  -- dbm: datum fetch (datum KEY)
1368      Reads a record from the database with the matching key.  The KEY
1369      argument supplies the key that is being looked for.
1370
1371      If no matching record is found, the `dptr' member of the returned
1372      datum is `NULL'.  Otherwise, the `dptr' member of the returned
1373      datum points to the memory managed by the compatibility library.
1374      The application should never free it.
1375
1376  -- dbm: int store (datum KEY, datum CONTENT)
1377      Stores the key/value pair in the database.  If a record with the
1378      matching key already exists, its content will be replaced with the
1379      new one.
1380
1381      Returns `0' on success and `-1' on error.
1382
1383  -- dbm: int delete (datum KEY)
1384      Deletes a record with the matching key.
1385
1386      If the function succeeds, `0' is returned.  Otherwise, if no
1387      matching record is found or if an error occurs, `-1' is returned.
1388
1389  -- dbm: datum firstkey (void)
1390      Initializes iteration over the keys from the database and returns
1391      the first key.  Note, that the word `first' does not imply any
1392      specific ordering of the keys.
1393
1394      If there are no records in the database, the `dptr' member of the
1395      returned datum is `NULL'.  Otherwise, the `dptr' member of the
1396      returned datum points to the memory managed by the compatibility
1397      library.  The application should never free it.
1398
1399  -- dbm: datum nextkey (datum KEY)
1400      Continues the iteration started by a call to `firstkey'.  Returns
1401      the next key in the database.  If the iteration covered all keys
1402      in the database, the `dptr' member of the returned datum is `NULL'.
1403      Otherwise, the `dptr' member of the returned datum points to the
1404      memory managed by the compatibility library.  The application
1405      should never free it.
1406
1407 \1f
1408 File: gdbm.info,  Node: gdbmtool,  Next: gdbm_dump,  Prev: Compatibility,  Up: Top
1409
1410 20 Examine and modify a GDBM database.
1411 **************************************
1412
1413 The `gdbmtool' utility allows you to view and modify an existing GDBM
1414 database or to create a new one.
1415
1416    When invoked without arguments, it tries to open a database file
1417 called `junk.gdbm', located in the current working directory.  You can
1418 change this default by supplying the name of the database to use as an
1419 argument to the program, e.g.:
1420
1421      $ gdbmtool file.db
1422
1423    The database will be opened in read-write mode, unless the `-r'
1424 (`--read-only') option is specified, in which case it will be opened
1425 only for reading.
1426
1427    If the database does not exist, `gdbmtool' will create it.  There is
1428 a special option `-n' (`--newdb', which instructs the utility to create
1429 a new database.  If it is used and if the database already exists, it
1430 will be deleted, so use it sparingly.
1431
1432 * Menu:
1433
1434 * invocation::
1435 * shell::
1436
1437 \1f
1438 File: gdbm.info,  Node: invocation,  Next: shell,  Up: gdbmtool
1439
1440 20.1 gdbmtool invocation
1441 ========================
1442
1443 The following table summarizes all `gdbmtool' command line options:
1444
1445 `-b SIZE'
1446 `--block-size=SIZE'
1447      Set block size.
1448
1449 `-c SIZE'
1450 `--cache-size=SIZE'
1451      Set cache size.
1452
1453 `-f FILE'
1454
1455 `--file FILE'
1456      Read commands from FILE, instead of the standard input.
1457
1458 `-h'
1459 `--help'
1460      Print a concise help summary.
1461
1462 `-N'
1463 `--norc'
1464      Don't read startup files (*note startup files::).
1465
1466 `-n'
1467 `--newdb'
1468      Create the database.
1469
1470 `-l'
1471 `--no-lock'
1472      Disable file locking.
1473
1474 `-m'
1475 `--no-mmap'
1476      Disable mmap.
1477
1478 `-q'
1479 `--quiet'
1480      Don't print the usual welcome banner at startup.  This is the same
1481      as setting the variable `quiet' in the startup file.  *Note
1482      quiet::.
1483
1484 `-r'
1485 `--read-only'
1486      Open the database in read-only mode.
1487
1488 `-s'
1489 `--synchronize'
1490      Synchronize to the disk after each write.
1491
1492 `-V'
1493 `--version'
1494      Print program version and licensing information and exit.
1495
1496 `--usage'
1497      Print a terse invocation syntax summary along with a list of
1498      available command line options.
1499
1500 \1f
1501 File: gdbm.info,  Node: shell,  Prev: invocation,  Up: gdbmtool
1502
1503 20.2 gdbmtool interactive mode
1504 ==============================
1505
1506 After successful startup, `gdbmtool' starts a loop, in which it reads
1507 commands from the standard input, executes them and prints the results
1508 on the standard output.  If the standard input is attached to a
1509 console, `gdbmtool' runs in interactive mode, which is indicated by its
1510 "prompt":
1511
1512      gdbmtool> _
1513
1514    The utility finishes when it reads the `quit' command (see below) or
1515 detects end-of-file on its standard input, whichever occurs first.
1516
1517    A `gdbmtool' command consists of a "command verb", optionally
1518 followed by "arguments", separated by any amount of white space.  A
1519 command verb can be entered either in full or in an abbreviated form,
1520 as long as that abbreviation does not match any other verb.  For
1521 example, `co' can be used instead of `count' and `ca' instead of
1522 `cache'.
1523
1524    Any sequence of non-whitespace characters appearing after the command
1525 verb forms an argument.  If the argument contains whitespace or
1526 unprintable characters it must be enclosed in double quotes.  Within
1527 double quotes the usual "escape sequences" are understood, as shown in
1528 the table below:
1529
1530 Sequence               Replaced with
1531 \a                     Audible bell character (ASCII 7)
1532 \b                     Backspace character (ASCII 8)
1533 \f                     Form-feed character (ASCII 12)
1534 \n                     Newline character (ASCII 10)
1535 \r                     Carriage return character (ASCII 13)
1536 \t                     Horizontal tabulation character
1537                        (ASCII 9)
1538 \v                     Vertical tabulation character
1539                        (ASCII 11)
1540 \\                     Single slash
1541 \"                     Double quote
1542
1543 Table 20.1: Backslash escapes
1544
1545    In addition, a backslash immediately followed by the end-of-line
1546 character effectively removes that character, allowing to split long
1547 arguments over several input lines.
1548
1549    Command parameters may be optional or mandatory.  If the number of
1550 actual arguments is less than the number of mandatory parameters,
1551 `gdbmtool' will prompt you to supply missing arguments.  For example,
1552 the `store' command takes two mandatory parameters, so if you invoked
1553 it with no arguments, you would be prompted twice to supply the
1554 necessary data, as shown in  example below:
1555
1556      gdbmtool> store
1557      key? three
1558      data? 3
1559
1560    However, such prompting is possible only in interactive mode.  In
1561 non-interactive mode (e.g. when running a script), all arguments must
1562 be supplied with each command, otherwise `gdbmtool' will report an
1563 error and exit immediately.
1564
1565 * Menu:
1566
1567 * variables::      shell variables.
1568 * commands::       shell commands.
1569 * definitions::    how to define structured data.
1570 * startup files::
1571
1572 \1f
1573 File: gdbm.info,  Node: variables,  Next: commands,  Up: shell
1574
1575 20.2.1 Shell Variables
1576 ----------------------
1577
1578 A number of `gdbmtool' parameters is kept in its internal variables.
1579
1580  -- gdbmtool variable: bool confirm
1581      Whether to ask for confirmation before certain destructive
1582      operations, such as truncating the existing database.
1583
1584      Default is `true'.
1585
1586  -- gdbmtool variable: string ps1
1587      Primary prompt string.  Its value can contain "conversion
1588      specifiers", consisting of the `%' character followed by another
1589      character.  These specifiers are expanded in the resulting prompt
1590      as follows:
1591
1592      Sequence                    Expansion
1593      --------------------------------------------------------------- 
1594      %f                          name of the current database file
1595      %p                          program invocation name
1596      %P                          package name (`GDBM')
1597      %v                          program version
1598      %_                          single space character
1599      %%                          %
1600
1601      The default value is `%p>%_', i.e. the program name, followed by a
1602      "greater than" sign, followed by a single space.
1603
1604  -- gdbmtool variable: string ps2
1605      Secondary prompt.  See `ps1' for a description of its value.  This
1606      prompt is displayed before reading the second and subsequent lines
1607      of a multi-line command.
1608
1609      The default value is `%_>%_'.
1610
1611  -- gdbmtool variable: string delim1
1612      A string used to delimit fields of a structured datum on output
1613      (*note definitions::).
1614
1615      Default is `,' (a comma).  This variable cannot be unset.
1616
1617  -- gdbmtool variable: string delim2
1618      A string used to delimit array items when printing a structured
1619      datum (*note definitions::).
1620
1621      Default is `,' (a comma).  This variable cannot be unset.
1622
1623  -- gdbmtool variable: string pager
1624      The name and command line of the pager program to pipe output to.
1625      This program is used in interactive mode when the estimated number
1626      of output lines is greater then the number of lines on your screen.
1627
1628      The default value is inherited from the environment variable
1629      `PAGER'.  Unsetting this variable disables paging.
1630
1631  -- gdbmtool variable: bool quiet
1632      Whether to display a welcome banner at startup.  This variable
1633      should be set in a startup script file (*note startup files::).
1634      *Note -q option::.
1635
1636    The following variables control how the database is opened:
1637
1638  -- gdbmtool variable: numeric blocksize
1639      Sets the block size.  *Note block_size: Open.  Unset by default.
1640
1641  -- gdbmtool variable: numeric cachesize
1642      Sets the cache size.  *Note GDBM_SETCACHESIZE: Options.  By
1643      default this variable is not set.
1644
1645  -- gdbmtool variable: string open
1646      Open mode.  The following values are allowed:
1647
1648     newdb
1649           Truncate the database if it exists or create a new one.  Open
1650           it in read-write mode.
1651
1652           Technically, this sets the `GDBM_NEWDB' flag in call to
1653           `gdbm_open'.  *Note GDBM_NEWDB: Open.
1654
1655     wrcreat
1656     rw
1657           Open the database in read-write mode.  Create it if it does
1658           not exist.  This is the default.
1659
1660           Technically speaking, it sets the `GDBM_WRCREAT' flag in call
1661           to `gdbm_open'.  *Note GDBM_WRCREAT: Open.
1662
1663     reader
1664     readonly
1665           Open the database in read-only mode.  Signal an error if it
1666           does not exist.
1667
1668           This sets the `GDBM_READER' flag (*note GDBM_READER: Open.).
1669
1670      Attempting to set any other value or to unset this variable
1671      produces an error.
1672
1673  -- gdbmtool variable: number filemode
1674      File mode (in octal) for creating new database files and database
1675      dumps.
1676
1677  -- gdbmtool variable: bool lock
1678      Lock the database.  This is the default.
1679
1680      Setting this variable to false or unsetting it results in passing
1681      `GDBM_NOLOCK' flag to `gdbm_open' (*note GDBM_NOLOCK: Open.).
1682
1683  -- gdbmtool variable: bool mmap
1684      Use memory mapping.  This is the default.
1685
1686      Setting this variable to false or unsetting it results in passing
1687      `GDBM_NOMMAP' flag to `gdbm_open' (*note GDBM_NOMMAP: Open.).
1688
1689  -- gdbmtool variable: bool sync
1690      Flush all database writes on disk immediately.  Default is false.
1691      *Note GDBM_SYNC: Open.
1692
1693    The following commands are used to list or modify the variables:
1694
1695  -- command verb: set [ASSIGNMENTS]
1696      When used without arguments, lists all variables and their values.
1697      Unset variables are shown after a comment sign (`#').  For string
1698      and numeric variables, values are shown after an equals sign.  For
1699      boolean variables, only the variable name is displayed if the
1700      variable is `true'.  If it is `false', its name is prefixed with
1701      `no'.
1702
1703      For example:
1704
1705           ps1="%p>%_"
1706           ps2="%_>%_"
1707           delim1=","
1708           delim2=","
1709           confirm
1710           # cachesize is unset
1711           # blocksize is unset
1712           open="wrcreat"
1713           lock
1714           mmap
1715           nosync
1716           pager="less"
1717           # quiet is unset
1718
1719      If used with arguments, the `set' command alters the specified
1720      variables.  In this case, arguments are variable assignments in the
1721      form `NAME=VALUE'.  For boolean variables, the VALUE is
1722      interpreted as follows: if it is numeric, `0' stands for `false',
1723      any non-zero value stands for `true'.  Otherwise, the values `on',
1724      `true', and `yes' denote `true', and `off', `false', `no' stand for
1725      `false'.  Alternatively, only the name of a boolean variable can be
1726      supplied to set it to `true', and its name prefixed with `no' can
1727      be used to set it to false.  For example, the following command
1728      sets the `delim2' variable to `;' and the `confirm' variable to
1729      `false':
1730
1731           set delim2=";" noconfirm
1732
1733  -- command verb: unset VARIABLES
1734      Unsets the listed variables.  The effect of unsetting depends on
1735      the variable.  Unless explicitly described in the discussion of the
1736      variables above, unsetting a boolean variable is equivalent to
1737      setting it to `false'.  Unsetting a string variable is equivalent
1738      to assigning it an empty string.
1739
1740 \1f
1741 File: gdbm.info,  Node: commands,  Next: definitions,  Prev: variables,  Up: shell
1742
1743 20.2.2 Gdbmtool Commands
1744 ------------------------
1745
1746  -- command verb: avail
1747      Print the "avail list".
1748
1749  -- command verb: bucket NUM
1750      Print the bucket number NUM and set it as the current one.
1751
1752  -- command verb: cache
1753      Print the bucket cache.
1754
1755  -- command verb: close
1756      Close the currently open database.
1757
1758  -- command verb: count
1759      Print the number of entries in the database.
1760
1761  -- command verb: current
1762      Print the current bucket.
1763
1764  -- command verb: delete KEY
1765      Delete record with the given KEY
1766
1767  -- command verb: dir
1768      Print hash directory.
1769
1770  -- command verb: export FILE-NAME [truncate] [binary|ascii]
1771      Export the database to the flat file FILE-NAME.  *Note Flat
1772      files::, for a description of the flat file format and its
1773      purposes.  This command will not overwrite an existing file,
1774      unless the `truncate' parameter is also given.  Another optional
1775      argument determines the type of the dump (*note Flat files::).  By
1776      default, ASCII dump is created.
1777
1778      The global variable `filemode' specifies the permissions to use
1779      for the created output file.
1780
1781      See also *note gdbmexport::.
1782
1783  -- command verb: fetch KEY
1784      Fetch and display the record with the given KEY.
1785
1786  -- command verb: first
1787      Fetch and display the first record in the database.  Subsequent
1788      records can be fetched using the `next' command (see below).
1789      *Note Sequential::, for more information on sequential access.
1790
1791  -- command verb: hash KEY
1792      Compute and display the hash value for the given KEY.
1793
1794  -- command verb: header
1795      Print file header.
1796
1797  -- command verb: help
1798  -- command verb: ?
1799      Print a concise command summary, showing each command verb with
1800      its parameters and a short description of what it does.  Optional
1801      arguments are enclosed in square brackets.
1802
1803  -- command verb: import FILE-NAME [replace] [nometa]
1804      Import data from a flat dump file FILE-NAME (*note Flat files::).
1805      If the word `replace' is given as an argument, any records with
1806      the same keys as the already existing ones will replace them.  The
1807      word `nometa' turns off restoring meta-information from the dump
1808      file.
1809
1810  -- command verb: list
1811      List the contents of the database.
1812
1813  -- command verb: next [KEY]
1814      Sequential access: fetch and display the next record.  If the KEY
1815      is given, the record following the one with this key will be
1816      fetched.
1817
1818      See also `first', above.
1819
1820      *Note Sequential::, for more information on sequential access.
1821
1822  -- command verb: open FILENAME
1823      Open the database file FILENAME.  If successful, any previously
1824      open database is closed.  Otherwise, if the operation fails, the
1825      currently opened database remains unchanged.
1826
1827      This command takes additional information from the following
1828      variables:
1829
1830     `open'
1831           The database access mode.  *Note The OPEN variable: openvar,
1832           for a list of its values.
1833
1834     `lock'
1835           Whether or not to lock the database.  Default is `on'.
1836
1837     `mmap'
1838           Use the memory mapping.  Default is `on'.
1839
1840     `sync'
1841           Synchronize after each write.  Default is `off'.
1842
1843     `filemode'
1844           Specifies the permissions to use in case a new file is
1845           created.
1846
1847      *Note open parameters::, for a detailed description of these
1848      variables.
1849
1850  -- command verb: quit
1851      Close the database and quit the utility.
1852
1853  -- command verb: reorganize
1854      Reorganize the database (*note Reorganization::).
1855
1856  -- command verb: source FILENAME
1857      Read `gdbmtool' commands from the file FILENAME.
1858
1859  -- command verb: status
1860      Print current program status.  The following example shows the
1861      information displayed:
1862
1863           Database file: junk.gdbm
1864           Database is open
1865           define key string
1866           define content string
1867
1868      The two `define' strings show the defined formats for key and
1869      content data.  *Note definitions::, for a detailed discussion of
1870      their meaning.
1871
1872  -- command verb: store KEY DATA
1873      Store the DATA with KEY in the database.  If KEY already exists,
1874      its data will be replaced.
1875
1876  -- command verb: version
1877      Print the version of `gdbm'.
1878
1879 \1f
1880 File: gdbm.info,  Node: definitions,  Next: startup files,  Prev: commands,  Up: shell
1881
1882 20.2.3 Data Definitions
1883 -----------------------
1884
1885 GDBM databases are able to keep data of any type, both in the key and
1886 in the content part of a record.  Quite often these data are
1887 structured, i.e. they consist of several fields of various types.
1888 `Gdbmtool' provides a mechanism for handling such kind of records.
1889
1890    The `define' command defines a record structure.  The general syntax
1891 is:
1892
1893      define WHAT DEFINITION
1894
1895 where WHAT is `key' to defining the structure of key data and `content'
1896 to define the structure of the content records.
1897
1898    The DEFINITION can be of two distinct formats.  In the simplest case
1899 it is a single data type.  For example,
1900
1901      define content int
1902
1903 defines content records consisting of a single integer field.
1904 Supported data types are:
1905
1906 char
1907      Single byte (signed).
1908
1909 short
1910      Signed short integer.
1911
1912 ushort
1913      Unsigned short integer.
1914
1915 int
1916      Signed integer.
1917
1918 unsigned
1919 uint
1920      Unsigned integer.
1921
1922 long
1923      Signed long integer.
1924
1925 ulong
1926      Unsigned long integer.
1927
1928 llong
1929      Signed long long integer.
1930
1931 ullong
1932      Unsigned long long integer.
1933
1934 float
1935      A floating point number.
1936
1937 double
1938      Double-precision floating point number.
1939
1940 string
1941      Array of bytes.
1942
1943 stringz
1944      Null-terminated string, trailing null being part of the string.
1945
1946    All numeric data types (integer as well as floating point) have the
1947 same respective widths as in C language on the host where the database
1948 file resides.
1949
1950    The `string' and `stringz' are special.  Both define a string of
1951 bytes, similar to `char x[]' in C.  The former defines an array of
1952 bytes, the latter - a null-terminated string.  This makes a difference,
1953 in particular, when the string is the only part of datum.  Consider the
1954 following two definitions:
1955
1956   1. `define key string'
1957
1958   2. `define key stringz'
1959
1960 Now, suppose we want to store the string "ab" in the key.  Using the
1961 definition (1), the `dptr' member of GDBM `datum' will contain two
1962 bytes: `a', and `b'.  Consequently, the `dsize' member will have the
1963 value 2.  Using the definition (2), the `dptr' member will contain
1964 three bytes: `a', `b', and ASCII 0.  The `dsize' member will have the
1965 value 3.
1966
1967    The definition (1) is the default for both key and content.
1968
1969    The second form of the `define' statement is similar to the C
1970 `struct' statement and allows for defining structural data.   In this
1971 form, the DEFINITION part is a comma-separated list of data types and
1972 variables enclosed in curly braces.  In contrast to the rest of `gdbm'
1973 commands, this command is inherently multiline and is terminated with
1974 the closing curly brace.  For example:
1975
1976      define content {
1977              int status,
1978              pad 8,
1979              char id[3],
1980              string name
1981      }
1982
1983 This defines a structure consisting of three members: an integer
1984 `status', an array of 8 bytes `id', and a null-terminated string
1985 `name'.  Notice the `pad' statement: it allows to introduce padding
1986 between structure members.  Another useful statement is `offset': it
1987 specifies that the member following it begins at the given offset in
1988 the structure.  Assuming the size of `int' is 8 bytes, the above
1989 definition can also be written as
1990
1991      define content {
1992              int status,
1993              offset 16,
1994              char id[3],
1995              string name
1996      }
1997
1998    _NOTE_: The `string' type can reasonably be used only if it is the
1999 last or the only member of the data structure.  That's because it
2000 provides no information about the number of elements in the array, so
2001 it is interpreted to contain all bytes up to the end of the datum.
2002
2003    When displaying the structured data, `gdbmtool' precedes each value
2004 with the corresponding field name and delimits parts of the structure
2005 with the string defined in the `delim1' variable (*note variables::).
2006 Array elements are delimited using the string from `delim2'.  For
2007 example:
2008
2009      gdbmtool> fetch foo
2010      status=2,id={ a, u, x },name="quux"
2011
2012    To supply a structured datum as an argument to a `gdbmtool' command,
2013 use the same notation, but without field names, e.g.:
2014
2015      gdbmtool> hash { 2, {a,u,x}, "quux" }
2016      hash value = 13089969.
2017
2018 \1f
2019 File: gdbm.info,  Node: startup files,  Prev: definitions,  Up: shell
2020
2021 20.2.4 Startup Files
2022 --------------------
2023
2024 Upon startup `gdbmtool' looks for a file named `.gdbmtoolrc' first in
2025 the current working directory and, if not found, in the home directory
2026 of the user who started the command.
2027
2028    If found, this file is read and interpreted as a list of `gdbmtool'
2029 commands.  This allows you to customize the program behavior.
2030
2031    Following is an example startup file which disables the welcome
2032 banner, sets command line prompt to contain the name of the database
2033 file in parentheses and defines the structure of the database content
2034 records:
2035
2036      set quiet
2037      set ps1="(%f) "
2038      define key stringz
2039      define content {
2040              int time,
2041              pad 4,
2042              int status
2043      }
2044
2045 \1f
2046 File: gdbm.info,  Node: gdbm_dump,  Next: gdbm_load,  Prev: gdbmtool,  Up: Top
2047
2048 21 The `gdbm_dump' utility
2049 **************************
2050
2051 The `gdbm_dump' utility creates a flat file dump of a GDBM database
2052 (*note Flat files::).  It takes one mandatory argument: the name of the
2053 source database file.  The second argument, if given, specifies the
2054 name of the output file.  If not given, `gdbm_dump' will produce the
2055 dump on the standard output.
2056
2057    For example, the following invocation creates a dump of the database
2058 `file.db' in the file `file.dump':
2059
2060      $ gdbm_dump file.db file.dump
2061
2062    By default the utility creates dumps in ASCII format (*note ASCII:
2063 Flat files.).  Another format can be requested using the `--format'
2064 (`-H') option.
2065
2066    The `gdbm_dump' utility understands the following command line
2067 options:
2068
2069 `-H FMT'
2070 `--format=FMT'
2071      Select output format.  Valid values for FMT are: `binary' or `0'
2072      to select binary dump format, and `ascii' or `1' to select ASCII
2073      format.
2074
2075 `-h'
2076 `--help'
2077      Print a concise help summary.
2078
2079 `-V'
2080 `--version'
2081      Print program version and licensing information and exit.
2082
2083 `--usage'
2084      Print a terse invocation syntax summary along with a list of
2085      available command line options.
2086
2087 \1f
2088 File: gdbm.info,  Node: gdbm_load,  Next: gdbmexport,  Prev: gdbm_dump,  Up: Top
2089
2090 22 The `gdbm_load' utility
2091 **************************
2092
2093 The `gdbm_load' utility restores a GDBM database from a flat file.  The
2094 utility requires at least one argument: the name of the input flat
2095 file.  If it is `-', the standard input will be read.  The format of
2096 the input file is detected automatically.
2097
2098    By default the utility attempts to restore the database under its
2099 original name, as stored in the input file.  It will fail to do so if
2100 the input is in binary format.  In that case, the name of the database
2101 must be given as the second argument.
2102
2103    In general, if two arguments are given the second one is treated as
2104 the name of the database to create, overriding the file name specified
2105 in the flat file.
2106
2107    The utility understands the following command line arguments:
2108
2109 `-b NUM'
2110 `--block-size=NUM'
2111      Sets block size.  *Note block_size: Open.
2112
2113 `-c NUM'
2114 `--cache-size=NUM'
2115      Sets cache size.  *Note GDBM_SETCACHESIZE: Options.
2116
2117 `-M'
2118 `--mmap'
2119      Use memory mapping.
2120
2121 `-m MODE'
2122
2123 `--mode=MODE'
2124      Sets the file mode.  The argument is the desired file mode in
2125      octal.
2126
2127 `-n'
2128 `--no-meta'
2129      Do not restore file meta-data (ownership and mode) from the flat
2130      file.
2131
2132 `-r'
2133 `--replace'
2134      Replace existing keys.
2135
2136 `-u USER[:GROUP]'
2137 `--user=USER[:GROUP]'
2138      Set file owner.  The USER can be either a valid user name or UID.
2139      Similarly, the GROUP is either a valid group name or GID.  If
2140      GROUP is not given, the main group of USER is used.
2141
2142      User and group parts can be separated by a dot, instead of the
2143      colon.
2144
2145 `-h'
2146 `--help'
2147      Print a concise help summary.
2148
2149 `-V'
2150 `--version'
2151      Print program version and licensing information and exit.
2152
2153 `--usage'
2154      Print a terse invocation syntax summary along with a list of
2155      available command line options.
2156
2157 \1f
2158 File: gdbm.info,  Node: gdbmexport,  Next: Exit codes,  Prev: gdbm_load,  Up: Top
2159
2160 23 Export a database into a portable format.
2161 ********************************************
2162
2163 The `gdbmexport' utility converts the database of an older GDBM version
2164 into a binary flat format.
2165
2166    The utility takes two mandatory arguments: the name of the database
2167 file to convert and the output file name, e.g.:
2168
2169      $ gdbmexport junk.gdbm junk.flat
2170
2171    In addition the following two options are understood:
2172
2173 `-h'
2174      Display short usage summary and exit.
2175
2176 `-v'
2177      Display program version and licensing information, and exit.
2178
2179 \1f
2180 File: gdbm.info,  Node: Exit codes,  Next: Bugs,  Prev: gdbmexport,  Up: Top
2181
2182 24 Exit codes
2183 *************
2184
2185 All GDBM utilities return uniform exit codes.  These are summarized in
2186 the table below:
2187
2188 Code                   Meaning
2189 -------------------------------------------------------------------------- 
2190 0                      Successful termination.
2191 1                      A fatal error occurred.
2192 2                      Program was unable to restore file ownership or
2193                        mode.
2194 3                      Command line usage error.
2195
2196 \1f
2197 File: gdbm.info,  Node: Bugs,  Next: Resources,  Prev: Exit codes,  Up: Top
2198
2199 25 Problems and bugs.
2200 *********************
2201
2202 If you have problems with GNU `dbm' or think you've found a bug, please
2203 report it.  Before reporting a bug, make sure you've actually found a
2204 real bug.  Carefully reread the documentation and see if it really says
2205 you can do what you're trying to do.  If it's not clear whether you
2206 should be able to do something or not, report that too; it's a bug in
2207 the documentation!
2208
2209    Before reporting a bug or trying to fix it yourself, try to isolate
2210 it to the smallest possible input file that reproduces the problem.
2211 Then send us the input file and the exact results `gdbm' gave you.  Also
2212 say what you expected to occur; this will help us decide whether the
2213 problem was really in the documentation.
2214
2215    Once you've got a precise problem, send e-mail to <bug-gdbm@gnu.org>.
2216
2217    Please include the version number of GNU `dbm' you are using.  You
2218 can get this information by printing the variable `gdbm_version' (*note
2219 Variables::).
2220
2221    Non-bug suggestions are always welcome as well.  If you have
2222 questions about things that are unclear in the documentation or are
2223 just obscure features, please report them too.
2224
2225    You may contact the authors and maintainers by e-mail:
2226      <phil@cs.wwu.edu>, <downsj@downsj.com>, <gray@gnu.org.ua>
2227
2228 \1f
2229 File: gdbm.info,  Node: Resources,  Next: GNU Free Documentation License,  Prev: Bugs,  Up: Top
2230
2231 26 Additional resources
2232 ***********************
2233
2234 For the latest updates and pointers to additional resources, visit
2235 `http://www.gnu.org/software/gdbm'.
2236
2237    In particular, a copy of `gdbm' documentation in various formats is
2238 available online at `http://www.gnu.org/software/gdbm/manual.html'.
2239
2240    Latest versions of `gdbm' can be downloaded from anonymous FTP:
2241 `ftp://ftp.gnu.org/gnu/gdbm', or via HTTP from
2242 `http://ftp.gnu.org/gnu/gdbm', or from any GNU mirror worldwide.  See
2243 `http://www.gnu.org/order/ftp.html', for a list of mirrors.
2244
2245    To track `gdbm' development, visit
2246 `http://puszcza.gnu.org.ua/projects/gdbm'.
2247
2248 \1f
2249 File: gdbm.info,  Node: GNU Free Documentation License,  Next: Index,  Prev: Resources,  Up: Top
2250
2251 Appendix A GNU Free Documentation License
2252 *****************************************
2253
2254                      Version 1.3, 3 November 2008
2255
2256      Copyright (C) 2000, 2001, 2002, 2007, 2008, 2011 Free Software
2257      Foundation, Inc.
2258      `http://fsf.org/'
2259
2260      Everyone is permitted to copy and distribute verbatim copies
2261      of this license document, but changing it is not allowed.
2262
2263   0. PREAMBLE
2264
2265      The purpose of this License is to make a manual, textbook, or other
2266      functional and useful document "free" in the sense of freedom: to
2267      assure everyone the effective freedom to copy and redistribute it,
2268      with or without modifying it, either commercially or
2269      noncommercially.  Secondarily, this License preserves for the
2270      author and publisher a way to get credit for their work, while not
2271      being considered responsible for modifications made by others.
2272
2273      This License is a kind of "copyleft", which means that derivative
2274      works of the document must themselves be free in the same sense.
2275      It complements the GNU General Public License, which is a copyleft
2276      license designed for free software.
2277
2278      We have designed this License in order to use it for manuals for
2279      free software, because free software needs free documentation: a
2280      free program should come with manuals providing the same freedoms
2281      that the software does.  But this License is not limited to
2282      software manuals; it can be used for any textual work, regardless
2283      of subject matter or whether it is published as a printed book.
2284      We recommend this License principally for works whose purpose is
2285      instruction or reference.
2286
2287   1. APPLICABILITY AND DEFINITIONS
2288
2289      This License applies to any manual or other work, in any medium,
2290      that contains a notice placed by the copyright holder saying it
2291      can be distributed under the terms of this License.  Such a notice
2292      grants a world-wide, royalty-free license, unlimited in duration,
2293      to use that work under the conditions stated herein.  The
2294      "Document", below, refers to any such manual or work.  Any member
2295      of the public is a licensee, and is addressed as "you".  You
2296      accept the license if you copy, modify or distribute the work in a
2297      way requiring permission under copyright law.
2298
2299      A "Modified Version" of the Document means any work containing the
2300      Document or a portion of it, either copied verbatim, or with
2301      modifications and/or translated into another language.
2302
2303      A "Secondary Section" is a named appendix or a front-matter section
2304      of the Document that deals exclusively with the relationship of the
2305      publishers or authors of the Document to the Document's overall
2306      subject (or to related matters) and contains nothing that could
2307      fall directly within that overall subject.  (Thus, if the Document
2308      is in part a textbook of mathematics, a Secondary Section may not
2309      explain any mathematics.)  The relationship could be a matter of
2310      historical connection with the subject or with related matters, or
2311      of legal, commercial, philosophical, ethical or political position
2312      regarding them.
2313
2314      The "Invariant Sections" are certain Secondary Sections whose
2315      titles are designated, as being those of Invariant Sections, in
2316      the notice that says that the Document is released under this
2317      License.  If a section does not fit the above definition of
2318      Secondary then it is not allowed to be designated as Invariant.
2319      The Document may contain zero Invariant Sections.  If the Document
2320      does not identify any Invariant Sections then there are none.
2321
2322      The "Cover Texts" are certain short passages of text that are
2323      listed, as Front-Cover Texts or Back-Cover Texts, in the notice
2324      that says that the Document is released under this License.  A
2325      Front-Cover Text may be at most 5 words, and a Back-Cover Text may
2326      be at most 25 words.
2327
2328      A "Transparent" copy of the Document means a machine-readable copy,
2329      represented in a format whose specification is available to the
2330      general public, that is suitable for revising the document
2331      straightforwardly with generic text editors or (for images
2332      composed of pixels) generic paint programs or (for drawings) some
2333      widely available drawing editor, and that is suitable for input to
2334      text formatters or for automatic translation to a variety of
2335      formats suitable for input to text formatters.  A copy made in an
2336      otherwise Transparent file format whose markup, or absence of
2337      markup, has been arranged to thwart or discourage subsequent
2338      modification by readers is not Transparent.  An image format is
2339      not Transparent if used for any substantial amount of text.  A
2340      copy that is not "Transparent" is called "Opaque".
2341
2342      Examples of suitable formats for Transparent copies include plain
2343      ASCII without markup, Texinfo input format, LaTeX input format,
2344      SGML or XML using a publicly available DTD, and
2345      standard-conforming simple HTML, PostScript or PDF designed for
2346      human modification.  Examples of transparent image formats include
2347      PNG, XCF and JPG.  Opaque formats include proprietary formats that
2348      can be read and edited only by proprietary word processors, SGML or
2349      XML for which the DTD and/or processing tools are not generally
2350      available, and the machine-generated HTML, PostScript or PDF
2351      produced by some word processors for output purposes only.
2352
2353      The "Title Page" means, for a printed book, the title page itself,
2354      plus such following pages as are needed to hold, legibly, the
2355      material this License requires to appear in the title page.  For
2356      works in formats which do not have any title page as such, "Title
2357      Page" means the text near the most prominent appearance of the
2358      work's title, preceding the beginning of the body of the text.
2359
2360      The "publisher" means any person or entity that distributes copies
2361      of the Document to the public.
2362
2363      A section "Entitled XYZ" means a named subunit of the Document
2364      whose title either is precisely XYZ or contains XYZ in parentheses
2365      following text that translates XYZ in another language.  (Here XYZ
2366      stands for a specific section name mentioned below, such as
2367      "Acknowledgements", "Dedications", "Endorsements", or "History".)
2368      To "Preserve the Title" of such a section when you modify the
2369      Document means that it remains a section "Entitled XYZ" according
2370      to this definition.
2371
2372      The Document may include Warranty Disclaimers next to the notice
2373      which states that this License applies to the Document.  These
2374      Warranty Disclaimers are considered to be included by reference in
2375      this License, but only as regards disclaiming warranties: any other
2376      implication that these Warranty Disclaimers may have is void and
2377      has no effect on the meaning of this License.
2378
2379   2. VERBATIM COPYING
2380
2381      You may copy and distribute the Document in any medium, either
2382      commercially or noncommercially, provided that this License, the
2383      copyright notices, and the license notice saying this License
2384      applies to the Document are reproduced in all copies, and that you
2385      add no other conditions whatsoever to those of this License.  You
2386      may not use technical measures to obstruct or control the reading
2387      or further copying of the copies you make or distribute.  However,
2388      you may accept compensation in exchange for copies.  If you
2389      distribute a large enough number of copies you must also follow
2390      the conditions in section 3.
2391
2392      You may also lend copies, under the same conditions stated above,
2393      and you may publicly display copies.
2394
2395   3. COPYING IN QUANTITY
2396
2397      If you publish printed copies (or copies in media that commonly
2398      have printed covers) of the Document, numbering more than 100, and
2399      the Document's license notice requires Cover Texts, you must
2400      enclose the copies in covers that carry, clearly and legibly, all
2401      these Cover Texts: Front-Cover Texts on the front cover, and
2402      Back-Cover Texts on the back cover.  Both covers must also clearly
2403      and legibly identify you as the publisher of these copies.  The
2404      front cover must present the full title with all words of the
2405      title equally prominent and visible.  You may add other material
2406      on the covers in addition.  Copying with changes limited to the
2407      covers, as long as they preserve the title of the Document and
2408      satisfy these conditions, can be treated as verbatim copying in
2409      other respects.
2410
2411      If the required texts for either cover are too voluminous to fit
2412      legibly, you should put the first ones listed (as many as fit
2413      reasonably) on the actual cover, and continue the rest onto
2414      adjacent pages.
2415
2416      If you publish or distribute Opaque copies of the Document
2417      numbering more than 100, you must either include a
2418      machine-readable Transparent copy along with each Opaque copy, or
2419      state in or with each Opaque copy a computer-network location from
2420      which the general network-using public has access to download
2421      using public-standard network protocols a complete Transparent
2422      copy of the Document, free of added material.  If you use the
2423      latter option, you must take reasonably prudent steps, when you
2424      begin distribution of Opaque copies in quantity, to ensure that
2425      this Transparent copy will remain thus accessible at the stated
2426      location until at least one year after the last time you
2427      distribute an Opaque copy (directly or through your agents or
2428      retailers) of that edition to the public.
2429
2430      It is requested, but not required, that you contact the authors of
2431      the Document well before redistributing any large number of
2432      copies, to give them a chance to provide you with an updated
2433      version of the Document.
2434
2435   4. MODIFICATIONS
2436
2437      You may copy and distribute a Modified Version of the Document
2438      under the conditions of sections 2 and 3 above, provided that you
2439      release the Modified Version under precisely this License, with
2440      the Modified Version filling the role of the Document, thus
2441      licensing distribution and modification of the Modified Version to
2442      whoever possesses a copy of it.  In addition, you must do these
2443      things in the Modified Version:
2444
2445        A. Use in the Title Page (and on the covers, if any) a title
2446           distinct from that of the Document, and from those of
2447           previous versions (which should, if there were any, be listed
2448           in the History section of the Document).  You may use the
2449           same title as a previous version if the original publisher of
2450           that version gives permission.
2451
2452        B. List on the Title Page, as authors, one or more persons or
2453           entities responsible for authorship of the modifications in
2454           the Modified Version, together with at least five of the
2455           principal authors of the Document (all of its principal
2456           authors, if it has fewer than five), unless they release you
2457           from this requirement.
2458
2459        C. State on the Title page the name of the publisher of the
2460           Modified Version, as the publisher.
2461
2462        D. Preserve all the copyright notices of the Document.
2463
2464        E. Add an appropriate copyright notice for your modifications
2465           adjacent to the other copyright notices.
2466
2467        F. Include, immediately after the copyright notices, a license
2468           notice giving the public permission to use the Modified
2469           Version under the terms of this License, in the form shown in
2470           the Addendum below.
2471
2472        G. Preserve in that license notice the full lists of Invariant
2473           Sections and required Cover Texts given in the Document's
2474           license notice.
2475
2476        H. Include an unaltered copy of this License.
2477
2478        I. Preserve the section Entitled "History", Preserve its Title,
2479           and add to it an item stating at least the title, year, new
2480           authors, and publisher of the Modified Version as given on
2481           the Title Page.  If there is no section Entitled "History" in
2482           the Document, create one stating the title, year, authors,
2483           and publisher of the Document as given on its Title Page,
2484           then add an item describing the Modified Version as stated in
2485           the previous sentence.
2486
2487        J. Preserve the network location, if any, given in the Document
2488           for public access to a Transparent copy of the Document, and
2489           likewise the network locations given in the Document for
2490           previous versions it was based on.  These may be placed in
2491           the "History" section.  You may omit a network location for a
2492           work that was published at least four years before the
2493           Document itself, or if the original publisher of the version
2494           it refers to gives permission.
2495
2496        K. For any section Entitled "Acknowledgements" or "Dedications",
2497           Preserve the Title of the section, and preserve in the
2498           section all the substance and tone of each of the contributor
2499           acknowledgements and/or dedications given therein.
2500
2501        L. Preserve all the Invariant Sections of the Document,
2502           unaltered in their text and in their titles.  Section numbers
2503           or the equivalent are not considered part of the section
2504           titles.
2505
2506        M. Delete any section Entitled "Endorsements".  Such a section
2507           may not be included in the Modified Version.
2508
2509        N. Do not retitle any existing section to be Entitled
2510           "Endorsements" or to conflict in title with any Invariant
2511           Section.
2512
2513        O. Preserve any Warranty Disclaimers.
2514
2515      If the Modified Version includes new front-matter sections or
2516      appendices that qualify as Secondary Sections and contain no
2517      material copied from the Document, you may at your option
2518      designate some or all of these sections as invariant.  To do this,
2519      add their titles to the list of Invariant Sections in the Modified
2520      Version's license notice.  These titles must be distinct from any
2521      other section titles.
2522
2523      You may add a section Entitled "Endorsements", provided it contains
2524      nothing but endorsements of your Modified Version by various
2525      parties--for example, statements of peer review or that the text
2526      has been approved by an organization as the authoritative
2527      definition of a standard.
2528
2529      You may add a passage of up to five words as a Front-Cover Text,
2530      and a passage of up to 25 words as a Back-Cover Text, to the end
2531      of the list of Cover Texts in the Modified Version.  Only one
2532      passage of Front-Cover Text and one of Back-Cover Text may be
2533      added by (or through arrangements made by) any one entity.  If the
2534      Document already includes a cover text for the same cover,
2535      previously added by you or by arrangement made by the same entity
2536      you are acting on behalf of, you may not add another; but you may
2537      replace the old one, on explicit permission from the previous
2538      publisher that added the old one.
2539
2540      The author(s) and publisher(s) of the Document do not by this
2541      License give permission to use their names for publicity for or to
2542      assert or imply endorsement of any Modified Version.
2543
2544   5. COMBINING DOCUMENTS
2545
2546      You may combine the Document with other documents released under
2547      this License, under the terms defined in section 4 above for
2548      modified versions, provided that you include in the combination
2549      all of the Invariant Sections of all of the original documents,
2550      unmodified, and list them all as Invariant Sections of your
2551      combined work in its license notice, and that you preserve all
2552      their Warranty Disclaimers.
2553
2554      The combined work need only contain one copy of this License, and
2555      multiple identical Invariant Sections may be replaced with a single
2556      copy.  If there are multiple Invariant Sections with the same name
2557      but different contents, make the title of each such section unique
2558      by adding at the end of it, in parentheses, the name of the
2559      original author or publisher of that section if known, or else a
2560      unique number.  Make the same adjustment to the section titles in
2561      the list of Invariant Sections in the license notice of the
2562      combined work.
2563
2564      In the combination, you must combine any sections Entitled
2565      "History" in the various original documents, forming one section
2566      Entitled "History"; likewise combine any sections Entitled
2567      "Acknowledgements", and any sections Entitled "Dedications".  You
2568      must delete all sections Entitled "Endorsements."
2569
2570   6. COLLECTIONS OF DOCUMENTS
2571
2572      You may make a collection consisting of the Document and other
2573      documents released under this License, and replace the individual
2574      copies of this License in the various documents with a single copy
2575      that is included in the collection, provided that you follow the
2576      rules of this License for verbatim copying of each of the
2577      documents in all other respects.
2578
2579      You may extract a single document from such a collection, and
2580      distribute it individually under this License, provided you insert
2581      a copy of this License into the extracted document, and follow
2582      this License in all other respects regarding verbatim copying of
2583      that document.
2584
2585   7. AGGREGATION WITH INDEPENDENT WORKS
2586
2587      A compilation of the Document or its derivatives with other
2588      separate and independent documents or works, in or on a volume of
2589      a storage or distribution medium, is called an "aggregate" if the
2590      copyright resulting from the compilation is not used to limit the
2591      legal rights of the compilation's users beyond what the individual
2592      works permit.  When the Document is included in an aggregate, this
2593      License does not apply to the other works in the aggregate which
2594      are not themselves derivative works of the Document.
2595
2596      If the Cover Text requirement of section 3 is applicable to these
2597      copies of the Document, then if the Document is less than one half
2598      of the entire aggregate, the Document's Cover Texts may be placed
2599      on covers that bracket the Document within the aggregate, or the
2600      electronic equivalent of covers if the Document is in electronic
2601      form.  Otherwise they must appear on printed covers that bracket
2602      the whole aggregate.
2603
2604   8. TRANSLATION
2605
2606      Translation is considered a kind of modification, so you may
2607      distribute translations of the Document under the terms of section
2608      4.  Replacing Invariant Sections with translations requires special
2609      permission from their copyright holders, but you may include
2610      translations of some or all Invariant Sections in addition to the
2611      original versions of these Invariant Sections.  You may include a
2612      translation of this License, and all the license notices in the
2613      Document, and any Warranty Disclaimers, provided that you also
2614      include the original English version of this License and the
2615      original versions of those notices and disclaimers.  In case of a
2616      disagreement between the translation and the original version of
2617      this License or a notice or disclaimer, the original version will
2618      prevail.
2619
2620      If a section in the Document is Entitled "Acknowledgements",
2621      "Dedications", or "History", the requirement (section 4) to
2622      Preserve its Title (section 1) will typically require changing the
2623      actual title.
2624
2625   9. TERMINATION
2626
2627      You may not copy, modify, sublicense, or distribute the Document
2628      except as expressly provided under this License.  Any attempt
2629      otherwise to copy, modify, sublicense, or distribute it is void,
2630      and will automatically terminate your rights under this License.
2631
2632      However, if you cease all violation of this License, then your
2633      license from a particular copyright holder is reinstated (a)
2634      provisionally, unless and until the copyright holder explicitly
2635      and finally terminates your license, and (b) permanently, if the
2636      copyright holder fails to notify you of the violation by some
2637      reasonable means prior to 60 days after the cessation.
2638
2639      Moreover, your license from a particular copyright holder is
2640      reinstated permanently if the copyright holder notifies you of the
2641      violation by some reasonable means, this is the first time you have
2642      received notice of violation of this License (for any work) from
2643      that copyright holder, and you cure the violation prior to 30 days
2644      after your receipt of the notice.
2645
2646      Termination of your rights under this section does not terminate
2647      the licenses of parties who have received copies or rights from
2648      you under this License.  If your rights have been terminated and
2649      not permanently reinstated, receipt of a copy of some or all of
2650      the same material does not give you any rights to use it.
2651
2652  10. FUTURE REVISIONS OF THIS LICENSE
2653
2654      The Free Software Foundation may publish new, revised versions of
2655      the GNU Free Documentation License from time to time.  Such new
2656      versions will be similar in spirit to the present version, but may
2657      differ in detail to address new problems or concerns.  See
2658      `http://www.gnu.org/copyleft/'.
2659
2660      Each version of the License is given a distinguishing version
2661      number.  If the Document specifies that a particular numbered
2662      version of this License "or any later version" applies to it, you
2663      have the option of following the terms and conditions either of
2664      that specified version or of any later version that has been
2665      published (not as a draft) by the Free Software Foundation.  If
2666      the Document does not specify a version number of this License,
2667      you may choose any version ever published (not as a draft) by the
2668      Free Software Foundation.  If the Document specifies that a proxy
2669      can decide which future versions of this License can be used, that
2670      proxy's public statement of acceptance of a version permanently
2671      authorizes you to choose that version for the Document.
2672
2673  11. RELICENSING
2674
2675      "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
2676      World Wide Web server that publishes copyrightable works and also
2677      provides prominent facilities for anybody to edit those works.  A
2678      public wiki that anybody can edit is an example of such a server.
2679      A "Massive Multiauthor Collaboration" (or "MMC") contained in the
2680      site means any set of copyrightable works thus published on the MMC
2681      site.
2682
2683      "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
2684      license published by Creative Commons Corporation, a not-for-profit
2685      corporation with a principal place of business in San Francisco,
2686      California, as well as future copyleft versions of that license
2687      published by that same organization.
2688
2689      "Incorporate" means to publish or republish a Document, in whole or
2690      in part, as part of another Document.
2691
2692      An MMC is "eligible for relicensing" if it is licensed under this
2693      License, and if all works that were first published under this
2694      License somewhere other than this MMC, and subsequently
2695      incorporated in whole or in part into the MMC, (1) had no cover
2696      texts or invariant sections, and (2) were thus incorporated prior
2697      to November 1, 2008.
2698
2699      The operator of an MMC Site may republish an MMC contained in the
2700      site under CC-BY-SA on the same site at any time before August 1,
2701      2009, provided the MMC is eligible for relicensing.
2702
2703
2704 ADDENDUM: How to use this License for your documents
2705 ====================================================
2706
2707 To use this License in a document you have written, include a copy of
2708 the License in the document and put the following copyright and license
2709 notices just after the title page:
2710
2711        Copyright (C)  YEAR  YOUR NAME.
2712        Permission is granted to copy, distribute and/or modify this document
2713        under the terms of the GNU Free Documentation License, Version 1.3
2714        or any later version published by the Free Software Foundation;
2715        with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
2716        Texts.  A copy of the license is included in the section entitled ``GNU
2717        Free Documentation License''.
2718
2719    If you have Invariant Sections, Front-Cover Texts and Back-Cover
2720 Texts, replace the "with...Texts." line with this:
2721
2722          with the Invariant Sections being LIST THEIR TITLES, with
2723          the Front-Cover Texts being LIST, and with the Back-Cover Texts
2724          being LIST.
2725
2726    If you have Invariant Sections without Cover Texts, or some other
2727 combination of the three, merge those two alternatives to suit the
2728 situation.
2729
2730    If your document contains nontrivial examples of program code, we
2731 recommend releasing these examples in parallel under your choice of
2732 free software license, such as the GNU General Public License, to
2733 permit their use in free software.
2734
2735 \1f
2736 File: gdbm.info,  Node: Index,  Prev: GNU Free Documentation License,  Up: Top
2737
2738 Index
2739 *****
2740
2741 \0\b[index\0\b]
2742 * Menu:
2743
2744 * --newdb, gdbmtool option:              gdbmtool.            (line  20)
2745 * --read-only, gdbmtool option:          gdbmtool.            (line  16)
2746 * -n, gdbmtool option:                   gdbmtool.            (line  20)
2747 * -r, gdbmtool option:                   gdbmtool.            (line  16)
2748 * .gdbmtoolrc:                           startup files.       (line   6)
2749 * ?:                                     commands.            (line  59)
2750 * _GDBM_MAX_ERRNO:                       Variables.           (line  28)
2751 * _GDBM_MIN_ERRNO:                       Variables.           (line  25)
2752 * avail:                                 commands.            (line   7)
2753 * blocksize:                             variables.           (line  67)
2754 * bucket:                                commands.            (line  10)
2755 * cache:                                 commands.            (line  13)
2756 * cachesize:                             variables.           (line  70)
2757 * close:                                 commands.            (line  16)
2758 * close-on-exec:                         Open.                (line  48)
2759 * closing database:                      Close.               (line   6)
2760 * command line options, gdbmtool:        invocation.          (line   6)
2761 * compatibility layer:                   Compatibility.       (line   6)
2762 * confirm:                               variables.           (line   9)
2763 * count:                                 commands.            (line  19)
2764 * creating a database, gdbmtool:         gdbmtool.            (line  20)
2765 * current:                               commands.            (line  22)
2766 * database options:                      Options.             (line   6)
2767 * database reorganization:               Reorganization.      (line   6)
2768 * database synchronization:              Sync.                (line   6)
2769 * database, closing:                     Close.               (line   6)
2770 * database, opening or creating:         Open.                (line   6)
2771 * DBM functions:                         dbm.                 (line   6)
2772 * dbm.h:                                 Compatibility.       (line  11)
2773 * dbm_clearerr:                          ndbm.                (line  98)
2774 * dbm_close:                             ndbm.                (line  26)
2775 * dbm_delete:                            ndbm.                (line  57)
2776 * dbm_dirfno:                            ndbm.                (line 101)
2777 * dbm_error:                             ndbm.                (line  93)
2778 * dbm_fetch:                             ndbm.                (line  30)
2779 * dbm_firstkey:                          ndbm.                (line  62)
2780 * DBM_INSERT:                            ndbm.                (line  49)
2781 * dbm_nextkey:                           ndbm.                (line  72)
2782 * dbm_open:                              ndbm.                (line   9)
2783 * dbm_pagfno:                            ndbm.                (line 109)
2784 * dbm_rdonly:                            ndbm.                (line 113)
2785 * DBM_REPLACE:                           ndbm.                (line  46)
2786 * dbm_store:                             ndbm.                (line  39)
2787 * dbmclose:                              dbm.                 (line  23)
2788 * dbminit:                               dbm.                 (line  11)
2789 * default database, gdbmtool:            gdbmtool.            (line   9)
2790 * delete <1>:                            commands.            (line  25)
2791 * delete:                                dbm.                 (line  42)
2792 * deleting records:                      Delete.              (line   6)
2793 * deletion in iteration loops:           Sequential.          (line  56)
2794 * delim1:                                variables.           (line  40)
2795 * delim2:                                variables.           (line  46)
2796 * dir:                                   commands.            (line  28)
2797 * dir file:                              Compatibility.       (line  22)
2798 * error codes:                           Error codes.         (line   6)
2799 * error strings:                         Errors.              (line   6)
2800 * exit code:                             Exit codes.          (line   6)
2801 * export <1>:                            commands.            (line  31)
2802 * export:                                Flat files.          (line   6)
2803 * fetch <1>:                             commands.            (line  44)
2804 * fetch:                                 dbm.                 (line  26)
2805 * fetching records:                      Fetch.               (line   6)
2806 * filemode:                              variables.           (line 102)
2807 * first:                                 commands.            (line  47)
2808 * firstkey:                              dbm.                 (line  48)
2809 * Flat file format:                      Flat files.          (line   6)
2810 * GDBM_BAD_FILE_OFFSET:                  Error codes.         (line 117)
2811 * GDBM_BAD_MAGIC_NUMBER:                 Error codes.         (line  48)
2812 * GDBM_BAD_OPEN_FLAGS:                   Error codes.         (line 121)
2813 * GDBM_BLOCK_SIZE_ERROR:                 Error codes.         (line  15)
2814 * GDBM_BYTE_SWAPPED:                     Error codes.         (line 112)
2815 * GDBM_CACHESIZE:                        Options.             (line  30)
2816 * GDBM_CANNOT_REPLACE:                   Error codes.         (line  92)
2817 * GDBM_CANT_BE_READER:                   Error codes.         (line  56)
2818 * GDBM_CANT_BE_WRITER:                   Error codes.         (line  61)
2819 * GDBM_CENTFREE:                         Options.             (line  78)
2820 * GDBM_CLOEXEC:                          Open.                (line  48)
2821 * gdbm_close:                            Close.               (line  10)
2822 * GDBM_COALESCEBLKS:                     Options.             (line  92)
2823 * gdbm_count:                            Count.               (line   7)
2824 * gdbm_delete:                           Delete.              (line   9)
2825 * gdbm_delete and sequential access:     Sequential.          (line  56)
2826 * gdbm_dump <1>:                         gdbm_dump.           (line   6)
2827 * gdbm_dump:                             Flat files.          (line  49)
2828 * gdbm_dump_to_file:                     Flat files.          (line 150)
2829 * GDBM_EMPTY_DATABASE:                   Error codes.         (line  52)
2830 * GDBM_ERR_FILE_MODE <1>:                Error codes.         (line 156)
2831 * GDBM_ERR_FILE_MODE:                    Flat files.          (line 136)
2832 * GDBM_ERR_FILE_OWNER <1>:               Error codes.         (line 149)
2833 * GDBM_ERR_FILE_OWNER:                   Flat files.          (line 133)
2834 * gdbm_errlist:                          Variables.           (line  17)
2835 * gdbm_errno:                            Variables.           (line   9)
2836 * gdbm_exists:                           Fetch.               (line  37)
2837 * gdbm_export:                           Flat files.          (line 173)
2838 * gdbm_export_to_file:                   Flat files.          (line 182)
2839 * GDBM_FASTMODE:                         Options.             (line  52)
2840 * gdbm_fdesc:                            Locking.             (line  14)
2841 * gdbm_fetch:                            Fetch.               (line   7)
2842 * GDBM_FILE_EOF:                         Error codes.         (line 132)
2843 * GDBM_FILE_OPEN_ERROR:                  Error codes.         (line  19)
2844 * GDBM_FILE_READ_ERROR:                  Error codes.         (line  41)
2845 * GDBM_FILE_SEEK_ERROR:                  Error codes.         (line  34)
2846 * GDBM_FILE_STAT_ERROR:                  Error codes.         (line 125)
2847 * GDBM_FILE_WRITE_ERROR:                 Error codes.         (line  27)
2848 * gdbm_firstkey:                         Sequential.          (line  14)
2849 * GDBM_GETCACHESIZE:                     Options.             (line  40)
2850 * GDBM_GETCOALESCEBLKS:                  Options.             (line 104)
2851 * GDBM_GETDBNAME:                        Options.             (line 127)
2852 * GDBM_GETFLAGS:                         Options.             (line  44)
2853 * GDBM_GETMAXMAPSIZE:                    Options.             (line 114)
2854 * GDBM_GETMMAP:                          Options.             (line 123)
2855 * GDBM_GETSYNCMODE:                      Options.             (line  74)
2856 * GDBM_ILLEGAL_DATA:                     Error codes.         (line  98)
2857 * gdbm_import:                           Flat files.          (line 187)
2858 * gdbm_import_from_file:                 Flat files.          (line 200)
2859 * GDBM_INSERT:                           Store.               (line  23)
2860 * GDBM_ITEM_NOT_FOUND:                   Error codes.         (line  83)
2861 * gdbm_load <1>:                         gdbm_load.           (line   6)
2862 * gdbm_load:                             Flat files.          (line  78)
2863 * gdbm_load_from_file:                   Flat files.          (line 166)
2864 * GDBM_MALLOC_ERROR:                     Error codes.         (line  12)
2865 * GDBM_NEWDB:                            Open.                (line  28)
2866 * gdbm_nextkey:                          Sequential.          (line  24)
2867 * GDBM_NO_DBNAME:                        Error codes.         (line 143)
2868 * GDBM_NO_ERROR:                         Error codes.         (line   9)
2869 * GDBM_NOLOCK <1>:                       Locking.             (line   6)
2870 * GDBM_NOLOCK:                           Open.                (line  40)
2871 * GDBM_NOMMAP:                           Open.                (line  40)
2872 * gdbm_open:                             Open.                (line   9)
2873 * GDBM_OPT_ALREADY_SET:                  Error codes.         (line 102)
2874 * GDBM_OPT_ILLEGAL:                      Error codes.         (line 107)
2875 * GDBM_READER:                           Open.                (line  28)
2876 * GDBM_READER_CANT_DELETE:               Error codes.         (line  65)
2877 * GDBM_READER_CANT_REORGANIZE:           Error codes.         (line  75)
2878 * GDBM_READER_CANT_STORE:                Error codes.         (line  70)
2879 * gdbm_reorganize:                       Reorganization.      (line   9)
2880 * GDBM_REORGANIZE_FAILED:                Error codes.         (line  88)
2881 * GDBM_REPLACE:                          Store.               (line  23)
2882 * GDBM_SETCACHESIZE:                     Options.             (line  30)
2883 * GDBM_SETCENTFREE:                      Options.             (line  78)
2884 * GDBM_SETCOALESCEBLKS:                  Options.             (line  92)
2885 * GDBM_SETMAXMAPSIZE:                    Options.             (line 108)
2886 * GDBM_SETMMAP:                          Options.             (line 118)
2887 * gdbm_setopt:                           Options.             (line  11)
2888 * GDBM_SETSYNCMODE:                      Options.             (line  61)
2889 * gdbm_store:                            Store.               (line   8)
2890 * gdbm_strerror:                         Errors.              (line   9)
2891 * gdbm_sync:                             Sync.                (line  15)
2892 * GDBM_SYNC <1>:                         Sync.                (line   6)
2893 * GDBM_SYNC:                             Open.                (line  40)
2894 * GDBM_SYNCMODE:                         Options.             (line  61)
2895 * GDBM_UNKNOWN_UPDATE:                   Error codes.         (line  80)
2896 * gdbm_version:                          Variables.           (line  31)
2897 * gdbm_version_cmp:                      Variables.           (line  61)
2898 * GDBM_VERSION_MAJOR:                    Variables.           (line  45)
2899 * GDBM_VERSION_MINOR:                    Variables.           (line  48)
2900 * gdbm_version_number:                   Variables.           (line  34)
2901 * GDBM_VERSION_PATCH:                    Variables.           (line  51)
2902 * GDBM_WRCREAT:                          Open.                (line  28)
2903 * GDBM_WRITER:                           Open.                (line  28)
2904 * gdbmexport:                            gdbmexport.          (line   6)
2905 * gdbmtool:                              gdbmtool.            (line   6)
2906 * hash:                                  commands.            (line  52)
2907 * header:                                commands.            (line  55)
2908 * help:                                  commands.            (line  58)
2909 * import <1>:                            commands.            (line  64)
2910 * import:                                Flat files.          (line   6)
2911 * init file, gdbmtool:                   startup files.       (line   6)
2912 * interactive mode, gdbmtool:            shell.               (line   6)
2913 * iterating over records:                Sequential.          (line   6)
2914 * iteration and gdbm_delete:             Sequential.          (line  56)
2915 * iteration loop:                        Sequential.          (line  36)
2916 * iteration loop, using NDBM:            ndbm.                (line  79)
2917 * junk.gdbm:                             gdbmtool.            (line   9)
2918 * libgdbm_compat:                        Compatibility.       (line  11)
2919 * list:                                  commands.            (line  71)
2920 * lock:                                  variables.           (line 106)
2921 * locking:                               Locking.             (line   6)
2922 * looking up records:                    Fetch.               (line   6)
2923 * mmap:                                  variables.           (line 112)
2924 * NDBM functions:                        ndbm.                (line   6)
2925 * ndbm.h:                                Compatibility.       (line  11)
2926 * next:                                  commands.            (line  74)
2927 * nextkey:                               dbm.                 (line  58)
2928 * number of records:                     Count.               (line   6)
2929 * open <1>:                              commands.            (line  83)
2930 * open:                                  variables.           (line  74)
2931 * opening the database:                  Open.                (line   6)
2932 * options, database:                     Options.             (line   6)
2933 * pag file:                              Compatibility.       (line  22)
2934 * pager:                                 variables.           (line  52)
2935 * ps1:                                   variables.           (line  15)
2936 * ps2:                                   variables.           (line  33)
2937 * quiet:                                 variables.           (line  60)
2938 * quit:                                  commands.            (line 111)
2939 * read-only mode, gdbmtool:              gdbmtool.            (line  16)
2940 * record, deleting:                      Delete.              (line   6)
2941 * record, fetching:                      Fetch.               (line   6)
2942 * records, iterating over:               Sequential.          (line   6)
2943 * records, storing:                      Store.               (line   6)
2944 * records, testing existence:            Fetch.               (line  34)
2945 * reorganization, database:              Reorganization.      (line   6)
2946 * reorganize:                            commands.            (line 114)
2947 * sequential access:                     Sequential.          (line   6)
2948 * sequential access, using NDBM:         ndbm.                (line  79)
2949 * set:                                   variables.           (line 124)
2950 * source:                                commands.            (line 117)
2951 * startup file, gdbmtool:                startup files.       (line   6)
2952 * status:                                commands.            (line 120)
2953 * store <1>:                             commands.            (line 133)
2954 * store:                                 dbm.                 (line  35)
2955 * storing records:                       Store.               (line   6)
2956 * sync:                                  variables.           (line 118)
2957 * synchronization, database:             Sync.                (line   6)
2958 * unset:                                 variables.           (line 162)
2959 * variables, gdbmtool:                   variables.           (line   6)
2960 * version:                               commands.            (line 137)
2961 * version number:                        Variables.           (line  30)
2962
2963
2964 \1f
2965 Tag Table:
2966 Node: Top\7f905
2967 Node: Copying\7f3070
2968 Node: Intro\7f4853
2969 Node: List\7f6273
2970 Node: Open\7f7574
2971 Node: Close\7f10888
2972 Node: Count\7f11342
2973 Node: Store\7f11748
2974 Node: Fetch\7f13724
2975 Node: Delete\7f14946
2976 Node: Sequential\7f15712
2977 Node: Reorganization\7f18705
2978 Node: Sync\7f19714
2979 Node: Flat files\7f20804
2980 Ref: gdbm_load function\7f24322
2981 Node: Errors\7f29758
2982 Node: Options\7f30322
2983 Node: Locking\7f36056
2984 Node: Variables\7f36652
2985 Node: Error codes\7f39083
2986 Node: Compatibility\7f44928
2987 Node: ndbm\7f46506
2988 Node: dbm\7f51344
2989 Node: gdbmtool\7f54004
2990 Node: invocation\7f54983
2991 Ref: -q option\7f55605
2992 Node: shell\7f56098
2993 Ref: backslash-interpretation\7f57312
2994 Node: variables\7f58897
2995 Ref: quiet\7f61106
2996 Ref: open parameters\7f61302
2997 Ref: openvar\7f61624
2998 Ref: filemode\7f62484
2999 Node: commands\7f65062
3000 Ref: gdbmtool export\7f65717
3001 Ref: gdbmtool import\7f66972
3002 Node: definitions\7f69328
3003 Node: startup files\7f73533
3004 Node: gdbm_dump\7f74335
3005 Node: gdbm_load\7f75576
3006 Node: gdbmexport\7f77456
3007 Node: Exit codes\7f78070
3008 Node: Bugs\7f78619
3009 Node: Resources\7f79971
3010 Node: GNU Free Documentation License\7f80690
3011 Node: Index\7f105862
3012 \1f
3013 End Tag Table