diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-08-03 12:40:15 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-08-03 12:40:15 +0000 |
commit | d04fa3e655613536ef7610c896ddd4b7a8a37d2f (patch) | |
tree | 63b24fc5a91fb7f26581ce1d1262395d79cab34c /doc/gdbm.texinfo | |
parent | b1135c2901ebe6331b1794002eec47c4b214f82c (diff) | |
download | gdbm-d04fa3e655613536ef7610c896ddd4b7a8a37d2f.tar.gz gdbm-d04fa3e655613536ef7610c896ddd4b7a8a37d2f.tar.bz2 |
Document flat format and related functions.
Diffstat (limited to 'doc/gdbm.texinfo')
-rw-r--r-- | doc/gdbm.texinfo | 140 |
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 |
301 | and | 309 | and |
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). | 316 | which is used if the file is created). |
309 | @item fatal_func | 317 | @item fatal_func |
310 | A function for @code{gdbm} to call if it detects a fatal error. The only | 318 | A function for @code{gdbm} to call if it detects a fatal error. The only |
311 | parameter of this function is a string. If the value of @samp{NULL} is | 319 | parameter 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 | |||
604 | immediately after the set of changes have been made. | 612 | immediately 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 | ||
621 | format}. This format can be used, for example, to migrate between | ||
622 | the different versions of @code{gdbm} databases. Generally speaking, | ||
623 | flat files are safe to send over the network, and can be used to | ||
624 | recreate the database on another machine. The recreated database is | ||
625 | guaranteed to be a byte-to-byte equivalent of the database from which | ||
626 | the flat file was created. This does not necessarily mean, however, | ||
627 | that this file can be used in the same way as the original one. For | ||
628 | example, if the original database contained non-@acronym{ASCII} data | ||
629 | (e.g. @acronym{C} structures, integers etc.), the recreated database | ||
630 | can be of any use only if the target machine has the same integer | ||
631 | size and byte ordering as the source one and if its @acronym{C} | ||
632 | compiler uses the same packing conventions as the one which generated | ||
633 | @acronym{C} which populated the original database. In general, such | ||
634 | binary databases are not portable between machines, unless you follow | ||
635 | some stringent rules on what data is written to them and how it is | ||
636 | interpreted. | ||
637 | |||
638 | @deftypefn {gdbm interface} int gdbm_export (GDBM_FILE @var{dbf}, @ | ||
639 | const char *@var{exportfile}, int @var{flag}, int @var{mode}) | ||
640 | Create a flat file from the @code{gdbm} database. The parameters are: | ||
641 | |||
642 | @table @var | ||
643 | @item dbf | ||
644 | A 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 | ||
648 | The name of the output file. | ||
649 | |||
650 | @item flag | ||
651 | @kwindex GDBM_WRCREAT | ||
652 | @kwindex GDBM_NEWDB | ||
653 | How to create the output file. If @var{flag} is @samp{GDBM_WRCREAT}, | ||
654 | the file will be created if it does not exist already. Otherwise, if | ||
655 | it is @samp{GDBM_NEWDB}, it will be created if it does not exist, and | ||
656 | truncated otherwise. | ||
657 | |||
658 | @item mode | ||
659 | The permissions to use when creating the output file. | ||
660 | See @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 | ||
666 | for 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}) | ||
672 | Populates the database from an existing flat file. | ||
673 | |||
674 | @table @var | ||
675 | @item dbf | ||
676 | A 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 | ||
680 | The name of the input flat file. The file must exist. | ||
681 | |||
682 | @item flag | ||
683 | The @var{flag} argument to be passed to @code{gdbm_store} function | ||
684 | when adding new records. @xref{Store}, for a description of its | ||
685 | effect. | ||
686 | @end table | ||
687 | @end deftypefn | ||
688 | |||
689 | See 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} |
832 | Some commands produce excessive amounts of output. To help you follow | 917 | Some commands produce excessive amounts of output. To help you follow |
833 | it, @command{testgdbm} will use a pager utility to display such | 918 | it, @command{testgdbm} will use a pager utility to display such |
834 | output. The name of the pager utility is taken from the environment | 919 | output. The name of the pager utility is taken from the environment |
@@ -850,19 +935,22 @@ The following table summarizes all available commands: | |||
850 | Print the number of entries in the database. | 935 | Print the number of entries in the database. |
851 | @item d @var{key} | 936 | @item d @var{key} |
852 | Delete entry with a given @var{key} | 937 | Delete entry with a given @var{key} |
938 | @anchor{testgdbm export} | ||
853 | @item e @var{file-name} [truncate] | 939 | @item e @var{file-name} [truncate] |
854 | Export the database (similar to @command{gdbmexport}, | 940 | Export the database to the flat file @var{file-name}. @xref{Flat files}, |
855 | @pxref{gdbmexport}) to file @var{file-name}. This command will not | 941 | for a description of the flat file format and its purposes. This |
856 | overwrite an existing file, unless the word @samp{truncate} is given | 942 | command will not overwrite an existing file, unless the word |
857 | as its second argument. | 943 | @samp{truncate} is given as its second argument. |
944 | |||
945 | See also @ref{gdbmexport}. | ||
858 | 946 | ||
859 | @item f @var{key} | 947 | @item f @var{key} |
860 | Fetch and display a record with the given @var{key}. | 948 | Fetch 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] |
864 | Import data from a flat dump file @var{file-name} | 952 | Import 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 |
866 | as the second argument, any records with the same keys as the already | 954 | as the second argument, any records with the same keys as the already |
867 | existing ones will replace them. | 955 | existing ones will replace them. |
868 | 956 | ||
@@ -961,8 +1049,9 @@ Quit the program. | |||
961 | 1049 | ||
962 | The @command{gdbmexport} utility converts the database into a portable | 1050 | The @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 |
964 | databases using the @code{i} command of @command{testgdbm} utility | 1052 | databases using the @code{gdbm_import} function (@pxref{Flat files, |
965 | (@pxref{import}). In many cases files in this format are suitable for | 1053 | gdbm_import}) or the @code{i} command of @command{testgdbm} utility |
1054 | (@pxref{testgdbm import}). In many cases files in this format are suitable for | ||
966 | sending over the network to populate the database on another machine. | 1055 | sending over the network to populate the database on another machine. |
967 | The only exception to this are databases whose records contain | 1056 | The only exception to this are databases whose records contain |
968 | non-@acronym{ASCII} data (e.g. @acronym{C} structures, integers | 1057 | non-@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 | ||
997 | The following two variables are variables that may need to be used: | 1086 | The following two variables are variables that may need to be used: |
998 | 1087 | ||
@@ -1009,6 +1098,23 @@ descriptive text. | |||
1009 | A string containing the version information. | 1098 | A string containing the version information. |
1010 | @end deftypevar | 1099 | @end deftypevar |
1011 | 1100 | ||
1101 | @deftypevar const char * const gdbm_errlist[] | ||
1102 | This 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 | ||
1105 | contains @code{_GDBM_MAX_ERRNO + 1} elements and can be directly | ||
1106 | indexed by the error code to obtain a corresponding descriptive | ||
1107 | text. | ||
1108 | @end deftypevar | ||
1109 | |||
1110 | @defvr {Constant} _GDBM_MIN_ERRNO | ||
1111 | The minimum error code used by @code{gdbm}. | ||
1112 | @end defvr | ||
1113 | |||
1114 | @defvr {Constant} _GDBM_MAX_ERRNO | ||
1115 | The 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_ |