⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdbm.3.html

📁 开源的数据库管理系统 说明文档! gdbm 适用场合很多
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!-- manual page source format generated by PolyglotMan v3.2, -->
<!-- available at http://polyglotman.sourceforge.net/ -->

<html>
<head>
<title>GDBM(3) manual page</title>
</head>
<body bgcolor='white'>
<a href='#toc'>Table of Contents</a><p>

<h2><a name='sect0' href='#toc0'>Name</a></h2>
GDBM - The GNU database manager.  Includes <b>dbm</b> and <b>ndbm</b> compatability.
(Version .) 
<h2><a name='sect1' href='#toc1'>Synopsis</a></h2>
<b>#include &lt;gdbm.h&gt;</b> <p>
<font size='-1'></font>
 <b>extern gdbm_error</b> <br>
<b>gdbm_errno</b> <p>
<b>extern char</b> <br>
<b>*gdbm_version</b> <p>
<b>GDBM_FILE</b> <br>
<b>gdbm_open (name, block_size, read_write, mode, fatal_func)</b> <br>
<b>char * name;</b> <br>
<b>int block_size, read_write, mode;</b> <br>
<b>void (*fatal_func) ();</b> <p>
<b>void</b> <br>
<b>gdbm_close (dbf)</b> <br>
<b>GDBM_FILE dbf;</b> <p>
<b>int</b> <br>
<b>gdbm_store (dbf, key, content, flag)</b> <br>
<b>GDBM_FILE dbf;</b> <br>
<b>datum key, content;</b> <br>
<b>int flag;</b> <p>
<b>datum</b> <br>
<b>gdbm_fetch (dbf, key)</b> <br>
<b>GDBM_FILE dbf;</b> <br>
<b>datum key;</b> <p>
<b>int</b> <br>
<b>gdbm_delete (dbf, key)</b> <br>
<b>GDBM_FILE dbf;</b> <br>
<b>datum key;</b> <p>
<b>datum</b> <br>
<b>gdbm_firstkey (dbf)</b> <br>
<b>GDBM_FILE dbf;</b> <p>
<b>datum</b> <br>
<b>gdbm_nextkey (dbf, key)</b> <br>
<b>GDBM_FILE dbf;</b> <br>
<b>datum key;</b> <p>
<b>int</b> <br>
<b>gdbm_reorganize (dbf)</b> <br>
<b>GDBM_FILE dbf;</b> <p>
<b>void</b> <br>
<b>gdbm_sync (dbf)</b> <br>
<b>GDBM_FILE dbf;</b> <p>
<b>int</b> <br>
<b>gdbm_exists (dbf, key)</b> <br>
<b>GDBM_FILE dbf;</b> <br>
<b>datum key;</b> <p>
<b>char *</b> <br>
<b>gdbm_strerror (errno)</b> <br>
<b>gdbm_error errno;</b> <p>
<b>int</b> <br>
<b>gdbm_setopt (dbf, option, value, size)</b> <br>
<b>GDBM_FILE dbf;</b> <br>
<b>int option;</b> <br>
<b>int *value;</b> <br>
<b>int size;</b> <p>
<b>int</b> <br>
<b>gdbm_fdesc (dbf)</b> <br>
<b>GDBM_FILE dbf;</b> <p>
<p>
<b>DBM Compatability routines:</b> <p>
<b>#include &lt;dbm.h&gt;</b> <p>
<font size='-1'></font>
 <b>int</b> <br>
<b>dbminit (name)</b> <br>
<b>char *name;</b> <p>
<b>int</b> <br>
<b>store (key, content)</b> <br>
<b>datum key, content;</b> <p>
<b>datum</b> <br>
<b>fetch (key)</b> <br>
<b>datum key;</b> <p>
<b>int</b> <br>
<b>delete (key)</b> <br>
<b>datum key;</b> <p>
<b>datum</b> <br>
<b>firstkey ()</b> <p>
<b>datum</b> <br>
<b>nextkey (key)</b> <br>
<b>datum key;</b> <p>
<b>int</b> <br>
<b>dbmclose ()</b> <p>
<p>
<b>NDBM Compatability routines:</b> <p>
<b>#include &lt;ndbm.h&gt;</b> <p>
<font size='-1'></font>
 <b>DBM</b> <br>
<b>*dbm_open (name, flags, mode)</b> <br>
<b>char *name;</b> <br>
<b>int flags, mode;</b> <p>
<b>void</b> <br>
<b>dbm_close (file)</b> <br>
<b>DBM *file;</b> <p>
<b>datum</b> <br>
<b>dbm_fetch (file, key)</b> <br>
<b>DBM *file;</b> <br>
<b>datum key;</b> <p>
<b>int</b> <br>
<b>dbm_store (file, key, content, flags)</b> <br>
<b>DBM *file;</b> <br>
<b>datum key, content;</b> <br>
<b>int flags;</b> <p>
<b>int</b> <br>
<b>dbm_delete (file, key)</b> <br>
<b>DBM *file;</b> <br>
<b>datum key;</b> <p>
<b>datum</b> <br>
<b>dbm_firstkey (file)</b> <br>
<b>DBM *file;</b> <p>
<b>datum</b> <br>
<b>dbm_nextkey (file)</b> <br>
<b>DBM *file;</b> <p>
<b>int</b> <br>
<b>dbm_error (file)</b> <br>
<b>DBM *file;</b> <p>
<b>int</b> <br>
<b>dbm_clearerr (file)</b> <br>
<b>DBM *file;</b> <p>
<b>int</b> <br>
<b>dbm_pagfno (file)</b> <br>
<b>DBM *file;</b> <p>
<b>int</b> <br>
<b>dbm_dirfno (file)</b> <br>
<b>DBM *file;</b> <p>
<b>int</b> <br>
<b>dbm_rdonly (file)</b> <br>
<b>DBM *file;</b> 
<p> 
<p> 
<h2><a name='sect2' href='#toc2'>Description</a></h2>
GNU dbm is a library of routines that manages data
files that contain key/data pairs.  The access provided is that of storing,
 retrieval, and deletion by key and a non-sorted traversal of all keys. 
A process is allowed to use multiple data files at the same time. 
<p> A process
that opens a gdbm file is designated as a "reader" or a "writer".  Only
one writer may open a gdbm file and many readers may open the file.  Readers
and writers can not open the gdbm file at the same time. The procedure for
opening a gdbm file is: 
<p>   GDBM_FILE dbf;<br>
 
<p>   dbf = gdbm_open ( name, block_size, read_write, mode, fatal_func )<br>
 
<p> <i>Name</i> is the name of the file (the complete name, gdbm does not append
any characters to this name).  <i>Block_size</i> is the size of a single transfer
from disk to memory. This parameter is ignored unless the file is a new
file.  The minimum size is 512.  If it is less than 512, dbm will use the
stat block size for the file system. <i>Read_write</i> can have one of the following
values: <br>
<b>GDBM_READER</b> reader <br>
<b>GDBM_WRITER</b> writer <br>
<b>GDBM_WRCREAT</b> writer - if database does not exist create new one <br>
<b>GDBM_NEWDB</b> writer - create new database regardless if one exists <br>
For the last three (writers of the database) the following may be added
added to <i>read_write</i> by bitwise or: <b>GDBM_SYNC,</b> which causes all database
operations to be synchronized to the disk, and <b>GDBM_NOLOCK,</b> which prevents
the library from performing any locking on the database file. The option
<b>GDBM_FAST</b> is now obsolete, since gdbm defaults to no-sync mode. <br>
<i>Mode</i> is the file mode (see <a href='chmod.2.html'><b>chmod(2)</b></a>
 and <a href='open.2.html'><b>open(2)</b></a>
) if the file is created.
<i>(*Fatal_func) ()</i> is a function for dbm to call if it detects a fatal error.
The only parameter of this function is a string. If the value of 0 is provided,
gdbm will use a default function. 
<p> The return value <i>dbf</i> is the pointer needed
by all other routines to access that gdbm file.  If the return is the NULL
pointer, <b>gdbm_open</b> was not successful.  The errors can be found in <i>gdbm_errno</i>
for gdbm errors and in <i>errno</i> for system errors.  (For error codes, see gdbmerrno.h.)

<p> In all of the following calls, the parameter <i>dbf</i> refers to the pointer
returned from <b>gdbm_open</b>. 
<p> It is important that every file opened is also
closed.  This is needed to update the reader/writer count on the file.  This
is done by: 
<p>   gdbm_close (dbf);<br>
 
<p> 
<p> The database is used by 3 primary routines.  The first stores data in
the database. 
<p>   ret = gdbm_store ( dbf, key, content, flag )<br>
 
<p> <i>Dbf</i> is the pointer returned by <b>gdbm_open</b>.  <i>Key</i> is the key data.  <i>Content</i>
is the data to be associated with the <i>key</i>. <i>Flag</i> can have one of the following
values: <br>
<b>GDBM_INSERT</b> insert only, generate an error if key exists <br>
<b>GDBM_REPLACE</b> replace contents if key exists. 
<p> If a reader calls <b>gdbm_store</b>,
the return value will be  -1. If called with GDBM_INSERT and <i>key</i> is in the
database, the return value will be 1.  Otherwise, the return value is 0.

<p> <i>NOTICE: If you store data for a key that is already in the data base,
gdbm replaces the old data with the new data if called with GDBM_REPLACE.
You do not get two data items for the same key and you do not get an error
from gdbm_store. 
<p></i> NOTICE: The size in gdbm is not restricted like dbm or
ndbm.  Your data can be as large as you want. 
<p> 
<p> To search for some data:

<p>   content = gdbm_fetch ( dbf, key )<br>
 
<p> <i>Dbf</i> is the pointer returned by <b>gdbm_open</b>.  <i>Key</i> is the key data. 
<p> 
<p> If the
<i>dptr</i> element of the return value is NULL, no data was found.  Otherwise
the return value is a pointer to the found data. The storage space for the
<i>dptr</i> element is allocated using <a href='malloc.3C.html'><b>malloc(3C)</b></a>
.  <b>Gdbm<i> does not automatically
free this data. It is the programmer&rsquo;s responsibility to free this storage
when it is no longer needed.</i></b> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -