gdbm: more user-friendly initial configuration
parent
9a1a60f804
commit
4720a1aad3
|
@ -14,10 +14,8 @@ LIBRARY: libgdbm
|
||||||
|
|
||||||
C-GLOBAL: c-string gdbm_version
|
C-GLOBAL: c-string gdbm_version
|
||||||
|
|
||||||
CONSTANT: GDBM_READER 0
|
ENUM: gdbm-role reader writer wrcreat newdb ;
|
||||||
CONSTANT: GDBM_WRITER 1
|
|
||||||
CONSTANT: GDBM_WRCREAT 2
|
|
||||||
CONSTANT: GDBM_NEWDB 3
|
|
||||||
CONSTANT: GDBM_SYNC HEX: 20
|
CONSTANT: GDBM_SYNC HEX: 20
|
||||||
CONSTANT: GDBM_NOLOCK HEX: 40
|
CONSTANT: GDBM_NOLOCK HEX: 40
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
! Copyright (C) 2010 Dmitry Shubin.
|
! Copyright (C) 2010 Dmitry Shubin.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.c-types alien.data alien.destructors
|
USING: accessors alien.c-types alien.data alien.destructors
|
||||||
classes.struct combinators destructors gdbm.ffi io.backend kernel libc
|
alien.enums classes.struct combinators destructors gdbm.ffi io.backend
|
||||||
literals locals math namespaces sequences serialize strings ;
|
kernel libc locals math namespaces sequences serialize strings ;
|
||||||
IN: gdbm
|
IN: gdbm
|
||||||
|
|
||||||
TUPLE: gdbm
|
TUPLE: gdbm
|
||||||
{ name string }
|
{ name string }
|
||||||
{ block-size integer }
|
{ block-size integer }
|
||||||
{ flags integer initial: $ GDBM_WRCREAT }
|
{ role initial: wrcreat }
|
||||||
{ mode integer initial: OCT: 644 } ;
|
{ sync boolean }
|
||||||
|
{ nolock boolean }
|
||||||
|
{ mode integer initial: OCT: 644 } ;
|
||||||
|
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -22,10 +24,16 @@ SYMBOL: current-dbf
|
||||||
|
|
||||||
: dbf ( -- dbf ) current-dbf get ;
|
: dbf ( -- dbf ) current-dbf get ;
|
||||||
|
|
||||||
|
: get-flag ( gdbm -- n )
|
||||||
|
[ role>> enum>number ]
|
||||||
|
[ sync>> GDBM_SYNC 0 ? ]
|
||||||
|
[ nolock>> GDBM_NOLOCK 0 ? ]
|
||||||
|
tri bitor bitor ;
|
||||||
|
|
||||||
: gdbm-open ( gdbm -- dbf )
|
: gdbm-open ( gdbm -- dbf )
|
||||||
{
|
{
|
||||||
[ name>> normalize-path ]
|
[ name>> normalize-path ]
|
||||||
[ block-size>> ] [ flags>> ] [ mode>> ]
|
[ block-size>> ] [ get-flag ] [ mode>> ]
|
||||||
} cleave f gdbm_open [ gdbm-throw ] unless* ;
|
} cleave f gdbm_open [ gdbm-throw ] unless* ;
|
||||||
|
|
||||||
DESTRUCTOR: gdbm-close
|
DESTRUCTOR: gdbm-close
|
||||||
|
|
Loading…
Reference in New Issue