aboutsummaryrefslogtreecommitdiff
path: root/doc/gdbm.texinfo
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-03 12:40:15 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-03 12:40:15 +0000
commitd04fa3e655613536ef7610c896ddd4b7a8a37d2f (patch)
tree63b24fc5a91fb7f26581ce1d1262395d79cab34c /doc/gdbm.texinfo
parentb1135c2901ebe6331b1794002eec47c4b214f82c (diff)
downloadgdbm-d04fa3e655613536ef7610c896ddd4b7a8a37d2f.tar.gz
gdbm-d04fa3e655613536ef7610c896ddd4b7a8a37d2f.tar.bz2
Document flat format and related functions.
Diffstat (limited to 'doc/gdbm.texinfo')
-rw-r--r--doc/gdbm.texinfo140
1 files changed, 122 insertions, 18 deletions
diff --git a/doc/gdbm.texinfo b/doc/gdbm.texinfo
index 27730f4..6211f67 100644
--- a/doc/gdbm.texinfo
+++ b/doc/gdbm.texinfo
@@ -22,6 +22,13 @@
22@defcodeindex fl 22@defcodeindex fl
23@syncodeindex fl cp 23@syncodeindex fl cp
24 24
25@c Merge all indices into a single one
26@syncodeindex fn cp
27@syncodeindex vr cp
28@syncodeindex ky cp
29@syncodeindex pg cp
30@syncodeindex tp cp
31
25@iftex 32@iftex
26@finalout 33@finalout
27@end iftex 34@end iftex
@@ -122,6 +129,7 @@ Functions:
122* Sequential:: Sequential access to records. 129* Sequential:: Sequential access to records.
123* Reorganization:: Database reorganization. 130* Reorganization:: Database reorganization.
124* Sync:: Insure all writes to disk have competed. 131* Sync:: Insure all writes to disk have competed.
132* Flat files:: Export and import to Flat file format.
125* Errors:: Convert internal error codes into English. 133* Errors:: Convert internal error codes into English.
126* Options:: Setting internal options. 134* Options:: Setting internal options.
127* Locking:: File locking. 135* Locking:: File locking.
@@ -300,12 +308,12 @@ chmod(2) man page},
300@end ifnothtml 308@end ifnothtml
301and 309and
302@ifhtml 310@ifhtml
303@uref{http://www.manpagez.com/man/2/open}, 311@uref{http://www.manpagez.com/man/2/open}),
304@end ifhtml 312@end ifhtml
305@ifnothtml 313@ifnothtml
306@pxref{open,,open a file,open(2), open(2) man page} 314@pxref{open,,open a file,open(2), open(2) man page}),
307@end ifnothtml 315@end ifnothtml
308), which is used if the file is created). 316which is used if the file is created).
309@item fatal_func 317@item fatal_func
310A function for @code{gdbm} to call if it detects a fatal error. The only 318A function for @code{gdbm} to call if it detects a fatal error. The only
311parameter of this function is a string. If the value of @samp{NULL} is 319parameter of this function is a string. If the value of @samp{NULL} is
@@ -604,6 +612,83 @@ The @code{gdbm_close} function automatically calls the equivalent of
604immediately after the set of changes have been made. 612immediately after the set of changes have been made.
605@end deftypefn 613@end deftypefn
606 614
615@node Flat files
616@chapter Export and Import
617@cindex Flat file format
618@cindex export
619@cindex import
620@code{Gdbm} databases can be converted into a protable @dfn{flat
621format}. This format can be used, for example, to migrate between
622the different versions of @code{gdbm} databases. Generally speaking,
623flat files are safe to send over the network, and can be used to
624recreate the database on another machine. The recreated database is
625guaranteed to be a byte-to-byte equivalent of the database from which
626the flat file was created. This does not necessarily mean, however,
627that this file can be used in the same way as the original one. For
628example, if the original database contained non-@acronym{ASCII} data
629(e.g. @acronym{C} structures, integers etc.), the recreated database
630can be of any use only if the target machine has the same integer
631size and byte ordering as the source one and if its @acronym{C}
632compiler uses the same packing conventions as the one which generated
633@acronym{C} which populated the original database. In general, such
634binary databases are not portable between machines, unless you follow
635some stringent rules on what data is written to them and how it is
636interpreted.
637
638@deftypefn {gdbm interface} int gdbm_export (GDBM_FILE @var{dbf}, @
639 const char *@var{exportfile}, int @var{flag}, int @var{mode})
640Create a flat file from the @code{gdbm} database. The parameters are:
641
642@table @var
643@item dbf
644A pointer to the source database, returned by a call to
645@code{gdbm_open}. The database must be open in @samp{GDBM_WRITER} mode.
646
647@item exportfile
648The name of the output file.
649
650@item flag
651@kwindex GDBM_WRCREAT
652@kwindex GDBM_NEWDB
653How to create the output file. If @var{flag} is @samp{GDBM_WRCREAT},
654the file will be created if it does not exist already. Otherwise, if
655it is @samp{GDBM_NEWDB}, it will be created if it does not exist, and
656truncated otherwise.
657
658@item mode
659The permissions to use when creating the output file.
660See @ifhtml
661@uref{http://www.manpagez.com/man/2/open},
662@end ifhtml
663@ifnothtml
664@ref{open,,open a file,open(2), open(2) man page},
665@end ifnothtml
666for a detailed discussion.
667@end table
668@end deftypefn
669
670@deftypefn {gdbm interface} int gdbm_import (GDBM_FILE @var{dbf}, @
671 const char *@var{importfile}, int @var{flag})
672Populates the database from an existing flat file.
673
674@table @var
675@item dbf
676A pointer to the source database, returned by a call to
677@code{gdbm_open}. The database must be open in @samp{GDBM_WRITER} mode.
678
679@item importfile
680The name of the input flat file. The file must exist.
681
682@item flag
683The @var{flag} argument to be passed to @code{gdbm_store} function
684when adding new records. @xref{Store}, for a description of its
685effect.
686@end table
687@end deftypefn
688
689See also @ref{gdbmexport}, @ref{testgdbm export}, and
690@ref{testgdbm import}.
691
607@node Errors 692@node Errors
608@chapter Error strings. 693@chapter Error strings.
609 694
@@ -828,7 +913,7 @@ error and exits immediately.
828 913
829@anchor{pager} 914@anchor{pager}
830@cindex pager, @command{testgdbm} 915@cindex pager, @command{testgdbm}
831@cindex @env{PAGER}. 916@cindex @env{PAGER}
832Some commands produce excessive amounts of output. To help you follow 917Some commands produce excessive amounts of output. To help you follow
833it, @command{testgdbm} will use a pager utility to display such 918it, @command{testgdbm} will use a pager utility to display such
834output. The name of the pager utility is taken from the environment 919output. The name of the pager utility is taken from the environment
@@ -850,19 +935,22 @@ The following table summarizes all available commands:
850Print the number of entries in the database. 935Print the number of entries in the database.
851@item d @var{key} 936@item d @var{key}
852Delete entry with a given @var{key} 937Delete entry with a given @var{key}
938@anchor{testgdbm export}
853@item e @var{file-name} [truncate] 939@item e @var{file-name} [truncate]
854Export the database (similar to @command{gdbmexport}, 940Export the database to the flat file @var{file-name}. @xref{Flat files},
855@pxref{gdbmexport}) to file @var{file-name}. This command will not 941for a description of the flat file format and its purposes. This
856overwrite an existing file, unless the word @samp{truncate} is given 942command will not overwrite an existing file, unless the word
857as its second argument. 943@samp{truncate} is given as its second argument.
944
945See also @ref{gdbmexport}.
858 946
859@item f @var{key} 947@item f @var{key}
860Fetch and display a record with the given @var{key}. 948Fetch and display a record with the given @var{key}.
861 949
862@anchor{import} 950@anchor{testgdbm import}
863@item i @var{file-name} [replace] 951@item i @var{file-name} [replace]
864Import data from a flat dump file @var{file-name} 952Import data from a flat dump file @var{file-name}
865(@pxref{gdbmexport}). If the word @samp{replace} is given 953(@pxref{Flat files}). If the word @samp{replace} is given
866as the second argument, any records with the same keys as the already 954as the second argument, any records with the same keys as the already
867existing ones will replace them. 955existing ones will replace them.
868 956
@@ -961,8 +1049,9 @@ Quit the program.
961 1049
962The @command{gdbmexport} utility converts the database into a portable 1050The @command{gdbmexport} utility converts the database into a portable
963@dfn{flat format}. Files in this format can be used to populate 1051@dfn{flat format}. Files in this format can be used to populate
964databases using the @code{i} command of @command{testgdbm} utility 1052databases using the @code{gdbm_import} function (@pxref{Flat files,
965(@pxref{import}). In many cases files in this format are suitable for 1053gdbm_import}) or the @code{i} command of @command{testgdbm} utility
1054(@pxref{testgdbm import}). In many cases files in this format are suitable for
966sending over the network to populate the database on another machine. 1055sending over the network to populate the database on another machine.
967The only exception to this are databases whose records contain 1056The only exception to this are databases whose records contain
968non-@acronym{ASCII} data (e.g. @acronym{C} structures, integers 1057non-@acronym{ASCII} data (e.g. @acronym{C} structures, integers
@@ -992,7 +1081,7 @@ Display program version and licensing information, and exit.
992@end table 1081@end table
993 1082
994@node Variables 1083@node Variables
995@chapter Two useful variables. 1084@chapter Useful global variables.
996 1085
997The following two variables are variables that may need to be used: 1086The following two variables are variables that may need to be used:
998 1087
@@ -1009,6 +1098,23 @@ descriptive text.
1009A string containing the version information. 1098A string containing the version information.
1010@end deftypevar 1099@end deftypevar
1011 1100
1101@deftypevar const char * const gdbm_errlist[]
1102This variable is an array of error descriptions, which is used by
1103@code{gdbm_strerror} to convert error codes to human-readable text
1104(@pxref{Errors}). You can access it directly, if you wish so. It
1105contains @code{_GDBM_MAX_ERRNO + 1} elements and can be directly
1106indexed by the error code to obtain a corresponding descriptive
1107text.
1108@end deftypevar
1109
1110@defvr {Constant} _GDBM_MIN_ERRNO
1111The minimum error code used by @code{gdbm}.
1112@end defvr
1113
1114@defvr {Constant} _GDBM_MAX_ERRNO
1115The maximum error code used by @code{gdbm}.
1116@end defvr
1117
1012@node Error codes 1118@node Error codes
1013@chapter Error codes 1119@chapter Error codes
1014 1120
@@ -1031,10 +1137,9 @@ the value of its @var{block_size} argument is incorrect.
1031 1137
1032@kwindex GDBM_FILE_OPEN_ERROR 1138@kwindex GDBM_FILE_OPEN_ERROR
1033@item GDBM_FILE_OPEN_ERROR 1139@item GDBM_FILE_OPEN_