File: gdbm.3

package info (click to toggle)
manpages-ja 0.5.0.0.20080615-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,508 kB
  • ctags: 1
  • sloc: sh: 13,690; perl: 157; makefile: 114
file content (596 lines) | stat: -rw-r--r-- 14,976 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
.ds ve 1.8
.TH GDBM 3 5/19/99
.\" Japanese Version Copyright (c) 2000 Tsugikazu Shibata
.\"         all rights reserved.
.\" Translated Fri. August 29 23:32:00 JST 2000
.\"         by Tsugikazu Shibata <ts@tsden.org>
.SH ̾
GDBM - GNUǡ١ޥ͡㡣\fBdbm\fR  \fBndbm\fR
ߴǽޤࡣ (Version \*(ve.)

.SH 
.B #include <gdbm.h>
.PP
.SM
.B extern gdbm_error
.br
.B gdbm_errno
.PP
.B extern char
.br
.B *gdbm_version
.PP
.B GDBM_FILE
.br
.B gdbm_open (name, block_size, read_write, mode, fatal_func)
.br
.B char * name;
.br
.B int block_size, read_write, mode;
.br
.B void (*fatal_func) ();
.PP
.B void
.br
.B gdbm_close (dbf)
.br
.B GDBM_FILE dbf;
.PP
.B int
.br
.B gdbm_store (dbf, key, content, flag)
.br
.B GDBM_FILE dbf;
.br
.B datum key, content;
.br
.B int flag;
.PP
.B datum
.br
.B gdbm_fetch (dbf, key)
.br
.B GDBM_FILE dbf;
.br
.B datum key;
.PP
.B int
.br
.B gdbm_delete (dbf, key)
.br
.B GDBM_FILE dbf;
.br
.B datum key;
.PP
.B datum
.br
.B gdbm_firstkey (dbf)
.br
.B GDBM_FILE dbf;
.PP
.B datum
.br
.B gdbm_nextkey (dbf, key)
.br
.B GDBM_FILE dbf;
.br
.B datum key;
.PP
.B int
.br
.B gdbm_reorganize (dbf)
.br
.B GDBM_FILE dbf;
.PP
.B void
.br
.B gdbm_sync (dbf)
.br
.B GDBM_FILE dbf;
.PP
.B int
.br
.B gdbm_exists (dbf, key)
.br
.B GDBM_FILE dbf;
.br
.B datum key;
.PP
.B char *
.br
.B gdbm_strerror (errno)
.br
.B gdbm_error errno;
.PP
.B int
.br
.B gdbm_setopt (dbf, option, value, size)
.br
.B GDBM_FILE dbf;
.br
.B int option;
.br
.B int *value;
.br
.B int size;
.PP
.B int
.br
.B gdbm_fdesc (dbf)
.br
.B GDBM_FILE dbf;
.PP
.PP
.B DBM Compatability routines:
.PP
.B #include <dbm.h>
.PP
.SM
.B int
.br
.B dbminit (name)
.br
.B char *name;
.PP
.B int
.br
.B store (key, content)
.br
.B datum key, content;
.PP
.B datum
.br
.B fetch (key)
.br
.B datum key;
.PP
.B int
.br
.B delete (key)
.br
.B datum key;
.PP
.B datum
.br
.B firstkey ()
.PP
.B datum
.br
.B nextkey (key)
.br
.B datum key;
.PP
.B int
.br
.B dbmclose ()
.PP
.PP
.B NDBM Compatability routines:
.PP
.B #include <ndbm.h>
.PP
.SM
.B DBM
.br
.B *dbm_open (name, flags, mode)
.br
.B char *name;
.br
.B int flags, mode;
.PP
.B void
.br
.B dbm_close (file)
.br
.B DBM *file;
.PP
.B datum
.br
.B dbm_fetch (file, key)
.br
.B DBM *file;
.br
.B datum key;
.PP
.B int
.br
.B dbm_store (file, key, content, flags)
.br
.B DBM *file;
.br
.B datum key, content;
.br
.B int flags;
.PP
.B int
.br
.B dbm_delete (file, key)
.br
.B DBM *file;
.br
.B datum key;
.PP
.B datum
.br
.B dbm_firstkey (file)
.br
.B DBM *file;
.PP
.B datum
.br
.B dbm_nextkey (file)
.br
.B DBM *file;
.PP
.B int
.br
.B dbm_error (file)
.br
.B DBM *file;
.PP
.B int
.br
.B dbm_clearerr (file)
.br
.B DBM *file;
.PP
.B int
.br
.B dbm_pagfno (file)
.br
.B DBM *file;
.PP
.B int
.br
.B dbm_dirfno (file)
.br
.B DBM *file;
.PP
.B int
.br
.B dbm_rdonly (file)
.br
.B DBM *file;


.SH 
GNU dbm ϡȥǡΥڥޤǡե갷
롼󷲤Υ饤֥Ǥ롣
󶡤륢ȤƤϡˤǼˤФ
ˤ¾٤ƤΥϤ륽ȤƤʤŪ
ĤΥץʣΥǡեƱѤ뤳ȤǤ롣

gdbm ե򥪡ץ󤹤ץϡ֥꡼פޤϡ֥饤
ȸƤФ롣
1 Ĥ gdbm ե򥪡ץǤ饤 1 Ĥ
꡼ʣ 1 Ĥ gdbm ե򥪡ץ󤹤뤳ȤǤ롣

꡼ȥ饤ƱƱե򥪡ץ󤹤뤳ȤϤǤʤ
gdbm ե򥪡ץ󤹤³ϡ

  GDBM_FILE dbf;
 
   dbf = gdbm_open ( name, block_size, read_write, mode, fatal_func )

\fIname\fR ϥե̾Ǥ롣(̾gdbm Ϥ̾
ʸդä褦ʤȤϤʤ)
\fIblock_size\fR ϥǥ 1 ž륵Ǥ롣
Υѥ᡼ϡեξʳ̵뤵롣Ǿ
 512 Ǥ롣
512 ⾮ˤ, gdbm ϥե륷ƥФ stat
Υ֥åѤ롣
\fIread_write\fR ˤϰʲΤ줫ͤ롣
.br
.B GDBM_READER
.br
.B GDBM_WRITER
.br
.B GDBM_WRCREAT
饤 - ǡ١¸ߤʤк
.br
.B GDBM_NEWDB
饤 - Ǥ¸ߤƤ⿷ǡ١
.br
Ǹ 3 ĤˤĤƤ (ǡ١Υ饤) \fIread_write\fR Ф
ʲӥåȤ OR ˤɲäǤ:
.B GDBM_SYNC
Ϥ٤ƤΥǡ١ǥƱ롢ޤ
.B GDBM_NOLOCK
ϥǡ١ե˴ؤ饤֥꤫ΥåưԤʤ
ץ
.B GDBM_FAST
 gdbm δư no-sync ⡼ɤˤʤäˤ⤦Ȥʤʤä
.br
\fImode\fR ϥեΥ⡼ɤǤ (\fBchmod(2)\fR  \fBopen(2)\fR 
)\fI(*fatal_func) ()\fR  dbm ̿Ū顼򸡽Ф˸ƤӽФ
ؿǤ롣δؿؤͣΥѥ᡼ʸǤ롣
 0 ꤵȡgdbm ϥǥեȤδؿѤ롣

֤ \fIdbf\fR ϡ gdbm ե˥¾Τ٤ƤΥ롼
ɬפʥݥ󥿤Ǥ롣 NULL ݥ󥿤֤ä硢\fBgdbm_open\fR 
ʤäȤ򼨤
gdbm Υ顼  \fIgdbm_errno\fR ˡƥΥ顼 \fIerrno\fR 
˳Ǽ롣(顼ɤˤĤƤ gdbmerrno.h 򻲾)

ʲΤ٤ƤΥˤƤϡ
ѥ᡼ \fIdbf\fR  \fBgdbm_open\fR 
֤äƤݥ󥿤Ǥ롣
ɤʥեǤ⥪ץ󤷤Τ򥯥뤳ȤϽפǤ롣
ϥեФ꡼饤򹹿롣
ϰʲΤ褦ˤƹԤ

   gdbm_close (dbf);

ǡ١ 3 Ĥμʥ롼ˤäѤǤ롣ǽϥǡ
ǡ١˳ǼΤǤ롣


   ret = gdbm_store ( dbf, key, content, flag )


\fIdbf\fR  \fBgdbm_open\fR ֤äƤݥ󥿤Ǥ롣
\fIkey\fR ϥǡǡ\fIcontent\fR  \fIkey\fR ˴Ϣդ줿
ǡǤ롣
\fIflag\fR ϰʲΤ줫ͤĤȤǤ롣
.br
.B GDBM_INSERT
Τߡ¸ߤХ顼Ȥʤ롣
.br
.B GDBM_REPLACE
¸ߤƤ򹹿롣

꡼ \fBgdbm_store\fR 򥳡뤷硢֤ͤ -1 Ȥʤ롣
GDBM_INSERT ꤵ줿˥ǡ١ \fIkey\fR ¸ߤȡ
֤ͤ 1 Ǥ롣Ǥʤ֤ͤ 0 Ǥ롣

\fI: ˥ǡ١¸ߤ륭ꤷƳǼ硢
GDBM_REPLACEǸƤӽФƤʤСgdbm ϸŤǡ
ǡ֤롣
Ʊ 2 ĤΥǡƥ뤳ȤϤǤʤ
ޤ gdbm_store 顼֤Ȥʤ

: gdbm Υϡdbm  ndbm Ȱۤʤ¤ʤ
ǡɬפʤ礭뤳ȤǤ롣
\fR

ǡ򸡺ˤϡʲΤ褦ˤ:

  content = gdbm_fetch ( dbf, key )

\fIdbf\fR  \fBgdbm_open\fR ֤äƤݥ󥿤Ǥ롣
\fIkey\fR ϥǡǤ롣

֤ͤ \fIdptr\fR  NULL ξ硢ǡϸĤʤä
ĤäϥǡؤΥݥ󥿤֤롣
\fIdptr\fR ε֤ \fBmalloc(3C)\fR ˤݤ롣 
\fBgdbm\fI ϼưŪˤΥǡ뤳ȤϤʤ
ɬפ̵ʤäΰΤϥץޤǤǤ롣\fR

ǡ򻲾Ȥˡˤϡ

   ret = gdbm_exists ( dbf, key )

\fIdbf\fR  \fBgdbm_open\fR ֤äƤݥ󥿤Ǥ롣
\fIkey\fR ϸǡǤ롣

ǡ١ \fIkey\fR ĤС֤ \fIret\fR  true Ǥ롣
.\" If nothing appropiate is found, \fIret\fR will be false.
бΤĤʤ \fIret\fR  false Ǥ롣

\fBgdbm_fetch\fR ǤϥݤԤ뤬Υ롼Ϥ򤷤ʤ
Τǡ쥳ɤ¸ߤå򤹤Ωġ

ǡ١餢ǡϡʲΤ褦ˤ:

   ret = gdbm_delete ( dbf, key )

\fIdbf\fR  \fBgdbm_open\fR ֤äƤݥ󥿤Ǥ롣\fIkey\fR 
ǡǤ롣

ƥब¸ߤʤäꡢ׵ᤷΤ꡼ä硢
֤ͤ -1 Ǥ롣
֤ͤ 0 Ǥ롣

 2 ĤΥ롼ϡǡ١Τ٤ƤΥƥ˥Ǥ롣
ϥǤϤʤǡ١Ǥ٤ƤΥ˳ 1 
뤳ȤݾڤƤ롣(ϥϥåͤνˤʤ롣)

   key = gdbm_firstkey ( dbf )

   nextkey = gdbm_nextkey ( dbf, key )

\fIdbf\fR  \fBgdbm_open\fR ֤äƤݥ󥿤Ǥ롣\fIkey\fR 
ǡǤ롣

֤ͤϤɤ \fBdatum\fR Ǥ롣֤ͤ \fIdptr\fR Ǥ NULL
ξ硢ǽΥޤϼΥʤäȤ򼨤
֤ͤ \fIdptr\fR ǤؤƤΤ \fBmalloc(3C)\fR
ˤݤ줿ǡǤꡢ\fBgdbm\fR  free ƤϤʤȤ
⤦դ뤳ȡ

δؿϥǡ١꡼ɥ꡼ǻȤ뤳ȤտޤƤ
ȤСǡ١ǧꤹ褦Ūǡ

եؤΡֻȡפϡ֥ϥå塦ơ֥פ˴ŤƤ롣
\fIgdbm_delete\fR ϥϥå塦ơ֥ƹơָĤ뤳ȤΤʤ
ƥबơ֥֤ʤ褦ˡ٤Ƥζǧ롣
٤ƤΥǡμΤѹäʤäȤƤ⡢ꥸʥΥ
ݾڤʤ

.\" 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;
    }


ʲΥ롼Ϸ֤Ȥ٤ǤϤʤ


   ret = gdbm_reorganize ( dbf )

⤷ʤκԤ\fBgdbm\fR ե뤬ȤäƤ
ڡ򾮤ȻפʤСΥ롼ϥǡ١κƹԤ
\fBgdbm\fR Ϥκƹʳ \fBgdbm\fR ȤäƤե礭
뤳Ȥ̵(줿ڡϺѤ)

ǡ١ GDBM_SYNC ե饰դ open ʤ¤ꡢgdbm ϼư
³ˡwrite ǥ˥եå夹ΤԤĤ褦ʤȤϤʤ
Υ롼ϥǡ١ʪŪ˥ǥ˽񤭽ФȤݾڤ롣

   gdbm_sync ( dbf )

ϥᥤξ֤ǥξ֤ƱޤǤäʤ

\fBgdbm\fR Υ顼ɤʸΥƥȤѴˤϡΥ롼
Ѥ롣

   ret = gdbm_strerror ( errno )


 \fIerrno\fR  \fIgdbm_error\fR Ǥꡢ̾ϥХѿ
 \fIgdbm_errno\fR Ǥ롣бե졼֤äƤ롣

\fBgdbm\fR ϴ open ƤեФ륪ץǤ
ǽ򥵥ݡȤƤ롣

   ret = gdbm_setopt ( dbf, option, value, size )

ǡ\fIdbf\fR ľ \fBgdbm_open\fR ֤ͤǤꡢ
\fIoption\fR ꤷץꤹ롣ߤץϡ

\fBGDBM_CACHESIZE\fR -  bucket åΥꤹ롣
Υץ \fIGDBM_FILE\fR Υǥץ˰٤Ǥ
ǡ١κǽΥ˼ưŪ 100 ꤵ롣

\fBGDBM_FASTMODE\fR - \fBfast mode\fR  on, off ꤹ롣
\fBfast mode\fR ϤǤ˥ץ󤵤Ƥơƥ֤ʥǡ١
Фƥȥ (on, off) Ǥ롣\fIvalue\fR (ʲ)  TRUE  FALSE 
Ǥ롣ΥץϤ⤦Ȥʤ

\fBGDBM_SYNCMODE\fR - ե륷ƥƱ on, off 롣
ΥǥեȤ off Ǥ롣\fIvalue\fR (ʲ)  TRUE  FALSE 
ꤹ롣

\fBGDBM_CENTFREE\fR - \fBcentral ե꡼֥åס\fR  on, off 롣
ǥեȤ off ǤꡢϰΥС \fBgdbm\fR Υե꡼
֥åμ갷ƱǤ롣⤷ꤵȡΥץϤ
θϥե꡼֥åϥХסˤ졢(Ūˤ) ¿
ե륹ڡ᤯Ѥ褦ˤʤ롣
\fIvalue\fR (ʲ)  TRUE  FALSE ꤹ٤Ǥ롣
աεǽϤޤƤǤ롣

\fBGDBM_COALESCEBLKS\fR - ե꡼֥åޡ󥰤 on, off 
롣ǥեȤ off ΥС \fBgdbm\fR Υե꡼֥å
ΰƱǤ롣⤷ꤵȤΥץϡնˤե꡼
֥åޡ롣 ä\fBGDBM_CENTFREE\fR Ȱ˻Ȥ줿
ȤƤ ֤ CPU Τˤʤ롣\fIvalue\fR (ʲ)  TRUE 
 FALSE ꤹ٤Ǥ롣
աεǽϤޤƤǤ롣

\fIvalue\fR  \fIoption\fR ꤹͤǤꡢinteger ؤΥݥ
Ǥ롣 \fIsize\fR  \fIvalue\fR ˤäƥݥȤǡ
Ǥ롣֤ͤ Ԥ -1 ˤʤꡢ 0 ˤʤ롣
Ԥξ硢Хѿ \fIgdbm_errno\fR ˤͤꤵ롣

㤨С\fBgdbm_open\fR ǥץ󤷤ǡ١򥢥ˡ
åȤ 10 Ȥ褦ꤹ硢ʲΥɤѤǤ롧

   int value = 10;

   ret = gdbm_setopt( dbf, GDBM_CACHESIZE, &value, sizeof(int));


⤷ǡ١ \fBGDBM_NOLOCK\fR ե饰դǥץ󤵤줿硢
桼ϥǡ١Фơ㤨ʣΥ饤ƱΥե
ФƹԤ褦ʡʬȼΥեå󥰤ȤȤǤ롢

򥵥ݡȤ뤿ᡢ\fIgdbm_fdesc\fR 롼󶡤롣

   ret = gdbm_fdesc ( dbf )

  \fIdbf\fR ϰ \fBgdbm_open\fR ֤ͤǤ롣
֤ͤϥǡ١ΥեǥץǤ롣


ʲ 2 ĤγѿΩĤȤ
\fIgdbm_errno\fR  gdbm Υ顼˴ؤܤġ
(gdbm.h ϥ顼ͤ gdbm_errno ѿȤ)
.br
\fIgdbm_version\fR ϥСʸġ


⤦̣ȤĤ롣ޤ \fBgdbm\fR ϡַ֤Τ
եǤ̵ȤȤǤ롣ʤϤΥե UNIX 
\fBcp(1)\fR ޥɤˤäƥԡ뤳ȤǽǡΥԡδ
˥ե륵ĥ褦ʤȤϤʤˡUNIX ǤǤ˻
Ƥ \fBdbm\fR Υѥ֥⡼ɤ¸ߤ롣Υѥ֥
⡼ɤǤϡ\fRgdbm\fR Υեݥ󥿤ϥץޤ˼äɬפǤ
ʤ٤ˤ 1 ĤΥեץ󤵤롣ѥ֥⡼
ƤѼԤϥ饤ȸʤ롣⤷\fBgdbm\fR ե뤬꡼
꡼ʤС饤ȤƤϼԤ꡼Ȥƥץľ
ߤ롣datum ¤ΤΤ٤ƤΥݥ󥿤ϡ\fBgdbm\fR Ǥ
ǡؤ (ɸŪ UNIX \fBdbm\fR 褦) 
Ūݥ󥿤Ȥưɬפ롣



.SH 
Υ饤֥ϥѥԤκǸΥѥ᡼Ȥ \fI-lgdbm\fR 
ꤹ뤳ȤѤ롣

.sp
	gcc -o prog prog.c -lgdbm
.SH Х


.SH Ϣ
dbm, ndbm

.SH 

by Philip A. Nelson and Jason Downs.
Copyright (C) 1990 - 1999 Free Software Foundation, Inc.
 
GDBM is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
 
GDBM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with GDBM; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
You may contact the original author by:
.br
   e-mail:  phil@cs.wwu.edu
.br
  us-mail:  Philip A. Nelson
.br
Computer Science Department
.br
Western Washington University
.br
Bellingham, WA 98226
 
You may contact the current maintainer by:
.br
   e-mail:  downsj@downsj.com