¸ñÂ÷
dbm
.
dbm
and ndbm
.
dbm
files to gdbm
format.
dbm
¼Ò°³
dbm
, ndbm
°ú ȣȯ¼º
dbm
ÆÄÀÏÀ» gdbm
Çü½ÄÀ¸·Î º¯È¯Çϱâ
This library is free; this means that everyone is free to use
it and free to redistribute it on a free basis. GNU dbm
(gdbm
)
is not in the public domain; it is copyrighted and there
are restrictions on its distribution, but these restrictions are
designed to permit everything that a good cooperating citizen would want
to do. What is not allowed is to try to prevent others from further
sharing any version of gdbm
that they might get from
you.
Specifically, we want to make sure that you have the right to give
away copies
ÀÌ ¶óÀ̺귯¸®´Â ÀÚÀ¯·Ó´Ù. ÀÌ´Â ¾Æ¹«³ª »ç¿ëÇÒ ¼ö ÀÖ°í,
ÀÌ Á¶°ÇÇÏ¿¡¼ ÀÚÀ¯·Ó°Ô ¹èÆ÷ÇÒ ¼ö ÀÖ´Ù´Â ¶æÀÌ´Ù. GNU
´ç½Å¿¡°Ô gdbm
, that you receive
source code or else can get it if you want it, that you can change these
functions or use pieces of them in new free programs, and that you know
you can do these things.
dbm
(gdbm
)´Â ÆÛºí¸¯ µµ¸ÞÀÎ(public domain)¿¡ ÀÖÁö ¾Ê´Ù. (Áï,
À̸¦ »ó¾÷ÀûÀÎ ¸ñÀûÀ¸·Î ¹èŸÀûÀ¸·Î »ç¿ëÇÒ ¼ö ¾ø´Ù.)
ÀÌ´Â ÀúÀÛ±ÇÀ¸·Î º¸È£µÇ°í ¹èÆ÷Çϴµ¥ Á¦ÇÑÀÌ ÀÖ´Ù. ±×·¯³ª
ÀÌ Á¦ÇÑÀº Çùµ¿ÇÏ´Â ÁÁÀº ³×ƼÁðÀÌ ÇÏ·Á´Â ¸ðµç °ÍÀ» Çã¿ëÇϱâ À§ÇØ Àǵµ‰ç´Ù.
Çã¿ëµÇÁö ¾Ê´Â °ÍÀº ´Ù¸¥ »ç¶÷µé°ú ´õ ÀÌ»ó gdbm
À»
°øÀ¯ÇÏÁö ¾ÊÀ¸·Á ÇÏ´Â °ÍÀÌ´Ù.
gdbm
À» ¹èÆ÷ÇÒ ±Ç¸®¿Í ¿øÇÑ´Ù¸é
¼Ò½ºÄÚµå µîÀ» ¾òÀ» ±Ç¸®°¡ ÀÖÀ½À» ¸íÈ®È÷ ÇÑ´Ù. ±×·¡¼
±â´ÉÀ» ¼öÁ¤Çϰųª »õ·Î¿î ÀÚÀ¯ ¼ÒÇÁÆ®¿þ¾î¿¡¼ ÄÚµåÀÇ ÀϺθ¦ »ç¿ëÇÒ
¼ö ÀÖ´Ù´Â Á¡À» ¾Ë¾Æ¾ß ÇÑ´Ù.
To make sure that everyone has such rights, we have to forbid you to
deprive anyone else of these rights. For example, if you distribute
copies gdbm
, you must give the recipients all
the rights that you have. You must make sure that they, too, receive or
can get the source code. And you must tell them their rights.
Also, for our own protection, we must make certain that everyone finds
out that there is no warranty for anything in the
¸ðµÎ¿¡°Ô ÀÌ·± ±Ç¸®°¡ Àֱ⠶§¹®¿¡ ¿ì¸®´Â ´ç½ÅÀÌ ±×µé¿¡°Ô¼ ÀÌ ±Ç¸®¸¦
»©¾Ò´Â °ÍÀ» ±ÝÁöÇÑ´Ù. ¿¹¸¦ µé¾î ´ç½ÅÀÌ
¶ÇÇÑ ¿ì¸®´Â gdbm
distribution.
If these functions are modified by someone else and passed on, we want
their recipients to know that what they have is not what we distributed,
so that any problems introduced by others will not reflect on our
reputation.
gdbm
À» ¹èÆ÷ÇÑ´Ù¸é
´ç½ÅÀÌ °¡Áø ±Ç¸®µµ Áà¾ßÇÑ´Ù. ¶Ç ±×µéÀÌ ¼Ò½ºÄڵ带 ¾òÀ» ¼ö ÀÖ´Ù´Â °Íµµ
¾Ë·Á¾ßÇÑ´Ù. ±×µé¿¡°Ô ±×µéÀÇ ±Ç¸®¸¦ ¸»ÇØÁà¾ß ÇÑ´Ù.
gdbm
¹èÆ÷¸¦ º¸ÀåÇÏÁö ¾Ê´Â´Ù´Â Á¡µµ È®½ÇÈ÷ ÇÑ´Ù.
¾î¶² »ç¶÷ÀÌ ±â´ÉÀ» ¼öÁ¤ÇÏ¿´´Ù¸é ¿ì¸®°¡ ¿ø·¡ ¹èÆ÷ÇÑ °ÍÀÌ ¾Æ´ÔÀ» ¾Ë·Á¼,
´Ù¸¥ »ç¶÷ÀÌ ¸¸µç ¹®Á¦·Î ¿ì¸® ¸í¼º¿¡ ¿µÇâÀÌ ¾ø¾î¾ß ÇÑ´Ù.
gdbm
is currently distributed under the terms of the GNU General
Public License, Version 2. (NOT under the GNU General Library
Public License.) A copy the GNU General Public License is included with
the distribution of gdbm
.
gdbm
Àº ÇöÀç (GNU General Library Public License°¡ ¾Æ´Ï¶ó)
GNU General Public License, Version 2·Î ¹èÆ÷µÈ´Ù. GNU General Public LicenseÀÇ
º¹»çº»Àº gdbm
¿¡ Æ÷ÇÔµÇÀÖ´Ù. (¿ªÁÖ; Áï, »ó¾÷Àû ¸ñÀûÀÇ ¼ÒÇÁÆ®¿þ¾î¿¡¼
gdbm
À» »ç¿ëÇÒ ¼ö ¾ø´Ù.)
GNU
dbm
¼Ò°³
GNU dbm
(gdbm
)is a library of database functions that use
extendible hashing and works similar to the standard UNIX dbm
functions. These routines are provided to a programmer needing to
create and manipulate a hashed database. (gdbm
is NOT a
complete database package for an end user.)
The basic use of gdbm
is to store key/data pairs in a data file.
Each key must be unique and each key is paired with only one data item.
The keys can not be directly accessed in sorted order. The basic unit
of data in gdbm
is the structure:
typedef struct { char *dptr; int dsize; } datum;
GNU dbm
(gdbm
)Àº È®Àå°¡´ÉÇÑ Çؽ¬¸¦ »ç¿ëÇÑ
µ¥ÀÌÅͺ£À̽º ÇÔ¼ö ¶óÀ̺귯¸®·Î, Ç¥ÁØ À¯´Ð½º dbm
ÇÔ¼ö¿Í
ºñ½ÁÇÏ°Ô µ¿ÀÛÇÑ´Ù. ÀÌ ÇÔ¼öµé·Î Çؽ¬µÈ µ¥ÀÌÅͺ£À̽º¸¦ ¸¸µé°í ´Ù·ê ¼ö
ÀÖ´Ù. (dbm
Àº ÀÏ¹Ý »ç¿ëÀÚ¸¦ À§ÇÑ ¿ÏÀüÇÑ µ¥ÀÌÅ׺£À̽º°¡
¾Æ´Ï´Ù.)
gdbm
Àº ±âº»ÀûÀ¸·Î ÀÚ·á ÆÄÀÏ¿¡ Å°¿Í ÀÚ·áÀÇ ½ÖÀ» ÀúÀåÇÑ´Ù.
°¢ Å°´Â Áߺ¹µÇ¸é ¾ÈµÇ°í, ¿ÀÁ÷ ÇϳªÀÇ ÀڷḦ °¡Áø´Ù. Å°´Â Á¤·ÄµÈ
¼ø¼·Î Á÷Á¢ Á¢±ÙÇÒ ¼ö ¾ø´Ù. gdbm
ÀÇ (Å°¿Í ÀÚ·áÀÇ)
±âº» ÀڷᱸÁ¶´Â ´ÙÀ½°ú °°´Ù.
typedef struct { char *dptr; int dsize; } datum;
This structure allows for arbitrary sized keys and data items.
The key/data pairs are stored in a
ÀÌ ±¸Á¶Ã¼´Â ¾î¶² Å©±âÀÇ Å°¿Í ÀÚ·áµµ ´ãÀ» ¼ö ÀÖ´Ù.
Å°¿Í ÀÚ·á ½ÖÀº gdbm
disk file, called a
gdbm
database. An application must open a gdbm
database
to be able manipulate the keys and data contained in the database.
gdbm
allows an application to have multiple databases open at the
same time. When an application opens a gdbm
database, it is
designated as a reader
or a writer
. A gdbm
database opened by at most one writer at a time. However, many readers
may open the database open simultaneously. Readers and writers can not
open the gdbm
database at the same time.
gdbm
µ¥ÀÌÅͺ£À̽º¶ó°í ºÎ¸£´Â gdbm
ÀÚ·á ÆÄÀÏ¿¡ ÀúÀåµÈ´Ù. ÇÁ·Î±×·¥Àº µ¥ÀÌÅͺ£À̽º¿¡ ÀúÀåµÈ Å°¿Í ÀڷḦ
´Ù·ç±â À§Çؼ gdbm
µ¥ÀÌÅͺ£À̽º¸¦ ¿¾î¾ß ÇÑ´Ù.
gdbm
¿¡¼ ÇÁ·Î±×·¥Àº µ¿½Ã¿¡ ¿©·¯ µ¥ÀÌÅͺ£À̽º¸¦ ¿ ¼ö ÀÖ´Ù.
ÇÁ·Î±×·¥ÀÌ gdbm
µ¥ÀÌÅͺ£À̽º¸¦ ¿¸é, µ¶ÀÚ(reader)
³ª
ÇÊÀÚ(writer)
·Î ÇൿÇÑ´Ù. gdbm
µ¥ÀÌÅͺ£À̽º´Â
µ¿½Ã¿¡ ÃÖ´ë ÇÑ ÇÊÀÚ¸¸ÀÌ ¿ ¼ö ÀÖÁö¸¸, µ¶ÀÚÀÇ °æ¿ì ¿©·¯ µ¶ÀÚ°¡ µ¿½Ã¿¡ ÇÑ
µ¥ÀÌÅͺ£À̽º¸¦ ¿ ¼ö ÀÖ´Ù. µ¶ÀÚ¿Í ÇÊÀÚ´Â µ¿½Ã¿¡ gdbm
µ¥ÀÌÅͺ£À̽º¸¦ ¿ ¼ö ¾ø´Ù.
ÇÔ¼ö ¸ñ·Ï
The following is a quick list of the functions contained in the gdbm
library. The include file gdbm.h
, that can be included by the user,
contains a definition of these functions.
#include <gdbm.h> GDBM_FILE gdbm_open(name, block_size, flags, mode, fatal_func); void gdbm_close(dbf); int gdbm_store(dbf, key, content, flag); datum gdbm_fetch(dbf, key); int gdbm_delete(dbf, key); datum gdbm_firstkey(dbf); datum gdbm_nextkey(dbf, key); int gdbm_reorganize(dbf); void gdbm_sync(dbf); int gdbm_exists(dbf, key); char *gdbm_strerror(errno); int gdbm_setopt(dbf, option, value, size); int gdbm_fdesc(dbf);
´ÙÀ½Àº gdbm
¶óÀ̺귯¸®¿¡ Æ÷ÇÔµÈ ÇÔ¼öµéÀÌ´Ù.
Çì´õ ÆÄÀÏ gdbm.h
¿¡ ÀÌ ÇÔ¼öµéÀÌ ¼±¾ðµÇÀÖ´Ù.
#include <gdbm.h> GDBM_FILE gdbm_open(name, block_size, flags, mode, fatal_func); void gdbm_close(dbf); int gdbm_store(dbf, key, content, flag); datum gdbm_fetch(dbf, key); int gdbm_delete(dbf, key); datum gdbm_firstkey(dbf); datum gdbm_nextkey(dbf, key); int gdbm_reorganize(dbf); void gdbm_sync(dbf); int gdbm_exists(dbf, key); char *gdbm_strerror(errno); int gdbm_setopt(dbf, option, value, size); int gdbm_fdesc(dbf);
The gdbm.h
include file is often in the `/usr/local/include'
directory. (The actual location of gdbm.h
depends on your local
installation of gdbm
.)
Çì´õ ÆÄÀÏ gdbm.h
´Â º¸Åë `/usr/local/include'¿¡
ÀÖ´Ù. (gdbm.h
ÀÇ ½ÇÁ¦ À§Ä¡´Â gdbm
À» ±¸¼ºÇÑ
¹æ¹ý¿¡ µû¶ó ´Ù¸£´Ù.)
µ¥ÀÌÅͺ£À̽º ¿±â
Initialize gdbm
system. If the file has a size of zero bytes, a file
initialization procedure is performed, setting up the initial structure in the
file.
The procedure for opening a gdbm
file is:
GDBM_FILE dbf; dbf = gdbm_open(name, block_size, flags, mode, fatal_func);
gdbm
½Ã½ºÅÛÀ» ÃʱâÈÇÑ´Ù. ÆÄÀÏÀÇ Å©±â°¡ 0À̶ó¸é
ÆÄÀÏ¿¡ Ãʱ⠱¸Á¶¸¦ ¸¸µå´Â ÆÄÀÏ ÃʱâÈ °úÁ¤ÀÌ ¼öÇàµÈ´Ù.
gdbm
ÆÄÀÏÀ» ¿©´Â ÇÔ¼ö´Â,
GDBM_FILE dbf; dbf = gdbm_open(name, block_size, flags, mode, fatal_func);
The parameters are:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm
does not append any
characters to this name).
gdbm
Àº ÀÌ À̸§¿¡ ¾î¶² ¹®ÀÚµµ Ãß°¡ÇÏÁö
¾Ê´Â´Ù.)
block_size
is used.
flags
is set to GDBM_READER, the user wants to just read the
database and any call to gdbm_store
or gdbm_delete
will fail.
Many readers can access the database at the same time. If flags
is
set to GDBM_WRITER, the user wants both read and write access to the database
and requires exclusive access. If flags
is set to GDBM_WRCREAT, the
user wants both read and write access to the database and if the database does
not exist, create a new one. If flags
is set to GDBM_NEWDB, the
user want a new database created, regardless of whether one existed, and wants
read and write access to the new database. The following may also be logically
or'd into the database flags: GDBM_SYNC, which causes all database operations
to be synchronized to the disk, and GDBM_NOLOCK, which prevents the library
from performing any locking on the database file. The option GDBM_FAST is
now obsolete, since gdbm
defaults to no-sync mode. Any error detected
will cause a return value of NULL and an appropriate value will be in
gdbm_errno
(see Variables). If no errors occur, a pointer to the
gdbm
file descriptor will be returned.
flags
°¡ GDBM_READER¶ó¸é »ç¿ëÀÚ´Â µ¥ÀÌÅͺ£À̽º¸¦
Àб⸸ ÇÑ´Ù. gdbm_store
³ª gdbm_delete
ÇÔ¼ö´Â
½ÇÆÐÇÑ´Ù. µ¿½Ã¿¡ ¸¹Àº µ¶ÀÚ°¡ µ¥ÀÌÅ׺£À̽º¿¡ Á¢±ÙÇÒ ¼ö ÀÖ´Ù.
flags
°¡ GDBM_WRITER¶ó¸é »ç¿ëÀÚ´Â µ¥ÀÌÅͺ£À̽º¸¦
ÀÐ°í ¾µ ¼ö ÀÖ´Ù. ±×·¯¸é ´Ù¸¥ °ÍµéÀº µ¥ÀÌÅͺ£À̽º¿¡ Á¢±ÙÇÒ ¼ö ¾ø°Ô µÈ´Ù.
flags
°¡ GDBM_WRCREATÀÌ¸é »ç¿ëÀÚ´Â µ¥ÀÌÅͺ£À̽º¸¦
ÀÐ°í ¾µ ¼ö ÀÖ°í, ¸¸¾à µ¥ÀÌÅͺ£À̽º°¡ ¾ø´Ù¸é »õ·Î ¸¸µç´Ù.
flags
°¡ GDBM_NEWDB¶ó¸é »ç¿ëÀÚ´Â ÀÌ¹Ì ÀÖ´õ¶óµµ
»õ·Ó°Ô µ¥ÀÌÅͺ£À̽º¸¦ ¸¸µé°í, µ¥ÀÌÅͺ£À̽º¸¦ ÀÐ°í ¾µ ¼ö ÀÖ´Ù.
´ÙÀ½Àº À§ÀÇ °ªµé°ú ³í¸®ÇÕ(OR)À» ÇÒ ¼ö ÀÖ´Ù. GDBM_SYNC´Â ¸ðµç
µ¥ÀÌÅͺ£À̽º ÀÛ¾÷À» µð½ºÅ©°ú µ¿±âÈÇÑ´Ù. GDBM_NOLOCKÀº
¶óÀ̺귯¸®°¡ µ¥ÀÌÅͺ£À̽º ÆÄÀÏÀ» Àá±×Áö ¾Ê°Ô ÇÑ´Ù.
GDBM_FAST´Â µ¿±âÈÇÏÁö ¾Ê´Â °ÍÀÌ ±âº» ÇൿÀ̱⠶§¹®¿¡ Áö±ÝÀº »ç¿ëµÇÁö ¾Ê´Â´Ù.
¾î¶² ¿À·ù°¡ ¹ß»ýÇϸé NULLÀ» ¹ÝȯÇÏ°í, ÀûÀýÇÑ °ªÀÌ
gdbm_errno
¿¡ ÀúÀåµÈ´Ù. ("µÎ À¯¿ëÇÑ º¯¼ö" Âü°í) ¿À·ù°¡ ¾ø´Ù¸é
gdbm
ÆÄÀϱâ¼úÀÚÀÇ Æ÷ÀÎÅÍ°¡ ¹ÝȯµÈ´Ù.
gdbm
to call if it detects a fatal error. The only
parameter of this function is a string. If the value of NULL is provided,
gdbm
will use a default function.
The return value, dbf
, is the pointer needed by all other functions to
access that gdbm
file. If the return is the NULL pointer,
gdbm_open
was not successful. The errors can be found in
gdbm_errno
for gdbm
errors and in errno
for file system
errors (for error codes, see gdbm.h
).
In all of the following calls, the parameter
¹Ýȯ°ª
´ÙÀ½ ¸ðµç ÇÔ¼ö¿¡¼ ÆĶó¹ÌÅÍ dbf
refers to the pointer
returned from gdbm_open
.
dbf
´Â gdbm
ÆÄÀÏÀ» Á¢±ÙÇÏ´Â ´Ù¸¥ ¸ðµç
ÇÔ¼öµéÀÌ ÇÊ¿ä·ÎÇÏ´Â Æ÷ÀÎÅÍÀÌ´Ù. NULL Æ÷ÀÎÅ͸¦ ¹ÝȯÇϸé, gdbm_open
˼
¼º°øÇÏÁö ¸øÇÑ °ÍÀÌ´Ù. gdbm
¿À·ù´Â gdbm_errno
,
ÆÄÀϽýºÅÛ ¿À·ù´Â errno
¿¡¼ ãÀ» ¼ö ÀÖ´Ù. (¿À·ù ÄÚµå´Â
gdbm.h
¸¦ Âü°íÇ϶ó.)
dbf
´Â gdbm_open
ÀÌ
¹ÝȯÇÑ Æ÷ÀÎÅÍÀÌ´Ù.
µ¥ÀÌÅͺ£À̽º ´Ý±â
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:
gdbm_close(dbf);
Çѹø ¿¾ú´ø ÆÄÀÏÀ» ´Ý´Â °ÍÀº Áß¿äÇÏ´Ù. ´Ý±â´Â ÆÄÀÏ¿¡ º¯°æµÈ µ¶ÀÚ¿Í ÇÊÀÚ ¼ö¸¦ ¹Ý¿µÇϱâ À§ÇØ ÇÊ¿äÇÏ´Ù. ´Ý±â´Â ´ÙÀ½ ÇÔ¼ö·Î ÇÑ´Ù.
gdbm_close(dbf);
The parameter is:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
Closes the gdbm
file and frees all memory associated with the file
dbf
.
ÀÌ ÇÔ¼ö´Â gdbm
ÆÄÀÏÀ» ´Ý°í, dbf
ÆÄÀÏ°ú
¿¬°üµÈ ¸ðµç ¸Þ¸ð¸®¸¦ ¹ÝȯÇÑ´Ù.
µ¥ÀÌÅͺ£À̽º¿¡¼ ·¹ÄÚµå Ãß°¡/´ëü
The function gdbm_store
inserts or replaces records in the database.
ret = gdbm_store(dbf, key, content, flag);
ÇÔ¼ö gdbm_store
´Â µ¥ÀÌÅͺ£À̽º¿¡¼ ·¹Äڵ带 Ãß°¡Çϰųª
´ëüÇÑ´Ù.
ret = gdbm_store(dbf, key, content, flag);
The parameters are:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
key
data.
gdbm.h
) asks that the old data be replaced by
the new content
. The value GDBM_INSERT asks that an error be returned
and no action taken if the key
already exists.
gdbm.h
¿¡ Á¤ÀǵÈ) GDBM_REPLACE¸¦ »ç¿ëÇÏ¸é »õ·Î¿î
content
·Î ÀüÀÇ ÀڷḦ ´ëüÇÑ´Ù. GDBM_INSERT¸¦ »ç¿ëÇϸé
ÀÌ¹Ì key
°¡ ÀÖ´Â °æ¿ì ¿À·ù¸¦ ¹ß»ýÇÏ°í ¾Æ¹« Àϵµ ÇÏÁö ¾Ê´Â´Ù.
The values returned in ret
are:
¹Ýȯ°ª ret
´Â,
key
or content
have a NULL dptr field.
Both key
and content
must have the dptr field be a non-NULL value.
Since a NULL dptr field is used by other functions to indicate an error, a NULL
field cannot be valid data.
key
³ª content
±¸Á¶Ã¼ÀÇ dptr ¸â¹ö°¡
NULLÀ̱⠶§¹®¿¡ µ¥ÀÌÅͺ£À̽º¿¡ ÀúÀåÇÒ ¼ö ¾ø´Ù. key
¿Í content
±¸Á¶Ã¼ÀÇ dptr ¸â¹ö´Â NULLÀÌ ¾Æ´Ñ °ªÀ» °¡Á®¾ßÇÑ´Ù.
dptr °ªÀÌ NULLÀÎ °ÍÀº ´Ù¸¥ ÇÔ¼ö¿¡¼ ¿À·ù¸¦ ÀǹÌÇϱ⠶§¹®¿¡ »ç¿ëÇÒ ¼ö ¾ø´Ù.
flag
was GDBM_INSERT and
the key
was already in the database.
flag
°¡ GDBM_INSERTÀÌ°í key
°¡ ÀÌ¹Ì µ¥ÀÌÅͺ£À̽º¿¡
Àֱ⠶§¹®¿¡ º£ÀÌÅͺ£À̽º¿¡ ÀúÀåÇÒ ¼ö ¾ø´Ù.
content
is keyed by key
. The file on disk is updated
to reflect the structure of the new database before returning from this
function.
key
¸¦ Å°·Î ÇÏ¿© content
°¡ ÀúÀåµÇ¾ú´Ù. ÀÌ ÇÔ¼ö°¡
¹ÝȯÇϱâ Àü¿¡, µð½ºÅ©ÀÇ ÆÄÀÏÀº »õ·Î¿î µ¥ÀÌÅͺ£À̽º ±¸Á¶¸¦ ¹Ý¿µÇϱâ À§ÇØ
°»½ÅµÈ´Ù.
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
.
The size in
ÀÌ¹Ì ÀÖ´Â
gdbm
is not restricted like dbm
or ndbm
. Your
data can be as large as you want.
key
·Î ÀڷḦ ÀúÀåÇÏ·ÁÇÒ ¶§, GDBM_REPLACE¸¦
»ç¿ëÇÑ °æ¿ì »õ·Î¿î ÀÚ·á·Î ±âÁ¸ÀÇ ÀڷḦ ´ëüÇÑ´Ù. ÀÌ °æ¿ì °°Àº key
¿¡
µÎ ÀÚ·á°¡ ÀúÀåµÇÁö ¾Ê°í, ¹®Á¦¾øÀÌ ½ÇÇàµÈ´Ù.
gdbm
¿¡¼ Å©±â´Â dbm
³ª ndbm
°ú °°ÀÌ
Á¦ÇѵÇÁö ¾Ê´Â´Ù. ÀÚ·á´Â ¿øÇÏ´Â ¸¸Å Ä¿Áú ¼ö ÀÖ´Ù.
µ¥ÀÌÅͺ£À̽º¿¡¼ ·¹ÄÚµå ã±â
Looks up a given key
and returns the information associated with that
key. The pointer in the structure that is returned is a pointer to dynamically
allocated memory block. To search for some data:
content = gdbm_fetch(dbf, key);
ÁÖ¾îÁø key
¸¦ ã°í, ±× Å°¿Í ¿¬°áµÈ ÀڷḦ ¹ÝȯÇÑ´Ù.
¹ÝȯµÇ´Â ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ´Â µ¿ÀûÀ¸·Î ÇÒ´çµÈ ¸Þ¸ð¸®¸¦ °¡¸®Å²´Ù.
ÀڷḦ ã±â À§Çؼ ´ÙÀ½ ÇÔ¼ö¸¦ »ç¿ëÇÑ´Ù.
content = gdbm_fetch(dbf, key);
The parameters are:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
key
data.
The datum returned in
content
is a pointer to the data found. If the
dptr is NULL, no data was found. If dptr is not NULL, then it points
to data allocated by malloc. gdbm
does not automatically free this data.
The user must free this storage when done using it. This eliminates the
need to copy the result to save it for later use (you just save the pointer).
content
·Î ¹ÝȯµÈ ÀÚ·á´Â ãÀº ÀÚ·áÀÇ Æ÷ÀÎÅÍÀÌ´Ù. dptrÀÌ NULLÀ̶ó¸é
ÀڷḦ ãÁö ¸øÇÑ °ÍÀÌ´Ù. dptrÀÌ NULLÀÌ ¾Æ´Ï¶ó¸é mallocÀ¸·Î ÇÒ´çÇÑ °ø°£ÀÇ Æ÷ÀÎÅÍÀÌ´Ù.
gdbm
´Â ÀÚµ¿À¸·Î ÀÌ °ø°£¸¦ ¹ÝȯÇÏÁö ¾Ê´Â´Ù. »ç¿ëÀÚ´Â »ç¿ëÇÑ
ÈÄ ÀÌ °ø°£À» ¹ÝȯÇØ¾ß ÇÑ´Ù. ÀÌ·± ¹æ½ÄÀº (dbm
À̳ª ndbm
°ú
´Þ¸®) ³ªÁß¿¡ »ç¿ëÇϱâ À§ÇØ °á°ú¸¦ ÀúÀåÇÒ Çʿ並 ¾ø°ÔÇÑ´Ù.
(´ÜÁö Æ÷ÀÎÅ͸¸ ÀúÀåÇÏ¸é µÈ´Ù.) (¿ªÁÖ; datum ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ°¡ ¹ÝȯµÇÁö ¾ÊÀ½À»
ÁÖÀÇÇ϶ó. gdbm_fetch
´Â ´ÜÁö dptrÀ» À§ÇÑ ¸Þ¸ð¸®¸¸À» µ¿ÀûÀ¸·Î
ÇÒ´çÇÑ´Ù. ¸¸¾à Å°¿Í ¿¬°áµÈ ÀÚ·á°¡ Å©±â°¡ ¾ø´Ù¸é dsize ¸â¹ö´Â 0ÀÌÁö¸¸,
dptrÀº NULLÀÌ ¾Æ´Ï±â À§Çؼ Å©±â°¡ 1·Î ÇÒ´çµÈ ¸Þ¸ð¸®¸¦ °¡¸®Å²´Ù. ¹Ý´ë·Î
gdbm_store
ÀÇ °æ¿ì¿¡µµ Å©±â°¡ 0ÀÎ ÀڷḦ Å°³ª ÀÚ·á·Î »ç¿ëÇÒ
¼ö ÀÖ´Ù. datum.dsize = 0; datum.dptr = "";°ú °°ÀÌ
ÇÏ¸é µÈ´Ù.)
You may also search for a particular key without retrieving it, using:
ret = gdbm_exists(dbf, key);
¶ÇÇÑ ´ÙÀ½ ÇÔ¼ö¸¦ »ç¿ëÇÏ¿© ÀڷḦ °¡Á®¿ÀÁö ¾Ê°í ƯÁ¤ Å°ÀÇ À¯¹«¸¸À» ¾Ë¾Æº¼ ¼öµµ ÀÖ´Ù.
ret = gdbm_exists(dbf, key);
The parameters are:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
key
data.
Unlike gdbm_fetch
, this routine does not allocate any memory, and
simply returns true or false, depending on whether the key
exists,
or not.
gdbm_fetch
¿Í ´Þ¸® ÀÌ ÇÔ¼ö´Â ¸Þ¸ð¸®¸¦ ÇÒ´çÇÏÁö ¾Ê°í,
´ÜÁö key
ÀÇ Á¸Àç À¯¹«¸¸À» ¾Ë·ÁÁØ´Ù.
µ¥ÀÌÅͺ£À̽º¿¡¼ ·¹ÄÚµå »èÁ¦Çϱâ
To remove some data from the database:
ret = gdbm_delete(dbf, key);
ret = gdbm_delete(dbf, key);
The parameters are:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
key
data.
The ret value is -1 if the item is not present or the requester is a reader. The ret value is 0 if there was a successful delete.
ÀÚ·á°¡ ¾ø°Å³ª µ¶ÀÚ°¡ ÇÔ¼ö¸¦ ºÎ¸¥ °æ¿ì -1ÀÌ ¹ÝȯµÈ´Ù. ¼º°øÀûÀ¸·Î
»èÁ¦ÇÏ¿´´Ù¸é 0À» ¹ÝȯÇÑ´Ù.
gdbm_delete
removes the keyed item and the key
from the database
dbf
. The file on disk is updated to reflect the structure of the new
database before returning from this function.
gdbm_delete
´Â µ¥ÀÌÅͺ£À̽º dbf
¿¡¼ key
¿Í,
¿¬°áµÈ ÀڷḦ »èÁ¦ÇÑ´Ù. ÀÌ ÇÔ¼ö°¡ ¹ÝȯÇϱâ Àü¿¡, µð½ºÅ©ÀÇ ÆÄÀÏÀº »õ·Î¿î
µ¥ÀÌÅͺ£À̽º ±¸Á¶¸¦ ¹Ý¿µÇϱâ À§ÇØ °»½ÅµÈ´Ù.
·¹Äڵ带 ¼øÂ÷ÀûÀ¸·Î Á¢±ÙÇϱâ
The next two functions allow for accessing all items in the database. This
access is not key
sequential, but it is guaranteed to visit every
key
in the database once. The order has to do with the hash values.
gdbm_firstkey
starts the visit of all keys in the database.
gdbm_nextkey
finds and reads the next entry in the hash structure for
dbf
.
key = gdbm_firstkey(dbf); nextkey = gdbm_nextkey(dbf, key);
´ÙÀ½ µÎ ÇÔ¼ö´Â µ¥ÀÌÅͺ£À̽ºÀÇ ¸ðµç Å°¸¦ Á¢±ÙÇÒ ¶§ »ç¿ëÇÑ´Ù.
ÀÌ´Â key
¸¦ ¼øÂ÷ÀûÀ¸·Î Á¢±ÙÇÏÁö´Â ¾ÊÁö¸¸, µ¥ÀÌÅͺ£À̽ºÀÇ
¸ðµç key
¸¦ Çѹø¾¿ Á¢±ÙÇÏ´Â °ÍÀ» º¸ÀåÇÑ´Ù. Á¢±Ù ¼ø¼´Â
Ç콬°ª°ú °ü·ÃÀÌ ÀÖ´Ù. gdbm_firstkey
´Â µ¥ÀÌÅͺ£À̽ºÀÇ
¸ðµç Å°ÀÇ Á¢±ÙÀ» ½ÃÀÛÇÑ´Ù. gdbm_nextkey
´Â dbf
ÀÇ
Çؽ¬ ±¸Á¶¿¡¼ ´ÙÀ½ ·¹Äڵ带 ã¾Æ¼ ¹ÝȯÇÑ´Ù.
key = gdbm_firstkey(dbf); nextkey = gdbm_nextkey(dbf, key);
The parameters are:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
key
key
data.
The return values are both datum. If key
.dptr or nextkey.dptr is NULL,
there is no first key
or next key
. Again notice that dptr points to
data allocated by malloc and gdbm
will not free it for you.
These functions were intended to visit the database in read-only algorithms,
for instance, to validate the database or similar operations.
¹ÝȯµÈ °ªÀº ¸ðµÎ datum ±¸Á¶Ã¼ÀÌ´Ù.
ÀÌ ÇÔ¼öµéÀº µ¥ÀÌÅͺ£À̽º È®ÀÎ µîÀÇ ÀÛ¾÷À» À§ÇØ ÀбâÀü¿ëÀ¸·Î
µ¥ÀÌÅͺ£À̽º¸¦ Á¢±ÙÇÔÀ» °¡Á¤ÇÑ´Ù.
key
.dptr³ª nextkey.dptrÀÌ
NULLÀ̶ó¸é ù key
³ª ´ÙÀ½ key
°¡ ¾ø´Â °ÍÀÌ´Ù.
´Ù½Ã dptr Æ÷ÀÎÅÍ´Â mallocÀ¸·Î ÇÒ´çÇÑ °ø°£À» °¡¸®Å°¸ç, gdbm
´Â
À̸¦ ¾Ë¾Æ¼ ¹ÝȯÇÏÁö ¾Ê´Â Á¡À» ÁÖÀÇÇ϶ó.
File visiting
is based on a hash table
. gdbm_delete
re-arranges the hash table to make sure that any collisions in the table do not
leave some item un-findable
. The original key order is NOT guaranteed to
remain unchanged in ALL instances. It is possible that some key will not be
visited if a loop like the following is executed:
key = gdbm_firstkey ( dbf ); while ( key.dptr ) { nextkey = gdbm_nextkey ( dbf, key ); if ( some condition ) { gdbm_delete ( dbf, key ); free ( key.dptr ); } key = nextkey; }
¹æ¹®ÇÏ´Â
ÆÄÀÏÀº Çؽ¬Å×À̺í
À» ±â¹ÝÀ¸·Î ÇÑ´Ù.
gdbm_delete
´Â Å×À̺íÀÇ ¾î¶² ºÒÀÏÄ¡°¡ ÀڷḦ ãÀ»
¼ö ¾ø°Ô
¸¸µéÁö ¾Ê°ÔÇϱâ À§Çؼ Çؽ¬Å×À̺íÀ» ÀçÁ¤·ÄÇÑ´Ù.
¿ø·¡ Å° ¼ø¼°¡ ±×´ë·Î À¯ÁöµÈ´Ù°í º¸ÀåÇÏÁö ¸øÇÑ´Ù. ´ÙÀ½°ú °°Àº
(µ¥ÀÌÅͺ£À̽º¸¦ ¼öÁ¤ÇÏ´Â) ¹Ýº¹¹®¿¡¼ ¾î¶² Å°´Â Á¢±ÙÇÏÁö ¸øÇÒ ¼öµµ ÀÖ´Ù.
key = gdbm_firstkey ( dbf ); while ( key.dptr ) { nextkey = gdbm_nextkey ( dbf, key ); if ( some condition ) { gdbm_delete ( dbf, key ); free ( key.dptr ); } key = nextkey; }
The following function should be used very seldom.
ret = gdbm_reorganize(dbf);
´ÙÀ½ ÇÔ¼ö´Â ¸Å¿ì µå¹°°Ô »ç¿ëÇØ¾ß ÇÑ´Ù.
ret = gdbm_reorganize(dbf);
The parameter is:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
If you have had a lot of deletions and would like to shrink the space
used by the gdbm
file, this function will reorganize the database.
gdbm
will not shorten the length of a gdbm
file (deleted file space will be
reused) except by using this reorganization.
This reorganization requires creating a new file and inserting all the elements
in the old file
¸Å¿ì ¸¹ÀÌ »èÁ¦ÇÑ ÈÄ
À籸¼ºÀº »õ·Î ÆÄÀÏÀ» ¸¸µé°í ±âÁ¸ÀÇ dbf
into the new file. The new file is then renamed to
the same name as the old file and dbf
is updated to contain all the
correct information about the new file. If an error is detected, the return
value is negative. The value zero is returned after a successful
reorganization.
gdbm
ÆÄÀÏÀÌ »ç¿ëÇÏ´Â °ø°£À»
ÁÙÀÌ°í ½ÍÀ» ¶§, ÀÌ ÇÔ¼ö·Î µ¥ÀÌÅͺ£À̽º¸¦ À籸¼ºÇÑ´Ù.
gdbm
´Â ÀÌ À籸¼º ¿ÜÀÇ °æ¿ì¿¡´Â gdbm
ÆÄÀÏ Å©±â¸¦
ÁÙÀÌÁö ¾Ê´Â´Ù. (»èÁ¦ÇÑ ÈÄ ³²Àº ÆÄÀÏ °ø°£Àº Àç»ç¿ëµÈ´Ù.)
dbf
ÆÄÀÏÀÇ ¸ðµç
ÀڷḦ »õ ÆÄÀÏ¿¡ Áý¾î³Ö´Â´Ù. ±×ÈÄ »õ ÆÄÀÏÀº óÀ½ ÆÄÀÏ°ú °°Àº À̸§À¸·Î
º¯°æµÇ°í, dbf
´Â »õ ÆÄÀÏ¿¡ ´ëÇÑ Á¤º¸·Î °»½ÅµÈ´Ù.
¿À·ù°¡ ¹ß»ýÇÏ¸é ¹Ýȯ°ªÀº À½¼öÀÌ´Ù. ¼º°øÀûÀ¸·Î À籸¼ºÀ» ¸¶ÃÆ´Ù¸é
0À» ¹ÝȯÇÑ´Ù.
µ¥ÀÌÅͺ£À̽º µ¿±âÈ
Unless your database was opened with the GDBM_SYNC flag, gdbm
does not
wait for writes to be flushed to the disk before continuing. This allows
faster writing of databases at the risk of having a corrupted database if
the application terminates in an abnormal fashion. The following function
allows the programmer to make sure the disk version of the
database has been completely updated with all changes to the current time.
gdbm_sync(dbf);
µ¥ÀÌÅͺ£À̽º¸¦ GDBM_SYNC Ç÷¡±×·Î ¿Áö ¾Ê¾Ò´Ù¸é, gdbm
˼
ÀÚ·á°¡ µð½ºÅ©¿¡ ¾²¿©Áö´Â °ÍÀ» ±â´Ù¸®Áö ¾Ê´Â´Ù. ±×·¡¼ »¡¸®
µ¥ÀÌÅ׺£À̽º¿¡ ¾µ ¼ö ÀÖÁö¸¸, ÇÁ·Î±×·¥ÀÌ ºñÁ¤»óÀûÀ¸·Î Á¾·áÇÏ´Â
°æ¿ì µ¥ÀÌÅͺ£À̽º¸¦ ¸Á°¡Æ®¸± ¼ö ÀÖ´Ù. ´ÙÀ½ ÇÔ¼ö´Â ÇöÀç±îÁö
¸ðµç º¯È°¡ µð½ºÅ©¿¡ ¿ÏÀüÈ÷ ±â·ÏµÇ¾úÀ½À» º¸ÀåÇÑ´Ù.
gdbm_sync(dbf);
The parameter is:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
This would usually be called after a complete set of changes have been
made to the database and before some long waiting time.
gdbm_close
automatically calls the equivalent of gdbm_sync
so no call is needed if the database is to be closed immediately after
the set of changes have been made.
ÀÌ ÇÔ¼ö´Â º¸Åë µ¥ÀÌÅͺ£À̽º¿¡ ÀÏ·ÃÀÇ º¯È¸¦ ÁØ ÈÄ, ¿À·¡µ¿¾È ½¬±â Àü¿¡
»ç¿ëÇÑ´Ù. gdbm_close
´Â ÀÚµ¿À¸·Î gdbm_sync
¿Í
ºñ½ÁÇÑ ÀÛ¾÷À» Çϱ⠶§¹®¿¡ º¯ÈÈÄ Áï½Ã µ¥ÀÌÅͺ£À̽º¸¦ ´Ý´Â´Ù¸é ÀÌ ÇÔ¼ö¸¦
»ç¿ëÇÒ ÇÊ¿ä´Â ¾ø´Ù.
¿À·ù ¹®ÀÚ¿
To convert a gdbm
error code into English text, use this routine:
ret = gdbm_strerror(errno)
gdbm
¿À·ù Äڵ带 ¿µ¾î ¹®ÀåÀ¸·Î ¹Ù²Û´Ù.
ret = gdbm_strerror(errno)
The parameter is:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm
error code, usually gdbm_errno
.
gdbm
¿À·ù ÄÚµå, º¸Åë gdbm_errno
.
The appropiate phrase for reading by humans is returned.
»ç¶÷ÀÌ ¾Ë¾Æº¼ ¼ö ÀÖ´Â ¹®±¸°¡ ¹ÝȯµÈ´Ù.
¿É¼Ç ¼³Á¤Çϱâ
Gdbm
supports the ability to set certain options on an already
open database.
ret = gdbm_setopt(dbf, option, value, size);
ret = gdbm_setopt(dbf, option, value, size);
The parameters are:
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
option
will be set.
option
°ªÀ¸·Î »ç¿ëÇÒ ÀÚ·áÀÇ Æ÷ÀÎÅÍ.
value
.
value
Æ÷ÀÎÅÍ°¡ °¡¸®Å°´Â ÀÚ·áÀÇ Å©±â.
The valid options are:
°¡´ÉÇÑ ¿É¼ÇÀº ´ÙÀ½°ú °°´Ù.
GDBM_CACHESIZE - Set the size of the internal bucket cache. This
option may only be set once on each GDBM_FILE descriptor, and
is set automatically to 100 upon the first access to the database.
GDBM_CACHESIZE - ³»ºÎ ¹öŶ(bucket) ij½¬ÀÇ Å©±â¸¦ ¼³Á¤ÇÑ´Ù.
ÀÌ ¿É¼ÇÀº °¢ GDBM_FILE ±â¼úÀÚ¿¡ Çѹø¸¸ »ç¿ëÇÒ ¼ö ÀÖ°í,
µ¥ÀÌÅͺ£À̽º¿¡ óÀ½ Á¢±ÙÇÒ ¶§ ÀÚµ¿À¸·Î 100À¸·Î ¼³Á¤µÈ´Ù.
GDBM_FASTMODE - Set fast mode to either on or off. This allows
fast mode to be toggled on an already open and active database.
value (see below) should be set to either TRUE or FALSE.
This option is now obsolete.
GDBM_FASTMODE - ºü¸¥ ¸ðµå¸¦ Å°°í ²ö´Ù. ÀÌ ¿É¼ÇÀº ÀÌ¹Ì ¿·ÁÁø
µ¥ÀÌÅͺ£À̽ºÀÇ ºü¸¥ ¸ðµå¸¦ Å°°í ²ö´Ù. °ªÀº TRUE³ª FALSE¸¸ÀÌ °¡´ÉÇÏ´Ù. (¾Æ·¡ Âü°í)
ÀÌ ¿É¼ÇÀº ÇöÀç »ç¿ëµÇÁö ¾Ê´Â´Ù.
GDBM_SYNCMODE - Turn on or off file system synchronization operations. This
setting defaults to off; value (see below) should be set to either TRUE or
FALSE.
GDBM_SYNCMODE - ÆÄÀϽýºÅÛ µ¿±âȸ¦ Å°°í ²ö´Ù. ±âº»°ªÀº ²¨Á®ÀÖ´Ù.
°ªÀº TRUE³ª FALSE¸¸ÀÌ °¡´ÉÇÏ´Ù. (¾Æ·¡ Âü°í)
GDBM_CENTFREE - Set central free block pool to either on or off.
The default is off, which is how previous versions of Gdbm
handled free blocks. If set, this option causes all subsequent free
blocks to be placed in the global pool, allowing (in theory)
more file space to be reused more quickly. value (see below) should
be set to either TRUE or FALSE.
NOTICE: This feature is still under study.
GDBM_CENTFREE - Áß¾Ó ÇÁ¸®ºí·° Ç®(free block pool)À» Å°°í ²ö´Ù.
±âº»°ªÀº ²¨Á®ÀÖ´Ù. ÀÌ´Â °ú°Å gdbm
ÀÌ ÇÁ¸®ºí·°À» ´Ù·ç´Â
¹æ¹ýÀ̾ú´Ù. ÀÌ ¿É¼ÇÀ» Å°¸é ÀÌÈÄ ¸ðµç ÇÁ¸®ºí·°À» Àü¿ª Ç®¿¡
µÎ¾î¼ (ÀÌ·ÐÀûÀ¸·Î) ´õ ¸¹Àº ÆÄÀÏ°ø°£ÀÌ »¡¸® Àç»ç¿ëµÇ°Ô ÇÑ´Ù. °ªÀº
TRUE³ª FALSE¸¸ÀÌ °¡´ÉÇÏ´Ù. (¾Æ·¡ Âü°í)
ÁÖÀÇ: ÀÌ ±â´ÉÀº ÇöÀç ¿¬±¸ÁßÀÌ´Ù.
GDBM_COALESCEBLKS - Set free block merging to either on or off.
The default is off, which is how previous versions of Gdbm
handled free blocks. If set, this option causes adjacent free blocks
to be merged. This can become a CPU expensive process with time, though,
especially if used in conjunction with GDBM_CENTFREE. value (see below)
should be set to either TRUE or FALSE.
NOTICE: This feature is still under study.
GDBM_COALESCEBLKS - ÇÁ¸®ºí·° ÇÕÄ¡±â¸¦ Å°°í ²ö´Ù.
±âº»°ªÀº ²¨Á®ÀÖ´Ù. ÀÌ´Â °ú°Å gdbm
ÀÌ ÇÁ¸®ºí·°À» ´Ù·ç´Â
¹æ¹ýÀ̾ú´Ù. ÀÌ ¿É¼ÇÀ» Å°¸é ÀÌ¿ôÇÑ ÇÁ¸®ºí·°µéÀ» ÇÕÄ£´Ù. ±×·¯³ª
ÀÌ ÀÛ¾÷Àº (ƯÈ÷ GDBM_CENTFREE¿Í ÇÔ²² »ç¿ëÇϸé) CPU ÀÚ¿øÀ» ¸¹ÀÌ Â÷ÁöÇÑ´Ù.
°ªÀº TRUE³ª FALSE¸¸ÀÌ °¡´ÉÇÏ´Ù. (¾Æ·¡ Âü°í)
The return value will be -1 upon failure, or 0 upon success. The global
variable gdbm_errno
will be set upon failure.
For instance, to set a database to use a cache of 10, after opening it
with gdbm_open
, but prior to accessing it in any way, the following
code could be used:
int value = 10; ret = gdbm_setopt(dbf, GDBM_CACHESIZE, &value, sizeof(int));
½ÇÆÐÇϸé -1, ¼º°øÇϸé 0ÀÌ ¹ÝȯµÈ´Ù. ½ÇÆнà Àü¿ªº¯¼ö gdbm_errno
°¡
¼³Á¤µÈ´Ù.
¿¹¸¦ µé¾î gdbm_open
À¸·Î µ¥ÀÌÅͺ£À̽º¸¦ ¿¬ ÈÄ
½ÇÁ¦·Î Á¢±ÙÇϱâ Àü¿¡ ´ÙÀ½°ú °°ÀÌ µ¥ÀÌÅͺ£À̽ºÀÇ Ä³½¬¸¦ 10À¸·Î ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.
int value = 10; ret = gdbm_setopt(dbf, GDBM_CACHESIZE, &value, sizeof(int));
(¿ªÁÖ; À§¿¡¼ TRUE³ª FALSE¸¸ÀÌ °¡´ÉÇÏ´Ù°í Çߴµ¥, ÀÌ µÎ °ªÀº Çì´õÆÄÀÏ¿¡¼ Á¤ÀǵǾúÀ¸¹Ç·Î int value = TRUE;¿Í °°ÀÌ »ç¿ëÇÏ¸é µÈ´Ù.)
With locking disabled (if gdbm_open
was called with GDBM_NOLOCK),
the user may want to perform their own file locking on the database file
in order to prevent multiple writers operating on the same file
simultaneously.
In order to support this, the gdbm_fdesc
routine is provided.
ret = gdbm_fdesc(dbf);
(gdbm_open
¿¡¼ GDBM_NOLOCKÀ» »ç¿ëÇÏ¿©)
Àá±×±â¸¦ ¾ÈÇÑ´Ù¸é °°Àº ÆÄÀÏ¿¡ µ¿½Ã¿¡ ¿©·¯ ÇÊÀÚ°¡ Á¢±ÙÇÏ´Â °ÍÀ» ¸·±âÀ§ÇØ
Á÷Á¢ µ¥ÀÌÅͺ£À̽º ÆÄÀÏÀ» Àá±Û ÇÊ¿ä°¡ ÀÖ´Ù.
À̸¦ Áö¿øÇϱâ À§ÇØ gdbm_fdesc
ÇÔ¼ö°¡ Á¦°øµÈ´Ù.
ret = gdbm_fdesc(dbf);
The single valid parameter is:
ÆĶó¹ÌÅÍ´Â ´ÙÀ½°ú °°´Ù.
gdbm_open
.
gdbm_open
ÀÌ ¹ÝȯÇÑ Æ÷ÀÎÅÍ.
The return value will be the file descriptor of the database.
µ¥ÀÌÅͺ£À̽ºÀÇ ÆÄÀϱâ¼úÀÚ°¡ ¹ÝȯµÈ´Ù.
µÎ À¯¿ëÇÑ º¯¼ö
The following two variables are variables that may need to be used:
´ÙÀ½ µÎ º¯¼ö°¡ ÇÊ¿äÇÒ ¼ö ÀÖ´Ù.
gdbm
errors
(gdbm.h
has the definitions of the error values).
gdbm
¿À·ù¿¡ ´ëÇÑ Á¤º¸¸¦ ÀúÀåÇÏ´Â º¯¼ö.
(¿À·ù°ªÀÇ Á¤ÀÇ´Â gdbm.h
¿¡ ÀÖ´Ù.)
dbm
, ndbm
°ú ȣȯ¼º
GNU dbm
files are not sparse
. You can copy them with the UNIX
cp
command and they will not expand in the copying process.
There is a compatibility mode for use with programs that already use UNIX
dbm
and UNIX ndbm
.
GNU
GNU
ÀÌ¹Ì À¯´Ð½º
GNU dbm
has compatibility functions for dbm
. For dbm
compatibility functions, you need the include file dbm.h
.
dbm
ÆÄÀÏÀº Áß°£ÀÌ ºñ¾îÀÖÁö(sparse)
¾Ê´Ù.
±×·¡¼ À¯´Ð½º cp
¸í·ÉÀ¸·Î º¹»çÇصµ Å©±â°¡ Ä¿ÁöÁö ¾Ê´Â´Ù.
dbm
À̳ª ndbm
À» »ç¿ëÇÏ´Â ÇÁ·Î±×·¥À»
À§ÇÑ È£È¯ ¸ðµå°¡ ÀÖ´Ù.
dbm
˼ dbm
°ú ȣȯÀ» À§ÇÑ ÇÔ¼ö¸¦ Á¦°øÇÑ´Ù.
dbm
ȣȯ ÇÔ¼ö´Â Çì´õÆÄÀÏ dbm.h
¿¡ ¼±¾ðµÇÀÖ´Ù.
In this compatibility mode, no gdbm
file pointer is required
by the user, and Only one file may be opened at a time. All users in
compatibility mode are assumed to be writers. If the gdbm
file is a
read only, it will fail as a writer, but will also try to open it as a reader.
All returned pointers in datum structures point to data that gdbm
WILL
free. They should be treated as static pointers (as standard UNIX dbm
does). The compatibility function names are the same as the UNIX dbm
function names. Their definitions follow:
int dbminit(name); int store(key, content); datum fetch(key); int delete(key); datum firstkey(); datum nextkey(key); int dbmclose();
ȣȯ ¸ðµå¿¡¼ gdbm
ÆÄÀÏÆ÷ÀÎÅÍ´Â »ç¿ëÇÏÁö ¾Ê°í, ¿ÀÁ÷ ÇÑ
ÆÄÀϸ¸ µ¿½Ã¿¡ ¿ ¼ö ÀÖ´Ù. ȣȯ ¸ðµå¿¡¼´Â ¸ðµç »ç¿ëÀÚ¸¦ ÇÊÀÚ·Î °¡Á¤ÇÑ´Ù.
gdbm
ÆÄÀÏÀÌ ÀбâÀü¿ëÀ̶ó¸é ÇÊÀÚÀ̱⠶§¹®¿¡ ½ÇÆÐÇÒ °ÍÀÌ´Ù.
±×·¯³ª µ¶ÀÚ·Î ÆÄÀÏÀ» ¿ ¼ö ÀÖ´Ù. ¹ÝȯµÈ datum ÀڷᱸÁ¶ÀÇ Æ÷ÀÎÅÍ´Â
gdbm
ÀÌ ¾Ë¾Æ¼ ¹ÝȯÇÑ´Ù. Æ÷ÀÎÅ͸¦ (Ç¥ÁØ À¯´Ð½º dbm
ó·³)
Á¤ÀûÆ÷ÀÎÅÍ·Î Ãë±ÞÇØ¾ß ÇÑ´Ù. ȣȯ ÇÔ¼öÀ̸§Àº À¯´Ð½º dbm
°ú
°°´Ù. ÇÔ¼ö Á¤ÀÇ´Â ´ÙÀ½°ú °°´Ù.
int dbminit(name); int store(key, content); datum fetch(key); int delete(key); datum firstkey(); datum nextkey(key); int dbmclose();
Standard UNIX dbm
and GNU dbm
do not have the same data
format in the file. You cannot access a standard UNIX dbm
file with GNU
dbm
! If you want to use an old database with GNU dbm
, you must
use the conv2gdbm
program.
Also, GNU
Ç¥ÁØ À¯´Ð½º
GNU dbm
has compatibility functions for ndbm
. For
ndbm
compatibility functions, you need the include file ndbm.h
.
dbm
°ú GNU dbm
Àº °°Àº Çü½ÄÀ¸·Î ÆÄÀÏ¿¡
ÀڷḦ ÀúÀåÇÏÁö ¾Ê´Â´Ù. GNU dbm
À¸·Î Ç¥ÁØ À¯´Ð½º dbm
ÆÄÀÏÀ»
Á¢±ÙÇÒ ¼ö ¾ø´Ù! GNU dbm
À¸·Î ±âÁ¸ÀÇ µ¥ÀÌÅͺ£À̽º¸¦ »ç¿ëÇÏ·Á¸é
conv2gdbm
ÇÁ·Î±×·¥À» »ç¿ëÇÏ¿© º¯È¯ÇØ¾ß ÇÑ´Ù.
dbm
˼ ndbm
°ú ȣȯÀ» À§ÇÑ ÇÔ¼öµµ Á¦°øÇÑ´Ù.
ndbm
ȣȯ ÇÔ¼ö´Â Çì´õÆÄÀÏ ndbm.h
¿¡ ¼±¾ðµÇÀÖ´Ù.
Again, just like ndbm
, any returned datum can be assumed to be static
storage. You do not have to free that memory, the ndbm
compatibility
functions will do it for you.
The functions are:
DBM *dbm_open(name, flags, mode);
void dbm_close(file);
datum dbm_fetch(file, key);
int dbm_store(file, key, content
, flags);
int dbm_delete(file, key);
datum dbm_firstkey(file);
datum dbm_nextkey(file);
int dbm_error(file);
int dbm_clearerr(file);
int dbm_dirfno(file);
int dbm_pagfno(file);
int dbm_rdonly(file);
ndbm
°ú °°ÀÌ ¹ÝȯµÈ datumÀº Á¤Àû ¸Þ¸ð¸®¿¡ ÀÖ´Ù°í °¡Á¤ÇÑ´Ù.
±× ¸Þ¸ð¸®¸¦ ¹ÝȯÇÏ¸é ¾ÈµÈ´Ù. ndbm
ȣȯ ÇÔ¼ö°¡ ´ë½Å ¹ÝȯÇÑ´Ù.
ÇÔ¼ö´Â ´ÙÀ½°ú °°´Ù.
DBM *dbm_open(name, flags, mode);
void dbm_close(file);
datum dbm_fetch(file, key);
int dbm_store(file, key, content
, flags);
int dbm_delete(file, key);
datum dbm_firstkey(file);
datum dbm_nextkey(file);
int dbm_error(file);
int dbm_clearerr(file);
int dbm_dirfno(file);
int dbm_pagfno(file);
int dbm_rdonly(file);
If you want to compile an old C program that used UNIX dbm
or ndbm
and want to use gdbm
files, execute the following cc
command:
cc ... -L /usr/local/lib -lgdbm
À¯´Ð½º dbm
À̳ª ndbm
À» »ç¿ëÇÏ´Â ¿À·¡µÈ C ÇÁ·Î±×·¥À»
ÄÄÆÄÀÏ ÇÒ ¶§, ´ÙÀ½ cc
¸í·É¾î¸¦ ½ÇÇàÇÏ¿© gdbm
À»
ÀÌ¿ëÇÑ´Ù.
cc ... -L /usr/local/lib -lgdbm
dbm
ÆÄÀÏÀ» gdbm
Çü½ÄÀ¸·Î º¯È¯Çϱâ
The program conv2gdbm
has been provided to help you convert from dbm
databases to gdbm
. The usage is:
conv2gdbm [-q] [-b block_size] dbm_file [gdbm_file]
conv2gdbm
˼ dbm
µ¥ÀÌÅͺ£À̽º¸¦
gdbm
Çü½ÄÀ¸·Î º¯È¯Çϱâ À§Çؼ Á¦°øµÈ´Ù. »ç¿ë¹ýÀº ´ÙÀ½°ú °°´Ù.
conv2gdbm [-q] [-b block_size] dbm_file [gdbm_file]
The options are:
¿É¼ÇÀº ´ÙÀ½°ú °°´Ù.
conv2gdbm
to work quietly.
conv2gdbm
ÀÌ ÁøÇà°úÁ¤À» ȸ鿡 Ãâ·ÂÀ» ÇÏÁö¾Ê´Â´Ù.
gdbm_open
.
gdbm_open
¿¡¼¿Í °°´Ù.
dbm
file without the .pag
or .dir
extensions.
.pag
³ª .dir
È®ÀåÀÚ¸¦ Á¦¿ÜÇÑ dbm
ÆÄÀϸí.
gdbm
file name is the
same as the dbm
file name without any extensions. That is
conv2gdbm
dbmfile
converts the files dbmfile.pag
and
dbmfile.dir
into a gdbm
file called dbmfile
.
gdbm
ÆÄÀϸíÀº dbm
ÆÄÀÏ¸í¿¡¼ È®ÀåÀÚ¸¦ »« °Í°ú °°´Ù. Áï, conv2gdbm
dbmfile
˼
ÆÄÀÏ dbmfile.pag
°ú dbmfile.dir
À»
dbmfile
¶ó´Â gdbm
ÆÄÀÏ·Î º¯È¯ÇÑ´Ù.
If you have problems with GNU dbm
or think you've found a bug,
please report it. Before reporting a bug, make sure you've actually
found a real bug. Carefully reread the documentation and see if it
really says you can do what you're trying to do. If it's not clear
whether you should be able to do something or not, report that too; it's
a bug in the documentation!
Before reporting a bug or trying to fix it yourself, try to isolate it
to the smallest possible input file that reproduces the problem. Then
send us the input file and the exact results
GNU
¹ö±×¸¦ ¾Ë¸®°Å³ª Á÷Á¢ °íÄ¡·ÁÇϱâ Àü¿¡ ¹®Á¦¸¦ ¸¸µé ¼ö ÀÖ´Â
°¡´ÉÇÑ ÃÖ¼ÒÀÇ ÀÔ·Â ÆÄÀÏÀ» ¸¸µé¾îºÁ¶ó. ±×ÈÄ ÀÔ·ÂÆÄÀÏ°ú gdbm
gave you. Also
say what you expected to occur; this will help us decide whether the
problem was really in the documentation.
dbm
¿¡ ¹®Á¦°¡ Àְųª ¹ö±×¸¦ ¹ß°ßÇß´Ù°í »ý°¢µÇ¸é
¾Ë·ÁÁà¶ó. ¹ö±×¸¦ ¾Ë¸®±â Àü¿¡ ½ÇÁ¦·Î ¹ö±×¸¦ ¹ß°ßÇß´ÂÁö È®ÀÎÇ϶ó.
¹®¼¸¦ ÁÖÀÇÀÖ°Ô ´Ù½ÃÀаí ÀǵµÇÑ ÀÏÀ» ½ÇÁ¦·Î ÇÒ ¼ö ÀÖ´ÂÁö ¾Ë¾ÆºÁ¶ó.
ÇÒ ¼ö ÀÖ´ÂÁö ¸íÈ®ÇÏÁö ¾Ê´Ù¸é ±×°Íµµ ¾Ë·Á¶ó. ÀÌ´Â ¹®¼ÀÇ ¹ö±×ÀÌ´Ù!
gdbm
ÀÇ
°á°ú¸¦ ±×´ë·Î ¿ì¸®¿¡°Ô º¸³»¶ó. ¶ÇÇÑ ¹«½¼ ÀÏÀÌ ÀϾ±â¸¦ ¹Ù·¨´ÂÁöµµ
¾Ë·ÁÁà¶ó. ±×·¯¸é ¿ì¸®°¡ ¹®¼¿¡ ¹®Á¦°¡ ÀÖ´ÂÁö¸¦ ¾Æ´Âµ¥ µµ¿òÀÌ µÈ´Ù.
Once you've got a precise problem, send e-mail to:
Internet: `bug-gnu-utils@prep.ai.mit.edu'. UUCP: `mit-eddie!prep.ai.mit.edu!bug-gnu-utils'.
¹®Á¦¸¦ ¹ß°ßÇÏ¸é ¾Æ·¡·Î ¸ÞÀÏÀ» º¸³»¶ó.
ÀÎÅͳÝ: `bug-gnu-utils@prep.ai.mit.edu'. UUCP: `mit-eddie!prep.ai.mit.edu!bug-gnu-utils'.
Please include the version number of GNU dbm
you are using. You can get
this information by printing the variable gdbm_version
(see Variables).
Non-bug suggestions are always welcome as well. If you have questions
about things that are unclear in the documentation or are just obscure
features, please report them too.
»ç¿ëÇÏ´Â GNU
¹ö±× ¿Ü¿¡ Á¦¾Èµµ ȯ¿µÇÑ´Ù. ¹®¼¿¡ ºÒºÐ¸íÇÑ ³»¿ëÀ̳ª ¾Ö¸ÅÇÑ ±â´ÉÀÌ
ÀÖ´Ù¸é À̰͵µ ¿ì¸®¿¡°Ô ¾Ë·ÁÁÖ±æ ¹Ù¶õ´Ù.
dbm
¹öÀüµµ °°ÀÌ ¾Ë·ÁÁà¶ó. ¹öÀüÀº
º¯¼ö gdbm_version
À» Ãâ·ÂÇÏ¸é ¾Ë ¼ö ÀÖ´Ù. ("µÎ À¯¿ëÇÑ º¯¼ö" Âü°í)
You may contact the author by:
e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226
¾Æ·¡ ÁÖ¼Ò·Î ÀúÀÚ¿Í ¿¬¶ôÇÒ ¼ö ÀÖ´Ù.
e-mail: phil@cs.wwu.edu us-mail: Philip A. Nelson Computer Science Department Western Washington University Bellingham, WA 98226
You may contact the current maintainer by:
e-mail: downsj@downsj.com
¾Æ·¡ ÁÖ¼Ò·Î ÇöÀç ¸ÞÀÎÅ×ÀÌ³Ê¿Í ¿¬¶ôÇÒ ¼ö ÀÖ´Ù.
e-mail: downsj@downsj.com
This document was generated on 26 August 2001 using texi2html 1.56k.