aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-11-14 19:33:18 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-11-14 19:33:18 +0000
commit91751b0ce995e2b3b73fd60d4dbeade3cc4de123 (patch)
treecb9fb0fd73dac5b8cbb01aba21e5da2c21dc83d9 /doc
parentf1ee8328d4f4e347b6df4f839ff6f182603e2ffd (diff)
downloadgdbm-91751b0ce995e2b3b73fd60d4dbeade3cc4de123.tar.gz
gdbm-91751b0ce995e2b3b73fd60d4dbeade3cc4de123.tar.bz2
Minor changes
Diffstat (limited to 'doc')
-rw-r--r--doc/gdbm.texinfo167
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
660the flat file was created. This does not necessarily mean, however, 660the flat file was created. This does not necessarily mean, however,
661that this file can be used in the same way as the original one. For 661that this file can be used in the same way as the original one. For
662example, if the original database contained non-@acronym{ASCII} data 662example, 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
664can be of any use only if the target machine has the same integer 664can be of any use only if the target machine has the same integer
665size and byte ordering as the source one and if its @acronym{C} 665size and byte ordering as the source one and if its @acronym{C}
666compiler uses the same packing conventions as the one which generated 666compiler uses the same packing conventions as the one which generated
@@ -669,25 +669,41 @@ binary databases are not portable between machines, unless you follow
669some stringent rules on what data is written to them and how it is 669some stringent rules on what data is written to them and how it is
670interpreted. 670interpreted.
671 671
672@deftypefn {gdbm interface} int gdbm_export (GDBM_FILE @var{dbf}, @ 672GDBM 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
674Create a flat file from the @code{gdbm} database. The parameters are: 674form. The @dfn{ascii} flat file, on the other hand, encodes all data
675in base64 and can be sent over transmission channels that normally
676allow only ASCII data, such as, e.g.@: SMTP. Apart from that, ASCII
677flat files contain original database file metadata (file name, mode
678and ownership), and can therefore be used to restore an exact copy of
679the 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})
684Dumps the database file to the named file in requested format.
685Arguments are:
675 686
676@table @var 687@table @var
677@item dbf 688@item dbf
678A pointer to the source database, returned by a call to 689A 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
682The name of the output file. 693Name of the dump file.
683 694
684@item flag 695@item format
685@kwindex GDBM_WRCREAT 696Dump format. Allowed values are: @samp{GDBM_DUMP_FMT_BINARY} to
686@kwindex GDBM_NEWDB 697create a binary dump and @samp{GDBM_DUMP_FMT_ASCII} to create an ASCII
687How to create the output file. If @var{flag} is @samp{GDBM_WRCREAT}, 698dump file.
688the file will be created if it does not exist already. Otherwise, if 699
689it is @samp{GDBM_NEWDB}, it will be created if it does not exist, and 700@item open_flags
690truncated otherwise. 701How to create the output file. If @var{flag} is @samp{GDBM_WRCREAT}
702the file will be created if it does not exist. If it does exist,
703the @code{gdbm_dump} will fail.
704
705If @var{flag} is @samp{GDBM_NEWDB}, the function will create a new
706output file, replacing it if it already exists.
691 707
692@item mode 708@item mode
693The permissions to use when creating the output file. 709The 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}, @
706Populates the database from an existing flat file. 722 const char *@var{filename}, int @var{flag}, unsigned long *@var{errline})
723Loads data from the dump file @var{filename} into the database pointed
724to by @var{pdbf}. The latter can point to @samp{NULL}, in which case
725the function will try to create a new database. If it succeeds, the
726function will return a pointer to the newly created database in the
727memory location pointed to by @var{pdbf}. If the dump file carries no
728information about the original database file name, the function will
729set @code{gdbm_errno} to @samp{GDBM_NO_DBNAME} and return
730@samp{-1}, indicating failure.
731
732The @var{flag} has the same meaning as the @var{flag} argument
733to the @code{gdbm_store} function (@pxref{Store}).
734
735The function returns 0 upon successful completion or -1 on error. In
736the latter case, @code{gdbm_errno} will be set to one of the
737following values:
738
739@table @asis
740@item GDBM_FILE_OPEN_ERROR
741Input file (@var{filename}) cannot be opened. The @code{errno}
742variable can be used to get more detail about the failure.
743
744@item GDBM_MALLOC_ERROR
745Not enough memory to load data.
746
747@item GDBM_FILE_READ_ERROR
748Reading from @var{filename} failed. The @code{errno} variable can be
749used to get more detail about the failure.
750
751@item GDBM_ILLEGAL_DATA
752Input contained some illegal data.
753
754@item GDBM_ITEM_NOT_FOUND
755This error can occur only when the input file is in ASCII format. It
756indicates that the data part of the record about to be read lacked
757length specification. Application developers are advised to treat
758this error equally as @samp{GDBM_ILLEGAL_DATA}.
759@end table
760
761If any error, excepting @var{GDBM_FILE_OPEN_ERROR}, occurs and the
762input file is in ASCII format, the number of line in which the error
763occurred 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})
769This is an alternative entry point to @code{gdbm_dump} (which see).
770Arguments are:
707 771
708@table @var 772@table @var
709@item dbf 773@item dbf
710A pointer to the source database, returned by a call to 774A 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
714The name of the input flat file. The file must exist. 778File to write the data to.
715 779
716@item flag 780@item format
717The @var{flag} argument to be passed to @code{gdbm_store} function 781Format of the dump file. See the @var{format} argument to the
718when adding new records. @xref{Store}, for a description of its 782@code{gdbm_dump} function.
719effect.
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})
788This is an alternative entry point to @code{gdbm_dump}. It writes the
789output to @var{fp} which must be a file open for writing. The rest of
790arguments 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})
796This function is retained for compatibility with GDBM 1.10 and
797earlier. It dumps the database to a file in binary dump format and
798is entirely equivalent to
799
800@example
801gdbm_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})
808This function is retained for compatibility with GDBM 1.10 and
809earlier. It loads the file @var{importfile}, which must be a binary
810flat file, into the database @var{dbf} and is equivalent to the
811following construct:
722 812
723See 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);
817gdbm_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
799Enable or disable the @dfn{fast writes mode}, i.e. writes without 895Enable or disable the @dfn{fast writes mode}, i.e.@: writes without
800subsequent synchronization. The @var{value} should point 896subsequent synchronization. The @var{value} should point
801to an integer: @samp{TRUE} to enable fast mode, and @samp{FALSE} to 897to an integer: @samp{TRUE} to enable fast mode, and @samp{FALSE} to
802disable it. 898disable it.
@@ -815,7 +911,7 @@ to an integer: @samp{TRUE} to turn synchronization on, and @samp{FALSE} to
815turn it off. 911turn it off.
816 912
817Note, that this option is a reverse of @code{GDBM_FASTMODE}, 913Note, that this option is a reverse of @code{GDBM_FASTMODE},
818i.e. calling @code{GDBM_SETSYNCMODE} with @samp{TRUE} has the same effect 914i.e.@: calling @code{GDBM_SETSYNCMODE} with @samp{TRUE} has the same effect
819as calling @code{GDBM_FASTMODE} with @samp{FALSE}. 915as calling @code{GDBM_FASTMODE} with @samp{FALSE}.
820 916
821The @samp{GDBM_SYNCMODE} option is provided for compatibility with 917The @samp{GDBM_SYNCMODE} option is provided for compatibility with
@@ -1074,7 +1170,7 @@ data> @kbd{3}
1074@end example 1170@end example
1075 1171
1076However, such prompting is possible only in interactive mode. In 1172However, such prompting is possible only in interactive mode. In
1077non-interactive mode (e.g. when running a script), all arguments must 1173non-interactive mode (e.g.@: when running a script), all arguments must
1078be supplied with each command, otherwise @command{testgdbm} will report an 1174be supplied with each command, otherwise @command{testgdbm} will report an
1079error and exit immediately. 1175error 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
1283sending over the network to populate the database on another machine.