2
+----------------------------------------------------------------------+
4
+----------------------------------------------------------------------+
5
| Copyright (c) 1997-2004 The PHP Group |
6
+----------------------------------------------------------------------+
7
| This source file is subject to version 3.0 of the PHP license, |
8
| that is bundled with this package in the file LICENSE, and is |
9
| available through the world-wide-web at the following url: |
10
| http://www.php.net/license/3_0.txt. |
11
| If you did not receive a copy of the PHP license and are unable to |
12
| obtain it through the world-wide-web, please send a note to |
13
| license@php.net so we can mail you a copy immediately. |
14
+----------------------------------------------------------------------+
15
| Author: Sascha Schumann <sascha@schumann.cx> |
16
+----------------------------------------------------------------------+
19
/* $Id: dba_ndbm.c,v 1.18 2004/01/08 08:14:39 andi Exp $ */
31
#ifdef NDBM_INCLUDE_FILE
32
#include NDBM_INCLUDE_FILE
35
#define NDBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen
42
dba_info *pinfo = (dba_info *) info;
52
gmode = O_RDWR | O_CREAT;
55
gmode = O_RDWR | O_CREAT | O_TRUNC;
58
return FAILURE; /* not possible */
62
convert_to_long_ex(info->argv[0]);
63
filemode = Z_LVAL_PP(info->argv[0]);
66
dbf = dbm_open(info->path, gmode, filemode);
83
gval = dbm_fetch(info->dbf, gkey);
85
if(newlen) *newlen = gval.dsize;
86
new = estrndup(gval.dptr, gval.dsize);
96
gval.dptr = (char *) val;
99
if(!dbm_store(info->dbf, gkey, gval, mode == 1 ? DBM_INSERT : DBM_REPLACE))
104
DBA_EXISTS_FUNC(ndbm)
108
gval = dbm_fetch(info->dbf, gkey);
115
DBA_DELETE_FUNC(ndbm)
118
return(dbm_delete(info->dbf, gkey) == -1 ? FAILURE : SUCCESS);
121
DBA_FIRSTKEY_FUNC(ndbm)
126
gkey = dbm_firstkey(info->dbf);
128
if(newlen) *newlen = gkey.dsize;
129
key = estrndup(gkey.dptr, gkey.dsize);
134
DBA_NEXTKEY_FUNC(ndbm)
139
gkey = dbm_nextkey(info->dbf);
141
if(newlen) *newlen = gkey.dsize;
142
nkey = estrndup(gkey.dptr, gkey.dsize);
147
DBA_OPTIMIZE_FUNC(ndbm)
159
return estrdup("NDBM");
169
* vim600: sw=4 ts=4 fdm=marker