.\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)dbopen.3 8.5 (Berkeley) 1/2/94 .\" .\" $FreeBSD$ .TH DBOPEN 3 "January 2, 1994" .UC 7 .SH ̾�� dbopen \- �ǡ����١��������������� .SH �� .nf .ft B #include <sys/types.h> #include <limits.h> #include <db.h> DB * dbopen(const char *file, int flags, int mode, DBTYPE type, .ti +5 const void *openinfo); .ft R .fi .SH ���� .I dbopen �ϡ��ǡ����١����ե�����ؤΥ饤�֥�ꥤ�ե������Ǥ��� ���ݡ��Ȥ���Ƥ���ե�����ե����ޥåȤϡ� .I btree �������ϥå��������UNIX �ե�����ظ������Ǥ��� .I btree �ե����ޥåȤϡ������ȺѤߤΥХ�ΤȤ줿 �ĥ��¤��ɽ���Ǥ����ϥå���ե����ޥåȤϡ���ĥ��ǽ��ưŪ�� �ϥå��她�����ޤǤ����ե�åȥե�����ե����ޥåȤϡ�����Ĺ�ޤ��ϲ���Ĺ �쥳���ɤ���ʤ�Х��ȥ��ȥ��ե�����Ǥ����ե����ޥåȤ���� �ե�����ե����ޥåȤ˸�ͭ�ξ���ˤĤ��Ƥϡ����줾��Υޥ˥奢��ڡ����� �ܤ����Ҥ٤��Ƥ��ޤ��� .IR btree (3), .IR hash (3), .IR recno (3) �Ǥ��� .PP .I dbopen �ϡ��ɤ߹��ߤޤ��Ͻ����Ѥ� .I file �� open ���ޤ����ǥ���������ݻ�����ɬ�פΤʤ��ե�����ϡ� �ե�����ѥ�����̥�����ꤹ�뤳�ȤǺ����Ǥ��ޤ��� .PP ���� .I flags �Ȱ��� .I mode �ϡ� .IR open (2) �ǻ��ꤵ���Τ�Ʊ���Ǥ����������� O_CREAT, O_EXCL, O_EXLOCK, O_NONBLOCK, O_RDONLY, O_RDWR, O_SHLOCK, O_TRUNC �γƥե饰�����˰�̣������ޤ� (�ǡ����١����ե������ O_WRONLY �Ǥ� open �Ǥ��ʤ����Ȥ����դ��Ƥ�������) �� .\"Three additional options may be specified by .\".IR or 'ing .\"them into the .\".I flags .\"argument. .\".TP .\"DB_LOCK .\"Do the necessary locking in the database to support concurrent access. .\"If concurrent access isn't needed or the database is read-only this .\"flag should not be set, as it tends to have an associated performance .\"penalty. .\".TP .\"DB_SHMEM .\"Place the underlying memory pool used by the database in shared .\"memory. .\"Necessary for concurrent access. .\".TP .\"DB_TXN .\"Support transactions in the database. .\"The DB_LOCK and DB_SHMEM flags must be set as well. .PP ���� .I type �ϡ������� DBTYPE (���롼�ɥե����� <db.h> ���������Ƥ��ޤ�) �Ǥ��ꡢDB_BTREE, DB_HASH, DB_RECNO ������Ǥ��ޤ��� .PP ���� .I openinfo �ϡ��������������Υޥ˥奢��ڡ������������Ƥ���褦�ˡ� �������������˸�ͭ�ι�¤��ؤ��ݥ��Ǥ��� .I openinfo ���̥�ξ�硢�ƥ������������ϡ������ƥ�ȥ������������� Ŭ�ڤʥǥե���Ȥ���Ѥ��ޤ��� .PP .I dbopen �ϡ���������������� DB ��¤�Τ�ؤ��ݥ����֤��� ���顼�ξ��ˤϥ̥���֤��ޤ��� DB ��¤�Τϡ����롼�ɥե����� <db.h> ����������Ƥ��ꡢ ���ʤ��Ȥ⼡�Υե�����ɤ��ޤޤ�Ƥ��ޤ��� .sp .nf typedef struct { .RS DBTYPE type; int (*close)(const DB *db); int (*del)(const DB *db, const DBT *key, u_int flags); int (*fd)(const DB *db); int (*get)(const DB *db, DBT *key, DBT *data, u_int flags); int (*put)(const DB *db, DBT *key, const DBT *data, .ti +5 u_int flags); int (*sync)(const DB *db, u_int flags); int (*seq)(const DB *db, DBT *key, DBT *data, u_int flags); .RE } DB; .fi .PP ���������Ǥϡ��ǡ����١��������פȳƼ�Υ���������¹Ԥ��� �ؿ��Υ��åȤҤ��Ƥ��ޤ��������δؿ��ϡ� .I dbopen �ˤ�ä��֤��줿��¤�ΤؤΥݥ�������˼�ꡢ ��������/�ǡ�����¤�ȥե饰�ͤ�ؤ� 1 �Ĥޤ���ʣ���Υݥ��� ��뤳�Ȥ⤢��ޤ��� .TP type ���ܥ����������� (����ӥե�����ե����ޥå�) �Υ����ס� .TP close ����å��夵�줿�����ǥ������˥ե�å��夷����꿶��줿������� ����������ˤʤäƤ���ե����� (1 �Ĥޤ���ʣ��) ���Ĥ���롼�����ؤ� �ݥ�������/�ǡ������Ȥϥ���˥���å��夵���Τǡ��ե������ .I close �ؿ��ޤ��� .I sync �ؿ��ǥե������Ʊ������Τ˼��Ԥ���ȡ������̷����� �����뤫�⤷��ޤ��� .I close �롼����ϡ����顼��λ���ˤ� -1 ���֤� (errno������) �� ���ェλ���ˤ� 0 ���֤��ޤ��� .TP del ����/�ǡ������Ȥ�ǡ����١�������������롼�����ؤ��ݥ��� .IP �ѥ��� .I flag �ϼ����ͤ�����Ǥ��ޤ��� .RS .TP R_CURSOR �������뤬���Ȥ���쥳���ɤ������ޤ�����������ϡ� ���餫�����������Ƥ���ɬ�פ�����ޤ��� .RE .IP delete �롼����ϥ��顼��λ���ˤ� -1 ���֤� (errno������) �� ���ェλ���ˤ� 0 ���֤��ޤ������ꤷ�� .I key ���ե��������ˤʤ��ä����� 1 ���֤��ޤ��� .TP fd ���ܥǡ����١����Υե����뵭��ɽ�����֤��롼�����ؤ��ݥ��� Ʊ���ե�����Ȥ��Ƥ���ե����뵭�һҤϡ�Ʊ�� .I file ̾�� .I dbopen ��ƤӽФ����ץ��������֤���ޤ������Υե����뵭�һҤϡ����å��ؿ� .IR fcntl (2) �� .IR flock (2) �ؤΰ����Ȥ��ư����˻��ѤǤ��ޤ��� �ե����뵭�һҤϡ�ɬ�����⥢���������������Ѥ��Ƥ�����ܥե������ ��Ϣ�դ����Ƥ���ɬ�פϤ���ޤ��ե����뵭�һҤ� ����ǡ����١���������ѤǤ��ޤ��� .I fd �롼����ϡ����顼��λ���� -1 ���֤� (errno������) �� ���ェλ���ˤϥե����뵭�һҤ��֤��ޤ��� .TP get �ǡ����١������饭������Ѥ��Ƽ��Ф����ե������Ǥ��� �롼�����ؤ��ݥ�������� .I key �˴�Ϣ�դ���줿�ǡ����Υ��ɥ쥹��Ĺ������ .I data �ǻ��Ȥ���빽¤������֤���ޤ��� .I get �롼����ϥ��顼��λ���ˤ� -1 ���֤� (errno������) �� ���ェλ���ˤ� 0 ���֤��ޤ��� .I key ���ե��������ˤʤ��ä����� 1 ���֤��ޤ��� .TP put ����/�ǡ������Ȥ�ǡ����١��������¸����롼�����ؤ��ݥ��� .IP �ѥ��� .I flag �ˤϼ����ͤ� 1 �Ĥ�����Ǥ��ޤ��� .RS .TP R_CURSOR �������뤬���Ȥ��륭��/�ǡ������Ȥ��֤������ޤ�����������ϡ� ���餫������������Ƥ���ɬ�פ�����ޤ��� .TP R_IAFTER .I key �ǻ��Ȥ����ǡ�����ľ��˥ǡ������ɲä��� ����������/�ǡ������Ȥ�������ޤ����ɲä�������/�ǡ������ȤΥ쥳�����ֹ椬 .I key ��¤������֤���ޤ� ( DB_RECNO �������������ˤ���Ŭ�ѤǤ��ޤ�) �� .TP R_IBEFORE .I key �ǻ��Ȥ����ǡ�����ľ���˥ǡ������������� ����������/�ǡ������Ȥ�������ޤ����ɲä�������/�ǡ������ȤΥ쥳�����ֹ椬 .I key ��¤������֤���ޤ� (DB_RECNO �������������ˤ���Ŭ�ѤǤ��ޤ�) �� .TP R_NOOVERWRITE ���������������¸�ߤ��ʤ����ˤ���������������/�ǡ������Ȥ����Ϥ��ޤ��� .TP R_SETCURSOR ����/�ǡ������Ȥ���¸��������Ȥ��륫������ΰ��֤åȡ��ޤ��� ��������ޤ� (DB_BTREE ����� DB_RECNO �������������ˤ���Ŭ�ѤǤ��ޤ�) �� .RE .IP R_SETCURSOR �����ѤǤ���Τϡ�DB_BTREE �� DB_RECNO �Υ������������Ǥ����Ǥ��� �����ˤϡ��Ѳ����ʤ���ͭ�ν�������뤳�Ȥ��̣���Ƥ��뤫��Ǥ��� .IP R_IAFTER �� R_IBEFORE �� DB_RECNO �������������ˤ������ѤǤ��ޤ��� �ɤ�⡢������������������������������Ǥ��뤳�Ȥ��̣���Ƥ��뤫��Ǥ��� ����ϡ�����������դ����Ƥ�����Ω�ʾ��ˤ������Ȥʤ�ޤ��� ���Ȥ��С��쥳�����ֹ�Ǥ��� .IP .I put �롼����Υǥե���Ȥ�ư��ϡ�����������/�ǡ������Ȥ����Ϥ��� ���������¸�ߤ��Ƥ����������֤������뤳�ȤǤ��� .IP .I put �롼����ϥ��顼��λ���ˤ� -1 ���֤� (errno������) �� ���ェλ���ˤ� 0 ���֤��� R_NOOVERWRITE �ե饰�����ꤵ��Ƥ��ơ������⥭�����ե�������� ����¸�ߤ������ 1 ���֤��ޤ��� .TP seq �ǡ����١�������Υ��������ʼ��Ф��ѥ��ե������Ǥ��� �롼�����ؤ��ݥ��������Υ��ɥ쥹��Ĺ���� .I key �����Ȥ��빽¤������֤��졢�ǡ����Υ��ɥ쥹��Ĺ���� .I data �����Ȥ��빽¤������֤���ޤ��� .IP ���������ʥ���/�ǡ������Ȥμ��Ф��ϡ����ĤǤⳫ�Ϥ��뤳�Ȥ��Ǥ��� ``��������''�ΰ��֤� .IR del , .IR get , .IR put , .I sync �γƥ롼����ˤ��ƤӽФ��ˤ�äƱƶ�������ޤ��� ���������������δ֤Υǡ����١����ν�����������ȿ�Ǥ���ޤ��� ���ʤ������������������������줿�쥳���ɤ��֤����ޤǤδ֡� ��������θ�����������줿�쥳���ɤ��֤���ޤ��� .IP �ե饰�ͤϼ����ͤ� 1 �Ĥ˥��åȤ��ʤ���Фʤ�ޤ��� .RS .TP R_CURSOR ����Υ����˴�Ϣ�դ���줿�ǡ������֤���ޤ�������ϥ���������ΰ��֤� ���åȤޤ��Ͻ��������Ȥ������� .I get �롼����Ȱۤʤ�ޤ� (DB_BTREE �������������ξ�硢�֤��줿������ɬ���������Υ��������Τ˰��פ��� ɬ�פ��ʤ����Ȥ����դ��Ƥ����������֤���륭���ϡ�����Υ������ �礭�����ޤ����������褦�ʡ��Ǿ��Υ����Ǥ��ꡢ ��ʬŪ�ʥ������פ��ϰϸ������Ǥ��ޤ�) �� .TP R_FIRST �ǡ����١����κǽ�Υ���/�ǡ������Ȥ��֤��졢��������Ϥ���� ���Ȥ���褦�˥��åȤޤ��Ͻ��������ޤ��� .TP R_LAST �ǡ����١����κǸ�Υ���/�ǡ������Ȥ��֤��졢��������Ϥ���� ���Ȥ���褦�˥��åȤޤ��Ͻ��������ޤ� ( DB_BTREE �� DB_RECNO �γƥ������������ˤ���Ŭ�ѤǤ��ޤ�) �� .TP R_NEXT ���������ľ��ˤ��륭��/�ǡ������Ȥ���Ф��ޤ����������뤬�ޤ� ���åȤ���Ƥ��ʤ����ϡ������ R_FIRST �ե饰��Ʊ���ˤʤ�ޤ��� .TP R_PREV ���������ľ���ˤ��륭��/�ǡ������Ȥ���Ф��ޤ����������뤬�ޤ� ���ꤵ��Ƥ��ʤ����ˤϡ������ R_LAST �ե饰��Ʊ���ˤʤ�ޤ���( DB_BTREE �� DB_RECNO �γƥ������������ˤ���Ŭ�ѤǤ��ޤ�) �� .RE .IP R_LAST �� R_PREV �����ѤǤ���Τϡ�DB_BTREE �� DB_RECNO �γ� �������������ˤĤ��Ƥ����Ǥ��������Ϥ��줾�쥭�����Ѳ����ʤ���ͭ�� ��������뤳�Ȥ��̣���Ƥ��뤫��Ǥ��� .IP .I seq �롼����ϥ��顼��λ���ˤ� -1 ���֤� (errno������) �� ���ェλ���ˤ� 0 ���֤�������Υ����ޤ��ϸ��ߤΥ�����꾮�������ޤ��� �礭������/�ǡ������Ȥ�¸�ߤ��ʤ����� 1 ���֤��ޤ��� DB_RECNO �����������������Ѥ���Ƥ��ơ� ������ǡ����١����ե����뤬����饯���ü�ե�����Ǥ��ꡢ �����ʥ���/�ǡ������Ȥ����λ�����¸�ߤ��ʤ���硢 .I seq �롼����� 2 ���֤��ޤ��� .TP sync ����å��夵�줿�����ǥ������˥ե�å��夹��롼�����ؤ��ݥ��� �ǡ����١�����������ˤ���¸�ߤ����硢 .I sync �롼����ˤϲ��θ��̤�ʤ��������Ͼ�����ェλ���ޤ��� .IP �ե饰�ͤϼ����ͤ˥��åȤǤ��ޤ��� .RS .TP R_RECNOSYNC DB_RECNO �����������������Ѥ�����硢���Υե饰�� .I sync �롼���� .I recno �ե����뼫�ȤǤϤʤ��� .I recno �ե�����δ�Ȥʤ� .I btree �ե������Ŭ�Ѥ����褦�ˤ��ޤ� (�ܺ٤ˤĤ��Ƥ� .IR recno (3) �ޥ˥奢��ڡ����� .I bfname �ե�����ɤȤ��Ƥ�������) �� .RE .IP .I sync �롼����ϥ��顼��λ���ˤ� -1 ���֤� (errno������) �� ���ェλ���ˤ� 0 ���֤��ޤ��� .SH ����/�ǡ������� ���٤ƤΥե����륿���פؤΥ��������ϥ���/�ǡ������Ȥ��ˤ��Ƥ��ޤ��� �����ȥǡ�����ξ�������Υǡ�����¤��ɽ����ޤ��� .PP typedef struct { .RS void *data; .br size_t size; .RE } DBT; .PP DBT ��¤�Τ����Ǥϼ��Τ褦���������ޤ��� .TP data �Х��ȥ��ȥ��ؤ��ݥ��� .TP size �Х��ȥ��ȥ��Ĺ���� .PP �����ȥǡ����Х��ȥ��ȥ�ϡ�Ʊ�������ѤǤ������˥ե��åȤ���ɬ�� �Ϥ���ޤ��������ȤǤ���ʸ�����Ĺ���ˤ��ܼ�Ū�ˤ����¤�����ޤ��� �������������ϡ��Х��ȥ��ȥ�ΥХ��ȥ��饤��ˤĤ��Ƥ� �����ݾڤ⤷�Ƥ��ʤ����Ȥ����դ��٤��Ǥ��� .SH ���顼 .I dbopen �롼�����顼��λ����ȡ��饤�֥��롼���� .IR open (2) �� .IR malloc (3) �ǽ�Ƥ��륨�顼���ޤ��ϲ����Υ��顼���Ф��� .I errno �åȤ��ޤ��� .TP [EFTYPE] �ե�����Υե����ޥåȤ��ְ�äƤ��ޤ��� .TP [EINVAL] ��¸�Υե��������ȸߴ����Τʤ��ѥ��� (�ϥå���ؿ��� �ѥåɥХ��Ȥʤ�) �䡢�ؿ��˰�̣�Τʤ��ѥ��������ꤵ�줿 (���Ȥ��С� �����ν�������Ԥʤ��Ƥ��ʤ���������λ���) �� �ޤ��ϥե�����ȥ��եȥ������ΥС������֤����פ�����ޤ��� .PP .I close �롼�����顼��λ����ȡ��饤�֥��롼���� .IR close (2), .IR read (2), .IR write (2), .IR free (3), .IR fsync (2) �˽�Ƥ��륨�顼�ˤĤ��Ƥ� .I errno �åȤ��ޤ��� .PP .IR del , .IR get , .IR put , .I seq �γƥ롼�����顼��λ����ȡ��饤�֥��롼���� .IR read (2), .IR write (2), .IR free (3), .IR malloc (3) �˽�Ƥ��륨�顼�ˤĤ��Ƥ� .I errno �åȤ��ޤ��� .PP .I fd �롼�����顼��λ����ȡ�����ǡ����١������ ENOENT �� .I errno �åȤ��ޤ��� .PP .I sync �롼�����顼��λ����ȡ��饤�֥��롼���� .IR fsync(2) �˽�Ƥ��륨�顼�ˤĤ��Ƥ� .I errno �åȤ��ޤ��� .SH ��Ϣ���� .IR btree (3), .IR hash (3), .IR mpool (3), .IR recno (3) .sp .IR "LIBTP: Portable, Modular Transactions for UNIX" , .SH �Х� typedef DBT �ϡ�``data base thang'' ��ά�Τǡ� �ޤ����Ѥ���Ƥ��ʤ�����Ū��̾����ï��פ��Ĥ��ʤ��ä������ �Ȥ��뤳�Ȥˤʤ�ޤ����� .PP �ե����뵭�һҥ��ե������Ϲ�����Ĵ�¤��Ƥ��餺�� ���ե������κ���ΥС������ǤϺ�������ͽ��Ǥ��� .PP �ɤΥ������������⡢�¹ԥ������������å����ޤ��ϥȥ������� �ϡ��ɤΤ褦�ʷ����Ǥ����ޤ���