diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-11-14 19:33:18 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-11-14 19:33:18 +0000 |
commit | 91751b0ce995e2b3b73fd60d4dbeade3cc4de123 (patch) | |
tree | cb9fb0fd73dac5b8cbb01aba21e5da2c21dc83d9 /doc | |
parent | f1ee8328d4f4e347b6df4f839ff6f182603e2ffd (diff) | |
download | gdbm-91751b0ce995e2b3b73fd60d4dbeade3cc4de123.tar.gz gdbm-91751b0ce995e2b3b73fd60d4dbeade3cc4de123.tar.bz2 |
Minor changes
Diffstat (limited to 'doc')
-rw-r--r-- | doc/gdbm.texinfo | 167 |
1 files changed, 135 insertions, 32 deletions
diff --git a/doc/gdbm.texinfo b/doc/gdbm.texinfo index ff93a1a..fcbc14e 100644 --- a/doc/gdbm.texinfo +++ b/doc/gdbm.texinfo | |||
@@ -660,7 +660,7 @@ guaranteed to be a byte-to-byte equivalent of the database from which | |||
660 | the flat file was created. This does not necessarily mean, however, | 660 | the flat file was created. This does not necessarily mean, however, |
661 | that this file can be used in the same way as the original one. For | 661 | that this file can be used in the same way as the original one. For |
662 | example, if the original database contained non-@acronym{ASCII} data | 662 | example, if the original database contained non-@acronym{ASCII} data |
663 | (e.g. @acronym{C} structures, integers etc.), the recreated database | 663 | (e.g.@: @acronym{C} structures, integers etc.), the recreated database |
664 | can be of any use only if the target machine has the same integer | 664 | can be of any use only if the target machine has the same integer |
665 | size and byte ordering as the source one and if its @acronym{C} | 665 | size and byte ordering as the source one and if its @acronym{C} |
666 | compiler uses the same packing conventions as the one which generated | 666 | compiler uses the same packing conventions as the one which generated |
@@ -669,25 +669,41 @@ binary databases are not portable between machines, unless you follow | |||
669 | some stringent rules on what data is written to them and how it is | 669 | some stringent rules on what data is written to them and how it is |
670 | interpreted. | 670 | interpreted. |
671 | 671 | ||
672 | @deftypefn {gdbm interface} int gdbm_export (GDBM_FILE @var{dbf}, @ | 672 | GDBM version @value{VERSION} supports two flat file formats. The |
673 | const char *@var{exportfile}, int @var{flag}, int @var{mode}) | 673 | @dfn{binary} flat file, as its name implies, keeps data in binary |
674 | Create a flat file from the @code{gdbm} database. The parameters are: | 674 | form. The @dfn{ascii} flat file, on the other hand, encodes all data |
675 | in base64 and can be sent over transmission channels that normally | ||
676 | allow only ASCII data, such as, e.g.@: SMTP. Apart from that, ASCII | ||
677 | flat files contain original database file metadata (file name, mode | ||
678 | and ownership), and can therefore be used to restore an exact copy of | ||
679 | the database. | ||
680 | |||
681 | @deftypefn {gdbm interface} int gdbm_dump (GDBM_FILE @var{dbf}, @ | ||
682 | const char *@var{filename}, int @var{format}, @ | ||
683 | int @var{open_flags}, int @var{mode}) | ||
684 | Dumps the database file to the named file in requested format. | ||
685 | Arguments are: | ||
675 | 686 | ||
676 | @table @var | 687 | @table @var |
677 | @item dbf | 688 | @item dbf |
678 | A pointer to the source database, returned by a call to | 689 | A pointer to the source database, returned by a prior call to |
679 | @code{gdbm_open}. The database must be open in @samp{GDBM_WRITER} mode. | 690 | @code{gdbm_open}. |
680 | 691 | ||
681 | @item exportfile | 692 | @item filename |
682 | The name of the output file. | 693 | Name of the dump file. |
683 | 694 | ||
684 | @item flag | 695 | @item format |
685 | @kwindex GDBM_WRCREAT | 696 | Dump format. Allowed values are: @samp{GDBM_DUMP_FMT_BINARY} to |
686 | @kwindex GDBM_NEWDB | 697 | create a binary dump and @samp{GDBM_DUMP_FMT_ASCII} to create an ASCII |
687 | How to create the output file. If @var{flag} is @samp{GDBM_WRCREAT}, | 698 | dump file. |
688 | the file will be created if it does not exist already. Otherwise, if | 699 | |
689 | it is @samp{GDBM_NEWDB}, it will be created if it does not exist, and | 700 | @item open_flags |
690 | truncated otherwise. | 701 | How to create the output file. If @var{flag} is @samp{GDBM_WRCREAT} |
702 | the file will be created if it does not exist. If it does exist, | ||
703 | the @code{gdbm_dump} will fail. | ||
704 | |||
705 | If @var{flag} is @samp{GDBM_NEWDB}, the function will create a new | ||
706 | output file, replacing it if it already exists. | ||
691 | 707 | ||
692 | @item mode | 708 | @item mode |
693 | The permissions to use when creating the output file. | 709 | The permissions to use when creating the output file. |
@@ -701,27 +717,107 @@ for a detailed discussion. | |||
701 | @end table | 717 | @end table |
702 | @end deftypefn | 718 | @end deftypefn |
703 | 719 | ||
704 | @deftypefn {gdbm interface} int gdbm_import (GDBM_FILE @var{dbf}, @ | 720 | @anchor{gdbm_load function} |
705 | const char *@var{importfile}, int @var{flag}) | 721 | @deftypefn {gdbm interface} int gdbm_load (GDBM_FILE *@var{pdbf}, @ |
706 | Populates the database from an existing flat file. | 722 | const char *@var{filename}, int @var{flag}, unsigned long *@var{errline}) |
723 | Loads data from the dump file @var{filename} into the database pointed | ||
724 | to by @var{pdbf}. The latter can point to @samp{NULL}, in which case | ||
725 | the function will try to create a new database. If it succeeds, the | ||
726 | function will return a pointer to the newly created database in the | ||
727 | memory location pointed to by @var{pdbf}. If the dump file carries no | ||
728 | information about the original database file name, the function will | ||
729 | set @code{gdbm_errno} to @samp{GDBM_NO_DBNAME} and return | ||
730 | @samp{-1}, indicating failure. | ||
731 | |||
732 | The @var{flag} has the same meaning as the @var{flag} argument | ||
733 | to the @code{gdbm_store} function (@pxref{Store}). | ||
734 | |||
735 | The function returns 0 upon successful completion or -1 on error. In | ||
736 | the latter case, @code{gdbm_errno} will be set to one of the | ||
737 | following values: | ||
738 | |||
739 | @table @asis | ||
740 | @item GDBM_FILE_OPEN_ERROR | ||
741 | Input file (@var{filename}) cannot be opened. The @code{errno} | ||
742 | variable can be used to get more detail about the failure. | ||
743 | |||
744 | @item GDBM_MALLOC_ERROR | ||
745 | Not enough memory to load data. | ||
746 | |||
747 | @item GDBM_FILE_READ_ERROR | ||
748 | Reading from @var{filename} failed. The @code{errno} variable can be | ||
749 | used to get more detail about the failure. | ||
750 | |||
751 | @item GDBM_ILLEGAL_DATA | ||
752 | Input contained some illegal data. | ||
753 | |||
754 | @item GDBM_ITEM_NOT_FOUND | ||
755 | This error can occur only when the input file is in ASCII format. It | ||
756 | indicates that the data part of the record about to be read lacked | ||
757 | length specification. Application developers are advised to treat | ||
758 | this error equally as @samp{GDBM_ILLEGAL_DATA}. | ||
759 | @end table | ||
760 | |||
761 | If any error, excepting @var{GDBM_FILE_OPEN_ERROR}, occurs and the | ||
762 | input file is in ASCII format, the number of line in which the error | ||
763 | occurred will be stored in the location pointed to by the | ||
764 | @var{errline} parameter, unless it is @samp{NULL}. | ||
765 | @end deftypefn | ||
766 | |||
767 | @deftypefn {gdbm interface} int gdbm_dump_to_file (GDBM_FILE @var{dbf}, @ | ||
768 | FILE *@var{fp}, int @var{format}) | ||
769 | This is an alternative entry point to @code{gdbm_dump} (which see). | ||
770 | Arguments are: | ||
707 | 771 | ||
708 | @table @var | 772 | @table @var |
709 | @item dbf | 773 | @item dbf |
710 | A pointer to the source database, returned by a call to | 774 | A pointer to the source database, returned by a call to |
711 | @code{gdbm_open}. The database must be open in @samp{GDBM_WRITER} mode. | 775 | @code{gdbm_open}. |
712 | 776 | ||
713 | @item importfile | 777 | @item fp |
714 | The name of the input flat file. The file must exist. | 778 | File to write the data to. |
715 | 779 | ||
716 | @item flag | 780 | @item format |
717 | The @var{flag} argument to be passed to @code{gdbm_store} function | 781 | Format of the dump file. See the @var{format} argument to the |
718 | when adding new records. @xref{Store}, for a description of its | 782 | @code{gdbm_dump} function. |
719 | effect. | ||
720 | @end table | 783 | @end table |
721 | @end deftypefn | 784 | @end deftypefn |
785 | |||
786 | @deftypefn {gdbm interface} int gdbm_load_from_file (GDBM_FILE *@var{pdbf}, @ | ||
787 | FILE *@var{fp}, int @var{replace}, unsigned long *@var{line}) | ||
788 | This is an alternative entry point to @code{gdbm_dump}. It writes the | ||
789 | output to @var{fp} which must be a file open for writing. The rest of | ||
790 | arguments is the same as for @code{gdbm_load} (excepting of course | ||
791 | @var{flag}, which is not needed in this case). | ||
792 | @end deftypefn | ||
793 | |||
794 | @deftypefn {gdbm interface} int gdbm_export (GDBM_FILE @var{dbf}, @ | ||
795 | const char *@var{exportfile}, int @var{flag}, int @var{mode}) | ||
796 | This function is retained for compatibility with GDBM 1.10 and | ||
797 | earlier. It dumps the database to a file in binary dump format and | ||
798 | is entirely equivalent to | ||
799 | |||
800 | @example | ||
801 | gdbm_dump(@var{dbf}, @var{exportfile}, GDBM_DUMP_FMT_BINARY, | ||
802 | @var{flag}, @var{mode}) | ||
803 | @end example | ||
804 | @end deftypefn | ||
805 | |||
806 | @deftypefn {gdbm interface} int gdbm_import (GDBM_FILE @var{dbf}, @ | ||
807 | const char *@var{importfile}, int @var{flag}) | ||
808 | This function is retained for compatibility with GDBM 1.10 and | ||
809 | earlier. It loads the file @var{importfile}, which must be a binary | ||
810 | flat file, into the database @var{dbf} and is equivalent to the | ||
811 | following construct: | ||
722 | 812 | ||
723 | See also @ref{gdbmexport}, @ref{testgdbm export}, and | 813 | @example |
724 | @ref{testgdbm import}. | 814 | @var{dbf} = gdbm_open (@var{importfile}, 0, |
815 | @var{flag} == GDBM_REPLACE ? GDBM_WRCREAT : | ||
816 | GDBM_NEWDB, 0600, NULL); | ||
817 | gdbm_load (&@var{dbf}, @var{exportfile}, GDBM_DUMP_FMT_BINARY, | ||
818 | @var{flag}, NULL) | ||
819 | @end example | ||
820 | @end deftypefn | ||
725 | 821 | ||
726 | @node Errors | 822 | @node Errors |
727 | @chapter Error strings. | 823 | @chapter Error strings. |
@@ -796,7 +892,7 @@ been altered by another calls to @code{gdbm_setopt}. | |||
796 | 892 | ||
797 | @kwindex GDBM_FASTMODE | 893 | @kwindex GDBM_FASTMODE |
798 | @item GDBM_FASTMODE | 894 | @item GDBM_FASTMODE |
799 | Enable or disable the @dfn{fast writes mode}, i.e. writes without | 895 | Enable or disable the @dfn{fast writes mode}, i.e.@: writes without |
800 | subsequent synchronization. The @var{value} should point | 896 | subsequent synchronization. The @var{value} should point |
801 | to an integer: @samp{TRUE} to enable fast mode, and @samp{FALSE} to | 897 | to an integer: @samp{TRUE} to enable fast mode, and @samp{FALSE} to |
802 | disable it. | 898 | disable it. |
@@ -815,7 +911,7 @@ to an integer: @samp{TRUE} to turn synchronization on, and @samp{FALSE} to | |||
815 | turn it off. | 911 | turn it off. |
816 | 912 | ||
817 | Note, that this option is a reverse of @code{GDBM_FASTMODE}, | 913 | Note, that this option is a reverse of @code{GDBM_FASTMODE}, |
818 | i.e. calling @code{GDBM_SETSYNCMODE} with @samp{TRUE} has the same effect | 914 | i.e.@: calling @code{GDBM_SETSYNCMODE} with @samp{TRUE} has the same effect |
819 | as calling @code{GDBM_FASTMODE} with @samp{FALSE}. | 915 | as calling @code{GDBM_FASTMODE} with @samp{FALSE}. |
820 | 916 | ||
821 | The @samp{GDBM_SYNCMODE} option is provided for compatibility with | 917 | The @samp{GDBM_SYNCMODE} option is provided for compatibility with |
@@ -1074,7 +1170,7 @@ data> @kbd{3} | |||
1074 | @end example | 1170 | @end example |
1075 | 1171 | ||
1076 | However, such prompting is possible only in interactive mode. In | 1172 | However, such prompting is possible only in interactive mode. In |
1077 | non-interactive mode (e.g. when running a script), all arguments must | 1173 | non-interactive mode (e.g.@: when running a script), all arguments must |
1078 | be supplied with each command, otherwise @command{testgdbm} will report an | 1174 | be supplied with each command, otherwise @command{testgdbm} will report an |
1079 | error and exit immediately. | 1175 | error and exit immediately. |
1080 | 1176 | ||
@@ -1282,7 +1378,7 @@ gdbm_import}) or the @code{i} command of @command{testgdbm} utility | |||
1282 | (@pxref{testgdbm import}). In many cases files in this format are suitable for | 1378 | (@pxref{testgdbm import}). In many cases files in this format are suitable for |
1283 | sending over the network to populate the database on another machine. |