1*2639ae9bSBen Gras.\" $NetBSD: dbm_clearerr.3,v 1.5 2010/05/05 06:55:57 jruoho Exp $ 2*2639ae9bSBen Gras.\" 3*2639ae9bSBen Gras.\" Copyright (c) 2004 The NetBSD Foundation, Inc. 4*2639ae9bSBen Gras.\" All rights reserved. 5*2639ae9bSBen Gras.\" 6*2639ae9bSBen Gras.\" This code is derived from software contributed to The NetBSD Foundation 7*2639ae9bSBen Gras.\" by Klaus Klein. 8*2639ae9bSBen Gras.\" 9*2639ae9bSBen Gras.\" Redistribution and use in source and binary forms, with or without 10*2639ae9bSBen Gras.\" modification, are permitted provided that the following conditions 11*2639ae9bSBen Gras.\" are met: 12*2639ae9bSBen Gras.\" 1. Redistributions of source code must retain the above copyright 13*2639ae9bSBen Gras.\" notice, this list of conditions and the following disclaimer. 14*2639ae9bSBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 15*2639ae9bSBen Gras.\" notice, this list of conditions and the following disclaimer in the 16*2639ae9bSBen Gras.\" documentation and/or other materials provided with the distribution. 17*2639ae9bSBen Gras.\" 18*2639ae9bSBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19*2639ae9bSBen Gras.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20*2639ae9bSBen Gras.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*2639ae9bSBen Gras.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22*2639ae9bSBen Gras.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*2639ae9bSBen Gras.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*2639ae9bSBen Gras.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*2639ae9bSBen Gras.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*2639ae9bSBen Gras.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*2639ae9bSBen Gras.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*2639ae9bSBen Gras.\" POSSIBILITY OF SUCH DAMAGE. 29*2639ae9bSBen Gras.\" 30*2639ae9bSBen Gras.Dd May 5, 2010 31*2639ae9bSBen Gras.Dt DBM_CLEARERR 3 32*2639ae9bSBen Gras.Os 33*2639ae9bSBen Gras.Sh NAME 34*2639ae9bSBen Gras.Nm dbm_clearerr , 35*2639ae9bSBen Gras.Nm dbm_close , 36*2639ae9bSBen Gras.Nm dbm_delete , 37*2639ae9bSBen Gras.Nm dbm_dirfno , 38*2639ae9bSBen Gras.Nm dbm_error , 39*2639ae9bSBen Gras.Nm dbm_fetch , 40*2639ae9bSBen Gras.Nm dbm_firstkey , 41*2639ae9bSBen Gras.Nm dbm_nextkey , 42*2639ae9bSBen Gras.Nm dbm_open , 43*2639ae9bSBen Gras.Nm dbm_store , 44*2639ae9bSBen Gras.Nm ndbm 45*2639ae9bSBen Gras.Nd database functions 46*2639ae9bSBen Gras.Sh LIBRARY 47*2639ae9bSBen Gras.Lb libc 48*2639ae9bSBen Gras.Sh SYNOPSIS 49*2639ae9bSBen Gras.In ndbm.h 50*2639ae9bSBen Gras.Ft int 51*2639ae9bSBen Gras.Fn dbm_clearerr "DBM *db" 52*2639ae9bSBen Gras.Ft void 53*2639ae9bSBen Gras.Fn dbm_close "DBM *db" 54*2639ae9bSBen Gras.Ft int 55*2639ae9bSBen Gras.Fn dbm_delete "DBM *db" "datum key" 56*2639ae9bSBen Gras.Ft int 57*2639ae9bSBen Gras.Fn dbm_dirfno "DBM *db" 58*2639ae9bSBen Gras.Ft int 59*2639ae9bSBen Gras.Fn dbm_error "DBM *db" 60*2639ae9bSBen Gras.Ft datum 61*2639ae9bSBen Gras.Fn dbm_fetch "DBM *db" "datum key" 62*2639ae9bSBen Gras.Ft datum 63*2639ae9bSBen Gras.Fn dbm_firstkey "DBM *db" 64*2639ae9bSBen Gras.Ft datum 65*2639ae9bSBen Gras.Fn dbm_nextkey "DBM *db" 66*2639ae9bSBen Gras.Ft DBM * 67*2639ae9bSBen Gras.Fn dbm_open "const char *file" "int open_flags" "mode_t file_mode" 68*2639ae9bSBen Gras.Ft int 69*2639ae9bSBen Gras.Fn dbm_store "DBM *db" "datum key" "datum content" "int store_mode" 70*2639ae9bSBen Gras.Sh DESCRIPTION 71*2639ae9bSBen GrasThe 72*2639ae9bSBen Gras.Nm ndbm 73*2639ae9bSBen Grasfacility provides access to hash database files. 74*2639ae9bSBen Gras.Pp 75*2639ae9bSBen GrasTwo data types are fundamental to the 76*2639ae9bSBen Gras.Nm ndbm 77*2639ae9bSBen Grasfacility. 78*2639ae9bSBen Gras.Fa DBM 79*2639ae9bSBen Grasserves as a handle to a database. 80*2639ae9bSBen GrasIt is an opaque type. 81*2639ae9bSBen Gras.Pp 82*2639ae9bSBen GrasThe other data type is 83*2639ae9bSBen Gras.Fa datum , 84*2639ae9bSBen Graswhich is a structure type which includes the following members: 85*2639ae9bSBen Gras.Bd -literal -offset indent 86*2639ae9bSBen Grasvoid * dptr 87*2639ae9bSBen Grassize_t dsize 88*2639ae9bSBen Gras.Ed 89*2639ae9bSBen Gras.Pp 90*2639ae9bSBen GrasA 91*2639ae9bSBen Gras.Fa datum 92*2639ae9bSBen Grasis thus given by 93*2639ae9bSBen Gras.Fa dptr 94*2639ae9bSBen Graspointing at an object of 95*2639ae9bSBen Gras.Fa dsize 96*2639ae9bSBen Grasbytes in length. 97*2639ae9bSBen Gras.Pp 98*2639ae9bSBen GrasThe 99*2639ae9bSBen Gras.Fn dbm_open 100*2639ae9bSBen Grasfunction opens a database. 101*2639ae9bSBen GrasThe 102*2639ae9bSBen Gras.Fa file 103*2639ae9bSBen Grasargument is the pathname which the actual database file pathname 104*2639ae9bSBen Grasis based on. 105*2639ae9bSBen GrasThis implementation uses a single file with the suffix 106*2639ae9bSBen Gras.Pa .db 107*2639ae9bSBen Grasappended to 108*2639ae9bSBen Gras.Fa file . 109*2639ae9bSBen GrasThe 110*2639ae9bSBen Gras.Fa open_flags 111*2639ae9bSBen Grasargument has the same meaning as the 112*2639ae9bSBen Gras.Fa flags 113*2639ae9bSBen Grasargument to 114*2639ae9bSBen Gras.Xr open 2 115*2639ae9bSBen Grasexcept that when opening a database for write-only access the file 116*2639ae9bSBen Grasis opened for read/write access, and the 117*2639ae9bSBen Gras.Dv O_APPEND 118*2639ae9bSBen Grasflag must not be specified. 119*2639ae9bSBen GrasThe 120*2639ae9bSBen Gras.Fa file_mode 121*2639ae9bSBen Grasargument has the same meaning as the 122*2639ae9bSBen Gras.Fa mode 123*2639ae9bSBen Grasargument to 124*2639ae9bSBen Gras.Xr open 2 . 125*2639ae9bSBen Gras.Pp 126*2639ae9bSBen GrasFor the following functions, the 127*2639ae9bSBen Gras.Fa db 128*2639ae9bSBen Grasargument is a handle previously returned by a call to 129*2639ae9bSBen Gras.Fn dbm_open . 130*2639ae9bSBen Gras.Pp 131*2639ae9bSBen GrasThe 132*2639ae9bSBen Gras.Fn dbm_close 133*2639ae9bSBen Grasfunction closes a database. 134*2639ae9bSBen Gras.Pp 135*2639ae9bSBen GrasThe 136*2639ae9bSBen Gras.Fn dbm_fetch 137*2639ae9bSBen Grasfunction retrieves a record from the database. 138*2639ae9bSBen GrasThe 139*2639ae9bSBen Gras.Fa key 140*2639ae9bSBen Grasargument is a 141*2639ae9bSBen Gras.Fa datum 142*2639ae9bSBen Grasthat identifies the record to be fetched. 143*2639ae9bSBen Gras.Pp 144*2639ae9bSBen GrasThe 145*2639ae9bSBen Gras.Fn dbm_store 146*2639ae9bSBen Grasfunction stores a record into the database. 147*2639ae9bSBen GrasThe 148*2639ae9bSBen Gras.Fa key 149*2639ae9bSBen Grasargument is a 150*2639ae9bSBen Gras.Fa datum 151*2639ae9bSBen Grasthat identifies the record to be stored. 152*2639ae9bSBen GrasThe 153*2639ae9bSBen Gras.Fa content 154*2639ae9bSBen Grasargument is a 155*2639ae9bSBen Gras.Fa datum 156*2639ae9bSBen Grasthat specifies the value of the record to be stored. 157*2639ae9bSBen GrasThe 158*2639ae9bSBen Gras.Fa store_mode 159*2639ae9bSBen Grasargument specifies the behavior of 160*2639ae9bSBen Gras.Fn dbm_store 161*2639ae9bSBen Grasif a record matching 162*2639ae9bSBen Gras.Fa key 163*2639ae9bSBen Grasis already present in the database, 164*2639ae9bSBen Gras.Fa db . 165*2639ae9bSBen Gras.Fa store_mode 166*2639ae9bSBen Grasmust be one of the following: 167*2639ae9bSBen Gras.Bl -tag -width DBM_REPLACEXX -offset indent 168*2639ae9bSBen Gras.It Dv DBM_INSERT 169*2639ae9bSBen GrasIf a record matching 170*2639ae9bSBen Gras.Fa key 171*2639ae9bSBen Grasis already present, it is left unchanged. 172*2639ae9bSBen Gras.It Dv DBM_REPLACE 173*2639ae9bSBen GrasIf a record matching 174*2639ae9bSBen Gras.Fa key 175*2639ae9bSBen Grasis already present, its value is replaced by 176*2639ae9bSBen Gras.Fa content . 177*2639ae9bSBen Gras.El 178*2639ae9bSBen Gras.Pp 179*2639ae9bSBen GrasIf no record matching 180*2639ae9bSBen Gras.Fa key 181*2639ae9bSBen Grasis present, a new record is inserted regardless of 182*2639ae9bSBen Gras.Fa store_mode . 183*2639ae9bSBen Gras.Pp 184*2639ae9bSBen GrasThe 185*2639ae9bSBen Gras.Fn dbm_delete 186*2639ae9bSBen Grasfunction deletes a record from the database. 187*2639ae9bSBen GrasThe 188*2639ae9bSBen Gras.Fa key 189*2639ae9bSBen Grasargument is a 190*2639ae9bSBen Gras.Fa datum 191*2639ae9bSBen Grasthat identifies the record to be deleted. 192*2639ae9bSBen Gras.Pp 193*2639ae9bSBen GrasThe 194*2639ae9bSBen Gras.Fn dbm_firstkey 195*2639ae9bSBen Grasfunction returns the first key in the database. 196*2639ae9bSBen Gras.Pp 197*2639ae9bSBen GrasThe 198*2639ae9bSBen Gras.Fn dbm_nextkey 199*2639ae9bSBen Grasfunction returns the next key in the database. 200*2639ae9bSBen GrasIn order to be meaningful, it must be preceded by a call to 201*2639ae9bSBen Gras.Fn dbm_firstkey . 202*2639ae9bSBen Gras.Pp 203*2639ae9bSBen GrasThe 204*2639ae9bSBen Gras.Fn dbm_error 205*2639ae9bSBen Grasfunction returns the error indicator of the database. 206*2639ae9bSBen Gras.Pp 207*2639ae9bSBen GrasThe 208*2639ae9bSBen Gras.Fn dbm_clearerr 209*2639ae9bSBen Grasfunction clears the error indicator of the database. 210*2639ae9bSBen Gras.Pp 211*2639ae9bSBen GrasThe 212*2639ae9bSBen Gras.Fn dbm_dirfno 213*2639ae9bSBen Grasfunction returns the file descriptor of the underlying database file. 214*2639ae9bSBen Gras.Sh IMPLEMENTATION NOTES 215*2639ae9bSBen GrasThe 216*2639ae9bSBen Gras.Nm ndbm 217*2639ae9bSBen Grasfacility is implemented on top of the 218*2639ae9bSBen Gras.Xr hash 3 219*2639ae9bSBen Grasaccess method of the 220*2639ae9bSBen Gras.Xr db 3 221*2639ae9bSBen Grasdatabase facility. 222*2639ae9bSBen Gras.Sh RETURN VALUES 223*2639ae9bSBen GrasThe 224*2639ae9bSBen Gras.Fn dbm_open 225*2639ae9bSBen Grasfunction returns a pointer to a 226*2639ae9bSBen Gras.Fa DBM 227*2639ae9bSBen Graswhen successful; otherwise a null pointer is returned. 228*2639ae9bSBen Gras.Pp 229*2639ae9bSBen GrasThe 230*2639ae9bSBen Gras.Fn dbm_close 231*2639ae9bSBen Grasfunction returns no value. 232*2639ae9bSBen Gras.Pp 233*2639ae9bSBen GrasThe 234*2639ae9bSBen Gras.Fn dbm_fetch 235*2639ae9bSBen Grasfunction returns a content 236*2639ae9bSBen Gras.Fa datum ; 237*2639ae9bSBen Grasif no record matching 238*2639ae9bSBen Gras.Fa key 239*2639ae9bSBen Graswas found or if an error occured, its 240*2639ae9bSBen Gras.Fa dptr 241*2639ae9bSBen Grasmember is a null pointer. 242*2639ae9bSBen Gras.Pp 243*2639ae9bSBen GrasThe 244*2639ae9bSBen Gras.Fn dbm_store 245*2639ae9bSBen Grasfunction returns 0 when then record was successfully inserted; 246*2639ae9bSBen Grasit returns 1 when called with 247*2639ae9bSBen Gras.Fa store_mode 248*2639ae9bSBen Grasbeing 249*2639ae9bSBen Gras.Dv DBM_INSERT 250*2639ae9bSBen Grasand a record matching 251*2639ae9bSBen Gras.Fa key 252*2639ae9bSBen Grasis already present; 253*2639ae9bSBen Grasotherwise a negative value is returned. 254*2639ae9bSBen Gras.Pp 255*2639ae9bSBen GrasThe 256*2639ae9bSBen Gras.Fn dbm_delete 257*2639ae9bSBen Grasfunction returns 0 when the record was successfully deleted; 258*2639ae9bSBen Grasotherwise a negative value is returned. 259*2639ae9bSBen Gras.Pp 260*2639ae9bSBen GrasThe 261*2639ae9bSBen Gras.Fn dbm_firstkey 262*2639ae9bSBen Grasand 263*2639ae9bSBen Gras.Fn dbm_nextkey 264*2639ae9bSBen Grasfunctions return a key 265*2639ae9bSBen Gras.Fa datum . 266*2639ae9bSBen GrasWhen the end of the database is reached or if an error occured, its 267*2639ae9bSBen Gras.Fa dptr 268*2639ae9bSBen Grasmember is a null pointer. 269*2639ae9bSBen Gras.Pp 270*2639ae9bSBen GrasThe 271*2639ae9bSBen Gras.Fn dbm_error 272*2639ae9bSBen Grasfunction returns 0 if the error indicator is clear; 273*2639ae9bSBen Grasif the error indicator is set a non-zero value is returned. 274*2639ae9bSBen Gras.Pp 275*2639ae9bSBen GrasThe 276*2639ae9bSBen Gras.Fn dbm_clearerr 277*2639ae9bSBen Grasfunction always returns 0. 278*2639ae9bSBen Gras.Pp 279*2639ae9bSBen GrasThe 280*2639ae9bSBen Gras.Fn dbm_dirfno 281*2639ae9bSBen Grasfunction returns the file descriptor of the underlying database file. 282*2639ae9bSBen Gras.Sh ERRORS 283*2639ae9bSBen GrasNo errors are defined. 284*2639ae9bSBen Gras.Sh SEE ALSO 285*2639ae9bSBen Gras.Xr open 2 , 286*2639ae9bSBen Gras.Xr db 3 , 287*2639ae9bSBen Gras.Xr hash 3 288*2639ae9bSBen Gras.Sh STANDARDS 289*2639ae9bSBen GrasThe 290*2639ae9bSBen Gras.Fn dbm_clearerr , 291*2639ae9bSBen Gras.Fn dbm_close , 292*2639ae9bSBen Gras.Fn dbm_delete , 293*2639ae9bSBen Gras.Fn dbm_error , 294*2639ae9bSBen Gras.Fn dbm_fetch , 295*2639ae9bSBen Gras.Fn dbm_firstkey , 296*2639ae9bSBen Gras.Fn dbm_nextkey , 297*2639ae9bSBen Gras.Fn dbm_open , 298*2639ae9bSBen Grasand 299*2639ae9bSBen Gras.Fn dbm_store 300*2639ae9bSBen Grasfunctions conform to 301*2639ae9bSBen Gras.St -xpg4.2 302*2639ae9bSBen Grasand 303*2639ae9bSBen Gras.St -susv2 . 304*2639ae9bSBen GrasThe 305*2639ae9bSBen Gras.Fn dbm_dirfno 306*2639ae9bSBen Grasfunction is an extension. 307